Esempio n. 1
1
 public function get($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN GETRUTACONDUCTOR(:p_id, :rc); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $refcur = oci_new_cursor($data->getConn());
     $this->id = $id;
     oci_bind_by_name($sent, ':p_id', $this->id);
     oci_bind_by_name($sent, ':rc', $refcur, -1, OCI_B_CURSOR);
     if (!oci_execute($sent)) {
         return false;
     }
     if (!oci_execute($refcur)) {
         return false;
     }
     while (($row = oci_fetch_array($refcur, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
         $this->ruta = $row['ID_RUTA'];
         $this->conductor = $row['ID_CONDUCTOR'];
         $this->kilometraje = $row['KILOMETRAJE'];
         $this->descripcion = $row['DESCRIPCION'];
     }
     oci_free_statement($refcur);
     $data->free($sent);
     $data->close();
     return true;
 }
Esempio n. 2
0
 function loadAtendente()
 {
     include_once 'app.ado/DataBase.php';
     $db = new DataBase();
     $aten = $db->getConn()->query('select nome_usuario from usuarios where id_usuario = ' . $this->usuario_id . ';')->fetchAll(PDO::FETCH_CLASS, "Item");
     return $aten;
 }
 public function render()
 {
     if (!$this->conteudo) {
         include_once 'app.ado/DataBase.php';
         $pdo = new DataBase();
         $db = $pdo->getConn();
         $sql = 'select * from ctrl_chaves';
         if ($this->dt_inicial or $this->dt_final) {
             $this->dt_inicial = $this->dt_inicial ? $this->dt_inicial : '2012/01/01';
             $this->dt_final = $this->dt_final ? $this->dt_final : date('Y/m/d');
             $sql .= ' where ((dt_inicial_controle between ? and ?) or (dt_final_controle between ? and ?))';
             $exec[] = $this->dt_inicial;
             $exec[] = $this->dt_final;
             if ($this->id) {
                 $sql .= ' and id_controle = ?';
                 $exec[] = $this->id;
             }
         } elseif ($this->id) {
             $sql .= ' where id_controle = ?';
             $exec[] = $this->id;
         }
         if ($this->order) {
             $sql .= ' order by ?';
             $exec[] = $this->order;
         }
         $sth = $db->prepare($sql);
         $conteudo = $sth->execute($exec);
         $this->conteudo = $conteudo->fetchAll(PDO::FETCH_CLASS, 'CrlChave');
     }
     $tabela = new TTableChave($this->conteudo);
     $pdf = new TRelatorio();
     $pdf->writeHTML($tabela->render());
     $pdf->render();
     $pdf->exit();
 }
    function getTable($news_id, $hotelType, $hotelLocation, $impactType)
    {
        $mydatabase = new DataBase();
        //$news = $mydatabase->getNews_by_game($game,$period);
        $news = $mydatabase->getNews_by_id($news_id);
        //print_r("Game: ".$game.", Period: ".$period);
        if (!isset($news) || count($news) == 0) {
            return "fail";
        }
        $parameters = $mydatabase->getAllNews_parameters($news['id']);
        $count = 0;
        $result = '<h3 align="center"> News Affects Parameters</h3>' . '<br />' . '<table class="table table-bordered">
						<thead>
							<tr>
								<th>#</th>
								<th>Hotel Type</th>
								<th>Hotel Location</th>
								<th>Impact</th>
							</tr>
					</thead>';
        if (isset($parameters) && count($parameters) > 0) {
            foreach ($parameters as $key => $temp) {
                $result .= "<tbody>" . "<tr>" . "<td>" . ++$count . "</td>" . "<td>" . $temp['hotel_type'] . "</td>" . "<td>" . $mydatabase->getLocation($temp['hotel_location'])['type'] . "</td>" . "<td>" . $temp['effect'] . "</td>" . "</tr>" . "</tbody>";
            }
        }
        if (isset($hotelType) && isset($hotelLocation) && isset($impactType)) {
            for ($counter = 0; $counter < count($impactType); $counter++) {
                $result .= "<tbody>" . "<tr>" . "<td>" . ($counter + 1 + $count) . "</td>" . "<td>" . $hotelType[$counter] . "</td>" . "<td>" . $hotelLocation[$counter] . "</td>" . "<td>" . $impactType[$counter] . "</td>" . "</tr>" . "</tbody>";
            }
        }
        $result .= "</table><br />";
        return $result;
    }
Esempio n. 5
0
 public function search_matrix($idMatrix = FALSE)
 {
     $objData = new DataBase();
     $sth = $objData->prepare('SELECT * FROM matrix M inner join users U ' . 'on M.id_matrix = U.id_matrix WHERE M.id_matrix = :idMatrix');
     $sth->execute(array(':idMatrix' => $idMatrix));
     return $result = $sth->fetchAll();
 }
Esempio n. 6
0
function PollMessage()
{
    include 'config/config.php';
    require_once 'libs/database.php';
    $db = new DataBase($db_server, $db_user, $db_password);
    $db->Select($db_name);
    $db->Query("SELECT * FROM messages ORDER BY id DESC LIMIT 2");
    $data = $db->ReadNext();
    //no message in queue - return nop
    if ($data == null) {
        echo "none";
        return;
    }
    /*		echo "<pre>";
    		print_r($data);
    		echo "</pre>";*/
    $id = $data['id'];
    $message = $data['message'];
    //return the command to client
    echo $message;
    //delete message from queue
    $db = new DataBase($db_server, $db_user, $db_password);
    $db->Select($db_name);
    $db->Query("DELETE FROM messages WHERE id = '{$id}';");
}
Esempio n. 7
0
 public static function listaUnidades($sql)
 {
     $db = new DataBase();
     $db->setQuery(" \n            SELECT\n                  codUnidad\n                , nombre\n            FROM e_unidad\n            WHERE {$sql}\n                AND estado=2\n        ");
     //f::message($db->getQuery());
     $db->executeQuery();
     return $db->getTable('encode');
 }
 function loadLaboratorio()
 {
     include_once 'app.ado/DataBase.php';
     $db = new DataBase();
     $lab = $db->getConn()->query('select nome_laboratorio from laboratorios where id_laboratorio = ' . $this->laboratorio_id . ';')->fetch(PDO::FETCH_COLUMN);
     unset($db);
     return $lab;
 }
Esempio n. 9
0
 function tearDown()
 {
     $db = new DataBase();
     $db->Clear();
     $db->Close();
     unset($_SESSION['user']);
     unset($_SESSION['pw']);
 }
Esempio n. 10
0
 public static function getCurrentUser($id)
 {
     $class = static::class;
     $sql = 'SELECT * FROM users WHERE id=:id';
     $db = new DataBase();
     $res = $db->findOne($class, $sql, [':id' => $id]);
     return $res;
 }
Esempio n. 11
0
function EnqueueMessage($message)
{
    include 'config/config.php';
    require_once 'libs/database.php';
    $db = new DataBase($db_server, $db_user, $db_password);
    $db->Select($db_name);
    $query = "INSERT INTO messages (\n\t\t\t\t\tmessage\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t'{$message}'\n\t\t\t\t\t);";
    $db->Query($query);
}
Esempio n. 12
0
 public function get_feed_items()
 {
     $db = new DataBase();
     $result = $db->get_all();
     $feed = array();
     foreach ($result as $feed_item) {
         array_push($feed, new FeedItem($feed_item));
     }
     return $feed;
 }
Esempio n. 13
0
function get_siteInfo($TcName)
{
    //    Busca en la tabla de configuraciones el valor establecido
    $query = "SELECT valor,tipo FROM Configuracion WHERE idConfiguracion = '{$TcName}'";
    include_once './dataBaseClass/connection.php';
    $cDb = new DataBase();
    $result = $cDb->query($query);
    $row = mysqli_fetch_assoc($result);
    return $row["valor"];
}
Esempio n. 14
0
		public function insertNews() {
			$db = new DataBase();
			//$db->setClassName(get_called_class());
			$news = [];
			foreach ($this->data['news'] as $key => $value) {
				$news[] = '(' . $key . ', ' . $value . ')';
			}
			$sql = 'INSERT INTO ' . $this->table . '(Owner, Post) VALUES ' . implode(', ', array_values($news)) . ' ON DUPLICATE KEY UPDATE Owner = Owner';
			return $db->execute($sql);
		}
Esempio n. 15
0
 function get_dataByLogin($login)
 {
     $db = new DataBase();
     $mysqli = $db->getMysqli();
     $sql = 'SELECT * FROM users WHERE login ="******"';
     if ($result = $mysqli->query($sql)) {
         return $result->fetch_assoc();
     } else {
         return null;
     }
 }
Esempio n. 16
0
 public function delete($profesional)
 {
     try {
         $database = new DataBase();
         $mdb = $database->connect();
         $query = $mdb->prepare('DELETE FROM profesionales WHERE matricula = ?');
         $query->bindParam(1, $profesional->matricula);
         return $query->execute();
     } catch (PDOException $e) {
         $e->getMessage();
     }
 }
Esempio n. 17
0
 public function delete($noticia)
 {
     try {
         $database = new DataBase();
         $mdb = $database->connect();
         $query = $mdb->prepare('DELETE FROM noticias WHERE idnoticia = ?');
         $query->bindParam(1, $noticia->idNoticia);
         return $query->execute();
     } catch (PDOException $e) {
         $e->getMessage();
     }
 }
Esempio n. 18
0
 static function getPatternByProgram($program)
 {
     $pattern = new Pattern();
     $db = new DataBase("SchedulerDatabase");
     $getProgramPattern = "SELECT * FROM Patterns \n\t\t\t\t\t\t\t\t\tWHERE ProgramID = '{$program}'\n\t\t\t\t\t\t\t\t\tORDER BY YearRequired, TermRequired, SubjectID;";
     $rows = $db->execute($getProgramPattern);
     while ($row = $rows->fetch_object()) {
         $newItem = new PatternItem($row->ProgramID, $row->CourseType, $row->YearRequired, $row->TermRequired, $row->SubjectID, $row->CourseNumber);
         $pattern->addItem($newItem);
     }
     return $pattern;
 }
Esempio n. 19
0
/**
 * 取得一个AdoDB的数据库连接对象
 */
function get_conn($dbhost = '', $dbname = '', $dbuser = '', $dbpsw = '', $charset = '')
{
    require_once EZBOSS_CLASSES_PATH . DIRECTORY_SEPARATOR . 'DataBase.class.php';
    if ($dbhost == '') {
        global $dbhost, $dbname, $dbuser, $dbpsw, $charset;
    }
    $db = new DataBase($dbhost, $dbname, $dbuser, $dbpsw, $charset);
    try {
        $conn = $db->getConn();
        return $conn;
    } catch (Exception $e) {
        echo "数据库连接失败";
        exit;
    }
}
Esempio n. 20
0
 public function updateRow()
 {
     $cols = [];
     $data = [];
     $db = new DataBase();
     foreach ($this->data as $k => $v) {
         $data[':' . $k] = $v;
         if ('id' == $k) {
             continue;
         }
         $cols[] = $k . '=:' . $k;
     }
     $sql = ' UPDATE ' . static::$table . ' SET ' . implode(', ', $cols) . ' WHERE id=:id';
     return $db->execute($sql, $data);
 }
Esempio n. 21
0
 public function get($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN GETPLANIFICACION(:id, :nombre, :distancia, :ruta); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $this->id = $id;
     oci_bind_by_name($sent, ':id', $this->id);
     oci_bind_by_name($sent, ':nombre', $this->nombre);
     oci_bind_by_name($sent, ':distancia', $this->distancia);
     oci_bind_by_name($sent, ':ruta', $this->ruta);
     oci_execute($sent);
     $data->free($sent);
     $data->close();
 }
Esempio n. 22
0
 /**
  *
  * @return string
  */
 public function getCode()
 {
     if (isset($_POST['save'])) {
         foreach ($_POST as $property => $value) {
             if ($property != "save" && $property != "roles") {
                 $settings = Settings::getRootInstance()->specify($this->areaType, $this->area);
                 if ($this->dir != "" && $this->dir != "/") {
                     $settings = $settings->dir($this->dir);
                 }
                 $settings->set($property, $value, $this->role);
             }
         }
         Settings::forceReload();
         Cache::clear();
         Language::GetGlobal()->ClearCache();
         if (@header("Location:" . str_replace("&save_settings=1", "", $_SERVER['REQUEST_URI']))) {
             exit;
         } else {
             die("<script>window.location.href = '" . str_replace("&save_settings=1", "", $_SERVER['REQUEST_URI']) . "';</script>");
         }
         $changed = true;
     }
     $template = new Template();
     $template->load($this->template);
     if ($this->area != "global" || $this->areaType != "global") {
         $roleselector = "<select name=\"roles\" onchange=\"document.location.href='" . $this->url . $this->getQuerySeperator() . "areatype=" . urlencode($this->areaType) . "&area=" . urlencode($this->area) . "&role=' + this.options[this.selectedIndex].value + '&save_settings=1';\">";
     } else {
         $roleselector = "<select name=\"roles\" onchange=\"document.location.href='" . $this->url . $this->getQuerySeperator() . "role=' + this.options[this.selectedIndex].value + '&save_settings=1';\">";
     }
     $roles = DataBase::Current()->ReadRows("SELECT * FROM {'dbprefix'}roles ORDER BY name");
     if ($roles) {
         foreach ($roles as $role) {
             if ($this->role == $role->id) {
                 $roleselector .= "<option value=\"" . $role->id . "\" selected=\"selected\">" . htmlentities($role->name) . "</option>";
             } else {
                 $roleselector .= "<option value=\"" . $role->id . "\">" . $role->name . "</option>";
             }
         }
     }
     $roleselector .= "</select>";
     $template->assign_var("ROLES", $roleselector);
     if ($this->area != "global" || $this->areaType != "global") {
         $template->assign_var("URL", $this->url . $this->getQuerySeperator() . "areatype=" . urlencode($this->areaType) . "&area=" . urlencode($this->area) . "&role=" . $this->role . "&save_settings=1");
     } else {
         $template->assign_var("URL", $this->url . $this->getQuerySeperator() . "role=" . $this->role . "&save_settings=1");
     }
     $rows = Settings::getRootInstance()->specify($this->areaType, $this->area)->dir($this->dir)->getRows($this->role);
     if ($rows) {
         foreach ($rows as $row) {
             $index = $template->add_loop_item("SETTINGS");
             $template->assign_loop_var("SETTINGS", $index, "PROPERTY", $row['name']);
             $template->assign_loop_var("SETTINGS", $index, "DESCRIPTION", htmlentities($row['description']));
             $control = new $row['type']();
             $control->name = $row['name'];
             $control->value = $row['value'];
             $template->assign_loop_var("SETTINGS", $index, "CONTROL", $control->getCode());
         }
     }
     return $template->getCode();
 }
Esempio n. 23
0
 public function do_url()
 {
     $num = isset(Vars::$get['recent']) && Vars::$get['recent'] > 0 ? (int) Vars::$get['recent'] : 15;
     $db = DataBase::getinstance();
     $query = "SELECT pagename,timestamp FROM page";
     if (isset(Vars::$get['exp']) && trim(Vars::$get['exp']) != '') {
         $_inc = $db->escape(Vars::$get['exp']);
         $query .= " WHERE php('mb_ereg', '{$_inc}', pagename)";
     } else {
         if (isset(Vars::$get['include']) && trim(Vars::$get['include']) != '') {
             $_inc = $db->escape(glob2ereg(Vars::$get['include']));
             $query .= " WHERE php('mb_ereg', '{$_inc}', pagename)";
         }
     }
     $query .= " ORDER BY timestamp DESC, pagename ASC LIMIT {$num}";
     $result = $db->query($query);
     $list = array();
     while ($row = $db->fetch($result)) {
         $item['timestamp'] = $row['timestamp'];
         $item['pagename'] = $row['pagename'];
         $item['url'] = getURL(Page::getinstance($row['pagename']));
         $list[] = $item;
     }
     $smarty = $this->getSmarty();
     $smarty->assign('rssurl', SCRIPTURL . '?' . htmlspecialchars($_SERVER['QUERY_STRING']));
     $smarty->assign('sitename', SITENAME);
     $smarty->assign('baseurl', SCRIPTURL);
     $smarty->assign('list', $list);
     header('Content-Type: application/xml; charset=UTF-8');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $item['timestamp'][0]) . ' GMT');
     $smarty->display('rss10.tpl.htm');
     exit;
 }
