function performAction_settings($getPage_connection2)
{
    if ($_SESSION["action"] == "change") {
        changeSettings($getPage_connection2);
    }
    // if
}
Beispiel #2
0
include_once "header.php";
?>

<?php 
include_once "db.php";
include_once "mindoflib.php";
if (stripslashes(!$_POST['checksubmit']) && checkCookie()) {
    showSettingsform();
} else {
    if (checkCookie()) {
        $username = getUserName();
        $site = strip_tags($_POST['site']);
        $url = stripslashes($_POST['url']);
        $numberIndex = stripslashes($_POST['index']);
        $numberRSS = stripslashes($_POST['rss']);
        $user = $username;
        $pass = stripslashes($_POST['pass']);
        $logincheck = checkLogin($user, $pass);
        if ($logincheck == 0) {
            changeSettings($site, $url, $numberIndex, $numberRSS);
        } else {
            echo "the username and/or password you entered was wrong.  please <a href='settings.php'>try again</a>.";
        }
    } else {
        echo "please <a href='login.php'>login</a> in order to change the site settings!";
    }
}
?>
</body>
</html>
Beispiel #3
0
<?php

include_once "header.php";
?>

<?php 
include_once "db.php";
include_once "sourlib.php";
if (stripslashes(!$_POST['checksubmit']) && checkCookie()) {
    showSettingsform();
} else {
    if (checkCookie()) {
        $purgedays = $_POST['purgedays'];
        changeSettings($purgedays);
    } else {
        echo "please <a href='login.php'>login</a> in order to change the site settings!";
    }
}
?>
</body>
</html>
Beispiel #4
0
/**
 * Delete the damn thing!
 * Finalizes the upgrade
 * Updates maintenance mode to what it was before the upgrade started
 * Updates settings.php, sometimes even correctly
 * Flushes the cache so there is a clean start
 * Runs a scheduled fetch files so the install can be checked in the admin panel
 */
function action_deleteUpgrade()
{
    global $command_line, $language, $upcontext, $forum_version, $user_info, $maintenance, $db_type;
    // Now it's nice to have some of the basic source files.
    if (!isset($_GET['ssi']) && !$command_line) {
        redirectLocation('&ssi=1');
    }
    $upcontext['sub_template'] = 'upgrade_complete';
    $upcontext['page_title'] = 'Upgrade Complete';
    $endl = $command_line ? "\n" : '<br />' . "\n";
    $changes = array('language' => '\'' . (substr($language, -4) == '.lng' ? substr($language, 0, -4) : $language) . '\'', 'db_error_send' => '1');
    // Are we in maintenance mode?
    if (isset($upcontext['user']['main'])) {
        if ($command_line) {
            echo ' * ';
        }
        $upcontext['removed_maintenance'] = true;
        $changes['maintenance'] = $upcontext['user']['main'];
    } elseif (!empty($maintenance) && $maintenance == 2) {
        $changes['maintenance'] = 1;
    }
    // Wipe this out...
    $upcontext['user'] = array();
    // @todo this is mad and needs to be looked at
    // Make a backup of Settings.php first as otherwise earlier changes are lost.
    copy(BOARDDIR . '/Settings.php', BOARDDIR . '/Settings_bak.php');
    changeSettings($changes);
    // Now remove our marker
    $changes = array('upgradeData' => '#remove#');
    changeSettings($changes);
    copy(BOARDDIR . '/Settings.php', BOARDDIR . '/Settings_bak.php');
    // Clean any old cache files away.
    clean_cache();
    // Can we delete the file?
    $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
    // Now is the perfect time to fetch the ELK files.
    if ($command_line) {
        cli_scheduled_fetchFiles();
    } else {
        // The variable is usually defined in index.php so lets just use the constant to do it for us.
        $forum_version = CURRENT_VERSION;
        // Now go get those files!
        require_once SUBSDIR . '/ScheduledTask.class.php';
        $task = new Scheduled_Task();
        $task->fetchFiles();
    }
    // Log what we've done.
    if (empty($user_info['id'])) {
        $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
    }
    // We need to log in the database
    $db = database();
    // Log the action manually, so CLI still works.
    $db->insert('', '{db_prefix}log_actions', array('log_time' => 'int', 'id_log' => 'int', 'id_member' => 'int', 'ip' => 'string-16', 'action' => 'string', 'id_board' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'extra' => 'string-65534'), array(time(), 3, $user_info['id'], $command_line ? '127.0.0.1' : $user_info['ip'], 'upgrade', 0, 0, 0, serialize(array('version' => $forum_version, 'member' => $user_info['id']))), array('id_action'));
    $user_info['id'] = 0;
    // Save the current database version.
    $server_version = $db->db_server_info();
    if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
        updateSettings(array('db_mysql_group_by_fix' => '1'));
    }
    // Set jquery to auto if its not already set
    if (!isset($modSettings['jquery_source'])) {
        updateSettings(array('jquery_source' => 'auto'));
    }
    if ($command_line) {
        echo $endl;
        echo 'Upgrade Complete!', $endl;
        echo 'Please delete this file as soon as possible for security reasons.', $endl;
        exit;
    }
    // Make sure it says we're done.
    $upcontext['overall_percent'] = 100;
    if (isset($upcontext['step_progress'])) {
        unset($upcontext['step_progress']);
    }
    $_GET['substep'] = 0;
    return false;
}
Beispiel #5
0
function checkFlags()
{
    global $config;
    logMessage("Checking remote Flags");
    $post = array('action' => 'getFlags', 'PID' => $config->PID);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $config->serverurl);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close($ch);
    logMessage("Got result: " . $result);
    $jsonout = json_decode($result);
    if ($jsonout->takePic == 1) {
        logMessage("Taking pic, say cheese!");
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://localhost:8080/0/action/snapshot");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close($ch);
        sleep(3);
        // just a little delay to take the pic
        uploadNewPics();
    }
    if ($jsonout->changeSettings == 1) {
        changeSettings();
    }
    if (count($jsonout->needPics) > 0) {
        foreach ($jsonout->needPics as $PicID) {
            uploadOnePic($PicID);
        }
    }
    if ($jsonout->takePic || $jsonout->changeSettings || $jsonout->forceReboot) {
        resetFlags();
    }
    foreach ($jsonout->Files as $filename => $version) {
        if (checkFileVersion($filename) < $version) {
            loadNewFile($filename);
            if (basename($filename) == 'interact.php') {
                $str = "/usr/bin/php {$filename}";
                $pidfile = "/dev/shm/naboor.pid";
                exec(sprintf("%s > %s 2>&1 & echo \$! >> %s", $str, "/dev/null", $pidfile));
                die;
            } elseif (basename($filename) == 'parsejson.php') {
                if (is_file("/dev/shm/upload/parsejson.pid")) {
                    $pid = file_get_contents("/dev/shm/upload/parsejson.pid");
                    exec("kill {$pid}");
                    checkParseJsonRunning();
                }
            }
        }
    }
    if (property_exists($jsonout, "command")) {
        //TODO:execute command and upload results to server
    }
    if (property_exists($jsonout, "mayday") && $jsonout->mayday == 1) {
        //TODO:open SSH session
    }
    if ($jsonout->forceReboot == 1) {
        //TODO:Dan, add some code here
        $str = "shutdown -h now";
        exec(sprintf("%s > %s 2>&1 & echo \$! >> %s", $str, "/dev/null", $pidfile));
        die;
        //should never get here
    }
}
Beispiel #6
0
<?php

