示例#1
0
 /**
  * This function returns a new token.
  *
  * @access public
  * @return string                               a new token
  */
 public function create_token()
 {
     do {
         $token = sha1(uniqid(Text::random('alnum', 32), TRUE));
     } while (DB_SQL::select($this->data_source(DB_DataSource::SLAVE_INSTANCE))->from($this->table())->where('token', DB_SQL_Operator::_EQUAL_TO_, $token)->query()->is_loaded());
     return $token;
 }
示例#2
0
 static function dump()
 {
     $result = DB_SQL::db()->connection->prepare('show profiles')->execute();
     $rows = $result->fetch_all();
     print '<table style="margin: 10px;" cellspacing="1" bgcolor="#000"><tr style="background-color: #888;color: #fff"><th style="padding:3px;">ID</th><th style="padding:3px;">Duration</th><th style="padding:3px;">Query</th></tr>';
     foreach ($rows as $row) {
         print '<tr style="background-color: white; color: black;">';
         print '<td nowrap style="padding:3px;">' . $row['Query_ID'] . '</td>';
         print '<td nowrap style="padding:3px;">' . $row['Duration'] . '</td>';
         print '<td style="padding:3px;">' . $row['Query'] . '</td>';
         print '</tr';
     }
     print '</table>';
 }
示例#3
0
 /**
  * This function returns the last insert id.
  *
  * @access public
  * @override
  * @param string $table                         the table to be queried
  * @param string $column                        the column representing the table's id
  * @return integer                              the last insert id
  * @throws Throwable_SQL_Exception              indicates that the query failed
  *
  * @see http://www.php.net/manual/en/pdo.lastinsertid.php
  */
 public function get_last_insert_id($table = NULL, $column = 'id')
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: Unable to find connection.');
     }
     try {
         if (is_string($table)) {
             $sql = $this->sql;
             $precompiler = DB_SQL::precompiler($this->data_source);
             $table = $precompiler->prepare_identifier($table);
             $column = $precompiler->prepare_identifier($column);
             $alias = $precompiler->prepare_alias('id');
             $id = (int) $this->query("SELECT MAX({$column}) AS {$alias} FROM {$table};")->get('id', 0);
             $this->sql = $sql;
             return $id;
         }
         return (int) $this->query('SELECT LASTVAL() AS "id";')->get('id', 0);
     } catch (Exception $ex) {
         throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: :reason', array(':reason' => $ex->getMessage()));
     }
 }
示例#4
0
 /**
  * This function loads the corresponding model.
  *
  * @access protected
  * @override
  * @return DB_ORM_Model							the corresponding model
  */
 protected function load()
 {
     $parent_key = $this->metadata['parent_key'];
     $child_model = $this->metadata['child_model'];
     $child_table = $child_model::table();
     $child_key = $this->metadata['child_key'];
     $child_source = $child_model::data_source(DB_DataSource::SLAVE_INSTANCE);
     $builder = DB_SQL::select($child_source)->all("{$child_table}.*")->from($child_table);
     $field_count = count($child_key);
     for ($i = 0; $i < $field_count; $i++) {
         $builder->where("{$child_table}.{$child_key[$i]}", DB_SQL_Operator::_EQUAL_TO_, $this->model->{$parent_key[$i]});
     }
     $result = $builder->limit(1)->query($child_model);
     if ($result->is_loaded()) {
         return $result->fetch(0);
     }
     $record = new $child_model();
     for ($i = 0; $i < $field_count; $i++) {
         $record->{$child_key[$i]} = $this->model->{$parent_key[$i]};
     }
     return $record;
 }
示例#5
0
 /**
  * This function adds a lock definition.
  *
  * @access public
  * @override
  * @param string $table                            the table to be locked
  * @param array $hints                             the hints to be applied
  * @return DB_SQL_Lock_Builder                     a reference to the current instance
  */
 public function add($table, array $hints = NULL)
 {
     $table = $this->precompiler->prepare_identifier($table);
     $sql = "SELECT * FROM {$table} WITH (";
     $modes = array();
     if ($hints !== NULL) {
         foreach ($hints as $hint) {
             if (preg_match('/^FORCESCAN|HOLDLOCK|NOLOCK|NOWAIT|PAGLOCK|READCOMMITTED|READCOMMITTEDLOCK|READPAST|READUNCOMMITTED|REPEATABLEREAD|ROWLOCK|SERIALIZABLE|TABLOCK|TABLOCKX|UPDLOCK|XLOCK$/i', $hint)) {
                 $modes[] = strtoupper($hint);
             } else {
                 if (preg_match('/^(INDEX|FORCESEEK).+$/i', $hint)) {
                     $modes[] = DB_SQL::expr($hint);
                 }
             }
         }
     }
     if (empty($modes)) {
         $modes[] = 'TABLOCKX';
     }
     $this->data[$table] = $sql . implode(', ', $modes) . ');';
     return $this;
 }
示例#6
0
<?php

