كود: تحديد الكل
data['is_registered']) ? true : false; $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx", ""); $add = (isset($_POST['submit_present'])) ? true : false; $user_present = utf8_normalize_nfc(request_var('username_present', '', true)); $present_text = utf8_normalize_nfc(request_var('text_present', '', true)); $mode = request_var('mode', ''); $type_show_tp = $config['type_show_pts']; if (($type_show_tp != "hor" )&&( $type_show_tp != "ver") ){$type_show_tp = 'hor';} if ($user->data['is_registered']) { $user_who = $user->data['username']; }else {$user_who = $user_present; } $del_pts = (isset($_GET['del_pts'])) ? true : false; $show_pts = (isset($_GET['show_pts'])) ? true : false; $show_all_pts = ($config['show_all_pts']) ? true : false; $safty_code_pts = ($config['safty_code_pts']) ? true : false; ############################################################ admin processes ## start //test for del ................................ 1.01 if ($del_pts) { //FOR SAFE $del_pts_id = intval($_GET['del_pts']); //then delete ...but !!!! u mist be admin ... waaaw its so beautiful .. if ($auth->acl_get('a_')) { $sql = 'DELETE FROM ' . PRESENT_TABLE . ' WHERE id = ' . (int) $del_pts_id; $db->sql_query($sql); //ok.... it went to hell //fix .. language bug with ajax header('Content-type: text/html; charset=UTF-8'); // oh my God ... this small code took 3 hours ... good for javascript die( ''. $user->lang['OK_DEL_DONE'] .'->['.$del_pts_id.']'); } else { //for safe .. trigger_error($user->lang['NO_AUTH_OPERATION']); } //show message .. exit; } //test for del ................................ //test for show ........................... if ($show_pts) { //FOR SAFE $show_pts_id = intval($_GET['show_pts']); //then delete ...but !!!! u mUst be admin ... waaaw its so beautiful .. if ($auth->acl_get('a_')) { $sql = 'UPDATE ' . PRESENT_TABLE . ' SET show_or_no = 1 WHERE ' . $db->sql_in_set('id', $show_pts_id); $db->sql_query($sql); //ok.... it went to hell //fix .. language bug with ajax header('Content-type: text/html; charset=UTF-8'); die( ''. $user->lang['OK_SHOW_DONE'] .'->['.$show_pts_id.']'); } else { //for safe .. trigger_error($user->lang['NO_AUTH_OPERATION']); } //show message .. exit; } //test for show ........................... ############################################################ admin processes ## end // for add ################################################################# add present #### start if ($add && check_form_key('presentation')){ //edited .. 01:24 pm 02/12/28h before Alhaj 1428h // confirm code if ($safty_code_pts && ($user->data['is_registered'] !== true)) { $confirm_id = request_var('confirm_id', ''); $confirm_code = request_var('confirm_code', ''); $sql = 'SELECT code FROM ' . CONFIRM_TABLE . " WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . CONFIRM_POST; $result = $db->sql_query($sql); $confirm_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (empty($confirm_row['code']) || strcasecmp($confirm_row['code'], $confirm_code) !== 0) { trigger_error($user->lang['CONFIRM_CODE_WRONG']); } else { $solved_captcha = true; } } // confirm code //fix for 1.01 ilove number 3 .. . //nothing to insert if ( (!$user->data['is_registered']) && ( strlen($user_who) == 0 || strlen($user_who) < 3 ) ) { $is_empty = $user->lang['PERSENT_EMPTY']; trigger_error($is_empty); } if (strlen($present_text) == 0 || strlen($present_text) < 3) { $is_empty = $user->lang['PERSENT_EMPTY']; trigger_error($is_empty); } //nothing to insert // we cant filter presents of admin [V.I.P] if ($auth->acl_get('a_')) { $show_or_no_vip = 1; } else { $show_or_no_vip = 0; }#else vip $sql_ary = array( 'userid' => (int) $user->data['user_id'], 'username' => (string) $user_who, 'usercolor' => (string) $user->data['user_colour'], 'time' => (int) time(), 'text' => (string) $present_text, 'show_or_no'=> (int) $show_or_no_vip ); $sql = 'INSERT INTO ' . PRESENT_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); //if finish .. meta_refresh(3, $redirect_url); $message = $user->lang['PRESENT_ADDED_SUCCESS'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', ''); trigger_error($message); }#add finish #####################################################################add present ## end //.. now show begein ... // make query ... //1 -> admin if ($auth->acl_get('a_')) { //its enough 30 more for admin ? $limitw = $limit+30; $sql = 'SELECT * FROM ' . PRESENT_TABLE . " ORDER BY id DESC LIMIT 0,$limitw"; } else { //for people .. if ($show_all_pts) { $sql = 'SELECT * FROM ' . PRESENT_TABLE . " ORDER BY id DESC LIMIT 0,$limit "; } else { $sql = 'SELECT * FROM ' . PRESENT_TABLE . " WHERE show_or_no = 1 ORDER BY id DESC LIMIT 0,$limit "; }#else show all } #else admin $result = $db->sql_query($sql); //to fix showin without result if ($result) { $i = 0; while ($row = $db->sql_fetchrow($result)) { //MAKE ,,, SAFE .. and MAKE SMILy ... etc. $text = censor_text($row['text']); // from bad words //special smiles filter ... i hate smiles ... $text = str_replace(":)", '', $text); $text = str_replace(":(", '', $text); $text = str_replace(":th:",'', $text); $text = str_replace(":tup:",'', $text); $text = str_replace(":vr:", '', $text); $text = str_replace(":wk:", '', $text); $text = str_replace(":ys:", '', $text); $text = str_replace(":bl:", '', $text); $text = str_replace(":bg:", '', $text); $text = str_replace(":bu:", '', $text); $text = str_replace(":cl:", '', $text); $text = str_replace(":cf:", '', $text); $text = str_replace(":co:", '', $text); $text = str_replace(":cr:", '', $text); $text = str_replace(":dv:", '', $text); $text = str_replace(":lu:", '', $text); $text = str_replace(":lo:", '', $text); $text = str_replace(":md:", '', $text); $text = str_replace(":no:", '', $text); $text = str_replace(":re:", '"', $text); //make special variables of style ... //fix url 1.0b8... reported bt Sa7er-alqlob [http://www.mara7net.com/] $template->assign_block_vars('frame_block', array( 'USERNAME' => ($row['userid'] != '1') ? 'session_id).'" target="_blank">'.$row['username'].'' : $row['username'], 'ID' => $row['id'], 'ID_V' => $i++, 'SHOW_OR_NO' => (!$show_all_pts && $row['show_or_no']==0)? true : false , 'TIME' => $user->format_date($row['time']), 'TEXT' => $text )); //just ONE query .. doesnt kill bandwith :) $for_del_row[] = $row; } #while } #if result ### if ($safty_code_pts && ($user->data['is_registered'] !== true)) { // Show confirm image // [1] $sql = 'DELETE FROM ' . CONFIRM_TABLE . " WHERE session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . CONFIRM_POST; $db->sql_query($sql); //[2] $code = gen_rand_string(mt_rand(5, 8)); $confirm_id = md5(unique_id($user->ip)); $seed = hexdec(substr(unique_id(), 4, 10)); //[3] // compute $seed % 0x7fffffff $seed -= 0x7fffffff * floor($seed / 0x7fffffff); $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'confirm_id' => (string) $confirm_id, 'session_id' => (string) $user->session_id, 'confirm_type' => (int) CONFIRM_POST, 'code' => (string) $code, 'seed' => (int) $seed) ); $db->sql_query($sql); // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if ($solved_captcha !== false) { $s_hidden_fields = build_hidden_fields(array( 'confirm_id' => request_var('confirm_id', ''), 'confirm_code' => request_var('confirm_code', '')) ); } }# Show confirm image // // wheee :) added 01:24 pm 02/12/28 add_form_key('presentation'); // //make general variables of style ... $template->assign_vars(array( 'TYPE_SHOW_TP_H' => ($type_show_tp == 'hor')? true : false, 'TYPE_SHOW_TP_V' => ($type_show_tp == 'ver')? true : false, 'USER_IS_MEMBER' => $user_what, 'PRESENT_USERNAME' => $user_who, 'PRESENT_TEXT' => $present_text, 'NO_VISITOR' => ($no_visitor && !$user->data['is_registered']) ? FALSE : TRUE , 'U_CANT_PRESENT' => $user->lang['U_CANT_PRESENT'], 'PRESENT_TITLE' => $user->lang['PRESENT_TITLE'], 'NEW_PRESENT' => $user->lang['NEW_PRESENT'], 'S_PRESENT_ACTION' => append_sid("{$phpbb_root_path}index.$phpEx", ''), 'L_ADD_PRESENT' => $user->lang['NEW_PRESENT'], 'L_PRESENT_MESSAGE_EXPLAIN' => $user->lang['EXPLAIN_PRESENT'], 'L_USERNAME' => $user->lang['USERNAME'], 'L_TEXT' => $user->lang['PRESENT_TEXT'], 'DELETE' => $user->lang['DELETE'], 'DISPLAY' => $user->lang['DISPLAY'], 'S_CONFIRM_CODE' => ($safty_code_pts && ($user->data['is_registered'] !== true))? true : false, 'L_CONFIRM_ID' => $user->lang['CONFIRM_CODE'], 'CONFIRM_ID' => $confirm_id, 'CONFIRM_IMAGE' => ' $s_hidden_fields )); //show style ,,, $template->set_filenames(array( 'body' => 'present_body.html') ); ################# end show // to delete ................. ###################################################### delete presents ### start $today = date('d', time()); //i hate math ....................... i love history :) for ($i = 0, $size = sizeof($for_del_row); $i < $size; $i++) { $for_del_row[$i]['time'] = date('d', $for_del_row[$i]['time']); $cal[$i] = ($today - $for_del_row[$i]['time']); if ( $cal[$i] == $day_before_del && $cal[$i] != 0 ) { $sql = 'DELETE FROM ' . PRESENT_TABLE . ' WHERE id = ' . (int) $for_del_row[$i]['id']; $db->sql_query($sql); } } // to delete ................. ###################################################### delete presents ### end $db->sql_freeresult($result); return; } #function get_presnts ?>