2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-30 13:51:41 +00:00
* e107 website system
*
2013-03-24 13:07:15 +01:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2008-12-30 13:51:41 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Administration - Database Utilities
*
2006-12-02 04:36:16 +00:00
*/
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . " /../class2.php " );
2009-09-05 23:02:23 +00:00
$theme = e107 :: getPref ( 'sitetheme' );
define ( " EXPORT_PATH " , " { e_THEME} " . $theme . " /install/ " );
2008-12-30 13:51:41 +00:00
if ( ! getperms ( '0' ))
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2008-12-30 13:51:41 +00:00
exit ();
2006-12-02 04:36:16 +00:00
}
2008-12-30 13:51:41 +00:00
if ( isset ( $_POST [ 'back' ]))
{
2020-12-22 14:48:28 -08:00
e107 :: redirect ( e_SELF );
2008-12-30 13:51:41 +00:00
exit ();
}
2017-01-17 01:33:03 +01:00
e107 :: coreLan ( 'db' , true );
2009-11-13 07:14:57 +00:00
2011-06-08 03:16:47 +00:00
$e_sub_cat = 'database' ;
2009-11-13 07:14:57 +00:00
2011-06-08 03:16:47 +00:00
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
2008-12-30 13:51:41 +00:00
2014-06-27 20:54:47 +03:00
if ( isset ( $_GET [ 'mode' ]))
{
2019-12-01 15:31:47 +01:00
$_GET [ 'mode' ] = preg_replace ( '/[^\w\-]/' , '' , $_GET [ 'mode' ]);
2014-06-27 20:54:47 +03:00
}
if ( isset ( $_GET [ 'type' ]))
{
2019-12-01 15:31:47 +01:00
$_GET [ 'type' ] = preg_replace ( '/[^\w\-]/' , '' , $_GET [ 'type' ]);
2014-06-27 20:54:47 +03:00
}
2008-12-30 13:51:41 +00:00
/*
* Execute trigger
*/
2011-06-08 03:16:47 +00:00
if ( isset ( $_POST [ 'db_execute' ]))
2008-12-30 13:51:41 +00:00
{
2011-06-08 03:16:47 +00:00
$type = key ( $_POST [ 'db_execute' ]);
2008-12-30 13:51:41 +00:00
if ( ! varset ( $_POST [ 'db_execute' ]))
{
2011-06-08 03:16:47 +00:00
$mes -> add ( DBLAN_53 , E_MESSAGE_WARNING );
2008-12-30 13:51:41 +00:00
}
else
{
2011-06-08 03:16:47 +00:00
$_POST [ $type ] = true ;
2008-12-30 13:51:41 +00:00
}
}
2013-05-04 19:59:54 -07:00
2006-12-02 04:36:16 +00:00
2011-06-08 03:16:47 +00:00
2009-08-27 21:01:44 +00:00
if ( isset ( $_POST [ 'exportXmlFile' ]))
2009-08-22 00:28:55 +00:00
{
2016-12-24 12:41:06 -08:00
2019-07-09 12:08:52 -07:00
if ( exportXmlFile ( $_POST [ 'xml_prefs' ], $_POST [ 'xml_tables' ], $_POST [ 'xml_plugprefs' ], $_POST [ 'xml_themeprefs' ], $_POST [ 'package_images' ], false ))
2009-09-05 23:02:23 +00:00
{
2013-03-24 13:07:15 +01:00
$mes = e107 :: getMessage ();
2019-05-29 11:18:34 -07:00
$mes -> add ( LAN_CREATED , E_MESSAGE_SUCCESS );
2009-09-05 23:02:23 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-22 00:28:55 +00:00
}
2006-12-02 04:36:16 +00:00
2014-01-25 15:56:20 -08:00
if ( e_AJAX_REQUEST )
{
session_write_close ();
2020-12-18 19:55:12 -08:00
while ( ob_get_length () !== false ) // destroy all ouput buffering
{
ob_end_clean ();
}
2014-01-25 15:56:20 -08:00
if ( varset ( $_GET [ 'mode' ]) == 'backup' ) //FIXME - not displaying progress until complete. Use e-progress?
{
2016-09-14 12:55:09 +02:00
echo " " . DBLAN_120 . " <br /> " ;
2014-01-25 15:56:20 -08:00
$data = array ();
$data [] = e_MEDIA ;
$data [] = e_LOG ;
$data [] = e_IMPORT ;
$data [] = e_TEMP ;
$data [] = e_SYSTEM . " filetypes.xml " ;
$data [] = e_THEME . e107 :: getPref ( 'sitetheme' );
$plugins = e107 :: getPlugin () -> getOtherPlugins ();
foreach ( $plugins as $dir )
{
$data [] = e_PLUGIN . $dir ;
}
$newFile = eHelper :: title2sef ( SITENAME ) . " _ " . date ( " Y-m-d-H-i-s " );
$zip = e107 :: getFile () -> zip ( $data , e_BACKUP . $newFile . " .zip " );
2015-05-02 09:55:47 +02:00
echo DBLAN_60 . " <small>( " . $zip . " )</small><br /> " ;
2014-01-25 15:56:20 -08:00
2015-05-02 09:55:47 +02:00
echo DBLAN_61 . " <br /> " ;
2012-11-26 18:42:11 -08:00
2014-01-25 15:56:20 -08:00
$dbfile = e107 :: getDb () -> backup ( '*' , $newFile . " .sql " , array ( 'nologs' => 1 , 'droptable' => 1 ));
2015-05-02 09:55:47 +02:00
echo DBLAN_62 . " <small>( " . $dbfile . " )</small> " ;
2014-01-25 15:56:20 -08:00
2020-12-22 09:36:02 -08:00
e107 :: getLog () -> addSuccess ( $zip . " " . $dbfile , false ) -> save ( DBLAN_63 );
2014-01-25 15:56:20 -08:00
}
exit ;
}
2012-11-26 18:42:11 -08:00
2008-12-30 13:51:41 +00:00
require_once ( " auth.php " );
2011-06-08 03:16:47 +00:00
2009-11-13 07:14:57 +00:00
$st = new system_tools ;
2009-09-05 23:02:23 +00:00
2006-12-02 04:36:16 +00:00
2010-02-10 21:53:56 +00:00
/* No longer needed after XML feature added .
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'backup_core' ]) || $_GET [ 'mode' ] == 'backup_core' )
2009-08-27 21:01:44 +00:00
{
2009-08-29 15:30:41 +00:00
backup_core ();
//message_handler("MESSAGE", DBLAN_1);
2012-11-30 03:08:15 -08:00
$mes -> add ( DBLAN_1 , E_MESSAGE_SUCCESS );
2009-08-27 21:01:44 +00:00
}
2009-08-29 15:30:41 +00:00
*/
2009-08-27 21:01:44 +00:00
2006-12-02 04:36:16 +00:00
2009-01-16 01:02:41 +00:00
2006-12-02 04:36:16 +00:00
2009-11-13 07:14:57 +00:00
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
require_once ( " footer.php " );
class system_tools
{
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
public $_options = array ();
2013-10-27 22:37:34 -07:00
private $_utf8_exclude = array ();
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
function __construct ()
{
global $mySQLdefaultdb ;
2013-10-27 22:37:34 -07:00
$this -> _utf8_exclude = array ( MPREFIX . " core " );
2009-08-29 15:30:41 +00:00
$this -> _options = array (
2021-02-03 20:38:31 -08:00
" db_update " => array ( 'diz' => DBLAN_15 , 'label' => DBLAN_16 , 'icon' => 'fas-angle-double-up.glyph' ),
" verify_sql " => array ( 'diz' => DBLAN_4 , 'label' => DBLAN_5 , 'icon' => 'fas-database.glyph' ),
'optimize_sql' => array ( 'diz' => DBLAN_6 , 'label' => DBLAN_7 , 'icon' => 'fas-wrench.glyph' ),
'plugin_scan' => array ( 'diz' => DBLAN_28 , 'label' => DBLAN_29 , 'icon' => 'fas-plug.glyph' ),
'pref_editor' => array ( 'diz' => DBLAN_19 , 'label' => DBLAN_20 , 'icon' => 'fas-edit.glyph' ),
2009-08-29 15:30:41 +00:00
// 'backup_core' => array('diz'=>DBLAN_8, 'label'=> DBLAN_9),
2013-05-04 19:59:54 -07:00
// 'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36),
2021-02-03 20:38:31 -08:00
'importForm' => array ( 'diz' => DBLAN_59 , 'label' => DBLAN_59 , 'icon' => 'fas-file-import.glyph' ),
'exportForm' => array ( 'diz' => DBLAN_58 , 'label' => DBLAN_58 , 'icon' => 'fas-file-export.glyph' ),
'sc_override_scan' => array ( 'diz' => DBLAN_55 , 'label' => DBLAN_56 , 'icon' => 'fas-search.glyph' ),
'convert_to_utf8' => array ( 'diz' => DBLAN_64 , 'label' => DBLAN_65 , 'icon' => 'fas-language.glyph' ),
'correct_perms' => array ( 'diz' => DBLAN_66 , 'label' => DBLAN_67 , 'icon' => 'fas-folder.glyph' ),
2021-02-01 18:18:30 -08:00
'backup' => array ( 'diz' => DBLAN_68 , 'label' => DBLAN_69 , 'icon' => 'fas-archive.glyph' )
2009-08-29 15:30:41 +00:00
);
2013-07-14 09:45:01 -07:00
2015-05-25 14:35:15 -07:00
if ( deftrue ( 'e_DEVELOPER' ))
2013-07-14 09:45:01 -07:00
{
2021-02-03 20:38:31 -08:00
$this -> _options [ 'multisite' ] = array ( 'diz' => " <span class='label label-warning'> " . DBLAN_114 . " </span> " , 'label' => 'Multi-Site' , 'icon' => 'fas-clone.glyph' );
2021-02-01 18:18:30 -08:00
$this -> _options [ 'github' ] = array ( 'diz' => " <span class='label label-warning'> " . DBLAN_114 . " </span> " . DBLAN_115 . " " , 'label' => DBLAN_112 , 'icon' => 'fab-github.glyph' );
2013-07-14 09:45:01 -07:00
}
2009-08-29 18:07:42 +00:00
2015-05-30 17:06:22 -07:00
2013-03-06 14:53:20 -08:00
$this -> _options = multiarray_sort ( $this -> _options , 'label' );
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'delplug' ]))
{
2016-12-24 09:34:00 -08:00
$this -> delete_plugin_entry (); // $_POST['pref_type']
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'upload' ]))
2010-02-10 21:53:56 +00:00
{
$this -> importXmlFile ();
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'delpref' ]) || ( isset ( $_POST [ 'delpref_checked' ]) && isset ( $_POST [ 'delpref2' ])))
{
2009-09-26 18:08:14 +00:00
$this -> del_pref_val ( $_POST [ 'pref_type' ]);
2009-08-29 15:30:41 +00:00
}
2011-06-08 03:16:47 +00:00
2018-11-22 13:43:02 -08:00
if ( isset ( $_POST [ 'verify_sql' ]) || ! empty ( $_POST [ 'verify_table' ]) || varset ( $_GET [ 'mode' ]) == 'verify_sql' )
2011-06-08 03:16:47 +00:00
{
2022-11-12 11:14:37 -08:00
e107 :: css ( 'inline' , "
td . darker { background - color : rgba ( 0 , 0 , 0 , 0.5 ) }
2022-11-12 11:19:20 -08:00
label . form - check { cursor : pointer }
2022-11-12 11:14:37 -08:00
" );
e107 :: js ( 'footer-inline' , "
$ ( '#core-db-verify-sql-tables input[type=\"checkbox\"]' ) . click ( function ( evt ){
if ( this . checked )
{
$ ( this ) . closest ( 'td' ) . addClass ( 'darker' , 50 );
}
else
{
$ ( this ) . closest ( 'td' ) . removeClass ( 'darker' , 300 );
}
});
" );
2017-02-03 11:34:14 -08:00
e107 :: getCache () -> clear ( 'Dbverify' , true );
2011-06-08 03:16:47 +00:00
require_once ( e_HANDLER . " db_verify_class.php " );
$dbv = new db_verify ;
2011-06-09 07:03:55 +00:00
$dbv -> backUrl = e_SELF . " ?mode=verify_sql " ;
$dbv -> verify ();
2018-11-22 13:43:02 -08:00
//echo e107::getMessage()->render();
2011-06-08 03:16:47 +00:00
return ;
}
2015-05-30 17:06:22 -07:00
// ----------------- Processes ------------------
2014-01-25 15:56:20 -08:00
2013-05-04 19:59:54 -07:00
// if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']))
// {
2011-06-08 03:16:47 +00:00
//$this->verify_sql_record(); // - currently performed in db_verify_class.php
2013-05-04 19:59:54 -07:00
// }
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'importForm' ]) || $_GET [ 'mode' ] == 'importForm' )
{
2010-02-10 21:53:56 +00:00
$this -> importForm ();
2009-08-29 15:30:41 +00:00
}
2013-05-04 19:59:54 -07:00
if ( isset ( $_POST [ 'db_update' ]) || varset ( $_GET [ 'mode' ]) == 'db_update' ) // Requires further testing.
{
// header("location: ".e_ADMIN."e107_update.php");
2018-09-12 11:46:23 -07:00
$dbupdate = null ;
2013-05-04 19:59:54 -07:00
require_once ( e_ADMIN . " update_routines.php " );
new e107Update ( $dbupdate );
return ;
}
2018-09-12 11:46:23 -07:00
if ( isset ( $_POST [ 'convert_to_utf8' ]) || $_GET [ 'mode' ] == 'convert_to_utf8' )
2009-11-13 07:14:57 +00:00
{
2010-02-10 21:53:56 +00:00
$this -> convertUTF8Form ();
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'exportForm' ]) || $_GET [ 'mode' ] == 'exportForm' )
{
2010-02-10 21:53:56 +00:00
$this -> exportXmlForm ();
2009-08-29 15:30:41 +00:00
}
2009-08-22 00:28:55 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'optimize_sql' ]) || $_GET [ 'mode' ] == 'optimize_sql' )
{
$this -> optimizesql ( $mySQLdefaultdb );
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'pref_editor' ]) || $_GET [ 'mode' ] == 'pref_editor' || isset ( $_POST [ 'delpref' ]) || isset ( $_POST [ 'delpref_checked' ]))
{
2009-09-10 12:49:47 +00:00
$type = isset ( $_GET [ 'type' ]) ? $_GET [ 'type' ] : " core " ;
$this -> pref_editor ( $type );
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
if ( isset ( $_POST [ 'sc_override_scan' ]) || $_GET [ 'mode' ] == 'sc_override_scan' )
{
$this -> scan_override ();
}
2010-02-10 21:53:56 +00:00
2009-09-10 10:23:12 +00:00
if ( isset ( $_POST [ 'plugin_scan' ]) || e_QUERY == " plugin " || isset ( $_POST [ 'delplug' ]) || $_GET [ 'mode' ] == 'plugin_scan' )
2009-08-29 15:30:41 +00:00
{
2012-12-23 15:00:15 +00:00
$this -> plugin_viewscan ( 'refresh' );
2009-08-29 15:30:41 +00:00
}
2013-07-14 09:45:01 -07:00
2015-05-30 17:06:22 -07:00
if ( ! empty ( $_POST [ 'create_multisite' ]))
2013-07-14 09:45:01 -07:00
{
$this -> multiSiteProcess ();
}
2010-02-10 21:53:56 +00:00
2015-05-30 17:06:22 -07:00
if ( ! empty ( $_POST [ 'perform_utf8_convert' ]))
2009-11-13 07:14:57 +00:00
{
$this -> perform_utf8_convert ();
2011-06-08 03:16:47 +00:00
return ;
2009-11-13 07:14:57 +00:00
}
2015-05-30 17:06:22 -07:00
if ( ! empty ( $_POST [ 'githubSyncProcess' ]))
{
$this -> githubSyncProcess ();
return ;
}
// --------------------- Modes --------------------------------.
2012-08-05 10:06:01 +00:00
if ( varset ( $_GET [ 'mode' ]) == 'correct_perms' )
{
$this -> correct_perms ();
return ;
}
2013-07-14 09:45:01 -07:00
if ( varset ( $_GET [ 'mode' ]) == 'multisite' )
{
$this -> multiSite ();
return ;
}
2015-05-30 17:06:22 -07:00
if ( varset ( $_GET [ 'mode' ]) == 'github' )
{
$this -> githubSync ();
}
2014-01-25 15:56:20 -08:00
if ( varset ( $_GET [ 'mode' ]) == 'backup' )
{
$this -> backup ();
return ;
}
2010-02-10 21:53:56 +00:00
2011-06-08 03:16:47 +00:00
if ( ! vartrue ( $_GET [ 'mode' ]) && ! isset ( $_POST [ 'db_execute' ]))
2010-02-10 21:53:56 +00:00
{
2009-08-29 18:07:42 +00:00
$this -> render_options ();
}
2009-11-13 07:14:57 +00:00
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2014-01-25 15:56:20 -08:00
2018-10-03 18:53:16 +02:00
// Developer Mode ONly.. No LANS required.
2015-05-30 17:06:22 -07:00
private function githubSync ()
{
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
2020-05-25 13:09:29 -07:00
$pref = e107 :: pref ();
2015-05-30 17:06:22 -07:00
2020-05-25 13:09:29 -07:00
if ( empty ( $pref [ 'developer' ]))
2020-04-27 15:19:58 +02:00
{
e107 :: getMessage () -> addError ( " Developer mode has to be enabled in order to use this functionality! " );
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_112 , $mes -> render ());
return ;
}
2018-10-03 18:53:16 +02:00
// Check for minimum required PHP version, and display warning instead of sync button to avoid broken functionality after syncing
// MIN_PHP_VERSION constant only defined in install.php, thus hardcoded here
$min_php_version = '5.6' ;
2018-10-04 15:54:02 +02:00
if ( version_compare ( PHP_VERSION , $min_php_version , " < " ))
2018-10-03 18:53:16 +02:00
{
2020-05-23 17:31:44 +02:00
$mes -> addWarning ( " The minimum required PHP version is <strong> " . $min_php_version . " </strong>. You are using PHP version <strong> " . PHP_VERSION . " </strong>. <br /> Syncing with Github has been disabled to avoid broken fuctionality. " ); // No need to translate, developer mode only
2018-10-03 18:53:16 +02:00
}
else
{
$message = $frm -> open ( 'githubSync' );
$message .= " <p> " . DBLAN_116 . " <b> " . e_SYSTEM . " temp</b> " . DBLAN_117 . " </p> " ;
$message .= $frm -> button ( 'githubSyncProcess' , 1 , 'delete' , DBLAN_113 );
$message .= $frm -> close ();
$mes -> addInfo ( $message );
}
2015-05-30 17:06:22 -07:00
2016-09-14 12:55:09 +02:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_112 , $mes -> render ());
2015-05-30 17:06:22 -07:00
}
// Developer Mode ONly.. No LANS.
private function githubSyncProcess ()
{
2017-04-23 12:38:05 -07:00
$result = e107 :: getFile () -> unzipGithubArchive ( 'core' );
2015-05-30 17:06:22 -07:00
2017-04-23 12:38:05 -07:00
if ( $result === false )
2015-05-30 17:06:22 -07:00
{
2016-09-14 12:55:09 +02:00
e107 :: getMessage () -> addError ( DBLAN_118 );
2017-04-23 12:38:05 -07:00
return null ;
2015-05-30 17:06:22 -07:00
}
2017-04-23 12:38:05 -07:00
$success = $result [ 'success' ];
$error = $result [ 'error' ];
2015-05-30 17:06:22 -07:00
2017-04-23 12:38:05 -07:00
// $message = e107::getParser()->lanVars(DBLAN_121, array('x'=>$oldPath, 'y'=>$newPath));
2015-05-30 17:06:22 -07:00
if ( ! empty ( $success ))
{
e107 :: getMessage () -> addSuccess ( print_a ( $success , true ));
}
if ( ! empty ( $skipped ))
{
e107 :: getMessage () -> setTitle ( " Skipped " , E_MESSAGE_INFO ) -> addInfo ( print_a ( $skipped , true ));
}
if ( ! empty ( $error ))
{
2018-10-02 11:36:17 -07:00
//e107::getMessage()->addError(print_a($error,true));
e107 :: getMessage () -> setTitle ( " Ignored " , E_MESSAGE_WARNING ) -> addWarning ( print_a ( $error , true ));
2015-05-30 17:06:22 -07:00
}
2016-09-14 12:55:09 +02:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_112 , e107 :: getMessage () -> render ());
2015-05-30 17:06:22 -07:00
2020-03-26 11:53:37 -07:00
e107 :: getCache () -> clearAll ( 'system' );
2015-05-30 17:06:22 -07:00
}
2014-01-25 15:56:20 -08:00
private function backup ()
{
$mes = e107 :: getMessage ();
2015-05-02 09:55:47 +02:00
$message = DBLAN_70 ;
$message .= " <br /><a class='e-ajax btn btn-success' data-loading-text=' " . DBLAN_71 . " ' href='#backupstatus' data-src=' " . e_SELF . " ?mode=backup' > " . LAN_CREATE . " </a> " ;
2014-01-25 15:56:20 -08:00
$mes -> addInfo ( $message );
$text = " <div id='backupstatus' style='margin-top:20px'></div> " ;
2016-09-14 12:55:09 +02:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_119 , $mes -> render () . $text );
2014-01-25 15:56:20 -08:00
}
2012-08-05 10:06:01 +00:00
/**
* Correct Folder and File permissions .
*/
function correct_perms ()
{
$mes = e107 :: getMessage ();
$fl = e107 :: getFile ();
ob_start ();
$fl -> chmod ( e_BASE );
$fl -> chmod ( e_BASE . " cron.php " , 0755 );
$errors = ob_get_clean ();
if ( $errors != '' )
{
$mes -> addError ( $errors );
}
else
{
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_72 );
2012-08-05 10:06:01 +00:00
}
2015-05-02 09:55:47 +02:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_73 , $mes -> render ());
2012-08-05 10:06:01 +00:00
}
2013-07-14 09:45:01 -07:00
private function multiSiteProcess ()
{
$sql = e107 :: getDb ( 'new' );
$mes = e107 :: getMessage ();
$user = $_POST [ 'name' ];
$pass = $_POST [ 'password' ];
$server = e107 :: getMySQLConfig ( 'server' ); // $_POST['server'];
$database = $_POST [ 'db' ];
$prefix = $_POST [ 'prefix' ];
if ( $connect = $sql -> connect ( $server , $user , $pass , true ))
{
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_74 );
2013-07-14 09:45:01 -07:00
2013-07-24 05:45:17 -07:00
if ( vartrue ( $_POST [ 'createdb' ]))
2013-07-14 09:45:01 -07:00
{
2013-07-24 05:45:17 -07:00
if ( $sql -> gen ( " CREATE DATABASE " . $database . " CHARACTER SET `utf8` " ))
2013-07-14 09:45:01 -07:00
{
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_75 );
2013-07-24 05:45:17 -07:00
// $sql->gen("CREATE USER ".$user."@'".$server."' IDENTIFIED BY '".$pass."';");
$sql -> gen ( " GRANT ALL ON ` " . $database . " `.* TO " . $user . " @' " . $server . " '; " );
$sql -> gen ( " FLUSH PRIVILEGES; " );
2013-07-14 09:45:01 -07:00
}
2013-07-24 05:45:17 -07:00
else
2013-07-14 09:45:01 -07:00
{
2015-05-02 09:55:47 +02:00
$mes -> addError ( DBLAN_75 );
2013-07-24 05:45:17 -07:00
return ;
}
2013-07-14 09:45:01 -07:00
}
2013-07-24 05:45:17 -07:00
if ( ! $sql -> database ( $database ))
2013-07-14 09:45:01 -07:00
{
2015-05-02 09:55:47 +02:00
$mes -> addError ( DBLAN_76 );
2013-07-14 09:45:01 -07:00
}
2013-07-24 05:45:17 -07:00
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_76 );
2013-07-24 05:45:17 -07:00
if ( $this -> multiSiteCreateTables ( $sql , $prefix ))
{
$coreConfig = e_CORE . " xml/default_install.xml " ;
$ret = e107 :: getXml () -> e107Import ( $coreConfig , 'add' , true , false , $sql ); // Add core pref values
$mes -> addInfo ( print_a ( $ret , true ));
}
2013-07-14 09:45:01 -07:00
}
else
{
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_74 );
2013-07-14 09:45:01 -07:00
}
if ( $error = $sql -> getLastErrorText ())
{
$mes -> addError ( $error );
}
// print_a($_POST);
}
2019-05-29 11:18:34 -07:00
/**
* @ param object $sql
* @ param $prefix
* @ return bool
*/
2013-07-14 09:45:01 -07:00
private function multiSiteCreateTables ( $sql , $prefix )
{
$mes = e107 :: getMessage ();
$sql_data = file_get_contents ( e_CORE . " sql/core_sql.php " );
$sql_data = preg_replace ( " # \ / \ *.*? \ * \ /#mis " , '' , $sql_data ); // Strip comments
if ( ! $sql_data )
{
2015-05-02 09:55:47 +02:00
$mes -> addError ( DBLAN_77 );
2013-07-14 09:45:01 -07:00
}
preg_match_all ( " /create(.*?)(?:myisam|innodb);/si " , $sql_data , $result );
2019-05-29 11:18:34 -07:00
2013-07-14 09:45:01 -07:00
$sql -> gen ( 'SET NAMES `utf8`' );
foreach ( $result [ 0 ] as $sql_table )
{
$sql_table = preg_replace ( " /create table \ s/si " , " CREATE TABLE " . $prefix , $sql_table );
if ( ! $sql -> gen ( $sql_table ))
{
$mes -> addError ( $sql -> getLastErrorText ());
return false ;
}
2020-12-18 19:55:12 -08:00
/* else
2013-07-14 09:45:01 -07:00
{
// $mes->addDebug($sql_table);
}
2020-12-18 19:55:12 -08:00
*/
2013-07-14 09:45:01 -07:00
}
return true ;
}
private function multiSite ()
{
2015-05-25 14:35:15 -07:00
if ( ! deftrue ( 'e_DEVELOPER' ))
{
return false ;
}
2013-07-14 09:45:01 -07:00
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
e107 :: lan ( 'core' , 'installer' );
2015-07-03 19:39:02 -07:00
// Leave here until no longer experimental. - Should be placed inside lan_db.php and LANS renamed.
define ( 'LANINS_130' , " Parked Domain " );
define ( 'LANINS_131' , " The parked domain which will become a new e107 website. " );
define ( 'LANINS_132' , " mydomain.com " );
define ( 'LANINS_133' , " This will create a fresh installation of e107 at the domain you specify. Using your server administration software (e.g. cPanel) - park your other domain on top of [x] " );
2018-09-12 11:46:23 -07:00
$config = e107 :: getMySQLConfig (); // prefix|server|user|password|defaultdb
2013-07-14 09:45:01 -07:00
if ( ! isset ( $POST [ 'create_multisite' ]))
{
2015-05-07 10:55:44 +02:00
$info = str_replace ( '[x]' , e_DOMAIN , LANINS_133 );
2015-05-02 09:55:47 +02:00
$mes -> addInfo ( $info );
2013-07-14 09:45:01 -07:00
}
$text = $frm -> open ( 'multisite' ) . "
< table class = 'table table-striped' >
< tr >
2015-05-02 09:55:47 +02:00
< td >< label for = 'server' > " .LANINS_130. " </ label ></ td >
2013-07-14 09:45:01 -07:00
< td >
2015-05-02 09:55:47 +02:00
< input class = 'tbox' type = 'text' placeholder = '".LANINS_132."' id = 'domain' name = 'domain' autofocus size = '40' value = '' maxlength = '100' required = 'required' />
< span class = 'field-help' > " .LANINS_131. " </ span >
2013-07-14 09:45:01 -07:00
</ td >
</ tr >
" ;
/*
$text .= "
< tr >
< td >< label for = 'server' > " .LANINS_024. " </ label ></ td >
< td >
< input class = 'tbox' type = 'text' id = 'server' name = 'server' autofocus size = '40' value = 'localhost' maxlength = '100' required = 'required' />
< span class = 'field-help' > " .LANINS_030. " </ span >
</ td >
</ tr > " ;
*/
$text .= "
< tr >
< td >< label for = 'name' > " .LANINS_025. " </ label ></ td >
< td >
< input class = 'tbox' type = 'text' name = 'name' id = 'name' size = '40' value = '".e107::getMySQLConfig(' user ')."' maxlength = '100' required = 'required' />
< span class = 'field-help' > " .LANINS_031. " </ span >
</ td >
</ tr >
< tr >
< td >< label for = 'password' > " .LANINS_026. " </ label ></ td >
< td >
< input class = 'tbox' type = 'password' name = 'password' size = '40' id = 'password' value = '".e107::getMySQLConfig(' password ')."' maxlength = '100' />
< span class = 'field-help' > " .LANINS_032. " </ span >
</ td >
</ tr >
" ;
$text .= "
< tr >
< td >< label for = 'db' > " .LANINS_027. " </ label ></ td >
< td class = 'input-inline' >
< input type = 'text' name = 'db' size = '20' id = 'db' value = '' maxlength = '100' required = 'required' />
< label class = 'checkbox inline' >< input type = 'checkbox' name = 'createdb' value = '1' /> " .LANINS_028. " </ label >
< span class = 'field-help' > " .LANINS_033. " </ span >
</ td >
</ tr > " ;
$text .= "
< tr >
< td >< label for = 'prefix' > " .LANINS_029. " </ label ></ td >
< td >
< input type = 'text' name = 'prefix' size = '20' id = 'prefix' value = 'e107_' pattern = '[a-z0-9]*_$' maxlength = '100' required = 'required' />
< span class = 'field-help' > " .LANINS_034. " </ span >
</ td >
</ tr >
\n " ;
$text .= "
< tr >
< td >< label for = 'u_name' > " .LANINS_072. " </ label ></ td >
< td >
< input class = 'tbox' type = 'text' autofocus name = 'u_name' id = 'u_name' placeholder = 'admin' size = '30' required = 'required' value = '".USERNAME."' maxlength = '60' />
< span class = 'field-help' > " .LANINS_073. " </ span >
</ td >
</ tr >
< tr >
< td >< label for = 'd_name' > " .LANINS_074. " </ label ></ td >
< td >
< input class = 'tbox' type = 'text' name = 'd_name' id = 'd_name' size = '30' placeholder = 'Administrator' value = '".USERNAME."' maxlength = '60' />
< span class = 'field-help' > " .LANINS_123. " </ span >
</ td >
</ tr >
< tr >
< td >< label for = 'pass1' > " .LANINS_076. " </ label ></ td >
< td >
< input type = 'password' name = 'pass1' size = '30' id = 'pass1' value = '' maxlength = '60' required = 'required' />
< span class = 'field-help' > " .LANINS_124. " </ span >
</ td >
</ tr >
< tr >
< td >< label for = 'pass2' > " .LANINS_078. " </ label ></ td >
< td >
< input type = 'password' name = 'pass2' size = '30' id = 'pass2' value = '' maxlength = '60' required = 'required' />
< span class = 'field-help' > " .LANINS_079. " </ span >
</ td >
</ tr >
< tr >
< td >< label for = 'email' > " .LANINS_080. " </ label ></ td >
< td >
< input type = 'text' name = 'email' size = '30' id = 'email' required = 'required' placeholder = 'admin@mysite.com' value = '".USEREMAIL."' maxlength = '100' />
< span class = 'field-help' > " .LANINS_081. " </ span >
</ td >
</ tr >
</ table >
< div class = 'buttons-bar text-center' >
" . $frm->admin_button ('create_multisite',1,'submit','Create New Site'). "
</ div >
\n " ;
$text .= $frm -> close ();
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . " Multi-Site " . SEP . $config [ 'mySQLdefaultdb' ], $mes -> render () . $text );
}
2012-08-05 10:06:01 +00:00
2009-11-14 00:56:57 +00:00
private function convertUTF8Form ()
2009-11-13 07:14:57 +00:00
{
2013-05-04 19:59:54 -07:00
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
$config = e107 :: getMySQLConfig ();
$sql = e107 :: getDb ();
2015-07-16 01:17:21 -07:00
$tp = e107 :: getParser ();
2013-05-04 19:59:54 -07:00
$sql -> gen ( 'SHOW TABLE STATUS WHERE Name LIKE "' . $config [ 'mySQLprefix' ] . '%" ' );
$text = " <table class='table adminlist'>
< colgroup >
< col style = 'width: auto' />
< col style = 'width: auto' />
< col style = 'width: auto' />
< col style = 'width: auto' />
</ colgroup >
< thead >
< tr >
2015-05-02 09:55:47 +02:00
< th > " .DBLAN_78. " </ th >
< th > " .DBLAN_79. " </ th >
< th > " .DBLAN_80. " </ th >
< th > " .DBLAN_81. " </ th >
2013-05-04 19:59:54 -07:00
</ tr >
</ thead >
< tbody > " ;
$invalidCollations = false ;
while ( $row = $sql -> fetch ())
{
2013-10-27 22:37:34 -07:00
if ( in_array ( $row [ 'Name' ], $this -> _utf8_exclude ))
{
continue ;
}
2013-05-04 19:59:54 -07:00
$text .= " <tr>
< td > " . $row['Name'] . " </ td >
< td > " . $row['Engine'] . " </ td >
< td > " . $row['Collation'] . " </ td >
2022-12-10 07:06:47 -08:00
< td > " .(( $row['Collation'] == 'utf8_general_ci') ? defset('ADMIN_TRUE_ICON') : defset('ADMIN_FALSE_ICON')). " </ td >
2013-05-04 19:59:54 -07:00
</ tr > " ;
// print_a($row);
if ( $row [ 'Collation' ] != 'utf8_general_ci' )
{
$invalidCollations = true ;
}
2009-11-13 07:14:57 +00:00
2013-05-04 19:59:54 -07:00
}
$text .= " </tbody></table> " ;
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
if ( $invalidCollations == true )
{
2015-05-02 09:55:47 +02:00
$message = str_replace ( '[database]' , $config [ 'mySQLdefaultdb' ], DBLAN_82 );
$message .= '<br/>' ;
$message .= DBLAN_83 ;
$message .= '<br/>' ;
$message .= '<br/>' ;
$message .= DBLAN_84 ;
$message .= '<ul>' ;
$message .= '<li>' . DBLAN_85 . '</li>' ;
$message .= '<li>' . DBLAN_86 . '</li>' ;
$message .= '<li>' . DBLAN_87 . '</li>' ;
$message .= '<li>' . DBLAN_88 . '</li>' ;
$message .= '</ul>' ;
2019-02-26 12:22:36 -08:00
$mes -> add ( $tp -> toHTML ( $message , true ), E_MESSAGE_WARNING );
2013-05-04 19:59:54 -07:00
$text .= "
< form method = 'post' action = '".e_SELF."' id = 'linkform' >
< fieldset id = 'core-db-utf8-convert' >
2015-05-02 09:55:47 +02:00
< legend class = 'e-hideme' > " .DBLAN_89. " </ legend >
2013-05-04 19:59:54 -07:00
< div class = 'buttons-bar center' >
2015-05-02 09:55:47 +02:00
" . $frm->admin_button ('perform_utf8_convert', DBLAN_90,false,DBLAN_90,'class=btn-success&data-loading-text='.DBLAN_91). "
2013-05-04 19:59:54 -07:00
</ div >
</ fieldset >
</ form > " ;
}
else
{
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_92 );
2013-05-04 19:59:54 -07:00
}
2016-09-14 12:55:09 +02:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_65 . SEP . $config [ 'mySQLdefaultdb' ], $mes -> render () . $text );
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
2009-11-14 00:56:57 +00:00
private function perform_utf8_convert ()
2009-11-13 07:14:57 +00:00
{
2013-05-04 19:59:54 -07:00
$config = e107 :: getMySQLConfig ();
$dbtable = $config [ 'mySQLdefaultdb' ];
2018-09-12 12:03:17 -07:00
2010-02-10 21:53:56 +00:00
//TODO Add a check to be sure the database is not already utf-8.
2009-11-14 04:28:04 +00:00
// yep, needs more methods - possibly a class in e107_handler
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
$sql = e107 :: getDb ( 'utf8-convert' );
2009-11-13 07:14:57 +00:00
$mes = e107 :: getMessage ();
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
$ERROR = FALSE ;
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
// if(!$sql->gen("USE information_schema;"))
// {
// $mes->add("Couldn't read information_schema", E_MESSAGE_ERROR);
// return;
// }
2010-02-10 21:53:56 +00:00
$queries = array ();
2013-05-04 19:59:54 -07:00
$queries [] = $this -> getQueries ( " SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = ' " . $dbtable . " ' AND TABLE_NAME LIKE ' " . $config [ 'mySQLprefix' ] . " %' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%'; " );
$queries [] = $this -> getQueries ( " SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = ' " . $dbtable . " ' AND TABLE_NAME LIKE ' " . $config [ 'mySQLprefix' ] . " %' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%'; " );
2010-02-10 21:53:56 +00:00
$queries2 = array ();
2013-05-04 19:59:54 -07:00
$queries2 [] = $this -> getQueries ( " SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA =' " . $dbtable . " ' AND TABLE_NAME LIKE ' " . $config [ 'mySQLprefix' ] . " %' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%'; " );
$queries2 [] = $this -> getQueries ( " SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA = ' " . $dbtable . " ' AND TABLE_NAME LIKE ' " . $config [ 'mySQLprefix' ] . " %' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%'; " );
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
// $sql->gen("USE ".$dbtable);
// print_a($queries2);
// echo $mes->render();
// return;
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
// Convert Text tables to Binary.
2009-11-13 07:14:57 +00:00
foreach ( $queries as $qry )
{
2013-05-04 19:59:54 -07:00
2009-11-13 07:14:57 +00:00
foreach ( $qry as $q )
{
if ( ! $sql -> db_Query ( $q ))
{
2013-05-04 19:59:54 -07:00
$mes -> addError ( $q );
2009-11-13 07:14:57 +00:00
$ERROR = TRUE ;
}
2013-05-04 19:59:54 -07:00
else
{
$mes -> addDebug ( $q );
}
2010-02-10 21:53:56 +00:00
}
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
//------------
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
// Convert Table Fields to utf8
$sql2 = e107 :: getDb ( 'sql2' );
$sql -> gen ( 'SHOW TABLE STATUS WHERE Collation != "utf8_general_ci" ' );
while ( $row = $sql -> fetch ())
2009-11-13 07:14:57 +00:00
{
2013-05-04 19:59:54 -07:00
$table = $row [ 'Name' ];
2013-10-27 22:37:34 -07:00
if ( in_array ( $row [ 'Name' ], $this -> _utf8_exclude ))
{
continue ;
}
2013-05-04 19:59:54 -07:00
$tab_query = " ALTER TABLE " . $table . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; " ;
//echo "TABQRT= ".$tab_query;
if ( ! $sql2 -> db_Query ( $tab_query ))
2009-11-13 07:14:57 +00:00
{
2013-05-04 19:59:54 -07:00
$mes -> addError ( $tab_query );
2010-02-10 21:53:56 +00:00
$ERROR = TRUE ;
2009-11-13 07:14:57 +00:00
}
2013-05-04 19:59:54 -07:00
else
{
$mes -> addDebug ( $tab_query );
}
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
// ---------------
2013-05-04 19:59:54 -07:00
// Convert Table Fields back to Text/varchar etc.
2009-11-13 07:14:57 +00:00
foreach ( $queries2 as $qry )
{
foreach ( $qry as $q )
{
if ( ! $sql -> db_Query ( $q ))
{
2013-05-04 19:59:54 -07:00
$mes -> addError ( $q );
2010-02-10 21:53:56 +00:00
$ERROR = TRUE ;
2009-11-13 07:14:57 +00:00
}
2013-05-04 19:59:54 -07:00
else
{
$mes -> addDebug ( $q );
}
2010-02-10 21:53:56 +00:00
}
2009-11-13 07:14:57 +00:00
}
//------------
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
$lastQry = " ALTER DATABASE ` " . $dbtable . " ` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; " ;
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
if ( ! $sql -> db_Query ( $lastQry ))
{
2010-02-10 21:53:56 +00:00
$mes -> add ( $lastQry , E_MESSAGE_ERROR );
2009-11-13 07:14:57 +00:00
}
elseif ( $ERROR != TRUE )
{
2015-05-02 09:55:47 +02:00
$message = DBLAN_93 ;
2013-05-04 19:59:54 -07:00
//$message .= "<br />Please now add the following line to your e107_config.php file:<br /><b>\$mySQLcharset = 'utf8';</b>";
2010-02-10 21:53:56 +00:00
$mes -> add ( $message , E_MESSAGE_SUCCESS );
2015-05-02 09:55:47 +02:00
$mes -> addSuccess ( DBLAN_94 );
2013-11-18 16:53:52 -08:00
$mes -> addSuccess ( '$mySQLcharset = "utf8";' );
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
2013-05-04 19:59:54 -07:00
echo $mes -> render ();
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
2009-11-13 07:14:57 +00:00
function getQueries ( $query )
{
2013-05-04 19:59:54 -07:00
$mes = e107 :: getMessage ();
$sql = e107 :: getDb ( 'utf8-convert' );
2021-11-26 12:36:25 -08:00
$qry = [];
2013-05-04 19:59:54 -07:00
if ( $sql -> gen ( $query ))
{
2016-02-14 12:15:55 -08:00
while ( $row = $sql -> fetch ( 'num' ))
2013-05-04 19:59:54 -07:00
{
$qry [] = $row [ 0 ];
}
}
else
{
$mes -> addError ( $query );
}
return $qry ;
/*
2009-11-13 07:14:57 +00:00
if ( ! $result = mysql_query ( $query ))
{
2013-05-04 19:59:54 -07:00
$mes -> addError ( " Query Failed: " . $query );
2009-11-13 07:14:57 +00:00
return ;
}
2016-02-14 12:15:55 -08:00
while ( $row = mysql_fetch_array ( $result , 'num' ))
2009-11-13 07:14:57 +00:00
{
2010-02-10 21:53:56 +00:00
$qry [] = $row [ 0 ];
2009-11-13 07:14:57 +00:00
}
2010-02-10 21:53:56 +00:00
return $qry ;
2013-05-04 19:59:54 -07:00
* */
2009-11-13 07:14:57 +00:00
}
2009-08-22 00:28:55 +00:00
2009-08-29 15:30:41 +00:00
/**
2010-02-10 21:53:56 +00:00
* Delete selected preferences .
2019-05-29 11:18:34 -07:00
* @ return null
2010-02-10 21:53:56 +00:00
*/
2009-09-26 18:08:14 +00:00
private function del_pref_val ( $mode = 'core' )
2009-08-29 15:30:41 +00:00
{
2012-11-30 03:08:15 -08:00
$mes = e107 :: getMessage ();
2010-02-10 21:53:56 +00:00
2009-09-26 18:08:14 +00:00
$deleted_list = " " ;
2010-02-10 21:53:56 +00:00
2021-03-15 10:46:50 -07:00
$config = $this -> getPrefConfig ( $mode );
2010-02-10 21:53:56 +00:00
2009-09-26 18:08:14 +00:00
// Single Pref Deletion using button
if ( varset ( $_POST [ 'delpref' ]))
2009-08-29 15:30:41 +00:00
{
2009-09-26 18:08:14 +00:00
$delpref = key ( $_POST [ 'delpref' ]);
if ( $config -> remove ( $delpref ))
{
2010-02-10 21:53:56 +00:00
$deleted_list .= " <li> " . $delpref . " </li> " ;
}
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-09-26 18:08:14 +00:00
// Multiple Pref deletion using checkboxes
if ( varset ( $_POST [ 'delpref2' ]))
2010-02-10 21:53:56 +00:00
{
2009-08-29 15:30:41 +00:00
foreach ( $_POST [ 'delpref2' ] as $k => $v )
{
2009-09-26 18:08:14 +00:00
if ( $config -> remove ( $k ))
{
2010-02-10 21:53:56 +00:00
$deleted_list .= " <li> " . $k . " </li> " ;
}
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
}
2009-09-26 18:08:14 +00:00
if ( $deleted_list && $config -> save ())
2010-02-10 21:53:56 +00:00
{
2012-11-30 03:08:15 -08:00
$mes -> add ( LAN_DELETED . " <ul> " . $deleted_list . " </ul> " );
2009-09-26 18:08:14 +00:00
e107 :: getCache () -> clear ();
2009-09-10 12:49:47 +00:00
}
2009-09-26 18:08:14 +00:00
2016-12-24 09:34:00 -08:00
return null ;
2009-08-29 15:30:41 +00:00
}
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
private function delete_plugin_entry ()
{
2012-11-30 03:08:15 -08:00
$mes = e107 :: getMessage ();
$sql = e107 :: getDb ();
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$del = array_keys ( $_POST [ 'delplug' ]);
2016-12-24 09:34:00 -08:00
if ( $sql -> delete ( " plugin " , " plugin_id=' " . intval ( $del [ 0 ]) . " ' " ))
2009-08-29 15:30:41 +00:00
{
2012-11-30 03:08:15 -08:00
$mes -> add ( LAN_DELETED , E_MESSAGE_SUCCESS );
2009-08-29 15:30:41 +00:00
}
else
{
2012-11-30 03:08:15 -08:00
$mes -> add ( LAN_DELETED_FAILED , E_MESSAGE_WARNING );
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
}
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
/**
* Render Options
2016-12-24 09:34:00 -08:00
* @ return null
2010-02-10 21:53:56 +00:00
*/
2009-08-29 15:30:41 +00:00
private function render_options ()
{
2016-12-24 09:34:00 -08:00
2021-02-03 20:38:31 -08:00
$mes = e107 :: getMessage ();
$tp = e107 :: getParser ();
2012-11-30 03:08:15 -08:00
2009-08-29 15:30:41 +00:00
$text = "
< form method = 'post' action = '".e_SELF."' id = 'core-db-main-form' >
< fieldset id = 'core-db-plugin-scan' >
< legend class = 'e-hideme' > " .DBLAN_10. " </ legend >
2013-03-02 21:07:42 -08:00
< table class = 'table table-striped adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 60%' />
< col style = 'width: 40%' />
2009-08-29 15:30:41 +00:00
</ colgroup >
< tbody > " ;
2013-03-06 14:53:20 -08:00
2021-02-04 08:45:10 -08:00
$text = " <div class='row'> " ;
2013-03-06 14:53:20 -08:00
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
foreach ( $this -> _options as $key => $val )
{
2013-03-06 14:53:20 -08:00
2021-02-04 08:45:10 -08:00
$text .= " <div class='col-md-6 col-lg-4' style='height:80px; padding-bottom:10px'>
< a class = 'btn btn-default btn-secondary btn-lg btn-large pull-left' style = 'margin-right:10px' href = '".e_SELF."?mode=".$key."' title = \ " " . $val [ 'label' ] . " \" > " . $tp -> toGlyph ( $val [ 'icon' ], [ 'fw' => true , 'size' => '2x' ]) . " </a>
2013-03-06 14:53:20 -08:00
< h4 style = 'margin-bottom:3px' >< a href = '".e_SELF."?mode=".$key."' title = \ " " . $val [ 'label' ] . " \" > " . $val [ 'label' ] . " </a></h4><small> " . $val [ 'diz' ] . " </small>
</ div > " ;
2013-05-04 19:59:54 -07:00
2010-02-10 21:53:56 +00:00
}
2013-03-06 14:53:20 -08:00
/*
2009-08-29 15:30:41 +00:00
$text .= "
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
</ tbody >
2011-06-08 03:16:47 +00:00
</ table > " ;
// $text .= "<div class='buttons-bar center'>
// ".$frm->admin_button('trigger_db_execute', DBLAN_51, 'execute')."
// </div>";
$text .= "
2009-08-29 15:30:41 +00:00
</ fieldset >
</ form >
" ;
2013-03-06 14:53:20 -08:00
*/
2011-06-08 03:16:47 +00:00
e107 :: getRender () -> tablerender ( DBLAN_10 , $mes -> render () . $text );
2016-12-24 09:34:00 -08:00
return null ;
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
/**
* Import XML Form
2016-12-24 09:34:00 -08:00
* @ return null
2010-02-10 21:53:56 +00:00
*/
2009-08-29 15:30:41 +00:00
private function importForm ()
{
// Get largest allowable file upload
2010-02-10 21:53:56 +00:00
2012-11-30 03:08:15 -08:00
$frm = e107 :: getSingleton ( 'e_form' );
2013-03-24 13:07:15 +01:00
$mes = e107 :: getMessage ();
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
require_once ( e_HANDLER . 'upload_handler.php' );
$max_file_size = get_user_max_upload ();
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text = "
< form enctype = 'multipart/form-data' method = 'post' action = '".e_SELF."?mode=".$_GET[' mode ']."' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2009-08-29 15:30:41 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
< tbody >
< tr >
< td > " .LAN_UPLOAD. " </ td >
2008-12-30 13:51:41 +00:00
< td >
2009-08-29 15:30:41 +00:00
< input type = 'hidden' name = 'MAX_FILE_SIZE' value = '{$max_file_size}' />
< input type = 'hidden' name = 'ac' value = '".md5(ADMINPWCHANGE)."' />
< input class = 'tbox' type = 'file' name = 'file_userfile[]' accept = 'text/xml' size = '50' />
2008-12-30 13:51:41 +00:00
</ td >
2009-08-29 15:30:41 +00:00
</ tr >
</ tbody >
</ table >
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
< div class = 'center buttons-bar' > " ;
$text .= $frm -> admin_button ( 'upload' , LAN_UPLOAD , 'submit' , LAN_UPLOAD );
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text .= "
</ div >
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
</ form > \n " ;
2010-02-10 21:53:56 +00:00
2012-11-30 03:08:15 -08:00
2013-02-22 21:34:06 -08:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_59 , $mes -> render () . $text );
2010-02-10 21:53:56 +00:00
2016-12-24 09:34:00 -08:00
return null ;
2009-08-29 15:30:41 +00:00
}
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
/**
* Export XML Dump
2016-12-24 09:34:00 -08:00
* @ return null
2010-02-10 21:53:56 +00:00
*/
2009-08-29 15:30:41 +00:00
private function exportXmlForm ()
{
2013-03-24 13:07:15 +01:00
$mes = e107 :: getMessage ();
2009-08-29 15:30:41 +00:00
$frm = e107 :: getSingleton ( 'e_form' );
2010-02-10 21:53:56 +00:00
2009-09-05 23:02:23 +00:00
$text = " <form method='post' action=' " . e_SELF . " ? " . e_QUERY . " ' id='core-db-export-form'>
2009-08-29 15:30:41 +00:00
< fieldset id = 'core-db-export' >
2015-05-02 09:55:47 +02:00
< legend class = 'e-hideme' > " .DBLAN_95. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
2012-05-13 05:56:35 +00:00
< col style = 'width: 80%' />
< col style = 'width: 20%' />
2010-02-10 21:53:56 +00:00
</ colgroup >
2009-08-29 15:30:41 +00:00
< thead >
2008-12-30 13:51:41 +00:00
< tr >
2016-02-25 18:43:49 -08:00
< th class = 'form-inline' > " . $frm->checkbox_toggle ('check-all-verify', 'xml_prefs'). " & nbsp ; " .LAN_PREFS. " </ th >
2015-05-02 09:55:47 +02:00
< th class = 'right' > " .DBLAN_98. " </ th >
2010-02-10 21:53:56 +00:00
</ tr >
2009-08-29 15:30:41 +00:00
</ thead >
< tbody >
2010-02-10 21:53:56 +00:00
2009-08-31 02:00:51 +00:00
" ;
2010-02-10 21:53:56 +00:00
2009-09-05 23:02:23 +00:00
$pref_types = e107 :: getConfig () -> aliases ;
2013-05-20 01:06:52 -07:00
unset ( $pref_types [ 'core_old' ], $pref_types [ 'core_backup' ]);
2009-09-05 23:02:23 +00:00
// $exclusions = array('core_old'=>1,'core_backup'=>1);
// $filteredprefs = array_diff($pref_types,$exclusions);
2010-02-10 21:53:56 +00:00
2009-08-31 02:00:51 +00:00
foreach ( $pref_types as $key => $description )
2009-08-29 15:30:41 +00:00
{
2016-12-24 09:34:00 -08:00
$data = e107 :: getConfig ( $key ) -> getPref ();
$rows = count ( $data );
2012-12-08 13:52:05 +01:00
$checked = ( vartrue ( $_POST [ 'xml_prefs' ][ $key ]) == $key ) ? 1 : 0 ;
2009-09-05 23:02:23 +00:00
$text .= " <tr>
2009-08-31 02:00:51 +00:00
< td >
2013-05-20 01:06:52 -07:00
" . $frm->checkbox ( " xml_prefs [ " . $key . " ] " , $key , $checked , array('label'=>LAN_PREFS. " : " . $key )). "
</ td >
2016-12-24 09:34:00 -08:00
< td class = 'text-right' > " .intval( $rows ). " </ td >
2010-02-10 21:53:56 +00:00
2009-08-31 02:00:51 +00:00
</ tr > " ;
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
}
2016-12-24 09:34:00 -08:00
// Plugin Preferences ----------------------------
$pluglist = e107 :: pref ( 'core' , 'plug_installed' );
$text .= " </tbody><thead><tr>
< th class = 'form-inline' > " . $frm->checkbox_toggle ('check-all-verify', 'xml_plugprefs'). " & nbsp ; Plugin " .LAN_PREFS. " </ th >
< th class = 'right' > " .DBLAN_98. " </ th >
</ tr ></ thead >< tbody > " ;
ksort ( $pluglist );
foreach ( $pluglist as $plug => $ver )
{
$data = e107 :: getPlugConfig ( $plug ) -> getPref ();
$key = $plug ;
$checked = false ;
if ( ! empty ( $data ))
{
$rows = count ( $data );
$text .= " <tr>
< td >
" . $frm->checkbox ( " xml_plugprefs [ " . $key . " ] " , $key , $checked , array('label'=>LAN_PREFS. " : " . $key )). "
</ td >
< td class = 'text-right' > " . $rows . " </ td >
</ tr > " ;
}
}
2019-07-09 12:08:52 -07:00
// theme preferences
$sitetheme = e107 :: pref ( 'core' , 'sitetheme' ); // currently just sitetheme, but could easily be expanded.
$themelist = array ( $sitetheme );
$text .= " </tbody><thead><tr>
< th class = 'form-inline' > " . $frm->checkbox_toggle ('check-all-verify', 'xml_plugprefs'). " & nbsp ; Theme " .LAN_PREFS. " </ th >
< th class = 'right' > " .DBLAN_98. " </ th >
</ tr ></ thead >< tbody > " ;
// ksort($themelist);
foreach ( $themelist as $plug )
{
$data = e107 :: getThemeConfig ( $plug ) -> getPref ();
$key = $plug ;
$checked = false ;
if ( ! empty ( $data ))
{
$rows = count ( $data );
$text .= " <tr>
< td >
" . $frm->checkbox ( " xml_themeprefs [ " . $key . " ] " , $key , $checked , array('label'=>LAN_PREFS. " : " . $key )). "
</ td >
< td class = 'text-right' > " . $rows . " </ td >
</ tr > " ;
}
}
2016-12-24 09:34:00 -08:00
2009-09-02 17:27:29 +00:00
$text .= " </tbody>
</ table >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 80%' />
< col style = 'width: 20%' />
2010-02-10 21:53:56 +00:00
</ colgroup >
2009-09-02 17:27:29 +00:00
< thead >
< tr >
2016-02-25 18:43:49 -08:00
< th class = 'form-inline' > " . $frm->checkbox_toggle ('check-all-verify', 'xml_tables'). " & nbsp ; " .DBLAN_97. " </ th >
2015-05-02 09:55:47 +02:00
< th class = 'right' > " .DBLAN_98. " </ th >
2010-02-10 21:53:56 +00:00
</ tr >
2009-09-02 17:27:29 +00:00
</ thead >
< tbody > \n " ;
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$tables = table_list ();
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
foreach ( $tables as $name => $count )
2010-02-10 21:53:56 +00:00
{
2012-12-08 13:52:05 +01:00
$checked = ( vartrue ( $_POST [ 'xml_tables' ][ $name ]) == $name ) ? 1 : 0 ;
2010-02-10 21:53:56 +00:00
$text .= " <tr>
2009-08-29 15:30:41 +00:00
< td >
2015-05-02 09:55:47 +02:00
" . $frm->checkbox ( " xml_tables [ " . $name . " ] " , $name , $checked , array('label'=>DBLAN_99. " " . $name )).
2013-05-20 01:06:52 -07:00
" </td>
2021-05-11 13:26:27 -07:00
< td class = 'right' > " . $count . " </ td >
2009-08-29 15:30:41 +00:00
</ tr > " ;
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text .= "
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
</ tbody >
</ table >
2010-02-10 21:53:56 +00:00
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 80%' />
< col style = 'width: 20%' />
2010-02-10 21:53:56 +00:00
</ colgroup >
2009-09-02 17:27:29 +00:00
< thead >
< tr >
< th colspan = '2' > " .LAN_OPTIONS. " </ th >
2010-02-10 21:53:56 +00:00
</ tr >
2009-09-02 17:27:29 +00:00
</ thead >
< tbody >
< tr >
2009-09-05 23:02:23 +00:00
< td colspan = '2' > " ;
2010-02-10 21:53:56 +00:00
$checked = ( vartrue ( $_POST [ 'package_images' ])) ? 1 : 0 ;
2015-05-02 09:55:47 +02:00
$text .= $frm -> checkbox ( " package_images " , 'package_images' , $checked ) . " " . DBLAN_100 . " <i> " . e107 :: getParser () -> replaceConstants ( EXPORT_PATH ) . " </i>
2010-02-10 21:53:56 +00:00
2009-09-02 17:27:29 +00:00
</ td >
</ tr >
</ tbody >
</ table >
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
< div class = 'buttons-bar center' >
2015-05-02 09:55:47 +02:00
" . $frm->admin_button ('exportXmlFile', DBLAN_101, 'other'). "
2009-08-29 15:30:41 +00:00
</ div >
</ fieldset >
</ form > " ;
2010-02-10 21:53:56 +00:00
2016-12-24 09:34:00 -08:00
// display differences between default and core prefs.
/*
$corePrefs = e107 :: pref ( 'core' );
$defaultArray = e107 :: getXml () -> loadXMLfile ( e_CORE . " xml/default_install.xml " , 'advanced' );
$defaultPrefs = e107 :: getXml () -> e107ImportPrefs ( $defaultArray );
$text .= " <table class='table'> " ;
foreach ( $defaultPrefs as $k => $val )
{
if ( $val == $corePrefs [ $k ] || substr ( $k , - 5 ) === '_list' || substr ( $k , 0 , 9 ) == 'sitetheme' )
{
continue ;
}
$text .= " <tr>
< td > " . $k . " </ td >
< td > " .print_a( $val ,true). " < td >< td > " .print_a( $corePrefs[$k] ,true). " </ td >
</ tr > " ;
}
$text .= " </table> " ;
*/
2010-02-10 21:53:56 +00:00
2016-12-24 09:34:00 -08:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_102 , $mes -> render () . $text );
2010-02-10 21:53:56 +00:00
2016-12-24 09:34:00 -08:00
return null ;
2009-08-29 15:30:41 +00:00
}
2006-12-02 04:36:16 +00:00
2009-08-29 15:30:41 +00:00
/**
* Import XML Dump
2016-12-24 09:34:00 -08:00
* @ return null
2009-08-29 15:30:41 +00:00
*/
2009-08-31 02:00:51 +00:00
private function importXmlFile ()
2009-08-29 15:30:41 +00:00
{
2009-08-31 02:00:51 +00:00
$ret = e107 :: getSingleton ( 'xmlClass' ) -> e107Import ( $_FILES [ 'file_userfile' ][ 'tmp_name' ][ 0 ]);
2007-03-15 15:55:08 +00:00
2009-08-31 02:00:51 +00:00
foreach ( $ret [ 'success' ] as $table )
2009-08-29 15:30:41 +00:00
{
2015-05-02 09:55:47 +02:00
e107 :: getMessage () -> addSuccess ( DBLAN_103 . " $table " );
2009-08-29 18:07:42 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-31 02:00:51 +00:00
foreach ( $ret [ 'failed' ] as $table )
2009-08-29 18:07:42 +00:00
{
2015-05-02 09:55:47 +02:00
e107 :: getMessage () -> addError ( DBLAN_104 . " $table " );
2010-02-10 21:53:56 +00:00
}
2016-12-24 09:34:00 -08:00
return null ;
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
/**
* Optimize SQL
2016-12-24 09:34:00 -08:00
* @ param $mySQLdefaultdb
* @ return null
2009-08-29 15:30:41 +00:00
*/
2015-10-29 00:26:56 +01:00
private function optimizesql ( $mySQLdefaultdb )
2009-08-29 15:30:41 +00:00
{
2015-10-29 00:26:56 +01:00
$mes = e107 :: getMessage ();
$tables = e107 :: getDb () -> tables ();
foreach ( $tables as $table )
2009-08-29 15:30:41 +00:00
{
2015-10-29 00:26:56 +01:00
e107 :: getDb () -> gen ( " OPTIMIZE TABLE " . $table );
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2015-10-29 00:26:56 +01:00
$mes -> addSuccess ( e107 :: getParser () -> lanVars ( DBLAN_11 , $mySQLdefaultdb ));
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_7 , $mes -> render ());
2016-12-24 09:34:00 -08:00
return null ;
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2021-03-15 10:46:50 -07:00
private function getPrefConfig ( $type )
{
if ( strpos ( $type , 'plugin_' ) === 0 )
{
$config = e107 :: getPlugConfig ( substr ( $type , 7 ));
}
elseif ( strpos ( $type , 'theme_' ) === 0 )
{
$config = e107 :: getThemeConfig ( substr ( $type , 6 ));
}
else
{
$config = e107 :: getConfig ( $type );
}
return $config ;
}
2009-08-29 15:30:41 +00:00
/**
* Preferences Editor
2016-12-24 09:34:00 -08:00
* @ param string $type
2009-12-13 21:52:32 +00:00
* @ return string text for display
2009-08-29 15:30:41 +00:00
*/
2009-09-28 07:17:52 +00:00
private function pref_editor ( $type = 'core' )
2009-08-29 15:30:41 +00:00
{
2010-02-10 21:53:56 +00:00
2013-03-24 13:07:15 +01:00
global $e107 ;
2012-11-30 03:08:15 -08:00
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
2013-03-24 13:07:15 +01:00
$tp = e107 :: getParser ();
$pref = e107 :: getPref ();
2010-02-10 21:53:56 +00:00
2021-03-15 10:46:50 -07:00
$config = $this -> getPrefConfig ( $type );
2009-09-26 18:08:14 +00:00
$spref = $config -> getPref ();
2010-02-10 21:53:56 +00:00
ksort ( $spref );
2009-08-29 15:30:41 +00:00
$text = "
2009-09-26 18:08:14 +00:00
< form method = 'post' action = '".e_ADMIN."db.php?mode=".$_GET[' mode ']."&type=".$type."' id = 'pref_edit' >
2009-08-29 15:30:41 +00:00
< fieldset id = 'core-db-pref-edit' >
2009-09-10 12:49:47 +00:00
< legend class = 'e-hideme' > " .DBLAN_20. " </ legend > " ;
2010-02-10 21:53:56 +00:00
2017-02-01 08:54:28 -08:00
$text .= " <select class='tbox form-control input-large' name='type_select' onchange='urljump(this.options[selectedIndex].value)' >
2015-01-27 19:06:12 -08:00
< option value = '".e_ADMIN."db.php?mode=".$_GET[' mode ']."&type=core' > Core </ option > \n
2015-02-03 12:23:03 -08:00
< option value = '".e_ADMIN."db.php?mode=".$_GET[' mode ']."&type=search' > Search </ option >
< option value = '".e_ADMIN."db.php?mode=".$_GET[' mode ']."&type=notify' > Notify </ option > \n " ;
2010-02-10 21:53:56 +00:00
2009-09-26 18:08:14 +00:00
// e107::getConfig($type)->aliases
2021-03-15 10:46:50 -07:00
$text .= '<optgroup label="' . LAN_PLUGIN . '">' ;
2015-10-29 00:25:49 +01:00
e107 :: getDb () -> gen ( " SELECT e107_name FROM #core WHERE e107_name LIKE ('plugin_%') ORDER BY e107_name " );
while ( $row = e107 :: getDb () -> fetch ())
2009-09-10 12:49:47 +00:00
{
2021-03-15 10:46:50 -07:00
$label = str_replace ( " plugin_ " , " " , $row [ 'e107_name' ]);
$key = $row [ 'e107_name' ];
2009-09-10 12:49:47 +00:00
$selected = ( varset ( $_GET [ 'type' ]) == $key ) ? " selected='selected' " : " " ;
2021-03-15 10:46:50 -07:00
$text .= " <option value=' " . e_ADMIN . " db.php?mode= " . $_GET [ 'mode' ] . " &type= " . $key . " ' { $selected } > " . ucwords ( $label ) . " </option> \n " ;
2010-02-10 21:53:56 +00:00
}
2021-03-15 10:46:50 -07:00
$text .= '</optgroup>' ;
2010-02-10 21:53:56 +00:00
2021-03-15 10:46:50 -07:00
$text .= '<optgroup label="' . LAN_THEME . '">' ;
e107 :: getDb () -> gen ( " SELECT e107_name FROM #core WHERE e107_name LIKE ('theme_%') ORDER BY e107_name " );
while ( $row = e107 :: getDb () -> fetch ())
{
$label = str_replace ( " theme_ " , " " , $row [ 'e107_name' ]);
$key = $row [ 'e107_name' ];
$selected = ( varset ( $_GET [ 'type' ]) == $key ) ? " selected='selected' " : " " ;
$text .= " <option value=' " . e_ADMIN . " db.php?mode= " . $_GET [ 'mode' ] . " &type= " . $key . " ' { $selected } > " . ucwords ( $label ) . " </option> \n " ;
}
$text .= '</optgroup>' ;
2010-02-10 21:53:56 +00:00
2009-09-10 12:49:47 +00:00
$text .= " </select></div>
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 5%' />
< col style = 'width: 20%' />
< col style = 'width: 70%' />
< col style = 'width: 5%' />
2009-08-29 15:30:41 +00:00
</ colgroup >
< thead >
< tr >
< th class = 'center' > " .LAN_DELETE. " </ th >
< th > " .DBLAN_17. " </ th >
< th > " .DBLAN_18. " </ th >
< th class = 'center last' > " .LAN_OPTIONS. " </ th >
</ tr >
</ thead >
< tbody >
" ;
2010-02-10 21:53:56 +00:00
2009-09-10 12:49:47 +00:00
foreach ( $spref as $key => $val )
2009-08-29 15:30:41 +00:00
{
2021-02-06 12:48:19 -08:00
if ( is_array ( $val ))
{
$varView = deftrue ( 'e_DEBUG' ) ? var_export ( $val , true ) : print_r ( $val , true );
$ptext = " <pre> " . htmlentities ( $varView ) . " </pre> " ;
}
else
{
$ptext = htmlspecialchars ( $val , ENT_QUOTES , 'utf-8' );
}
2013-03-24 13:07:15 +01:00
$ptext = $tp -> textclean ( $ptext , 80 );
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text .= "
2009-08-22 00:28:55 +00:00
< tr >
2009-08-29 15:30:41 +00:00
< td class = 'center autocheck e-pointer' > " . $frm->checkbox ( " delpref2 [ $key ] " , 1). " </ td >
< td > { $key } </ td >
< td > { $ptext } </ td >
< td class = 'center' > " . $frm->submit_image ( " delpref [ $key ] " , LAN_DELETE, 'delete', LAN_CONFIRMDEL. " [ $key ] " ). " </ td >
2009-08-22 00:28:55 +00:00
</ tr >
2009-08-29 15:30:41 +00:00
" ;
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text .= "
</ tbody >
</ table >
< div class = 'buttons-bar center' >
2009-11-08 09:14:39 +00:00
" . $frm->admin_button ('delpref_checked', LAN_DELCHECKED, 'delete'). "
" . $frm->admin_button ('back', LAN_BACK, 'back'). "
2009-09-28 07:17:52 +00:00
< input type = 'hidden' name = 'pref_type' value = '".$type."' />
2009-08-29 15:30:41 +00:00
</ div >
</ fieldset >
</ form > \n\n " ;
2010-02-10 21:53:56 +00:00
2021-03-15 10:46:50 -07:00
if ( strpos ( $type , 'plugin_' ) === 0 )
{
$caption = LAN_PLUGIN . SEP . ucfirst ( substr ( $type , 7 ));
}
elseif ( strpos ( $type , 'theme_' ) === 0 )
{
$caption = LAN_THEME . SEP . ucfirst ( substr ( $type , 6 ));
}
else
{
$caption = ucwords ( $type );
}
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_20 . SEP . $caption , $mes -> render () . $text );
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
return $text ;
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
/**
* Preferences Editor
2019-05-29 11:18:34 -07:00
* @ return null
2010-02-10 21:53:56 +00:00
*/
2009-08-29 15:30:41 +00:00
private function scan_override ()
{
2013-03-24 13:07:15 +01:00
$pref = e107 :: getPref ();
2012-11-30 03:08:15 -08:00
$mes = e107 :: getMessage ();
$f = e107 :: getFile ();
2013-02-08 16:49:57 +02:00
$config = e107 :: getConfig ();
2010-02-10 21:53:56 +00:00
2013-02-08 16:49:57 +02:00
$fList = $f -> get_files ( e_CORE . 'override/shortcodes/single' , '\.php$' );
2013-02-09 19:05:51 +02:00
$scList = array ();
2009-08-29 15:30:41 +00:00
if ( count ( $fList ))
{
foreach ( $fList as $file )
{
2013-02-09 19:05:51 +02:00
$scList [] = strtoupper ( substr ( $file [ 'fname' ], 0 , - 4 ));
2009-08-29 15:30:41 +00:00
}
2013-02-09 19:05:51 +02:00
$scList = implode ( ',' , $scList );
2009-08-29 15:30:41 +00:00
}
2013-02-08 16:49:57 +02:00
$config -> set ( 'sc_override' , $scList ) -> save ( false );
2013-02-09 19:05:51 +02:00
// core batch overrides
2013-02-08 16:49:57 +02:00
$fList = $f -> get_files ( e_CORE . 'override/shortcodes/batch' , '\.php$' );
2013-02-09 19:05:51 +02:00
$scList = array ();
2013-02-08 16:49:57 +02:00
if ( count ( $fList ))
{
foreach ( $fList as $file )
{
2013-02-09 19:05:51 +02:00
$scList [] = substr ( $file [ 'fname' ], 0 , - 4 );
2013-02-08 16:49:57 +02:00
}
2013-02-09 19:05:51 +02:00
$scList = implode ( ',' , $scList );
2013-02-08 16:49:57 +02:00
}
2013-02-09 19:05:51 +02:00
2013-02-08 16:49:57 +02:00
$config -> set ( 'sc_batch_override' , $scList ) -> save ( false );
//$pref['sc_override'] = $scList;
//save_prefs();
2012-11-30 03:08:15 -08:00
// $mes->add(DBLAN_57.':<br />'.$pref['sc_override'], E_MESSAGE_SUCCESS);
2013-02-08 16:49:57 +02:00
e107 :: getRender () -> tablerender (
2013-02-09 19:05:51 +02:00
'<strong>' . DBLAN_56 , DBLAN_57 . ':</strong> '
2015-05-02 09:55:47 +02:00
. ( $config -> get ( 'sc_override' ) ? '<br />' . $config -> get ( 'sc_override' ) : DBLAN_106 )
. '<br /><br /><strong>' . DBLAN_105 . '</strong>'
. ( $config -> get ( 'sc_batch_override' ) ? '<br />' . $config -> get ( 'sc_batch_override' ) : DBLAN_106 )
2013-02-08 16:49:57 +02:00
);
2009-08-29 15:30:41 +00:00
}
2009-08-22 00:28:55 +00:00
2017-12-16 11:31:47 -08:00
2009-08-29 15:30:41 +00:00
/**
* Plugin Folder Scanner
2019-05-29 11:18:34 -07:00
* @ return null
2010-02-10 21:53:56 +00:00
*/
2012-12-23 15:00:15 +00:00
private function plugin_viewscan ( $mode = 'update' )
2009-08-29 15:30:41 +00:00
{
2015-06-25 16:05:23 +02:00
$error_messages = array ( 0 => DBLAN_31 , 1 => LAN_ERROR , 2 => DBLAN_33 , 3 => DBLAN_34 );
2013-05-04 15:42:55 -07:00
// $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png");
2022-12-10 07:06:47 -08:00
$error_glyph = array ( ADMIN_TRUE_ICON , ADMIN_FALSE_ICON , ADMIN_WARNING_ICON , " <i style='display:inline-block;width:17px;height:16px;'> </i> " );
2013-05-04 15:42:55 -07:00
$error_type = array ( 'warning' => 2 , 'error' => 1 );
2010-02-10 21:53:56 +00:00
2009-10-26 01:04:06 +00:00
global $e107 ;
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
$frm = e107 :: getForm ();
2012-11-30 03:08:15 -08:00
$mes = e107 :: getMessage ();
2010-02-10 21:53:56 +00:00
2017-12-16 11:31:47 -08:00
// require_once (e_HANDLER."plugin_class.php");
// $ep = new e107plugin();
// $ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table.
// $ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table.
2010-02-10 21:53:56 +00:00
2012-11-30 03:08:15 -08:00
$mes -> add ( DBLAN_23 , E_MESSAGE_SUCCESS );
$mes -> add ( " <a href=' " . e_SELF . " '> " . LAN_BACK . " </a> " , E_MESSAGE_SUCCESS );
$mes -> add ( DBLAN_30 );
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text = "
< form method = 'post' action = '".e_ADMIN."db.php?mode=".$_GET[' mode ']."' id = 'plug_edit' >
< fieldset id = 'core-db-plugin-scan' >
< legend class = 'e-hideme' > " .ADLAN_CL_7. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 20%' />
< col style = 'width: 20%' />
< col style = 'width: 35%' />
< col style = 'width: 25%' />
2009-08-29 15:30:41 +00:00
</ colgroup >
< thead >
< tr >
2013-03-21 13:39:11 +01:00
< th > " .LAN_NAME. " </ th >
2009-08-29 15:30:41 +00:00
< th > " .DBLAN_25. " </ th >
< th > " .DBLAN_26. " </ th >
< th class = 'center last' > " .DBLAN_27. " </ th >
</ tr >
</ thead >
< tbody >
" ;
2010-02-10 21:53:56 +00:00
2017-12-16 11:31:47 -08:00
$plg = e107 :: getPlug () -> clearCache ();
$plg -> buildAddonPrefLists ();
2020-03-03 13:11:48 -08:00
$plgClass = e107 :: getPlugin ();
2017-12-16 11:31:47 -08:00
foreach ( $plg -> getDetected () as $folder )
{
$plg -> load ( $folder );
2020-03-03 13:11:48 -08:00
$plgClass -> plugFolder = $folder ;
$plgClass -> XmlLanguageFiles ( 'refresh' );
2017-12-16 11:31:47 -08:00
$name = $plg -> getName ();
$addons = $plg -> getAddons ();
$text .= "
< tr >
< td > " . $name . " </ td >
< td > " . $folder . " </ td >
< td > " ;
if ( ! empty ( $addons ))
{
foreach ( explode ( ',' , $addons ) as $this_addon )
{
$ret_code = 3 ; // Default to 'not checked
if (( strpos ( $this_addon , 'e_' ) === 0 ) || ( substr ( $this_addon , - 4 , 4 ) == '_sql' ))
{
$ret_code = $plg -> getAddonErrors ( $this_addon ); // See whether spaces before opening tag or after closing tag
}
elseif ( strpos ( $this_addon , 'sc_' ) === 0 )
{
$this_addon = substr ( $this_addon , 3 ) . ' (sc)' ;
}
if ( ! is_numeric ( $ret_code ))
{
$errorMessage = $ret_code [ 'msg' ];
$ret_code = $error_type [ $ret_code [ 'type' ]];
}
else
{
$errorMessage = $error_messages [ $ret_code ];
}
$text .= " <span class='clear e-tip' style='cursor:pointer' title=' " . $errorMessage . " '> " ;
$text .= $error_glyph [ $ret_code ] . " " ;
$text .= trim ( $this_addon ); // $ret_code - 0=OK, 1=content error, 2=access error
$text .= " </span><br /> " ;
}
}
$text .= " </td>
< td class = 'center' > " ;
$text .= ( $plg -> isInstalled () === true ) ? " <span class='label label-warning'> " . DBLAN_27 . " </span> " : " " ;
$text .= " </td>
</ tr >
" ;
}
2010-02-10 21:53:56 +00:00
2009-08-29 15:30:41 +00:00
$text .= "
</ tbody >
</ table >
</ fieldset >
</ form >
" ;
2010-02-10 21:53:56 +00:00
2013-02-22 21:34:06 -08:00
e107 :: getRender () -> tablerender ( DBLAN_10 . SEP . DBLAN_22 , $mes -> render () . $text );
2019-05-29 11:18:34 -07:00
return null ;
2009-08-29 15:30:41 +00:00
}
2017-12-16 11:31:47 -08:00
2009-08-29 15:30:41 +00:00
}
//XXX - what is this for (backup core)? <input type='hidden' name='sqltext' value='{$sqltext}' />
2012-11-26 18:42:11 -08:00
function db_adminmenu () //FIXME - has problems when navigation is on the LEFT instead of the right.
2009-08-29 15:30:41 +00:00
{
global $st ;
2010-02-10 21:53:56 +00:00
2019-05-29 11:18:34 -07:00
$var = array ();
2012-11-26 18:42:11 -08:00
2009-08-29 15:30:41 +00:00
foreach ( $st -> _options as $key => $val )
{
$var [ $key ][ 'text' ] = $val [ 'label' ];
$var [ $key ][ 'link' ] = e_SELF . " ?mode= " . $key ;
2021-02-01 18:18:30 -08:00
$var [ $key ][ 'image_src' ] = $val [ 'icon' ];
2009-08-29 15:30:41 +00:00
}
2010-02-10 21:53:56 +00:00
2021-02-01 18:18:30 -08:00
$caption = " <span> " . DBLAN_10 . " </span> " ;
$var [ '_extras_' ][ 'icon' ] = e107 :: getParser () -> toIcon ( 'e-database-24' );
2017-02-01 18:25:32 -08:00
e107 :: getNav () -> admin ( $caption , $_GET [ 'mode' ], $var );
2009-08-27 21:01:44 +00:00
}
2009-08-22 00:28:55 +00:00
2009-08-27 21:01:44 +00:00
2009-09-06 01:02:01 +00:00
/**
* Export XML File and Copy Images .
* @ param object $prefs
* @ param object $tables
* @ param object $debug [ optional ]
2019-05-29 11:18:34 -07:00
* @ return bool | null
2009-09-06 01:02:01 +00:00
*/
2019-07-09 12:08:52 -07:00
function exportXmlFile ( $prefs , $tables = array (), $plugPrefs = array (), $themePrefs = array (), $package = FALSE , $debug = FALSE )
2009-08-27 21:01:44 +00:00
{
2016-02-25 18:43:49 -08:00
$xml = e107 :: getXml ();
2009-09-05 23:02:23 +00:00
$tp = e107 :: getParser ();
2013-03-24 13:07:15 +01:00
$mes = e107 :: getMessage ();
2010-02-10 21:53:56 +00:00
2016-12-24 12:41:06 -08:00
$desinationFolder = null ;
2009-09-06 01:02:01 +00:00
if ( vartrue ( $package ))
2009-09-02 17:27:29 +00:00
{
2010-02-10 21:53:56 +00:00
2009-09-05 23:02:23 +00:00
$xml -> convertFilePaths = TRUE ;
2016-05-30 15:19:19 -07:00
$xml -> modifiedPrefsOnly = true ;
2009-09-05 23:02:23 +00:00
$xml -> filePathDestination = EXPORT_PATH ;
2009-09-10 09:49:01 +00:00
$xml -> filePathPrepend = array (
'news_thumbnail' => " { e_IMAGE}newspost_images/ "
);
2010-02-10 21:53:56 +00:00
2009-09-05 23:02:23 +00:00
$desinationFolder = $tp -> replaceConstants ( $xml -> filePathDestination );
2010-02-10 21:53:56 +00:00
2009-09-05 23:02:23 +00:00
if ( ! is_writable ( $desinationFolder ))
2010-02-10 21:53:56 +00:00
{
2015-05-02 09:55:47 +02:00
$message = str_replace ( '[folder]' , $desinationFolder , DBLAN_107 );
$mes -> add ( $message , E_MESSAGE_ERROR );
2016-12-24 09:34:00 -08:00
return false ;
2009-09-05 23:02:23 +00:00
}
2009-09-02 17:27:29 +00:00
}
2010-02-10 21:53:56 +00:00
2017-01-27 18:02:57 -08:00
$mode = ( $debug === true ) ? array ( " debug " => 1 ) : null ;
2009-09-06 01:02:01 +00:00
2019-07-09 12:08:52 -07:00
if ( $xml -> e107Export ( $prefs , $tables , $plugPrefs , $themePrefs , $mode ))
2009-09-05 23:02:23 +00:00
{
2015-05-02 09:55:47 +02:00
$mes -> add ( DBLAN_108 . " " . $desinationFolder . " install.xml " , E_MESSAGE_SUCCESS );
2009-09-05 23:02:23 +00:00
if ( varset ( $xml -> fileConvertLog ))
{
foreach ( $xml -> fileConvertLog as $oldfile )
{
$file = basename ( $oldfile );
$newfile = $desinationFolder . $file ;
2009-09-06 01:02:01 +00:00
if ( $oldfile == $newfile || ( copy ( $oldfile , $newfile )))
2009-09-05 23:02:23 +00:00
{
2015-05-02 09:55:47 +02:00
$mes -> add ( DBLAN_109 . " " . $newfile , E_MESSAGE_SUCCESS );
2009-09-05 23:02:23 +00:00
}
2016-05-30 15:19:19 -07:00
elseif ( ! file_exists ( $newfile ))
2009-09-05 23:02:23 +00:00
{
2015-05-02 09:55:47 +02:00
$mes -> add ( DBLAN_110 . " " . $newfile , E_MESSAGE_ERROR );
2010-02-10 21:53:56 +00:00
}
2009-09-05 23:02:23 +00:00
}
}
2016-12-24 09:34:00 -08:00
2009-09-05 23:02:23 +00:00
}
2016-12-24 09:34:00 -08:00
return null ;
2009-08-22 00:28:55 +00:00
}
2009-08-29 15:30:41 +00:00
2009-08-27 22:19:51 +00:00
2009-08-27 21:01:44 +00:00
function table_list ()
{
// grab default language lists.
2010-02-10 21:53:56 +00:00
//TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php.
2009-08-27 21:01:44 +00:00
$exclude = array ();
2009-08-29 15:30:41 +00:00
$exclude [] = " core " ;
2009-08-27 21:01:44 +00:00
$exclude [] = " rbinary " ;
$exclude [] = " parser " ;
$exclude [] = " tmp " ;
$exclude [] = " online " ;
$exclude [] = " upload " ;
$exclude [] = " user_extended_country " ;
2019-05-29 11:18:34 -07:00
// $exclude[] = "plugin";
2010-02-10 21:53:56 +00:00
2016-12-24 09:34:00 -08:00
$coreTables = e107 :: getDb () -> tables ( 'nolan' );
2009-08-29 18:07:42 +00:00
2009-09-05 23:02:23 +00:00
$tables = array_diff ( $coreTables , $exclude );
2010-02-10 21:53:56 +00:00
2016-12-24 09:34:00 -08:00
$tabs = array ();
2009-09-05 23:02:23 +00:00
foreach ( $tables as $e107tab )
2010-02-10 21:53:56 +00:00
{
2021-05-08 11:53:39 -07:00
$count = ( int ) e107 :: getDb () -> count ( $e107tab );
2010-02-10 21:53:56 +00:00
2021-05-08 11:53:39 -07:00
if ( ! empty ( $count ))
2009-08-27 21:01:44 +00:00
{
2010-02-10 21:53:56 +00:00
$tabs [ $e107tab ] = $count ;
}
2009-08-27 21:01:44 +00:00
}
2009-08-22 00:28:55 +00:00
2009-08-27 21:01:44 +00:00
return $tabs ;
}
2009-09-05 23:02:23 +00:00
2009-08-29 15:30:41 +00:00
2020-04-27 15:19:58 +02:00
?>