Here is the quick solution for optimizing database by deleting page views (only out included here, cause others are needed for your users)
1. Create php file called "admin_delete_pv_out.php" and place at your root directory
Code:
<?php
include_once('Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
include(mnminclude.'user.php');
include(mnminclude.'smartyvariables.php');
// require user to log in
force_authentication();
// restrict access to god only
$amIgod = 0;
$amIgod = $amIgod + checklevel('god');
$main_smarty->assign('amIgod', $amIgod);
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('god');
$canIhaveAccess = $canIhaveAccess + checklevel('admin');
if($canIhaveAccess == 0){
$main_smarty->assign('tpl_center', $the_template . '/admin_templates/admin_access_denied');
$main_smarty->display($the_template . '/pligg.tpl');
die();
}
function delete_pvout($pvid) {
$query="SELECT * FROM " . table_pageviews . " WHERE pv_id = '$pvid'";
if (! $result=mysql_query($query)) {die (mysql_error());}
else {$sql_array = mysql_fetch_object($result); }
}
$sql_query = "SELECT * FROM " . table_pageviews . " WHERE pv_type = 'out'";
$result_pvout = mysql_query($sql_query);
$num_rows = mysql_num_rows($result_pvout);
while($pvout = mysql_fetch_object($result_pvout))
{
delete_pvout($pvout->pvid);
}
# set discards total to zero
$query="UPDATE " . table_totals . " SET total = '0' WHERE name = 'out'";
if (!mysql_query($query)) {die (mysql_error());}
echo $num_rows. " Page View of out links has deleted";
?>
<p><a href="admin_optimize_database.php">Click here</a> to optimize database</p>
here are the code
Code:
<?php
include_once('Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
include(mnminclude.'user.php');
include(mnminclude.'smartyvariables.php');
// require user to log in
force_authentication();
// restrict access to god only
$amIgod = 0;
$amIgod = $amIgod + checklevel('god');
$main_smarty->assign('amIgod', $amIgod);
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('god');
$canIhaveAccess = $canIhaveAccess + checklevel('admin');
if($canIhaveAccess == 0){
$main_smarty->assign('tpl_center', $the_template . '/admin_templates/admin_access_denied');
$main_smarty->display($the_template . '/pligg.tpl');
die();
}
// $message = "";
$query = "SHOW TABLE STATUS";
$result=mysql_query($query);
$table_list = "";
while ($cur_table = mysql_fetch_object($result)) {
$table_list .= $cur_table->Name.", ";
}
if (!empty($table_list)) {
$table_list = substr($table_list, 0, -2);
$query = "OPTIMIZE TABLE ".$table_list;
mysql_query($query);
$message = "Database optimized, press 'back' button to back to admin home";
}
echo $message
?>
Code:
<img src="{$my_pligg_base}/templates/{$the_template}/images/manage_backup.png" align="absmiddle"/> <a href="{$my_pligg_base}/admin_delete_pv_out.php">{#PLIGG_Visual_Header_AdminPanel_41#}</a><br/>
Code:
//<SECTION>HEADER</SECTION><ADDED>0.57</ADDED> PLIGG_Visual_Header_AdminPanel_41 = "Optimize DB"
Thanks and regards




you have the solution? thanks

Linear Mode
