示例#1
0
 /**
  * @return put return description here..
  * @param param :  parameter passed to function
  * @desc decode :  put function description here ... 
  */
 function decode($string)
 {
     // Write Function Code Here
     $string = base64_decode($string);
     $tokens = explode($this->getSeparator(), $string);
     if ($tokens[1] != $this->getSalt()) {
         $thisError = new errorHandler();
         $thisError->setUserErrorMessage("Data Tampering Detected !! Administrator has been notified ! ");
         $thisError->setProgramErrorMessage("POST DATA TAMPERING");
         $thisError->setErrorPage($_SERVER['PHP_SELF']);
         $thisError->setQuitProgram(true);
         $thisError->handleError();
     }
     return $tokens[0];
 }
示例#2
0
 /**
  * @return put return description here..
  * @param param :  parameter passed to function
  * @desc buildDropDown($idField,$labelField,$tableName,$conditionField="",$conditionValue="",$labelField2 = "") :  put function description here ...
  */
 function buildDropDown($idField, $labelField, $tableName, $conditionField = "", $conditionValue = "", $labelField2 = "")
 {
     global $db;
     if ($labelField2 != "") {
         $lab2 = ", {$labelField2}";
     } else {
         $lab2 = "";
     }
     if ($conditionField != "") {
         $whereClause = " where {$conditionField}='{$conditionValue}' ";
     }
     $querydrop = "select {$idField},{$labelField} {$lab2} from {$tableName} {$whereClause} ";
     $thisDatabaseQuery = new databaseQuery();
     $thisDatabaseQuery->setSqlQuery($querydrop);
     $thisDatabaseQuery->executeQuery();
     $result = $thisDatabaseQuery->getResultSet();
     if ($result == false) {
         $thisError = new errorHandler();
         $thisError->setUserErrorMessage("An Error Occured while trying to build drop down box from database");
         $thisError->setProgramErrorMessage("An Error Occured while trying to build drop down box from database in function buildDropDown()" . $querydrop);
         $thisError->handleError();
     } else {
         if ($result->RowCount() == 0) {
             return "";
         } else {
             if ($result->RowCount() > 0) {
                 while (!$result->EOF) {
                     $id = $result->fields[$idField];
                     $label = $result->fields[$labelField];
                     if ($labelField2 != "") {
                         $label2 = $result->fields[$labelField2];
                     }
                     echo "<option value=\"{$id}\">{$label}";
                     if ($labelField2 != "") {
                         echo " {$label2} ";
                     }
                     echo "</option>";
                     $result->MoveNext();
                 }
             }
         }
     }
 }
示例#3
0
 function countReturnRows()
 {
     $this->buildSearchSQL();
     $query = new databaseQuery();
     $query->setSqlQuery($this->getSql());
     //$result = $query->getDbConn()->Execute($newQuery);
     $result = $query->countResultSet();
     if ($result == false) {
         $thisError = new errorHandler();
         $thisError->setUserErrorMessage("A Database Error Occured while counting result Rows ");
         $thisError->setProgramErrorMessage($this->dbConn->ErrorMsg());
         $thisError->setErrorPage($_SERVER['PHP_SELF']);
         $thisError->handleError();
         return 0;
     } else {
         return $query->getTotalRows();
     }
 }
示例#4
0
 /**
  * @return a number representing the total number of result rows in a query
  * @desc counts the total number of rows for a query..
  * @version 1.0 [2004-08-06]
  * @license GNU GPL License
  * @author Nilesh Dosooye 
  * @copyright Copyright &copy; 2003, Nilesh Dosooye
  */
 function countResultSet()
 {
     // count only if query is a select query
     if (strtoupper(substr($this->getSqlQuery(), 0, 6)) != "SELECT") {
         $this->setTotalRows("1");
         return true;
     } else {
         // Break query into two parts on 'from' pivot
         list($select, $conditions) = explode(" FROM ", $this->getSqlQuery());
         // replace select fields items by count(*) to find total num of resultsets
         $newQuery = "select count(*) as total from " . $conditions;
         if (DEBUG_PRINT_COUNT_SQL) {
             $timeNow = date("h:i:s");
             echo "<b>Original SQL Query (before count)--></b><font color=green>" . $this->getSqlQuery() . "</font><br>";
             echo "<b>Count SQL Query</b> (<font color=red>" . $timeNow . "</font>)--><font color=green>" . $newQuery . "</font><br>";
         }
         $result = $this->dbConn->Execute($newQuery);
         if ($result == false) {
             $thisError = new errorHandler();
             $thisError->setUserErrorMessage("A Database Error Occured while counting result Rows ");
             $thisError->setProgramErrorMessage($this->dbConn->ErrorMsg());
             $thisError->setErrorPage($_SERVER['PHP_SELF']);
             $thisError->handleError();
             return false;
         } else {
             //$result->MoveNext();
             // Returning ResultSet
             $totalNumberOfRows = $result->fields['total'];
             $this->setTotalRows($totalNumberOfRows);
             return true;
         }
     }
 }