Esempio n. 24
0
 public static function getDBO()
 {
     if (self::$db == null) {
         self::$db = new DataBase(Config::DB_HOST, Config::DB_USER, Config::DB_PASSWORD, Config::DB_NAME);
     }
     return self::$db;
 }
Esempio n. 25
0
 public function supprimer_certificat($id)
 {
     $delete = DataBase::connect()->query("delete from certificat where id_certificat = '{$id}'");
     if ($delete) {
         return true;
     }
 }
Esempio n. 26
0
 function doing()
 {
     $db = DataBase::getinstance();
     $db->begin();
     if (!$db->istable('plugin_counter')) {
         $db->exec(file_get_contents(PLUGIN_DIR . 'counter/counter.sql'));
     }
     $_pagename = $db->escape($this->getcurrentPage()->getpagename());
     $query = "SELECT total,today,yesterday,date FROM plugin_counter";
     $query .= " WHERE pagename = '{$_pagename}'";
     $count = $db->fetch($db->query($query));
     $time = time();
     $date = date('Y-m-d', $time);
     if ($count == null || $date != $count['date']) {
         $yesterday = date('Y-m-d', $time - 24 * 60 * 60);
         $count['total'] = isset($count['total']) ? $count['total'] + 1 : 1;
         $count['yesterday'] = isset($count['date']) && $count['date'] == $yesterday ? $count['today'] : 0;
         $count['today'] = 1;
         $query = "INSERT OR REPLACE INTO plugin_counter";
         $query .= " (pagename, total, today, yesterday, date)";
         $query .= " VALUES('{$_pagename}', {$count['total']}, {$count['today']}, {$count['yesterday']}, '{$date}')";
     } else {
         $count['total']++;
         $count['today']++;
         $query = "UPDATE plugin_counter";
         $query .= " SET total = total + 1, today = today + 1";
         $query .= " WHERE pagename = '{$_pagename}'";
     }
     $db->query($query);
     self::$count = $count;
     $db->commit();
 }
Esempio n. 27
0
 public function supprimer_support($id)
 {
     $delete = DataBase::connect()->query("delete from support where id_support = '{$id}'");
     if ($delete) {
         return true;
     }
 }
Esempio n. 28
0
 protected function kino1tokino2()
 {
     set_time_limit(0);
     $unconverted = array();
     $db = DataBase::getinstance();
     $db->begin();
     $_path = $db->escape(realpath(DATA_DIR . WIKIID . '.db.kino1'));
     $db->exec("ATTACH DATABASE '{$_path}' as kino1");
     $query = 'SELECT pagename FROM kino1.page';
     $query .= ' WHERE pagename IN (SELECT pagename FROM purepage)';
     $unconverted = $db->fetchsinglearray($db->query($query));
     $query = 'INSERT INTO purepage';
     $query .= ' SELECT pagename, NULL, source, timestamp, timestamp FROM kino1.page';
     $query .= '  WHERE pagename NOT IN (SELECT pagename FROM purepage)';
     $db->exec($query);
     AutoLink::getinstance()->refresh();
     $db->exec('DELETE FROM pagebackup');
     $query = 'SELECT main.attach.pagename, main.attach.filename FROM attach';
     $query .= ' INNER JOIN kino1.attach ON main.attach.pagename = kino1.attach.pagename AND main.attach.filename = kino1.attach.filename';
     $result = $db->query($query);
     while ($row = $db->fetch($result)) {
         $unconverted[] = "{$row['main.attach.pagename']} の添付ファイル {$row['main.attach.filename']}";
     }
     $query = 'INSERT OR IGNORE INTO attach';
     $query .= ' SELECT * FROM kino1.attach';
     $db->exec($query);
     $db->commit();
     $db->exec("DETACH DATABASE kino1");
     return $unconverted;
 }
Esempio n. 29
0
 function do_block($pagename, $param1, $param2)
 {
     $param = array_map('trim', explode(',', $param1));
     if (!isset($param[0])) {
         throw new PluginException('引数がありません', $this);
     }
     $url = $param[0];
     $expire = isset($param[1]) ? (int) $param[1] : 1;
     if ($expire == 0) {
         return $this->getrss($url);
     } else {
         $db = DataBase::getinstance();
         $db->begin();
         $_url = $db->escape($url);
         $row = $db->fetch($db->query("SELECT data,time FROM plugin_rss WHERE url = '{$_url}'"));
         if ($row == false || $row['time'] + $expire * 60 < time()) {
             $data = $this->getrss($url);
             $_data = $db->escape($data);
             $query = "INSERT OR REPLACE INTO plugin_rss (url,data,time)";
             $query .= " VALUES('{$_url}', '{$_data}', " . time() . ")";
             $db->query($query);
         } else {
             $data = $row['data'];
         }
         $db->commit();
         return $data;
     }
 }
Esempio n. 30
0
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }