コード例 #1
0
ファイル: ctrlIndex.php プロジェクト: toppestkek/Test
 function login()
 {
     if (!empty($_POST)) {
         $check = new Check();
         $user = new User();
         $pdo = new Db();
         $db = $pdo->get();
         $mapper = new Mapper($db);
         //Проверяем входные данные
         $user->login = $check->checkInput($_POST['login']);
         $password = $check->checkInput($_POST['pass']);
         $user->password = md5($password);
         //Если пользователь не найден
         $this->user = $mapper->select($user);
         if (empty($this->user)) {
             $this->error = "Пароль или логин не совпадают";
             $this->out('login.php');
         } else {
             $this->out('profile.php');
             //Если найден, выводим профиль
         }
     } else {
         $this->out('login.php');
     }
 }
コード例 #2
0
ファイル: init.php プロジェクト: nowotny/ttrss-wp_fixes
 function init($host)
 {
     $this->host = $host;
     $this->dbh = Db::get();
     $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
     $host->add_hook($host::HOOK_PREFS_TAB, $this);
 }
コード例 #3
0
ファイル: programlist.php プロジェクト: balucio/smac
 public function enumerate($spid = null, $include = self::ALL)
 {
     $rawList = Db::get()->getResultSet("SELECT * FROM elenco_programmi()");
     if (!($include & self::POWEROFF)) {
         unset($rawList[0]);
     }
     if (!($include & self::ANTIFREEZE)) {
         unset($rawList[1]);
     }
     if (!($include & self::MANUAL)) {
         array_pop($rawList);
     }
     $this->list = [];
     $selected = null;
     foreach ($rawList as $v) {
         $k = $v['id_programma'];
         $this->list[$k] = $v;
         if ($selected === null && $spid == $k) {
             $this->list[$k]['selected'] = 'selected';
             $selected = $k;
         } else {
             $this->list[$k]['selected'] = '';
         }
     }
     if ($selected === null && $this->list) {
         $selected = key($this->list);
         $this->list[$selected]['selected'] = 'selected';
     }
     return $selected;
 }
コード例 #4
0
ファイル: init.php プロジェクト: k2s/af_refspoof
 /**
  * Init
  *
  * @param PluginHost $host
  */
 function init($host)
 {
     require_once "PhCURL.php";
     $this->host = $host;
     $this->dbh = Db::get();
     $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
     $host->add_hook($host::HOOK_PREFS_TAB, $this);
 }
コード例 #5
0
ファイル: User.php プロジェクト: rocksyne/wyf
 /**
  * Logs an activity.
  * @param string $activity
  * @param string $data
  */
 public static function log($activity, $data = null)
 {
     $db = Db::get();
     $data = Db::escape(json_encode($data));
     if (ENABLE_AUDIT_TRAILS === true && class_exists("SystemAuditTrailModel", false)) {
         SystemAuditTrailModel::log(array('item_id' => 0, 'item_type' => 'system_activity', 'description' => $activity, 'type' => SystemAuditTrailModel::AUDIT_TYPE_SYSTEM));
     }
 }
コード例 #6
0
ファイル: prefs.php プロジェクト: adrianpietka/bfrss
 function __construct()
 {
     $this->dbh = Db::get();
     $this->cache = array();
     if ($_SESSION["uid"]) {
         $this->cache();
     }
 }
コード例 #7
0
ファイル: User.php プロジェクト: kilya11/spotyfest
 public function __construct($id)
 {
     if (empty($id)) {
         throw new \InvalidArgumentException('Enter User ID');
     }
     $this->id = $id;
     $this->db = Db::get();
 }
コード例 #8
0
ファイル: PgFileStore.php プロジェクト: ekowabaka/cfx
 public static function addData($data)
 {
     $pdo = Db::get();
     $statement = $pdo->prepare("INSERT INTO common.binary_objects(data) VALUES(?)");
     $statement->bindParam(1, $data, PDO::PARAM_LOB);
     $statement->execute();
     $id = Db::query("SELECT LASTVAL()");
     return $id[0]['lastval'];
 }
コード例 #9
0
ファイル: index.php プロジェクト: toppestkek/GuestBook
 function savelike($like, $itemid)
 {
     $pdo = new Db();
     $db = $pdo->get();
     $mapper = new Mapper($db);
     $comments = new Comments();
     $comments->likes = $like;
     $comments->id = $itemid;
     $mapper->saveLike($comments);
 }
