diff --git a/phpBB/adm/admin_database.php b/phpBB/adm/admin_database.php deleted file mode 100644 index ca4cf7db9b..0000000000 --- a/phpBB/adm/admin_database.php +++ /dev/null @@ -1,994 +0,0 @@ -acl_get('a_backup')) ? $filename . "$SID&mode=backup" : ''; - - $file_uploads = @ini_get('file_uploads'); - if (!empty($file_uploads) && $file_uploads !== 0 && strtolower($file_uploads) != 'off' && $auth->acl_get('a_restore')) - { - $module['DB']['DB_RESTORE'] = "$filename$SID&mode=restore"; - } - - return; -} - -define('IN_PHPBB', 1); -// Load default header -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); -include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - -@set_time_limit(1200); - - -// Get some vars -$mode = (isset($_GET['mode'])) ? htmlspecialchars($_GET['mode']) : ''; -$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : ''; - - -// -------------------- -// Begin program proper -// -------------------- -switch($mode) -{ - case 'backup': - if (!$auth->acl_get('a_backup')) - { - trigger_error($user->lang['NO_ADMIN']); - } - - $db_type = ''; - switch (SQL_LAYER) - { - case 'oracle': - $db_type = 'Oracle'; - break; - case 'odbc': - $db_type = 'ODBC'; - break; - case 'mssql': - $db_type = 'MSSQL'; - break; - } - - if ($db_type) - { - trigger_error($user->lang['Backups_not_supported']); - } - - $additional_tables = (isset($_REQUEST['tables'])) ? htmlspecialchars($_REQUEST['tables']) : ''; - $backup_type = (isset($_REQUEST['type'])) ? intval($_REQUEST['type']) : false; - $search = (!empty($_REQUEST['search'])) ? true : false; - $store = (!empty($_REQUEST['store'])) ? true : false; - $compress = (isset($_REQUEST['compress'])) ? htmlspecialchars($_REQUEST['compress']) : ''; - - if (!isset($_POST['backupstart']) && !isset($_GET['backupstart'])) - { - adm_page_header($user->lang['DB_BACKUP']); - -?> - -
lang['Backup_explain']; ?>
- - - -"; - - $message = (empty($store_path)) ? $user->lang['Backup_download'] : $user->lang['Backup_writing']; - - adm_page_header($user->lang['DB_Backup'], $meta); - page_message($user->lang['DB_Backup'], $message); - adm_page_footer(); - } - - $tables = (SQL_LAYER != 'postgresql') ? mysql_get_tables() : pg_get_tables(); - @sort($tables); - - if (!empty($additional_tables)) - { - $additional_tables = explode(',', $additional_tables); - - for($i = 0; $i < count($additional_tables); $i++) - { - $tables[] = trim($additional_tables[$i]); - } - unset($additional_tables); - } - - // Enable output buffering - @ob_start(); - @ob_implicit_flush(0); - - // Build the sql script file... - echo "#\n"; - echo "# phpBB Backup Script\n"; - echo "# Dump of tables for $dbname\n"; - echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; - echo "#\n"; - - if (SQL_LAYER == 'postgresql') - { - echo "\n" . pg_get_sequences("\n", $backup_type); - } - - for($i = 0; $i < count($tables); $i++) - { - $table_name = $tables[$i]; - - if (SQL_LAYER != 'mysql4') - { - $table_def_function = "get_table_def_" . SQL_LAYER; - $table_content_function = "get_table_content_" . SQL_LAYER; - } - else - { - $table_def_function = "get_table_def_mysql"; - $table_content_function = "get_table_content_mysql"; - } - - if ($backup_type != 'data') - { - echo "#\n# TABLE: " . $table_name . "\n#\n"; - echo $table_def_function($table_name, "\n") . "\n"; - } - - if ($backup_type != 'structure') - { - // - // Skip search table data? - // - if ($search || (!$search && !preg_match('/search_word/', $table_name))) - { - $table_content_function($table_name, "output_table_content"); - } - } - } - - // Flush the buffer, send the file - switch ($compress) - {/* - case 'gzip': - $extension = 'sql.gz'; - $contents = gzencode(ob_get_contents()); - ob_end_clean(); - break; - - case 'zip': - $extension = 'zip'; - $zip = new zipfile; - $zip->add_file(ob_get_contents(), "phpbb_db_backup.sql", time()); - ob_end_clean(); - $contents = $zip->file(); - break; - - case 'bzip': - $extension = 'bz2'; - $contents = bzcompress(ob_get_contents()); - ob_end_clean(); - break;*/ - - default: - $extension = 'sql'; - $contents = ob_get_contents(); - ob_end_clean(); - } - - add_log('admin', 'log_db_backup'); - - if (empty($store_path)) - { - header("Pragma: no-cache"); - header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.$extension\""); - header("Content-disposition: attachment; filename=phpbb_db_backup.$extension"); - - echo $contents; - unset($contents); - } - else - { - if (!($fp = fopen('./../' . $store_path . "/phpbb_db_backup.$extension", 'wb'))) - { - message_die(ERROR, 'Could not open backup file'); - } - - if (!fwrite($fp, $contents)) - { - message_die(ERROR, 'Could not write backup file content'); - } - - fclose($fp); - unset($contents); - - trigger_error($user->lang['Backup_success']); - } - - exit; - break; - - case 'restore': - if (!$auth->acl_get('a_restore')) - { - trigger_error($user->lang['NO_ADMIN']); - } - - if (isset($_POST['restorestart'])) - { - // Handle the file upload .... - // If no file was uploaded report an error... - if (!empty($_POST['local'])) - { - $file_tmpname = './../' . str_replace('\\\\', '/', $_POST['local']); - $filename = substr($file_tmpname, strrpos($file_tmpname, '/')); - } - else - { - $filename = (!empty($_POST['backup_file']['name'])) ? $HTTP_POST_FILES['backup_file']['name'] : ''; - $file_tmpname = ($HTTP_POST_FILES['backup_file']['tmp_name'] != 'none') ? $HTTP_POST_FILES['backup_file']['tmp_name'] : ''; - } - - if ($file_tmpname == '' || $filename == '' || !file_exists($file_tmpname)) - { - trigger_error($user->lang['Restore_Error_no_file']); - } - - $ext = substr($filename, strrpos($filename, '.') + 1); - - if (!preg_match('/^(sql|gz|bz2)$/', $ext)) - { - trigger_error($user->lang['Restore_Error_filename']); - } - - if ((!extension_loaded('zlib') && $ext == 'gz') || (!extension_loaded('zip') && $ext == 'zip') || ($ext == 'bz2' && !extension_loaded('bz2'))) - { - trigger_error($user->lang['Compress_unsupported']); - } - - $sql_query = ''; - switch ($ext) - { - case 'gz': - $fp = gzopen($file_tmpname, 'rb'); - while (!gzeof($fp)) - { - $sql_query .= gzgets($fp, 100000); - } - gzclose($fp); - break; - - case 'bz2': - $sql_query = bzdecompress(fread(fopen($file_tmpname, 'rb'), filesize($file_tmpname))); - break; - - case 'zip': - - - default; - $sql_query = fread(fopen($file_tmpname, 'r'), filesize($file_tmpname)); - } - - if ($sql_query != '') - { - // Strip out sql comments... - remove_remarks($sql_query); - $pieces = split_sql_file($sql_query, ';'); - - $sql_count = count($pieces); - for($i = 0; $i < $sql_count; $i++) - { - $sql = trim($pieces[$i]); - - if (!empty($sql) && $sql[0] != '#') - { - $db->sql_query($sql); - } - } - } - - add_log('admin', 'log_db_restore'); - - trigger_error($user->lang['Restore_success']); - } - - // - // Restore page - // - adm_page_header($user->lang['DB_RESTORE']); - -?> - -lang['Restore_explain']; ?>
- - - -lang['No_admin']); - exit; - -} - -adm_page_footer(); - -// ----------------------------------------------- -// Begin Functions -// - -// -// Table defns (not from phpMyAdmin) -// -function mysql_get_tables() -{ - global $db, $table_prefix; - - $tables = array(); - - $result = mysql_list_tables($db->dbname, $db->db_connect_id); - if ($row = $db->sql_fetchrow($result)) - { - do - { - if (preg_match('/^' . $table_prefix . '/', $row[0])) - { - $tables[] = $row[0]; - } - } - while ($row = $db->sql_fetchrow($result)); - } - - return $tables; -} - -// -// The following functions are adapted from phpMyAdmin and upgrade_20.php -// -// This function is used for grabbing the sequences for postgres... -// -function pg_get_sequences($crlf, $backup_type) -{ - global $db; - - $get_seq_sql = "SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' - AND relkind = 'S' ORDER BY relname"; - - $seq = $db->sql_query($get_seq_sql); - - if (!$num_seq = $db->sql_numrows($seq)) - { - - $return_val = "# No Sequences Found $crlf"; - - } - else - { - $return_val = "# Sequences $crlf"; - $i_seq = 0; - - while($i_seq < $num_seq) - { - $row = $db->sql_fetchrow($seq); - $sequence = $row['relname']; - - $get_props_sql = "SELECT * FROM $sequence"; - $seq_props = $db->sql_query($get_props_sql); - - if ($db->sql_numrows($seq_props) > 0) - { - $row1 = $db->sql_fetchrow($seq_props); - - if ($backup_type == 'structure') - { - $row['last_value'] = 1; - } - - $return_val .= "CREATE SEQUENCE $sequence start " . $row['last_value'] . ' increment ' . $row['increment_by'] . ' maxvalue ' . $row['max_value'] . ' minvalue ' . $row['min_value'] . ' cache ' . $row['cache_value'] . "; $crlf"; - - } // End if numrows > 0 - - if (($row['last_value'] > 1) && ($backup_type != 'structure')) - { - $return_val .= "SELECT NEXTVALE('$sequence'); $crlf"; - unset($row['last_value']); - } - - $i_seq++; - - } // End while.. - - } // End else... - - return $returnval; - -} // End function... - -// -// The following functions will return the "CREATE TABLE syntax for the -// varying DBMS's -// -// This function returns, will return the table def's for postgres... -// -function get_table_def_postgresql($table, $crlf) -{ - global $db; - - $schema_create = ""; - // - // Get a listing of the fields, with their associated types, etc. - // - - $field_query = "SELECT a.attnum, a.attname AS field, t.typname as type, a.attlen AS length, a.atttypmod as lengthvar, a.attnotnull as notnull - FROM pg_class c, pg_attribute a, pg_type t - WHERE c.relname = '$table' - AND a.attnum > 0 - AND a.attrelid = c.oid - AND a.atttypid = t.oid - ORDER BY a.attnum"; - $result = $db->sql_query($field_query); - - if (!$result) - { - message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query); - } // end if.. - - $schema_create .= "DROP TABLE $table;$crlf"; - - // - // Ok now we actually start building the SQL statements to restore the tables - // - - $schema_create .= "CREATE TABLE $table($crlf"; - - while ($row = $db->sql_fetchrow($result)) - { - // - // Get the data from the table - // - $sql_get_default = "SELECT d.adsrc AS rowdefault - FROM pg_attrdef d, pg_class c - WHERE (c.relname = '$table') - AND (c.oid = d.adrelid) - AND d.adnum = " . $row['attnum']; - $def_res = $db->sql_query($sql_get_default); - - if (!$def_res) - { - unset($row['rowdefault']); - } - else - { - $row['rowdefault'] = @pg_result($def_res, 0, 'rowdefault'); - } - - if ($row['type'] == 'bpchar') - { - // Internally stored as bpchar, but isn't accepted in a CREATE TABLE statement. - $row['type'] = 'char'; - } - - $schema_create .= ' ' . $row['field'] . ' ' . $row['type']; - - if (eregi('char', $row['type'])) - { - if ($row['lengthvar'] > 0) - { - $schema_create .= '(' . ($row['lengthvar'] -4) . ')'; - } - } - - if (eregi('numeric', $row['type'])) - { - $schema_create .= '('; - $schema_create .= sprintf("%s,%s", (($row['lengthvar'] >> 16) & 0xffff), (($row['lengthvar'] - 4) & 0xffff)); - $schema_create .= ')'; - } - - if (!empty($row['rowdefault'])) - { - $schema_create .= ' DEFAULT ' . $row['rowdefault']; - } - - if ($row['notnull'] == 't') - { - $schema_create .= ' NOT NULL'; - } - - $schema_create .= ",$crlf"; - - } - // - // Get the listing of primary keys. - // - - $sql_pri_keys = "SELECT ic.relname AS index_name, bc.relname AS tab_name, ta.attname AS column_name, i.indisunique AS unique_key, i.indisprimary AS primary_key - FROM pg_class bc, pg_class ic, pg_index i, pg_attribute ta, pg_attribute ia - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (ia.attrelid = i.indexrelid) - AND (ta.attrelid = bc.oid) - AND (bc.relname = '$table') - AND (ta.attrelid = i.indrelid) - AND (ta.attnum = i.indkey[ia.attnum-1]) - ORDER BY index_name, tab_name, column_name "; - $result = $db->sql_query($sql_pri_keys); - - if (!$result) - { - message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_pri_keys); - } - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['primary_key'] == 't') - { - if (!empty($primary_key)) - { - $primary_key .= ', '; - } - - $primary_key .= $row['column_name']; - $primary_key_name = $row['index_name']; - - } - else - { - // - // We have to store this all this info because it is possible to have a multi-column key... - // we can loop through it again and build the statement - // - $index_rows[$row['index_name']]['table'] = $table; - $index_rows[$row['index_name']]['unique'] = ($row['unique_key'] == 't') ? ' UNIQUE ' : ''; - $index_rows[$row['index_name']]['column_names'] .= $row['column_name'] . ', '; - } - } - - if (!empty($index_rows)) - { - while(list($idx_name, $props) = each($index_rows)) - { - $props['column_names'] = ereg_replace(", $", "" , $props['column_names']); - $index_create .= 'CREATE ' . $props['unique'] . " INDEX $idx_name ON $table (" . $props['column_names'] . ");$crlf"; - } - } - - if (!empty($primary_key)) - { - $schema_create .= " CONSTRAINT $primary_key_name PRIMARY KEY ($primary_key),$crlf"; - } - - // - // Generate constraint clauses for CHECK constraints - // - $sql_checks = "SELECT rcname as index_name, rcsrc - FROM pg_relcheck, pg_class bc - WHERE rcrelid = bc.oid - AND bc.relname = '$table' - AND NOT EXISTS ( - SELECT * - FROM pg_relcheck as c, pg_inherits as i - WHERE i.inhrelid = pg_relcheck.rcrelid - AND c.rcname = pg_relcheck.rcname - AND c.rcsrc = pg_relcheck.rcsrc - AND c.rcrelid = i.inhparent - )"; - $result = $db->sql_query($sql_checks); - - if (!$result) - { - message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_checks); - } - - // - // Add the constraints to the sql file. - // - while ($row = $db->sql_fetchrow($result)) - { - $schema_create .= ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['rcsrc'] . ",$crlf"; - } - - $schema_create = ereg_replace(',' . $crlf . '$', '', $schema_create); - $index_create = ereg_replace(',' . $crlf . '$', '', $index_create); - - $schema_create .= "$crlf);$crlf"; - - if (!empty($index_create)) - { - $schema_create .= $index_create; - } - - // - // Ok now we've built all the sql return it to the calling function. - // - return (stripslashes($schema_create)); - -} - -// -// This function returns the "CREATE TABLE" syntax for mysql dbms... -// -function get_table_def_mysql($table, $crlf) -{ - global $db; - - $schema_create = ""; - $field_query = "SHOW FIELDS FROM $table"; - $key_query = "SHOW KEYS FROM $table"; - - // If the user has selected to drop existing tables when doing a restore. - // Then we add the statement to drop the tables.... - $schema_create .= "DROP TABLE IF EXISTS $table;$crlf"; - $schema_create .= "CREATE TABLE $table($crlf"; - - // Ok lets grab the fields... - $result = $db->sql_query($field_query); - - while ($row = $db->sql_fetchrow($result)) - { - $schema_create .= ' ' . $row['Field'] . ' ' . $row['Type']; - - if (!empty($row['Default'])) - { - $schema_create .= ' DEFAULT \'' . $row['Default'] . '\''; - } - - if ($row['Null'] != "YES") - { - $schema_create .= ' NOT NULL'; - } - - if ($row['Extra'] != "") - { - $schema_create .= ' ' . $row['Extra']; - } - - $schema_create .= ",$crlf"; - } - // - // Drop the last ',$crlf' off ;) - // - $schema_create = ereg_replace(',' . $crlf . '$', "", $schema_create); - - // - // Get any Indexed fields from the database... - // - $result = $db->sql_query($key_query); - - while($row = $db->sql_fetchrow($result)) - { - $kname = $row['Key_name']; - - if (($kname != 'PRIMARY') && ($row['Non_unique'] == 0)) - { - $kname = "UNIQUE|$kname"; - } - - if (!is_array($index[$kname])) - { - $index[$kname] = array(); - } - - $index[$kname][] = $row['Column_name']; - } - - foreach ($index as $x => $columns) - { - $schema_create .= ", $crlf"; - - if ($x == 'PRIMARY') - { - $schema_create .= ' PRIMARY KEY (' . implode($columns, ', ') . ')'; - } - elseif (substr($x,0,6) == 'UNIQUE') - { - $schema_create .= ' UNIQUE ' . substr($x,7) . ' (' . implode($columns, ', ') . ')'; - } - else - { - $schema_create .= " KEY $x (" . implode($columns, ', ') . ')'; - } - } - - $schema_create .= "$crlf);"; - - if (get_magic_quotes_runtime()) - { - return stripslashes($schema_create); - } - else - { - return $schema_create; - } - -} // End get_table_def_mysql - - -// -// This fuction will return a tables create definition to be used as an sql -// statement. -// -// -// The following functions Get the data from the tables and format it as a -// series of INSERT statements, for each different DBMS... -// After every row a custom callback function $handler gets called. -// $handler must accept one parameter ($sql_insert); -// -// -// Here is the function for postgres... -// -function get_table_content_postgresql($table, $handler) -{ - global $db; - - // Grab all of the data from current table. - $result = $db->sql_query("SELECT * FROM $table"); - - $i_num_fields = $db->sql_numfields($result); - - for ($i = 0; $i < $i_num_fields; $i++) - { - $aryType[] = $db->sql_fieldtype($i, $result); - $aryName[] = $db->sql_fieldname($i, $result); - } - - $iRec = 0; - - while ($row = $db->sql_fetchrow($result)) - { - unset($schema_vals); - unset($schema_fields); - unset($schema_insert); - - // Build the SQL statement to recreate the data. - for($i = 0; $i < $i_num_fields; $i++) - { - $strVal = $row[$aryName[$i]]; - if (preg_match('#char|text|bool#i', $aryType[$i])) - { - $strQuote = "'"; - $strEmpty = ""; - $strVal = addslashes($strVal); - } - elseif (preg_match('#date|timestamp#i', $aryType[$i])) - { - if ($empty($strVal)) - { - $strQuote = ""; - } - else - { - $strQuote = "'"; - } - } - else - { - $strQuote = ""; - $strEmpty = "NULL"; - } - - if (empty($strVal) && $strVal != "0") - { - $strVal = $strEmpty; - } - - $schema_vals .= " $strQuote$strVal$strQuote,"; - $schema_fields .= " $aryName[$i],"; - } - - $schema_vals = preg_replace('#,$#', '', $schema_vals); - $schema_vals = preg_replace('#^ #', '', $schema_vals); - $schema_fields = preg_replace('#,$#', '', $schema_fields); - $schema_fields = preg_replace('#^ #', '', $schema_fields); - - // Take the ordered fields and their associated data and build it - // into a valid sql statement to recreate that field in the data. - $schema_insert = "INSERT INTO $table ($schema_fields) VALUES($schema_vals);"; - - $handler(trim($schema_insert)); - } - - return(true); - -}// end function get_table_content_postgres... - -// -// This function is for getting the data from a mysql table. -// - -function get_table_content_mysql($table, $handler) -{ - global $db; - - // Grab the data from the table. - $result = $db->sql_query("SELECT * FROM $table"); - - // Loop through the resulting rows and build the sql statement. - $schema_insert = ""; - if ($row = $db->sql_fetchrow($result)) - { - $schema_insert = "\n#\n# Table Data for $table\n#\n"; - - $handler($schema_insert); - - do - { - $table_list = '('; - $num_fields = $db->sql_numfields($result); - // - // Grab the list of field names. - // - for ($j = 0; $j < $num_fields; $j++) - { - $table_list .= $db->sql_fieldname($j, $result) . ', '; - } - // - // Get rid of the last comma - // - $table_list = preg_replace('#, $#', '', $table_list); - $table_list .= ')'; - // - // Start building the SQL statement. - // - $schema_insert = "INSERT INTO $table $table_list VALUES("; - // - // Loop through the rows and fill in data for each column - // - for ($j = 0; $j < $num_fields; $j++) - { - if (!isset($row[$j])) - { - // - // If there is no data for the column set it to null. - // There was a problem here with an extra space causing the - // sql file not to reimport if the last column was null in - // any table. Should be fixed now :) JLH - // - $schema_insert .= ' NULL,'; - } - elseif ($row[$j] != '') - { - $schema_insert .= ' \'' . addslashes($row[$j]) . '\','; - } - else - { - $schema_insert .= '\'\','; - } - } - // - // Get rid of the the last comma. - // - $schema_insert = preg_replace('#,$#', '', $schema_insert); - $schema_insert .= ');'; - // - // Go ahead and send the insert statement to the handler function. - // - $handler(trim($schema_insert)); - } - while ($row = $db->sql_fetchrow($result)); - } - - return true; -} - -function output_table_content($content) -{ - global $tempfile; - - //fwrite($tempfile, $content . "\n"); - //$backup_sql .= $content . "\n"; - echo $content ."\n"; - return; -} -// -// End Functions -// ----------------------------------------------- - -?> \ No newline at end of file diff --git a/phpBB/adm/admin_permissions.php b/phpBB/adm/admin_permissions.php deleted file mode 100644 index e64bae1211..0000000000 --- a/phpBB/adm/admin_permissions.php +++ /dev/null @@ -1,1360 +0,0 @@ -acl_get('a_auth')) ? "$filename$SID&mode=forum" : ''; - $module['PERM']['MODERATORS'] = ($auth->acl_get('a_authmods')) ? "$filename$SID&mode=mod" : ''; - $module['PERM']['SUPER_MODERATORS'] = ($auth->acl_get('a_authmods')) ? "$filename$SID&mode=supermod" : ''; - $module['PERM']['ADMINISTRATORS'] = ($auth->acl_get('a_authadmins')) ? "$filename$SID&mode=admin" : ''; - $module['PERM']['USER_PERMS'] = ($auth->acl_get('a_authusers')) ? "$filename$SID&mode=user" : ''; - $module['PERM']['GROUP_PERMS'] = ($auth->acl_get('a_authgroups')) ? "$filename$SID&mode=group" : ''; - - return; -} - -define('IN_PHPBB', 1); -// Include files -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); - - -// Grab and set some basic parameters -// -// 'mode' determines what we're altering; administrators, users, deps, etc. -// 'submit' is used to determine what we're doing ... special format -$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; -$submode = (isset($_REQUEST['submode'])) ? htmlspecialchars($_REQUEST['submode']) : ''; -$which_mode = (!empty($submode) && $submode != $mode) ? $submode : $mode; -$submit = array_values(preg_grep('#^submit_(.*)$#i', array_keys($_REQUEST))); -$submit = (sizeof($submit)) ? substr($submit[0], strpos($submit[0], '_') + 1) : ''; - - -// Submitted setting data -// -// 'auth_settings' contains the submitted option settings assigned to options, should be an -// associative array with integer values -$auth_settings = (isset($_POST['settings'])) ? $_POST['settings'] : ''; - - -// Forum, User or Group information -// -// 'ug_type' is either user or groups used mainly for forum/admin/mod permissions -// 'ug_data' contains the list of usernames, user_id's or group_ids for the 'ug_type' -// 'forum_id' contains the list of forums, 0 is used for "All forums", can be array or scalar -$ug_type = (isset($_REQUEST['ug_type'])) ? htmlspecialchars($_REQUEST['ug_type']) : ''; -$ug_data = (isset($_POST['ug_data'])) ? $_POST['ug_data'] : ''; - -if (isset($_REQUEST['f'])) -{ - $forum_id = (is_array($_REQUEST['f'])) ? $_REQUEST['f'] : intval($_REQUEST['f']); -} - -if (!isset($forum_id[$which_mode])) -{ - $forum_id[$which_mode][] = 0; -} -$sql_forum_id = implode(', ', array_map('intval', $forum_id[$which_mode])); - -// Generate list of forum id's -$s_forum_id = ''; -foreach ($forum_id as $forum_submode => $forum_submode_ids) -{ - foreach ($forum_submode_ids as $submode_forum_id) - { - $s_forum_id .= ''; - } -} -unset($forum_submode_ids); -unset($forum_submode); -unset($submode_forum_id); - - -// Instantiate a new auth admin object in readiness -$auth_admin = new auth_admin(); - - -// What mode are we running? So we can output the correct title, explanation -// and set the sql_option_mode/acl check -switch ($mode) -{ - case 'forum': - $l_title = $user->lang['PERMISSIONS']; - $l_title_explain = $user->lang['PERMISSIONS_EXPLAIN']; - $which_acl = 'a_auth'; - $sql_option_mode = 'f'; - break; - - case 'mod': - $l_title = $user->lang['MODERATORS']; - $l_title_explain = $user->lang['MODERATORS_EXPLAIN']; - $which_acl = 'a_authmods'; - $sql_option_mode = 'm'; - break; - - case 'supermod': - $l_title = $user->lang['SUPER_MODERATORS']; - $l_title_explain = $user->lang['SUPER_MODERATORS_EXPLAIN']; - $which_acl = 'a_authmods'; - $sql_option_mode = 'm'; - break; - - case 'admin': - $l_title = $user->lang['ADMINISTRATORS']; - $l_title_explain = $user->lang['ADMINISTRATORS_EXPLAIN']; - $which_acl = 'a_authadmins'; - $sql_option_mode = 'a'; - break; - - case 'user': - $l_title = $user->lang['USER_PERMISSIONS']; - $l_title_explain = $user->lang['USER_PERMISSIONS_EXPLAIN']; - $which_acl = 'a_authusers'; - $sql_option_mode = 'u'; - break; - - case 'group': - $l_title = $user->lang['GROUP_PERMISSIONS']; - $l_title_explain = $user->lang['GROUP_PERMISSIONS_EXPLAIN']; - $which_acl = 'a_authgroups'; - $sql_option_mode = 'u'; - break; - - case 'deps': - $l_title = $user->lang['DEPENDENCIES']; - $l_title_explain = $user->lang['DEPENDENCIES_EXPLAIN']; - $which_acl = 'a_authdeps'; - break; -} - -// Permission check -if (!$auth->acl_get($which_acl)) -{ - trigger_error($user->lang['NO_ADMIN']); -} - -// Are we setting deps? If we are we need to re-run the mode match above for the -// relevant 'new' mode -if (!empty($submode)) -{ - switch ($submode) - { - case 'forum': - $l_title_explain = $user->lang['PERMISSIONS_EXPLAIN']; - $which_acl = 'a_auth'; - $sql_option_mode = 'f'; - break; - - case 'mod': - $l_title_explain = $user->lang['MODERATORS_EXPLAIN']; - $which_acl = 'a_authmods'; - $sql_option_mode = 'm'; - break; - - case 'supermod': - $l_title_explain = $user->lang['SUPER_MODERATORS_EXPLAIN']; - $which_acl = 'a_authmods'; - $sql_option_mode = 'm'; - break; - } - - // Permission check - if (!$auth->acl_get($which_acl)) - { - trigger_error($user->lang['NO_ADMIN']); - } -} - - -// Does user want to update anything? Check here to find out -// and act appropriately -switch ($submit) -{ - case 'update': - - if (sizeof($auth_settings)) - { - // Admin wants subforums to inherit permissions ... so add these - // forums to the list ... since inheritance is only available for - // forum and moderator primary modes we deal with '$forum_id[$mode]' - if (!empty($_POST['inherit'])) - { - $forum_id[$mode] = array_merge($forum_id[$mode], array_map('intval', $_POST['inherit'])); - } - - // Update the permission set ... we loop through each auth setting array - foreach ($auth_settings as $auth_submode => $auth_setting) - { - // Are any entries * ? If so we need to remove them since they - // are options the user wishes to ignore - if (in_array('*', $auth_setting)) - { - $temp = array(); - foreach ($auth_setting as $option => $setting) - { - if ($setting != '*') - { - $temp[$option] = $setting; - } - } - $auth_setting = $temp; - } - - if (sizeof($auth_setting)) - { - // Loop through all user/group ids - foreach ($ug_data as $id) - { - $auth_admin->acl_set($ug_type, $forum_id[$auth_submode], intval($id), $auth_setting); - } - } - } - - - // Do we need to recache the moderator lists? We do if the mode - // was mod or auth_settings['mod'] is a non-zero size array - if ($mode == 'mod' || (isset($auth_settings['mod']) && sizeof($auth_settings['mod']))) - { - cache_moderators(); - } - - // Remove users who are now moderators or admins from everyones foes - // list - if ($mode == 'mod' || (isset($auth_settings['mod']) && sizeof($auth_settings['mod'])) || $mode == 'admin' || (isset($auth_settings['admin']) && sizeof($auth_settings['admin']))) - { - update_foes(); - } - - // Logging ... first grab user or groupnames ... - $sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE group_id' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE user_id'; - $sql .= ' IN (' . implode(', ', array_map('intval', $ug_data)) . ')'; - $result = $db->sql_query($sql); - - $l_ug_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '' . $user->lang['G_' . $row['name']] . '' : $row['name']); - } - $db->sql_freeresult($result); - - foreach (array_keys($auth_settings) as $submode) - { - if (!in_array(0, $forum_id[$submode])) - { - // Grab the forum details if non-zero forum_id - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . " - WHERE forum_id IN ($sql_forum_id)"; - $result = $db->sql_query($sql); - - $l_forum_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name']; - } - $db->sql_freeresult($result); - - add_log('admin', 'LOG_ACL_' . strtoupper($submode) . '_ADD', $l_forum_list, $l_ug_list); - } - else - { - add_log('admin', 'LOG_ACL_' . strtoupper($submode) . '_ADD', $l_ug_list); - } - } - unset($l_ug_list); - } - unset($auth_submode); - unset($auth_setting); - - trigger_error($user->lang['AUTH_UPDATED']); - break; - - case 'delete': - - $sql = "SELECT auth_option_id - FROM " . ACL_OPTIONS_TABLE . " - WHERE auth_option LIKE '{$sql_option_mode}_%'"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $option_id_ary = array(); - do - { - $option_id_ary[] = $row['auth_option_id']; - } - while ($row = $db->sql_fetchrow($result)); - - foreach ($ug_data as $id) - { - $auth_admin->acl_delete($ug_type, $forum_id[$mode], $id, $option_id_ary); - } - unset($option_id_ary); - } - $db->sql_freeresult($result); - - - // Do we need to recache the moderator lists? We do if the mode - // was mod or auth_settings['mod'] is a non-zero size array - if ($mode == 'mod' || (isset($auth_settings['mod']) && sizeof($auth_settings['mod']))) - { - cache_moderators(); - } - - - // Logging ... first grab user or groupnames ... - $sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE group_id' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE user_id'; - $sql .= ' IN (' . implode(', ', array_map('intval', $ug_data)) . ')'; - $result = $db->sql_query($sql); - - $l_ug_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '' . $user->lang['G_' . $row['name']] . '' : $row['name']); - } - $db->sql_freeresult($result); - - - // Grab the forum details if non-zero forum_id - if (!in_array(0, $forum_id[$which_mode])) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . " - WHERE forum_id IN ($sql_forum_id)"; - $result = $db->sql_query($sql); - - $l_forum_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name']; - } - $db->sql_freeresult($result); - - add_log('admin', 'LOG_ACL_' . strtoupper($which_mode) . '_DEL', $l_forum_list, $l_ug_list); - } - else - { - add_log('admin', 'LOG_ACL_' . strtoupper($which_mode) . '_DEL', $l_ug_list); - } - - trigger_error($user->lang['AUTH_UPDATED']); - break; - - case 'presetsave': - - $holding_ary = array(); - foreach ($auth_settings[$which_mode] as $option => $setting) - { - switch ($setting) - { - case ACL_YES: - $holding_ary['yes'][] = $option; - break; - - case ACL_NO: - $holding_ary['no'][] = $option; - break; - - case ACL_UNSET: - $holding_ary['unset'][] = $option; - break; - } - } - unset($option); - unset($setting); - - $sql = array( - 'preset_user_id'=> intval($user->data['user_id']), - 'preset_type' => $sql_option_mode, - 'preset_data' => $db->sql_escape(serialize($holding_ary)) - ); - - if (!empty($_POST['presetname'])) - { - $sql['preset_name'] = $db->sql_escape($_POST['presetname']); - } - - if (!empty($_POST['presetname']) || $_POST['presetoption'] != -1) - { - $sql = ($_POST['presetoption'] == -1) ? 'INSERT INTO ' . ACL_PRESETS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql) : 'UPDATE ' . ACL_PRESETS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql) . ' WHERE preset_id =' . intval($_POST['presetoption']); - $db->sql_query($sql); - - add_log('admin', 'LOG_ACL_PRESET_ADD', $sql['preset_name']); - } - break; - - case 'presetdel': - if (!empty($_POST['presetoption'])) - { - $sql = "SELECT preset_name - FROM " . ACL_PRESETS_TABLE . " - WHERE preset_id = " . intval($_POST['presetoption']); - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sql = "DELETE FROM " . ACL_PRESETS_TABLE . " - WHERE preset_id = " . intval($_POST['presetoption']); - $db->sql_query($sql); - - add_log('admin', 'LOG_ACL_PRESET_DEL', $row['preset_name']); - unset($row); - } - break; -} -// End update - - -// Output page header -adm_page_header($l_title); - - -// First potential form ... this is for selecting forums, users -// or groups. -if (in_array($mode, array('user', 'group', 'forum', 'mod')) && empty($submit)) -{ - -?> - - - - - - - - - - - - - -lang['USERS']; ?> |
- lang['USERGROUPS']; ?> |
-
- - | - - |
- - | - |
lang['ACL_EXPLAIN']; ?>
- - - -' . $user->lang[$l_selected_forums] . ': ' . $forum_list . ''; - - unset($forum_list); - unset($l_selected_forums); - } - - // Now output the list of users or groups ... these will always exist - $l_selected_users = ($ug_type == 'user') ? ((sizeof($ug_data) == 1) ? 'SELECTED_USER' : 'SELECTED_USERS') : ((sizeof($ug_data) == 1) ? 'SELECTED_GROUP' : 'SELECTED_GROUPS'); - - echo '' . $user->lang[$l_selected_users] . ': ' . $l_ug_list . '
'; - - unset($l_selected_users); - unset($ug_data); - -?> - - - - - -lang['WARNING_EXPLAIN']; ?>
- - - - - -acl_get_list(false, array('a_', 'm_'), false) as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $user_ary) - { - $perms += $user_ary; - } - } - - if (sizeof($perms)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE zebra_id IN (' . implode(', ', $perms) . ')'; - $db->sql_query($sql); - } - unset($perms); -} -// -// FUNCTIONS -// --------- - -?> \ No newline at end of file diff --git a/phpBB/adm/admin_search.php b/phpBB/adm/admin_search.php deleted file mode 100644 index 9826c51d33..0000000000 --- a/phpBB/adm/admin_search.php +++ /dev/null @@ -1,175 +0,0 @@ -acl_get('a_search')) - { - return; - } - - $module['DB']['SEARCH_INDEX'] = basename(__FILE__) . $SID; - - return; -} - -define('IN_PHPBB', 1); -// Include files -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); -include($phpbb_root_path . 'includes/message_parser.'.$phpEx); - -// Check permissions -if (!$auth->acl_get('a_search')) -{ - trigger_error($user->lang['NO_ADMIN']); -} - -// Start indexing -if (isset($_POST['start']) || isset($_GET['batchstart'])) -{ - $batchsize = 5000; // Process this many posts per batch - $batchcount = request_var('batchcount', 1); - $batchstart = request_var('batchstart', 0); - $loopcount = 0; - - $fulltext = new fulltext_search(); - - // Search re-indexing is tough on the server ... so we'll check the load - // each loop and if we're on a 1min load of 3 or more we'll re-load the page - // and try again. No idea how well this will work in practice so we'll see ... - if (file_exists('/proc/loadavg')) - { - if ($load = @file('/proc/loadavg')) - { - list($load) = explode(' ', $load[0]); - - if ($load > 3) - { - redirect("adm/admin_search.$phpEx$SID&batchstart=$batchstart&batchcount=$batchcount", 3); - } - } - } - - if (!$batchstart) - { - // Take board offline - set_config('board_disable', 1); - - // Empty existing tables - $db->sql_query("TRUNCATE " . SEARCH_TABLE); - $db->sql_query("TRUNCATE " . SEARCH_WORD_TABLE); - $db->sql_query("TRUNCATE " . SEARCH_MATCH_TABLE); - } - - // Fetch a batch of posts_text entries - $sql = "SELECT COUNT(*) AS total, MAX(post_id) AS max_post_id, MIN(post_id) AS min_post_id - FROM " . POSTS_TABLE; - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - $totalposts = $row['total']; - $max_post_id = $row['max_post_id']; - - $batchstart = (!$batchstart) ? $row['min_post_id'] : $batchstart; - $batchend = $batchstart + $batchsize; - - $db->sql_freeresult($result); - - $sql = "SELECT * - FROM " . POSTS_TABLE . " - WHERE post_id - BETWEEN $batchstart - AND $batchend"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $fulltext->add('admin', $row['post_id'], $row['post_text'], $row['post_subject']); - } - while ($row = $db->sql_fetchrow($result)); - } - - $db->sql_freeresult($result); - - $batchcount++; - - if (($batchstart + $batchsize) < $max_post_id) - { - redirect("adm/admin_search.$phpEx$SID&batchstart=" . ($batchstart + $batchsize) . "&batchcount=$batchcount", 3); - } - else - { - set_config('board_disable', 0); - - // search tidy - $fulltext->search_tidy(); - - adm_page_header($user->lang['SEARCH_INDEX']); - -?> - -lang['SEARCH_INDEX_COMPLETE']; ?>
- -lang['SEARCH_INDEX']); - -?> - -lang['SEARCH_INDEX_CANCEL']; ?>
- -lang['SEARCH_INDEX']); - -?> - -lang['SEARCH_INDEX_EXPLAIN']; ?>
- - - - \ No newline at end of file diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php deleted file mode 100644 index 71a5058bbe..0000000000 --- a/phpBB/adm/admin_styles.php +++ /dev/null @@ -1,3377 +0,0 @@ - store in DB -> some kind of failure - -if (!empty($setmodules)) -{ - if (!$auth->acl_get('a_styles')) - { - return; - } - - $filename = basename(__FILE__); - $module['STYLE']['MANAGE_STYLE'] = "$filename$SID&mode=style"; - $module['STYLE']['MANAGE_TEMPLATE'] = "$filename$SID&mode=template"; - $module['STYLE']['MANAGE_THEME'] = "$filename$SID&mode=theme"; - $module['STYLE']['MANAGE_IMAGESET'] = "$filename$SID&mode=imageset"; - - return; -} - -define('IN_PHPBB', 1); -// Include files -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); - -// Do we have styles admin permissions? -if (!$auth->acl_get('a_styles')) -{ - trigger_error($user->lang['NO_ADMIN']); -} - - -// Get some vars -$update = (isset($_POST['update'])) ? true : false; -$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; -$id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : ''; - -if (isset($_REQUEST['action'])) -{ - $action = htmlspecialchars($_REQUEST['action']); -} -else -{ - $action = ''; - if (isset($_POST['add'])) - { - $action = 'add'; - } - else if (isset($_POST['preview'])) - { - $action = 'preview'; - } -} - -// Set some basic vars -$error = $cfg = array(); - -$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false; -$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false; - -// Generate list of archive types inc. regexp | match -$archive_types = '.tar'; -$archive_preg = '\.tar'; -foreach (array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib') as $type => $module) -{ - if (!@extension_loaded($module)) - { - continue; - } - $archive_types .= ", .$type"; - $archive_preg .= '|\.' . preg_quote($type); -} - -// -------------------- -// Start program proper -// -------------------- - -// Mode indepedent actions -switch ($action) -{ - case 'export': - if ($id) - { - export($mode, $id); - } - break; - - case 'add': - case 'install': - case 'details': - install($mode, $action, $id); - break; - - case 'delete': - if ($id) - { - remove($mode, $id); - } - break; -} - -// Mode based actions -switch ($mode) -{ - // STYLES - case 'style': - switch ($action) - { - case 'activate': - case 'deactivate': - if ($id == $config['default_style']) - { - trigger_error($user->lang['DEACTIVATE_DEFAULT']); - } - - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' - WHERE style_id = ' . $id; - $db->sql_query($sql); - - // Set style to default for any member using deactivated style - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . $config['default_style'] . " - WHERE user_style = $id"; - $db->sql_query($sql); - break; - } - - frontend('style', array('delete', 'export')); - break; - - - // TEMPLATES - case 'template': - $tpllist = array( - 'misc' => array( - 'confirm_body.html', 'faq_body.html', 'index_body.html', 'message_body.html', 'viewonline_body.html', - ), - 'includes' => array( - 'overall_footer.html', 'overall_header.html', 'simple_footer.html', 'simple_header.html', 'searchbox.html', 'jumpbox.html', - ), - 'forum' => array( - 'viewforum_body.html', 'viewforum_subforum.html', - ), - 'topic' => array( - 'attachment.html', 'viewtopic_body.html', 'viewtopic_print.html', - ), - 'group' => array( - 'gcp_body.html', 'gcp_pending_info.html', 'gcp_user_body.html', - ), - 'user' => array( - 'ucp_agreement.html', 'ucp_footer.html', 'ucp_header.html', 'ucp_main.html', 'ucp_pm_body.html', 'ucp_pm_popup.html', 'ucp_pm_preview.html', 'ucp_pm_read.html', 'ucp_prefs.html', 'ucp_profile.html', 'ucp_register.html', 'ucp_remind.html', - ), - 'profile' => array( - 'memberlist_body.html', 'memberlist_email.html', 'memberlist_im.html', 'memberlist_view.html', - ), - 'mod' => array( - 'mcp_forum.html', 'mcp_foruminfo.html', 'mcp_front.html', 'mcp_header.html', 'mcp_jumpbox.html', 'mcp_move.html', 'mcp_post.html', 'mcp_queue.html', 'mcp_reports.html', 'mcp_topic.html', 'mcp_viewlogs.html', 'report_body.html', - ), - 'search' => array( - 'search_body.html', 'search_results_posts.html', 'search_results_topics.html', - ), - 'posting' => array( - 'posting_attach_body.html', 'posting_body.html', 'posting_poll_body.html', 'posting_preview.html', 'posting_smilies.html', 'posting_topic_review.html', - ), - 'login' => array( - 'login_body.html', 'login_forum.html', - ), - 'custom' => array(), - ); - - // Lights, Camera ... - switch ($action) - { - case 'edit': - $tplcols = (isset($_POST['tplcols'])) ? max(20, intval($_POST['tplcols'])) : 80; - $tplrows = (isset($_POST['tplrows'])) ? max(5, intval($_POST['tplrows'])) : 20; - $tplname = (isset($_POST['tplname'])) ? htmlspecialchars($_POST['tplname']) : ''; - $tpldata = (!empty($_POST['tpldata'])) ? stripslashes($_POST['tpldata']) : ''; // NB : STRIPSLASHED! - - if ($id) - { - $sql = 'SELECT * - FROM ' . STYLES_TPL_TABLE . " - WHERE template_id = $id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - - // User wants to submit data ... - if ($update) - { - // Where is the template stored? - if (!$template_storedb && is_writeable("{$phpbb_root_path}styles/$template_path/template/$tplname")) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'wb'))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $stylesheet = fwrite($fp, $tpldata); - fclose($fp); - } - else - { - $db->sql_transaction('begin'); - - if (!$template_storedb) - { - // We change the path to one relative to the root rather than the theme folder - $sql = 'UPDATE ' . STYLES_TPL_TABLE . ' - SET template_storedb = 1 - WHERE template_id = ' . $id; - $db->sql_query($sql); - - $filelist = filelist("{$phpbb_root_path}styles/$template_path/template"); - $filelist = array('/template' => $filelist['']); - store_templates('insert', $id, $template_path, $filelist); - } - - $sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . " - SET template_data = '" . $db->sql_escape($tpldata) . "', template_mtime = " . time() . " - WHERE template_id = $id - AND template_filename = '" . $db->sql_escape($tplname) . "'"; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - } - - @unlink("{$phpbb_root_path}cache/tpl_{$template_name}_$tplname.$phpEx"); - - $error[] = $user->lang['TEMPLATE_UPDATED']; - add_log('admin', 'LOG_EDIT_TEMPLATE', $template_name, $tplname); - } - - $test_ary = array(); - foreach ($tpllist as $category => $tpl_ary) - { - $test_ary = array_merge($test_ary, $tpl_ary); - } - - if (!$template_storedb) - { - $dp = @opendir("{$phpbb_root_path}styles/$template_path/template"); - while ($file = readdir($dp)) - { - if (!strstr($file, 'bbcode.') && strstr($file, '.html') && !in_array($file, $test_ary) && is_file("{$phpbb_root_path}styles/$template_path/template/$file")) - { - $tpllist['custom'][] = $file; - } - } - closedir($dp); - unset($matches); - unset($test_ary); - - if ($tplname) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'r'))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $tpldata = fread($fp, filesize("{$phpbb_root_path}styles/$template_path/template/$tplname")); - fclose($fp); - } - - } - else - { - $sql = 'SELECT * - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!strstr($row['template_filename'], 'bbcode.') && !in_array($row['template_filename'], $test_ary)) - { - $tpllist['custom'][] = $row['template_filename']; - } - - if ($row['template_filename'] == $tplname) - { - $tpldata = $row['template_data']; - } - } - $db->sql_freeresult($result); - } - - // List of included templates - if ($tplname) - { - preg_match_all('##', $tpldata, $included_tpls); - $included_tpls = $included_tpls[1]; - } - } - unset($test_ary); - - // Generate list of template options - $tpl_options = ''; - ksort($tpllist); - foreach ($tpllist as $category => $tpl_ary) - { - sort($tpl_ary); - $tpl_options .= ''; - - foreach ($tpl_ary as $tpl_file) - { - $selected = ($tpl_file == $tplname) ? ' selected="selected"' : ''; - $tpl_options .= ''; - } - } - - // Output page - adm_page_header($user->lang['EDIT_TEMPLATE']); - -?> - -lang['EDIT_TEMPLATE_EXPLAIN']; ?>
- -lang['SELECTED_TEMPLATE'] . ": $template_name"; ?>
- - - -sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - - $cache_prefix = "tpl_$template_path"; - - // User wants to delete one or more files ... - if ($_POST['update'] && $file_ary) - { - foreach ($file_ary as $file) - { - $file = "{$phpbb_root_path}cache/{$cache_prefix}_$file.html.$phpEx"; - if (file_exists($file) && is_file($file)) - { - @unlink($file); - } - } - unset($file_ary); - - add_log('admin', 'LOG_CLEAR_TPLCACHE', $template_name); - trigger_error($user->lang['TEMPLATE_CACHE_CLEARED']); - } - - // Someone wants to see the cached source ... so we'll highlight it, - // add line numbers and indent it appropriately. This could be nasty - // on larger source files ... - if ($source && file_exists("{$phpbb_root_path}cache/{$cache_prefix}_$source.html.$phpEx")) - { - - adm_page_header($user->lang['TEMPLATE_CACHE']); - -?> - - - -', '', '
','[', ']', '.');
- $str_to = array(' ';
- $str_to[] = '';
- $str_from[] = '<?php ';
- $str_to[] = '';
- $str_from[] = '?>';
- $str_to[] = '';
- }
-
- $code = str_replace($str_from, $str_to, $code);
- $code = preg_replace('#^()\n?(.*?)\n?()$#is', '\1\2\3', $code);
- $code = explode("$marker", $code);
-
-?>
-
-- | $j) - { - $indent = substr($indent, 0, -6); - $j++; - } - unset($code[$key]); - -?> | -
lang['TEMPLATE_CACHE_EXPLAIN']; ?>
- - -sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - - if ($template_storedb && file_exists("{$phpbb_root_path}styles/$template_path/template/")) - { - $filelist = array('/' => array()); - - $sql = 'SELECT template_filename, template_mtime - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (@filemtime("{$phpbb_root_path}styles/$template_path/template/" . $row['template_filename']) > $row['template_mtime']) - { - $filelist['/'][] = $row['template_filename']; - } - } - $db->sql_freeresult($result); - - store_templates('update', $id, $template_path, $filelist); - unset($filelist); - } - } - break; - } - - // Front page - frontend('template', array('cache', 'details', 'refresh', 'export', 'delete')); - break; - - - // THEMES - case 'theme': - switch ($action) - { - case 'edit': - // General parameters - $class = (isset($_POST['classname'])) ? htmlspecialchars($_POST['classname']) : ''; - $customclass = (!empty($_POST['customclass'])) ? htmlspecialchars($_POST['customclass']) : ''; - - $txtcols = (isset($_POST['txtcols'])) ? max(20, intval($_POST['txtcols'])) : 76; - $txtrows = (isset($_POST['txtrows'])) ? max(5, intval($_POST['txtrows'])) : 10; - $showcss = (!empty($_POST['showcss'])) ? true : ((!empty($_POST['hidecss'])) ? false : ((!empty($_GET['showcss'])) ? true : false)); - - // List of default classes, categorised - $base_classes = array( - 'text' => array( - 'body', 'p', 'h1', 'h2', 'h3', '.tabletitle', '.cattitle', '.topictitle', '.topicauthor', '.topicdetails', '.postdetails', '.postbody', '.posthilit', '.postauthor', '.mainmenu', '.nav', '.genmed', '.gensmall', '.copyright', - ), - 'tables' => array( - 'table', 'th', '.cat', '.catdiv', 'td', '.row1', '.row2', '.row3', '.spacer', 'hr', - ), - 'forms' => array( - 'form', 'input', 'select', 'textarea', '.post', '.btnlite', '.btnmain', '.btnbbcode', - ), - 'bbcode' => array( - '.b', '.u', '.i', '.color', '.size', '.code', '.quote', '.flash', '.syntaxbg', '.syntaxcomment', '.syntaxdefault', '.syntaxhtml', '.syntaxkeyword', '.syntaxstring', - ), - 'custom' => array(), - ); - - // We categorise the elements which comprise the css class so that we set - // any appropriate additional data, e.g. sizes require the scale type to be set, - // images require the relevant image be pulled and selected in the dropdown, etc. - $match_elements = array( - 'colors' => array('background-color', 'color',), - 'sizes' => array('font-size', 'line-height',), - 'images' => array('background-image',), - 'repeat' => array('background-repeat',), - 'other' => array('font-weight', 'font-family', 'font-style', 'text-decoration',), - ); - - // Used in an sprintf statement to generate appropriate output for rawcss mode - $map_elements = array( - 'colors' => '%s', - 'sizes' => '%d%s', - 'images' => 'url(\'./%s\')', - 'repeat' => '%s', - 'other' => '%s', - ); - - $s_hidden_fields = ''; - - // Do we want to edit an existing theme? - if ($id) - { - $sql = 'SELECT * - FROM ' . STYLES_CSS_TABLE . " - WHERE theme_id = $id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_THEME']); - } - $db->sql_freeresult($result); - - - // Where is the CSS stored? - if (!$theme_storedb) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css", 'rb'))) - { - trigger_error($user->lang['NO_THEME']); - } - $stylesheet = fread($fp, filesize("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")); - fclose($fp); - } - else - { - $stylesheet = &$theme_data; - } - - // Pull out list of "custom" tags - $class_used = $test_ary = array(); - if (preg_match_all('/^([a-z0-9\.:#>]+?)[ \t]*?\{.*?\}/msi', $stylesheet, $matches)) - { - foreach ($base_classes as $category => $class_ary) - { - $test_ary = array_merge($test_ary, $class_ary); - } - - foreach ($matches[1] as $value) - { - if (!in_array($value, $test_ary)) - { - $base_classes['custom'][] = $value; - } - else - { - $class_used[] = $value; - } - } - unset($matches); - unset($test_ary); - } - } - - // Do we have a class set? If so, we need to extract and set the relevant data - if (!empty($class)) - { - // We must generate the relevant data ... what we need depends on whether - // we are looking @ the rawcss or the simplified settings and whether we - // have just selected a class. We must also cope with switching between - // simple and rawcss mode - $css_element = array(); - if (!empty($_POST['rawcss']) && (!empty($_POST['hidecss']) || !empty($_POST['preview']) || $update)) - { - $css_element = trim(stripslashes(htmlspecialchars(preg_replace("#;[\r\n]*#s", "\n", $_POST['rawcss'])))); - $css_element = explode("\n", $css_element); - } - else if (($showcss && !empty($_POST['showcss'])) || !empty($_POST['preview']) || $update) - { - if (!empty($_POST['cssother'])) - { - $css_element = explode(';', stripslashes(htmlspecialchars(trim($_POST['cssother'])))); - } - - foreach ($match_elements as $type => $match_ary) - { - foreach ($match_ary as $match) - { - $var = str_replace('-', '_', $match); - if (!empty($_POST[$var])) - { - $css_element[] = str_replace('_', '-', $var) . ': ' . (($type == 'sizes') ? sprintf($map_elements[$type], stripslashes($_POST[$var]), $_POST[$var . '_units']) : sprintf($map_elements[$type], stripslashes($_POST[$var]))); - } - } - } - } - else if (preg_match('#^' . $class . '[ \t]*?\{(.*?)\}#ms', $stylesheet, $matches)) - { - $css_element = explode(';', substr(trim($matches[1]), 0, -1)); - } - - $css_element = preg_replace('#^\s*(.*?)\s*$#', '\1', $css_element); - - // User wants to submit data ... - if ($update || $customclass) - { - if ($update) - { - $updated_element = trim(implode('; ', $css_element)) . ';'; - if (preg_match('#^' . $class . '[ \t]*?\{(.*?)\}#ms', $stylesheet)) - { - $stylesheet = preg_replace('#^(' . $class . '[ \t]*?\{).*?(\})#m', '\1 ' . $updated_element . ' \2', $stylesheet); - } - $error[] = $user->lang['THEME_UPDATED']; - } - else - { - // Check custom class name is valid - if (!preg_match('/^[a-z0-9#:\.]+$/i', $customclass)) - { - $error[] = $user->lang['THEME_ERR_CLASS_CHARS']; - } - else - { - $stylesheet .= "\n$customclass { }"; - $base_classes['custom'][] = $customclass; - $error[] = $user->lang['THEME_CLASS_ADDED']; - } - } - - // Where is the CSS stored? - if (!$storedb && is_writeable("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")) - { - // Grab template data - if (!($fp = fopen("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css", 'wb'))) - { - trigger_error($user->lang['NO_THEME']); - } - $stylesheet = fwrite($fp, $stylesheet); - fclose($fp); - } - else - { - // We change the path to one relative to the root rather than the theme folder - $sql_ary = array( - 'theme_storedb' => 1, - 'theme_data' => str_replace('./', "styles/$theme_path/theme/", $stylesheet), - ); - $sql = 'UPDATE ' . STYLES_CSS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE theme_id = ' . $id; - $db->sql_query($sql); - } - - $cache->destroy('sql', STYLES_CSS_TABLE); - add_log('admin', 'LOG_EDIT_THEME', $theme_name); - } - - // I guess really this needs some basic examples, pulled from subSilver - // to demonstrate the default classes. Other, custom classes can just use - // the div/span and some text? This is gonna get nasty :( - if (!empty($_POST['preview'])) - { - // Temp, just to get this out of the way - theme_preview($theme_path, $stylesheet, $class, $css_element); - exit; - } - - // Here we pull out the appropriate class entry then proceed to pull it apart, - // setting appropriate variables to their respective values. We only match - // certain css elements, the rest are "hidden" and can be accessed by exposing - // the raw css - if (!$showcss) - { - foreach ($match_elements as $type => $match_ary) - { - foreach ($match_ary as $match) - { - $var = str_replace('-', '_', $match); - $$var = ''; - - if (sizeof($css_element)) - { - foreach ($css_element as $key => $element) - { - if (preg_match('#^' . preg_quote($match, '#') . ':[ \t]*?(.*?)$#', $element, $matches)) - { - switch ($type) - { - case 'sizes': - if (preg_match('#(.*?)(px|%|em|pt)#', $matches[1], $matches)) - { - ${$var . '_units'} = trim($matches[2]); - } - $$var = trim($matches[1]); - break; - - case 'images': - if (preg_match('#url\(\'(.*?)\'\)#', $matches[1], $matches)) - { - $$var = trim($matches[1]); - $$var = str_replace('./', $theme_name . '/', $$var); - } - break; - - default: - $$var = trim($matches[1]); - } - - // Remove this element from array - unset($css_element[$key]); - break; - } - } - } - } - } - - // Any remaining elements must be custom data so we save that - // in a hidden field - if (sizeof($css_element)) - { - $s_hidden_fields .= ''; - } - } - } - // End of class element variable setting - - // Generate list of class options - $class_options = ''; - foreach ($base_classes as $category => $class_ary) - { - $class_options .= ''; - foreach ($class_ary as $class_name) - { - $used = (in_array($class_name, $class_used) || $category == 'custom') ? ' style="color:red"' : ''; - $selected = ($class_name == $class) ? ' selected="selected"' : ''; - $class_options .= ''; - } - } - unset($class_used); - - // Grab list of potential images for class backgrounds - $imglist = filelist("{$phpbb_root_path}styles/$theme_path/theme"); - - $bg_imglist = ''; - foreach ($imglist as $path => $img_ary) - { - foreach ($img_ary as $img) - { - $img = ((substr($path, 0, 1) == '/') ? substr($path, 1) : $path) . $img; - - $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; - $bg_imglist .= ''; - } - } - $bg_imglist = '' . $bg_imglist; - unset($imglist); - - // Output the page - adm_page_header($user->lang['EDIT_THEME']); - -?> - - - -lang['EDIT_THEME_EXPLAIN']; ?>
- -lang['SELECTED_THEME'] . ": $theme_name"; ?>
- - -lang['SHOW_RAW_CSS_EXPLAIN']; ?>
- - - - array( - 'btn_post', 'btn_reply', 'btn_locked', 'btn_quote', 'btn_edit', 'btn_delete', 'btn_report', 'btn_post_pm', 'btn_reply_pm', 'btn_profile', 'btn_pm', 'btn_ip', 'btn_search', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', - ), - 'icons' => array( - 'icon_unapproved', 'icon_reported', 'icon_attach', 'icon_post', 'icon_post_new', 'icon_post_latest', 'icon_post_newest',), - 'forums' => array( - 'forum', 'forum_new', 'forum_locked', 'forum_link', 'sub_forum', 'sub_forum_new',), - 'folders' => array( - 'folder', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted',), - 'polls' => array( - 'poll_left', 'poll_center', 'poll_right',), - ); - - switch ($action) - { - case 'edit': - $imgname = (!empty($_POST['imgname'])) ? htmlspecialchars($_POST['imgname']) : ''; - $imgpath = (isset($_POST['imgpath'])) ? htmlspecialchars($_POST['imgpath']) : ''; - $imgsize = (!empty($_POST['imgsize'])) ? true : false; - $imgwidth = (isset($_POST['imgwidth'])) ? intval($_POST['imgwidth']) : ''; - - if ($id) - { - $sql_select = ($imgname) ? ", $imgname" : ''; - $sql = "SELECT imageset_path, imageset_name, imageset_copyright$sql_select - FROM " . STYLES_IMAGE_TABLE . " - WHERE imageset_id = $id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_IMAGESET']); - } - $db->sql_freeresult($result); - - // Check to see whether the selected image exists in the table - $valid_name = false; - foreach ($imglist as $category => $img_ary) - { - if (in_array($imgname, $img_ary)) - { - $valid_name = true; - break; - } - } - - if (!$valid_name) - { - $error[] = $user->lang['NO_IMAGE']; - } - - if ($update && $imgpath) - { - if (!sizeof($error)) - { - // If imgwidth and imgheight are non-zero grab the actual size - // from the image itself ... we ignore width settings for the poll center - // image - $imgwidth = $imgheight = ''; - if ($imgsize) - { - list($imgwidth, $imgheight) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"); - $imgwidth = ($imgname != 'poll_center') ? " width=\"$imgwidth\"" : ''; - $imgheight = " height=\"$imgheight\""; - } - - $imgpath = '"styles/' . $imageset_path . '/imageset/' . preg_replace('#^(.*?)/(.*?)$#', '{LANG}/\2', $imgpath) . '" border="0"' . $imgwidth . $imgheight; - - $sql = 'UPDATE ' . STYLES_IMAGE_TABLE . " - SET $imgname = '$imgpath' - WHERE imageset_id = $id"; - $db->sql_query($sql); - - $cache->destroy('sql', STYLES_IMAGE_TABLE); - - add_log('admin', 'LOG_EDIT_IMAGESET', $imageset_name); - $error[] = $user->lang['IMAGESET_UPDATED']; - - $$imgname = $imgpath; - } - } - - $test_ary = array(); - foreach ($imglist as $category => $img_ary) - { - foreach ($img_ary as $img) - { - if (!empty($$img)) - { - $test_ary[] = preg_replace('#^"styles/' . $imageset_path . '/imageset/(\{LANG\}/)?(.*?)".*$#', '\2', $$img); - } - } - } - unset($test_ary); - } - - // Generate list of image options - $img_options = ''; - foreach ($imglist as $category => $img_ary) - { - $img_options .= (sizeof($img_ary)) ? '' : ''; - foreach ($img_ary as $img) - { - $selected = ($img == $imgname) ? ' selected="selected"' : ''; - $img_options .= ''; - } - } - - // TODO - // Check whether localised buttons exist in admins language first - // Clean up this code - $imglang = ''; - $imagesetlist = array('nolang' => array(), 'lang' => array()); - $dp = opendir("{$phpbb_root_path}styles/$imageset_path/imageset"); - while ($file = readdir($dp)) - { - if (!is_file($file) && !is_link($file) && $file{0} != '.' && strtoupper($file) != 'CVS' && !sizeof($imagesetlist['lang'])) - { - $dp2 = opendir("{$phpbb_root_path}styles/$imageset_path/imageset/$file"); - while ($file2 = readdir($dp2)) - { - $imglang = $file; - if (preg_match('#\.(gif|jpg|png)$#', $file2)) - { - $imagesetlist['lang'][] = "$file/$file2"; - } - } - closedir($dp2); - } - else if (preg_match('#\.(gif|jpg|png)$#', $file)) - { - $imagesetlist['nolang'][] = $file; - } - } - closedir($dp); - - $imagesetlist_options = ''; - foreach ($imagesetlist as $type => $img_ary) - { - $imagesetlist_options .= ($type == 'lang') ? '' : ''; - foreach ($img_ary as $img) - { - $imgvalue = preg_replace('#^.*?/(.*?)$#', '\1', $img); - $selected = (strstr($$imgname, $imgvalue)) ? ' selected="selected"' : ''; - - $imagesetlist_options .= ''; - } - } - $imagesetlist_options = '' . $imagesetlist_options; - unset($imagesetlist); - - $imgsize_no = $imgsize_yes = ''; - if ($imgsize || preg_match('# height="[0-9]+?#', $$imgname)) - { - $imgsize_yes = ' checked="checked"'; - } - else - { - $imgsize_no = ' checked="checked"'; - } - - adm_page_header($user->lang['EDIT_IMAGESET']); - -?> - - - -lang['EDIT_IMAGESET_EXPLAIN']; ?>
- -lang['SELECTED_IMAGESET'] . ": $imageset_name"; ?>
- - - -lang[$l_prefix . 'S']); - -?> -lang[$l_prefix . 'S_EXPLAIN']; ?>
- - - -sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_' . $l_prefix]); - } - - $path = ($type != 'style') ? ${$type . '_path'} : ''; - $storedb = (isset(${$type . '_storedb'})) ? ${$type . '_storedb'} : false; - - $sql = "SELECT {$type}_id, {$type}_name - FROM $sql_from - WHERE {$type}_id <> $id - ORDER BY {$type}_id"; - $result = $db->sql_query($sql); - - $options = ''; - if (!($row = $db->sql_fetchrow($result))) - { - trigger_error($user->lang['ONLY_' . $l_prefix]); - } - - do - { - $options .= ''; - } - while ($row = $db->sql_fetchrow($result)); - - if ($update) - { - $sql = "DELETE FROM $sql_from - WHERE {$type}_id = $id"; - $db->sql_query($sql); - - $onfs = 0; - if ($type == 'style') - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_style = $new_id - WHERE user_style = $id"; - $db->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . STYLES_TABLE . " - SET {$type}_id = $new_id - WHERE {$type}_id = $id"; - $db->sql_query($sql); - - if ($deletefs && is_writeable("{$phpbb_root_path}styles/$path/{$type}")) - { - $filelist = filelist("{$phpbb_root_path}styles/$path/{$type}", '', '*'); - krsort($filelist); - - foreach ($filelist as $subpath => $file_ary) - { - $subpath = "{$phpbb_root_path}styles/$path/{$type}$subpath"; - foreach ($file_ary as $file) - { -/* if (!@unlink("$subpath$file")) - { - $onfs = 1; - } -*/ } - -/* if (!@rmdir($subpath)) - { - $onfs = 1; - } -*/ } - } - else - { - $onfs = (file_exists("{$phpbb_root_path}styles/$path/{$type}")) ? 1 : 0; - } - } - - $cache->destroy('sql', STYLES_TABLE); - - add_log('admin', 'LOG_DELETE_' . $l_prefix, ${$type . '_name'}); - $message = ($onfs) ? $l_prefix . '_DELETED_FS' : $l_prefix . '_DELETED'; - trigger_error($user->lang[$message]); - } - - // Output list of themes - adm_page_header($user->lang['DELETE_' . $l_prefix]); - -?> -lang['DELETE_' . $l_prefix . '_EXPLAIN']; ?>
- - -lang['STYLE_ERR_MORE_ELEMENTS']; - } - - $style_id = &$id; - $name = 'style_name'; - - $sql_select = 's.style_id, s.style_name, s.style_copyright'; - $sql_select .= ($inc_template) ? ', t.*' : ', t.template_name'; - $sql_select .= ($inc_theme) ? ', c.*' : ', c.theme_name'; - $sql_select .= ($inc_imageset) ? ', i.*' : ', i.imageset_name'; - $sql_from = STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . ' i'; - $sql_where = "s.style_id = $id AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id"; - - $l_prefix = 'STYLE'; - break; - - case 'template': - $template_id = &$id; - $name = 'template_name'; - - $sql_select = '*'; - $sql_from = STYLES_TPL_TABLE; - $sql_where = "template_id = $id"; - - $l_prefix = 'TEMPLATE'; - break; - - case 'theme': - $theme_id = &$id; - $name = 'theme_name'; - - $sql_select = '*'; - $sql_from = STYLES_CSS_TABLE; - $sql_where = "theme_id = $id"; - - $l_prefix = 'THEME'; - break; - - case 'imageset': - $imageset_id = &$id; - $name = 'imageset_name'; - - $sql_select = '*'; - $sql_from = STYLES_IMAGE_TABLE; - $sql_where = "imageset_id = $id"; - - $l_prefix = 'IMAGESET'; - break; - } - - // Lets do a merry dance ... either that or generate the archive - if ($update && !sizeof($error)) - { - $sql = "SELECT $sql_select - FROM $sql_from - WHERE $sql_where"; - $result = $db->sql_query($sql); - - if (!($style_row = ($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_' . $l_prefix]); - } - $db->sql_freeresult($result); - - $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_storedb', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'theme_storedb', 'theme_mtime', 'theme_data', 'imageset_id', 'imageset_name', 'imageset_path', 'imageset_copyright'); - foreach ($var_ary as $var) - { - $$var = (!empty($style_row[$var])) ? $style_row[$var] : ''; - unset($style_row[$var]); - } - - $files = $data = array(); - - if ($mode == 'style') - { - $style_cfg = addslashes($style_name) . "\n"; - $style_cfg .= addslashes($style_copyright) . "\n"; - $style_cfg .= addslashes($config['version']) . "\n"; - $style_cfg .= ((!$inc_template) ? addslashes($template_name) : '') . "\n"; - $style_cfg .= ((!$inc_theme) ? addslashes($theme_name) : '') . "\n"; - $style_cfg .= ((!$inc_imageset) ? addslashes($imageset_name) : ''); - - $data[] = array( - 'src' => $style_cfg, - 'prefix' => 'style.cfg' - ); - unset($style_cfg); - } - - // Export template core code - if ($mode == 'template' || $inc_template) - { - $template_cfg = addslashes($template_name) . "\n"; - $template_cfg .= addslashes($template_copyright) . "\n"; - $template_cfg .= addslashes($config['version']) . "\n"; - $template_cfg .= addslashes($bbcode_bitfield); - - $data[] = array( - 'src' => $template_cfg, - 'prefix' => 'template/template.cfg' - ); - - // This is potentially nasty memory-wise ... - if (!$template_storedb) - { - $files[] = array( - 'src' => "styles/$template_path/template/", - 'prefix-' => "styles/$template_path/", - 'prefix+' => false, - 'exclude' => 'template.cfg' - ); - } - else - { - $sql = 'SELECT template_filename, template_data - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $data[] = array( - 'src' => $row['template_data'], - 'prefix' => 'template/' . $row['template_filename'] - ); - } - $db->sql_freeresult($result); - } - unset($template_cfg); - } - - // Export theme core code - if ($mode == 'theme' || $inc_theme) - { - $theme_cfg = addslashes($theme_name) . "\n"; - $theme_cfg .= addslashes($theme_copyright) . "\n"; - $theme_cfg .= addslashes($config['version']); - - $files[] = array( - 'src' => "styles/$theme_path/theme/", - 'prefix-' => "styles/$theme_path/", - 'prefix+' => false, - 'exclude' => ($theme_storedb) ? 'stylesheet.css,theme.cfg' : 'theme.cfg' - ); - - $data[] = array( - 'src' => $theme_cfg, - 'prefix' => 'theme/theme.cfg' - ); - - if ($theme_storedb) - { - $data[] = array( - 'src' => $theme_data, - 'prefix' => 'theme/stylesheet.css' - ); - } - unset($theme_data); - unset($theme_cfg); - } - - // Export imageset core code - if ($mode == 'imageset' || $inc_imageset) - { - $imageset_cfg = addslashes($imageset_name) . "\n"; - $imageset_cfg .= addslashes($imageset_copyright) . "\n"; - $imageset_cfg .= addslashes($config['version']) . "\n"; - - foreach (array_keys($style_row) as $key) - { - $imageset_cfg .= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $style_row[$key]) . "\n"; - unset($style_row[$key]); - } - $imageset_cfg = rtrim($imageset_cfg); - - $files[] = array( - 'src' => "styles/$imageset_path/imageset/", - 'prefix-' => "styles/$imageset_path/", - 'prefix+' => false, - 'exclude' => 'imageset.cfg' - ); - - $data[] = array( - 'src' => trim($imageset_cfg), - 'prefix' => 'imageset/imageset.cfg' - ); - unset($imageset_cfg); - } - - switch ($format) - { - case 'tar': - $ext = 'tar'; - $mimetype = 'x-tar'; - $compress = 'compress_tar'; - break; - - case 'zip': - if (!extension_loaded('zlib')) - { - trigger_error($user->lang['NO_SUPPORT_ZIP']); - } - $ext = 'zip'; - $mimetype = 'zip'; - $compress = 'compress_zip'; - break; - - case 'tar.gz': - if (!extension_loaded('zlib')) - { - trigger_error($user->lang['NO_SUPPORT_GZ']); - } - $ext = 'tar.gz'; - $mimetype = 'x-gzip'; - $compress = 'compress_tar'; - break; - - case 'tar.bz2': - if (!extension_loaded('bz2')) - { - trigger_error($user->lang['NO_SUPPORT_BZ2']); - } - $ext = 'tar.bz2'; - $mimetype = 'x-bzip2'; - $compress = 'compress_tar'; - break; - - default: - $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; - } - - if (!sizeof($error)) - { - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - - $path = str_replace(' ', '_', $$name); - - if (!($zip = new $compress('w', "{$phpbb_root_path}store/$path.$ext"))) - { - trigger_error($user->lang['STORE_UNWRITEABLE']); - } - - if ($files) - { - foreach ($files as $file_ary) - { - $zip->add_file($file_ary['src'], $file_ary['prefix-'], $file_ary['prefix+'], $file_ary['exclude']); - } - } - - if ($data) - { - foreach ($data as $data_ary) - { - $zip->add_data($data_ary['src'], $data_ary['prefix']); - } - } - - $zip->close(); - - add_log('admin', 'LOG_EXPORT_' . $l_prefix, $$name); - - if (!$store) - { - header('Pragma: no-cache'); - header("Content-Type: application/$mimetype; name=\"$path.$ext\""); - header("Content-disposition: attachment; filename=$path.$ext"); - - $fp = fopen("{$phpbb_root_path}store/$path.$ext", 'rb'); - while ($buffer = fread($fp, 1024)) - { - echo $buffer; - } - fclose($fp); - @unlink("{$phpbb_root_path}store/$path.$ext"); - exit; - } - - trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path.$ext")); - } - } - else - { - $sql = "SELECT {$mode}_id, {$mode}_name - FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " - WHERE {$mode}_id = $id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_' . $l_prefix]); - } - $db->sql_freeresult($result); - } - - // Output list - adm_page_header($user->lang[$l_prefix . '_EXPORT']); - -?> -lang[$l_prefix . '_EXPORT_EXPLAIN']; ?>
- - - $file_ary) - { - foreach ($file_ary as $file) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile/$file", 'r'))) - { - trigger_error("Could not open {$phpbb_root_path}styles/$path/$pathfile/$file"); - } - $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$path$pathfile/$file")); - fclose($fp); - - if (preg_match_all('##is', $template_data, $matches)) - { - foreach ($matches[1] as $match) - { - $includes[trim($match)][] = $file; - } - } - } - } - - foreach ($filelist as $pathfile => $file_ary) - { - foreach ($file_ary as $file) - { - // Skip index. - if (strpos($file, 'index.') === 0) - { - continue; - } - - // We could do this using extended inserts ... but that could be one - // heck of a lot of data ... - $sql_ary = array( - 'template_id' => $id, - 'template_filename' => $file, - 'template_included' => (!empty($includes[$file])) ? implode(':', $includes[$file]) . ':' : '', - 'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile/$file"), - 'template_data' => implode('', file("{$phpbb_root_path}styles/$path$pathfile/$file")), - ); - - $sql = ($mode == 'insert') ? 'INSERT INTO ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) . " WHERE template_id = $id AND template_filename = '" . $db->sql_escape($file) . "'"; - $db->sql_query($sql); - } - } -} - -// Does what it says in the function title ... give it a src location, array of files -// and destination -function copy_files($src, $filelist, $dst) -{ - global $phpbb_root_path; - - if (!(is_writable("{$phpbb_root_path}styles"))) - { - return false; - } - - umask(0); - if (!file_exists("{$phpbb_root_path}styles/$dst")) - { - @mkdir("{$phpbb_root_path}styles/$dst", 0777); - chmod("{$phpbb_root_path}styles/$dst", 0777); - } - - @ksort($filelist); - foreach ($filelist as $filepath => $file_ary) - { - $filepath = (substr($filepath, 0, 1) != '/') ? "/$filepath" : $filepath; - - if ($filepath && !file_exists("{$phpbb_root_path}styles/$dst$filepath")) - { - @mkdir("{$phpbb_root_path}styles/$dst$filepath", 0777); - chmod("{$phpbb_root_path}styles/$dst$filepath", 0777); - } - - foreach ($file_ary as $file) - { - if (!file_exists("{$phpbb_root_path}styles/$dst$filepath$file")) - { - @copy("$src$filepath$file", "{$phpbb_root_path}styles/$dst$filepath$file"); - @chmod("{$phpbb_root_path}styles/$dst$filepath$file", 0777); - } - } - } -} - -// You can guess what this does ... just give it a path -function cleanup_folder($path) -{ - $filelist = filelist($path, '', '*'); - - krsort($filelist); - foreach ($filelist as $filepath => $file_ary) - { - foreach ($file_ary as $file) - { - @unlink("$path$filepath$file"); - } - - if (file_exists("$path$filepath")) - { - @rmdir("$path$filepath"); - } - } - @rmdir("$path"); -} - -// Is this element installed? If not, grab its cfg details -function test_installed($element, &$error, $root_path, $reqd_name, &$id, &$name, &$copyright) -{ - global $db, $user; - - switch ($element) - { - case 'template': - $sql_from = STYLES_TPL_TABLE; - break; - case 'theme': - $sql_from = STYLES_CSS_TABLE; - break; - case 'imageset': - $sql_from = STYLES_IMAGE_TABLE; - break; - } - - $l_element = strtoupper($element); - - $chk_name = ($reqd_name) ? $reqd_name : $name; - - $sql = "SELECT {$element}_id, {$element}_name - FROM $sql_from - WHERE {$element}_name = '" . $db->sql_escape($chk_name) . "'"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $name = $row[$element . '_name']; - $id = $row[$element . '_id']; - } - else - { - if (!($cfg = @file("$root_path$element/$element.cfg"))) - { - $error[] = sprintf($user->lang['REQUIRES_' . $l_element], $reqd_name); - return false; - } - - $name = trim($cfg[0]); - $copyright = trim($cfg[1]); - $id = 0; - unset($cfg); - } - $db->sql_freeresult($result); -} - -// Install an element, doing various checks as we go -function install_element($type, &$error, $action, $root_path, &$id, $name, $copyright, $storedb = 0) -{ - global $phpbb_root_path, $db, $user; - - switch ($type) - { - case 'template': - $sql_from = STYLES_TPL_TABLE; - break; - case 'theme': - $sql_from = STYLES_CSS_TABLE; - break; - case 'imageset': - $sql_from = STYLES_IMAGE_TABLE; - break; - } - - $l_type = strtoupper($type); - $path = str_replace(' ', '_', $name); - - if (empty($name)) - { - $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; - } - - if (strlen($name) > 30) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; - } - - if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $name)) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_CHARS']; - } - - if (strlen($copyright) > 60) - { - $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; - } - - $sql = "SELECT {$type}_name - FROM $sql_from - WHERE {$type}_name = '" . $db->sql_escape($name) . "'"; - $result = $db->sql_query($sql); - - if (extract($db->sql_fetchrow($result))) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; - } - $db->sql_freeresult($result); - - if (sizeof($error)) - { - return false; - } - - if ($action != 'install') - { - @mkdir("{$phpbb_root_path}styles/$path", 0777); - @chmod("{$phpbb_root_path}styles/$path", 0777); - if ($root_path) - { - copy_files("$root_path$type", filelist("$root_path$type", '', '*'), "$path/$type"); - } - } - - $sql_ary = array( - $type . '_name' => $name, - $type . '_copyright'=> $copyright, - $type . '_path' => $path, - ); - if ($type != 'imageset') - { - switch ($type) - { - case 'template': - $sql_ary += array( - $type . '_storedb' => (!is_writeable("{$phpbb_root_path}styles/$path/$type")) ? 1 : 0 - ); - break; - - case 'theme': - $sql_ary += array( - 'theme_storedb' => (!is_writeable("{$phpbb_root_path}styles/$path/theme/stylesheet.css")) ? 1 : $storedb, - 'theme_data' => ($storedb) ? (($root_path) ? str_replace('./', "styles/$path/theme/", implode('', file("$root_path/$type/stylesheet.css"))) : '') : '', - 'theme_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/theme/stylesheet.css") : 0 - ); - break; - } - } - else - { - $cfg = file("$root_path$type/imageset.cfg"); - - for ($i = 3; $i < sizeof($cfg); $i++) - { - $tmp = explode('||', $cfg[$i]); - $sql_ary[$tmp[0]] = str_replace('{PATH}', "styles/$path/imageset/", trim($tmp[1])); - } - unset($cfg); - } - - $db->sql_transaction('begin'); - - $sql = "INSERT INTO $sql_from - " . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $id = $db->sql_nextid(); - - if ($type == 'template' && $storedb) - { - $filelist = filelist("{$root_path}template", '', 'html'); - store_templates('insert', $id, $path, $filelist); - } - - $db->sql_transaction('commit'); - - $log = ($storedb) ? 'LOG_ADD_' . $l_type . '_FS' : 'LOG_ADD_' . $l_type . '_DB'; - add_log('admin', $log, $name); -} - -function install_style($action, &$error, $name, $copyright, $active, $default, $root_path, &$template_id, &$template_name, &$template_copyright, &$theme_id, &$theme_name, &$theme_copyright, &$imageset_id, &$imageset_name, &$imageset_copyright) -{ - global $config, $db, $user; - - $element_ary = array('template', 'theme', 'imageset'); - - if (empty($name)) - { - $error[] = $user->lang['STYLE_ERR_STYLE_NAME']; - } - - if (strlen($name) > 30) - { - $error[] = $user->lang['STYLE_ERR_NAME_LONG']; - } - - if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $name)) - { - $error[] = $user->lang['STYLE_ERR_NAME_CHARS']; - } - - if (strlen($copyright) > 60) - { - $error[] = $user->lang['STYLE_ERR_COPY_LONG']; - } - - $sql = 'SELECT style_name - FROM ' . STYLES_TABLE . " - WHERE style_name = '" . $db->sql_escape($name) . "'"; - $result = $db->sql_query($sql); - - if (extract($db->sql_fetchrow($result))) - { - $error[] = $user->lang['STYLE_ERR_NAME_EXIST']; - } - $db->sql_freeresult($result); - - foreach ($element_ary as $element) - { - // Zero id value ... need to install element ... run usual checks - // and do the install if necessary - if (!${$element . '_id'}) - { - $error = install_element($element, $error, $action, $root_path, ${$element . '_id'}, ${$element . '_name'}, ${$element . '_copyright'}); - } - } - - if (!$template_id || !$theme_id || !$imageset_id) - { - $error[] = $user->lang['STYLE_ERR_NO_IDS']; - } - - if (sizeof($error)) - { - return false; - } - - $db->sql_transaction('begin'); - - $sql_ary = array( - 'style_name' => $name, - 'style_copyright' => $copyright, - 'style_active' => $active, - 'template_id' => $template_id, - 'theme_id' => $theme_id, - 'imageset_id' => $imageset_id, - ); - - $sql = 'INSERT INTO ' . STYLES_TABLE . ' - ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $id = $db->sql_nextid(); - - if ($default) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_style = $id - WHERE user_style = " . $config['default_style']; - $db->sql_query($sql); - - set_config('default_style', $id); - } - - $db->sql_transaction('commit'); - - add_log('admin', 'LOG_ADD_STYLE', $name); -} - -// Commented inline -function install($type, $action, $id) -{ - global $phpbb_root_path, $phpEx, $SID, $config, $db, $cache, $user; - global $safe_mode, $file_uploads, $archive_preg; - - $install_path = (isset($_REQUEST['path'])) ? htmlspecialchars($_REQUEST['path']) : ''; - $update = (isset($_POST['update'])) ? true : false; - - $installcfg = $error = array(); - $template_storedb = $theme_storedb = $basis = false; - $root_path = $tmp_path = $theme_data = $s_hidden_fields = ''; - $template_id = $template_name = $template_copyright =$theme_id = $theme_name = $theme_copyright = $imageset_id = $imageset_name = $imageset_copyright = ''; - - $l_type = strtoupper($type); - $l_prefix = ($action == 'add') ? 'ADD' : (($action == 'details') ? 'EDIT_DETAILS' : 'INSTALL'); - - $element_ary = array('template' => STYLES_TPL_TABLE, 'theme' => STYLES_CSS_TABLE, 'imageset' => STYLES_IMAGE_TABLE); - $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); - - switch ($type) - { - case 'style': - $sql_from = STYLES_TABLE; - break; - case 'template': - $sql_from = STYLES_TPL_TABLE; - break; - case 'theme': - $sql_from = STYLES_CSS_TABLE; - break; - case 'imageset': - $sql_from = STYLES_IMAGE_TABLE; - break; - } - - // Importing/uploading then check data and extract archive - if (!empty($_FILES['upload_file']['name']) || !empty($_POST['import_file'])) - { - if (!empty($_FILES['upload_file']['name'])) - { - $realname = htmlspecialchars($_FILES['upload_file']['name']); - $filename = htmlspecialchars($_FILES['upload_file']['tmp_name']); - - if (!is_uploaded_file($filename)) - { - trigger_error("$filename was not uploaded"); - } - } - else - { - $realname = htmlspecialchars($_POST['import_file']); - $filename = "{$phpbb_root_path}store/$realname"; - } - - if (!preg_match('#(' . $archive_preg . ')$#i', $realname, $match)) - { - $error[] = sprintf($user->lang['UPLOAD_WRONG_TYPE'], $archive_types); - } - $path = preg_replace('#^(.*?)' . preg_quote($match[0]) . '$#', '\1', $realname); - - // Attempt to extract the files to a temporary directory in store - $tmp_path = $phpbb_root_path . 'store/tmp_' . substr(uniqid(''), 0, 10) . '/'; - if (!@mkdir($tmp_path)) - { - trigger_error("Cannot create $tmp_path", E_USER_ERROR); - } - - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - - switch ($match[0]) - { - case '.zip': - $zip = new compress_zip('r', $filename); - break; - default: - $zip = new compress_tar('r', $filename, $match[0]); - } - $zip->extract($tmp_path); - $zip->close(); - - unset($cfg); - } - - // Installing, importing/uploading then obtain the style cfg information - if (($action == 'install' && $install_path) || (!empty($_FILES['upload_file']['name']) || !empty($_POST['import_file']))) - { - $root_path = ($action == 'install') ? "{$phpbb_root_path}styles/$install_path/" : "$tmp_path"; - $cfg_path = ($type == 'style') ? "$root_path$type.cfg" : "$root_path$type/$type.cfg"; - - if (!($fp = @fopen($cfg_path, 'rb'))) - { - $error[] = $user->lang[$l_type . '_ERR_NOT_' . $l_type]; - } - else - { - $installcfg = explode("\n", fread($fp, filesize($cfg_path))); - } - fclose($fp); - } - - // Installing, importing/uploading then grab the element info else grab the - // submitted params ... stylecfg will be set if this is true (see above) - if (sizeof($installcfg)) - { - $name = trim($installcfg[0]); - $copyright = trim($installcfg[1]); - $version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($installcfg[2])); - - switch ($type) - { - case 'style': - $reqd_template = trim($installcfg[3]); - $reqd_theme = trim($installcfg[4]); - $reqd_imageset = trim($installcfg[5]); - - // Check to see if each element is already installed, if it is grab the id - foreach ($element_ary as $element => $table) - { - ${$element . '_id'} = ${$element . '_name'} = ${$element . '_copyright'} = ''; - - test_installed($element, $error, $root_path, ${'reqd_' . $element}, ${$element . '_id'}, ${$element . '_name'}, ${$element . '_copyright'}); - } - break; - - case 'template': - test_installed('template', $error, $root_path, false, $template_id, $template_name, $template_copyright); - break; - - case 'theme': - test_installed('theme', $error, $root_path, false, $theme_id, $theme_name, $theme_copyright); - break; - - case 'imageset': - test_installed('imageset', $error, $root_path, false, $imageset_id, $imageset_name, $imageset_copyright); - break; - } - - $s_hidden_fields = ''; - } - else - { - // NOTE: Data here is stripslashed! Ensure it's escaped when entering the DB - $name = (!empty($_POST['name'])) ? stripslashes(htmlspecialchars($_POST['name'])) : ''; - $copyright = (!empty($_POST['copyright'])) ? stripslashes(htmlspecialchars($_POST['copyright'])) : ''; - - $template_id = (!empty($_POST['template_id'])) ? intval($_POST['template_id']) : 0; - $theme_id = (!empty($_POST['theme_id'])) ? intval($_POST['theme_id']) : 0; - $imageset_id = (!empty($_POST['imageset_id'])) ? intval($_POST['imageset_id']) : 0; - $basis = (isset($_POST['basis'])) ? intval($_POST['basis']) : 0; - - // If we have a basis or we're editing we want some additional info ... else - // we need nothing - if ($basis || ($update && $action != 'add')) - { - switch ($type) - { - case 'style': - $sql_select = ($action != 'details') ? 'style_name, template_id, theme_id, imageset_id' : 'style_name'; - break; - case 'template': - $sql_select = 'template_id, template_name, template_path, template_storedb'; - break; - case 'theme': - $sql_select = 'theme_id, theme_name, theme_path, theme_data, theme_storedb'; - break; - case 'imageset': - $sql_select = 'imageset_id, imageset_name, imageset_path'; - break; - } - - $sql = "SELECT $sql_select - FROM $sql_from - WHERE {$type}_id = " . (($basis) ? $basis : $id); - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - $error[] = $user->lang['NO_' . $l_type]; - } - $db->sql_freeresult($result); - - $s_hidden_fields .= ''; - } - } - - $storedb = (!empty($_POST['storedb'])) ? 1 : 0; - $style_active = (isset($_POST['style_active'])) ? ((!empty($_POST['style_active'])) ? 1 : 0) : 1; - $style_default = (isset($_POST['style_default'])) ? ((!empty($_POST['style_default'])) ? 1 : 0) : (($config['default_style'] == $id) ? 1 : 0); - - // User has submitted form and no errors have occured - if ($update && !sizeof($error)) - { - $sql_ary = array(); - - // We're installing/uploading/importing - if ($action == 'install') - { - switch ($type) - { - case 'style': - install_style($action, $error, $name, $copyright, $style_active, $style_default, $root_path, $template_id, $template_name, $template_copyright, $theme_id, $theme_name, $theme_copyright, $imageset_id, $imageset_name, $imageset_copyright); - break; - - case 'template': - install_element('template', $error, $action, $root_path, $id, $name, $copyright); - break; - - case 'theme': - install_element('theme', $error, $action, $root_path, $id, $name, $copyright); - break; - - case 'imageset': - install_element('imageset', $error, $action, $root_path, $id, $name, $copyright); - break; - } - - if ($tmp_path) - { - cleanup_folder($tmp_path); - } - - if (!sizeof($error)) - { - $cache->destroy('sql', STYLES_TABLE); - - $message = ($storedb) ? '_ADDED_DB' : '_ADDED'; - trigger_error($user->lang[$l_type . $message]); - } - } - else if ($action == 'add') - { - if ($type == 'style') - { - install_style($action, $error, $name, $copyright, $style_active, $style_default, $root_path, $template_id, $template_name, $template_copyright, $theme_id, $theme_name, $theme_copyright, $imageset_id, $imageset_name, $imageset_copyright); - } - else - { - // Create path if it doesn't exist - $storedb = 1; - - umask(0); - if (file_exists("{$phpbb_root_path}styles/$path") || @mkdir("{$phpbb_root_path}styles/$path", 0777)) - { - if (@chmod("{$phpbb_root_path}styles/$path", 0777)) - { - $storedb = 0; - } - } - - if ($basis && ($template_storedb || $theme_storedb)) - { - $tmp_path = $phpbb_root_path . 'store/tmp_' . substr(uniqid(''), 0, 10) . '/'; - if (!@mkdir($tmp_path, 0777)) - { - trigger_error("Cannot create $tmp_path", E_USER_ERROR); - } - @chmod($tmp_path, 0777); - - if (!@mkdir("$tmp_path$type", 0777)) - { - trigger_error("Cannot create $tmp_path$type", E_USER_ERROR); - } - @chmod("$tmp_path$type", 0777); - - switch ($type) - { - case 'theme': - copyfiles("{$phpbb_root_path}styles/$path/theme/", filelist("{$phpbb_root_path}styles/$path/theme/", '', '*'), "$tmp_path$type/"); - - $fp = fopen("$tmp_path$type/stylesheet.css", 'wb'); - fwrite($fp, $theme_data); - fclose($theme_data); - break; - - case 'template': - copyfiles("{$phpbb_root_path}styles/$path/$type/", filelist("{$phpbb_root_path}styles/$path/$type/", '', '*'), "$tmp_path$type/"); - - $sql = 'SELECT template_filename, template_mtime, template_data - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $basis"; - $result = $db->sql_fetchrow($result); - - while ($row = $db->sql_fetchrow($result)) - { - $fp = fopen("$tmp_path$type/" . $row['template_filename'], 'wb'); - fwrite($fp, $row['template_data']); - fclose($fp); - } - $db->sql_freeresult($result); - break; - } - } - - $root_path = ($tmp_path) ? $tmp_path : (($basis) ? $phpbb_root_path . 'styles/' . ${$type . '_path'} . '/' : ''); - - install_element($type, $error, $action, $root_path, $id, $name, $copyright, $storedb); - } - - if ($tmp_path) - { - cleanup_folder($tmp_path); - } - - if (!sizeof($error)) - { - $cache->destroy('sql', STYLES_TABLE); - - $message = ($storedb) ? '_ADDED_DB' : '_ADDED'; - trigger_error($user->lang["$l_type$message"]); - } - } - else if ($action == 'details') - { - if ($type == 'style') - { - $sql_ary = array( - 'template_id' => $template_id, - 'theme_id' => $theme_id, - 'imageset_id' => $imageset_id, - 'style_active' => $style_active, - ); - } - else if ($type != 'imageset') - { - switch ($type) - { - case 'theme': - if ($theme_storedb != $storedb) - { - $theme_data = implode('', file("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")); - if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")) - { - $storedb = 1; - if ($fp = @fopen("{$phpbb_root_path}styles/$theme_path/$type/stylesheet.css", 'wb')) - { - $storedb = (@fwrite($fp, str_replace("styles/$theme_path/theme/", './', $theme_data))) ? 0 : 1; - } - fclose($fp); - } - $theme_data = str_replace('./', "styles/$theme_path/theme/", $theme_data); - - $sql_ary = array( - 'theme_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css") : 0, - 'theme_storedb' => $storedb, - 'theme_data' => ($storedb) ? $theme_data : '', - ); - } - break; - - case 'template': - if ($theme_storedb != $storedb) - { - $filelist = filelist("{$phpbb_root_path}styles/$template_path/template", '', 'html'); - - if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$template_path/template")) - { - $sql = 'SELECT * - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!($fp = @fopen("{$phpbb_root_path}styles/$template_path/template/" . $row['template_filename'], 'wb'))) - { - $storedb = 1; - break; - } - - fwrite($fp, $row['template_data']); - fclose($fp); - } - $db->sql_freeresult($result); - - if (!$storedb) - { - $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $id"; - $db->sql_query($sql); - } - } - - $sql_ary = array( - 'template_storedb' => $storedb, - ); - } - break; - } - } - - if ($type != 'imageset' && sizeof($sql_ary)) - { - $sql = "UPDATE $sql_from - SET " . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE {$type}_id = $id"; - $db->sql_query($sql); - - if ($type == 'style' && $style_default) - { - set_config('default_style', $id); - } - } - - $cache->destroy('sql', STYLES_TABLE); - - add_log('admin', 'LOG_EDIT_' . $l_type, $name); - trigger_error($user->lang[$l_type . '_EDITED']); - } - } - - // Something went wrong ... so we'll clean up any decompressed uploaded/imported archives. - if ($tmp_path) - { - cleanup_folder($tmp_path); - } - - // Either an error occured or the user has just entered the form - if (!sizeof($error) && !$update && $id) - { - $sql = "SELECT * - FROM $sql_from - WHERE {$type}_id = $id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_' . $l_type]); - } - $db->sql_freeresult($result); - - $style_default = ($type == 'style' && $config['default_style'] == $id) ? 1 : 0; - $storedb = (!empty(${$type . '_storedb'})) ? true : false; // Fudged because we use $storedb when submitting data - } - - if ($type == 'style' && $action != 'install') - { - $style_options = array(); - foreach ($element_ary as $element => $table) - { - $sql = "SELECT {$element}_id, {$element}_name - FROM $table - ORDER BY {$element}_id ASC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row[$element . '_id'] == ${$element . '_id'}) ? ' selected="selected"' : ''; - ${$element . '_options'} .= ''; - } - $db->sql_freeresult($result); - } - } - - // Output the page - adm_page_header($user->lang[$l_prefix . '_' . $l_type]); - -?> - -lang[$l_prefix . '_' . $l_type . '_EXPLAIN']; ?>
- - - - - - - - - - - - -h1 |
- h2 |
- h3 |
-
mainmenu | -||
- |
titles - |
navlink | -
th | -||
---|---|---|
cattitle / cat | -catdiv | -|
topictitle / row1 | -- | topicdetails / row1 | -
row3 | -||
spacer | -||
- | postdetails / row2 | -postbody / row1 posthilit | -
gen | -genmed | -gensmall | -
copyright phpBB | -
postbody / bold italic underline | -||
|
- ||
|
- ||
|
-
IP whois for | -
---|
\2\3', $ipwhois);
- echo '' . trim($ipwhois) . ''; - } - -?> |
-
lang['USER_ADMIN_EXPLAIN']; ?>
- - - -acl_get('a_user')) -{ - trigger_error($user->lang['No_admin']); -} - -?> - -lang['USER_ADMIN_EXPLAIN']; ?>
- -lang['SELECT_USER']; ?> | -|
---|---|
lang['FIND_USERNAME']; ?>: [ " onclick="window.open('', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;">lang['FIND_USERNAME']; ?> ] |
- - |
- |
" target="_top">![]() |
- lang['ADMIN_TITLE']; ?> | -
|
-