function dbmtime() { $tables =& $this->tables; $lookup = array_flip($tables); $app =& Dataface_Application::getInstance(); $res = xf_db_query("SHOW TABLE STATUS", $app->_db); $latestMod = 0; while ($row = xf_db_fetch_array($res)) { if ((sizeof($tables) === 0 || isset($lookup[$row['Name']])) && strtotime($row['Update_time']) > $latestMod) { $latestMod = strtotime($row['Update_time']); } } return $latestMod; }
/** * @brief Returns the status of this table. Includes things like modification time, etc... * @return array */ function &getStatus() { if (!isset($this->status)) { /* * Get the table status - when was it last updated, etc... */ if (Dataface_Application::getInstance()->getMySQLMajorVersion() < 5) { $res = xf_db_query("SHOW TABLE STATUS LIKE '" . addslashes($this->tablename) . "'", $this->db); } else { $dbname = Dataface_Application::getInstance()->_conf['_database']['name']; $res = xf_db_query("select CREATE_TIME as Create_time, UPDATE_TIME as Update_time from information_schema.tables where TABLE_SCHEMA='" . addslashes($dbname) . "' and TABLE_NAME='" . addslashes($this->tablename) . "' limit 1", df_db()); } if (!$res) { throw new Exception("Error performing mysql query to obtain status for table '" . $this->tablename . "': " . xf_db_error($this->db), E_USER_ERROR); } $this->status = xf_db_fetch_array($res); xf_db_free_result($res); } return $this->status; }
function old_test_perform_sql() { $s =& $this->table1; $s->setValue('id', 15); $res = $s->_addRelatedRecordSQL("courses"); if (PEAR::isError($res)) { echo "Printing error"; echo $res->toString(); exit; } //echo "What the f**k"; //echo "REs: ";print_r($res); $s->_performSQL($res); $res = $s->_addRelatedRecordSQL("courses", array("Courses.dept" => "Computing", "Courses.coursenumber" => "CMPT118")); print_r($res); $this->assertEquals(1, xf_db_num_rows(xf_db_query("SELECT * FROM Courses", $s->db))); $s->_performSQL($res); $this->assertEquals(2, xf_db_num_rows(xf_db_query("SELECT * FROM Courses", $s->db))); $res = xf_db_query("SELECT * FROM Courses", $s->db); $found = false; while ($row = xf_db_fetch_array($res)) { if ($row['id'] == 2) { $found = true; $this->assertEquals("Computing", $row['dept']); $this->assertEquals("CMPT118", $row['coursenumber']); } } $this->assertTrue($found, "Failed to insert related record into Courses."); }
function fnSQLtoXML($sSQL, $oConn = '') { //Returns an XML data island from an SQL statement or an error string if (!$oConn and !($oConn = @xf_db_connect(DB_HOST, DB_USER, DB_PASSWORD))) { $sRetVal = xf_db_error(); } else { if (!mysql_selectdb(DB_NAME, $oConn)) { $sRetVal = xf_db_error(); } else { if (!($result = xf_db_query($sSQL, $oConn))) { $sRetVal = xf_db_error(); } else { while ($line = xf_db_fetch_array($result, MYSQL_ASSOC)) { $sRetVal = "\n<" . mysql_field_table($result, 0) . ">"; $iThisField = 0; foreach ($line as $col_value) { $oTMP = mysql_fetch_field($result, $iThisField); $iThisField++; $sThisFieldName = $oTMP->name; $sRetVal .= "\n\t<{$sThisFieldName} value=" . $col_value . ">"; $sRetVal .= "</{$sThisFieldName}>"; } $sRetVal .= "\n</" . mysql_field_table($result, 0) . ">\n"; } xf_db_free_result($result); } } xf_db_close($oConn); } return $sRetVal; }
/** * Places a row from the result set into the given array * * Formating of the array and the data therein are configurable. * See DB_result::fetchInto() for more information. * * This method is not meant to be called directly. Use * DB_result::fetchInto() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result the query result resource * @param array $arr the referenced array to put the data in * @param int $fetchmode how the resulting array should be indexed * @param int $rownum the row number to fetch (0 = first row) * * @return mixed DB_OK on success, NULL when the end of a result set is * reached or on failure * * @see DB_result::fetchInto() */ function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if ($rownum !== null) { if (!@xf_db_data_seek($result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { $arr = @xf_db_fetch_array($result, MYSQL_ASSOC); if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $arr = @xf_db_fetch_row($result); } if (!$arr) { return null; } if ($this->options['portability'] & DB_PORTABILITY_RTRIM) { /* * Even though this DBMS already trims output, we do this because * a field might have intentional whitespace at the end that * gets removed by DB_PORTABILITY_RTRIM under another driver. */ $this->_rtrimArrayValues($arr); } if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) { $this->_convertNullArrayValuesToEmpty($arr); } return DB_OK; }
function display() { $this->_build(); $showform = true; $b = new Dataface_QueryBuilder($this->_tablename, $this->_query); if (isset($this->_query['-delete-one'])) { $q = array('-skip' => $this->_query['-cursor'], '-limit' => 1); $sql = $b->select('', $q); $res = xf_db_query($sql, $this->_db); if (!$res) { throw new Exception(df_translate('scripts.Dataface.DeleteForm._build.ERROR_TRYING_TO_FETCH', "Error trying to fetch element to be deleted.: ") . xf_db_error($this->_db), E_USER_ERROR); } if (xf_db_num_rows($res) == 0) { $msg = df_translate('scripts.Dataface.DeleteForm._build.ERROR_NO_RECORD_SELECTED', "No record is currently selected so no record can be deleted."); $showform = false; } else { $row = xf_db_fetch_array($res); $rowRec = new Dataface_Record($this->_tablename, $row); $displayCol = $rowRec->getTitle(); $msg = df_translate('scripts.Dataface.DeleteForm.display.ARE_YOU_SURE', "Are you sure you want to delete this record: "{$displayCol}"?", array('displayCol' => $displayCol)); } } else { if (isset($this->_query['-delete-found'])) { $q = $b->select_num_rows(); $res = xf_db_query($q, $this->_db); if (!$res) { throw new Exception(df_translate('scripts.Dataface.DeleteForm.display.ERROR_ESTIMATING', "Error estimating number of rows that will be deleted: ") . xf_db_error($this->_db), E_USER_ERROR); } list($num) = xf_db_fetch_row($res); if ($num <= 0) { $msg = df_translate('scripts.Dataface.DeleteForm.display.ERROR_NO_RECORDS_FOUND', "There are no records in the current found set so no records can be deleted."); $showform = false; } else { $msg = df_translate('scripts.Dataface.DeleteForm.display.ARE_YOU_SURE_MULTIPLE', "Are you sure you want to delete the found records. {$num} records will be deleted.", array('num' => $num)); } } else { $msg = df_translate('scripts.Dataface.DeleteForm.display.ERROR_GET_VARS', "Error: You must specify either '-delete-one' or '-delete-found' in GET vars."); $showform = false; } } if ($showform) { ob_start(); parent::display(); $form = ob_get_contents(); ob_end_clean(); } else { $form = ''; } $context = array('msg' => $msg, 'form' => $form); import('Dataface/SkinTool.php'); $skinTool =& Dataface_SkinTool::getInstance(); //$smarty = new Smarty; //$smarty->template_dir = $GLOBALS['Dataface_Globals_Templates']; //$smarty->compile_dir = $GLOBALS['Dataface_Globals_Templates_c']; //$smarty->assign($context); //$smarty->display('Dataface_DeleteForm.html'); $skinTool->display($context, 'Dataface_DeleteForm.html'); }
$phpThumb->phpThumbDebug(); } //////////////////////////////////////////////////////////////// $parsed_url_referer = parse_url(@$_SERVER['HTTP_REFERER']); if ($phpThumb->config_nooffsitelink_require_refer && !in_array(@$parsed_url_referer['host'], $phpThumb->config_nohotlink_valid_domains)) { $phpThumb->ErrorImage('config_nooffsitelink_require_refer enabled and ' . (@$parsed_url_referer['host'] ? '"' . $parsed_url_referer['host'] . '" is not an allowed referer' : 'no HTTP_REFERER exists')); } $parsed_url_src = parse_url(@$_GET['src']); if ($phpThumb->config_nohotlink_enabled && $phpThumb->config_nohotlink_erase_image && eregi('^(f|ht)tps?://', @$_GET['src']) && !in_array(@$parsed_url_src['host'], $phpThumb->config_nohotlink_valid_domains)) { $phpThumb->ErrorImage($phpThumb->config_nohotlink_text_message); } if ($phpThumb->config_xf_db_query) { if ($cid = @xf_db_connect($phpThumb->config_mysql_hostname, $phpThumb->config_mysql_username, $phpThumb->config_mysql_password)) { if (@xf_db_select_db($phpThumb->config_mysql_database, $cid)) { if ($result = @xf_db_query($phpThumb->config_xf_db_query, $cid)) { if ($row = @xf_db_fetch_array($result)) { xf_db_free_result($result); xf_db_close($cid); $phpThumb->setSourceData($row[0]); unset($row); } else { xf_db_free_result($result); xf_db_close($cid); $phpThumb->ErrorImage('no matching data in database.'); } } else { xf_db_close($cid); $phpThumb->ErrorImage('Error in MySQL query: "' . xf_db_error($cid) . '"'); } } else { xf_db_close($cid);