|
From: Jon O. <jon...@us...> - 2005-10-15 22:18:37
|
Update of /cvsroot/mxbb/mx_sitestats/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29610/admin Added Files: admin_counter.php admin_referers.php admin_sitestats.php Log Message: readded this module... --- NEW FILE: admin_referers.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, Marc Ferran (www.phpmix.com) * Copyright : (C) 2002-2005 mxBB Portal, phpMiX (c) 2004 * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: admin_referers.php,v 1.1 2005/10/15 22:18:28 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ // ====================================================== // [ ADMINCP COMMON INITIALIZATION ] // ====================================================== // This is how we add an entry to the phpBB Administration Control Panel... if ( !empty( $setmodules ) ) { $module['SiteStats']['Referers_Management'] = 'modules/mx_sitestats/admin/' . basename( __FILE__ ); return; } // Setup basic portal stuff... define( 'IN_PORTAL', 1 ); $mx_root_path = '../../../'; $module_root_path = '../'; // Security and page header... require( $mx_root_path . 'extension.inc' ); $no_page_header = true; require( $mx_root_path . 'admin/pagestart.' . $phpEx ); // Include common module stuff... require( $module_root_path . 'includes/common.' . $phpEx ); // ====================================================== // [ MAIN PROCESS ] // ====================================================== // Get POST/GET variables... $start = intval( ( isset( $_POST['start'] ) ) ? $_POST['start'] : ( ( isset( $_GET['start'] ) ) ? $_GET['start'] : 0 ) ); $sort_method = ( ( isset( $_POST['sort'] ) ) ? $_POST['sort'] : ( ( isset( $_GET['sort'] ) ) ? $_GET['sort'] : 'hits' ) ); $sort_order = ( ( isset( $_POST['order'] ) ) ? $_POST['order'] : ( ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC' ) ); $filter_flag = ( ( isset( $_POST['filter'] ) ) ? $_POST['filter'] : ( ( isset( $_GET['filter'] ) ) ? $_GET['filter'] : 'disabled' ) ); $enable = ( isset( $_POST['enable'] ) ) ? true : 0; $delete = ( isset( $_POST['delete'] ) ) ? true : 0; $delete_all = ( isset( $_POST['deleteall'] ) ) ? true : 0; $id_list = ( !empty( $_POST['id_list'] ) ) ? $_POST['id_list'] : array(); // Check which mode we should operate in... if ( $enable ) { for( $i = 0; $i < count( $id_list ); $i++ ) { $sql = 'UPDATE ' . SITESTATS_REFERER_TABLE . " SET enabled = " . ( ( $filter_flag == 'enabled' ) ? 0 : 1 ) . " WHERE id = " . $id_list[$i]; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't update HTTP Referer (id=" . $id_list[$i] . ") from database", '', __LINE__, __FILE__, $sql ); } } } else if ( $delete ) { for( $i = 0; $i < count( $id_list ); $i++ ) { $sql = 'DELETE FROM ' . SITESTATS_REFERER_TABLE . " WHERE id = " . $id_list[$i]; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't delete HTTP Referer (id=" . $id_list[$i] . ") from database", '', __LINE__, __FILE__, $sql ); } } } else if ( $delete_all ) { $sql = 'DELETE FROM ' . SITESTATS_REFERER_TABLE . ' WHERE enabled = ' . ( ( $filter_flag == 'enabled' ) ? 1 : 0 ); if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't delete HTTP Referers from database", '', __LINE__, __FILE__, $sql ); } } // ====================================================== // [ DEFAULT PROCESS ] // ====================================================== // Get TopReferers Block Settings... $sql = "SELECT block_id FROM " . BLOCK_TABLE . " WHERE block_title = 'SiteStats TopReferers' LIMIT 1"; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Could not query SiteStats TopReferers block information", "", __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); $block_id = $row['block_id']; $block_config = read_block_config( $block_id ); $rows_per_page = $block_config[$block_id]['SiteStats_TopReferers_Count']['parameter_value']; if ( !is_numeric( $rows_per_page ) ) { $rows_per_page = 10; } $rows_per_page *= 2; // Setup report variables... $a_sort_method = array( 'host' => $lang['Host'], 'hits' => $lang['Hits'], 'firstvisit' => $lang['First_visit'], 'lastvisit' => $lang['Last_visit'] ); $s_sort_method = ''; foreach( $a_sort_method as $s_value => $s_text ) { $selected = ( $s_value == $sort_method ) ? ' selected' : ''; $s_sort_method .= '<option value="' . $s_value . '"' . $selected . '>' . $s_text . '</option>'; } // Get total records count, for pagination... $total_rows = array(); $sql = 'SELECT COUNT(*) AS total FROM ' . SITESTATS_REFERER_TABLE . ' WHERE enabled = 0'; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't query HTTP Referers Count", '', __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); $total_rows[0] = $row['total']; $sql = 'SELECT COUNT(*) AS total FROM ' . SITESTATS_REFERER_TABLE . ' WHERE enabled = 1'; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't query HTTP Referers Count", '', __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); $total_rows[1] = $row['total']; $total_now = ( $filter_flag == 'enabled' ) ? 1 : 0; // Default process is report... switch ( $sort_method ) { case 'host': $order_by = 'host ' . $sort_order; break; case 'firstvisit': $order_by = 'firstvisit ' . $sort_order; break; case 'lastvisit': $order_by = 'lastvisit ' . $sort_order; break; default: case 'hits': $order_by = 'hits ' . $sort_order . ', lastvisit DESC'; break; } $sql = 'SELECT * FROM ' . SITESTATS_REFERER_TABLE . ' WHERE enabled = ' . ( ( $filter_flag == 'enabled' ) ? 1 : 0 ) . ' ORDER BY ' . $order_by . ' LIMIT ' . $start . ', ' . $rows_per_page; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't query HTTP Referers Information", '', __LINE__, __FILE__, $sql ); } $rowset = $db->sql_fetchrowset( $result ); $rowset_count = count( $rowset ); // Set template variables and send to browser... $template->set_filenames( array( 'body' => 'admin/sitestats_referers_admin.tpl' ) ); if ( $rowset_count > 0 ) { for( $i = 0; $i < $rowset_count; $i++ ) { $template->assign_block_vars( 'datarow', array( 'ROW_CLASS' => ( !( $i % 2 ) ) ? $theme['td_class1'] : $theme['td_class2'], 'ID' => $rowset[$i]['id'], 'HOST' => $rowset[$i]['host'], 'HITS' => $rowset[$i]['hits'], 'FIRST_VISIT' => create_date( 'Y-m-d H:i:s', $rowset[$i]['firstvisit'], $board_config['board_timezone'] ), 'LAST_VISIT' => create_date( 'Y-m-d H:i:s', $rowset[$i]['lastvisit'], $board_config['board_timezone'] ) ) ); } $template->assign_block_vars( 'ok_referers_sw', array() ); } else { $template->assign_block_vars( 'no_referers_sw', array() ); } $template->assign_vars( array( 'L_TITLE' => $lang['Referers_Management'], 'L_EXPLAIN' => $lang['Referers_Management_explain'] . $lang['Enabled'] . '(' . $total_rows[1] . '), ' . $lang['Disabled'] . '(' . $total_rows[0] . ')', 'U_FORM_ACTION' => append_sid( @basename( __FILE__ ) ), 'L_SELECT_FILTER' => $lang['Select_filter'], 'L_ENABLED' => $lang['Enabled'], 'L_DISABLED' => $lang['Disabled'], 'L_GO' => $lang['Go'], 'ENABLED_SELECTED' => ( $filter_flag == 'enabled' ) ? 'checked="checked"' : '', 'DISABLED_SELECTED' => ( $filter_flag != 'enabled' ) ? 'checked="checked"' : '', 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'], 'S_SORT_METHOD' => $s_sort_method, 'L_SORT' => $lang['Sort'], 'L_ORDER' => $lang['Order'], 'L_SORT_DESCENDING' => $lang['Sort_Descending'], 'L_SORT_ASCENDING' => $lang['Sort_Ascending'], 'ASC_SELECTED' => ( $sort_order != 'DESC' ) ? 'selected="selected"' : '', 'DESC_SELECTED' => ( $sort_order == 'DESC' ) ? 'selected="selected"' : '', 'L_REFERER_HOST' => $lang['Host'], 'L_REFERER_HITS' => $lang['Hits'], 'L_FIRST_VISIT' => $lang['First_visit'], 'L_LAST_VISIT' => $lang['Last_visit'], 'L_NO_REFERERS' => ( $filter_flag == 'enabled' ) ? $lang['No_Enabled_Referers'] : $lang['No_Disabled_Referers'], 'L_MARK' => $lang['Mark'], 'L_MARK_ALL' => $lang['Mark_all'], 'L_UNMARK_ALL' => $lang['Unmark_all'], 'L_ENABLE_MARKED' => ( $filter_flag == 'enabled' ) ? $lang['Disable_marked'] : $lang['Enable_marked'], 'L_DELETE_MARKED' => $lang['Delete_marked'], 'L_DELETE_ALL' => $lang['Delete_all'], 'L_NO_ITEMS_MARKED' => $lang['No_items_marked'], 'L_PLEASE_CONFIRM' => $lang['Please_confirm'], 'PAGINATION' => generate_pagination( append_sid( @basename( __FILE__ ) . "?filter=$filter_flag&sort=$sort_method&order=$sort_order" ), $total_rows[$total_now], $rows_per_page, $start ), 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $rows_per_page ) + 1 ), ceil( $total_rows[$total_now] / $rows_per_page ) ) ) // end array ); include_once( $mx_root_path . 'admin/page_header_admin.' . $phpEx ); $template->pparse( 'body' ); // ========== // // DEBUG ONLY // // ========== // // foreach( $_POST as $key => $val ) echo "POST[$key]=(".(is_array($val)?implode(',',$val):$val).")<br />"; // foreach( $_GET as $key => $val ) echo "GET[$key]=($val)<br />"; // ========== // include_once( $mx_root_path . 'admin/page_footer_admin.' . $phpEx ); exit; ?> --- NEW FILE: admin_sitestats.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, Marc Ferran (www.phpmix.com) * Copyright : (C) 2002-2005 mxBB Portal, phpMiX (c) 2004 * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: admin_sitestats.php,v 1.1 2005/10/15 22:18:28 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ // ====================================================== // [ ADMINCP COMMON INITIALIZATION ] // ====================================================== // Add our entry to the Administration Control Panel... if ( !empty( $setmodules ) ) { $module['SiteStats']['SiteStats_Settings'] = 'modules/mx_sitestats/admin/' . @basename( __FILE__ ); return; } // Setup basic portal stuff... define( 'IN_PORTAL', true ); $mx_root_path = '../../../'; $module_root_path = "../"; // Security and page header... require( $mx_root_path . 'extension.inc' ); require( $mx_root_path . '/admin/pagestart.' . $phpEx ); // Include common module stuff... require( $module_root_path . 'includes/common.' . $phpEx ); $sitestats_counter = new sitestats_counter(); $digits_path = $module_root_path . 'images/digits/'; $sitestats_digary = $sitestats_counter->getDigitStyles( $digits_path ); // Send page header... include_once( $mx_root_path . 'admin/page_header_admin.' . $phpEx ); // ====================================================== // [ MAIN PROCESS ] // ====================================================== // Read the module settings... $sql = "SELECT * FROM " . SITESTATS_CONFIG_TABLE; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't query SiteStats config table", "", __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $config_name = $row['config_name']; $config_value = $row['config_value']; $default_config[$config_name] = $config_value; $new[$config_name] = ( isset( $HTTP_POST_VARS[$config_name] ) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name]; if ( isset( $HTTP_POST_VARS['submit'] ) ) { $sql = "UPDATE " . SITESTATS_CONFIG_TABLE . " SET config_value = '" . str_replace( "\'", "''", $new[$config_name] ) . "'" . " WHERE config_name = '$config_name'"; if ( !$db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Failed to update SiteStats configuration for $config_name", "", __LINE__, __FILE__, $sql ); } } } // If the form was submitted, display the update successful message... if ( isset( $HTTP_POST_VARS['submit'] ) ) { $message = $lang['SiteStats_Settings_updated'] . '<br /><br />' . sprintf( $lang['SiteStats_Settings_return'], '<a href="' . append_sid( @basename( __FILE__ ) ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_admin_index'], '<a href="' . append_sid( $mx_root_path . "admin/index.$phpEx?pane=right" ) . '">', '</a>' ); message_die( GENERAL_MESSAGE, $message ); } // Prepare the Settings form... $template->set_filenames( array( 'body' => 'admin/sitestats_settings.tpl' ) ); // Counter Settings... $select_class_ary = array( 'cattitle', 'gen', 'genmed', 'gensmall', 'maintitle', 'postbody', 'topictitle' ); $select_text_class = ''; for( $i = 0; $i < count( $select_class_ary ); $i++ ) { $selected = ( $new['text_class'] == $select_class_ary[$i] ) ? 'selected="selected"' : ''; $select_text_class .= '<option value="' . $select_class_ary[$i] . '" ' . $selected . '>' . $select_class_ary[$i] . '</option>'; } $select_counter_class = ''; for( $i = 0; $i < count( $select_class_ary ); $i++ ) { $selected = ( $new['counter_class'] == $select_class_ary[$i] ) ? 'selected="selected"' : ''; $select_counter_class .= '<option value="' . $select_class_ary[$i] . '" ' . $selected . '>' . $select_class_ary[$i] . '</option>'; } $selected = ( empty( $new['counter_type'] ) ) ? 'selected="selected"' : ''; $select_counter_type = '<option value="" ' . $selected . '>' . $lang['SiteStats_Counter_TypeText'] . '</option>'; $counter_type_key = ''; foreach( $sitestats_digary as $key => $val ) { if ( $new['counter_type'] == $key ) { $selected = 'selected="selected"'; $counter_type_key = $key; $counter_type_val = $val; } else { $selected = ''; } $select_counter_type .= '<option value="' . $key . '" ' . $selected . '>' . $key . '</option>'; $template->assign_block_vars( 'imginfo', array( 'EXTENSION' => $val ) ); } $sample_digits = ''; if ( empty( $counter_type_key ) ) { for( $i = 0; $i < 10; $i++ ) { $sample_digits .= '<img name="img_' . $i . '" src="' . $digits_path . 'spacer.gif' . '" border="0" />'; } } else { for( $i = 0; $i < 10; $i++ ) { $sample_digits .= '<img name="img_' . $i . '" src="' . $digits_path . $counter_type_key . '/' . $i . '.' . $counter_type_val . '" border="0" />'; } } $counters_toshow_both = ( $new['counters_toshow'] == 0 ) ? 'checked="checked"' : ''; $counters_toshow_hits = ( $new['counters_toshow'] == 1 ) ? 'checked="checked"' : ''; $counters_toshow_sess = ( $new['counters_toshow'] == 2 ) ? 'checked="checked"' : ''; // Referers Settings... $referers_logging_off = ( !$new['referers_logging'] ) ? 'checked="checked"' : ''; $referers_logging_on = ( $new['referers_logging'] ) ? 'checked="checked"' : ''; $referers_showdis_off = ( !$new['referers_show_disabled'] ) ? 'checked="checked"' : ''; $referers_showdis_on = ( $new['referers_show_disabled'] ) ? 'checked="checked"' : ''; // Setup template vars and send the HTML... $template->assign_vars( array( 'S_ACTION' => append_sid( @basename( __FILE__ ) ), 'L_SITESTATS_SETTINGS' => $lang['SiteStats_Settings'], 'L_SITESTATS_SETTINGS_EXPLAIN' => $lang['SiteStats_Settings_explain'], 'DIGITS_PATH' => $digits_path, 'SAMPLE_DIGITS' => $sample_digits, 'SPACER' => $digits_path . 'spacer.gif', 'L_COUNTER_SETTINGS' => $lang['Counter_Settings'], 'L_COUNTER_TYPE' => $lang['SiteStats_Counter_Type'], 'L_COUNTER_TYPE_EXPLAIN' => $lang['SiteStats_Counter_Typeinfo'], 'SELECT_COUNTER_TYPE' => $select_counter_type, 'L_TEXT_CLASS' => $lang['SiteStats_Text_Class'], 'L_TEXT_CLASS_EXPLAIN' => $lang['SiteStats_Text_Classinfo'], 'SELECT_TEXT_CLASS' => $select_text_class, 'L_COUNTER_CLASS' => $lang['SiteStats_Counter_Class'], 'L_COUNTER_CLASS_EXPLAIN' => $lang['SiteStats_Counter_Classinfo'], 'SELECT_COUNTER_CLASS' => $select_counter_class, 'L_COUNTER_STYLE' => $lang['SiteStats_Counter_Style'], 'L_COUNTER_STYLE_EXPLAIN' => $lang['SiteStats_Counter_Styleinfo'], 'COUNTER_STYLE' => $new['counter_style'], 'L_COUNTER_SIZE' => $lang['SiteStats_Counter_Size'], 'L_COUNTER_SIZE_EXPLAIN' => $lang['SiteStats_Counter_Sizeinfo'], 'COUNTER_SIZE' => $new['counter_size'], 'L_COUNTER_TOSHOW' => $lang['SiteStats_Counter_ToShow'], 'L_COUNTER_TOSHOW_EXPLAIN' => $lang['SiteStats_Counter_ToShowinfo'], 'COUNTER_TOSHOW' => $new['counters_toshow'], 'COUNTER_TOSHOW_HITS' => $counters_toshow_hits, 'COUNTER_TOSHOW_SESS' => $counters_toshow_sess, 'COUNTER_TOSHOW_BOTH' => $counters_toshow_both, 'L_MORE_STATS_PAGE' => $lang['SiteStats_MoreStats_Page'], 'L_MORE_STATS_PAGE_EXPLAIN' => $lang['SiteStats_MoreStats_Pageinfo'], 'MORE_STATS_PAGE' => $new['more_stats_page'], 'L_REFERERS_SETTINGS' => $lang['Referers_Settings'], 'L_REFERERS_LOGGING' => $lang['Referers_Logging'], 'L_REFERERS_LOGGING_EXPLAIN' => $lang['Referers_Logginginfo'], 'REFERERS_LOGGING' => $new['referers_logging'], 'REFERERS_LOGGING_ON' => $referers_logging_on, 'REFERERS_LOGGING_OFF' => $referers_logging_off, 'L_REFERERS_COUNT' => $lang['SiteStats_TopReferers_Count'], 'L_REFERERS_COUNT_EXPLAIN' => $lang['SiteStats_TopReferers_Countinfo'], 'REFERERS_COUNT' => $new['referers_count'], 'L_REFERERS_SHOWDIS' => $lang['SiteStats_TopReferers_ShowDisabled'], 'L_REFERERS_SHOWDIS_EXPLAIN' => $lang['SiteStats_TopReferers_ShowDisabledinfo'], 'REFERERS_SHOWDIS' => $new['referers_show_disabled'], 'REFERERS_SHOWDIS_ON' => $referers_showdis_on, 'REFERERS_SHOWDIS_OFF' => $referers_showdis_off, 'L_HITS' => $lang['SiteStats_Counter_hits'], 'L_SESSIONS' => $lang['SiteStats_Counter_sess'], 'L_BOTH' => $lang['Both'], 'L_ON' => $lang['On'], 'L_OFF' => $lang['Off'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'] ) ); $template->pparse( 'body' ); include_once( $mx_root_path . 'admin/page_footer_admin.' . $phpEx ); ?> --- NEW FILE: admin_counter.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, Marc Ferran (www.phpmix.com) * Copyright : (C) 2002-2005 mxBB Portal, phpMiX (c) 2004 * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: admin_counter.php,v 1.1 2005/10/15 22:18:28 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ // ====================================================== // [ ADMINCP COMMON INITIALIZATION ] // ====================================================== // This is how we add an entry to the phpBB Administration Control Panel... if ( !empty( $setmodules ) ) { $module['SiteStats']['Counter_Management'] = 'modules/mx_sitestats/admin/' . basename( __FILE__ ); return; } // Setup basic portal stuff... define( 'IN_PORTAL', 1 ); $mx_root_path = '../../../'; $module_root_path = "../"; // Security and page header... require( $mx_root_path . 'extension.inc' ); $no_page_header = true; require( $mx_root_path . 'admin/pagestart.' . $phpEx ); // Include common module stuff... require( $module_root_path . 'includes/common.' . $phpEx ); // ====================================================== // [ GLOBAL DATA ] // ====================================================== $my_script_name = basename( __FILE__ ); $my_script_title = $lang['SiteStats'] . ': ' . $lang['Counter_Management']; // ====================================================== // [ MAIN PROCESS ] // ====================================================== // Send page header and set the main template... include_once( $mx_root_path . 'admin/page_header_admin.' . $phpEx ); $template->set_filenames( array( "body" => "admin/sitestats_counter_admin.tpl" ) ); // Check out which mode we operate in... if ( isset( $_POST['cancel'] ) ) { $mode = ''; } else { $mode = ( isset( $_POST['mode'] ) ? $_POST['mode'] : ( isset( $_GET['mode'] ) ? $_GET['mode'] : '' ) ); $myid = ( isset( $_POST['id'] ) ? $_POST['id'] : ( isset( $_GET['id'] ) ? $_GET['id'] : '' ) ); $mypg = ( isset( $_POST['pg'] ) ? $_POST['pg'] : ( isset( $_GET['pg'] ) ? $_GET['pg'] : '' ) ); $mych = ( isset( $_POST['ch'] ) ? $_POST['ch'] : ( isset( $_GET['ch'] ) ? $_GET['ch'] : '' ) ); $mycs = ( isset( $_POST['cs'] ) ? $_POST['cs'] : ( isset( $_GET['cs'] ) ? $_GET['cs'] : '' ) ); } // Deal with each mode of operation... switch ( $mode ) { case 'add': case 'edit': dialog_addedit( $mode == 'add' ? 'db_insert' : 'db_update' ); break; case 'delete': dialog_confirm_delete(); break; case 'db_insert': case 'db_update': if ( empty( $mypg ) ) { dialog_addedit( $mode, $lang['Error_page_empty'] ); } $sitestats_counter = new sitestats_counter(); $sitestats_counter->id = ( $mode == 'db_insert' ? 0 : $myid ); $sitestats_counter->page = $mypg; $sitestats_counter->hits_counter = intval( $mych ); $sitestats_counter->sess_counter = intval( $mycs ); if ( !$sitestats_counter->updateCounter() ) { message_die( GENERAL_ERROR, "Couldn't update SiteStats counter for page: " . $sitestats_counter->page, "", __LINE__, __FILE__, $sitestats_counter->sql ); } dialog_updated( $mode ); break; case 'db_delete': $sitestats_counter = new sitestats_counter(); $sitestats_counter->id = $myid; if ( !$sitestats_counter->deleteCounter() ) { message_die( GENERAL_ERROR, "Couldn't delete SiteStats counter for page: " . $sitestats_counter->page, "", __LINE__, __FILE__, $sitestats_counter->sql ); } dialog_updated( $mode ); break; default: break; } // Display counter report... $sql = "SELECT * FROM " . SITESTATS_COUNTER_TABLE . " ORDER BY page"; if ( !$result = $db->sql_query( $sql ) ) { message_die( GENERAL_ERROR, "Couldn't read counter data", "", __LINE__, __FILE__, $sql ); } $rs_counter = $db->sql_fetchrowset( $result ); for( $i = 0; $i < count( $rs_counter ); $i++ ) { $get_vars = '&id=' . $rs_counter[$i]['id'] . '&pg=' . $rs_counter[$i]['page'] . '&ch=' . $rs_counter[$i]['hits_counter'] . '&cs=' . $rs_counter[$i]['sess_counter']; $template->assign_block_vars( "counter_rows", array( 'COUNTER_ID' => $rs_counter[$i]['id'], 'COUNTER_PAGE' => $rs_counter[$i]['page'], 'COUNTER_HITS' => $rs_counter[$i]['hits_counter'], 'COUNTER_SESS' => $rs_counter[$i]['sess_counter'], 'U_EDIT' => append_sid( $my_script_name . '?mode=edit' . $get_vars ), 'U_DELETE' => append_sid( $my_script_name . '?mode=delete' . $get_vars ) ) ); } $template->assign_vars( array( 'L_PAGE_TITLE' => $my_script_title, 'L_PAGE_EXPLAIN' => $lang['Counter_Management_explain'], 'L_COUNTER_ID' => $lang['SiteStats_Counter_id'], 'L_COUNTER_PAGE' => $lang['SiteStats_Counter_page'], 'L_COUNTER_HITS' => $lang['SiteStats_Counter_hits'], 'L_COUNTER_SESS' => $lang['SiteStats_Counter_sess'], 'L_ADD' => $lang['Add'], 'U_ADD' => append_sid( $my_script_name . '?mode=add' ), 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'], 'L_ACTION' => $lang['Action'] ) ); // Send page body/footer and exit... $template->pparse( "body" ); include_once( $mx_root_path . 'admin/page_footer_admin.' . $phpEx ); exit; // ====================================================== // [ FUNCTIONS ] // ====================================================== // ------------ // Dialogs (without templates =:-P) ... function dialog_addedit( $newmode, $errmsg = '' ) { global $lang, $my_script_name, $my_script_title, $myid, $mypg, $mych, $mycs; $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" />'; if ( $newmode == 'db_update' ) { $s_hidden_fields .= '<input type="hidden" name="id" value="' . $myid . '" />'; $s_field_id = '<tr><td><b>' . $lang['SiteStats_Counter_id'] . ':</b> </td><td>' . '[ ' . $myid . ' ]</td></tr>'; } else { $s_field_id = ''; $mych = 0; $mycs = 0; } $message = '<br />' . ( empty( $errmsg ) ? ' ' : '<div style="width:80%; padding:10px; border:solid red 1px;">' . $errmsg . '</div>' ) . '<br />' . '<script>function doOnLoad() {document.forms[0].elements[0].focus();} window.onload=doOnLoad;</script>' . '<form method="post" action="' . $my_script_name . '">' . '<table border="0" cellpadding="4" cellspacing="0">' . $s_field_id . '<tr><td><b>' . $lang['SiteStats_Counter_page'] . ':</b> </td><td>' . '<input type="text" name="pg" size="100" value="' . $mypg . '" class="post" /></td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_hits'] . ':</b> </td><td>' . '<input type="text" name="ch" size="100" value="' . $mych . '" class="post" /></td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_sess'] . ':</b> </td><td>' . '<input type="text" name="cs" size="100" value="' . $mycs . '" class="post" /></td></tr>' . '</table> <br /> <br />' . $s_hidden_fields . '<input type="submit" name="cancel" value="' . $lang['Cancel'] . '" class="liteoption" /> ' . '<input type="submit" name="submit" value="' . $lang['Submit'] . '" class="liteoption" />' . '</form>'; message_die( GENERAL_MESSAGE, $message, $my_script_title ); } function dialog_confirm_delete() { global $lang, $my_script_name, $my_script_title, $myid, $mypg, $mych, $mycs; $s_hidden_fields = '<input type="hidden" name="mode" value="db_delete" />'; $s_hidden_fields .= '<input type="hidden" name="id" value="' . $myid . '" />'; $s_hidden_fields .= '<input type="hidden" name="pg" value="' . $mypg . '" />'; $s_hidden_fields .= '<input type="hidden" name="ch" value="' . $mych . '" />'; $s_hidden_fields .= '<input type="hidden" name="cs" value="' . $mycs . '" />'; $message = '<form method="post" action="' . $my_script_name . '">' . '<table border="0" cellpadding="4" cellspacing="0">' . '<tr><td><b>' . $lang['SiteStats_Counter_id'] . ':</b> </td><td>[ ' . $myid . ' ]</td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_page'] . ':</b> </td><td>[ ' . $mypg . ' ]</td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_hits'] . ':</b> </td><td>[ ' . $mych . ' ]</td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_sess'] . ':</b> </td><td>[ ' . $mycs . ' ]</td></tr>' . '</table> <br /> <br />' . '<div style="width:80%; padding:10px; border:solid red 1px;">' . $lang['Confirm_delete_counter'] . '<br /> <br />' . $s_hidden_fields . '<input type="submit" name="cancel" value="' . $lang['No'] . '" class="liteoption" /> ' . '<input type="submit" name="submit" value="' . $lang['Yes'] . '" class="liteoption" />' . '</div><br /> ' . '</form>'; message_die( GENERAL_MESSAGE, $message, $my_script_title ); } function dialog_updated( $mode ) { global $lang, $my_script_name, $my_script_title, $myid, $mypg, $mych, $mycs; if ( $mode == 'db_insert' ) { $s_field_id = ''; } else { $s_field_id = '<tr><td><b>' . $lang['SiteStats_Counter_id'] . ':</b> </td><td>[ ' . $myid . ' ]</td></tr>'; } $message = '<table border="0" cellpadding="4" cellspacing="0">' . $s_field_id . '<tr><td><b>' . $lang['SiteStats_Counter_page'] . ':</b> </td><td>[ ' . $mypg . ' ]</td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_hits'] . ':</b> </td><td>[ ' . intval( $mych ) . ' ]</td></tr>' . '<tr><td><b>' . $lang['SiteStats_Counter_sess'] . ':</b> </td><td>[ ' . intval( $mycs ) . ' ]</td></tr>' . '</table> <br /> <br />' . '<div style="width:80%; padding:10px; border:solid blue 1px;">' . $lang['Counter_Config_updated'] . '<br /> <br />' . sprintf( $lang['Click_return_Counter_admin'], '<a href="' . append_sid( $my_script_name ) . '">', '</a>' ) . '</div><br /> '; message_die( GENERAL_MESSAGE, $message, $my_script_title ); } ?> |