diff --git a/e107_admin/db.php b/e107_admin/db.php index 1a1ff29aa..01637738e 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -1,67 +1,96 @@ add(DBLAN_53, E_MESSAGE_WARNING); + } + else + { + $_POST[$_POST['db_execute']] = true; + } +} + +if(isset($_POST['db_update'])) +{ header("location: ".e_ADMIN."e107_update.php"); - exit; + exit(); } -if (isset($_POST['verify_sql'])) { +if(isset($_POST['verify_sql'])) +{ header("location: ".e_ADMIN."db_verify.php"); - exit; + exit(); } -require_once("auth.php"); +require_once ("auth.php"); +require_once (e_HANDLER."form_handler.php"); +$frm = new e_form(); +$emessage = &eMessage::getInstance(); //nothing wrong with doing it twice - -if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2'])) ) +if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2']))) { del_pref_val(); } - if(isset($_POST['pref_editor']) || isset($_POST['delpref']) || isset($_POST['delpref_checked'])) { pref_editor(); - require_once("footer.php"); - exit; + require_once ("footer.php"); + exit(); } - -if (isset($_POST['optimize_sql'])) { +if(isset($_POST['optimize_sql'])) +{ optimizesql($mySQLdefaultdb); - require_once("footer.php"); - exit; } - -if (isset($_POST['backup_core'])) { +if(isset($_POST['backup_core'])) +{ backup_core(); - message_handler("MESSAGE", DBLAN_1); + //message_handler("MESSAGE", DBLAN_1); + $emessage->add(DBLAN_1, E_MESSAGE_SUCCESS); } if(isset($_POST['delplug'])) @@ -70,330 +99,469 @@ if(isset($_POST['delplug'])) } -if (isset($_POST['plugin_scan']) || e_QUERY == "plugin" || $_POST['delplug']) { +if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || $_POST['delplug']) +{ plugin_viewscan(); - require_once("footer.php"); - exit; + require_once ("footer.php"); + exit(); } -if (isset($_POST['verify_sql_record']) || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']) ) { +if(isset($_POST['verify_sql_record']) || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) +{ verify_sql_record(); - require_once("footer.php"); - exit; + require_once ("footer.php"); + exit(); } +//XXX - what is this for (backup core)? +$text = " +
+
+ ".DBLAN_10." + + + + + + + + + + + -$text = "
- \n -
".DBLAN_15." + ".$frm->radio('db_execute', 'db_update').$frm->label(DBLAN_16, 'db_execute', 'db_update')." + +
+ + + + + - - - - + + + + + - - - - + + + + + - - - - + + + + + - - - - + + + + + - - - - + + + + + - - - - - - - - - -
".DBLAN_4." + ".$frm->radio('db_execute', 'verify_sql').$frm->label(DBLAN_5, 'db_execute', 'verify_sql')." + +
".DBLAN_15."
".DBLAN_6." + ".$frm->radio('db_execute', 'optimize_sql').$frm->label(DBLAN_7, 'db_execute', 'optimize_sql')." + +
".DBLAN_4."
".DBLAN_28." + ".$frm->radio('db_execute', 'plugin_scan').$frm->label(DBLAN_29, 'db_execute', 'plugin_scan')." + +
".DBLAN_6."
".DBLAN_19." + ".$frm->radio('db_execute', 'pref_editor').$frm->label(DBLAN_20, 'db_execute', 'pref_editor')." + +
".DBLAN_28."
".DBLAN_8." + ".$frm->radio('db_execute', 'backup_core').$frm->label(DBLAN_9, 'db_execute', 'backup_core')." + +
".DBLAN_19."
".DBLAN_35." + ".$frm->radio('db_execute', 'verify_sql_record').$frm->label(DBLAN_36, 'db_execute', 'verify_sql_record')." + +
".DBLAN_8." - -
".DBLAN_35."
+ + +
+ ".$frm->admin_button('trigger_db_execute', DBLAN_51, 'execute')." +
+
- "; + "; -$ns->tablerender(DBLAN_10, $text); +$e107->ns->tablerender(DBLAN_10, $emessage->render().$text); -function backup_core() { +function backup_core() +{ global $pref, $sql; $tmp = base64_encode((serialize($pref))); - if (!$sql->db_Insert("core", "'pref_backup', '{$tmp}' ")) { + if(!$sql->db_Insert("core", "'pref_backup', '{$tmp}' ")) + { $sql->db_Update("core", "e107_value='{$tmp}' WHERE e107_name='pref_backup'"); } } -function optimizesql($mySQLdefaultdb) { - +function optimizesql($mySQLdefaultdb) +{ + global $emessage; $result = mysql_list_tables($mySQLdefaultdb); - while ($row = mysql_fetch_row($result)) { + 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); - + $emessage->add(DBLAN_11." $mySQLdefaultdb ".DBLAN_12, E_MESSAGE_SUCCESS); } - function plugin_viewscan() { - $error_messages = array(0 => DBLAN_31, 1 =>DBLAN_32, 2 =>DBLAN_33, 3 => DBLAN_34); - $error_image = array("integrity_pass.png","integrity_fail.png","warning.png","blank.png"); + $error_messages = array(0 => DBLAN_31, 1 => DBLAN_32, 2 => DBLAN_33, 3 => DBLAN_34); + $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png"); - 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. + global $sql, $e107, $emessage, $frm; - $ns -> tablerender(DBLAN_22, "
".DBLAN_23."

".DBLAN_13."
"); + 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. - $text = "
-
- - - - - "; + /* we all are awaiting for PHP5 only support - method chaining... + $emessage->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS) + ->add("".DBLAN_13."", E_MESSAGE_SUCCESS) + ->add(DBLAN_30); + */ - $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()) + $emessage->add(DBLAN_23, E_MESSAGE_SUCCESS); + $emessage->add("".DBLAN_13."", E_MESSAGE_SUCCESS); + $emessage->add(DBLAN_30); + + $text = " + +
+ ".ADLAN_CL_7." +
".DBLAN_24."".DBLAN_25."".DBLAN_26."
".DBLAN_30."
".DBLAN_27."
+ + + + + + + + + + + + + + + + "; + + $sql->db_Select("plugin", "*", "plugin_id !='' order by plugin_path ASC"); // Must order by path to pick up duplicates. (plugin names may change). + $previous = ''; + while($row = $sql->db_Fetch()) + { + $text .= " + + + + - - - - - "; - $previous = $row['plugin_path']; } -// $text .= ""; - $text .= "
".DBLAN_24."".DBLAN_25."".DBLAN_26."".DBLAN_27."
".$e107->tp->toHtml($row['plugin_name'], FALSE, "defs,emotes_off")."".$row['plugin_path'].""; + + if(trim($row['plugin_addons'])) { - $text .= "
".$tp->toHtml($row['plugin_name'],FALSE,"defs,emotes_off")."".$row['plugin_path'].""; - - if (trim($row['plugin_addons'])) + //XXX - $nl_code = ''; - OLD VAR? + foreach(explode(',', $row['plugin_addons']) as $this_addon) { - $nl_code = ''; - foreach(explode(',',$row['plugin_addons']) as $this_addon) - { - $ret_code = 3; // Default to 'not checked - if ((strpos($this_addon,'e_') === 0) && (substr($this_addon,-4,4) != '_sql')) - { -// 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 .= "
"; - $text .= "\"".$error_messages[$ret_code]."\"\n"; - $text .= trim($this_addon); // $ret_code - 0=OK, 1=content error, 2=access error - $text .= "
"; - } + $ret_code = 3; // Default to 'not checked + if((strpos($this_addon, 'e_') === 0) && (substr($this_addon, - 4, 4) != '_sql')) + { + $ret_code = $ep->checkAddon($row['plugin_path'], $this_addon); // See whether spaces before opening tag or after closing tag + } + $text .= "
"; + $text .= "".$error_messages[$ret_code].""; + $text .= trim($this_addon); // $ret_code - 0=OK, 1=content error, 2=access error + $text .= "
"; } - - $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); + $text .= " + + + "; + + if($previous == $row['plugin_path']) + { + $delid = $row['plugin_id']; + $delname = $row['plugin_name']; + //Admin delete button + $text .= $frm->admin_button("delplug[{$delid}]", DBLAN_52, 'delete', '', array('title' => LAN_CONFIRMDEL." ID:{$delid} [$delname]")); + //Or maybe image submit? - + //$text .= $frm->submit_image("delplug[{$delid}]", DBLAN_52, 'delete', LAN_CONFIRMDEL." ID:{$delid} [$delname]"); + } + else + { + $text .= ($row['plugin_installflag'] == 1) ? DBLAN_27 : " "; // "Installed and not installed"; + } + $text .= " + + + "; + $previous = $row['plugin_path']; + } + + $text .= " + + + + + "; + + $e107->ns->tablerender(DBLAN_10.' - '.DBLAN_22, $emessage->render().$text); } - function pref_editor() { - global $pref,$ns,$tp; - ksort($pref); + global $pref, $e107, $emessage, $frm; + ksort($pref); - $text = "
-
- - - - - - - "; + $text = " + +
+ ".DBLAN_20." +
".LAN_DELETE."".DBLAN_17."".DBLAN_18."".LAN_OPTIONS."
+ + + + + + + + + + + + + + + + "; - foreach($pref as $key=>$val) - { - $ptext = (is_array($val)) ? "
".print_r($val,TRUE)."
" : htmlspecialchars($val); - $ptext = $tp -> textclean($ptext, 80); + foreach($pref as $key => $val) + { + $ptext = (is_array($val)) ? "
".print_r($val, TRUE)."
" : htmlspecialchars($val, ENT_QUOTES, CHARSET); + $ptext = $e107->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); + $text .= " + + ".$frm->checkbox("delpref2[$key]", 1)." + {$key} + {$ptext} + ".$frm->submit_image("delpref[$key]", LAN_DELETE, 'delete', LAN_CONFIRMDEL." [$key]")." + + "; + } - return $text; + $text .= " + + +
+ ".$frm->admin_button('delpref_checked', DBLAN_21, 'delete')." + ".$frm->admin_button('back', DBLAN_13, 'back')." +
+ + + + "; + //$text .= "
".DBLAN_13."
\n"; + $e107->ns->tablerender(DBLAN_10.' - '.DBLAN_20, $emessage->render().$text); + + return $text; } - - -function del_pref_val(){ - global $pref,$ns,$e107cache; +function del_pref_val() +{ + global $pref, $e107cache, $emessage; $del = array_keys($_POST['delpref']); $delpref = $del[0]; if($delpref) { - unset($pref[$delpref]); - $deleted_list .= "
  • ".$delpref."
  • "; + unset($pref[$delpref]); + $deleted_list .= "
  • ".$delpref."
  • "; } - if($_POST['delpref2']){ - foreach($_POST['delpref2'] as $k=>$v) + if($_POST['delpref2']) + { + + foreach($_POST['delpref2'] as $k => $v) { - $deleted_list .= "
  • ".$k."
  • "; + $deleted_list .= "
  • ".$k."
  • "; unset($pref[$k]); } } - $message = "

    -

    ".DBLAN_13."
    "; - save_prefs(); + save_prefs(); + $emessage->add(LAN_DELETED.""); $e107cache->clear(); - $ns -> tablerender(LAN_DELETED,$message); + //$e107->ns->tablerender(LAN_DELETED,$message); + } function delete_plugin_entry() { - global $sql,$ns; + global $sql, $emessage; + $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); + if($sql->db_Delete("plugin", "plugin_id='".intval($del[0])."' LIMIT 1")) + { + $emessage->add(LAN_DELETED, E_MESSAGE_SUCCESS); + } + else + { + $emessage->add(LAN_DELETED_FAILED, E_MESSAGE_WARNING); + } + } -function verify_sql_record(){ - global $ns, $sql, $sql2, $tp; +function verify_sql_record() +{ + global $emessage, $sql, $sql2, $sql3, $frm, $e107, $tp; - if(!is_object($sql)){ $sql = new db; } - if(!is_object($sql2)){ $sql2 = new db; } - if(!is_object($sql3)){ $sql3 = new db; } + 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'])){ + 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 .= "
    "; + if(!varset($_POST['del_dbrec'])) + { + $emessage->add('Nothing to delete', E_MESSAGE_DEBUG); + } + else + { + $msg = "ok, so you want to delete some records? not a problem at all!
    "; + $msg .= "but, since this is still an experimental procedure, i won't actually delete anything
    "; + $msg .= "instead, i will show you the queries that would be performed
    "; + $text .= "
    "; + $emessage->add($msg, E_MESSAGE_DEBUG); - foreach($_POST['del_dbrec'] as $k=>$v){ - - if($k=='rate'){ + foreach($_POST['del_dbrec'] as $k => $v) + { - $keys = implode(", ", array_keys($v)); - $qry .= "DELETE * FROM rate WHERE rate_id IN (".$keys.")
    "; + if($k == 'rate') + { - }elseif($k=='comments'){ + $keys = implode(", ", array_keys($v)); + $qry .= "DELETE * FROM rate WHERE rate_id IN (".$keys.")
    "; - $keys = implode(", ", array_keys($v)); - $qry .= "DELETE * FROM comments WHERE comment_id IN (".$keys.")
    "; + } + elseif($k == 'comments') + { + + $keys = implode(", ", array_keys($v)); + $qry .= "DELETE * FROM comments WHERE comment_id IN (".$keys.")
    "; + + } } + $emessage->add($qry, E_MESSAGE_DEBUG); + $emessage->add("".DBLAN_13."", E_MESSAGE_DEBUG); } - $text .= $qry; - - $text .= "
    -
    - - -
    -
    -
    "; - - $ns->tablerender($caption, $text); - - return; } - if(!isset($_POST['check_verify_sql_record'])){ + //Nothing selected + if(isset($_POST['check_verify_sql_record']) && (!isset($_POST['table_rate']) && !isset($_POST['table_comments']))) + { + $_POST['check_verify_sql_record'] = ''; + unset($_POST['check_verify_sql_record']); + $emessage->add(DBLAN_53, E_MESSAGE_WARNING); + } + + if(!isset($_POST['check_verify_sql_record'])) + { //select table to verify $text = " -
    - - + + + "; + } + $text .= " + +
    ".DBLAN_37."

    "; - foreach($tables as $t){ - $text .= "{$t}
    +
    + ".DBLAN_39." + + + + + + + + + + + "; + foreach($tables as $t) + { $text .= " -
    - - - -
    ".DBLAN_37."
    - "; - - $ns->tablerender(DBLAN_39, $text); - }else{ +
    + ".$frm->checkbox('table_'.$t, $t).$frm->label($t, 'table_'.$t, $t)." +
    +
    + ".$frm->admin_button('check_verify_sql_record', DBLAN_38)." + ".$frm->admin_button('back', DBLAN_13, 'back')." +
    + + + "; + $e107->ns->tablerender(DBLAN_10.' - '.DBLAN_39, $emessage->render().$text); + } + else + { //function to sort the results - function verify_sql_record_cmp($a, $b) { - - $orderby=array('type'=>'asc', 'itemid'=>'asc'); + function verify_sql_record_cmp($a, $b) + { - $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; + $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; @@ -402,98 +570,131 @@ function verify_sql_record(){ //function to display the results //$err holds the error data //$ctype holds the tablename - function verify_sql_record_displayresult($err, $ctype){ + function verify_sql_record_displayresult($err, $ctype) + { + global $frm; usort($err, 'verify_sql_record_cmp'); - $text = ''; - if(is_array($err) && !empty($err)){ + $text = " - $text .= " - - - - - - - - "; +
    + ".DBLAN_40." ".$ctype." +
    ".DBLAN_40." ".$ctype."
    ".DBLAN_41."".DBLAN_42."".DBLAN_43."".DBLAN_44."
    + + + + + + + + + + + + + + + + "; + if(is_array($err) && !empty($err)) + { - foreach($err as $k=>$v){ + + foreach($err as $k => $v) + { $delkey = $v['sqlid']; $text .= " - - - - - - "; + + + + + + + "; } - $text .= " - - - - -
    ".DBLAN_41."".DBLAN_42."".DBLAN_43."".DBLAN_44."
    ".$v['type']."".$v['itemid']."".($v['table_exist'] ? DBLAN_45 : DBLAN_46)." ".DBLAN_47."
    {$v['type']}{$v['itemid']}".($v['table_exist'] ? DBLAN_45 : DBLAN_46)." + ".$frm->checkbox('del_dbrec['.$ctype.']['.$delkey.'][]', '1').$frm->label(DBLAN_47, 'del_dbrec['.$ctype.']['.$delkey.'][]', '1')." +
    - - -

    "; + } + else + { + $text .= " + + {$err} + + "; + } + $text .= " + + + + "; return $text; } - function verify_sql_record_gettables(){ + 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()){ + $sql2->db_Select_gen("SHOW TABLES"); + while($row2 = $sql2->db_Fetch()) + { $dbtables[] = $row2[0]; } return $dbtables; } - $text = ''; + $text = "
    "; //validate rate table records - if(isset($_POST['table_rate'])){ + 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{ + $data = array('type' => 'rate', 'table' => 'rate_table', 'itemid' => 'rate_itemid', 'id' => 'rate_id'); + if(!$sql->db_Select_gen($query)) + { + $text .= verify_sql_record_displayresult(DBLAN_49, $data['type']); + } + else + { //the master error array - $err=array(); + $err = array(); //array which will hold all db tables $dbtables = verify_sql_record_gettables(); - while($row=$sql->db_Fetch()){ + while($row = $sql->db_Fetch()) + { - $ctype = $data['type']; - $cid = $row[$data['id']]; - $citemid = $row[$data['itemid']]; - $ctable = $row[$data['table']]; + $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)){ + //FIXME Steve: table is never found without MPREFIX; Multi-language tables? + if(in_array(MPREFIX.$ctable, $dbtables)) + { - $sql3 -> db_Select_gen("SHOW COLUMNS FROM {$ctable}"); - while($row3=$sql3->db_Fetch()){ + $sql3->db_Select_gen("SHOW COLUMNS FROM ".MPREFIX.$ctable); + while($row3 = $sql3->db_Fetch()) + { //find the auto_increment field, since that's the most likely key used - if($row3['Extra']=='auto_increment'){ + if($row3['Extra'] == 'auto_increment') + { $aif = $row3['Field']; break; } @@ -502,116 +703,181 @@ function verify_sql_record(){ //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); + 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); + } + else + { + $err[] = array('type' => $ctable, 'sqlid' => $cid, 'table' => $ctable, 'itemid' => $citemid, 'table_exist' => FALSE); } } - $text .= verify_sql_record_displayresult($err, $ctype); + $text .= verify_sql_record_displayresult(($err ? $err : DBLAN_54), $ctype); } } //validate comments table records - if(isset($_POST['table_comments'])){ + 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'); + $data = array('type' => 'comments', 'table' => 'comment_type', 'itemid' => 'comment_item_id', 'id' => 'comment_id'); - if(!$sql -> db_Select_gen($query)){ - $text = DBLAN_49; - }else{ + if(!$sql->db_Select_gen($query)) + { + $text .= verify_sql_record_displayresult(DBLAN_49, $data['type']); + } + else + { //the master error array - $err=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; + require_once (e_HANDLER."comment_class.php"); + $cobj = new comment(); $e_comment = $cobj->get_e_comment(); - while($row=$sql->db_Fetch()){ + while($row = $sql->db_Fetch()) + { - $ctype = $data['type']; - $cid = $row[$data['id']]; - $citemid = $row[$data['itemid']]; - $ctable = $row[$data['table']]; + $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); + 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"){ + // 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); + } + 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); + } + 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); + } + 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])){ + } + elseif(isset($e_comment[$ctable]) && is_array($e_comment[$ctable])) + { $var = $e_comment[$ctable]; - $qryp=''; + $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' ")){ + 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); + 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); + //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); + //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 .= verify_sql_record_displayresult(($err ? $err : DBLAN_54), $ctype); } } - $text = "".$text."
    "; - $ns->tablerender(DBLAN_50,$text); + $text .= " +
    + ".$frm->admin_button('delete_verify_sql_record', DBLAN_48, 'delete')." + ".$frm->admin_button('verify_sql_record', DBLAN_13, 'back')." + +
    + + "; + + $e107->ns->tablerender(DBLAN_10.' - '.DBLAN_50, $emessage->render().$text); } } -require_once("footer.php"); +require_once ("footer.php"); +/** + * Handle page DOM within the page header + * + * @return string JS source + */ +function headerjs() +{ + require_once (e_HANDLER.'js_helper.php'); + $ret = " + + + "; + + return $ret; +} ?> \ No newline at end of file diff --git a/e107_admin/db_verify.php b/e107_admin/db_verify.php index 001ef4484..5e26ddc91 100644 --- a/e107_admin/db_verify.php +++ b/e107_admin/db_verify.php @@ -1,71 +1,80 @@
    "; +if(varset($_POST['db_tools_back'])) +{ + header("Location:".e_ADMIN_ABS."db.php"); exit; } - $tables["core"] = $sql_data; +require_once("auth.php"); -if (!getperms("0")) { - header("location:".e_BASE."index.php"); +require_once(e_HANDLER."form_handler.php"); +$frm = new e_form(); + +require_once (e_HANDLER."message_handler.php"); +$emessage = &eMessage::getInstance(); + +$sql_data = file_get_contents(e_ADMIN.'sql/core_sql.php'); +if (!$sql_data) +{ + exit(DBLAN_1); +} + +$tables["core"] = $sql_data; + +if (!getperms("0")) +{ + header("Location:".SITEURL."index.php"); exit; } //Get any plugin _sql.php files - - foreach($pref['e_sql_list'] as $path => $file) - { - $filename = e_PLUGIN.$path."/".$file.".php"; - if(is_readable($filename)){ - $fd = fopen($filename, "r"); - $sql_data = fread($fd, filesize($filename)); - fclose ($fd); - $id = str_replace("_sql","",$file); - $tables[$id] = $sql_data; - }else{ - echo $filename.DBLAN_22."
    "; - } - } +foreach($pref['e_sql_list'] as $path => $file) +{ + $filename = e_PLUGIN.$path."/".$file.".php"; + if(is_readable($filename)) + { + $id = str_replace("_sql","",$file); + $tables[$id] = file_get_contents($filename); + } + else + { + $emessage->add($filename.DBLAN_22, E_MESSAGE_WARNING); + } +} -function read_tables($tab) { - global $tablines; - global $table_list; - global $tables,$sql,$pref; +function read_tables($tab) +{ + global $tablines, $table_list, $tables, $pref; $file = split("\n", $tables[$tab]); - foreach($file as $line) { + foreach($file as $line) + { $line = ltrim(stripslashes($line)); - if (preg_match("/CREATE TABLE (.*) /", $line, $match)) { - if($match[1] != "user_extended"){ + $match = array(); + if (preg_match('/CREATE TABLE (.*) /', $line, $match)) + { + if($match[1] != "user_extended") + { $table_list[$match[1]] = 1; $current_table = $match[1]; $x = 0; @@ -73,231 +82,339 @@ function read_tables($tab) { } } - if (strpos($line, "TYPE=") !== FALSE) { + if (strpos($line, "TYPE=") !== FALSE) + { $current_table = ""; } - if ($current_table && $x) { + if ($current_table && $x) + { $tablines[$current_table][$cnt++] = $line; - } $x = 1; } // Get multi-language tables as well - if($pref['multilanguage']){ + if($pref['multilanguage']) + { $langs = table_list(); - foreach($table_list as $name=>$stuff){ - if($langs[$name]){ + foreach(array_keys($table_list) as $name) + { + if($langs[$name]) + { $ltab = $langs[$name]; $table_list[$ltab] = 1; $tablines[$ltab] = $tablines[$name]; } } } - } // Get list of fields and keys for a table -function get_current($tab, $prefix = "") -{ - if (!$prefix) - { - $prefix = MPREFIX; - } - $result = mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1'); - $qry = 'SHOW CREATE TABLE `'.$prefix.$tab."`"; - $z = mysql_query($qry); - if ($z) - { - $row = mysql_fetch_row($z); - return str_replace("`", "", stripslashes($row[1])); - } - else - { - return FALSE; - } +function get_current($tab, $prefix = "") +{ + if(! $prefix) + { + $prefix = MPREFIX; + } + mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1'); + $qry = 'SHOW CREATE TABLE `' . $prefix . $tab . "`"; + $z = mysql_query($qry); + if($z) + { + $row = mysql_fetch_row($z); + return str_replace("`", "", stripslashes($row[1])); + } + else + { + return FALSE; + } } -function check_tables($what) +function check_tables($what) { - global $tablines; - global $table_list; - global $ns; - $cur=0; + global $tablines, $table_list, $frm; + + $cur = 0; $table_list = ""; read_tables($what); $fix_active = FALSE; // Flag set as soon as there's a fix - enables 'Fix it' button - - $text = "
    -
    - - - - - - - "; - foreach(array_keys($table_list) as $k) + + $text = " + +
    + ".DBLAN_16." - $what ".DBLAN_18." + "; + foreach(array_keys($table_list) as $k) { // $k is the DB table name (less prefix) - $prefix = MPREFIX; - $current_tab = get_current($k, $prefix); // Get list of fields and keys from actual table - unset($fields); - unset($xfields); - if ($current_tab) - { - $lines = split("\n", $current_tab); // Create one element of $lines per field or other line of info - $fieldnum = 0; - foreach($tablines[$k] as $x) - { // $x is a line of the DB definition from the *_sql.php file - $x = str_replace(' ',' ',$x); // Remove double spaces - $fieldnum++; - $ffound = 0; - list($fname, $fparams) = split(" ", $x, 2); - if ($fname == "KEY") - { - list($key, $keyname, $keyparms) = split(" ", $x, 3); - $fname = $key." ".$keyname; - $fparams = $keyparms; - } - $fields[$fname] = 1; - $fparams = ltrim(rtrim($fparams)); - $fparams = preg_replace("/\r?\n$|\r[^\n]$|,$/", "", $fparams); - if(stristr($k, "lan_") !== FALSE && $cur != 1) - { - $text .= "
    "; - $cur = 1; - }; + $text .= " +
    ".DBLAN_4."".DBLAN_5."".DBLAN_6."".DBLAN_7."
    ".ADLAN_132."
    + + + + + + + + + + + + + + + + + + "; + $prefix = MPREFIX; + $current_tab = get_current($k, $prefix); // Get list of fields and keys from actual table + unset($fields); + unset($xfields); - - $text .= ""; - $s = 0; - $xfieldnum = -1; - foreach($lines as $l) - { - $xfieldnum++; - list($xl, $tmp) = split("\n", $l, 2); // $tmp should be null - $xl = ltrim(rtrim(stripslashes($xl))); - $xl = preg_replace("/\r?\n$|\r[^\n]$/", "", $xl); - $xl = str_replace(' ',' ',$xl); // Remove double spaces - list($xfname, $xfparams) = split(" ", $xl, 2); // Field name and the rest - - if ($xfname == "KEY") - { - list($key, $keyname, $keyparms) = split(" ", $xl, 3); - $xfname = $key." ".$keyname; - $xfparams = $keyparms; - } - - if ($xfname != "CREATE" && $xfname != ")") - { - $xfields[$xfname] = 1; - } - $xfparams = preg_replace("/,$/", "", $xfparams); - $fparams = preg_replace("/,$/", "", $fparams); - if ($xfname == $fname) - { // Field names match - or it could be the word 'KEY' and its name which matches - $ffound = 1; -// echo "Field: ".$xfname." Actuals: ".$xfparams." Expected: ".$fparams."
    "; - $xfsplit = explode(' ',$xfparams); - $fsplit = explode(' ',$fparams); - $skip = FALSE; - $i = 0; - $fld_err = FALSE; - foreach ($xfsplit as $xf) - { - if ($skip) - { - $skip = FALSE; -// echo " Unskip: ".$xf."
    "; - } - elseif (strcasecmp(trim($xf),'collate') == 0) - { // Strip out the collation definition - $skip = TRUE; -// echo "Skip = ".$xf; - } - else - { -// echo "Compare: ".$xf." - ".$fsplit[$i]."
    "; - // Since VARCHAR and CHAR are interchangeable, convert to CHAR (strictly, VARCHAR(3) and smalller becomes CHAR() ) - if (stripos($xf,'VARCHAR') === 0) $xf = substr($xf,3); - if (stripos($fsplit[$i],'VARCHAR') === 0) $fsplit[$i] = substr($fsplit[$i],3); - if (strcasecmp(trim($xf),trim($fsplit[$i])) != 0) - { - $fld_err = TRUE; -// echo "Mismatch: ".$xf." - ".$fsplit[$i]."
    "; - } - $i++; - } - } - - if ($fld_err) - { - $text .= ""; - $text .= ""; - $fix_active = TRUE; - } - elseif ($fieldnum != $xfieldnum) - { // Field numbers different - missing field? - $text .= " - "; - } - else - { - $text .= " - "; - } - } - } // Finished checking one field - - if ($ffound == 0) - { - $text .= " - "; - $fix_active = TRUE; - } - $prev_fname = $fname; - $text .= "\n"; - } - foreach(array_keys($xfields) as $tf) + if ($current_tab) { - if (!$fields[$tf] && $k != "user_extended") - { - $fix_active = TRUE; - $text .= ""; - } - } - } - else - { // Table Missing. - $text .= ""; - $fix_active = TRUE; - } - } - $text .= "
    ".DBLAN_4.": {$k}".DBLAN_5."".DBLAN_6."".DBLAN_7."".DBLAN_19."
    $k$fname"; - if (strpos($fparams, "KEY") !== FALSE) - { - $text .= " $fparams"; - } - $text .= "".DBLAN_8."".DBLAN_9."
    ".$xfparams."
    ".DBLAN_10."
    ".$fparams."
    ".fix_form($k,$fname,$fparams,"alter")."
    ".DBLAN_5." ".DBLAN_8."".DBLAN_9." #{$xfieldnum}
    ".DBLAN_10." #{$fieldnum}
    OK ".DBLAN_11."".DBLAN_10." [$fparams]
    ".fix_form($k,$fname,$fparams,"insert",$prev_fname)."
    $k$tf".DBLAN_12." ".fix_form($k,$tf,$fparams,"drop")."
    $k ".DBLAN_13."
     ".fix_form($k,$tf,$tablines[$k],"create")."
    "; + $lines = split("\n", $current_tab); // Create one element of $lines per field or other line of info + $fieldnum = 0; + foreach($tablines[$k] as $x) + { // $x is a line of the DB definition from the *_sql.php file + $x = str_replace(' ',' ',$x); // Remove double spaces + $fieldnum++; + $ffound = 0; + list($fname, $fparams) = split(" ", $x, 2); + if ($fname == "UNIQUE") + { + list($key, $key1, $keyname, $keyparms) = split(" ", $x, 4); + $fname = $key." ".$key1." ".$keyname; + $fparams = $keyparms; + } + elseif ($fname == "KEY") + { + list($key, $keyname, $keyparms) = split(" ", $x, 3); + $fname = $key." ".$keyname; + $fparams = $keyparms; + } + $fields[$fname] = 1; + $fparams = ltrim(rtrim($fparams)); + $fparams = preg_replace("/\r?\n$|\r[^\n]$|,$/", "", $fparams); - if($fix_active){ - $text .= "
    -
    \n"; + + if(stristr($k, "lan_") !== FALSE && $cur != 1) + { + $cur = 1; + } + + $text .= " + + {$k} + {$fname} + "; + + if (strpos($fparams, "KEY") !== FALSE) + { + $text .= " $fparams"; + } + + $text .= " + + "; + + //$s = 0; - never used + $xfieldnum = -1; + + foreach($lines as $l) + { + $xfieldnum++; + list($xl, $tmp) = split("\n", $l, 2); // $tmp should be null + + $xl = ltrim(rtrim(stripslashes($xl))); + $xl = preg_replace("/\r?\n$|\r[^\n]$/", "", $xl); + $xl = str_replace(' ',' ',$xl); // Remove double spaces + list($xfname, $xfparams) = split(" ", $xl, 2); // Field name and the rest + if ($xfname == "UNIQUE") + { + list($key, $key1, $keyname, $keyparms) = split(" ", $xl, 4); + $xfname = $key." ".$key1." ".$keyname; + $xfparams = $keyparms; + } + elseif ($xfname == "KEY") + { + list($key, $keyname, $keyparms) = split(" ", $xl, 3); + $xfname = $key." ".$keyname; + $xfparams = $keyparms; + } + if ($xfname != "CREATE" && $xfname != ")") + { + $xfields[$xfname] = 1; + } + $xfparams = preg_replace('/,$/', '', $xfparams); + $fparams = preg_replace('/,$/', '', $fparams); + if ($xfname == $fname) + { // Field names match - or it could be the word 'KEY' and its name which matches + $ffound = 1; + //echo "Field: ".$xfname." Actuals: ".$xfparams." Expected: ".$fparams."
    "; + $xfsplit = explode(' ',$xfparams); + $fsplit = explode(' ',$fparams); + $skip = FALSE; + $i = 0; + $fld_err = FALSE; + foreach ($xfsplit as $xf) + { + if ($skip) + { + $skip = FALSE; + // echo " Unskip: ".$xf."
    "; + } + elseif (strcasecmp(trim($xf),'collate') == 0) + { // Strip out the collation definition + $skip = TRUE; + // cho "Skip = ".$xf; + } + else + { + // echo "Compare: ".$xf." - ".$fsplit[$i]."
    "; + // Since VARCHAR and CHAR are interchangeable, convert to CHAR (strictly, VARCHAR(3) and smalller becomes CHAR() ) + if (stripos($xf,'VARCHAR') === 0) $xf = substr($xf,3); + if (stripos($fsplit[$i],'VARCHAR') === 0) $fsplit[$i] = substr($fsplit[$i],3); + if (strcasecmp(trim($xf),trim($fsplit[$i])) != 0) + { + $fld_err = TRUE; + //echo "Mismatch: ".$xf." - ".$fsplit[$i]."
    "; + } + $i++; + } + } + + if ($fld_err) + { + $text .= " + ".DBLAN_8." + + ".DBLAN_9." +
    {$xfparams}
    + ".DBLAN_10." +
    {$fparams}
    + + ".fix_form($k, $fname, $fparams, "alter")." + "; + $fix_active = TRUE; + } + elseif ($fieldnum != $xfieldnum) + { // Field numbers different - missing field? + $text .= " + ".DBLAN_5." ".DBLAN_8." + + ".DBLAN_9.": #{$xfieldnum} +
    + ".DBLAN_10.": #{$fieldnum} + +   + + "; + } + else + { + $text .= " + OK +   +   + "; + /**/ + } + } + } // Finished checking one field + + if ($ffound == 0) + { + $prev_fname = $fname; + $text .= " + ".DBLAN_11." + + ".DBLAN_10." +
    {$fparams}
    + + ".fix_form($k, $fname, $fparams, "insert", $prev_fname)." + "; + $fix_active = TRUE; + } + + $text .= " + + + "; + } + + foreach(array_keys($xfields) as $tf) + { + if (!$fields[$tf] && $k != "user_extended") + { + $fix_active = TRUE; + $text .= " + + $k + $tf + ".DBLAN_12." +   + ".fix_form($k, $tf, $fparams, "drop")." + + "; + } + } + } + else + { // Table Missing. + $text .= " + + {$k} +   + ".DBLAN_13." +   + ".fix_form($k, $tf, $tablines[$k], "create") . " + + "; + + $fix_active = TRUE; + } + $text .= " + + +
    + "; + } + + if($fix_active) + { + $text .= " +
    + ".$frm->admin_button('do_fix', DBLAN_21, 'execute', '', array('id'=>false))." + ".$frm->admin_button('check_all', 'jstarget:fix_active', 'action', LAN_CHECKALL, array('id'=>false))." + ".$frm->admin_button('uncheck_all', 'jstarget:fix_active', 'action', LAN_UNCHECKALL, array('id'=>false))." +
    + "; } foreach(array_keys($_POST) as $j) { - if (preg_match("/table_(.*)/", $j, $mitch)) { - $lx = $mitch[1]; - $text .= "\n"; + $match = array(); + if (preg_match('/table_(.*)/', $j, $match)) + { + $lx = $match[1]; + $text .= "
    \n"; } } - $text .= "
    "; + + $text .= " + +
    + ".$frm->admin_button('back', DBLAN_17, 'back')." +
    + + + "; return $text; } @@ -306,16 +423,21 @@ global $table_list; // -------------------- Table Fixing ------------------------------ -if(isset($_POST['do_fix'])){ - $text = "
    "; - foreach( $_POST['fix_active'] as $key=>$val){ +if(isset($_POST['do_fix'])) +{ + //$emessage->add(DBLAN_20); + foreach( $_POST['fix_active'] as $key=>$val) + { - if (MAGIC_QUOTES_GPC == TRUE) { + if (MAGIC_QUOTES_GPC == TRUE) + { $table = stripslashes($_POST['fix_table'][$key][0]); $newval = stripslashes($_POST['fix_newval'][$key][0]); $mode = stripslashes($_POST['fix_mode'][$key][0]); $after = stripslashes($_POST['fix_after'][$key][0]); - } else { + } + else + { $table = $_POST['fix_table'][$key][0]; $newval = $_POST['fix_newval'][$key][0]; $mode = $_POST['fix_mode'][$key][0]; @@ -325,94 +447,127 @@ if(isset($_POST['do_fix'])){ $field= $key; - if($mode == "alter"){ + if($mode == "alter") + { $query = "ALTER TABLE `".MPREFIX.$table."` CHANGE `$field` `$field` $newval"; } - if($mode == "insert"){ + if($mode == "insert") + { $query = "ALTER TABLE `".MPREFIX.$table."` ADD `$field` $newval AFTER $after"; } - if($mode == "drop"){ + if($mode == "drop") + { $query = "ALTER TABLE `".MPREFIX.$table."` DROP `$field` "; } - if($mode == "index"){ + if($mode == "index") + { $query = "ALTER TABLE `".MPREFIX.$table."` ADD INDEX `$field` (`$newval`)"; } - if($mode == "indexdrop"){ + if($mode == "indexdrop") + { $query = "ALTER TABLE `".MPREFIX.$table."` DROP INDEX `$field`"; } - if($mode == "create"){ + if($mode == "create") + { $query = "CREATE TABLE ".MPREFIX.$table." ($newval) TYPE=MyISAM;"; } - - $text .= ""; - - + if(mysql_query($query)) $emessage->add(LAN_UPDATED.' ['.$query.']', E_MESSAGE_SUCCESS); + else $emessage->add(LAN_UPDATED_FAILED.' ['.$query.']', E_MESSAGE_WARNING); } - $text .= "
    ".$query.""; - $text .= (mysql_query($query)) ? " - ".LAN_UPDATED."" : " - ".LAN_UPDATED_FAILED.""; - $text .= "
    "; - $text .="

    -
    - -
    -
    "; - - $ns -> tablerender(DBLAN_20, $text); } // ---------------------- Main Form and Submit. ------------------------ -if (!$_POST['db_verify'] && !$_POST['do_fix']) { - $text = " -
    - -
    ".DBLAN_14."

    "; - foreach(array_keys($tables) as $x) { - $text .= "".$x."
    "; - } - $text .= " -
    -
    "; - $ns->tablerender(DBLAN_16, $text); -} else { - foreach(array_keys($_POST) as $k) { - if (preg_match("/table_(.*)/", $k, $match)) { +if (varset($_POST['db_verify']) || varset($_POST['do_fix'])) +{ + $text = ''; + foreach(array_keys($_POST) as $k) + { + $match = array(); + if (preg_match("/table_(.*)/", $k, $match)) + { $xx = $match[1]; - $str = "
    -
    -
    - -
    -
    "; - $ns->tablerender(DBLAN_16." - $xx ".DBLAN_18, check_tables($xx).$str); + $text .= check_tables($xx); + } } + + if(!$text) $emessage->add(DBLAN_24, E_MESSAGE_WARNING); + else + { + $e107->ns->tablerender(DBLAN_23.' - '.DBLAN_16, $emessage->render().$text); + require_once(e_ADMIN."footer.php"); + exit; + } } +$text = " +
    +
    + ".DBLAN_14." + + + + + + + + + + +"; +foreach(array_keys($tables) as $x) { + $text .= " + + + + "; +} + +$text .= " + +
    ".$frm->checkbox_toggle('check-all-verify', 'table_').LAN_CHECKALL.' | '.LAN_UNCHECKALL."
    + ".$frm->checkbox('table_'.$x, $x).$frm->label($x, 'table_'.$x, $x)." +
    +
    + ".$frm->admin_button('db_verify', DBLAN_15)." + ".$frm->admin_button('db_tools_back', DBLAN_17, 'back')." +
    +
    +
    +"; + +$e107->ns->tablerender(DBLAN_23.' - '.DBLAN_16, $emessage->render().$text); +require_once(e_ADMIN."footer.php"); +exit; // -------------------------------------------------------------- function fix_form($table,$field, $newvalue,$mode,$after =''){ + global $frm; - if(stristr($field, "KEY ") !== FALSE){ + if(stristr($field, "KEY ") !== FALSE) + { $field = chop(str_replace("KEY ","",$field)); $mode = ($mode == "drop") ? "indexdrop" : "index"; $search = array("(",")"); $newvalue = str_replace($search,"",$newvalue); } - if($mode == "create"){ + if($mode == "create") + { $newvalue = implode("\n",$newvalue); } - $text .= " ".DBLAN_19."\n"; // 'attempt to fix' + $field = trim($field, '`'); + $text .= $frm->checkbox("fix_active[$field][]", 1, false, array('id'=>false)); $text .= "\n"; $text .= "\n"; $text .= "\n"; @@ -421,7 +576,8 @@ function fix_form($table,$field, $newvalue,$mode,$after =''){ return $text; } -function table_list() { +function table_list() +{ // grab default language lists. global $mySQLdefaultdb; @@ -439,17 +595,18 @@ function table_list() { $exclude[] = "pm_messages"; $exclude[] = "pm_blocks"; - // print_r($search); - $tables = mysql_list_tables($mySQLdefaultdb); - while (list($temp) = mysql_fetch_array($tables)){ + while (list($temp) = mysql_fetch_array($tables)) + { $prefix = MPREFIX."lan_"; - - if(preg_match("/^".$prefix."(.*)/", $temp, $match)){ + $match = array(); + if(preg_match('/^'.$prefix.'(.*)/', $temp, $match)) + { $e107tab = str_replace(MPREFIX, "", $temp); $pos = strrpos($match[1],"_")+1; $core = substr(str_replace("lan_","",$e107tab),$pos); - if (str_replace($exclude, "", $e107tab)){ + if (str_replace($exclude, "", $e107tab)) + { $tabs[$core] = $e107tab; } } @@ -458,8 +615,29 @@ function table_list() { return $tabs; } +/** + * Handle page DOM within the page header + * + * @return string JS source + */ +function headerjs() +{ + require_once (e_HANDLER.'js_helper.php'); + $ret = " + + + "; - -require_once(e_ADMIN."footer.php"); -?> + return $ret; +} +?> \ No newline at end of file diff --git a/e107_admin/fla.php b/e107_admin/fla.php index 9e8834a6a..48308a1a8 100644 --- a/e107_admin/fla.php +++ b/e107_admin/fla.php @@ -9,8 +9,8 @@ * Manage/View failed login attempts * * $Source: /cvs_backup/e107_0.8/e107_admin/fla.php,v $ - * $Revision: 1.6 $ - * $Date: 2008-12-23 16:25:06 $ + * $Revision: 1.7 $ + * $Date: 2008-12-30 13:51:41 $ * $Author: secretr $ * */ @@ -166,7 +166,7 @@ else ".LAN_BAN."
    - ".$frm->checkbox('check_all_ban', 'jstarget:flaban', false, array('id'=>false,'class'=>'checkbox toggle-all'))." + ".$frm->checkbox_toggle('check-all-ban', 'flaban')." @@ -225,8 +225,6 @@ function headerjs() require_once(e_HANDLER.'js_helper.php'); $ret = " |tyle[^>]+>.*?))#mis', $full_text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); + $subcon = preg_split('#((?:]+>.*?|tyle[^>]+>.*?))#mis', $full_text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); foreach ($subcon as $sub_blk) { -// if (preg_match('#^<(script|style)[^>]+>#',$sub_blk)) // +// if (preg_match('#^<(script|style)[^>]+>#',$sub_blk)) // if ((substr($sub_blk,0,7) == '"; @@ -843,7 +843,7 @@ class e_parse // Convert emoticons to graphical icons, unless modifiers override if (!$opts['emotes_off'] && ($pref['smiley_activate'] || $opts['emotes_on'])) { - if (!is_object($this->e_emote)) + if (!is_object($this->e_emote)) { require_once(e_HANDLER.'emote_filter.php'); $this->e_emote = new e_emoteFilter; @@ -878,7 +878,7 @@ class e_parse // Start parse [bb][/bb] codes if ($parseBB !== FALSE) { - if (!is_object($this->e_bb)) + if (!is_object($this->e_bb)) { require_once(e_HANDLER.'bbcode_handler.php'); $this->e_bb = new e_bbcode; @@ -910,9 +910,9 @@ class e_parse // profanity filter - if ($pref['profanity_filter']) + if ($pref['profanity_filter']) { - if (!is_object($this->e_pf)) + if (!is_object($this->e_pf)) { require_once(e_HANDLER."profanity_filter.php"); $this->e_pf = new e_profanityFilter; @@ -946,7 +946,7 @@ class e_parse $sub_blk = $this->e_hook[$hook]->$hook($sub_blk,$opts['context']); } } - + if(isset($pref['e_tohtml_list']) && is_array($pref['e_tohtml_list'])) { foreach($pref['e_tohtml_list'] as $hook) @@ -999,7 +999,7 @@ class e_parse $ret_parser .= $sub_blk; } // End of 'normal' processing for a block of text - } // End of 'foreach() on each block of non-script text + } // End of 'foreach() on each block of non-script text } // End of 'normal' parsing (non-script text) @@ -1015,7 +1015,7 @@ class e_parse function toAttribute($text) { $text = str_replace("&","&",$text); // URLs posted without HTML access may have an & in them. $text = htmlspecialchars($text, ENT_QUOTES, CHARSET); // Xhtml compliance. - if (!preg_match('/&#|\'|"|\(|\)|<|>/s', $text)) + if (!preg_match('/&#|\'|"|\(|\)|<|>/s', $text)) { $text = $this->replaceConstants($text); return $text; diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 675e4d7bf..928ad51fc 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -9,8 +9,8 @@ * Form Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ - * $Revision: 1.12 $ - * $Date: 2008-12-23 08:28:42 $ + * $Revision: 1.13 $ + * $Date: 2008-12-30 13:51:41 $ * $Author: secretr $ * */ @@ -108,6 +108,12 @@ class e_form } + function checkbox_toggle($name, $selector = 'multitoggle') + { + $selector = 'jstarget:'.$selector; + return $this->checkbox($name, $selector, false, array('id'=>false,'class'=>'checkbox toggle-all')); + } + function radio($name, $value, $checked = false, $options = array()) { $options['checked'] = $checked; //comes as separate argument just for convenience diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index b16d948f3..8b4d40e6b 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -9,8 +9,8 @@ * Message Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $ - * $Revision: 1.10 $ - * $Date: 2008-12-23 16:25:06 $ + * $Revision: 1.11 $ + * $Date: 2008-12-30 13:51:41 $ * $Author: secretr $ * */ @@ -317,7 +317,8 @@ class eMessage E_MESSAGE_ERROR => array(), E_MESSAGE_WARNING => array(), E_MESSAGE_SUCCESS => array(), - E_MESSAGE_INFO => array() + E_MESSAGE_INFO => array(), + E_MESSAGE_DEBUG => array() ); } diff --git a/e107_languages/English/admin/lan_cpage.php b/e107_languages/English/admin/lan_cpage.php index 041d7916f..3046edcf0 100644 --- a/e107_languages/English/admin/lan_cpage.php +++ b/e107_languages/English/admin/lan_cpage.php @@ -1,13 +1,10 @@ diff --git a/e107_languages/English/admin/lan_db_verify.php b/e107_languages/English/admin/lan_db_verify.php index f56041e61..33851dae0 100644 --- a/e107_languages/English/admin/lan_db_verify.php +++ b/e107_languages/English/admin/lan_db_verify.php @@ -4,9 +4,9 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_db_verify.php,v $ -| $Revision: 1.2 $ -| $Date: 2007-05-29 18:53:07 $ -| $Author: e107steved $ +| $Revision: 1.3 $ +| $Date: 2008-12-30 13:51:41 $ +| $Author: secretr $ +----------------------------------------------------------------------------+ */ define("DBLAN_1", "Unable to read the sql datafile

    Please ensure the file core_sql.php exists in the /admin/sql directory."); @@ -31,4 +31,6 @@ define("DBLAN_19", "Attempt to Fix"); define("DBLAN_20", "Attempting to fix tables"); define("DBLAN_21", "Fix Selected Items"); define("DBLAN_22", " is not readable"); +define("DBLAN_23", "Database Utilities"); +define("DBLAN_24", "Please select action."); ?> \ No newline at end of file diff --git a/e107_themes/_blank/admin_style.css b/e107_themes/_blank/admin_style.css index ba153e1d1..ed22c8800 100644 --- a/e107_themes/_blank/admin_style.css +++ b/e107_themes/_blank/admin_style.css @@ -79,6 +79,16 @@ ul,ol { list-style:none; } .no-bg { background:none !important; } .clear { clear: both; } +pre { + overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */ + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + /* width: 99%; */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} + /*******************************************************************************************************************/ /* E107 CORE ADMIN CSS *********************************************************************************************/ @@ -87,7 +97,7 @@ ul,ol { list-style:none; } /******** Decorate JS */ /* Admin List Table */ .adminlist { width:100%; border:1px solid #ddd;} -.adminlist th { padding: 5px; border-bottom:1px solid #ddd; border-right: 1px solid #ddd; font-weight: bold; white-space:nowrap; } +.adminlist th { padding: 5px; border-bottom:1px solid #ddd; border-right: 1px solid #ddd; font-weight: bold } .adminlist td { padding: 5px; border-bottom:1px solid #ddd; border-right: 1px solid #ddd; } .adminlist th.last, .adminlist td.last { border-right: 0px solid;} @@ -197,6 +207,7 @@ label { cursor: pointer; } #s-message div.info, #s-message div.error, #s-message div.success, +#s-message div.debug, #s-message div.warning { padding: 5px; margin-bottom: 10px; } @@ -204,6 +215,7 @@ label { cursor: pointer; } #s-message div.error { background-color:#FFCECE; border: 1px solid #CC0000; } #s-message div.success { background-color:#DFFFDF; border: 1px solid #009900; } #s-message div.warning { background-color:#FFFFD5; border: 1px solid #FFCC00; } +#s-message div.debug { background-color:#FFFFFF; border: 1px solid #EAEAEA; } .message-title { height: 32px; background: 0 50% no-repeat; padding-left: 42px; font-size: 14px; font-weight: bold; line-height: 32px; } @@ -211,6 +223,7 @@ label { cursor: pointer; } #s-message div.error .message-title { background-image: url(images/messagebox_critical.png); } #s-message div.success .message-title { background-image: url(images/ok.png); } #s-message div.warning .message-title { background-image: url(images/messagebox_warning.png); } +#s-message div.debug .message-title { background-image: url(images/messagebox_info.png); } .message-body { padding-left: 42px; } .message-item () diff --git a/e107_themes/_blank/languages/English.php b/e107_themes/_blank/languages/English.php index dce8ee84f..8de2f6f7d 100644 --- a/e107_themes/_blank/languages/English.php +++ b/e107_themes/_blank/languages/English.php @@ -1,6 +1,7 @@ \ No newline at end of file