| 
<?PHP
/**
 * @package as_admintool
 * @desc sample.php - using as_admintool.php demonstration
 * @author Alexander Selifonov <[email protected]>
 * @copyright Alexander Selifonov 2007
 * @link http://as-works.narod.ru/en/php/
 * @version 1.000.000
 * modified 03.03.2007 (dd.mm.yyyy)
 * Read "as_admintool.htm" for detailed instructions
 */
 require_once('as_admintool.php'); // main module
 require_once('as_admintool_sqlqry.php'); //  executing SQL queries plugin
 require_once('as_admintool_backup.php'); //  backup SQL data plugin
 require_once('as_admintool_restore.php'); // restore SQL data from backup-files
 require_once('as_admintool_filemgr.php'); // file manager plugin
 require_once('as_admintool_sqlimport.php'); // txt 2 sql import
 
 # change or localize interface...
 $as_iface['parameters'] ='Query parameters';
 $as_iface['predef-qry'] ='Shoose a query...';
 $as_iface['explainqry'] ='Show execution plan';
 
 // Place Your function to connect to MySQL, or just set Your host/db/user/pass:
 @$as_dbengine->Connect('localhost','user','password','databasename');
 
 $access_lev = 2;
 // here may be a function to check if user logged on and has enough privileges
 // set $access_lev to 0 or 1 to see 'SQL lowest access' mode
 
 $as_adm_qryaccess = $access_lev;
 
 # as_admintool_filemgr: protect some files from deleting/overwriting:
 $asdt_fmgr_protect = array('sample.php','as_admintool.php','as_admintool.htm');
 
 # place this line BEFORE any HTML output !
 CAsAdminTool::PerformAction();
 
 # echo Your HTML header here...
 HTML_Header('as_admintool: using example');
 
 if($access_lev>=1 ) {
 $adminobj = new CAsAdminTool(620,440);
 #  If as_jsfunclib.js placed into some 'scripts' folder, uncomment next line.
 #  $adminobj->SetJsPath('scripts/');
 
 $qlist = array(array('Our company','-'),
 array('Departments search',"SELECT * from departments where department_name like '&P1%'",'Department name'),
 array('Employees search',"SELECT * from employees where emp_name like '&P1%' AND first_name LIKE '&P2%'",'Person name','First name'),
 array('Optimize tables...','-'),
 array('employees and depts','OPTIMIZE tables employess,departments')
 );
 
 $adminobj->AddPage(ASADM_SQLQUERY,'SQL Queries', $qlist);
 
 if($access_lev>=2) { // security check is a good idea !
 
 $tlist = ''; // all tables in current db will be shown
 //You could pass YOUR table names only: array('branches','employees','departments');
 
 $db_name = ''; // Set another DB name, if differs from current selected DB
 
 $adminobj->AddPage(ASADM_BACKUP,'Backup', $tlist, 'backup/',$db_name);
 $adminobj->AddPage(ASADM_RESTORE,'Restore','backup/',$db_name);
 # If You want to see 'restore' functionality, create a subfolder 'backup', and make at least one backup.
 # When there are .xml or .gz files in "backup/" folder, just refresh sample page.
 
 # folder list, available for file manager
 $folders = array(array('./','current folder'),
 array('scripts/','Scripts folder'),
 array('backup/','backup folder'),
 '../images/');
 
 
 $adminobj->AddPage(ASADM_FILEMGR,'File Mgr', $folders);
 
 # add import data page
 $totables = array('depts','employees','salaries');
 $adminobj->AddPage(ASADM_SQLIMPORT,'Import data','txtfiles/',$totables);
 
 }
 $adminobj->Draw();
 }
 else echo "Access denied !";
 echo "</BODY></HTML>";
 exit;
 function HTML_Header($title){ // draw Your HTML header here...
 ?>
 <HTML><HEAD><TITLE><?=$title?></TITLE>
 <META http-equiv="Content-Type" Content="text/html;">
 <link rel='stylesheet' href='styles.css' type='text/css'>
 </HEAD>
 <BODY>
 <H1 align='center'><?=$title?></H1>
 <?
 }
 ?>
 |