\n
".DBLAN_15."
".DBLAN_4."
".DBLAN_6."
".DBLAN_28."
".DBLAN_19."
".DBLAN_8."
".DBLAN_35."
"; $ns->tablerender(DBLAN_10, $text); function backup_core() { global $pref, $sql; $tmp = base64_encode((serialize($pref))); if (!$sql->db_Insert("core", "'pref_backup', '{$tmp}' ")) { $sql->db_Update("core", "e107_value='{$tmp}' WHERE e107_name='pref_backup'"); } } function optimizesql($mySQLdefaultdb) { $result = mysql_list_tables($mySQLdefaultdb); while ($row = mysql_fetch_row($result)) { mysql_query("OPTIMIZE TABLE ".$row[0]); } $str = "
".DBLAN_11." $mySQLdefaultdb ".DBLAN_12.".


"; $ns = new e107table; $ns->tablerender(DBLAN_14, $str); } function plugin_viewscan() { $error_messages = array(0 => DBLAN_31, 1 =>"".DBLAN_32."", 2 =>"".DBLAN_33."", 3 => DBLAN_34); global $sql, $pref, $ns, $tp; require_once(e_HANDLER."plugin_class.php"); $ep = new e107plugin; $ep->update_plugins_table(); // scan for e_xxx changes and save to plugin table. $ep->save_addon_prefs(); // generate global e_xxx_list prefs from plugin table. $ns -> tablerender(DBLAN_22, "
".DBLAN_23."

".DBLAN_13."
"); $text = "
"; $sql -> db_Select("plugin", "*", "plugin_id !='' order by plugin_path ASC"); // Must order by path to pick up duplicates. (plugin names may change). while($row = $sql-> db_Fetch()) { $text .= ""; $previous = $row['plugin_path']; } // $text .= ""; $text .= "
".DBLAN_24." ".DBLAN_25." ".DBLAN_26."
".DBLAN_30."
".DBLAN_27."
".$tp->toHtml($row['plugin_name'],FALSE,"defs")." ".$row['plugin_path']." "; if (trim($row['plugin_addons'])) { $nl_code = ''; foreach(explode(',',$row['plugin_addons']) as $this_addon) { $ret_code = 3; // Default to 'not checked if (strpos($this_addon,'e_') === 0) { // echo "Checking: ".$row['plugin_path'].":".$this_addon."
"; $ret_code = $ep->checkAddon($row['plugin_path'],$this_addon); // See whether spaces before opening tag or after closing tag } $text .= $nl_code.$this_addon." - ".$error_messages[$ret_code]; // $ret_code - 0=OK, 1=content error, 2=access error $nl_code = "
"; } } $text .= "
"; if($previous == $row['plugin_path']) { $delid = $row['plugin_id']; $delname = $row['plugin_name']; $text .= "\n"; } else { $text .= ($row['plugin_installflag'] == 1) ? DBLAN_27 : " "; // "Installed and not installed"; } $text .= "
".DBLAN_30."
"; $ns -> tablerender(ADLAN_CL_7, $text); } function pref_editor() { global $pref,$ns,$tp; ksort($pref); $text = "
"; foreach($pref as $key=>$val) { $ptext = (is_array($val)) ? "
".print_r($val,TRUE)."
" : htmlspecialchars($val); $ptext = $tp -> textclean($ptext, 80); $text .= " "; } $text .= "
".LAN_DELETE." ".DBLAN_17." ".DBLAN_18." ".LAN_OPTIONS."
".$key." ".$ptext."
"; $text .= "

