/** * Runs on activation * * Currently: * - Calls `init` * - Calls `upgrade` * - Flushes the rewrite rules so this plugin's PT permalinks * are registered with WP * * @since 3.0.0 */ function activate() { init(); upgrade(); flush_rewrite_rules(); php_version_check(); }
function cmdStep0() { global $boarddir, $sourcedir, $db_prefix, $language, $modSettings, $start_time, $cachedir, $databases, $db_type, $smcFunc, $upcontext; global $language, $is_debug, $txt; $start_time = time(); ob_end_clean(); ob_implicit_flush(true); @set_time_limit(600); if (!isset($_SERVER['argv'])) { $_SERVER['argv'] = array(); } $_GET['maint'] = 1; foreach ($_SERVER['argv'] as $i => $arg) { if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { $_GET['lang'] = $match[1]; } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { continue; } elseif ($arg == '--no-maintenance') { $_GET['maint'] = 0; } elseif ($arg == '--debug') { $is_debug = true; } elseif ($arg == '--backup') { $_POST['backup'] = 1; } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($boarddir . '/Themes/converted'))) { $_GET['conv'] = 1; } elseif ($i != 0) { echo 'SMF Command-line Upgrader Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... --language=LANG Reset the forum\'s language to LANG. --no-maintenance Don\'t put the forum into maintenance mode. --debug Output debugging information. --backup Create backups of tables with "backup_" prefix.'; echo "\n"; exit; } } if (!php_version_check()) { print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); } if (!db_version_check()) { print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); } if (!empty($databases[$db_type]['alter_support']) && $smcFunc['db_query']('alter_boards', 'ALTER TABLE {db_prefix}boards ORDER BY id_board', array()) === false) { print_error('Error: The ' . $databases[$db_type]['name'] . ' account in Settings.php does not have sufficient privileges.', true); } $check = @file_exists($boarddir . '/Themes/default/index.template.php') && @file_exists($sourcedir . '/QueryString.php') && @file_exists($sourcedir . '/ManageBoards.php'); if (!$check && !isset($modSettings['smfVersion'])) { print_error('Error: Some files are missing or out-of-date.', true); } // Do a quick version spot check. $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); preg_match('~\\*\\s@version\\s+(.+)[\\s]{2}~i', $temp, $match); if (empty($match[1]) || $match[1] != SMF_VERSION) { print_error('Error: Some files have not yet been updated properly.'); } // Make sure Settings.php is writable. if (!is_writable($boarddir . '/Settings.php')) { @chmod($boarddir . '/Settings.php', 0777); } if (!is_writable($boarddir . '/Settings.php')) { print_error('Error: Unable to obtain write access to "Settings.php".', true); } // Make sure Settings.php is writable. if (!is_writable($boarddir . '/Settings_bak.php')) { @chmod($boarddir . '/Settings_bak.php', 0777); } if (!is_writable($boarddir . '/Settings_bak.php')) { print_error('Error: Unable to obtain write access to "Settings_bak.php".'); } if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { print_error('Error: Unable to obtain write access to "agreement.txt".'); } elseif (isset($modSettings['agreement'])) { $fp = fopen($boarddir . '/agreement.txt', 'w'); fwrite($fp, $modSettings['agreement']); fclose($fp); } // Make sure Themes is writable. if (!is_writable($boarddir . '/Themes')) { @chmod($boarddir . '/Themes', 0777); } if (!is_writable($boarddir . '/Themes') && !isset($modSettings['smfVersion'])) { print_error('Error: Unable to obtain write access to "Themes".'); } // Make sure cache directory exists and is writable! $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; if (!file_exists($cachedir_temp)) { @mkdir($cachedir_temp); } if (!is_writable($cachedir_temp)) { @chmod($cachedir_temp, 0777); } if (!is_writable($cachedir_temp)) { print_error('Error: Unable to obtain write access to "cache".', true); } if (!file_exists($boarddir . '/Themes/default/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { print_error('Error: Unable to find language files!', true); } else { $temp = substr(@implode('', @file($boarddir . '/Themes/default/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); preg_match('~(?://|/\\*)\\s*Version:\\s+(.+?);\\s*index(?:[\\s]{2}|\\*/)~i', $temp, $match); if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { print_error('Error: Language files out of date.', true); } if (!file_exists($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php')) { print_error('Error: Install language is missing for selected language.', true); } // Otherwise include it! require_once $boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php'; } // Make sure we skip the HTML for login. $_POST['upcont'] = true; $upcontext['current_step'] = 1; }
function cmdStep0() { global $boarddir, $sourcedir, $db_prefix, $language, $modSettings, $start_time; $start_time = time(); ob_end_clean(); ob_implicit_flush(true); @set_time_limit(0); if (!isset($_SERVER['argv'])) { $_SERVER['argv'] = array(); } $_GET['maint'] = 1; foreach ($_SERVER['argv'] as $i => $arg) { if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { $_GET['lang'] = $match[1]; } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { continue; } elseif ($arg == '--no-maintenance') { $_GET['maint'] = 0; } elseif ($arg == '--debug') { $_GET['debug'] = 1; } elseif ($arg == '--backup') { $_GET['backup'] = 1; } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($boarddir . '/Themes/converted'))) { $_GET['conv'] = 1; } elseif ($i != 0) { echo 'SMF Command-line Upgrader Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... --language=LANG Reset the forum\'s language to LANG. --no-maintenance Don\'t put the forum into maintenance mode. --debug Output debugging information. --backup Create backups of tables with "backup_" prefix.'; if (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($boarddir . '/Themes/converted')) { echo ' --template Convert the YaBB SE template file.'; } echo "\n"; exit; } } if (!php_version_check()) { print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); } if (!mysql_version_check()) { print_error('Error: MySQL ' . min(mysql_get_server_info(), mysql_get_client_info()) . ' does not match minimum requirements.', true); } if (mysql_query("ALTER TABLE {$db_prefix}boards ORDER BY ID_BOARD") === false) { print_error('Error: The MySQL account in Settings.php does not have sufficient privileges.', true); } $check = @file_exists($boarddir . '/Themes/default/index.template.php') && @file_exists($sourcedir . '/QueryString.php') && @file_exists($sourcedir . '/ManageBoards.php'); if (!$check && !isset($modSettings['smfVersion'])) { print_error('Error: Some files are missing or out-of-date.', true); } // Do a quick version spot check. $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); preg_match('~\\*\\s*Software\\s+Version:\\s+SMF\\s+(.+?)[\\s]{2}~i', $temp, $match); if (empty($match[1]) || $match[1] != SMF_VERSION) { print_error('Error: Some files have not yet been updated properly.'); } // Make sure Settings.php is writable. if (!is_writable($boarddir . '/Settings.php')) { @chmod($boarddir . '/Settings.php', 0777); } if (!is_writable($boarddir . '/Settings.php')) { print_error('Error: Unable to obtain write access to "Settings.php".'); } // Make sure Settings.php is writable. if (!is_writable($boarddir . '/Settings_bak.php')) { @chmod($boarddir . '/Settings_bak.php', 0777); } if (!is_writable($boarddir . '/Settings_bak.php')) { print_error('Error: Unable to obtain write access to "Settings_bak.php".'); } if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { print_error('Error: Unable to obtain write access to "agreement.txt".'); } elseif (isset($modSettings['agreement'])) { $fp = fopen($boarddir . '/agreement.txt', 'w'); fwrite($fp, $modSettings['agreement']); fclose($fp); } // Make sure Themes is writable. if (!is_writable($boarddir . '/Themes')) { @chmod($boarddir . '/Themes', 0777); } if (!is_writable($boarddir . '/Themes') && !isset($modSettings['smfVersion'])) { print_error('Error: Unable to obtain write access to "Themes".'); } if (!file_exists($boarddir . '/Themes/default/languages/index.' . basename($language, '.lng') . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { print_error('Error: Unable to find language files!'); } else { $temp = substr(@implode('', @file($boarddir . '/Themes/default/languages/index.' . (isset($_GET['lang']) ? $_GET['lang'] : basename($language, '.lng')) . '.php')), 0, 4096); preg_match('~(?://|/\\*)\\s*Version:\\s+(.+?);\\s*index(?:[\\s]{2}|\\*/)~i', $temp, $match); if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { print_error('Error: Language files out of date.'); } } return doStep1(); }