$records_per_page) { if ($cur_page > 0) { $cur_page=$cur_page-1; } $first_record = ($cur_page) * $records_per_page; $limit_string = "LIMIT $first_record, $records_per_page"; $pages=$all_count/$records_per_page; if ($pages > (int) $pages) { $pages=(int)$pages+1; } } if ($pages>1) { $pages_string.="Page: "; if ($cur_page>10 && $pages>20) { $first_page=$cur_page-9; } else { $first_page=1; } if ($pages>20 && ($cur_page+10)<$pages) { $last_page=$first_page+19; } else { $last_page=$pages; } if ($cur_page+1>1) { $prev=$cur_page; $pages_string.="<  "; } for ($i=$first_page; $i<=$last_page; $i++){ if ($i != $cur_page+1) { $pages_string.="$i  "; } else { $pages_string.="$i  "; } } if ($cur_page+1<$pages) { $next=$cur_page+2; $pages_string.=">  "; } } return array ($pages_string, $limit_string); } // ---------------------------------------------------------------------------------------------------------------------- function search() { global $panel_db_link, $COM_CONF, $COM_LANG; $query = mysql_escape_string($_REQUEST['query']); $result = mysql_query("select href from {$COM_CONF['dbmaintable']} WHERE href like '%{$query}%' GROUP BY href"); $all_count = mysql_num_rows($result); list ($pages_string, $limit_string) = make_pages_string ($all_count, 30, $_REQUEST['page'], "{$COM_CONF['admin_script_url']}?action=search&query=$query"); $result = mysql_query("select href, COUNT(*) as count, MAX(time) as maxtime from {$COM_CONF['dbmaintable']} WHERE href like '%{$query}%' GROUP BY href ORDER BY maxtime DESC {$limit_string}", $panel_db_link); $href=$count=array(); $hrefs_count=0; while (list($href[$hrefs_count], $count[$hrefs_count]) = mysql_fetch_row($result)){ $hrefs_count++; } require("./templates/admin/default_search.php"); } // ---------------------------------------------------------------------------------------------------------------------- function view_list() { global $panel_db_link, $COM_CONF, $COM_LANG; $request_uri = $_REQUEST['href']; //$result = mysql_query("select COUNT(id) from {$COM_CONF['dbmaintable']} where href='$request_uri'", $panel_db_link); $result = mysql_query("select COUNT(id) from {$COM_CONF['dbmaintable']}", $panel_db_link); list ($all_count) = mysql_fetch_row($result); list ($pages_string, $limit_string) = make_pages_string ($all_count, 30, $_REQUEST['page'], "{$COM_CONF['admin_script_url']}?action=list&href=$request_uri"); //$result = mysql_query("select id, time, first_name, last_name, email, ip from {$COM_CONF['dbmaintable']} where href='$request_uri' order by time {$COM_CONF['sort_order']} $limit_string", $panel_db_link); $result = mysql_query("select id, time, first_name, last_name, email, ip from {$COM_CONF['dbmaintable']} where length(email) > 0 order by time {$COM_CONF['sort_order']} $limit_string", $panel_db_link); $comments_count=0; $id=$time=$first_name=$last_name=$email=$ip=array(); while (list($id[$comments_count], $time[$comments_count], $first_name[$comments_count], $last_name[$comments_count], $email[$comments_count], $ip[$comments_count])=mysql_fetch_array($result)) { $comments_count++; } require("./templates/admin/default_list.php"); } // ---------------------------------------------------------------------------------------------------------------------- function delete() { global $panel_db_link, $COM_CONF, $COM_LANG; $id = mysql_escape_string($_REQUEST['id']); mysql_query("delete from {$COM_CONF['dbmaintable']} where id='$id'", $panel_db_link); header("HTTP/1.1 302"); header("Location: {$COM_CONF['site_url']}{$COM_CONF['admin_script_url']}?action=list&href={$_REQUEST['from']}"); print "Person has been deleted.
Click here to get back."; } // ---------------------------------------------------------------------------------------------------------------------- function banip() { global $panel_db_link, $COM_CONF, $COM_LANG; $ip = mysql_escape_string($_REQUEST['ip']); mysql_query("INSERT INTO {$COM_CONF['dbbannedipstable']} SET ip='$ip'", $panel_db_link); print "IP {$_REQUEST['ip']} has been banned.
Click here to get back."; } // ---------------------------------------------------------------------------------------------------------------------- function bannedlist() { global $panel_db_link, $COM_CONF, $COM_LANG; $result = mysql_query("SELECT ip FROM {$COM_CONF['dbbannedipstable']}", $panel_db_link); $ips_count=0; while (list($ip[$ips_count]) = mysql_fetch_row($result)) { $ips_count++; } require ("./templates/admin/default_blist.php"); } // ---------------------------------------------------------------------------------------------------------------------- function unbanip() { global $panel_db_link, $COM_CONF, $COM_LANG; $ip = mysql_escape_string($_REQUEST['ip']); mysql_query("DELETE FROM {$COM_CONF['dbbannedipstable']} WHERE ip='$ip'", $panel_db_link); header("HTTP/1.1 302"); header("Location: {$COM_CONF['site_url']}{$COM_CONF['admin_script_url']}?action=bannedlist"); } // ---------------------------------------------------------------------------------------------------------------------- function exportcsv() { global $panel_db_link, $COM_CONF; $table = $COM_CONF['dbmaintable']; $file = "Newsletter_Signup_DB_Export"; /* original export with all column names and fields / $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field'].", "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table." ORDER BY id DESC"); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } */ // Column headers $csv_output .= "First Name, Last Name, Email\n"; // Row output $i = 3; $values = mysql_query("SELECT first_name, last_name, email FROM ".$table." WHERE length(email) > 0 ORDER BY id DESC"); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("m-d-Y",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header("Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; } // ---------------------------------------------------------------------------------------------------------------------- function exportcsvdaterange() { global $panel_db_link, $COM_CONF; $table = $COM_CONF['dbmaintable']; $file = "Newsletter_Signup_DB_Export"; $datefrom = $_POST['from']; $dateto = $_POST['to']; if($_POST['from']) { if($_POST['to']) { // Column headers $csv_output .= "First Name, Last Name, Email\n"; // Row output $i = 3; $values = mysql_query("SELECT first_name, last_name, email FROM ".$table." WHERE length(email) > 0 AND time BETWEEN STR_TO_DATE('$datefrom', '%m/%d/%Y') AND STR_TO_DATE('$dateto', '%m/%d/%Y')"); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("m-d-Y",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header("Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; } } header("HTTP/1.1 302"); header("Location: {$COM_CONF['site_url']}{$COM_CONF['admin_script_url']}?action=list&href=%2Findex.php&err=nodate"); //header("Location: {$COM_CONF['site_url']}{$COM_CONF['admin_script_url']}?action=list&href=%2Fcommunity%2Fonline-arthritis-panel%2Findex.php&err=nodate"); } // ---------------------------------------------------------------------------------------------------------------------- function logout() { global $panel_db_link, $COM_CONF; setcookie("login", "", time()-999999, "{$COM_CONF['script_dir']}/"); setcookie("passw", "", time()-999999, "{$COM_CONF['script_dir']}/"); mysql_query("OPTIMIZE TABLE {$COM_CONF['dbbannedipstable']}"); mysql_query("OPTIMIZE TABLE {$COM_CONF['dbmaintable']}"); header("HTTP/1.1 302"); header("Location: {$COM_CONF['site_url']}{$COM_CONF['admin_script_url']}"); } ?>