Beispiel #1
0
/**
 * if user agrees to send system information and the last sent info is outdated outputs a bunch of stuff that sends sysinfo without interrupting
 */
function fs_output_send_info_form()
{
    if (fs_is_admin() && fs_get_system_option("user_agreed_to_send_system_information") && fs_last_sent_info_outdated()) {
        ?>
        <iframe id="hidden_frame" name="hidden_frame" style="width:0px; height:0px; border: 0px" src="about:blank"></iframe>
        <form name="send_info_form" target="hidden_frame" method="post" action="<?echo FS_SYSINFO_URL?>">
            <?php 
        $sysinfo = fs_get_sysinfo();
        foreach ($sysinfo as $k => $v) {
            ?>
                        <input type="hidden" name="<?php 
            echo $k;
            ?>
" value="<?php 
            echo $v;
            ?>
"></input>
                    <?php 
        }
        ?>
        </form>
        <script type='text/javascript'>
        sendSilentRequest('action=saveSentSysInfo');
        document.forms['send_info_form'].submit();
        </script>
    <?php 
    }
}
Beispiel #2
0
/**
 * store some usage FireStats usage information
 */
function fs_maintain_usage_stats()
{
    if (fs_is_admin()) {
        $first_run_time = fs_get_system_option('first_run_time');
        if (!$first_run_time) {
            fs_update_system_option('first_run_time', time());
        }
        $firestats_id = fs_get_system_option('firestats_id');
        if (!$firestats_id) {
            fs_update_system_option('firestats_id', mt_rand());
        }
    }
    $first_login = fs_get_option('first_login');
    if (!$first_login) {
        fs_update_option('first_login', time());
    }
}
Beispiel #3
0
<?php 
if (fs_db_valid()) {
    fs_output_send_info_form();
    ?>

<script type='text/javascript'>
//<![CDATA[
	// this is done here instead of sending an updated page in the first place
	// to improve startup time.
	updateAllStats();
	toggleAutoRefresh();
	sendSilentRequest('action=getNextUserMessage');

	<?php 
    if (fs_is_admin()) {
        if (fs_get_auto_bots_list_update() == 'true') {
            ?>
			sendSilentRequest('action=updateBotsList&update=botlist_placeholder,num_excluded&user_initiated=false');
			<?php 
        }
        if (fs_get_system_option('archive_method') == 'auto') {
            ?>
			FS.archiveOldData();
			<?php 
        }
        ?>
		sendSilentRequest('action=handle_pending_maintanence');
		<?php 
    }
    ?>
Beispiel #4
0
function fs_delete_user($id)
{
    if (!fs_is_admin()) {
        return "Access denied : fs_delete_user";
    }
    $fsdb =& fs_get_db_conn();
    $users = fs_users_table();
    $id = $fsdb->escape($id);
    $sql = "DELETE FROM `{$users}` WHERE `id`={$id}";
    $r = $fsdb->query($sql);
    if ($r === false) {
        return fs_db_error();
    }
    return true;
}
Beispiel #5
0
?>
				</select>
				<button class="button" 
					onclick="saveOption('whois_providers','whois_provider','string','records_table')">
					<?php 
fs_e('Save');
?>
				</button>
				<?php 
fs_create_wiki_help_link('WhoisProviders', 800, 600);
?>
		<br/>
			</td>
		</tr>
	<?php 
if (fs_is_admin() || fs_is_demo()) {
    ?>
	<tr>
		<td class="config_cell" colspan="2">
		
		<h3><?php 
    fs_e('Compact old data');
    ?>
			<?php 
    fs_create_wiki_help_link('ArchiveOldData');
    ?>
		</h3>
		<?php 
    if (fs_mysql_newer_than("4.1.14")) {
        ?>
		<?php 
Beispiel #6
0
function fs_ajax_getNextUserMessage(&$response)
{
    require_once FS_ABS_PATH . '/php/html-utils.php';
    require_once FS_ABS_PATH . '/php/utils.php';
    // currently we don't show any user messages in demo mode.
    if (fs_is_demo()) {
        return;
    }
    if (fs_is_admin() && fs_get_system_option("user_agreed_to_send_system_information", '') == '') {
        fs_ajax_get_window($response, 'ask_to_send_sysinfo');
    } else {
        if (fs_time_to_nag()) {
            fs_ajax_get_window($response, 'ask_for_donation');
        } else {
            if (fs_is_admin() && fs_mysql_newer_than("4.1.14") && fs_get_system_option('archive_method') == null && fs_get_num_old_days() > 0) {
                // if the user never selected archive method
                fs_ajax_get_window($response, 'notify_about_archive');
            }
        }
    }
}
Beispiel #7
0
function fs_create_new_database($host, $admin_user, $admin_pass, $user, $pass, $dbname, $table_prefix)
{
    if (!fs_is_admin()) {
        return fs_get_db_response("access_denied", "Access denied : fs_create_new_database");
    }
    require_once dirname(__FILE__) . "/ezsql/mysql/ez_sql_mysql.php";
    require_once dirname(__FILE__) . "/ezsql/shared/ez_sql_core.php";
    require_once dirname(__FILE__) . "/db-setup.php";
    if ($user == '' || $pass == '') {
        $user = $admin_user;
        $pass = $admin_pass;
    }
    $conn = new fs_ezSQL_mysql($admin_user, $admin_pass, $dbname, $host);
    $conn->hide_errors();
    if (!fs_config_writeable()) {
        return fs_get_db_response('read_only_config');
    }
    if (!$conn->connect($admin_user, $admin_pass, $host, false)) {
        return fs_get_db_response('db_connect_error', $conn->last_error);
    }
    $db = $conn->query("SHOW DATABASES LIKE '{$dbname}'");
    if ($db === false) {
        return fs_get_db_response('db_access_error', $conn->last_error);
    }
    $existed = $db == 1;
    if ($conn->query("CREATE DATABASE IF NOT EXISTS `{$dbname}`") === false) {
        return fs_get_db_response('db_create_error', $conn->last_error);
    }
    if ($conn->query("GRANT SELECT, INSERT, UPDATE, \n\t\t\t\t\t\t\tDELETE, CREATE, ALTER, INDEX, \n\t\t\t\t\t\t\tDROP, CREATE TEMPORARY TABLES \n\t\t\t\t\t\t\tON `{$dbname}`.*\n\t\t\t\t\t\t\tTO `{$user}` IDENTIFIED BY '{$pass}';") === false) {
        $last_error = $conn->last_error;
        if (!$existed) {
            $conn->query("DROP DATABASE `{$dbname}`");
        }
        return fs_get_db_response('user_create_error', $last_error);
    }
    ob_start();
    $install_res = fs_install_into($user, $pass, $dbname, $host);
    $output = ob_get_clean();
    if (!$install_res) {
        $last_error = $conn->last_error;
        if (!$existed) {
            $conn->query("DROP DATABASE `{$dbname}`");
        }
        return fs_get_db_response('tables_create_error', $last_error . ($output ? ', Output: ' . $output : ''));
    }
    $r = fs_save_config_file($host, $user, $pass, $dbname, $table_prefix);
    if ($r != '') {
        if (!$existed) {
            $conn->query("DROP DATABASE `{$dbname}`");
        }
        return fs_get_db_response('config_save_error', $conn->last_error);
    }
    $conn->disconnect();
    return fs_get_db_response('db_created', $conn->last_error);
}
Beispiel #8
0
function fs_update_local_option($key, $value)
{
    // only administrators may change local options.
    // local options are site wide, but on the level of the site that implements
    // the fs_update_local_option_impl function.
    if (fs_in_wordpress() && fs_is_wpmu()) {
        // even non admin user is allowed to save those options in a wpmu blog.
        $allowed = array('firestats_show_footer', 'firestats_show_footer_stats', 'firestats_add_comment_flag', 'firestats_add_comment_browser_os');
    } else {
        $allowed = array();
    }
    if (!fs_is_admin() && !in_array($key, $allowed)) {
        echo "Access denied : fs_update_local_option, not admin";
        return;
    }
    $fs_local_options_list = fs_get_local_options_list();
    if (!in_array($key, $fs_local_options_list)) {
        echo "fs_update_local_option: {$key} is not an authorized local option<br/>";
        return;
    }
    if (function_exists('fs_update_local_option_impl')) {
        fs_update_local_option_impl($key, $value);
    } else {
        fs_update_option($key, $value);
    }
}