".DBLAN_13."
\n"; $ns -> tablerender(DBLAN_20, $text); return $text; } function del_pref_val(){ global $pref,$ns,$e107cache; $del = array_keys($_POST['delpref']); $delpref = $del[0]; if($delpref) { unset($pref[$delpref]); $deleted_list .= "
  • ".$delpref."
  • "; } if($_POST['delpref2']){ foreach($_POST['delpref2'] as $k=>$v) { $deleted_list .= "
  • ".$k."
  • "; unset($pref[$k]); } } $message = "


    ".DBLAN_13."
    "; save_prefs(); $e107cache->clear(); $ns -> tablerender(LAN_DELETED,$message); } function delete_plugin_entry() { global $sql,$ns; $del = array_keys($_POST['delplug']); $message = ($sql -> db_Delete("plugin", "plugin_id='".intval($del[0])."' LIMIT 1")) ? LAN_DELETED : LAN_DELETED_FAILED; $caption = ($message == LAN_DELETED) ? LAN_DELETED : LAN_ERROR; $ns -> tablerender($caption,$message); } function verify_sql_record(){ global $ns, $sql, $sql2, $tp; if(!is_object($sql)){ $sql = new db; } if(!is_object($sql2)){ $sql2 = new db; } if(!is_object($sql3)){ $sql3 = new db; } $tables = array(); $tables[] = 'rate'; $tables[] = 'comments'; if(isset($_POST['delete_verify_sql_record'])){ $text = "
    "; $text .= "ok, so you want to delete some records? not a problem at all!
    "; $text .= "but, since this is still an experimental procedure, i won't actually delete anything
    "; $text .= "instead, i will show you the queries that would be performed
    "; $text .= "
    "; foreach($_POST['del_dbrec'] as $k=>$v){ if($k=='rate'){ $keys = implode(", ", array_keys($v)); $qry .= "DELETE * FROM rate WHERE rate_id IN (".$keys.")
    "; }elseif($k=='comments'){ $keys = implode(", ", array_keys($v)); $qry .= "DELETE * FROM comments WHERE comment_id IN (".$keys.")
    "; } } $text .= $qry; $text .= "
    "; $ns->tablerender($caption, $text); return; } if(!isset($_POST['check_verify_sql_record'])){ //select table to verify $text = "
    ".DBLAN_37."

    "; foreach($tables as $t){ $text .= "{$t}
    "; $ns->tablerender(DBLAN_39, $text); }else{ //function to sort the results function verify_sql_record_cmp($a, $b) { $orderby=array('type'=>'asc', 'itemid'=>'asc'); $result= 0; foreach( $orderby as $key => $value ) { if( $a[$key] == $b[$key] ) continue; $result = ($a[$key] < $b[$key])? -1 : 1; if( $value=='desc' ) $result = -$result; break; } return $result; } //function to display the results //$err holds the error data //$ctype holds the tablename function verify_sql_record_displayresult($err, $ctype){ usort($err, 'verify_sql_record_cmp'); $text = ''; if(is_array($err) && !empty($err)){ $text .= " "; foreach($err as $k=>$v){ $delkey = $v['sqlid']; $text .= " "; } $text .= "
    ".DBLAN_40." ".$ctype."
    ".DBLAN_41." ".DBLAN_42." ".DBLAN_43." ".DBLAN_44."
    ".$v['type']." ".$v['itemid']." ".($v['table_exist'] ? DBLAN_45 : DBLAN_46)." ".DBLAN_47."

    "; } return $text; } function verify_sql_record_gettables(){ global $sql2; //array which will hold all db tables $dbtables = array(); //get all tables in the db $sql2 -> db_Select_gen("SHOW TABLES"); while($row2=$sql2->db_Fetch()){ $dbtables[] = $row2[0]; } return $dbtables; } $text = ''; //validate rate table records if(isset($_POST['table_rate'])){ $query = " SELECT r.* FROM #rate AS r WHERE r.rate_id!='' ORDER BY r.rate_table, r.rate_itemid"; $data = array('type'=>'rate', 'table'=>'rate_table', 'itemid'=>'rate_itemid', 'id'=>'rate_id'); if(!$sql -> db_Select_gen($query)){ $text = DBLAN_49; }else{ //the master error array $err=array(); //array which will hold all db tables $dbtables = verify_sql_record_gettables(); while($row=$sql->db_Fetch()){ $ctype = $data['type']; $cid = $row[$data['id']]; $citemid = $row[$data['itemid']]; $ctable = $row[$data['table']]; //if the rate_table is an existing table, we need to do more validation //else if the rate_table is not an existing table, this is an invalid reference if(in_array($ctable, $dbtables)){ $sql3 -> db_Select_gen("SHOW COLUMNS FROM {$ctable}"); while($row3=$sql3->db_Fetch()){ //find the auto_increment field, since that's the most likely key used if($row3['Extra']=='auto_increment'){ $aif = $row3['Field']; break; } } //we need to check if the itemid (still) exists in this table //if the record is not found, this could well be an obsolete record //if the record is found, we need to keep this record since it's a valid reference if(!$sql2 -> db_Select("{$ctable}", "*", "{$aif}='{$citemid}' ORDER BY {$aif} ")){ $err[] = array('type'=>$ctable, 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } }else{ $err[] = array('type'=>$ctable, 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>FALSE); } } $text .= verify_sql_record_displayresult($err, $ctype); } } //validate comments table records if(isset($_POST['table_comments'])){ $query = " SELECT c.* FROM #comments AS c WHERE c.comment_id!='' ORDER BY c.comment_type, c.comment_item_id"; $data = array('type'=>'comments', 'table'=>'comment_type', 'itemid'=>'comment_item_id', 'id'=>'comment_id'); if(!$sql -> db_Select_gen($query)){ $text = DBLAN_49; }else{ //the master error array $err=array(); //array which will hold all db tables $dbtables = verify_sql_record_gettables(); //get all e_comment files and variables require_once(e_HANDLER."comment_class.php"); $cobj = new comment; $e_comment = $cobj->get_e_comment(); while($row=$sql->db_Fetch()){ $ctype = $data['type']; $cid = $row[$data['id']]; $citemid = $row[$data['itemid']]; $ctable = $row[$data['table']]; //for each comment we need to validate the referencing record exists //we need to check if the itemid (still) exists in this table //if the record is not found, this could well be an obsolete record //if the record is found, we need to keep this record since it's a valid reference // news if($ctable == "0"){ if(!$sql2 -> db_Select("news", "*", "news_id='{$citemid}' ")){ $err[] = array('type'=>'news', 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } // article, review or content page }elseif($ctable == "1"){ // downloads }elseif($ctable == "2"){ if(!$sql2 -> db_Select("download", "*", "download_id='{$citemid}' ")){ $err[] = array('type'=>'download', 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } // poll }elseif($ctable == "4"){ if(!$sql2 -> db_Select("polls", "*", "poll_id='{$citemid}' ")){ $err[] = array('type'=>'polls', 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } // userprofile }elseif($ctable == "profile"){ if(!$sql2 -> db_Select("user", "*", "user_id='{$citemid}' ")){ $err[] = array('type'=>'user', 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } //else if this is a plugin comment }elseif(isset($e_comment[$ctable]) && is_array($e_comment[$ctable])){ $var = $e_comment[$ctable]; $qryp=''; //new method must use the 'qry' variable if(isset($var) && $var['qry']!=''){ if($installed = $sql2 -> db_Select("plugin", "*", "plugin_path = '".$var['plugin_path']."' AND plugin_installflag = '1' ")){ $qryp = str_replace("{NID}", $citemid, $var['qry']); if(!$sql2 -> db_Select_gen($qryp)){ $err[] = array('type'=>$ctable, 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } } //old method }else{ if(!$sql2 -> db_Select($var['db_table'], $var['db_title'], $var['db_id']." = '{$citemid}' ")){ $err[] = array('type'=>$ctable, 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>TRUE); } } //in all other cases }else{ $err[] = array('type'=>$ctable, 'sqlid'=>$cid, 'table'=>$ctable, 'itemid'=>$citemid, 'table_exist'=>FALSE); } } $text .= verify_sql_record_displayresult($err, $ctype); } } $text = "
    ".$text."
    "; $ns->tablerender(DBLAN_50,$text); } } require_once("footer.php"); ?>