Ejemplo n.º 1
0
function cs_repair_board($thread_id = 0)
{
    $q_time = "UPDATE {pre}_threads thr SET threads_last_time = (SELECT " . "MAX(com.comments_time) FROM {pre}_comments com WHERE thr.threads_id = " . "com.comments_fid AND com.comments_mod = 'board')";
    $q_time .= empty($thread_id) ? '' : " WHERE threads_id = " . (int) $thread_id;
    cs_sql_query(__FILE__, $q_time);
    $q_user = "******" . "FROM {pre}_comments com WHERE com.comments_fid = thr.threads_id GROUP BY " . " com.comments_fid HAVING MAX(com.comments_time))";
    $q_user .= empty($thread_id) ? '' : " WHERE threads_id = " . (int) $thread_id;
    cs_sql_query(__FILE__, $q_user);
    $q_repair = "UPDATE {pre}_threads SET threads_last_user = users_id, " . "threads_last_time = threads_time WHERE threads_last_time = 0";
    cs_sql_query(__FILE__, $q_repair);
}
Ejemplo n.º 2
0
function cs_sql_insertid($cs_file)
{
    global $cs_db;
    if ($cs_db['type'] == 'pdo_pgsql') {
        $found = cs_sql_query($cs_file, 'SELECT LASTVAL()', 1);
        $result = isset($found['more'][0]['lastval']) ? $found['more'][0]['lastval'] : NULL;
    } else {
        $result = $cs_db['con']->lastInsertId();
    }
    if ($result > 0) {
        return $result;
    } else {
        cs_error_sql($cs_file, 'cs_sql_insertid', cs_sql_error());
    }
}
Ejemplo n.º 3
0
                $data['pictures'][$run]['filesize'] = cs_filesize($img_filesize);
                $run++;
            }
        } elseif (empty($checkDiff) and !empty($_POST['read']) or empty($checkDiff) and $zip_file == 1) {
            $data['if']['nopic'] = TRUE;
        }
        if (!empty($checkDiff2) and !empty($_POST['del'])) {
            $data['if']['thumb'] = TRUE;
            $run = 0;
            foreach ($diff2 as $thumb) {
                if (cs_unlink('gallery', 'Thumb_' . $thumb, 'thumbs') == true) {
                    $where = "gallery_name = '" . $thumb . "'";
                    $search = cs_sql_count(__FILE__, 'gallery', $where);
                    if (!empty($search)) {
                        $query = "DELETE FROM {pre}_gallery WHERE gallery_name='{$thumb}'";
                        cs_sql_query(__FILE__, $query);
                    }
                    $msg = $cs_lang['deltrue'];
                } else {
                    $msg = $cs_lang['delfalse'];
                }
                $data['thumbs'][$run]['msg'] = $msg;
                $data['thumbs'][$run]['name'] = 'Thumb_' . $thumb;
                $run++;
            }
        } elseif (!empty($_POST['del'])) {
            $data['if']['no_thumb'] = TRUE;
        }
    }
}
if (isset($_POST['submit_1'])) {
Ejemplo n.º 4
0
$sql_install = str_replace('{guest}', $cs_lang['guest'], $sql_install);
$sql_install = str_replace('{community}', $cs_lang['community'], $sql_install);
$sql_install = str_replace('{member}', $cs_lang['member'], $sql_install);
$sql_install = str_replace('{orga}', $cs_lang['orga'], $sql_install);
$sql_install = str_replace('{admin}', $cs_lang['admin'], $sql_install);
if ($cs_db['hash'] == 'md5') {
    $sec_pwd = md5('admin');
} elseif ($cs_db['hash'] == 'sha1') {
    $sec_pwd = sha1('admin');
}
$sql_install = str_replace('{pwd}', $sec_pwd, $sql_install);
$sql_install = cs_sql_replace($sql_install);
$sql_array = preg_split("=;[\n\r]+=", $sql_install);
foreach ($sql_array as $sql_query) {
    $sql_query = trim($sql_query);
    if (!empty($sql_query)) {
        if (!cs_sql_query(__FILE__, $sql_query)) {
            cs_installerror($sql_query);
        }
    }
}
if (isset($_POST['module_select'])) {
    $mods = array('articles', 'awards', 'banners', 'board', 'boardmods', 'boardranks', 'buddys', 'cash', 'clans', 'computers', 'events', 'explorer', 'faq', 'fightus', 'files', 'gallery', 'games', 'gbook', 'history', 'joinus', 'links', 'linkus', 'maps', 'members', 'messages', 'news', 'newsletter', 'partner', 'quotes', 'ranks', 'replays', 'rules', 'search', 'servers', 'shoutbox', 'squads', 'static', 'usersgallery', 'votes', 'wars', 'wizard');
    $mods_count = count($mods);
    for ($run = 0; $run < $mods_count; $run++) {
        if (!isset($_POST[$mods[$run]])) {
            cs_sql_query(__FILE__, "UPDATE {pre}_access SET access_" . $mods[$run] . " = '0'");
        }
    }
}
cs_redirect('', 'install', 'admin', 'lang=' . $account['users_lang']);
Ejemplo n.º 5
0
        $langinfocontent .= '// ClanSphere 2010 - www.clansphere.net' . "\r\n";
        $langinfocontent .= '// File created by mod modules' . "\r\n\r\n";
        $langinfocontent .= '$cs_lang[\'mod\'] = \'' . $_POST['modname'] . "';\r\n";
        $langinfocontent .= '$cs_lang[\'mod_info\'] = \'' . $_POST['description'] . "';\r\n\r\n";
        $langinfocontent .= '?>';
        if (!($langinfofile = fopen($cs_main['def_path'] . '/lang/' . $account['users_lang'] . '/' . $_POST['moddir'] . '.php', 'w'))) {
            $error .= cs_html_br(1) . $cs_lang['modinfolang_create_failed'];
        } elseif (!fwrite($langinfofile, $langinfocontent)) {
            $error .= cs_html_br(1) . $cs_lang['modinfolang_write_failed'];
        } else {
            fclose($langinfofile);
        }
        // SQL
        $query = 'ALTER TABLE {pre}_access ADD access_' . cs_sql_escape($_POST['moddir']) . ' int(2) NOT NULL default \'0\';';
        $query = cs_sql_replace($query);
        if (!cs_sql_query(__FILE__, $query)) {
            $error .= cs_html_br(1) . $cs_lang['sqlaccess_failed'];
        }
    }
}
if (empty($_POST['submit']) || !empty($error)) {
    $data['message']['lang'] = empty($error) ? nl2br($cs_lang['need_chmod']) : $cs_lang['error_occured'] . $error;
    // SQL Tables
    $_POST['tablescount'] = empty($_POST['tablescount']) ? 1 : (int) $_POST['tablescount'];
    $tablescount = empty($_POST['addtable']) ? $_POST['tablescount'] : $_POST['tablescount'] + 1;
    for ($run = 0; $run < $tablescount; $run++) {
        $data['tables'][$run]['run'] = $run;
        $data['tables'][$run]['value'] = empty($_POST['table_' . $run]) ? '' : $_POST['table_' . $run];
    }
    $data['value']['tablescount'] = $tablescount;
    // Show
Ejemplo n.º 6
0
<?php

// ClanSphere 2010 - www.clansphere.net
// $Id$
$cs_lang = cs_translate('count');
$data = array();
$count_form = 1;
if (isset($_POST['agree'])) {
    $count_form = 0;
    cs_sql_query(__FILE__, 'TRUNCATE {pre}_count');
    $file = 'empty_1';
}
if (isset($_POST['cancel'])) {
    $count_form = 0;
    $file = 'empty_2';
}
if (!empty($count_form)) {
    $file = 'empty';
}
echo cs_subtemplate(__FILE__, $data, 'count', $file);
Ejemplo n.º 7
0
function cs_sql_version($cs_file)
{
    global $cs_db;
    $sql_infos = array('data_free' => 0, 'data_size' => 0, 'index_size' => 0, 'tables' => 0, 'names' => array());
    $sql_infos['type'] = 'PostgreSQL (pgsql)';
    $sql_infos['host'] = pg_host($cs_db['con']) or cs_error_sql($cs_file, 'cs_sql_version', cs_sql_error());
    if (function_exists('pg_version')) {
        $pg_infos = pg_version($cs_db['con']) or cs_error_sql($cs_file, 'cs_sql_version', cs_sql_error());
    }
    $sql_infos['encoding'] = pg_client_encoding($cs_db['con']);
    $sql_infos['client'] = isset($pg_infos['client']) ? $pg_infos['client'] : '-';
    $sql_infos['server'] = isset($pg_infos['server_version']) ? $pg_infos['server_version'] : '-';
    if ($sql_infos['server'] == '-') {
        $found = cs_sql_query($cs_file, 'SELECT VERSION()', 1);
        preg_match('=[\\d|.]+=', $found['more'][0]['version'], $matches, PREG_OFFSET_CAPTURE);
        $sql_infos['server'] = isset($matches[0][0]) ? $matches[0][0] : $found['more'][0]['version'];
    }
    return $sql_infos;
}
Ejemplo n.º 8
0
<?php

// ClanSphere 2010 - www.clansphere.net
// $Id$
$cs_lang = cs_translate('board');
require_once 'mods/board/functions.php';
$data = array();
$cs_homelimit = cs_sql_select(__FILE__, 'users', 'users_homelimit, users_readtime', "users_id = '" . $account["users_id"] . "'");
$cs_readtime = cs_time() - $cs_homelimit['users_readtime'];
cs_sql_query(__FILE__, "DELETE FROM {pre}_read WHERE users_id = '" . $account['users_id'] . "' AND read_since < '" . $cs_readtime . "'");
$from = "threads thr " . "INNER JOIN {pre}_board frm ON frm.board_id = thr.board_id " . "INNER JOIN {pre}_categories cat ON cat.categories_id = frm.categories_id " . "INNER JOIN {pre}_users usr ON thr.threads_last_user = usr.users_id " . "LEFT JOIN {pre}_members mem ON frm.squads_id = mem.squads_id AND mem.users_id = '" . $account['users_id'] . "' " . "LEFT JOIN {pre}_read red ON thr.threads_id = red.threads_id AND red.users_id = '" . $account['users_id'] . "'";
$where = "(frm.board_access <= '" . $account['access_board'] . "' OR mem.users_id = '" . $account['users_id'] . "') AND frm.board_pwd = '' AND thr.threads_last_time > '" . $cs_readtime . "' AND (thr.threads_last_time > red.read_since OR red.threads_id IS NULL)";
$select = 'cat.categories_name AS categories_name, cat.categories_id AS categories_id, frm.board_name AS board_name, frm.board_id AS board_id, thr.threads_headline AS threads_headline, thr.threads_last_time AS threads_last_time, thr.threads_comments AS threads_comments, thr.threads_id AS threads_id, usr.users_nick AS users_nick, usr.users_id AS users_id, usr.users_active AS users_active, usr.users_delete AS users_delete';
$order = 'thr.threads_last_time DESC';
$data['threads'] = cs_sql_select(__FILE__, $from, $select, $where, $order, 0, $cs_homelimit['users_homelimit']);
if (!empty($data['threads'])) {
    $count_threads = count($data['threads']);
    for ($run = 0; $run < $count_threads; $run++) {
        $data['threads'][$run]['threads_last_time'] = !empty($data['threads'][$run]['threads_last_time']) ? cs_date('unix', $data['threads'][$run]['threads_last_time'], 1) : '';
        $data['threads'][$run]['pages'] = $data['threads'][$run]['threads_comments'] <= $account['users_limit'] ? '' : cs_html_br(1) . cs_pages('board', 'thread', $data['threads'][$run]['threads_comments'], 0, $data['threads'][$run]['threads_id'], 0, 0, 1);
        $data['threads'][$run]['users_nick'] = !empty($data['threads'][$run]['users_nick']) ? cs_html_br(1) . $cs_lang['from'] . ' ' . cs_user($data['threads'][$run]['users_id'], $data['threads'][$run]['users_nick'], $data['threads'][$run]['users_active'], $data['threads'][$run]['users_delete']) : '';
        $data['threads'][$run]['new_posts'] = last_comment($data['threads'][$run]['threads_id'], $account['users_id'], $account['users_limit']);
    }
    echo cs_subtemplate(__FILE__, $data, 'board', 'users_home');
}
Ejemplo n.º 9
0
// ClanSphere 2010 - www.clansphere.net
// $Id$
# Overwrite global settings by using the following array
$cs_main = array('init_sql' => true, 'init_tpl' => false, 'init_mod' => true);
chdir('../../');
require_once 'system/core/functions.php';
cs_init($cs_main);
chdir('mods/captcha/');
$hash = '';
$pattern = '1234567890abcdefghijklmnpqrstuvwxyz';
$max = isset($_GET['mini']) ? 3 : 6;
for ($i = 0; $i < $max; $i++) {
    $hash .= $pattern[rand(0, 34)];
}
$ip = cs_getip();
$timeout = cs_time() - 900;
$save_hash = isset($_GET['mini']) ? 'mini_' . $hash : $hash;
$where = "captcha_ip = '" . cs_sql_escape($ip) . "' AND captcha_time < '" . $timeout . "'";
$old = cs_sql_select(__FILE__, 'captcha', 'captcha_id', $where, 'captcha_time DESC');
if (empty($old['captcha_id'])) {
    $captcha_cells = array('captcha_time', 'captcha_string', 'captcha_ip');
    $captcha_save = array(cs_time(), $save_hash, $ip);
    cs_sql_insert(__FILE__, 'captcha', $captcha_cells, $captcha_save);
} else {
    $captcha_cells = array('captcha_time', 'captcha_string');
    $captcha_save = array(cs_time(), $save_hash);
    cs_sql_update(__FILE__, 'captcha', $captcha_cells, $captcha_save, $old['captcha_id']);
}
cs_sql_query(__FILE__, "DELETE FROM {pre}_captcha WHERE captcha_time < '" . $timeout . "'");
cs_captcha($hash);
Ejemplo n.º 10
0
<?php

// ClanSphere 2010 - www.clansphere.net
// $Id$
$cs_lang = cs_translate('modules');
$data = array();
$dir = $_GET['dir'];
if (isset($_GET['confirm'])) {
    cs_sql_query(__FILE__, 'UPDATE {pre}_access SET access_' . cs_sql_escape($dir) . ' = \'0\'');
    $access = cs_sql_select(__FILE__, 'access', 'access_id', 0, 'access_clansphere ASC', 0, 0);
    foreach ($access as $level) {
        cs_cache_delete('access_' . $level['access_id']);
    }
    cs_redirect($cs_lang['success'], 'modules', 'roots');
} elseif (isset($_GET['cancel'])) {
    cs_redirect($cs_lang['remove_canceled'], 'modules', 'roots');
} else {
    $data['content']['deactivate'] = sprintf($cs_lang['rly_deactivate'], $dir);
    $data['content']['actions'] = cs_link($cs_lang['confirm'], 'modules', 'deactivate', 'dir=' . $dir . '&amp;confirm');
    $data['content']['actions'] .= ' - ';
    $data['content']['actions'] .= cs_link($cs_lang['cancel'], 'modules', 'deactivate', 'dir=' . $dir . '&amp;cancel');
}
echo cs_subtemplate(__FILE__, $data, 'modules', 'deactivate');
Ejemplo n.º 11
0
     $save = array('last_archiv_day' => $yesterday);
     require_once 'mods/clansphere/func_options.php';
     cs_optionsave('counter', $save);
 }
 if ($op_counter['last_archiv'] != $month) {
     $year = cs_datereal('Y');
     $timer = mktime(0, 0, 0, $month, 1, $year);
     $timer2 = $timer - 86400;
     $cond = "count_time < '" . $timer . "'";
     $last_day = cs_sql_count(__FILE__, 'count', $cond . " AND count_time > '" . $timer2 . "'");
     $count_month = cs_sql_count(__FILE__, 'count', $cond);
     $month_archieve = cs_sql_select(__FILE__, 'count_archiv', 'SUM(count_num) AS count', 'count_mode = 1', 0, 0, 0);
     $count_month += $month_archieve[0]['count'];
     if (!empty($count_month)) {
         cs_sql_query(__FILE__, 'DELETE FROM {pre}_count WHERE ' . $cond);
         cs_sql_query(__FILE__, "DELETE FROM {pre}_count_archiv WHERE count_mode = '1'");
         if ($month == 1) {
             $old_year = $year - 1;
             $old_month = 12;
         } else {
             $old_year = $year;
             $old_month = $month - 1;
         }
         $counter_cells1 = array('count_month', 'count_num');
         $counter_content1 = array($old_month . '-' . $old_year, $count_month);
         cs_sql_insert(__FILE__, 'count_archiv', $counter_cells1, $counter_content1);
     }
     //Save the newest month
     $save = array('last_archiv' => $month, 'last_archiv_day' => 1, 'count_lastday' => $last_day);
     require_once 'mods/clansphere/func_options.php';
     cs_optionsave('counter', $save);
Ejemplo n.º 12
0
}
if (!empty($sql_content)) {
    $sql_update = str_replace('{time}', cs_time(), $sql_content);
    $sql_update = cs_sql_replace($sql_update);
    $sql_update = str_replace('\\;', '{serial}', $sql_update);
    $sql_array = explode(';', $sql_update);
    cs_abcode_load();
    foreach ($sql_array as $sql_query) {
        $sql_query = trim(str_replace('{serial}', ';', $sql_query));
        if (!empty($sql_query)) {
            $sql_lower = strtolower($sql_query);
            $look_up = 0;
            if (strpos($sql_lower, 'explain') === 0 or strpos($sql_lower, 'select') === 0 or strpos($sql_lower, 'show') === 0) {
                $look_up = 1;
            }
            if ($check = cs_sql_query(__FILE__, $sql_query, $look_up)) {
                $para[1] = 'green';
                $info = $check['affected_rows'];
                if (!empty($look_up) and isset($check['more'][0])) {
                    $hide = array('users_pwd', 'users_cookiehash');
                    $explains = array();
                    foreach ($check['more'][0] as $key => $value) {
                        $explains['keys'][]['name'] = $key;
                    }
                    foreach ($check['more'] as $id => $more) {
                        foreach ($more as $unused => $value) {
                            $explains['more'][$id]['values'][]['name'] = in_array($unused, $hide) ? '****' : $value;
                        }
                    }
                    $info .= cs_subtemplate(__FILE__, $explains, 'database', 'explain');
                }
Ejemplo n.º 13
0
function cs_sql_insertid($cs_file)
{
    $found = cs_sql_query($cs_file, 'SELECT @@IDENTITY AS lastval', 1);
    $lastval = isset($found['more'][0]['lastval']) ? $found['more'][0]['lastval'] : NULL;
    return $lastval;
}