header("Content-type: application/xml");
define("PATH_TO_CLASSES", "administration/classes");
require PATH_TO_CLASSES . "/cls_db_mysql.php";
// dodawanie pliku konfigurujacego bibliotekê baz danych
require PATH_TO_CLASSES . '/cls_fast_template.php';
require "administration/inc/config.php";
require "inc/common_lib.php";
require "inc/main_lib.php";
// mysql_server_version
get_mysql_server_version();
$db = new DB_SQL();
$query = sprintf("\r\n    SELECT \r\n        b.*, a.id, a.title \r\n    FROM \r\n        %1\$s b \r\n    LEFT JOIN \r\n        %2\$s a \r\n    ON \r\n        b.comments_id = a.id \r\n    GROUP BY \r\n        date \r\n    DESC \r\n    LIMIT \r\n        %3\$d", TABLE_COMMENTS, TABLE_MAIN, 10);
$db->query($query);
$rewrite = get_config('mod_rewrite');
$lang = get_config('language_set');
$ft = new FastTemplate('./templates/' . $lang . '/main/tpl/');
$ft->define('xml_feed', 'xml_feed.tpl');
$ft->define_dynamic('xml_row', 'xml_feed');
$http_root = get_httproot();
$ft->assign(array('MAINSITE_LINK' => 'http://' . $http_root, 'NEWS_FEED' => false));
if ($db->num_rows() > 0) {
    while ($db->next_record()) {
        $date = $db->f("date");
        $title = $db->f("title");
        $text = $db->f("text");
        $author = $db->f("author");
        $id = $db->f("id");
        $image = $db->f("image");
        $comments_allow = $db->f("comments_allow");
示例#7
0
$viewbug ? error_reporting(E_ALL & ~E_NOTICE) : error_reporting(0);
#[加载字符串处理类]
require_once SYSTEM_ROOT . "/class/string.php";
$STR = new PHPOK_STRING(false, false, false);
$magic_quotes_gpc = get_magic_quotes_gpc();
@extract($STR->format($_POST));
@extract($STR->format($_GET));
if (!$magic_quotes_gpc) {
    $_FILES = $STR->format($_FILES);
}
#[加载文件处理操作]
require_once SYSTEM_ROOT . "/class/file.php";
$FS = new files();
#[加载数据库]
require_once SYSTEM_ROOT . "/class/db/" . $dbType . ".php";
$DB = new DB_SQL($dbHost, $dbUser, $dbPass);
$DB->Connect($dbData);
#[加载工厂类]
require_once SYSTEM_ROOT . "/class/factory.php";
$CF = new C_Factory($DB, $prefix, $dbType);
#[启用数据库SESSION]
require_once SYSTEM_ROOT . "/class/db/" . $dbType . "/session.php";
#[加载常用函数信息]
require_once SYSTEM_ROOT . "/include/global.func.php";
#[加载网站常规选项]
if (!file_exists(SYSTEM_ROOT . "/data/system.php")) {
    echo "Not Set System.";
    exit;
}
include_once SYSTEM_ROOT . "/data/system.php";
if (!$system["siteurl"] || substr(strtolower($msg), 0, 7) != "http://") {
示例#8
0
 /**
  * This function returns a result set of database views.
  *
  * +---------------+---------------+------------------------------------------------------------+
  * | field         | data type     | description                                                |
  * +---------------+---------------+------------------------------------------------------------+
  * | schema        | string        | The name of the schema that contains the table.            |
  * | table         | string        | The name of the table.                                     |
  * | type          | string        | The type of table.                                         |
  * +---------------+---------------+------------------------------------------------------------+
  *
  * @access public
  * @override
  * @param string $like                  a like constraint on the query
  * @return DB_ResultSet                 a result set of database views
  *
  * @see http://www.geeksww.com/tutorials/database_management_systems/mysql/tips_and_tricks/mysql_query_to_find_all_views_in_a_database.php
  */
 public function views($like = '')
 {
     $builder = DB_SQL::select($this->data_source)->column('TABLE_SCHEMA', 'schema')->column('TABLE_NAME', 'table')->column(DB_SQL::expr("'VIEW'"), 'type')->from('INFORMATION_SCHEMA.TABLES')->where(DB_SQL::expr('UPPER(`TABLE_TYPE`)'), DB_SQL_Operator::_EQUAL_TO_, 'VIEW')->order_by(DB_SQL::expr('UPPER(`TABLE_SCHEMA`)'))->order_by(DB_SQL::expr('UPPER(`TABLE_NAME`)'));
     if (!empty($like)) {
         $builder->where('TABLE_NAME', DB_SQL_Operator::_LIKE_, $like);
     }
     return $builder->query();
 }
示例#9
0
 } else {
     $ft->assign('ONLYINCAT_NO', 'checked="checked"');
 }
 if ($published == "1") {
     $ft->assign('CHECKBOX_YES', 'checked="checked"');
 } else {
     $ft->assign('CHECKBOX_NO', 'checked="checked"');
 }
 $ft->assign('OVERWRITE_PHOTO', !empty($image) ? true : false);
 if (!empty($image)) {
     $ft->define("form_imageedit", "form_imageedit.tpl");
     $ft->assign('IMAGE', $image);
     $ft->parse('IF_IMAGE_EXIST', ".form_imageedit");
 }
 $query = sprintf("\r\n                SELECT \r\n                    category_id, \r\n                    category_parent_id, \r\n                    category_name \r\n                FROM \r\n                    %1\$s \r\n                WHERE \r\n                    category_parent_id = '%2\$d'", TABLE_CATEGORY, 0);
 $sql = new DB_SQL();
 $db->query($query);
 while ($db->next_record()) {
     $c_id = $db->f("category_id");
     $c_name = $db->f("category_name");
     $query = sprintf("\r\n                    SELECT * FROM \r\n                        %1\$s \r\n                    WHERE \r\n                        category_id = '%2\$d' \r\n                    AND \r\n                        news_id = '%3\$d'", TABLE_ASSIGN2CAT, $c_id, $_GET['id']);
     $sql->query($query);
     $sql->next_record();
     $assigned = $sql->f("category_id");
     $ft->assign(array('C_ID' => $c_id, 'C_NAME' => $c_name, 'PAD' => '', 'CURRENT_CAT' => $c_id == $assigned ? 'checked="checked"' : ''));
     $ft->define("form_noteedit", "form_noteedit.tpl");
     $ft->define_dynamic("cat_row", "form_noteedit");
     $ft->parse('CAT_ROW', ".cat_row");
     get_editnews_assignedcat($c_id, 2);
 }
 $ft->parse('ROWS', "form_noteedit");
示例#10
0
 /**
  * This function returns a result set of database views.
  *
  * +---------------+---------------+------------------------------------------------------------+
  * | field         | data type     | description                                                |
  * +---------------+---------------+------------------------------------------------------------+
  * | schema        | string        | The name of the schema that contains the table.            |
  * | table         | string        | The name of the table.                                     |
  * | type          | string        | The type of table.                                         |
  * +---------------+---------------+------------------------------------------------------------+
  *
  * @access public
  * @override
  * @param string $like                  a like constraint on the query
  * @return DB_ResultSet                 a result set of database views
  *
  * @see http://www.devx.com/dbzone/Article/29585/0/page/4
  * @see http://lpetr.org/blog/archives/find-a-list-of-views-marked-inoperative
  * @see http://www.ibm.com/developerworks/data/library/techarticle/dm-0411melnyk/
  */
 public function views($like = '')
 {
     $builder = DB_SQL::select($this->data_source)->column('VIEWSCHEMA', 'schema')->column('VIEWNAME', 'table')->column(DB_SQL::expr("'VIEW'"), 'type')->from('SYSCAT.VIEWS')->where('VIEWSCHEMA', DB_SQL_Operator::_NOT_LIKE_, 'SYS%')->where('VALID', DB_SQL_Operator::_NOT_EQUIVALENT_, 'Y')->order_by(DB_SQL::expr('UPPER("VIEWSCHEMA")'))->order_by(DB_SQL::expr('UPPER("VIEWNAME")'));
     if (!empty($like)) {
         $builder->where('VIEWNAME', DB_SQL_Operator::_LIKE_, $like);
     }
     return $builder->query();
 }
示例#11
0
require PATH_TO_CLASSES . '/cls_db_mysql.php';
require PATH_TO_CLASSES . '/cls_upload.php';
require PATH_TO_CLASSES . '/cls_rss_parser.php';
require_once 'inc/config.php';
require_once '../inc/common_lib.php';
require_once '../inc/admin_lib.php';
// mysql_server_version
get_mysql_server_version();
$lang = get_config('language_set');
require_once 'i18n/' . $lang . '/i18n.php';
require_once PATH_TO_CLASSES . '/cls_fast_template.php';
require_once PATH_TO_CLASSES . '/cls_permissions.php';
// inicjowanie klasy, wkazanie katalogu przechowuj±cego szablony
$ft = new FastTemplate('./templates/' . $lang . '/tpl');
// egzemplarz klasy obs³uguj±cej bazê danych Core
$db = new DB_SQL();
// pobieramy poziom uprawnieñ
$query = sprintf("\r\n    SELECT \r\n        permission_level \r\n    FROM \r\n        %1\$s \r\n    WHERE \r\n        login = '******'", TABLE_USERS, $_SESSION['login']);
$db->query($query);
$db->next_record();
$privileges = $db->f('permission_level');
// egzemplarz klasy do obs³ugi uprawnieñ
$perms = new permissions();
$permarr = $perms->getPermissions($privileges);
$ft->assign(array('PERMS_USER' => false, 'PERMS_WRITER' => false, 'PERMS_MODERATOR' => false, 'PERMS_TPLEDITOR' => false, 'PERMS_ADMIN' => false));
switch ($privileges) {
    case '1':
        $privilege_level = 1;
        $ft->assign('PERMS_USER', true);
        break;
    case '3':
示例#12
0
function set_config($name, $value)
{
    $db = new DB_SQL();
    $query = sprintf("\n        UPDATE\n            %1\$s\n        SET\n            config_value = '%2\$s'\n        WHERE\n            config_name = '%3\$s'", TABLE_CONFIG, $value, $name);
    $db->query($query);
    return true;
}
示例#13
0
 public function item_id($item)
 {
     if ($mapper = $this->orm_mapper()) {
         $options = $mapper->options;
         $key = $options['key'];
         $key = current($key);
         return $item->{$key};
     }
     if ($tbl = $this->dbtable) {
         if ($serial = DB_SQL::db()->tables[$tbl]->serial) {
             return $item->{$serial};
         }
         return $item->id;
     }
     return $item->id();
 }
示例#14
0
 /**
  * This function loads the corresponding model(s).
  *
  * @access protected
  * @override
  * @return DB_ResultSet                         the corresponding model(s)
  */
 protected function load()
 {
     $parent_key = $this->metadata['parent_key'];
     $child_model = $this->metadata['child_model'];
     $child_table = $child_model::table();
     $child_key = $this->metadata['child_key'];
     $child_source = $child_model::data_source(DB_DataSource::SLAVE_INSTANCE);
     if (isset($this->metadata['through_model']) and isset($this->metadata['through_keys'])) {
         $through_model = $this->metadata['through_model'];
         $through_table = $through_model::table();
         $through_keys = $this->metadata['through_keys'];
         $through_source = $through_model::data_source(DB_DataSource::SLAVE_INSTANCE);
         if ($through_source != $child_source) {
             $builder = DB_SQL::select($through_source)->from($through_table);
             $field_count = count($through_keys[1]);
             for ($i = 0; $i < $field_count; $i++) {
                 $builder->column("{$through_table}.{$through_keys[1][$i]}");
             }
             $field_count = count($through_keys[0]);
             for ($i = 0; $i < $field_count; $i++) {
                 $builder->where("{$through_table}.{$through_keys[0][$i]}", DB_SQL_Operator::_EQUAL_TO_, $this->model->{$parent_key[$i]});
             }
             $records = $builder->query('array');
             $builder = DB_SQL::select($child_source)->all("{$child_table}.*")->from($child_table);
             $field_count = count($child_key);
             foreach ($records as $record) {
                 $builder->where_block(DB_SQL_Builder::_OPENING_PARENTHESIS_, DB_SQL_Connector::_OR_);
                 for ($i = 0; $i < $field_count; $i++) {
                     $builder->where("{$child_table}.{$child_key[$i]}", DB_SQL_Operator::_EQUAL_TO_, $this->model->{$record[$through_keys[1][$i]]});
                 }
                 $builder->where_block(DB_SQL_Builder::_CLOSING_PARENTHESIS_);
             }
             foreach ($this->metadata['options'] as $option) {
                 call_user_func_array(array($builder, $option[0]), $option[1]);
             }
             $result = $builder->query($child_model);
         } else {
             $builder = DB_SQL::select($child_source)->all("{$child_table}.*")->from($through_table)->join(DB_SQL_JoinType::_INNER_, $child_table);
             $field_count = count($child_key);
             for ($i = 0; $i < $field_count; $i++) {
                 $builder->on("{$child_table}.{$child_key[$i]}", DB_SQL_Operator::_EQUAL_TO_, "{$through_table}.{$through_keys[1][$i]}");
             }
             $field_count = count($through_keys[0]);
             for ($i = 0; $i < $field_count; $i++) {
                 $builder->where("{$through_table}.{$through_keys[0][$i]}", DB_SQL_Operator::_EQUAL_TO_, $this->model->{$parent_key[$i]});
             }
             foreach ($this->metadata['options'] as $option) {
                 call_user_func_array(array($builder, $option[0]), $option[1]);
             }
             $result = $builder->query($child_model);
         }
     } else {
         $builder = DB_SQL::select($child_source)->all("{$child_table}.*")->from($child_table);
         $field_count = count($child_key);
         for ($i = 0; $i < $field_count; $i++) {
             $builder->where("{$child_table}.{$child_key[$i]}", DB_SQL_Operator::_EQUAL_TO_, $this->model->{$parent_key[$i]});
         }
         foreach ($this->metadata['options'] as $option) {
             call_user_func_array(array($builder, $option[0]), $option[1]);
         }
         $result = $builder->query($child_model);
     }
     return $result;
 }
示例#15
0
         $monit[] = $i18n['edit_links'][7];
         foreach ($monit as $error) {
             $ft->assign('ERROR_MONIT', $error);
             $ft->parse('ROWS', ".error_row");
         }
         $ft->parse('ROWS', "error_reporting");
     }
     break;
 case "remark":
     // zmiana pozycji wybranego linku
     if ($permarr['moderator']) {
         $move = intval($_GET['move']);
         $query = sprintf("\r\n                UPDATE \r\n                    %1\$s \r\n                SET \r\n                    link_order = link_order + '%2\$d' \r\n                WHERE \r\n                    id='%3\$d'", TABLE_LINKS, $move, $_GET['id']);
         $db->query($query);
         // instancja potrzebna
         $sql = new DB_SQL();
         $query = sprintf("\r\n                SELECT * FROM \r\n                    %1\$s \r\n                ORDER BY \r\n                    link_order \r\n                ASC", TABLE_LINKS);
         $sql->query($query);
         $i = 10;
         $inc = 10;
         while ($sql->next_record()) {
             $lid = $sql->f("id");
             $query = sprintf("\r\n                    UPDATE \r\n                        %1\$s \r\n                    SET \r\n                        link_order = '{$i}' \r\n                    WHERE \r\n                        id = '{$lid}'", TABLE_LINKS);
             $db->query($query);
             $i += 10;
         }
         header("Location: main.php?p=12");
         exit;
     } else {
         $monit[] = $i18n['edit_category'][6];
         foreach ($monit as $error) {
示例#16
0
<?php

error_reporting(E_ALL ^ E_DEPRECATED);
include "lib/connect.php";
ob_start();
if (isset($_POST["submit"])) {
    $name = $_POST["name"];
    $email = $_POST["email"];
    $subject = $_POST["subject"];
    $message = $_POST["message"];
    $database = new DB_SQL();
    $result = $database->contact($name, $email, $subject, $message);
    if ($result == true) {
        echo 'Your message has been sent';
    } else {
        echo 'Failed send message';
    }
}
?>
<h2>Contact Us</h2>

"We are happy to answer any question you have or provide you with an estimate. Just send us a message in the form below with any questions you may have."
	<br>
	<br>
<form action="" method="POST" enctype="multipart/form-data">
	<div class="row">
		<label for="name">Your Name:</label><br />
		<input id="name" class="input" name="name" type="text" value="" size="30" required/><br />
	</div>
	<div class="row">
		<label for="email">Your Email:</label><br />
示例#17
0
 /**
  * This function returns the last insert id.
  *
  * @access public
  * @override
  * @param string $table                         the table to be queried
  * @param string $column                        the column representing the table's id
  * @return integer                              the last insert id
  * @throws Throwable_SQL_Exception              indicates that the query failed
  *
  * @see http://www.firebirdfaq.org/faq243/
  */
 public function get_last_insert_id($table = NULL, $column = 'id')
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: Unable to find connection.');
     }
     try {
         if (is_string($table)) {
             $sql = $this->sql;
             $precompiler = DB_SQL::precompiler($this->data_source);
             $table = $precompiler->prepare_identifier($table);
             $column = $precompiler->prepare_identifier($column);
             $id = (int) $this->query("SELECT MAX({$column}) AS \"id\" FROM {$table};")->get('id', 0);
             $this->sql = $sql;
             return $id;
         } else {
             $sql = $this->sql;
             if (preg_match('/^INSERT\\s+INTO\\s+(.*?)\\s+/i', $sql, $matches)) {
                 if (isset($matches[1])) {
                     $table = $matches[1];
                     $id = (int) $this->query("SELECT \"ID\" AS \"id\" FROM {$table} ORDER BY \"ID\" DESC ROWS 1;")->get('id', 0);
                     $this->sql = $sql;
                     return $id;
                 }
             }
             return 0;
         }
     } catch (Exception $ex) {
         throw new Throwable_SQL_Exception(preg_replace('/Failed to query SQL statement./', 'Failed to fetch the last insert id.', $ex->getMessage()));
     }
 }
示例#18
0
 /**
  * This function returns the last insert id.
  *
  * @access public
  * @override
  * @param string $table                         the table to be queried
  * @param string $column                        the column representing the table's id
  * @return integer                              the last insert id
  * @throws Throwable_SQL_Exception              indicates that the query failed
  *
  * @see http://www.php.net/manual/en/function.pg-last-oid.php
  * @see https://github.com/spadefoot/kohana-orm-leap/issues/44
  */
 public function get_last_insert_id($table = NULL, $column = 'id')
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: Unable to find connection.');
     }
     if (is_string($table)) {
         $sql = $this->sql;
         $precompiler = DB_SQL::precompiler($this->data_source);
         $table = $precompiler->prepare_identifier($table);
         $column = $precompiler->prepare_identifier($column);
         $id = (int) $this->query("SELECT MAX({$column}) AS \"id\" FROM {$table};")->get('id', 0);
         $this->sql = $sql;
         return $id;
     } else {
         // Option #1: Using 'SELECT LASTVAL();'
         $command = @pg_query($this->resource, 'SELECT LASTVAL();');
         if ($command === FALSE) {
             throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: :reason', array(':reason' => @pg_last_error($this->resource)));
         }
         $record = @pg_fetch_row($command);
         if ($record === FALSE) {
             throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: :reason', array(':reason' => @pg_last_error($this->resource)));
         }
         return $record[0];
         // Option #2: Using pg_last_oid($this->resource)
         //$id = @pg_last_oid($this->resource);
         //if ($id === FALSE) {
         //	throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: :reason', array(':reason' => @pg_last_error($this->resource)));
         //}
         //return $id;
     }
 }
