Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // SQL fixing
- // ####################### SET PHP ENVIRONMENT ###########################
- error_reporting(E_ALL & ~E_NOTICE & ~8192);
- // #################### DEFINE IMPORTANT CONSTANTS #######################
- define('THIS_SCRIPT', 'sqlfi');
- // ################### PRE-CACHE TEMPLATES AND DATA ######################
- // get special phrase groups
- $phrasegroups = array();
- // get special data templates from the datastore
- $specialtemplates = array(
- );
- // pre-cache templates used by all actions
- $globaltemplates = array(
- );
- // pre-cache templates used by specific actions
- $actiontemplates = array();
- // ######################### REQUIRE BACK-END ############################
- require_once('./global.php');
- $tables = $db->list_tables();
- $start = microtime(true);
- function check_execution_time() // returns true if CAN continue, else false
- {
- global $start;
- if (intval(microtime(true) - $start) > 99999999999999)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- function strposa($haystack ,$needles=array(),$offset=0) // strpos with array support
- {
- $chr = array();
- foreach($needles as $needle)
- {
- $strpos = strpos($haystack,$needle,$offset);
- if ($strpos !== false)
- {
- $chr[] = $strpos;
- }
- }
- if(empty($chr)) return false;
- return min($chr);
- }
- // loopers
- $table_loop = 1;
- $field_loop = 1;
- $row_loop = 1;
- // current values
- $current_table = 0;
- $current_field = 0;
- $current_row = 0;
- // parsed data
- $parsed_tables = array();
- $parsed_fields = array();
- $parsed_rows = array();
- $ignore_tables = array( // careful, this is a wildcard ignore
- 'admin',
- 'album',
- 'avatar',
- 'bbcode',
- 'calendar',
- 'cron',
- 'cpsession',
- 'log',
- 'payment',
- 'picture',
- 'profile',
- 'rss',
- 'group',
- 'subscribe',
- 'tachy',
- 'temp',
- 'hash',
- 'forum_announcementread',
- 'forum_attachmentviews',
- 'forum_covers',
- 'forum_discussionread',
- 'forum_forumprefixset',
- 'forum_forumread',
- 'forum_hvquestion',
- 'forum_imagecategorypermission',
- 'forum_infractiongroup',
- 'forum_linking',
- 'forum_maillist',
- 'forum_moderation',
- 'forum_moderatorlog',
- 'forum_noticecriteria',
- 'forum_noticedismissed',
- 'forum_passwordhistory',
- 'forum_pmthrottle',
- 'forum_postlog',
- 'forum_prefixpermission',
- 'forum_tagsearch',
- 'forum_tagthread',
- //'forum_template',
- 'forum_templatehistory',
- 'forum_threadread',
- 'forum_threadviews',
- 'forum_upgradelog',
- 'forum_useractivation',
- 'forum_userchangelog',
- 'forum_usergroupleader',
- 'forum_usergrouprequest',
- 'ow',
- 'access',
- 'attachment',
- 'bookmarksite',
- 'cache',
- 'faq',
- 'permission',
- 'holiday',
- 'verify',
- 'answer',
- 'icon',
- 'image',
- 'infraction',
- 'language',
- 'queue',
- 'plugin',
- 'podcast',
- 'product',
- 'ranks',
- 'reminder',
- 'session',
- 'search',
- 'reputation',
- 'setting',
- 'sig',
- 'stats',
- 'smili',
- 'prefix',
- 'event',
- 'forum_forum',
- 'forum_store',
- 'ressources',
- 'poll',
- 'moderator',
- 'post_thanks',
- 'phrase',
- 'parsed',
- );
- $ignore_fields = array(
- 'id',
- 'path',
- 'date',
- 'time',
- 'type',
- 'height',
- 'width',
- 'thumbnail',
- 'size',
- 'enabled',
- 'display',
- 'visible',
- 'password',
- 'list',
- 'url',
- 'deleted',
- 'show',
- 'address',
- 'hash',
- 'regex',
- 'point',
- 'reason',
- 'phrasegroup',
- 'code',
- 'email',
- 'header',
- 'condition',
- 'array',
- 'denied',
- 'name',
- 'keywords',
- 'author',
- 'repu',
- 'sign',
- 'allow',
- 'state',
- 'folder',
- 'field',
- 'last',
- 'permission',
- 'userip',
- );
- $parse = array(
- array(
- 'è',
- 'é',
- 'Ã',
- 'àŠ',
- 'à»',
- 'àª',
- ),
- array(
- htmlspecialchars('è'),
- htmlspecialchars('é'),
- htmlspecialchars('à'),
- htmlspecialchars('ê'),
- htmlspecialchars('û'),
- htmlspecialchars('ê'),
- )
- );
- $debug_full = false;
- // main table loop, excluding
- while($table_loop < count($tables))
- {
- if(!check_execution_time())
- {
- echo "<br><br>Warning: Execution time exeeded 25seconds, loop broken !";
- break;
- }
- // resetting loops
- $field_loop = 0;
- $row_loop = 0;
- $current_table = $tables[$table_loop];
- if(strposa($current_table,$ignore_tables) !== FALSE)
- {
- if ($debug_full)
- {
- echo "------------------------------<br>Parsing table: $current_table<br><br>";
- echo 'This table is in ignore list, table skipped!<br>------------------------------<br>';
- }
- $parsed_tables[] = $current_table;
- ++$table_loop;
- continue;
- }
- $fields = $db->list_fields($current_table,$ignore_fields);
- $data = $db->query_read("SELECT " . implode(',',$fields) . " FROM $current_table LIMIT 0,99999");
- $rows = $db->num_rows($data);
- if($rows == 0 or count($fields) == 0)
- {
- if($debug_full)
- {
- echo "------------------------------<br>Parsing table: $current_table<br><br>";
- echo "Nothing to parse, table skipped!<br>------------------------------<br>";
- }
- $parsed_tables[] = $current_table;
- ++$table_loop;
- continue;
- }
- else
- {
- //echo "------------------------------<br>Parsing table: $current_table<br><br>";
- //echo "* The table has " . count($fields) . " fields to parse<br>";
- //echo "* The table has $rows rows of data to parse<br>";
- // starting parse
- while($data_row = $db->fetch_array($data))
- {
- foreach($data_row as $data_field=>$data_content)
- {
- if(strposa($data_content,$parse[0]) !== FALSE)
- {
- print("UPDATE
- $current_table
- SET $data_field='" . addslashes(str_replace($parse[0],$parse[1],$data_content)) . "'
- WHERE $data_field='" . addslashes($data_content) . "';
- \n");
- }
- }
- ++$current_row;
- }
- //echo "Table parsed.";
- ++$table_loop;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment