Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * zg SQL TestBench
- *
- * Free and open source software
- * http://en.wikipedia.org/wiki/Free_and_open_source_software
- *
- * NOTE!
- * DO NOT PUT THIS SCRIPT TO AN PUBLIC SERVER! YOUR DB WILL BE SERIOUSLY COMPROMISED, IF YOU DO SO!
- * Use it in closed demo or development environment, where everyone can have anyway full access to DB.
- *
- * Do with it what you want. Absolutely no any(kind) warranties! Program is provided "as is"
- * without warranty of any kind, either expressed or implied. The entire risk as to the
- * quality and performance of the program is with you. In no event author will be liable to you
- * for damages, including any general, special, incidental or consequential damages arising out
- * of the use or inability to use the program (including but not limited to loss of data or data
- * being rendered inaccurate or losses sustained by you or third parties or a failure of the
- * program to operate with any other programs), even if the author has been advised of the
- * possibility of such damages.
- *
- * By using this software you agree this licence.
- *
- * First Author: ZeroGravity ([email protected])
- * Release Date: 16.2.2012
- * ============================================================
- * DB Schema (created by program)
- *
- * product tag category product_tag
- * ----------- ---------- ----------- -----------
- * id id id product_id
- * name name name tag_id
- * description category_id
- *
- * Each product has random 0-N tags (each has same amount).
- * These tags can be same, might not be unique - set could be (3,22,25,25,57,58,79,79,79,99)
- * Each tag has one and one category.
- * Each tag can contain 0-N products.
- */
- $mtime = explode(' ', microtime());
- $mtime = $mtime[1] + $mtime[0];
- $page_starttime = $mtime;
- /**
- * Configuration - do your own configuration
- */
- $DB_ROOT_USER = '<<ROOT>>'; // your root username -- needed for schema creation
- $DB_ROOT_PASS = '<<PASSWORD>>'; // your root password
- $USE_ENGINE = 'InnoDB'; // MyISAM, InnoDB, Blackhole, Memory ... you name it
- // all 4 tables use same engine
- $PRODUCT_HAS_TAGS = 10; // how many tags each product has
- $SHOW_MAX_ROWS = 5; // how many rows are shown in SQL Result Viewer
- $INDEX_TYPE = 'BTREE'; // BTREE or HASH (Memory and Heap engines)
- $PREDEFINED_SQLS = array (
- array('SELECT product_id FROM product_tag WHERE tag_id IN (22,25,30) GROUP BY product_id HAVING count(product_id)=3',0),
- array('EXPLAIN SELECT product_id FROM product_tag WHERE tag_id IN (22,25,30) GROUP BY product_id HAVING count(product_id)=3',0),
- array('SELECT p.name,pt.product_id FROM product p, product_tag pt WHERE pt.tag_id IN (22,25,30) AND pt.product_id = p.id GROUP BY pt.product_id HAVING count(pt.product_id)=3',0)
- );
- // Test DB -- these are created on the fly ... does not need to exists
- $TEST_DB_NAME = 'dim_test';
- $TEST_DB_USER = 'dim_test_user';
- $TEST_DB_PASSWD = 'dim_test_pass';
- define('IGNORE_ERROR',1);
- define('VERSION',1);
- define('PRODUCT_NAME','zg SQL TestBench');
- // Execute sql in db - return query or null - show error realtime
- function sqlExec($sql,$ignore=0) {
- global $DB_CONN;
- if($DB_CONN==null) {
- error('No connection to DB (schema missing, bad username/password?).');
- return null;
- }
- try {
- $query = $DB_CONN->prepare($sql);
- $query->execute();
- return $query;
- } catch(PDOException $e) {
- if(!$ignore) error($e);
- }
- return null;
- }
- // dont ask... bad planning
- function rootSqlExec($sql) {
- global $ROOT_DB_CONN;
- if($ROOT_DB_CONN==null) {
- error('No connection to DB (bad username/password?).');
- return null;
- }
- try {
- $query = $ROOT_DB_CONN->prepare($sql);
- $query->execute();
- return $query;
- } catch(PDOException $e) {
- error($e);
- }
- return null;
- }
- // Do execute, and if succesfull prints out what was done
- function sqlExecPrintOut($sql,$ignore=0) {
- if(sqlExec($sql,$ignore)!=null) {
- info('SQL ['.$sql.'] executed succesfully');
- }
- }
- function getCount($table) {
- global $DB_CONN;
- if($DB_CONN==null) {
- error('No connection to DB (schema missing, bad username/password?).');
- return null;
- }
- try {
- $query = $DB_CONN->prepare('SELECT COUNT(*) FROM '.$table);
- $query->execute();
- if($row = $query->fetch(PDO::FETCH_NUM)) {
- return $row[0];
- }
- } catch(PDOException $e) {
- // Table might not exists ... we just skip this
- }
- return -1;
- }
- function getMaxID($table) {
- global $DB_CONN;
- if($DB_CONN==null) {
- error('No connection to DB (schema missing, bad username/password?).');
- return null;
- }
- try {
- $query = $DB_CONN->prepare('SELECT MAX(id) FROM '.$table);
- $query->execute();
- if($row = $query->fetch(PDO::FETCH_NUM)) {
- return $row[0];
- }
- } catch(PDOException $e) {
- // Table might not exists ... we just skip this
- }
- return -1;
- }
- function getRandomString($len,$words=0) {
- $code = md5(rand());
- if($words==1) {
- $code = preg_replace(array('/0/','/1/','/2/','/3/','/4/','/5/','/6/','/7/','/8/','/9/'),
- array(' ','h','i','j','k',' ','m','n','o','p'),
- $code);
- } else {
- $code = preg_replace(array('/0/','/1/','/2/','/3/','/4/','/5/','/6/','/7/','/8/','/9/'),
- array('g','h','i','j','k','l','m','n','o','p'),
- $code);
- }
- if(strlen($code)<$len) $code .= getRandomString($len-strlen($code));
- return substr($code, 0, $len);
- }
- function title($title,$fontcolor,$bgcolor,$nobr=0,$showhide=null) {
- if($nobr!=1) echo '<br>';
- echo '<div style="background: '.$bgcolor.'; font: 12px verdana; font-weight:900; font-variant: small-caps; padding: 3px; color: '.$fontcolor.'">'.$title;
- if($showhide!=null) {
- echo '<a href="javascript:toggleme('.$showhide.');" id="showhide'.$showhide.'" class="xbutton">-</a>';
- }
- echo '</div>';
- }
- function box($color,$font_size='.75em',$id=null) {
- echo '<div '.
- ($id!=null?' id="'.$id.'" ':'')
- .'style="border: 2px '.$color.' solid; font: '.$font_size.' verdana; padding: 2px;">';
- }
- function error($error) {
- title('ERROR','white','red',1);
- box('red');
- echo $error.'</div>';
- }
- function info($info) {
- box('#333333','.65em');
- echo $info.'</div>';
- }
- function getIndexer() {
- $s = '<form action="?do_index=1" method="post" style="padding:0;margin:0;"><div style="background: blue; font: 10px verdana; font-weight:900; font-variant: small-caps; padding: 3px; color: white">Indexer</div>
- <div style="border: 2px blue solid; font: .8 verdana; padding: 2px;">
- <div class="db_odd"><input type="checkbox" name="idx[]" value="product-id" '.(indexExists('product','id')?'checked':'').'/><input type="checkbox" name="idx[]" value="product-name" '.(indexExists('product','name')?'checked':'').' /><input type="checkbox" name="idx[]" value="product-description" '.(indexExists('product','description')?'checked':'').'/></div>
- <div class="db_even"><input type="checkbox" name="idx[]" value="tag-id" '.(indexExists('tag','id')?'checked':'').'/><input type="checkbox" name="idx[]" value="tag-name" '.(indexExists('tag','name')?'checked':'').' /><input type="checkbox" name="idx[]" value="tag-category_id" '.(indexExists('tag','category_id')?'checked':'').'/></div>
- <div class="db_odd"><input type="checkbox" name="idx[]" value="product_tag-product_id" '.(indexExists('product_tag','product_id')?'checked':'').' /><input type="checkbox" name="idx[]" value="product_tag-tag_id" '.(indexExists('product_tag','tag_id')?'checked':'').' /></div>
- <div class="db_even"><input type="checkbox" name="idx[]" value="category-id" '.(indexExists('category','id')?'checked':'').'/><input type="checkbox" name="idx[]" value="category-name" '.(indexExists('category','name')?'checked':'').'/></div>
- <div><input type="submit" value="Create" class="button1" /></div>
- </div></form>';
- return $s;
- }
- function indexExists($table,$column) {
- global $DB_NAME;
- $result = rootSqlExec('SHOW INDEX FROM '.$table.' WHERE column_name=\''.$column.'\'');
- // info($result);
- if($result!=null && $result->rowCount()>0) return true;
- return false;
- }
- function getTableFields($table) {
- global $DB_CONN;
- if($DB_CONN==null) {
- error('No connection to DB (schema missing, bad username/password?).');
- return null;
- }
- try {
- $query = $DB_CONN->prepare("DESCRIBE ".$table);
- $query->execute();
- $table_fields = $query->fetchAll(PDO::FETCH_COLUMN);
- } catch(PDOException $e) {
- error($e);
- }
- $str = '';
- $s = '';
- foreach($table_fields as $t) {
- $str .= $s.$t;
- $s = ', ';
- }
- return $str;
- }
- /*****************
- * END OF HELPER FUNCTIONS
- *
- * Beef starts here...
- */
- $show_db = 1;
- $create_db = 0;
- $show_query = '';
- @session_start();
- if(!isset($_SESSION['saved_sqls'])) $_SESSION['saved_sqls'] = $PREDEFINED_SQLS;
- // one script ugly css definition
- echo '<!DOCTYPE html>
- <html><head>
- <style type="text/css">
- ul.menu {
- list-style-type:none;
- margin:0;
- padding:0;
- overflow:hidden;
- }
- li.menu {
- float:left;
- padding: 0 2px 0 0;
- }
- a.menu {
- border: 1px black solid;
- display:block;
- width: 160px;
- color: white;
- background-color:#333333;
- padding: 2px;
- font: 11px verdana;
- text-align: center;
- font-weight: 900;
- font-variant: small-caps;
- text-decoration: none;
- }
- a.save {
- border: 1px white solid;
- font: 11px verdana;
- background-color: red;
- color: white;
- text-decoration: none;
- }
- .smaller {
- font: 11px verdana;
- }
- a.xbutton {
- border: 1px black solid;
- float:right;
- width: 10px;
- color: black;
- background: white;
- font: 10px verdana;
- text-align:center;
- text-decoration: none;
- }
- tr.odd {
- background: #888888;
- color: white;
- font: .9em verdana;
- }
- tr.even {
- background: #444444;
- color: white;
- font: .9em verdana;
- }
- tr.db_odd, div.db_odd {
- background: #008888;
- color: white;
- font: 1em verdana;
- }
- tr.db_even, div.db_even {
- background: #004444;
- color: white;
- font: 1em verdana;
- }
- div.db_even, div.db_odd {
- padding: 1px 0 1px 0;
- }
- td.indexify {
- font: 12px verdana;
- font-weight:900;
- font-variant: small-caps;
- padding: 2px;
- }
- tr.dbresponse {
- background: black;
- color: white;
- font: .9em verdana;
- }
- h1 {
- padding:0;
- margin:0;
- background: gray;
- text-align: center;
- border: 2px gray solid;
- font: 1.5em Arial Black;
- color: white;
- font-weight: 900;
- }
- body {
- margin-top:2px;
- }
- div.showquery {
- font: 1em courier new;
- }
- ul.smallinfo {
- background: gray;
- list-style-type:none;
- margin:0;
- padding:0;
- overflow:hidden;
- }
- li.smallinfo {
- background: gray;
- float: right;
- padding: 0 5px 0 5px;
- font: .7em verdana;
- color: white;
- border-style:solid;
- border: 0;
- border-left: 1px solid white;
- }
- .button1 {
- width: 100%;
- border: 1px dotted #000;
- background: #222;
- color: white;
- font: .85em verdana;
- font-weight: 700;
- }
- </style></head><body>';
- echo '<h1>[ '.PRODUCT_NAME.' ]</h1>
- <ul class="smallinfo">
- <li class="smallinfo">Version: '.VERSION.'</li>
- <li class="smallinfo">Author: ZeroGravity</li>
- <li class="smallinfo">Product has tags: '.$PRODUCT_HAS_TAGS.'</li>
- <li class="smallinfo">Schema used: '.strtoupper($TEST_DB_NAME).'</li>
- </ul>';
- if($DB_ROOT_USER=='<<ROOT>>' || $DB_ROOT_PASS=='<<PASSWORD>>') {
- error('You have not configured ['.PRODUCT_NAME.']. <b>Do that on rows 44-53 (approx)</b>. Exiting!');
- exit();
- }
- /**
- * Show menu
- */
- // title('Menu','white','gray',1);
- box('gray');
- echo '<ul class="menu"><li class="menu"><a class="menu" href="?drop_create=1" title="Drop schema and user - and create it again">Recreate schema</a></li>
- <li class="menu"><a class="menu" href="?clear=1" title="Actually drops all tables, and creates them again">Clear tables</a></li>
- <li class="menu"><a class="menu" href="?more=1" title="Adds 1000 products to the product table and '.($PRODUCT_HAS_TAGS*1000).' connections to products_tag table">Add 1000 products</a></li>
- <li class="menu"><a class="menu" href="?drop=1" title="Removes test schema and user">Drop schema and user</a></li></ul></div>';
- /**
- * Drop Schema
- */
- if(isset($_GET['drop'])) {
- try {
- $DB_CONN = new PDO("mysql:host=localhost", $DB_ROOT_USER, $DB_ROOT_PASS);
- $DB_CONN->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- error($e);
- }
- sqlExecPrintOut('DROP DATABASE IF EXISTS '.$TEST_DB_NAME);
- sqlExecPrintOut('DROP USER \''.$TEST_DB_USER.'\'@\'localhost\'');
- // cannot show db anymore
- $show_db = 0;
- }
- /**
- * Drop and create schema and user
- */
- if(isset($_GET['drop_create'])) {
- try {
- $DB_CONN = new PDO("mysql:host=localhost", $DB_ROOT_USER, $DB_ROOT_PASS);
- $DB_CONN->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- error($e);
- }
- sqlExecPrintOut('DROP DATABASE IF EXISTS '.$TEST_DB_NAME);
- sqlExecPrintOut('CREATE DATABASE '.$TEST_DB_NAME);
- sqlExecPrintOut('DROP USER \''.$TEST_DB_USER.'\'@\'localhost\'',IGNORE_ERROR);
- sqlExecPrintOut('CREATE USER \''.$TEST_DB_USER.'\'@\'localhost\' IDENTIFIED BY \''.$TEST_DB_PASSWD.'\'');
- sqlExecPrintOut('GRANT USAGE ON *.* TO \''.$TEST_DB_USER.'\'@\'localhost\' IDENTIFIED BY \''.$TEST_DB_PASSWD.'\' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0');
- sqlExecPrintOut('GRANT ALL PRIVILEGES ON '.$TEST_DB_NAME.'.* TO \''.$TEST_DB_USER.'\'@\'localhost\'');
- $create_db = 1;
- }
- /**
- * Create connection to our test schema
- */
- try {
- // sadly due later "add-ons" we need also root access to schema ... bad planning, bad code
- $ROOT_DB_CONN = new PDO('mysql:host=localhost;dbname='.$TEST_DB_NAME, $DB_ROOT_USER, $DB_ROOT_PASS);
- $DB_CONN = new PDO('mysql:host=localhost;dbname='.$TEST_DB_NAME, $TEST_DB_USER, $TEST_DB_PASSWD);
- $ROOT_DB_CONN->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $DB_CONN->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- // ignore and do not show db
- $show_db = 0;
- }
- /**
- * Clear schema ... recreate tables
- * Fill dimensions
- */
- if((isset($_GET['clear']) && $show_db==1) || $create_db==1) {
- sqlExecPrintOut('DROP TABLE IF EXISTS product');
- sqlExecPrintOut('CREATE TABLE product (
- id INT,
- name VARCHAR(20),
- description VARCHAR(500)
- ) ENGINE = '.$USE_ENGINE.';');
- sqlExecPrintOut('DROP TABLE IF EXISTS tag');
- sqlExecPrintOut('CREATE TABLE tag (
- id INT,
- name VARCHAR(20),
- category_id INT
- ) ENGINE = '.$USE_ENGINE.';');
- sqlExecPrintOut('DROP TABLE IF EXISTS category');
- sqlExecPrintOut('CREATE TABLE category (
- id INT,
- name VARCHAR(20)
- ) ENGINE = '.$USE_ENGINE.';');
- sqlExecPrintOut('DROP TABLE IF EXISTS product_tag');
- sqlExecPrintOut('CREATE TABLE product_tag (
- product_id INT,
- tag_id INT
- ) ENGINE = '.$USE_ENGINE.';');
- sqlExecPrintOut('CREATE INDEX product_tag_tag_id_idx ON product_tag(tag_id) USING '.$INDEX_TYPE);
- sqlExecPrintOut('CREATE INDEX product_tag_product_id_idx ON product_tag(product_id) USING '.$INDEX_TYPE);
- // add test dimensions
- $sql = array();
- for($i=1;$i<21;$i++) {
- $sql[] = '('.$i.',\''.getRandomString(20).'\')';
- }
- sqlExec('INSERT INTO category (id,name) VALUES '.implode(',', $sql),0);
- info('20 categories inserted');
- $sql = array();
- for($i=1;$i<101;$i++) {
- $sql[] = '('.$i.',\''.getRandomString(20).'\','.(($i % 5)+1).')';
- }
- sqlExec('INSERT INTO tag (id,name,category_id) VALUES '.implode(',', $sql),0);
- info('100 tags inserted');
- $show_db = 1;
- }
- /**
- * Save SQL for later use or just to remember execution time
- * and redo, and removal functionality
- */
- if(isset($_GET['save_sql'])) {
- $sql = array ($_SESSION['prev_sql'],$_SESSION['prev_exec_time']);
- $_SESSION['saved_sqls'][] = $sql;
- $show_query = $_SESSION['prev_sql'];
- }
- if(isset($_GET['redo_sql'])) {
- $s = $_SESSION['saved_sqls'][$_GET['redo_sql']];
- $_POST['gogo'] = 1;
- $_POST['query'] = $s[0];
- }
- if(isset($_GET['remove_all_sql'])) {
- unset($_SESSION['saved_sqls']);
- $_SESSION['saved_sqls'] = $PREDEFINED_SQLS;
- }
- if(isset($_GET['remove_sql'])) {
- unset($_SESSION['saved_sqls'][$_GET['remove_sql']]);
- }
- /**
- * User has requested SQL query ... execute it ... no restrictions
- */
- if(isset($_POST['gogo']) && strlen($_POST['query'])>0) {
- title('Executed SQL Query','white','green',0,'5');
- box('green','.75em','toggle5');
- echo '<div class="showquery">'.$_POST['query'].'</div></div>';
- $mtime = explode(' ', microtime());
- $mtime = $mtime[1] + $mtime[0];
- $starttime = $mtime;
- $query = sqlExec($_POST['query'],0);
- $mtime = explode(' ', microtime());
- $mtime = $mtime[1] + $mtime[0];
- $totaltime = ($mtime - $starttime);
- title ('SQL took ' .$totaltime. ' seconds <a class="save" href="?save_sql=1">Save</a>','white','green',1);
- $max = $SHOW_MAX_ROWS;
- title('Response: first ['.$max.'] rows' ,'white','black',0,'4');
- box('black','.75em','toggle4');
- if($query!=null) {
- try {
- echo '<table><tr class="dbresponse">';
- foreach(range(0, $query->columnCount() - 1) as $column_index) {
- $meta = $query->getColumnMeta($column_index);
- echo '<td> '.$meta['name'].' </td>';
- }
- echo '</tr>';
- $class = 'odd';
- while($row = $query->fetch(PDO::FETCH_NUM)) {
- echo '<tr class="'.$class.'">';
- foreach($row as $c) {
- if(is_string($c) && !isset($_POST['no_cut'])) if(strlen($c)>30) $c = substr($c,0,30).'...';
- echo '<td>'.$c.'</td>';
- }
- if($class=='odd')
- $class='even';
- else
- $class='odd';
- if(--$max<1) break;
- echo '</tr>';
- }
- } catch(PDOException $e) {
- error($e);
- }
- }
- echo '</table></div>';
- if($query!=null) title('Total '.$query->rowCount().' rows returned.','white','black',1);
- $show_query = $_POST['query'];
- $_SESSION['prev_sql'] = $show_query;
- $_SESSION['prev_exec_time'] = $totaltime;
- }
- /**
- * Create more products and create connection between tag and product
- * (how many depends on $PRODUCT_HAS_TAGS)
- */
- if(isset($_GET['more'])) {
- $next_id = getMaxID('product')+1;
- $sql = array();
- for($i=$next_id;$i<$next_id+1000;$i++) {
- $sql[] = '('.$i.',\''.getRandomString(20).'\',\''.getRandomString(500,1).'\')';
- }
- sqlExec('INSERT INTO product (id,name,description) VALUES '.implode(',', $sql),0);
- info('1000 products inserted');
- $tag_max_id = getMaxID('tag');
- $sql = array();
- for($i=$next_id;$i<$next_id+1000;$i++) {
- for($j=0;$j<$PRODUCT_HAS_TAGS;$j++) {
- $sql[] = '('.$i.','.rand(1,$tag_max_id).')';
- }
- }
- sqlExec('INSERT INTO product_tag (product_id,tag_id) VALUES '.implode(',', $sql),0);
- info('Relation between product and tags inserted.');
- }
- /**
- * Manipulate indexes
- */
- if(isset($_REQUEST['do_index'])) {
- $tables = array('product','tag','product_tag','category');
- // we go thru all cols, as user might have remove the idx
- foreach($tables as $table) {
- $colstr = getTableFields($table);
- $cols = preg_split('/,/',$colstr);
- foreach($cols as $col) {
- $col = trim($col);
- $has_index = indexExists($table,$col);
- if(isset($_POST['idx'])) {
- $is_in_post = in_array($table.'-'.$col,$_POST['idx']);
- } else {
- $is_in_post = false;
- }
- // drop if exists and is not sent by user
- if($has_index && !$is_in_post) {
- sqlExecPrintOut('DROP INDEX '.$table.'_'.$col.'_idx ON '.$table);
- } else {
- // create if does not exist and is not sent by user
- if($is_in_post && !$has_index) {
- sqlExecPrintOut('CREATE INDEX '.$table.'_'.$col.'_idx ON '.$table.'('.$col.') USING BTREE');
- }
- }
- }
- }
- }
- /**
- * Show some basic info of schema (counts)
- */
- if($show_db==1) {
- title('DB Contents [table,count,fields]','white','blue',0,'3');
- box('blue','.75em','toggle3');
- echo '<table>
- <tr><td colspan="3" class="indexify"> </td><td rowspan="6" style="vertical-align: top;">'.getIndexer().'</td></tr>
- <tr class="db_odd"><td class="db_show">product:</td><td>'.getCount('product').'</td><td>['.getTableFields('product').']</td></tr>'.
- '<tr class="db_even"><td class="db_show">tag:</td><td>'.getCount('tag').'</td><td>['.getTableFields('tag').']</td></tr>'.
- '<tr class="db_odd"><td class="db_show">product_tag:</td><td>'.getCount('product_tag').'</td><td>['.getTableFields('product_tag').']</td></tr>'.
- '<tr class="db_even"><td class="db_show">category:</td><td>'.getCount('category').'</td><td>['.getTableFields('category').']</td></tr>
- <tr><td colspan="3"> </td></tr>'.
- '</table></div>';
- } else {
- title('DB Contents','white','blue',0,'3');
- box('blue','.75em','toggle3');
- echo 'NO SCHEMA</div>';
- }
- /**
- * Show box where user can insert SQL and execute it
- */
- title('Send SQL Query','white','green',0,'2');
- box('green','.75em','toggle2');
- echo '<form method="post" action="?"><textarea rows="10" cols="80" name="query">'.
- $show_query.
- '</textarea><br /><input type="submit" value="Send SQL Query" name="gogo" /> <input type="checkbox" name="no_cut" value="1" /> do not cut strings to 30 chars</form>
- </div>';
- /**
- * Show SQL redo log
- */
- title('Saved SQLs [<a href="?remove_all_sql=1" title="Remove all and bring back defaults">reset</a>]','white','#666666',0,'1');
- box('#666666','.75em','toggle1');
- if(isset($_SESSION['saved_sqls'])) {
- for($i=0;$i<sizeof($_SESSION['saved_sqls'])+1;$i++) {
- if(!isset($_SESSION['saved_sqls'][$i])) continue;
- $s = $_SESSION['saved_sqls'][$i];
- echo '<span class="smaller">['.round($s[1],8).'] <a href="?redo_sql='.$i.'">#redo#</a> <a href="?remove_sql='.$i.'">#remove#</a> '.$s[0].'</span><br />';
- }
- }
- echo '</div>';
- $mtime = explode(' ', microtime());
- $mtime = $mtime[1] + $mtime[0];
- $page_totaltime = ($mtime - $page_starttime);
- title('Page served in ' .$page_totaltime. ' seconds','white','black',0);
- // the end :P
- echo '
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- $("#showhide1").data(\'is_visible\',true);
- $("#showhide2").data(\'is_visible\',true);
- $("#showhide3").data(\'is_visible\',true);
- $("#showhide4").data(\'is_visible\',true);
- $("#showhide5").data(\'is_visible\',true);
- });
- function toggleme(targetId) {
- $("#toggle" + targetId).slideToggle();
- if($("#showhide" + targetId)) {
- $("#showhide" + targetId).data(\'is_visible\', !$("#showhide" + targetId).data(\'is_visible\'));
- $("#showhide" + targetId).html( (!$("#showhide" + targetId).data(\'is_visible\')) ? "+" : "-");
- } else {
- $("#showhide" + targetId).data(\'is_visible\',false);
- }
- }
- </script>
- </body></html>';
Advertisement
Add Comment
Please, Sign In to add comment