コード例 #10
0
ファイル: driverlist.php プロジェクト: balucio/smac
 public function enumerate($selected = 0)
 {
     $selected != $this->selected && ($this->selected = $selected);
     $this->list = [];
     foreach (Db::get()->getResultSet("SELECT id, nome FROM driver_sensori") as $v) {
         $k = $v['id'];
         $this->list[$k] = $v;
         $this->list[$k]['selected'] = $selected == $k ? 'selected' : '';
     }
 }
コード例 #11
0
ファイル: sensorlist.php プロジェクト: balucio/smac
 public function enumerate($status = self::ALL, $selected = 0)
 {
     $selected != $this->selected && ($this->selected = $selected);
     $status != $this->status && ($this->status = $status);
     $this->list = [];
     foreach (Db::get()->getResultSet("SELECT * FROM elenco_sensori(:status)", [':status' => $status]) as $v) {
         $k = $v['id'];
         $this->list[$k] = $v;
         $this->list[$k]['selected'] = $selected == $k ? 'selected' : '';
     }
 }
コード例 #12
0
ファイル: InstallController.php プロジェクト: elvyrra/hawk
 /**
  * Install the application
  */
 public function settings()
 {
     $form = new Form(array('id' => 'install-settings-form', 'labelWidth' => '30em', 'fieldsets' => array('global' => array('legend' => Lang::get('install.settings-global-legend', null, null, $this->language), new TextInput(array('name' => 'title', 'required' => true, 'label' => Lang::get('install.settings-title-label', null, null, $this->language), 'default' => DEFAULT_HTML_TITLE)), new TextInput(array('name' => 'rooturl', 'required' => true, 'label' => Lang::get('install.settings-rooturl-label', null, null, $this->language), 'placeholder' => 'http://', 'default' => getenv('REQUEST_SCHEME') . '://' . getenv('SERVER_NAME'))), new SelectInput(array('name' => 'timezone', 'required' => true, 'options' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'default' => DEFAULT_TIMEZONE, 'label' => Lang::get('install.settings-timezone-label')))), 'database' => array('legend' => Lang::get('install.settings-database-legend', null, null, $this->language), new TextInput(array('name' => 'db[host]', 'required' => true, 'label' => Lang::get('install.settings-db-host-label', null, null, $this->language), 'default' => 'localhost')), new TextInput(array('name' => 'db[username]', 'required' => true, 'label' => Lang::get('install.settings-db-username-label', null, null, $this->language))), new PasswordInput(array('name' => 'db[password]', 'required' => true, 'label' => Lang::get('install.settings-db-password-label', null, null, $this->language), 'pattern' => '/^.*$/')), new TextInput(array('name' => 'db[dbname]', 'required' => true, 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-db-dbname-label', null, null, $this->language))), new TextInput(array('name' => 'db[prefix]', 'default' => 'Hawk', 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-db-prefix-label', null, null, $this->language)))), 'admin' => array('legend' => Lang::get('install.settings-admin-legend', null, null, $this->language), new TextInput(array('name' => 'admin[login]', 'required' => true, 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-admin-login-label', null, null, $this->language))), new EmailInput(array('name' => 'admin[email]', 'required' => true, 'label' => Lang::get('install.settings-admin-email-label', null, null, $this->language))), new PasswordInput(array('name' => 'admin[password]', 'required' => true, 'label' => Lang::get('install.settings-admin-password-label', null, null, $this->language))), new PasswordInput(array('name' => 'admin[passagain]', 'required' => true, 'compare' => 'admin[password]', 'label' => Lang::get('install.settings-admin-passagain-label', null, null, $this->language)))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('install.install-button', null, null, $this->language), 'icon' => 'cog')))), 'onsuccess' => 'location.href = data.rooturl;'));
     if (!$form->submitted()) {
         // Display the form
         $body = View::make(Plugin::current()->getView('settings.tpl'), array('form' => $form));
         return \Hawk\Plugins\Main\MainController::getInstance()->index($body);
     } else {
         // Make the installation
         if ($form->check()) {
             /**
              * Generate Crypto constants
              */
             $salt = Crypto::generateKey(24);
             $key = Crypto::generateKey(32);
             $iv = Crypto::generateKey(16);
             $configMode = 'prod';
             /**
              * Create the database and it tables
              */
             $tmpfile = tempnam(sys_get_temp_dir(), '');
             DB::add('tmp', array(array('host' => $form->getData('db[host]'), 'username' => $form->getData('db[username]'), 'password' => $form->getData('db[password]'))));
             try {
                 DB::get('tmp');
             } catch (DBException $e) {
                 return $form->response(Form::STATUS_ERROR, Lang::get('install.install-connection-error'));
             }
             try {
                 $param = array('{{ $dbname }}' => $form->getData('db[dbname]'), '{{ $prefix }}' => $form->getData('db[prefix]'), '{{ $language }}' => $this->language, '{{ $timezone }}' => $form->getData('timezone'), '{{ $title }}' => Db::get('tmp')->quote($form->getData('title')), '{{ $email }}' => Db::get('tmp')->quote($form->getData('admin[email]')), '{{ $login }}' => Db::get('tmp')->quote($form->getData('admin[login]')), '{{ $password }}' => Db::get('tmp')->quote(Crypto::saltHash($form->getData('admin[password]'), $salt)), '{{ $ip }}' => Db::get('tmp')->quote(App::request()->clientIp()));
                 $sql = strtr(file_get_contents(Plugin::current()->getRootDir() . 'templates/install.sql.tpl'), $param);
                 // file_put_contents($tmpfile, $sql);
                 Db::get('tmp')->query($sql);
                 /**
                  * Create the config file
                  */
                 $param = array('{{ $salt }}' => addcslashes($salt, "'"), '{{ $key }}' => addcslashes($key, "'"), '{{ $iv }}' => addcslashes($iv, "'"), '{{ $configMode }}' => $configMode, '{{ $rooturl }}' => $form->getData('rooturl'), '{{ $host }}' => $form->getData('db[host]'), '{{ $username }}' => $form->getData('db[username]'), '{{ $password }}' => $form->getData('db[password]'), '{{ $dbname }}' => $form->getData('db[dbname]'), '{{ $prefix }}' => $form->getData('db[prefix]'), '{{ $sessionEngine }}' => $form->getData('session'), '{{ $version }}' => $form->getData('version'));
                 $config = strtr(file_get_contents(Plugin::current()->getRootDir() . 'templates/config.php.tpl'), $param);
                 file_put_contents(INCLUDES_DIR . 'config.php', $config);
                 /**
                  * Create etc/dev.php
                  */
                 App::fs()->copy(Plugin::current()->getRootDir() . 'templates/etc-dev.php', ETC_DIR . 'dev.php');
                 /**
                  * Create etc/prod.php
                  */
                 App::fs()->copy(Plugin::current()->getRootDir() . 'templates/etc-prod.php', ETC_DIR . 'prod.php');
                 $form->addReturn('rooturl', $form->getData('rooturl'));
                 return $form->response(Form::STATUS_SUCCESS, Lang::get('install.install-success'));
             } catch (\Exception $e) {
                 return $form->response(Form::STATUS_ERROR, Lang::get('install.install-error'));
             }
         }
     }
 }
コード例 #13
0
ファイル: init.php プロジェクト: Verisor/tt-rss
 function init($host)
 {
     require_once __DIR__ . "/lib/class.naivebayesian.php";
     //require_once __DIR__ . "/lib/class.naivebayesian_ngram.php";
     require_once __DIR__ . "/lib/class.naivebayesianstorage.php";
     $this->host = $host;
     $this->dbh = Db::get();
     $this->init_database();
     $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
     $host->add_hook($host::HOOK_PREFS_TAB, $this);
     $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
 }
コード例 #14
0
 public function getAclResources($id)
 {
     $res = Db::get("SELECT * FROM [prefix]user_groups_to_acl_resources WHERE `user-group-id`=:userGroupId", array(':userGroupId' => $id));
     $groups = array();
     if ($res !== false) {
         if (count($res) > 0) {
             foreach ($res as $row) {
                 $groups[] = $row['acl-resource-id'];
             }
         }
     }
     return $groups;
 }
コード例 #15
0
ファイル: sql.php プロジェクト: XelaRellum/tt-rss
 function log_error($errno, $errstr, $file, $line, $context)
 {
     if (Db::get() && get_schema_version() > 117) {
         $errno = Db::get()->escape_string($errno);
         $errstr = Db::get()->escape_string($errstr);
         $file = Db::get()->escape_string($file);
         $line = Db::get()->escape_string($line);
         $context = DB::get()->escape_string($context);
         $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
         $result = Db::get()->query("INSERT INTO ttrss_error_log\n\t\t\t\t(errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES\n\t\t\t\t({$errno}, '{$errstr}', '{$file}', '{$line}', '{$context}', {$owner_uid}, NOW())");
         return Db::get()->affected_rows($result) != 0;
     }
     return false;
 }
コード例 #16
0
ファイル: sensorstats.php プロジェクト: balucio/smac
 public function reportMisurazioni()
 {
     if ($this->status !== self::$MIS_REPORT_OK) {
         return null;
     }
     $query = "SELECT EXTRACT(epoch FROM data_ora) * 1000," . "({$this->physicalQt})::numeric(5,2) FROM " . "report_misurazioni(?::smallint, ?::timestamp, ?::timestamp)";
     // d($query, $this->sensorId, $this->start_date, $this->end_date);
     $stmt = Db::get()->prepare($query);
     $stmt->bindParam(1, $this->sensorId, PDO::PARAM_INT);
     $stmt->bindParam(2, $this->start_date, PDO::PARAM_STR);
     $stmt->bindParam(3, $this->end_date, PDO::PARAM_STR);
     $stmt->execute();
     return $stmt->fetchAll(PDO::FETCH_NUM);
 }
コード例 #17
0
ファイル: sql.php プロジェクト: Verisor/tt-rss
 function log_error($errno, $errstr, $file, $line, $context)
 {
     if (Db::get() && get_schema_version() > 117) {
         $errno = Db::get()->escape_string($errno);
         $errstr = Db::get()->escape_string($errstr);
         $file = Db::get()->escape_string($file);
         $line = Db::get()->escape_string($line);
         $context = '';
         // backtrace is a lot of data which is not really critical to store
         //$context = $this->dbh->escape_string(serialize($context));
         $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
         $result = Db::get()->query("INSERT INTO ttrss_error_log\n\t\t\t\t(errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES\n\t\t\t\t({$errno}, '{$errstr}', '{$file}', '{$line}', '{$context}', {$owner_uid}, NOW())");
         return Db::get()->affected_rows($result) != 0;
     }
     return false;
 }
コード例 #18
0
 public function getAssignedConntectedDataTableRows($row_id, $connection_id)
 {
     $connected_data_table = $this->getConnectedDataTableById($connection_id);
     if ($connected_data_table !== false) {
         $row_id = intval($row_id);
         $rows = Db::get("SELECT * FROM [prefix]" . $connected_data_table['dbTable'] . " WHERE `" . $connected_data_table['dbKeySelf'] . "` = :rowId", array(':rowId' => $row_id));
         $id_list = array();
         if ($rows !== false) {
             if (count($rows) > 0) {
                 foreach ($rows as $row) {
                     if (isset($row[$connected_data_table['dbKeyForeign']])) {
                         $id_list[] = intval($row[$connected_data_table['dbKeyForeign']]);
                     }
                 }
             }
         }
         return $id_list;
     }
     return false;
 }
コード例 #19
0
ファイル: Update.php プロジェクト: siite/choose-sa-cloud
 /**
  *
  */
 public static function cleanup()
 {
     // remove database tmp table
     $db = Db::get();
     $db->query("DROP TABLE IF EXISTS `" . self::$tmpTable . "`");
     //delete tmp data
     recursiveDelete(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update", true);
 }
コード例 #20
0
                $feed_id = (int) $line["feed_id"];
            }
            $filter["enabled"] = $line["enabled"] ? "on" : "off";
            $filter["rule"] = array(json_encode(array("reg_exp" => $line["reg_exp"], "feed_id" => $feed_id, "filter_type" => $line["filter_type"])));
            $filter["action"] = array(json_encode(array("action_id" => $line["action_id"], "action_param_label" => $line["action_param"], "action_param" => $line["action_param"])));
            // Oh god it's full of hacks
            $_REQUEST = $filter;
            $_SESSION["uid"] = $owner_uid;
            $filters = new Pref_Filters($_REQUEST);
            $filters->add();
        }
    }
}
if (isset($options["update-schema"])) {
    _debug("checking for updates (" . DB_TYPE . ")...");
    $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
    if ($updater->isUpdateRequired()) {
        _debug("schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION);
        _debug("WARNING: please backup your database before continuing.");
        _debug("Type 'yes' to continue.");
        if (read_stdin() != 'yes') {
            exit;
        }
        for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
            _debug("performing update up to version {$i}...");
            $result = $updater->performUpdateTo($i);
            _debug($result ? "OK!" : "FAILED!");
            if (!$result) {
                return;
            }
        }
コード例 #21
0
ファイル: pluginhost.php プロジェクト: zamentur/ttrss_ynh
 function __construct()
 {
     $this->dbh = Db::get();
     $this->storage = array();
 }
コード例 #22
0
ファイル: switcher.php プロジェクト: balucio/smac
 public function report_commutazioni($start = null, $end = null)
 {
     $this->result = Db::get()->getResultSet("SELECT date_trunc('minutes', inizio) inizio," . " extract(EPOCH FROM durata) durata, stato" . " FROM report_commutazioni(:start, :end)", [':start' => $start, ':end' => $end]);
 }
コード例 #23
0
ファイル: db.php プロジェクト: kucrut/tt-rss
function db_quote($str)
{
    return Db::get()->quote($str);
}
コード例 #24
0
ファイル: BaseRecord.php プロジェクト: AndraD1/ActiveRecord
 /**
  * Obtiene manejador de conexion a la base de datos
  *
  * @param  boolean $force forzar nueva conexion PDO
  * @return \PDO
  */
 protected static function dbh($force = false)
 {
     return Db::get(static::getDatabase(), $force);
 }
コード例 #25
0
ファイル: Postgresql.php プロジェクト: rocksyne/wyf
 public function __wakeup()
 {
     if (!is_resource(self::$_conn)) {
         self::$_conn = Db::get();
     }
 }
コード例 #26
0
ファイル: init.php プロジェクト: stesie/ttbag
 function init($host)
 {
     $this->host = $host;
     $this->dbh = Db::get();
     $host->add_handler("public", "sharepopup", $this);
 }
コード例 #27
0
ファイル: handler.php プロジェクト: XelaRellum/tt-rss
 function __construct($args)
 {
     $this->dbh = Db::get();
     $this->args = $args;
 }
コード例 #28
0
ファイル: Db.php プロジェクト: ekowabaka/wyf
 public static function getCachedInstance($connection = null)
 {
     if (isset(Db::$instances[$connection])) {
         return Db::$instances[$connection];
     } else {
         return Db::get($connection, false);
     }
 }
コード例 #29
0
ファイル: Profiler.php プロジェクト: pombredanne/ArcherSys
 /**
  * Get total number of queries
  *
  * @return int  number of queries
  */
 public static function getQueryCount()
 {
     $profiler = Db::get()->getProfiler();
     return $profiler->getTotalNumQueries();
 }
コード例 #30
0
    function dbupdate()
    {
        startup_gettext();
        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
            render_login_form();
            exit;
        }
        ?>
<html>
			<head>
			<title>Database Updater</title>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			<link rel="stylesheet" type="text/css" href="css/utility.css"/>
			</head>
			<style type="text/css">
				span.ok { color : #009000; font-weight : bold; }
				span.err { color : #ff0000; font-weight : bold; }
			</style>
		<body>
			<script type='text/javascript'>
			function confirmOP() {
				return confirm("Update the database?");
			}
			</script>

			<div class="floatingLogo"><img src="images/logo_small.png"></div>

			<h1><?php 
        echo __("Database Updater");
        ?>
</h1>

			<div class="content">

			<?php 
        @($op = $_REQUEST["subop"]);
        $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
        if ($op == "performupdate") {
            if ($updater->isUpdateRequired()) {
                print "<h2>Performing updates</h2>";
                print "<h3>Updating to schema version " . SCHEMA_VERSION . "</h3>";
                print "<ul>";
                for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
                    print "<li>Performing update up to version {$i}...";
                    $result = $updater->performUpdateTo($i);
                    if (!$result) {
                        print "<span class='err'>FAILED!</span></li></ul>";
                        print_warning("One of the updates failed. Either retry the process or perform updates manually.");
                        print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t\t\t</form>";
                        break;
                    } else {
                        print "<span class='ok'>OK!</span></li>";
                    }
                }
                print "</ul>";
                print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            } else {
                print "<h2>Your database is up to date.</h2>";
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        } else {
            if ($updater->isUpdateRequired()) {
                print "<h2>Database update required</h2>";
                print "<h3>";
                printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.", $updater->getSchemaVersion(), SCHEMA_VERSION);
                print "</h3>";
                print_warning("Please backup your database before proceeding.");
                print "<form method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='subop' value='performupdate'>\n\t\t\t\t\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t\t\t\t</form>";
            } else {
                print_notice("Tiny Tiny RSS database is up to date.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        }
        ?>

			</div>
			</body>
			</html>
		<?php 
    }