示例#19
0
<?php

error_reporting(E_ALL ^ E_DEPRECATED);
include "lib/connect.php";
ob_start();
session_start();
if (isset($_POST["submit"])) {
    $Username = $_POST["Username"];
    $Password = $_POST["Password"];
    $database = new DB_SQL();
    if (mysql_num_rows($database->login($Username, $Password)) > 0) {
        $row = mysql_fetch_assoc($database->login($Username, $Password));
        if (password_verify($Password, $row['Password'])) {
            echo ' You are now logged in';
            $_SESSION["user"] = ['username' => $row['Username']];
            header("Location: index.php");
        } else {
            echo "Wrong username and password";
        }
    } else {
        echo "User does not exist";
    }
}
?>

<h2>Login</h2>

<br>
<br>

<form action ="" method="POST">
示例#20
0
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
// inicjowanie klasy, wkazanie katalogu przechowuj±cego szablony
$ft = new fast_template('./templates/' . $lang . '/tpl');
$ft->define(array('main' => "main.tpl", 'main_loader' => "main_loader.tpl", 'rows' => "rows.tpl", 'form_login' => "form_login.tpl"));
$ft->assign(array('TITLE' => $i18n['index'][0], 'ERROR_MSG' => '', 'CSS_HREF' => 'templates/' . $lang . '/css/style.css'));
// deklaracja zmiennej $p
$p = empty($_GET['p']) ? '' : $_GET['p'];
if ($p == "log") {
    $login = trim($_POST['login']);
    $password = trim(md5($_POST['password']));
    if (empty($login) or empty($password)) {
        // U¿ytkownik nie uzupe³ni³ wszystkich pól::form
        $ft->assign('ERROR_MSG', $i18n['index'][1]);
        $ft->parse('ROWS', ".form_login");
    } else {
        $db = new DB_SQL();
        $query = sprintf("\r\n            SELECT \r\n                active \r\n            FROM \r\n                %1\$s \r\n            WHERE \r\n                login = '******' \r\n            AND \r\n                password = '******'", TABLE_USERS, $login, $password);
        $db->query($query);
        if ($db->num_rows()) {
            if ($db->f("active") != "N") {
                // Rejestrujemy zmienne sesyjne
                $_SESSION["login"] = $login;
                $_SESSION["loggedIn"] = TRUE;
                header("Location: main.php");
                break;
            } else {
                // U¿ytkownik nie zaaktywowa³ konta::db
                $ft->assign('ERROR_MSG', $i18n['index'][2]);
                $ft->parse('ROWS', ".form_login");
            }
        } else {
示例#21
0
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
// inicjowanie klasy, wkazanie katalogu przechowuj�cego szablony
$ft = new FastTemplate('./templates/' . $lang . '/tpl');
$ft->define(array('main' => 'main.tpl', 'main_loader' => 'main_loader.tpl', 'rows' => 'rows.tpl', 'form_login' => 'form_login.tpl'));
$ft->assign(array('TITLE' => $i18n['index'][0], 'ERROR_MSG' => '', 'LANG' => $lang));
// deklaracja zmiennej $p
$p = empty($_GET['p']) ? '' : $_GET['p'];
if ($p == 'log') {
    $login = trim($_POST['login']);
    $password = trim(md5($_POST['password']));
    if (empty($login) || empty($password)) {
        // U�ytkownik nie uzupe�ni� wszystkich p�l::form
        $ft->assign('ERROR_MSG', $i18n['index'][1]);
        $ft->parse('ROWS', '.form_login');
    } else {
        $db = new DB_SQL();
        $query = sprintf("\n            SELECT \n                active \n            FROM \n                %1\$s \n            WHERE \n                login = '******' \n            AND \n                password = '******'", TABLE_USERS, $login, $password);
        $db->query($query);
        if ($db->num_rows()) {
            if ($db->f('active') != 'N') {
                // Rejestrujemy zmienne sesyjne
                $_SESSION['login'] = $login;
                $_SESSION['loggedIn'] = TRUE;
                header('Location: main.php');
                break;
            } else {
                // U�ytkownik nie zaaktywowa� konta::db
                $ft->assign('ERROR_MSG', $i18n['index'][2]);
                $ft->parse('ROWS', '.form_login');
            }
        } else {
示例#22
0
    $simple = 1;
    $replacement = array('&', '<br />', '<', '>');
    $pattern = array(' &amp; ', '&lt;br /&gt;', '&lt;', '&gt;');
    $data = str_replace($pattern, $replacement, $data);
    $rss = new rss_parser($data, $simple);
    $allItems = $rss->getAllItems();
    $itemCount = count($allItems);
    $ft->define_dynamic('rss_row', 'main_site');
    for ($y = 0; $y < 5; $y++) {
        $ft->assign(array('PERMA_LINK' => $allItems[$y]['LINK'], 'NEWS_TITLE' => $allItems[$y]['TITLE'], 'DATE' => $allItems[$y]['DATE'], 'NEWS_TEXT' => str_cut(strip_tags($allItems[$y]['DESCRIPTION'])) . '...'));
        $ft->parse('ROWS', '.rss_row');
    }
} else {
    $ft->assign('GET_RSS', false);
}
// Inicjowanie egzemplarza klasy do obs³ugi Bazy Danych
$db = new DB_SQL();
// Zliczenie wszystkich publikowanych wpisów
$query = sprintf("\r\n    SELECT \r\n        count(*) AS id \r\n    FROM \r\n        %1\$s \r\n    WHERE \r\n        published = '%2\$d' \r\n    ORDER BY \r\n        date", TABLE_MAIN, 1);
$db->query($query);
$db->next_record();
$published_items = $db->f('id');
// Zliczenie wszystkich nie publikowanych wpisów
$query = sprintf("\r\n    SELECT \r\n        count(*) AS id \r\n    FROM \r\n        %1\$s \r\n    WHERE \r\n        published = '%2\$d' \r\n    ORDER BY \r\n        date", TABLE_MAIN, -1);
$db->query($query);
$db->next_record();
$nonpublished_items = $db->f('id');
// Zliczenie wszystkich wpisów
$num_items = $published_items + $nonpublished_items;
$ft->assign(array('COUNT_NOTES' => $num_items, 'PUBLISHED_NOTES' => $published_items, 'NONPUBLISHED_NOTES' => $nonpublished_items));
$ft->parse('ROWS', 'main_site');
示例#23
0
文件: SQL.php 项目: techart/tao
 public function run()
 {
     $binds = count($args = func_get_args()) > 1 ? $args : $args[0];
     $run_callbacks = $binds instanceof DB_SQL_Entity && $this->view && $binds instanceof $this->view->prototype;
     $sql = 'DELETE FROM ' . ($this->table ? $this->table : $this->view->table->name) . "\n";
     if (count($where = Core_Arrays::merge($this->view ? $this->view->__get('where') : array(), $this->where))) {
         $sql .= 'WHERE (' . Core_Arrays::join_with(') AND (', $where) . ')';
     }
     if ($run_callbacks ? $binds->before_delete() : true) {
         $rc = DB_SQL::db()->connection->prepare($sql)->bind($binds)->execute();
     }
     if ($run_callbacks && $rc) {
         $binds->after_delete();
     }
     return $rc;
 }
示例#24
0
<?php

error_reporting(E_ALL ^ E_DEPRECATED);
include "lib/connect.php";
ob_start();
if (isset($_POST["product"])) {
    $Productname = $_POST["Productname"];
    $Productdescription = $_POST["Productdescription"];
    $Productprice = $_POST["Productprice"];
    $Productquantity = $_POST["Productquantity"];
    $Image = $_POST["Image"];
}
$database = new DB_SQL();
$products = $database->products();
?>
<h2>Display Product<h2>


<?php 
$sql = mysql_query("SELECT * FROM product");
?>

<table id='products'width="1000"	border="1"	align="center"	cellpadding="0"> 
    <?php 
while ($rows = mysql_fetch_array($products)) {
    ?>

    <img src="products.php?id=1" />
       <tr>
       
       	<td width="250"><a href="#"><?php 
 * by the Free Software Foundation; version 2 only.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 */
require_once 'inc/i18n.php';
require_once 'inc/common_lib.php';
define('PATH_TO_CLASSES', get_root() . '/administration/classes');
require PATH_TO_CLASSES . '/cls_db_mysql.php';
// dodawanie pliku konfigurujacego bibliotekê baz danych
require 'administration/inc/config.php';
$db = new DB_SQL();
$sql = new DB_SQL();
$query = sprintf("\n    CREATE TABLE IF NOT EXIST \n    %1\$s (\n        id int(7) NOT NULL auto_increment, \n        news_id int(7) NOT NULL default '0', \n        category_id int(7) NOT NULL default '0', \n        PRIMARY KEY (id), \n        KEY news_id (news_id, category_id)", TABLE_ASSIGN2CAT);
$db->query($query);
$db->next_record();
$query = sprintf("\n    SELECT \n        id, c_id \n    FROM \n        %1\$s", TABLE_MAIN);
$db->query($query);
while ($db->next_record()) {
    $id = $db->f('id');
    $c_id = $db->f('c_id');
    $query = sprintf("\n        INSERT INTO \n            %1\$s \n        VALUES('', '%2\$d', '%3\$d')", TABLE_ASSIGN2CAT, $id, $c_id);
    $sql->query($query);
    $sql->next_record();
}
$query = sprintf("\n    ALTER TABLE \n        %1\$s \n    DROP \n        c_id", TABLE_MAIN);
$db->query($query);
$db->next_record();
示例#26
0
         $monit[] = $i18n['edit_category'][6];
         foreach ($monit as $error) {
             $ft->assign('ERROR_MONIT', $error);
             $ft->parse('ROWS', ".error_row");
         }
         $ft->parse('ROWS', "error_reporting");
     }
     break;
 case "remark":
     // zmiana pozycji wybranej kategorii
     if ($permarr['moderator']) {
         $move = intval($_GET['move']);
         $query = sprintf("\n                UPDATE \n                    %1\$s \n                SET \n                    category_order = category_order + '%2\$d' \n                WHERE \n                    category_id='%3\$d'", TABLE_CATEGORY, $move, $_GET['id']);
         $db->query($query);
         // instancja potrzebna
         $sql = new DB_SQL();
         $query = sprintf("\n                SELECT * FROM \n                    %1\$s \n                WHERE \n                    category_parent_id = '0' \n                ORDER BY \n                    category_order \n                ASC", TABLE_CATEGORY);
         $sql->query($query);
         $i = 10;
         $inc = 10;
         while ($sql->next_record()) {
             $cid = $sql->f("category_id");
             $query = sprintf("\n                    UPDATE \n                        %1\$s \n                    SET \n                        category_order = '{$i}' \n                    WHERE \n                        category_id = '{$cid}'", TABLE_CATEGORY);
             $db->query($query);
             $i += 10;
         }
         header("Location: main.php?p=9");
         exit;
     } else {
         $monit[] = $i18n['edit_category'][6];
         foreach ($monit as $error) {
示例#27
0
 /**
  * This function returns the last insert id.
  *
  * @access public
  * @override
  * @param string $table                         the table to be queried
  * @param string $column                        the column representing the table's id
  * @return integer                              the last insert id
  * @throws Throwable_SQL_Exception              indicates that the query failed
  */
 public function get_last_insert_id($table = NULL, $column = 'id')
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: Unable to find connection.');
     }
     if (is_string($table)) {
         $sql = $this->sql;
         $precompiler = DB_SQL::precompiler($this->data_source);
         $table = $precompiler->prepare_identifier($table);
         $column = $precompiler->prepare_identifier($column);
         $id = (int) $this->query("SELECT MAX({$column}) AS `id` FROM {$table};")->get('id', 0);
         $this->sql = $sql;
         return $id;
     } else {
         $id = @mysqli_insert_id($this->resource);
         if ($id === FALSE) {
             throw new Throwable_SQL_Exception('Message: Failed to fetch the last insert id. Reason: :reason', array(':reason' => @mysqli_error($this->resource)));
         }
         return $id;
     }
 }
示例#28
0
 /**
  * This function returns a result set of database views.
  *
  * +---------------+---------------+------------------------------------------------------------+
  * | field         | data type     | description                                                |
  * +---------------+---------------+------------------------------------------------------------+
  * | schema        | string        | The name of the schema that contains the table.            |
  * | table         | string        | The name of the table.                                     |
  * | type          | string        | The type of table.                                         |
  * +---------------+---------------+------------------------------------------------------------+
  *
  * @access public
  * @override
  * @param string $like                  a like constraint on the query
  * @return DB_ResultSet                 a result set of database views
  * 
  * @see http://infolab.stanford.edu/~ullman/fcdb/oracle/or-nonstandard.html
  * @see http://www.razorsql.com/articles/oracle_system_queries.html
  */
 public function views($like = '')
 {
     $builder = DB_SQL::select($this->data_source)->column('OWNER', 'schema')->column('VIEW_NAME', 'table')->column(DB_SQL::expr("'VIEW'"), 'type')->from('SYS.ALL_VIEWS')->order_by(DB_SQL::expr('UPPER("OWNER")'))->order_by(DB_SQL::expr('UPPER("VIEW_NAME")'));
     if (!empty($like)) {
         $builder->where('VIEW_NAME', DB_SQL_Operator::_LIKE_, $like);
     }
     return $builder->query();
 }
示例#29
0
 /**
  * This function returns a result set of database views.
  *
  * +---------------+---------------+------------------------------------------------------------+
  * | field         | data type     | description                                                |
  * +---------------+---------------+------------------------------------------------------------+
  * | schema        | string        | The name of the schema that contains the table.            |
  * | table         | string        | The name of the table.                                     |
  * | type          | string        | The type of table.                                         |
  * +---------------+---------------+------------------------------------------------------------+
  *
  * @access public
  * @override
  * @param string $like                  a like constraint on the query
  * @return DB_ResultSet                 a result set of database views
  *
  * @see http://www.alberton.info/sql_server_meta_info.html
  */
 public function views($like = '')
 {
     $builder = DB_SQL::select($this->data_source)->column('[TABLE_SCHEMA]', 'schema')->column('[TABLE_NAME]', 'table')->column(DB_SQL::expr("'VIEW'"), 'type')->from('[INFORMATION_SCHEMA].[TABLES]')->where('[TABLE_TYPE]', DB_SQL_Operator::_EQUAL_TO_, 'VIEW')->where(DB_SQL::expr("OBJECTPROPERTY(OBJECT_ID([TABLE_NAME]), 'IsMsShipped')"), DB_SQL_Operator::_EQUAL_TO_, 0)->order_by(DB_SQL::expr('UPPER([TABLE_SCHEMA])'))->order_by(DB_SQL::expr('UPPER([TABLE_NAME])'));
     if (!empty($like)) {
         $builder->where('[TABLE_NAME]', DB_SQL_Operator::_LIKE_, $like);
     }
     return $builder->query();
 }
示例#30
0
 /**
  * This function creates a new root node in the specified scope.
  *
  * @access public
  * @static
  * @param integer $scope                            the new scope to be create
  * @param string $name                              the name to given to the node
  * @param array $fields                             an associated array of additional field
  *                                                  name/value pairs
  * @return DB_ORM_MPTT                              the newly created root node
  **/
 public static function add_root($scope, $name, array $fields = NULL)
 {
     $data_source = static::data_source(DB_DataSource::MASTER_INSTANCE);
     $table = static::table();
     $connection = DB_Connection_Pool::instance()->get_connection($data_source);
     $connection->lock->add($table)->acquire();
     $builder = DB_SQL::insert($data_source)->into($table)->column('scope', $scope)->column('name', $name)->column('parent_id', NULL)->column('lft', 1)->column('rgt', 2);
     if (is_array($fields)) {
         foreach ($fields as $field => $value) {
             $builder->column($field, $value);
         }
     }
     $insert = $builder->statement();
     $connection->execute($insert);
     $id = $connection->get_last_insert_id();
     $connection->lock->release();
     $model = get_called_class();
     $root = new $model();
     $root->id = $id;
     $root->scope = $scope;
     $root->name = $name;
     $root->parent_id = NULL;
     $root->lft = 1;
     $root->rgt = 2;
     if (is_array($fields)) {
         foreach ($fields as $field => $value) {
             $root->{$field} = $value;
         }
     }
     return $root;
 }