function notifymods_mail($mod, $users_id = 0, $var = NULL) { // $mail_text[$lang] = cs_translate('notifymods'); // not implicitly necessary if (!is_array($var)) { $var = array($var); } $mails_send = 0; $from = "notifymods ntm INNER JOIN {pre}_users usr ON ntm.notifymods_user = usr.users_id"; $where = "ntm.notifymods_user != '" . $users_id . "' \n AND usr.users_delete != 1\n AND usr.users_active = 1\n AND ntm.notifymods_" . $mod . " = 1"; $ntm_users = cs_sql_select(__FILE__, $from, 'usr.users_lang, usr.users_email', $where, 0, 0, 0); $pattern1 = '/\'(?<mod>.*)_text\'\\](\\s*)=(\\s*)\'(?<value>.*)\';/'; $pattern2 = '/\'(?<mod>.*)_subject\'\\](\\s*)=(\\s*)\'(?<value>.*)\';/'; if (!empty($ntm_users)) { foreach ($ntm_users as $mail_user) { $lang = empty($mail_user['users_lang']) ? $cs_main['def_lang'] : $mail_user['users_lang']; if (empty($mail_text[$lang][$mod . '_text'])) { $mail_text[$lang] = cs_cache_load('lang_notifymods_' . $lang); if ($mail_text[$lang] === FALSE and file_exists('lang/' . $lang . '/notifymods.php')) { // read lang-file and search for text- & subject-placeholder $fp = fopen('lang/' . $lang . '/notifymods.php', 'r'); $file_content = ''; while (!feof($fp)) { $file_content .= fgets($fp, 4096); } fclose($fp); preg_match_all($pattern1, $file_content, $match); $run = 0; foreach ($match['mod'] as $lang_mod) { $mail_text[$lang][$lang_mod . '_text'] = $match['value'][$run]; $run++; } preg_match_all($pattern2, $file_content, $match); $run = 0; foreach ($match['mod'] as $lang_mod) { $mail_text[$lang][$lang_mod . '_subject'] = $match['value'][$run]; $run++; } cs_cache_save('lang_notifymods_' . $lang, $mail_text[$lang]); } } if (empty($text[$lang])) { $text[$lang] = empty($var) ? $mail_text[$lang][$mod . '_text'] : vsprintf($mail_text[$lang][$mod . '_text'], $var); } if (cs_mail($mail_user['users_email'], $mail_text[$lang][$mod . '_subject'], $text[$lang])) { $mails_send++; } } return $mails_send; } }
// ClanSphere 2010 - www.clansphere.net // $Id$ $thisday = cs_datereal('m-d'); $output = array(); $data = array(); $data = cs_cache_load('navbirth'); $cs_lang = cs_translate('users'); $options = cs_sql_option(__FILE__, 'users'); if ($data['day'] != $thisday) { $data['day'] = $thisday; $select = 'users_id, users_nick, users_age'; $where = "users_age LIKE '%-" . $data['day'] . "' AND users_hidden NOT LIKE '%users_age%' AND users_active = 1"; $order = 'users_nick ASC'; $data['users'] = cs_sql_select(__FILE__, 'users', $select, $where, $order, 0, 0); cs_cache_save('navbirth', $data); } if (empty($data['users'])) { echo $cs_lang['no_data']; } else { $count = empty($options['navbirth_max_users']) ? count($data['users']) : min(count($data['users']), $options['navbirth_max_users']); for ($run = 0; $run < $count; $run++) { $birth = explode('-', $data['users'][$run]['users_age']); $output['users'][$run]['age'] = cs_datereal('Y') - $birth[0]; $output['users'][$run]['day'] = $birth[2]; $output['users'][$run]['month'] = $birth[1]; $output['users'][$run]['year'] = $birth[0]; $output['users'][$run]['user'] = cs_user($data['users'][$run]['users_id'], $data['users'][$run]['users_nick']); $output['users'][$run]['messageurl'] = cs_url('messages', 'create', 'to_id=' . $data['users'][$run]['users_id']); } echo cs_subtemplate(__FILE__, $output, 'users', 'navbirth');
$select .= ', gam.games_name AS games_name, gam.games_id AS games_id'; $order = 'srv.servers_order'; $cs_servers = cs_sql_select(__FILE__, $tables, $select, 0, $order, 0, 0); $cs_servers_count = count($cs_servers); $data['servers'] = array(); for ($serv = 0; $serv < $cs_servers_count; $serv++) { $data['servers'][$serv]['name'] = $cs_servers[$serv]['servers_name']; $data['servers'][$serv]['url'] = $cs_servers[$serv]['servers_ip'] . ':' . $cs_servers[$serv]['servers_port']; switch ($cs_servers[$serv]['servers_type']) { case 1: $data['servers'][$serv]['type'] = $cs_lang['clanserver']; break; case 2: $data['servers'][$serv]['type'] = $cs_lang['pubserver']; break; case 3: $data['servers'][$serv]['type'] = $cs_lang['voiceserver']; break; } $data['servers'][$serv]['slots'] = $cs_servers[$serv]['servers_slots']; $data['servers'][$serv]['img'] = 'uploads/games/' . $cs_servers[$serv]['games_id'] . '.gif'; $data['servers'][$serv]['game'] = $cs_servers[$serv]['games_name']; $data['servers'][$serv]['info'] = $cs_servers[$serv]['servers_info']; } cs_cache_save($cache_name, $data, $cache_time); } if (empty($data['if']['noquery'])) { echo cs_subtemplate(__FILE__, $data, 'servers', 'list'); } else { echo cs_subtemplate(__FILE__, $data, 'servers', 'noquery'); }
function cs_cache_theme($mod, $action) { global $cs_main; $tpl_temp = 'thm_' . $cs_main["def_theme"] . '_' . $mod . '_' . $action . '_' . $cs_main['php_self']['filename']; $tpl_data = cs_cache_load($tpl_temp); $tpl_real = cs_subtemplate_check($mod, $action); if ($tpl_real === false) { return false; } elseif ($tpl_data != false) { if ($cs_main['cache_mode'] != 'file' or filemtime($tpl_real) < filemtime('uploads/cache/' . $tpl_temp . '.tmp')) { return $tpl_data; } } $tpl_data = file_get_contents($tpl_real); # the default template is used since users may have different templates activated $tpl_data = str_replace('{page:template}', $cs_main['def_tpl'], $tpl_data); # page path does always end with a slash $tpl_data = str_replace('{page:path}', $cs_main['php_self']['dirname'], $tpl_data); $tpl_data = str_replace('{page:width}', $cs_main['def_width'], $tpl_data); $tpl_data = str_replace('{page:cellspacing}', $cs_main['cellspacing'], $tpl_data); $tpl_data = preg_replace_callback("={icon:([\\S]*?)}=i", 'cs_icon', $tpl_data); $tpl_data = preg_replace_callback('={url(?:_([\\w]*?))?:([\\w]*?)(?:_([\\w]*?)((?::(?:(?:[\\S]*?{[\\S]*?}[\\S]*?)*?|[\\S]*?))*?))?}=i', 'cs_templateurl', $tpl_data); return cs_cache_save($tpl_temp, $tpl_data); }
function cs_sql_select($cs_file, $sql_table, $sql_select, $sql_where = 0, $sql_order = 0, $first = 0, $max = 1, $cache = 0) { if (!empty($cache) && ($return = cs_cache_load($cache))) { return $return; } global $cs_db; $first = $first < 0 ? 0 : (int) $first; $max = $max < 0 ? 20 : (int) $max; $run = 0; $sql_query = 'SELECT ' . $sql_select . ' FROM ' . $cs_db['prefix'] . '_' . $sql_table; if (!empty($sql_where)) { $sql_query .= ' WHERE ' . $sql_where; } if (!empty($sql_order)) { $sql_query .= ' ORDER BY ' . str_replace('{random}', 'RANDOM()', $sql_order); } if (!empty($max)) { $sql_query .= ' LIMIT ' . $max . ' OFFSET ' . $first; } $sql_query = str_replace('{pre}', $cs_db['prefix'], $sql_query); $sql_data = pg_query($cs_db['con'], $sql_query) or cs_error_sql($cs_file, 'cs_sql_select', cs_sql_error(0, $sql_query)); if ($max == 1) { $new_result = pg_fetch_assoc($sql_data); } else { while ($sql_result = pg_fetch_assoc($sql_data)) { $new_result[$run] = $sql_result; $run++; } } pg_free_result($sql_data); cs_log_sql($cs_file, $sql_query); if (!empty($new_result)) { if (!empty($cache)) { cs_cache_save($cache, $new_result); } return $new_result; } return NULL; }
$data['users'][$run]['users_id'] = $birth_users['users_id']; $data['users'][$run]['users_nick'] = $birth_users['users_nick']; $data['users'][$run]['users_day'] = $birth[2]; $data['users'][$run]['users_month'] = $birth[1]; $data['users'][$run]['users_year'] = $birth[0]; $run++; } } if (!empty($data['users'])) { foreach ($data['users'] as $sortarray) { $column[] = $sortarray['users_month'] . $sortarray['users_day']; } array_multisort($column, SORT_ASC, $data['users']); } } cs_cache_save('nextbirth', $data); } if (empty($data['users'])) { echo $cs_lang['no_data']; } else { $count = empty($options['nextbirth_max_users']) ? count($data['users']) : min(count($data['users']), $options['nextbirth_max_users']); for ($run = 0; $run < $count; $run++) { $output['users'][$run]['age'] = $time_now['0'] - $data['users'][$run]['users_year']; $output['users'][$run]['day'] = $data['users'][$run]['users_day']; $output['users'][$run]['month'] = $data['users'][$run]['users_month']; $output['users'][$run]['year'] = $data['users'][$run]['users_year']; $output['users'][$run]['user'] = cs_user($data['users'][$run]['users_id'], $data['users'][$run]['users_nick']); $output['users'][$run]['messageurl'] = cs_url('messages', 'create', 'to_id=' . $data['users'][$run]['users_id']); } echo cs_subtemplate(__FILE__, $output, 'users', 'nextbirth'); }
function cs_sql_select($cs_file, $sql_table, $sql_select, $sql_where = 0, $sql_order = 0, $first = 0, $max = 1, $cache = 0) { if (!empty($cache) && ($return = cs_cache_load($cache))) { return $return; } global $cs_db; $first = $first < 0 ? 0 : (int) $first; $max = $max < 0 ? 20 : (int) $max; $new_result = 0; $run = 0; if ($cs_db['type'] == 'pdo_sqlsrv' and (!empty($max) or $sql_order === '{random}')) { $sql_select = ' TOP ' . $max . ' ' . $sql_select; if (!empty($first)) { $cell = explode(' ', $sql_table); $same_qry = ' ' . $cell[0] . '_id FROM ' . $cs_db['prefix'] . '_' . $sql_table; $same_qry .= empty($sql_where) ? '' : ' WHERE ' . $sql_where; $same_qry .= empty($sql_order) ? '' : ' ORDER BY ' . $sql_order; $sql_notin = '(' . $cell[0] . '_id NOT IN (SELECT TOP ' . $first . ' ' . $same_qry . '))'; $sql_where = empty($sql_where) ? $sql_notin : $sql_notin . ' AND ' . $sql_where; } } $sql_query = 'SELECT ' . $sql_select . ' FROM ' . $cs_db['prefix'] . '_' . $sql_table; if (!empty($sql_where)) { $sql_query .= ' WHERE ' . $sql_where; } if (!empty($sql_order)) { if ($cs_db['type'] == 'pdo_mysql') { $random = 'RAND()'; } elseif ($cs_db['type'] == 'pdo_sqlsrv') { $random = 'NEWID()'; } else { $random = 'RANDOM()'; } $sql_query .= ' ORDER BY ' . str_replace('{random}', $random, $sql_order); } if ($cs_db['type'] != 'pdo_sqlsrv' and !empty($max)) { $limit = $cs_db['type'] == 'pdo_pgsql' ? $max . ' OFFSET ' . $first : $first . ',' . $max; $sql_query .= ' LIMIT ' . $limit; } $sql_query = str_replace('{pre}', $cs_db['prefix'], $sql_query); cs_log_sql($cs_file, $sql_query); try { $sql_data = $cs_db['con']->query($sql_query); } catch (PDOException $err) { cs_error_sql($cs_file, 'cs_sql_select', cs_sql_error($err, $sql_query)); } if (empty($error)) { $new_result = $max == 1 ? $sql_data->fetch(PDO::FETCH_ASSOC) : $sql_data->fetchAll(PDO::FETCH_ASSOC); $sql_data = NULL; } if (!empty($new_result)) { if (!empty($cache)) { cs_cache_save($cache, $new_result); } return $new_result; } return NULL; }
$data['messages']['new'] = $messages_count_new; } if (empty($data['if']['panel']) and $account['access_contact'] >= 3) { $data['contact']['new'] = cs_cache_load('count_mail_unread'); if ($data['contact']['new'] === false) { $data['contact']['new'] = cs_cache_save('count_mail_unread', (int) cs_sql_count(__FILE__, 'mail', 'mail_answered = 0')); } } if (empty($data['if']['panel']) and $account['access_joinus'] >= 3) { $data['joinus']['joinus_count'] = cs_cache_load('count_joinus'); if ($data['joinus']['joinus_count'] === false) { $data['joinus']['joinus_count'] = cs_cache_save('count_joinus', (int) cs_sql_count(__FILE__, 'joinus')); } } if (empty($data['if']['panel']) and $account['access_fightus'] >= 3) { $data['fightus']['fightus_count'] = cs_cache_load('count_fightus'); if ($data['fightus']['fightus_count'] === false) { $data['fightus']['fightus_count'] = cs_cache_save('count_fightus', (int) cs_sql_count(__FILE__, 'fightus')); } } if (empty($data['if']['panel']) and $account['access_board'] >= 4) { $data['boardreport']['boardreport_count'] = cs_cache_load('count_boardreport'); if ($data['boardreport']['boardreport_count'] === false) { $data['boardreport']['boardreport_count'] = cs_cache_save('count_boardreport', (int) cs_sql_count(__FILE__, 'boardreport', 'boardreport_done = 0')); } } if (!empty($data['if']['panel']) and $account['access_clansphere'] >= 3) { $data['link']['panel'] = cs_url('clansphere', 'admin', '', 'admin'); } echo cs_subtemplate(__FILE__, $data, 'users', 'navlogin_view' . $style); }
for ($run = 0; $run < $abo['count']; $run++) { $abo['lang'] = empty($abo_users[$run]['users_lang']) ? 'English' : $abo_users[$run]['users_lang']; if (empty($abo_lang[$abo['lang']]['text'])) { $abo_lang[$abo['lang']] = cs_cache_load('lang_abo_' . $abo['lang']); if ($abo_lang[$abo['lang']] === FALSE) { // read lang-file and search for text- & subject-placeholder $fp = fopen($cs_main['def_path'] . '/lang/' . $abo['lang'] . '/board.php', 'r'); $file_content = ''; while (!feof($fp)) { $file_content .= fgets($fp, 4096); } preg_match($pattern1, $file_content, $match); $abo_lang[$abo['lang']]['text'] = $match['value']; preg_match($pattern2, $file_content, $match); $abo_lang[$abo['lang']]['subject'] = $match['value']; cs_cache_save('lang_abo_' . $abo['lang'], $abo_lang[$abo['lang']]); } } if (empty($abo_text[$abo['lang']]['text'])) { $abo_text[$abo['lang']]['text'] = sprintf($abo_lang[$abo['lang']]['text'], $data['thread']['threads_headline'], $account['users_nick']); } cs_mail($abo_users[$run]['users_email'], $abo_lang[$abo['lang']]['subject'], $abo_text[$abo['lang']]['text']); } // END Abo-Mail $where = "comments_mod = 'board' AND comments_fid = " . (int) $fid; $count_com = cs_sql_count(__FILE__, 'comments', $where); $add_start = empty($start) ? '' : '&start=' . $start; $more = 'where=' . $fid . $add_start . '#com' . $count_com; cs_redirect($cs_lang['create_done'], 'board', 'thread', $more); } if (!empty($data['thread']['board_read']) and $account['access_clansphere'] < 5) {
<?php // ClanSphere 2010 - www.clansphere.net // $Id$ // Publish News when time has come global $cs_main, $account; if ($cs_main['mod'] == 'news' and !empty($account['access_news'])) { $next_publish = cs_cache_load('news_publish'); if ($next_publish === false) { $where = 'news_public = 0 AND news_publishs_at != 0'; $next_publish = cs_sql_select(__FILE__, 'news', 'news_publishs_at', $where, 'news_publishs_at ASC'); $next_publish = empty($next_publish) ? '0' : $next_publish['news_publishs_at']; cs_cache_save('news_publish', $next_publish); } if ($next_publish != 0 and cs_time() > $next_publish) { $cond = 'news_publishs_at != 0 AND news_public = 0 AND news_publishs_at < ' . cs_time(); $publish = cs_sql_select(__FILE__, 'news', 'news_id, news_publishs_at, news_public', $cond, 0, 0, 0); if (!empty($publish)) { $count_publish = count($publish); for ($run = 0; $run < $count_publish; $run++) { cs_sql_update(__FILE__, 'news', array('news_public', 'news_time'), array('1', $publish[$run]['news_publishs_at']), $publish[$run]['news_id']); } } cs_cache_delete('news_publish'); if (!empty($publish)) { include_once 'mods/news/rss.php'; } } }
function cs_sql_select($cs_file, $sql_table, $sql_select, $sql_where = 0, $sql_order = 0, $first = 0, $max = 1, $cache = 0) { if (!empty($cache) && ($return = cs_cache_load($cache))) { return $return; } global $cs_db; $first = $first < 0 ? 0 : (int) $first; $max = $max < 0 ? 20 : (int) $max; $run = 0; if (!empty($max) or $sql_order === '{random}') { $sql_select = ' TOP ' . $max . ' ' . $sql_select; if (!empty($first)) { $cell = explode(' ', $sql_table); $same_qry = ' ' . $cell[0] . '_id FROM ' . $cs_db['prefix'] . '_' . $sql_table; $same_qry .= empty($sql_where) ? '' : ' WHERE ' . $sql_where; $same_qry .= empty($sql_order) ? '' : ' ORDER BY ' . $sql_order; $sql_notin = '(' . $cell[0] . '_id NOT IN (SELECT TOP ' . $first . ' ' . $same_qry . '))'; $sql_where = empty($sql_where) ? $sql_notin : $sql_notin . ' AND ' . $sql_where; } } $sql_query = 'SELECT ' . $sql_select . ' FROM ' . $cs_db['prefix'] . '_' . $sql_table; if (!empty($sql_where)) { $sql_query .= ' WHERE ' . $sql_where; } if (!empty($sql_order)) { $sql_query .= ' ORDER BY ' . str_replace('{random}', 'NEWID()', $sql_order); } $sql_query = str_replace('{pre}', $cs_db['prefix'], $sql_query); if (!($sql_data = sqlsrv_query($cs_db['con'], $sql_query))) { cs_error_sql($cs_file, 'cs_sql_select', cs_sql_error(0, $sql_query)); return NULL; } if ($max == 1) { $new_result = sqlsrv_fetch_array($sql_data, SQLSRV_FETCH_ASSOC); } else { while ($sql_result = sqlsrv_fetch_array($sql_data, SQLSRV_FETCH_ASSOC)) { $new_result[$run] = $sql_result; $run++; } } sqlsrv_free_stmt($sql_data); cs_log_sql($cs_file, $sql_query); if (!empty($new_result)) { if (!empty($cache)) { cs_cache_save($cache, $new_result); } return $new_result; } return NULL; }