private static function fix_missing_site_threads(GDO_Database $db_from, GDO_Database $db_to, array &$db_offsets) { GDO::setCurrentDB($db_to); $table = GDO::table('WC_Site'); $module = GWF_Module::getModule('WeChall'); // Boards // if (false === ($result = $table->select('*'))) // { // echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); // return false; // } // while (false !== ($site = $table->fetch($result, GDO::ARRAY_O))) // { // $site instanceof WC_Site; // if (false === GDO::table('GWF_ForumBoard')->select('1', "board_id={$site->getBoardID()}")) // { // GWF_Cronjob::notice(sprintf('Site %s has no board!', $site->getClassName())); // $site->onCreateBoard(); // } // } // $table->free($result); // Threads if (false === ($result = $table->select('*'))) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } while (false !== ($site = $table->fetch($result, GDO::ARRAY_O))) { $site instanceof WC_Site; if (false === $site->getThread()) { GWF_Cronjob::notice(sprintf('Site %s has no thread!', $site->getClassName())); $site->onCreateThread($module); } } $table->free($result); }
$uid = exec("id '{$susername}'"); $pusername = preg_quote($username); if (1 !== preg_match("/(\\d+)\\({$pusername}\\)/", $uid, $matches)) { return false; } return (int) $matches[1]; } $query = "SELECT * FROM war_audit_add_user"; $uidfile = GWF_CORE_PATH . 'module/Audit/ruth/lastwcid'; if (false === ($result = $db->queryRead($query))) { die('DB ERROR 1'); } while (false !== ($row = $db->fetchAssoc($result))) { $username = $row['username']; if (!preg_match('/^[a-z][a-z0-9_]{0,31}$/iD', $username)) { GWF_Cronjob::error('Username invalid: ' . $username); continue; } $create = false; $crypt_pass = escapeshellarg($row['password']); if (false === ($uid = getUID($username))) { $nextuid = trim(file_get_contents($uidfile)); $nextuid++; $uid = $nextuid; file_put_contents($uidfile, $uid); $create = true; } if ($uid > 3000) { if ($create) { system(GWF_PATH . 'core/module/Audit/ruth/adduser.sh' . " {$uid} {$username} {$crypt_pass}"); } else {
function merge_users(GDO_Database $db_from, GDO_Database $db_to, array &$db_offsets, $prefix, $prevar) { $db_offsets['user_name'] = array(); GDO::setCurrentDB($db_from); $users = GDO::table('GWF_User'); if (false === ($result = $users->select('*', '', 'user_id ASC'))) { echo GWF_Error::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } GDO::setCurrentDB($db_to); $to_users = GDO::table('GWF_User'); $off = $db_offsets['GWF_User']; while (false !== ($user = $users->fetch($result, GDO::ARRAY_A))) { $oldname = $user['user_name']; $newname = merge_user_name($user['user_name'], $to_users, $prefix, $prevar); $user['user_name'] = $newname; if ($oldname !== $newname) { $db_offsets['user_name'][$oldname] = $newname; } $user['user_id'] += $off; $to_users->insertAssoc($user); GWF_Cronjob::log('Added user ' . $user['user_name'] . ' with id ' . $user['user_id']); } $users->free($result); return true; }
private static function cronjobsSession() { GWF_Cronjob::start('Session'); $table = GDO::table('GWF_Session'); $cut = time() - GWF_SESS_LIFETIME; if (false === $table->deleteWhere("sess_time<{$cut}")) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } elseif (0 < ($affected = $table->affectedRows())) { GWF_Cronjob::notice(sprintf('Deleted %s sesssions.', $affected)); } GWF_Cronjob::end('Session'); }
chdir('../../../www'); require_once 'protected/config.php'; require_once '../gwf3.class.php'; $gwf = new GWF3(getcwd(), array('init' => true, 'bootstrap' => false, 'website_init' => true, 'autoload_modules' => false, 'load_module' => false, 'start_debug' => true, 'get_user' => false, 'do_logging' => false, 'buffered_log' => false, 'log_request' => false, 'blocking' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false, 'kick_banned_ip' => false)); require_once 'merge/mergefuncs.php'; GWF_Log::init(false, 0x7fffffff, 'protected/logs/merge'); if ($argc !== 6) { merge_usage(); } GWF_Log::logCron('======================'); GWF_Log::logCron('=== STARTING MERGE ==='); GWF_Log::logCron('======================'); if (false === ($db_from = merge_db($argv))) { GWF_Log::logCritical('Connection to the import db failed!'); } $db_to = gdo_db(); // Store some offsets, like highest user(sic) => 1234 $db_offsets = array(); $prefix = $argv[4]; $prevar = $argv[5]; $modules = GWF_ModuleLoader::loadModulesFS(); $modules = GWF_ModuleLoader::sortModules($modules, 'module_priority', 'ASC'); GWF_Log::logCron('=== LOADED MODULES ==='); GWF_Log::logCron('======================'); merge_core($db_from, $db_to, $db_offsets, $prefix, $prevar); foreach ($modules as $module) { $module instanceof GWF_Module; GWF_Cronjob::notice(sprintf('MERGE MODULE %s', $module->getName())); GWF_ModuleLoader::includeAll($module); $module->onMerge($db_from, $db_to, $db_offsets, $prefix, $prevar); }