Don't like ads? PRO users don't see any ads ;-)

Untitled

By: F0u4d on May 30th, 2012  |  syntax: PHP  |  size: 4.52 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <?php
  3. /*
  4.  * Mysql Ajax Table Editor
  5.  *
  6.  * Copyright (c) 2008 Chris Kitchen <info@mysqlajaxtableeditor.com>
  7.  * All rights reserved.
  8.  *
  9.  * See COPYING file for license information.
  10.  *
  11.  * Download the latest version from
  12.  * http://www.mysqlajaxtableeditor.com
  13.  */
  14. require_once('Common.php');
  15. require_once('php/lang/LangVars-en.php');
  16. require_once('php/AjaxTableEditor.php');
  17. class Example1 extends Common
  18. {
  19.         var $Editor;
  20.        
  21.         function displayHtml()
  22.         {
  23.                 ?>
  24.                         <br />
  25.        
  26.                         <div align="left" style="position: relative;"><div id="ajaxLoader1"><img src="images/ajax_loader.gif" alt="Loading..." /></div></div>
  27.                        
  28.                         <br />
  29.                        
  30.                         <div id="historyButtonsLayer" align="left">
  31.                         </div>
  32.        
  33.                         <div id="historyContainer">
  34.                                 <div id="information">
  35.                                 </div>
  36.                
  37.                                 <div id="titleLayer" style="padding: 2px; font-weight: bold; font-size: 18px; text-align: center;">
  38.                                 </div>
  39.                
  40.                                 <div id="tableLayer" align="center">
  41.                                 </div>
  42.                                
  43.                                 <div id="recordLayer" align="center">
  44.                                 </div>         
  45.                                
  46.                                 <div id="searchButtonsLayer" align="center">
  47.                                 </div>
  48.                         </div>
  49.                         <script type="text/javascript">
  50.                                 trackHistory = false;
  51.                                 var ajaxUrl = '<?php echo $_SERVER['PHP_SELF']; ?>';
  52.                                 toAjaxTableEditor('update_html','');
  53.                         </script>
  54.                 <?php
  55.         }
  56.  
  57.         function initiateEditor()
  58.         {
  59.                 $tableColumns['ID'] = array('display_text' => 'ID', 'perms' => 'TVQSXO');
  60.                 $tableColumns['Header'] = array('display_text' => 'Header', 'perms' => 'EVCTAXQSHO');
  61.                 $tableColumns['Row'] = array('display_text' => 'Row', 'perms' => 'EVCTAXQSHO');
  62.                 $tableColumns['Date'] = array('display_text' => 'Date', 'perms' => 'EVCTAXQSHO');
  63.                 $tableColumns['Time'] = array('display_text' => 'Time', 'perms' => 'EVCTAXQSHO');
  64.                 $tableColumns['HomeTeam'] = array('display_text' => 'HomeTeam', 'perms' => 'EVCTAXQSHO');
  65.                 $tableColumns['Score'] = array('display_text' => 'Score', 'perms' => 'EVCTAXQSHO');
  66.                 $tableColumns['AwayTeam'] = array('display_text' => 'AwayTeam', 'perms' => 'EVCTAXQSHO');
  67.                 $tableColumns['Other'] = array('display_text' => 'Other', 'perms' => 'EVCTAXQSHO');
  68.                 $tableColumns['InfoID'] = array('display_text' => 'InfoID', 'perms' => 'EVCTAXQSHO');
  69.                 //$tableColumns['InfoData'] = array('display_text' => 'InfoDatas', 'perms' => 'EVCTAXQSHO');
  70.                
  71.                
  72.                 $tableName = 'latest';
  73.                 $primaryCol = 'ID';
  74.                 $errorFun = array(&$this,'logError');
  75.                 $permissions = 'EAVIDQCSXHO';
  76.                 // EAVIDQCSXHO
  77.                 // EAVDQCSM
  78.                
  79.                 $this->Editor = new AjaxTableEditor($tableName,$primaryCol,$errorFun,$permissions,$tableColumns);
  80.                 $this->Editor->setConfig('tableInfo','cellpadding="1" width="1200" class="mateTable"');
  81.                 $this->Editor->setConfig('orderByColumn','ID');
  82.                 $this->Editor->setConfig('addRowTitle','Add Game');
  83.                 $this->Editor->setConfig('editRowTitle','Edit Game');
  84.                 //$this->Editor->setConfig('iconTitle','Edit Employee');
  85.         }
  86.        
  87.        
  88.         function Example1()
  89.         {
  90.                 if(isset($_POST['json']))
  91.                 {
  92.                         session_start();
  93.                         // Initiating lang vars here is only necessary for the logError, and mysqlConnect functions in Common.php.
  94.                         // If you are not using Common.php or you are using your own functions you can remove the following line of code.
  95.                         $this->langVars = new LangVars();
  96.                         $this->mysqlConnect();
  97.                         if(ini_get('magic_quotes_gpc'))
  98.                         {
  99.                                 $_POST['json'] = stripslashes($_POST['json']);
  100.                         }
  101.                         if(function_exists('json_decode'))
  102.                         {
  103.                                 $data = json_decode($_POST['json']);
  104.                         }
  105.                         else
  106.                         {
  107.                                 require_once('php/JSON.php');
  108.                                 $js = new Services_JSON();
  109.                                 $data = $js->decode($_POST['json']);
  110.                         }
  111.                         if(empty($data->info) && strlen(trim($data->info)) == 0)
  112.                         {
  113.                                 $data->info = '';
  114.                         }
  115.                         $this->initiateEditor();
  116.                         $this->Editor->main($data->action,$data->info);
  117.                         if(function_exists('json_encode'))
  118.                         {
  119.                                 echo json_encode($this->Editor->retArr);
  120.                         }
  121.                         else
  122.                         {
  123.                                 echo $js->encode($this->Editor->retArr);
  124.                         }
  125.                 }
  126.                 else if(isset($_GET['export']))
  127.                 {
  128.             session_start();
  129.             ob_start();
  130.             $this->mysqlConnect();
  131.             $this->initiateEditor();
  132.             echo $this->Editor->exportInfo();
  133.             header("Cache-Control: no-cache, must-revalidate");
  134.             header("Pragma: no-cache");
  135.             header("Content-type: application/x-msexcel");
  136.             header('Content-Type: text/csv');
  137.             header('Content-Disposition: attachment; filename="'.$this->Editor->tableName.'.csv"');
  138.             exit();
  139.         }
  140.                 else
  141.                 {
  142.                         $this->displayHeaderHtml();
  143.                         $this->displayHtml();
  144.                         $this->displayFooterHtml();
  145.                 }
  146.         }
  147. }
  148. $lte = new Example1();
  149. ?>