include_once "header.php";
?>

<?php 
include_once "db.php";
include_once "mooshulib.php";
if (stripslashes(!$_POST['checksubmit']) && checkCookie()) {
    showSettingsform();
} else {
    if (checkCookie()) {
        $username = getUserName();
        $site = strip_tags($_POST['site']);
        $url = stripslashes($_POST['url']);
        $user = $username;
        $pass = stripslashes($_POST['pass']);
        $logincheck = checkLogin($user, $pass);
        if ($logincheck == 0) {
            changeSettings($site, $url);
        } else {
            echo "the username and/or password you entered was wrong.  please <a href='settings.php'>try again</a>.";
        }
    } else {
        echo "please <a href='login.php'>login</a> in order to change the site settings!";
    }
}
?>
</body>
</html>
Beispiel #7
0
<?php

include_once "header.php";
include_once "db.php";
include_once "dertyn.php";
if (!$_POST['checksubmit'] && checkCookie()) {
    showSettingsform();
} else {
    if (checkCookie()) {
        $username = getUserName();
        $site = strip_tags($_POST['site']);
        $tagline = strip_tags($_POST['tagline']);
        $realname = strip_tags($_POST['realname']);
        $url = $_POST['url'];
        $numberIndex = $_POST['index'];
        $numberRSS = $_POST['rss'];
        $rewrite = $_POST['rewrite'];
        $user = $username;
        $pass = $_POST['pass'];
        $logincheck = checkLogin($user, $pass);
        if ($logincheck == 0) {
            changeSettings($site, $url, $realname, $numberIndex, $numberRSS, $rewrite, $tagline);
        } else {
            echo "the username and/or password you entered was wrong.  please <a href='settings.php'>try again</a>.";
        }
    } else {
        echo "please <a href='login.php'>login</a> in order to change the site settings!";
    }
}
include_once "footer.php";
Beispiel #8
0
function doStep2()
{
    global $db_prefix, $modSettings, $command_line;
    global $language, $boardurl, $sourcedir, $boarddir;
    $_GET['step'] = '2';
    $endl = $command_line ? "\n" : '<br />' . "\n";
    // Okay, so we want to upgrade to 1.0 if not at 1.0 or higher.
    if (@$modSettings['smfVersion'] < '1.1' && empty($_GET['s'])) {
        parse_sql(dirname(__FILE__) . '/upgrade_1-0.sql');
        // Don't wanna do this part again, though we're not ready yet.
        upgrade_query("\n\t\t\tREPLACE INTO {$db_prefix}settings\n\t\t\t\t(variable, value)\n\t\t\tVALUES\n\t\t\t\t('smfVersion', '1.1 RC0')");
    }
    $_GET['s'] = 1;
    parse_sql(dirname(__FILE__) . '/upgrade_1-1.sql');
    if (!empty($_GET['debug'])) {
        echo $command_line ? ' +++ ' : '&nbsp;&nbsp;&nbsp;', 'Updating version number...';
    }
    upgrade_query("\n\t\tREPLACE INTO {$db_prefix}settings\n\t\t\t(variable, value)\n\t\tVALUES\n\t\t\t('smfVersion', '" . SMF_VERSION . "')");
    if (!empty($_GET['debug'])) {
        echo ' done.', $endl;
    }
    // Almost done... convert the template.php or template.html file?
    if (isset($_GET['conv']) && !file_exists($boarddir . '/Themes/converted')) {
        if (!empty($_GET['debug'])) {
            echo $command_line ? ' +++ ' : '&nbsp;&nbsp;&nbsp;', 'Converting the template...';
        }
        require_once $sourcedir . '/Themes.php';
        mkdir($boarddir . '/Themes/converted', 0777);
        convert_template($boarddir . '/Themes/converted');
        // Copy over the default index.php file.
        copy($boarddir . '/Themes/classic/index.php', $boarddir . '/Themes/converted/index.php');
        @chmod($boarddir . '/Themes/converted/index.php', 0777);
        // Now set up the "converted" theme.
        $values = array('name' => 'Converted Theme from YaBB SE', 'theme_url' => $boardurl . '/Themes/classic', 'images_url' => $boardurl . '/Themes/classic/images', 'theme_dir' => strtr($boarddir, array('\\' => '/')) . '/Themes/converted', 'base_theme_dir' => strtr($boarddir, array('\\' => '/')) . '/Themes/classic');
        // Get an available ID_THEME first...
        $request = upgrade_query("\n\t\t\tSELECT MAX(ID_THEME) + 1\n\t\t\tFROM {$db_prefix}themes");
        list($ID_THEME) = mysql_fetch_row($request);
        mysql_free_result($request);
        $setString = '';
        foreach ($values as $variable => $value) {
            $setString .= "\n\t\t\t\t\t(0, " . $ID_THEME . ", '" . $variable . "', '" . $value . "'),";
        }
        if (!empty($setString)) {
            upgrade_query("\n\t\t\t\tINSERT IGNORE INTO {$db_prefix}themes\n\t\t\t\tVALUES " . substr($setString, 0, -1));
        }
        upgrade_query("\n\t\t\tUPDATE {$db_prefix}settings\n\t\t\tSET value = CONCAT(value, ',{$ID_THEME}')\n\t\t\tWHERE variable = 'knownThemes'\n\t\t\tLIMIT 1");
        upgrade_query("\n\t\t\tREPLACE INTO {$db_prefix}settings\n\t\t\t\t(variable, value)\n\t\t\tVALUES ('theme_guests', {$ID_THEME}),\n\t\t\t\t('smiley_sets_default', 'classic')");
        if (!empty($_GET['debug'])) {
            echo ' done.', $endl;
        }
    }
    $changes = array('language' => '\'' . (substr($language, -4) == '.lng' ? substr($language, 0, -4) : $language) . '\'', 'db_error_send' => '1');
    if (!empty($_GET['maint'])) {
        echo $command_line ? ' * ' : '', 'Taking the forum out of maintenance mode...';
        $changes['maintenance'] = '0';
    }
    // Make a backup of Settings.php first as otherwise earlier changes are lost.
    copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
    changeSettings($changes);
    if (!empty($_GET['maint'])) {
        echo ' Successful.', $endl;
    }
    if ($command_line) {
        echo $endl;
        echo 'Upgrade Complete!', $endl;
        echo 'Please delete this file as soon as possible for security reasons.', $endl;
        return true;
    }
    echo '
			<h2 style="margin-top: 2ex;">Upgrade Complete</h2>
			<h3>That wasn\'t so hard, was it?  Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>.  Hope you like it!</h3>';
    if (is_writable(dirname(__FILE__)) || is_writable(__FILE__)) {
        echo '
			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" /> Delete this upgrade.php and its data files now.</label> <i>(doesn\'t work on all servers.)</i>
			<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
				function doTheDelete(theCheck)
				{
					var theImage = document.getElementById ? document.getElementById("delete_upgrader") : document.all.delete_upgrader;

					theImage.src = "', $_SERVER['PHP_SELF'], '?delete=1&ts=" + (new Date().getTime());
					theCheck.disabled = true;
				}
			// ]]></script>
			<img src="', $boardurl, '/Themes/default/images/blank.gif" alt="" id="delete_upgrader" /><br />';
    }
    echo '<br />
			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br />
			<br />
			Best of luck,<br />
			Simple Machines';
    return true;
}