Example #1
0
 private function doSave($item, $value, $environment, $group, $namespace = null)
 {
     $connection = $this->getConnection();
     $query = $connection->createQueryBuilder();
     if (is_array($value)) {
         foreach ($value as $key => $val) {
             $key = ($item ? $item . '.' : '') . $key;
             $this->doSave($key, $val, $environment, $group, $namespace);
         }
         return;
     }
     $query->update('Config', 'c')->set('configValue', $query->expr()->literal($value))->where($query->expr()->comparison('configGroup', '=', $query->expr()->literal($group)));
     if ($item) {
         $query->andWhere($query->expr()->comparison('configItem', '=', $query->expr()->literal($item)));
     }
     $query->andWhere($query->expr()->comparison('configNamespace', '=', $query->expr()->literal($namespace ?: '')));
     if (!$query->execute()) {
         try {
             $query = "INSERT INTO Config (configItem, configValue, configGroup, configNamespace) VALUES (?, ?, ?, ?)";
             \Database::executeQuery($query, array($item, $value, $group, $namespace ?: ''));
         } catch (\Exception $e) {
             // This happens when the update succeeded, but didn't actually change anything on the row.
         }
     }
 }
Example #2
0
 /**
  * Commit current tracking data.
  * @param $groupId
  */
 public function commit($groupId)
 {
     $sql = "UPDATE dbtrack_actions SET groupid = :groupid WHERE groupid = 0";
     $this->dbms->executeQuery($sql, array('groupid' => $groupId));
     // Count new actions.
     $count = $this->dbms->getResult('SELECT COALESCE(COUNT(id), 0) AS actions FROM dbtrack_actions WHERE groupid = :groupid', array('groupid' => $groupId));
     return $count->actions;
 }
Example #3
0
 public static function getInstance()
 {
     if (!self::$instance) {
         if (!file_exists(DB_DIR . "driver_db")) {
             $db = new Database(ROOT_DATABASE);
             $db->executeQuery("CREATE DATABASE driver_db");
         }
         self::$instance = new Database("driver_db");
     }
     return self::$instance;
 }
Example #4
0
 public function getDataFromDb2()
 {
     $db = new Database();
     $db->executeQuery("SELECT * FROM cars");
     return $db->getAllRows();
     //       $a = NULL;
     //       $a = 100;
     //        if (isset($a)) {
     //            echo "set";
     //        } else {
     //            echo 'not set';
     //        }
     //       return $a;
 }
Example #5
0
 public function getEntitiesFromList($listId, $return, $offset)
 {
     // for now, ignoring return & offset - will return all products in list
     $query = 'call getProductsByEntityListIdEx(' . $listId . ',' . $this->tenantid . ',' . $offset . ',' . $return . ')';
     $data = Database::executeQuery($query);
     $entity = '';
     if ($data->num_rows == 0) {
         return array();
     }
     while ($r = mysqli_fetch_assoc($data)) {
         $entities[] = $r;
     }
     return $entities;
 }
Example #6
0
 public function Yflatfile($url)
 {
     $url = parse_url($url);
     // Decode url-encoded information in the db connection string
     $url['path'] = urldecode($url['path']);
     //Check if the database exists
     $dbname = substr($url['path'], 1);
     if (!file_exists(DB_DIR . $dbname)) {
         $db = new Database(ROOT_DATABASE);
         $create_db_sql = "CREATE DATABASE {$dbname}";
         if (!$db->executeQuery($create_db_sql)) {
             die(txtdbapi_get_last_error());
         }
     }
     $this->lnk = new Database($dbname);
 }
Example #7
0
 public function getAvailableChildren($fieldname)
 {
     if ($fieldname == "pageCollections") {
         $query = "select id, name from pageCollection where tenantid=" . $this->tenantid;
         $results = Database::executeQuery($query);
         if ($results->num_rows == 0) {
             return array();
         } else {
             $entities = array();
             while ($r = mysqli_fetch_assoc($results)) {
                 $entities[] = $r;
             }
             return $entities;
         }
         return $results->fetch;
     } else {
         return parent::getAvailableChildren($fieldname);
     }
 }
Example #8
0
 static function perform()
 {
     $db = new Database();
     $rows = $db->executeQuery("SELECT * FROM MailQueue WHERE sent = 0");
     if (is_array($rows) && count($rows) > 0) {
         foreach ($rows as $data) {
             $result = Emailer::send([$data['senderEmail'] => $data['senderName']], [$data['receiverEmail']], $data['subject'], $data['body']);
             if ($result) {
                 $params = ['id' => $data['id'], 'sent' => 1, 'now' => date('Y-m-d H:i:s')];
                 $r = $db->executeUpdate("UPDATE MailQueue SET sentAt=:now, sent=:sent WHERE id = :id", $params);
                 if ($r) {
                     print "[{$data['subject']}] Email sent to: " . $data['receiverEmail'] . PHP_EOL;
                 } else {
                     print "[{$data['subject']}] Failed to send email for: " . $data['receiverEmail'] . PHP_EOL;
                 }
             }
         }
     }
 }
Example #9
0
 public function generateKE_1($elementObj)
 {
     $db = new Database();
     $query = "SELECT `E` FROM `ba_mat` WHERE `rcdNo`=";
     if ($elementObj->PK4ba_mat == 2) {
         $query .= "22";
     } elseif ($elementObj->PK4ba_mat == 0) {
         $query .= "23";
     }
     $dataset = $db->executeQuery($query);
     $r = $dataset->fetch_assoc();
     $E = $r['E'];
     $I = $elementObj->PK4ba_g;
     $EI = $E * $I;
     $le = $elementObj->getLength();
     $v1 = $EI * 12 / pow($le, 3);
     $v2 = $EI * 6 / pow($le, 2);
     $v3 = $EI * 4 / $le;
     $v4 = pow($EI, 2) / $le;
     $k_e = array(array($v1, $v2, -$v1, $v2), array($v2, $v3, -$v2, $v4), array(-$v1, -$v2, $v1, -$v2), array($v2, $v4, -$v2, $v3));
     return $k_e;
 }
Example #10
0
 public static function executeQueryReturnArray($query)
 {
     // executes the specified query and returns a multidimensional associative array with the results
     $data = Database::executeQuery($query);
     $resultSet = array();
     while ($row = mysqli_fetch_assoc($data)) {
         array_push($resultSet, $row);
     }
     return $resultSet;
 }
Example #11
0
 public function updatepassword($pass)
 {
     $secure_pass = generateHash($pass);
     $query = "UPDATE user SET password = " . Database::queryString($secure_pass) . ' WHERE id = ' . Database::queryNumber($this->id);
     return Database::executeQuery($query);
 }
Example #12
0
<?php

include "./db-api/txt-db-api.php";
$db = new Database("database_EAM");
$a = 0;
$username = $_POST['name'];
$password = $_POST['password'];
$er1 = "&nbsp &nbsp <font color=red>Invalid username/password</font>";
$redirect = "./index.php?er={$er1}";
$rs = $db->executeQuery("SELECT * FROM user;");
//get all rows
while ($rs->next()) {
    //read next line
    list($usernam, $passwor) = $rs->getCurrentValues();
    //do whatever you wish...
    if ($username == $usernam && $a != 2) {
        $a = 55;
        /*exei username apo thn vash user*/
        if ($password == $passwor) {
            $a = 2;
            /*vrhkame ton xrhsth*/
            session_start();
            /*if (!isset($_SESSION['count'])) {
            			 	$_SESSION['count'] = 0;
            		} else {
             				$_SESSION['count']++;
            		}*/
            unset($_SESSION["login_message"]);
            $_SESSION["isLoggedIn"] = 1;
            $_SESSION["uname"] = $username;
            $_SESSION["type"] = "user";
    echo " Δώσατε λάθος πόλη. \n<br>";
    $a = 1;
}
if (preg_match($regex1, $dieu8unsh)) {
    # valid name
} else {
    echo " Δώσατε λάθος διεύθυνση. \n<br>";
    $a = 1;
}
if (is_numeric($tk)) {
} else {
    echo " Δώσατε λάθος ταχυδρομικό κώδικα.\n<br>";
    $a = 1;
}
if ($oroi_xrhshs != NULL and $oroi_xrhshs1 != NULL and $sign_up == 'user' and $a != 1) {
    $resultset = $db->executeQuery("INSERT INTO user  VALUES ('" . $username . "','" . $password . "','" . $ar_taut . "','" . $onoma . "','" . $epitheto . "','" . $nomos . "','" . $polh . "','" . $dieu8unsh . "','" . $tk . "','" . $mail . "') ");
}
if ($oroi_xrhshs != NULL and $oroi_xrhshs1 != NULL and $sign_up == 'doctor' and $a != 1) {
    /*$resultset1=$db->executeQuery("SELECT COUNT(*) FROM doctor");
    	(username, password, ar_taut, onoma, epitheto, nomos, polh, dieu8unsh, tk,email)
    	(username, password, ar_taut, onoma, epitheto, nomos, polh, dieu8unsh, tk,email, eidikothta, dieu8_iatreiou) 
    	printf("resultset1= %d ",$resultset1);*/
    $resultset = $db->executeQuery("INSERT INTO doctor VALUES ('" . $username . "','" . $password . "','" . $ar_taut . "','" . $onoma . "','" . $epitheto . "','" . $nomos . "','" . $polh . "','" . $dieu8unsh . "','" . $tk . "','" . $mail . "','" . $ar_ad . "','" . $eidikothta . "','" . $dieu8_iatreiou . "') ");
}
if ($oroi_xrhshs == NULL || $oroi_xrhshs1 == NULL) {
    printf("Δεν έχετε συμφωνήσει με τους όρους χρήσης\n");
    $a = 1;
}
if ($a != 1) {
    echo "<br/><br/><br/>DOCTORS<br/>";
    $rs = $db->executeQuery("SELECT * FROM doctor;");
include "../_includes/SSDA_librarydatabase.php";
//SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
// class for database connections
include "../_classes/class.Database.php";
$query = "select title.StudyNum, title.Title FROM title where title.Restricted <> '*' ORDER BY title.StudyNum";
// sql query statement
// NOTE: original query did not exclude the Restricted items
// $query = "select title.Title, title.StudyNum, shfull.subject, Left(shfull.subject,1) AS firstLetterIndex, count(*) as titlePerSubjectCount FROM (title INNER JOIN shcode ON title.tisort = shcode.tisort) INNER JOIN shfull ON shcode.subjectcode = shfull.subjectcode group by shfull.subject ORDER BY shfull.subject";
// echo "<br>$query<br>";
// class.Database.php  is the class to make PDO connections
// initialize new db connection instance
$db = new Database();
// prepare query
$db->prepareQuery($query);
// execute query
$result = $db->executeQuery();
//$result = $db->resultset();  // execute the query
if (!$result) {
    die("Could not query the database: <br />");
}
// else {  echo "Successfully queried the database.<br>";   }  // for debugging
// the index term list
$studynumberList = array();
echo "<form action='da_catalog_titleRecord.php' method='put' name='studynumber' target='_self'>";
echo "<select name='studynumber' class='alphaTitleList'>";
$row_index = 0;
while ($row = $db->getRow()) {
    $title = $row['Title'];
    $tempStudynumber = $row['StudyNum'];
    // code to insure that the studynumbers sort correctly
    $numeric_only = preg_replace('/[a-zA-Z]/', '', $tempStudynumber);
    $query = $_POST['sql'];
} else {
    $query = "SELECT * FROM " . $_GET['tbl'] . " LIMIT " . $_POST['o'] . "," . $_POST['l'];
}
if (stristr($query, "limit")) {
    $use_limit = true;
} else {
    $use_limit = false;
}
$singleQueries = splitSql($query);
$num_queries = count($singleQueries);
$total = 0;
$tbl_view_rows = "";
for ($j = 0; $j < $num_queries; $j++) {
    $localTotal = 0;
    $res = $db->executeQuery($singleQueries[$j]);
    $phase = "{tablec}";
    $tbl_view_cols = "";
    $list_colnames = $res->getColumnNames();
    $numfields = count($list_colnames);
    for ($i = 0; $i < $numfields; $i++) {
        $field = $list_colnames[$i];
        eval("\$tbl_view_cols .= \"" . gettemplate("table_view_colbit") . "\";");
    }
    eval("\$tbl_view_rows .= \"" . gettemplate("table_view_start_table") . "\";");
    eval("\$tbl_view_rows .= \"" . gettemplate("table_view_rowbit") . "\";");
    $phase = "{tablea}";
    while ($res->next()) {
        $tbl_view_cols = "";
        $row = $res->getCurrentValues();
        for ($i = 0; $i < count($row); $i++) {
Example #16
0
        // version is too old, must fall back to system functions instead of SQL
        if (create_database($_POST['new_db'])) {
            $_GET['show'] = "database_details";
            $_GET['db'] = $_POST['new_db'];
        }
    }
}
if (isset($_GET['delete_db'])) {
    // DB is to be deleted, approach depends on version of API
    if (isset($_POST['confirm'])) {
        if ($_POST['confirm'] == "OK") {
            if (min_version("0.1.2-Beta-02")) {
                // version is new enough to handle action by SQL
                $db = new Database(ROOT_DATABASE);
                $query = "DROP DATABASE " . $_GET['delete_db'];
                if ($db->executeQuery($query)) {
                    eval("\$gui_message .= \"" . gettemplate("message_db_deleted_sql") . "\";");
                }
                unset($db);
            } else {
                // version is too old, must fall back to system functions instead of SQL
                $file = $DB_DIR . $_GET['delete_db'];
                $handle = opendir($file);
                while ($filename = readdir($handle)) {
                    if ($filename != "." && $filename != "..") {
                        unlink($file . "/" . $filename);
                    }
                }
                closedir($handle);
                if (rmdir($DB_DIR . $_GET['delete_db'])) {
                    eval("\$gui_message .= \"" . gettemplate("message_db_deleted") . "\";");
 * get parameters are:
 *      collection: name of the pageCollection to update (e.g. 'home')
 *      pageid: id of the page
 *      sort: new sort/sequence number for the page
 */
include_once dirname(__FILE__) . '/../partials/pageCheck.php';
include_once dirname(__FILE__) . '/../classes/utility.php';
include_once dirname(__FILE__) . '/../classes/service.php';
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $collection = Utility::getRequestVariable("collection", "");
    $pageid = Utility::getRequestVariable("pageid", "");
    $sort = Utility::getRequestVariable("sort", "");
    if ($collection == "") {
        Service::returnError('collection parameter is required.');
    }
    if ($pageid == "") {
        Service::returnError('pageid parameter is required.');
    }
    if ($sort == "") {
        Service::returnError('sort parameter is required.');
    }
    if (!$user->hasRole('admin', $tenantID)) {
        Service::returnError('Access denied.', 403);
    }
    $query = "call setPageSortOrderForCollection(" . Database::queryString($collection) . "," . Database::queryNumber($pageid) . "," . Database::queryNumber($sort) . "," . Database::queryNumber($tenantID) . ");";
    Database::executeQuery($query);
    $json = '{"success":true}';
    Service::returnJSON($json);
} else {
    Service::returnError('Unsupported HTTP method.');
}
Example #18
0
 public function findAll()
 {
     $db = new Database();
     return $db->executeQuery('SELECT * FROM User');
 }
Example #19
0
 /**
  * Delete a person from a database.
  * @param $id
  * @return array|bool
  */
 public function deletePerson($id)
 {
     $db = new Database();
     $sql = "DELETE FROM " . self::TABLE . " WHERE id=:id";
     return $db->executeQuery($sql, false, [':id' => $id]);
 }
Example #20
0
							<div class="modalinner">
								<form id="frmAddEndorsement" action="service/endorsement.php" method="post">
											<p>Add New Endorsement:	</p>
											<input type="hidden" name="type" value="location" />
											<input type="hidden" name="locationid" value="<?php 
    echo $location->id;
    ?>
" />
											<input type="hidden" name="id" value="0" />
											<div class="row">
												<span class="label">Endorsed by: </span>
												<span class="input">
													<select name="userid">
					        							<?php 
    $query = "call getEndorsers(" . $tenantID . ")";
    $categories = Database::executeQuery($query);
    if (!$categories) {
        Utility::errorRedirect('Error retrieving endorsing users: ' . mysql_error());
    } else {
        while ($r = mysqli_fetch_array($categories)) {
            echo '<option value="' . $r[0] . '">' . $r[1] . '</option>';
        }
    }
    ?>
					        						</select>
					        					</span>
			        						</div>
			        						<div class="row">
			        							<span class="label">Date:</span>
			        							<span class="date_input"><input name="date" id="date" type="text" value="<?php 
    echo date('Y-m-d H:i:s');
Example #21
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/common/includes/classes.inc";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$comments = $_REQUEST['comments'];
$myFile = "testFile.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $name;
fwrite($fh, "\n" . $stringData);
$stringData = " " . $email;
fwrite($fh, $stringData);
$stringData = " " . $comments;
fwrite($fh, $stringData);
fclose($fh);
$myFile = "email.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $email;
fwrite($fh, "\n" . $stringData);
fclose($fh);
$db = new Database();
$db->connect();
$query = sprintf("INSERT INTO log_email_signup VALUES('%s', '%s', '%s', NOW())", mysql_real_escape_string($name), mysql_real_escape_string($email), mysql_real_escape_string($comments));
$db->executeQuery($query);
$db->closeConnection();
        print "<a href=\"?lang=" . $lang . "&char=" . $chars[$i] . "\">" . lang('all') . "</a></td>\n";
    } else {
        print "<a href=\"?lang=" . $lang . "&char=" . $chars[$i] . "\">" . $chars[$i] . "</a></td>\n";
    }
}
?>
					</tr>
					<tr><td colspan="<?php 
echo strlen($chars);
?>
">
<?php 
// print all addresses which fits to the filter rule
$db = new Database("txtdbapi-examples");
if ($char == '*') {
    $result = $db->executeQuery("SELECT * FROM addressbook ORDER BY familyname");
} else {
    $result = $db->executeQuery("SELECT * FROM addressbook WHERE familyname LIKE '" . $char . "%' ORDER BY familyname, surname");
}
print "<br>\n";
if ($result->getRowCount() == 0) {
    print "<center><i>" . lang('no-data', $char) . "</i></center><br>";
} else {
    print "<table border=\"0\" style=\"width: 540px;\">";
    $help = 0;
    while ($result->next()) {
        if ($help) {
            print "<tr><td colspan=\"2\"><hr></td></tr>\n";
        }
        print "<tr><td>";
        $help = 1;
<?php

$db = new Database($_GET['db']);
$tbl_list_fields = "";
$gui_message2 = "";
$phase = "{tablea}";
$result = $db->executeQuery("SELECT * FROM " . $_GET['tbl']);
$colnames = $result->getColumnNames();
$coltypes = $result->getColumnTypes();
$numf = count($colnames);
for ($i = 0; $i < count($colnames); $i++) {
    $colname = $colnames[$i];
    $coltype = $coltypes[$i];
    $fieldname = "in_field" . $i;
    eval("\$tbl_list_fields .= \"" . gettemplate("table_insert_bit") . "\";");
    $phase = nextPhase($phase);
}
eval("dooutput(\"" . gettemplate("table_insert") . "\");");
Example #24
0
     $epg = $_POST['epg'];
     $yy = $_GET['yy'];
     if ($_GET['mm'] < 10) {
         $mm = '0' . $_GET['mm'];
     } else {
         $mm = $_GET['mm'];
     }
     if ($_GET['dd'] < 10) {
         $dd = '0' . $_GET['dd'];
     } else {
         $dd = $_GET['dd'];
     }
     $time_from = $yy . '-' . $mm . '-' . $dd . ' 00:00:00';
     $time_to = $yy . '-' . $mm . '-' . $dd . ' 24:00:00';
     $query = "delete from epg where ch_id=" . $_GET['id'] . " and time > '" . $time_from . "' and time < '" . $time_to . "'";
     $rs = $db->executeQuery($query);
     $tmp_epg = preg_split("/\n/", stripslashes(trim($epg)));
     $date = $yy . '-' . $mm . '-' . $dd;
     for ($i = 0; $i < count($tmp_epg); $i++) {
         $epg_line = trim($tmp_epg[$i]);
         $line_arr = get_line($date, $tmp_epg, $i);
         if (empty($line_arr)) {
             continue;
         }
         $query = "insert into epg (ch_id, name, time, time_to, duration) values ('" . $_GET['id'] . "', '" . mysql_real_escape_string($line_arr['name']) . "', '" . $line_arr['time'] . "', '" . $line_arr['time_to'] . "', '" . $line_arr['duration'] . "')";
         //var_dump($query);
         $rs = $db->executeQuery($query);
     }
     header("Location: add_epg.php?id=" . $_GET['id'] . "&mm=" . $_GET['mm'] . "&dd=" . $_GET['dd'] . "&yy=" . $_GET['yy'] . "&saved=1");
     exit;
 }
			</li>
			<li id="anakoinwseis">
			<a href="#">Ανακοινώσεις</a>
			</li>
		</ul>
	</div>



<!--div for main page-->
<div id="doctor_information_main">
		<?php 
include "./db-api/txt-db-api.php";
$db = new Database("database_EAM");
$e_mail = $_GET['mail'];
$result = $db->executeQuery("SELECT onoma,epitheto,nomos,polh,tk,email,eidikothta,dieu8_iatreiou FROM doctor WHERE email='{$e_mail}';");
$result->next();
list($onoma, $epitheto, $nomos, $polh, $tk, $mail, $eidikothta, $dieu8_iatreiou) = $result->getCurrentValues();
echo '<div id="doctor_details">
					<p id="p_doctor_details">Παρακάτω εμφανίζονται τα στοιχεία του γιατρού:<br/> κ. ' . $epitheto . ' ' . $onoma . '</p><hr/>
					<table id="table_details" border="1" cellspacing="0" bordercolor="#666666">
						<tr>
						 <th id="result_header_style" colspan="2">Στοιχεία Ιατρού</th>
						 </tr>
						<tr>
						<td>Όνομα</td>
						<td>', $onoma, '</td>
						</tr>
						<tr>
						<td>Επίθετο</td>
						<td>', $epitheto, '</td>
					<input type="submit" value="Αναζήτηση"><br>
					</fieldset>
					</form>
		</div><!--end of search_doctors_form div-->

		<div id="results_doctors">
			<?php 
include "./db-api/txt-db-api.php";
$db = new Database("database_EAM");
$a = 0;
if (sizeof($_POST) != 0) {
    $nomos = $_POST['nomos'];
    if ($nomos != "no") {
        $polh = $_POST['polh'];
        $eidikothta = $_POST['eidikothta'];
        $result = $db->executeQuery("SELECT onoma,epitheto,nomos,polh,tk,email,eidikothta,dieu8_iatreiou FROM doctor WHERE nomos='{$nomos}' AND polh='{$polh}' AND eidikothta = '{$eidikothta}';");
        if ($result->next()) {
            $a = 1;
            $result = $db->executeQuery("SELECT onoma,epitheto,nomos,polh,tk,email,eidikothta,dieu8_iatreiou FROM doctor WHERE nomos='{$nomos}' AND polh='{$polh}' AND eidikothta = '{$eidikothta}';");
        }
        if ($a != 0) {
            echo '<h3 style="width:200px; margin-left:auto; margin-right:auto;">', "~ΑΠΟΤΕΛΕΣΜΑΤΑ~", '</h3>';
            echo '<table cellpadding="4" cellspacing="0" border="1" style="margin-left:auto; margin-right:auto;">';
            echo '<tr id="result_header_style"><th>Όνομα</th><th>Επίθετο</th><th>Νομός</th><th>Πόλη</th><th>Ταχυδρομικός κώδικας</th><th>email</th><th>Ειδικότητα</th><th>Διεύθυνση ιατρείου</th><th>Εμφάνιση Αναλυτικής Καρτέλας</th></tr>';
            while ($result->next()) {
                $a = 1;
                //doctor.php?mail=$username
                echo '<tr>';
                list($onoma, $epitheto, $nomos, $polh, $tk, $mail, $eidikothta, $dieu8_iatreiou) = $result->getCurrentValues();
                $output = '<a href=doctor_information.php?mail=' . $mail . '>Πατήστε εδώ</a>';
                echo '<td>', $onoma, '</td>';
Example #27
0
 public function getTenants()
 {
     $tenants = array();
     if ($this->id > 0) {
         $query = "call getRolesByUserId(" . Database::queryNumber($this->id) . ");";
         $results = Database::executeQuery($query);
         $i = 0;
         while ($arr = mysqli_fetch_assoc($results)) {
             $arr["index"] = $i;
             $i++;
             array_push($tenants, $arr);
         }
     }
     return $tenants;
 }
<?php

// txt-db-api library: http://www.c-worker.ch/txtdbapi/index_eng.php
require_once "php-txt-db/txt-db-api.php";
require_once "login.php";
require_once "includes/auth.php";
require_once "includes/navigation.php";
// Init global variables
$db = new Database("pancoin");
$user = new User($db);
if (validate_user($user)) {
    ?>
    
    var myPanCoins = <?php 
    $sql = "SELECT PanCoins FROM Person WHERE PersonID={$user->id}";
    $rs = $db->executeQuery($sql);
    $balance = $rs->getValueByNr(0, 0);
    echo $balance > 0 ? $balance : 0;
    ?>
;
    var div = document.getElementById("myPanCoins");
    
    if (div != null)
    {
        div.innerHTML = myPanCoins;
    }
<?php 
}
<?php

$_POST['sql'] = stripslashes($_POST['sql']);
if (strtoupper(substr($_POST['sql'], 0, 6)) == "SELECT") {
    include 'table_view.php';
} else {
    $db = new Database($_GET['db']);
    $query = $_POST['sql'];
    $singleQueries = splitSql($query);
    $num_queries = count($singleQueries);
    for ($i = 0; $i < $num_queries; $i++) {
        $query = $singleQueries[$i];
        $result = $db->executeQuery($query);
        if ($result) {
            eval("\$gui_message2 .= \"" . gettemplate("message_sql_execute_success") . "\";");
        } else {
            eval("\$gui_message2 .= \"" . gettemplate("message_sql_execute_failure") . "\";");
        }
    }
    unset($db);
    include "{$_POST['referto']}";
}
Example #30
0
 public function linkMediaToLocation($mediaid, $locationid)
 {
     $query = "call AddLocationMedia(" . Database::queryNumber($mediaid) . "," . Database::queryNumber($locationid) . "," . Database::queryNumber($this->tenantid) . "," . Database::queryNumber($this->userid) . ");";
     Database::executeQuery($query);
 }