function updateDb() { $params = array(); $toReturn = array(); $toReturn['updated'] = true; $toReturn['message'] = ""; $db = new RecordSet($this->dbConnectionInfo, false, true); $rows = $db->Open("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . $this->dbConnectionInfo['dbName'] . "' AND TABLE_NAME = 'webhelp'"); if ($rows > 0) { $db->Open("SELECT * FROM webhelp;"); while ($db->MoveNext()) { $assoc = $db->getAssoc(); $params[$db->Field("parameter")] = $db->Field("value"); } $db->Close(); if ($params['databaseVersion'] != '1') { $toReturn['updated'] = false; $toReturn['message'] = "Incompatible database version found!"; } } else { $toReturn['updated'] = false; $toReturn['message'] = "Database structure does not exist! In order to create a compatible database structure you must check option <strong>\"Create new database structure\"</strong> from previous instalation page."; } return $toReturn; }
/** * export Comments for a specified page * * @param IExporter $exporter exporter to be used * @param String fields to be exported separated by comma * @param String orderClause to be used in selecting records */ function export($exporter, $fields = null, $orderClause = null) { $whereClause = ""; $whereFromFilter = $exporter->getFilter()->getSqlFilterClause(); if ($whereFromFilter != null) { $whereClause = "WHERE " . $whereFromFilter; } $db = new RecordSet($this->dbConnectionInfo); $select = "*"; if ($fields != null) { //$select=Utils::arrayToString($fields,","); $select = $fields; } $sql = "SELECT " . $select . " FROM " . $this->tableName . " " . $whereClause; if ($orderClause != null) { $sql .= " " . $orderClause; } $sql .= ";"; if ($db->Open($sql)) { $rowArray = $db->getAssoc(); while ($rowArray) { if (is_array($rowArray)) { $exporter->exportRow($rowArray); } $rowArray = $db->getAssoc(); } } $db->Close(); }
public function storeRecordSet(RecordSet $set, $key, $lifetime = null) { $class = $set->getClassName(); $fullKey = $this->_buildSetKey($class, $key); $ids = []; foreach ($set as $item) { $ids[] = $item->id; $this->storeRecord($item, $lifetime); } $this->_cacher->writeData($fullKey, $ids, $lifetime); }
function getBaseUrl($product, $version) { global $dbConnectionInfo; $toReturn = __BASE_URL__; $db = new RecordSet($dbConnectionInfo, false, true); $rows = $db->Open("SELECT value FROM webhelp WHERE parameter='path' AND product='" . $product . "' AND version='" . $version . "';"); if ($rows == 1) { $db->MoveNext(); $toReturn = $db->Field('value'); } $db->Close(); return $toReturn; }
/** * @return array all products that share comments with this one */ function getSharedWith() { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo, false, true); $query = "Select product,value from webhelp where parameter='name' and version='" . $db->sanitize($this->version) . "' "; if (defined('__SHARE_WITH__')) { $query .= "AND product in ("; $shareArray = explode(",", __SHARE_WITH__); foreach ($shareArray as $key => $value) { $query .= "'" . $db->sanitize($value) . "', "; } $query = substr($query, 0, -2) . ");"; } error_log($query); $prds = $db->Open($query); if ($prds > 0) { while ($db->MoveNext()) { $product = $db->Field('product'); $value = $db->Field('value'); $toReturn[$product] = $value; } } $db->close(); return $toReturn; }
public function getChildren() { /** @var Record|TTree $this */ if (is_null($this->_children)) { $this->_children = RecordSet::createFromForeign($this, get_class($this)); } return $this->_children; }
private function getEmails() { global $dbConnectionInfo; $this->to = array(); if (defined('__ADMIN_EMAIL__') && strlen(trim(__ADMIN_EMAIL__)) > 0) { $this->to[] = __ADMIN_EMAIL__; } if (defined("__SEND_ERRORS__") && __SEND_ERRORS__) { try { $ds = new RecordSet($dbConnectionInfo, false, true); $ds->open("SELECT email FROM users WHERE level='admin';"); while ($ds->MoveNext()) { $this->to[] = $ds->Field('email'); } $ds->close(); } catch (Exception $e) { // ignore $msg = date("Y-m-d H:i:s") . ": Error:[" . $e->getCode() . "] message:[" . $e->getMessage() . "]\tfile:[" . $e->getFile() . "] line:[" . $e->getLine() . "]"; $this->bag .= "[" . $this->getRealIpAddr() . "] - " . $msg . "<br/>"; $this->count++; $this->sendInternal(false); } } }
/** * @return array all products that share comments with this one */ function getSharedWith() { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo, false, true); $prds = $db->Open("Select product,value from webhelp where parameter='name' and version='" . $this->version . "' " . (defined('__SHARE_WITH__') ? "AND product in (" . __SHARE_WITH__ . ")" : '') . ";"); if ($prds > 0) { while ($db->MoveNext()) { $product = $db->Field('product'); $value = $db->Field('value'); $toReturn[$product] = $value; } } $db->close(); return $toReturn; }
function expandTransactionIdsInRecordSet( RecordSet $recordSet ) { for ( $i = 0; $i < $recordSet->getRecordCount(); $i++ ) { $record = $recordSet->getRecord( $i ); $record->transaction = getTransactionRecord( $record->transactionId ); } }
/** * Get allproduct for witch this user is valid * * @return multitype:Strign productId=>Name */ function getSharedProducts() { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo, false, true); $prds = $db->Open("Select product,value from webhelp where parameter='name' ;"); if ($prds > 0) { while ($db->MoveNext()) { $product = $db->Field('product'); $value = $db->Field('value'); $toReturn[$product] = $value; } } $db->close(); return $toReturn; }
/** * @param $className * @return mixed * @throws RecordsManException */ public function loadForeign($className) { $foreignClass = Helper::qualifyClassName($className); if (isset($this->_foreign[$foreignClass])) { return $this->_foreign[$foreignClass]; } $relationType = $this->getRelationTypeWith($foreignClass); $relationParams = $this->getRelationParamsWith($foreignClass); /** @var Record|string $foreignClass */ switch ($relationType) { case self::RELATION_BELONGS: $fKeyValue = $this->get($relationParams['foreignKey']); $this->_foreign[$foreignClass] = $fKeyValue ? $foreignClass::load($fKeyValue) : null; break; case self::RELATION_MANY: $this->_foreign[$foreignClass] = RecordSet::createFromForeign($this, $foreignClass); break; } return $this->_foreign[$foreignClass]; }
<?php /* Oxygen Webhelp plugin Copyright (c) 1998-2014 Syncro Soft SRL, Romania. All rights reserved. Licensed under the terms stated in the license file EULA_Webhelp.txt available in the base directory of this Oxygen Webhelp plugin. */ $baseDir0 = dirname(dirname(__FILE__)); include $baseDir0 . '/oxygen-webhelp/resources/php/init.php'; $version = "@PRODUCT_VERSION@"; if (isset($_POST['host']) && isset($_POST['user']) && isset($_POST['passwd']) && isset($_POST['db'])) { $dbConnectionInfo = array('dbHost' => $_POST['host'], 'dbName' => $_POST['db'], 'dbPassword' => $_POST['passwd'], 'dbUser' => $_POST['user']); try { $db = new RecordSet($dbConnectionInfo, false, true); $prds = $db->Open("Select product,value from webhelp where parameter='name' and version='" . $version . "'; "); if ($prds > 0) { echo "<div class=\"title\">Display comments from</div>\n\t\t\t<div class=\"desc\">Share other products comments (having the same version) with this one. You must select one or more products from the list. Hold down the Ctrl (windows) / Command (Mac) button to select multiple options. </div>\n\t\t\t<table>\n\t\t\t<tr>\n\t\t\t<td>Existing products sharing the same database\n\t\t\t</td>\n\t\t\t<td>"; echo "<select multiple=\"multiple\" name=\"shareWith[]\" size=\"5\">"; while ($db->MoveNext()) { $product = $db->Field('product'); $name = $db->Field('value'); echo "<option value=\"" . $product . "\">" . $name . "</option>"; } echo "</select>"; echo "</td>\n\t\t\t</tr></table></div>"; } } catch (Exception $ex) { echo "<br/>Could not connect to database using specified informations:"; echo "<table class=\"info\">";
function QueryStatus(&$arg) { $sid = intval(safefetch($arg, 'sid', "Fail")); global $conn; $rs = new RecordSet($conn); $rs->Query("SELECT sid, uid, status, run_time, run_memory, failcase FROM status WHERE sid = {$sid}"); if (!$rs->MoveNext()) { Fail("Invalid run id"); } Output("status", $rs->Fields["status"]); Output("run_time", $rs->Fields["run_time"]); Output("run_memory", $rs->Fields["run_memory"]); Output("case_num", $rs->Fields["failcase"]); Output("uid", $rs->Fields["uid"]); Output("sid", $rs->Fields["sid"]); $rs->Query("select count(*) from queue"); $rs->MoveNext(); Output("queue_size", intval($rs->Fields[0]) + 1); $rs->free_result(); }
<td width="10%">Ratio</td> <td width="10%">Edit</td> <td width="10%">Copy</td> </tr> <?php if ($rs->MoveNext()) { $i = 0; do { $i++; printf("<tr bgcolor=\"#%s\">\n", $i % 2 ? "EEEEEE" : "FCFCFC"); $pid = $rs->Fields['pid']; ?> <td height=25 align="center"> <?php if ($cid) { $rs1 = new RecordSet($conn); $rs1->Query("SELECT accepted FROM ranklist WHERE cid='{$cid}' AND uid='{$login_uid}' AND pid='{$pid}'"); if ($rs1->MoveNext()) { if ($rs1->Fields['accepted'] == 1) { echo "<img src=\"images/yes.gif\" width=\"20\" height=\"20\">"; } else { echo "<img src=\"images/no.gif\" width=\"20\" height=\"20\">"; } } } // if ($rs->Fields['list'][$rs->Fields['pid'] - 1000] == 1) echo "<img src=\"images/no.gif\" width=\"20\" height=\"20\">"; // if ($rs->Fields['list'][$rs->Fields['pid'] - 1000] == 2) echo "<img src=\"images/yes.gif\" width=\"20\" height=\"20\">"; ?> </td> <td align="center"><?php echo $pid;
/** * Gather user information * * @param string $username Find information for 'username' * @param string $info Required attribute of the user account object * @return null|string User information * @throws Exception */ public function getUserInformation($username, $info) { $toReturn = null; $db = new RecordSet($this->dbConnectionInfo, false, true); $information = $db->Open("SELECT email FROM users WHERE userName = '******' AND password != '';"); switch ($information) { case 1: // User found in local database $toReturn = $db->Field('email'); break; case 0: // User not found in local database // Try to find it in LDAP if ($this->ldap instanceof Ldap) { try { $information = $this->ldap->getUserInfo($username, array($info)); $toReturn = @$information[0][$info][0]; } catch (Exception $e) { throw new Exception($e->getMessage()); } } break; default: throw new Exception('No or more than one email address found for ' . $username); } return $toReturn; }
function getUniqueIdsInRecordSet( RecordSet $recordSet, array $idAttributes ) { $ids = array(); for ( $i = 0; $i < $recordSet->getRecordCount(); $i++ ) { $record = $recordSet->getRecord( $i ); foreach ( $idAttributes as $idAttribute ) { $ids[] = $record->getAttributeValue( $idAttribute ); } } return array_unique( $ids ); }
function deleteRecursive($ids) { if (count($ids) > 0) { $db = new RecordSet($this->dbConnectionInfo, false, true); $toDelete = array(); $idsS = implode(", ", $ids); $db->open("SELECT commentId FROM comments WHERE referedComment in (" . $idsS . ");"); while ($db->MoveNext()) { $toDelete[] = $db->Field("commentId"); } $query = "DELETE FROM comments WHERE commentId in (" . $idsS . ");"; $toReturn = $db->Run($query); $db->close(); if (count($toDelete) > 0) { $this->deleteRecursive($toDelete); } } }
function expandOptionsInRecordSet( RecordSet $recordSet, ViewInformation $viewInformation ) { global $dataSet; $o = OmegaWikiAttributes::getInstance(); $recordSet->getStructure()->addAttribute( $o->optionAttributeOption ); $recordSet->getStructure()->addAttribute( $o->optionAttribute ); for ( $i = 0; $i < $recordSet->getRecordCount(); $i++ ) { $record = $recordSet->getRecord( $i ); $optionRecordSet = queryRecordSet( null, $viewInformation->queryTransactionInformation, $o->optionAttributeOptionId, new TableColumnsToAttributesMapping( new TableColumnsToAttribute( array( 'attribute_id' ), $o->optionAttributeId ), new TableColumnsToAttribute( array( 'option_mid' ), $o->optionAttributeOption ) ), $dataSet->optionAttributeOptions, array( 'option_id = ' . $record->optionAttributeOptionId ) ); $optionRecord = $optionRecordSet->getRecord( 0 ); $record->optionAttributeOption = $optionRecord->optionAttributeOption; $optionRecordSet = queryRecordSet( null, $viewInformation->queryTransactionInformation, $o->optionAttributeId, new TableColumnsToAttributesMapping( new TableColumnsToAttribute( array( 'attribute_mid' ), $o->optionAttribute ) ), $dataSet->classAttributes, array( 'object_id = ' . $optionRecord->optionAttributeId ) ); $optionRecord = $optionRecordSet->getRecord( 0 ); $record->optionAttribute = $optionRecord->optionAttribute; } }
function KickoutUser(&$arg) { $uid = mysql_real_escape_string(safefetch($arg, 'uid')); $course_id = mysql_real_escape_string(safefetch($arg, 'course_id')); global $conn; $rs = new RecordSet($conn); $rs->Query("DELETE FROM course_reg WHERE uid = {$uid} AND course_id = {$course_id}"); $rs->affected_rows(); MsgAndBack(); }
/** * Returns all of the {@link DMRecord}s within this Set to the state they were in on the given date. * @param ref object $date A {@link DateAndTime} object. * @access public * @return boolean */ function revertToDate($date) { $this->loadRecords(RECORD_FULL); parent::revertToDate($date); }
<?php include_once "../inc/global.inc.php"; include_once "auth.inc.php"; global $conn; $id = $_GET["id"]; if ($id == "") { error("Invalid user ID!", "ranklist.php"); } $user = new UserTbl(); if (!$user->Get($id)) { error("Invalid user ID!", "ranklist.php"); } $solved = $user->detail['solved']; $submissions = $user->detail['submissions']; $rs = new RecordSet($conn); $rs->Query("SELECT count(*) FROM user WHERE solved > '{$solved}' OR (solved = '{$solved}' AND submissions < '{$submissions}') OR (solved = '{$solved}' AND submissions = '{$submissions}' AND uid < '{$id}')"); $rank = $rs->Fields[0] + 1; /* @mysql_connect($host, $user, $password) or die("Unable to connect database!"); mysql_select_db($database); $table = "user"; $query = "SELECT * FROM $table WHERE id = '$id'"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) error("Invalid user ID!", "ranklist.php"); $row = mysql_fetch_array($result); $id = $row["id"]; $username = $row["username"]; $email = $row["email"]; $address = $row["address"]; $solved = $row["solved"];
<?php require "./navigation.php"; include_once "./FCKeditor/fckeditor.php"; $course_id = tryget('course_id', ''); $courseTbl = new CourseTbl($course_id); if ($course_id && !$courseTbl->Get()) { error("Course not found"); } $course = $courseTbl->detail; $rs = new RecordSet($conn); $rs->Query("SELECT max(cid) FROM contests"); $rs->MoveNext(); $cid = $rs->Fields[0]; $rs->Query("SELECT * FROM contests"); ?> <script type="text/javascript"> function pad0(num) { if (num < 10) return "0" + num; return num; } function calc_during() { if ($("#starttime").val().length == 0) { alert("Please set start time first!!"); return; } var during = Date.parse($("#endtime").val()) - Date.parse($("#starttime").val()); during = during / 1000; var s = during % 60;
echo _("Run Memory"); ?> </b></td> <td width="10%"><b><?php echo _("Code Length"); ?> </b></td> <td width="18%"><b><?php echo _("Submit Time"); ?> </b></td> </tr> </thead> <?php global $conn; $rs = new RecordSet($conn); $rs->query("SELECT * FROM status WHERE sid={$problem['stdsid']}"); if ($rs->MoveNext()) { $user_id = $rs->Fields["uid"]; global $login_uid; if ($user_id == $login_uid) { $username = $login_username; } else { $user = new UserTbl($user_id); if ($user->Get()) { $username = $user->detail['username']; } else { $username = '******'; } } $problem_id = $rs->Fields["pid"];
<?php require "../inc/global.inc.php"; require "./auth.inc.php"; $p = $_GET['p']; if ($p == "") { $p = 1; } $rs = new RecordSet($conn); $rs->nPageSize = 16; $rs->PageCount("SELECT count(*) FROM user"); $rs->SetPage($p); $rs->dpQuery("SELECT uid, username, solved, submissions FROM user WHERE perm LIKE '%user%' ORDER BY solved DESC, submissions, uid"); ?> <html> <head> <title>Ranklist</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link rel="stylesheet" href="style.css"> </head> <body color="#FFFFFF" bgcolor="#005DA9" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="770"> <?php require "./navigation.php"; ?> </td> <td background="images/navigation_bg.gif"> </td> </tr> <tr align="center" valign="top">
public function tostring_indent( $depth = 0, $key = "", $myname = "" ) { return parent::tostring_indent( $depth, $key, $myname . "_ConvertingRecordSet" ); }
require "./navigation.php"; if (!isset($_GET['cid'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="get"> cid:<input name="cid" type="text" /> </form> <?php die; } $cid = $_GET['cid']; global $conn; $rs = new RecordSet($conn); $rs->Query("SELECT status.sid, status.uid, cpid, run_memory, codelength, username, nickname FROM contest_status left join status on contest_status.sid = status.sid left join user on status.uid = user.uid WHERE status.status = 'Accepted' and contest_status.cid = {$cid} order by cpid asc, run_memory asc, codelength asc"); $submits = array(); while ($rs->MoveNext()) { $submits[] = $rs->Fields; } echo "<table class='tblContainer ui-widget-content ui-corner-all'><tr class='ui-widget-header'><td>cpid</td><td>sid1</td><td>username1</td><td>sid2</td><td>username2</td></tr>"; $count = 0; for ($i = 0; $i < count($submits); ++$i) { for ($j = $i + 1; $j < count($submits) && is_similar($submits[$i], $submits[$j]); ++$j) { if (is_same($submits[$i], $submits[$j])) { output($submits[$i], $submits[$j]); ++$count; } } }
<?php require "navigation.php"; $p = tryget("p", 1); $rs = new RecordSet($conn); $query_str = "SELECT course_id, name, teacher, description FROM courses WHERE avail = 1 "; $count_str = "SELECT count(*) FROM courses WHERE avail = 1"; $rs->nPageSize = 20; $rs->PageCount($count_str); $rs->SetPage($p); $query_str .= "ORDER BY course_id DESC"; $rs->dpQuery($query_str); $now = time(); ?> <h1><?php echo _("Current Courses"); ?> </h1> <table class="ui-widget tblcontainer ui-widget-content ui-corner-all" width="100%"> <thead > <tr class="ui-widget-header"> <th width="100"><?php echo _("ID"); ?> </th> <th width="300"><?php echo _("Name"); ?> </th> <th width="300"><?php echo _("Teacher");
<?php include_once "../inc/global.inc.php"; include_once "auth.inc.php"; $p = $_GET["p"]; $cid = $_GET["cid"]; $pid = $_GET["pid"]; if ($p == "") { $p = 1; } $rs = new RecordSet($conn); $rs->nPageSize = 16; if ($cid) { $rs->PageCount("SELECT count(*) FROM contest_status"); $rs->SetPage($p); if ($pid) { $rs->dpQuery("SELECT sid, contest_status.uid, username, pid, language, status, run_time, run_memory, time FROM contest_status,user WHERE contest_status.uid=user.uid AND cid='{$cid}' AND pid='{$pid}' ORDER BY time DESC"); } else { $rs->dpQuery("SELECT sid, contest_status.uid, username, pid, language, status, run_time, run_memory, time FROM contest_status,user WHERE contest_status.uid=user.uid AND cid='{$cid}' ORDER BY time DESC"); } $contest = new ContestsTbl(); $contest->Get($cid); } else { $rs->PageCount("SELECT count(*) FROM status"); $rs->SetPage($p); $rs->dpQuery("SELECT sid, status.uid, username, pid, language, status, run_time, run_memory, time FROM status,user WHERE status.uid=user.uid ORDER BY sid DESC"); } ?> <html> <head> <title>Status</title>
function installProduct($dbConnectionInfo) { global $productId, $productVersion; try { $db = new RecordSet($dbConnectionInfo, false, true); $db->Run("DELETE FROM webhelp WHERE parameter='path' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->Run("DELETE FROM webhelp WHERE parameter='installDate' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->Run("DELETE FROM webhelp WHERE parameter='dir' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->Run("DELETE FROM webhelp WHERE parameter='name' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->run("INSERT INTO `webhelp` (`parameter`, `value`, `product`, `version`) VALUES\n\t\t\t\t\t\t('installDate','" . date('YmdHis') . "','" . $productId . "','" . $productVersion . "'),\n\t\t\t\t\t\t\t('path','" . addslashes(Utils::getParam($_POST, 'baseUrl')) . "','" . $productId . "','" . $productVersion . "'),\n\t\t\t\t\t\t\t('dir','" . addslashes(dirname(dirname(__FILE__))) . "','" . $productId . "','" . $productVersion . "'),\n\t\t\t\t\t\t\t('name','" . addslashes(Utils::getParam($_POST, 'productName')) . "','" . $productId . "','" . $productVersion . "')\n\t\t\t\t\t\t\t;"); $db->Close(); } catch (Exception $e) { error_log("Exception installing product " . $productId . " version " . $productVersion . " details: " . $e->getMessage()); echo "Exception installing product " . $productId . " version " . $productVersion . " details: " . $e->getMessage(); throw $e; } }
function recuperarTiposDeEsfera() { $jsonArray = array(); $rs = new RecordSet(); $sql = "SELECT DISTINCT codigo_esfera_administrativa, esfera_administrativa FROM estabelecimento_saude ORDER BY codigo_esfera_administrativa"; $result = $rs->select($sql); while ($row = $rs->setRow($result)) { $jsonLinha = array("codigo_esfera_administrativa" => $row['codigo_esfera_administrativa'], "esfera_administrativa" => $row['esfera_administrativa']); $jsonArray[] = $jsonLinha; } echo json_encode($jsonArray); }