private function addPoint()
 {
     $user = new User($this->getData());
     if ($this->get("group_id") == self::$CLOSED_GROUP) {
         $timeout = self::$CLOSED_GROUP_TIMEOUT;
     } else {
         $timeout = self::$OPEN_GROUP_TIMEOUT;
     }
     if ($user->isReadOnly()) {
         $this->noRightsError();
     } else {
         if (time() - $user->getLastCreate()->getTimeStamp() < $timeout && !$user->isModerator()) {
             $this->timeOutError(round((time() - $user->getLastCreate()->getTimeStamp()) / 60));
         } else {
             $userId = $this->get('userid');
             $db = new DB();
             $query = 'INSERT INTO mototimes_events (userid, lat, lng, alignment, transport, text) VALUES(?,?,?,?,?,?)';
             $stmt = $db->prepare($query);
             $stmt->bind_param('iddiis', $userId, $this->get('lat'), $this->get('lng'), $this->get('alignment'), $this->get('transport'), $this->get('text'));
             $stmt->execute();
             if ($stmt->errno != 0) {
                 $this->unknownError();
             } else {
                 $query = 'UPDATE mototimes_users SET last_create = NOW() WHERE id_vk=?';
                 $stmt = $db->prepare($query);
                 $stmt->bind_param('i', $userId);
                 $stmt->execute();
                 $result = array('response' => 'ok');
                 $this->setResult($result);
             }
         }
     }
 }
Exemplo n.º 2
0
 public function delete($id)
 {
     $sql = "DELETE FROM cadastro_funcionario WHERE id = :id";
     $stmt = DB::prepare($sql);
     $stmt->bindParam(':id', $id, PDO::PARAM_INT);
     return $stmt->execute();
 }
 protected function makeRelation($concepto, $parent)
 {
     if ($this->sthExistsRel == null) {
         $query = "SELECT count(*) as count FROM relaciones_maestros WHERE id_inf = ? AND id_sup = ? ";
         $this->sthExistsRel = DB::prepare($query);
     }
     $objCount = DB::executeFetch($this->sthExistsRel, array($concepto->id, $parent->id));
     if ($objCount->count == 1) {
         // ya existe la relación no se agrega.
         return false;
     }
     if ($this->sthInsertRel == null) {
         $query = "INSERT INTO relaciones_maestros (id_sup,id_inf,cantidad,factor,custom_nombre) values (?,?,?,?,?) ";
         $this->sthInsertRel = DB::prepare($query);
     }
     $params = array();
     $params[] = $parent->id;
     $params[] = $concepto->id;
     $params[] = $concepto->cantidad;
     $params[] = $concepto->factor;
     $params[] = isset($concepto->custom_nombre) ? $concepto->custom_nombre : '';
     $this->sthInsertRel->execute($params);
     //echo 'se creo relacion '. $concepto->id . ' ---> '. $parent->id .'\n<br/>' ;
     return true;
 }
Exemplo n.º 4
0
	public function get($ID)
	{
		$q = DB::prepare('SELECT * FROM MeCommentMockComment NATURAL JOIN Comment WHERE Comment.ID=:ID');
		$q->execute(array(':ID' => $ID));
		
		return self::fetch($q->fetch(), 'MeCommentMockComment');
	}
Exemplo n.º 5
0
	public function get($name)
	{
		$q = DB::prepare('SELECT * FROM Bar WHERE ID=:ID');
		$q->execute(array(':ID' => $name));
		
		return self::fetch($q->fetch(), 'Bar');
	}
Exemplo n.º 6
0
	public function get($username)
	{
		$q = DB::prepare('SELECT * FROM UserProfile WHERE username=:username');
		$q->execute(array(':username' => $username));
		
		return self::fetch($q->fetch(), 'UserProfile');
	}
Exemplo n.º 7
0
 /**
  * Write out the tags for a specific resource.
  *
  * @param int    $resource_id    The story we are tagging.
  * @param int    $channel_id     The channel id for the story we are tagging
  * @param array  $tags           An array of tags.
  *
  * @TODO: Move this to a tagger class that uses Content_Tagger
  * @return boolean
  * @throws Jonah_Exception
  */
 public function writeTags($resource_id, $channel_id, $tags)
 {
     global $conf;
     // First, make sure all tag names exist in the DB.
     $tagkeys = array();
     $insert = $this->_db->prepare('INSERT INTO jonah_tags (tag_id, tag_name) VALUES(?, ?)');
     $query = $this->_db->prepare('SELECT tag_id FROM jonah_tags WHERE tag_name = ?');
     foreach ($tags as $tag) {
         $tag = Horde_String::lower(trim($tag));
         $results = $this->_db->execute($query, $this->_db->escapeSimple($tag));
         if ($results instanceof PEAR_Error) {
             throw new Jonah_Exception($results);
         } elseif ($results->numRows() == 0) {
             $id = $this->_db->nextId('jonah_tags');
             $result = $this->_db->execute($insert, array($id, $tag));
             $tagkeys[] = $id;
         } else {
             $row = $results->fetchRow(DB_FETCHMODE_ASSOC);
             $tagkeys[] = $row['tag_id'];
         }
     }
     // Free our resources.
     $this->_db->freePrepared($insert, true);
     $this->_db->freePrepared($query, true);
     $sql = 'DELETE FROM jonah_stories_tags WHERE story_id = ' . (int) $resource_id;
     $query = $this->_db->prepare('INSERT INTO jonah_stories_tags (story_id, channel_id, tag_id) VALUES(?, ?, ?)');
     Horde::log('SQL query by Jonah_Driver_sql::writeTags: ' . $sql, 'DEBUG');
     $this->_db->query($sql);
     foreach ($tagkeys as $key) {
         $this->_db->execute($query, array($resource_id, $channel_id, $key));
     }
     $this->_db->freePrepared($query, true);
     /* @TODO We should clear at least any of our cached counts */
     return true;
 }
 public function indexAction()
 {
     //get the aff_camapaign_id
     $mysql['use_pixel_payout'] = 0;
     //see if it has the cookie in the campaign id, then the general match, then do whatever we can to grab SOMETHING to tie this lead to
     if ($_COOKIE['btclickid']) {
         $click_pid = $_COOKIE['btclickid'];
     } else {
         //ok grab the last click from this ip_id
         $mysql['ip_address'] = DB::quote($_SERVER['REMOTE_ADDR']);
         $daysago = time() - 2592000;
         // 30 days ago
         $click_sql1 = "\tSELECT \tbt_s_clicks.click_id\n\t\t\t\t\t\t\tFROM \t\tbt_s_clicks\n\t\t\t\t\t\t\tLEFT JOIN\tbt_s_clicks_advanced USING (click_id)\n\t\t\t\t\t\t\tLEFT JOIN \tbt_s_ips USING (ip_id)\n\t\t\t\t\t\t\tWHERE \tbt_s_ips.ip_address='" . $mysql['ip_address'] . "'\n\t\t\t\t\t\t\tAND\t\tbt_s_clicks.time >= '" . $daysago . "'\n\t\t\t\t\t\t\tORDER BY \tbt_s_clicks.click_id DESC\n\t\t\t\t\t\t\tLIMIT \t\t1";
         $click_row1 = DB::getRow($click_sql1);
         $click_pid = base_convert($click_row1['click_id'], 10, 36);
         $mysql['ad_account_id'] = DB::quote($click_row1['ad_account_id']);
     }
     $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => base_convert($click_pid, 36, 10))));
     if (!$click) {
         BTApp::end();
     }
     if ($click->get('ad_account_id')) {
         if (getArrayVar($_GET, 'amount') && is_numeric($_GET['amount'])) {
             $mysql['use_pixel_payout'] = 1;
         }
         if ($mysql['use_pixel_payout'] == 1) {
             $click->convert(0, $_GET['amount']);
         } else {
             $click->convert();
         }
         if ($click->campaign->option('pixel_type')->value) {
             $sql = "select v1.var_value as v1, v2.var_value as v2, v3.var_value as v3, v4.var_value as v4 from bt_s_clicks_advanced adv\n\t\t\t\t\tleft join bt_s_variables v1 on (v1.var_id=adv.v1_id)\n\t\t\t\t\tleft join bt_s_variables v2 on (v2.var_id=adv.v2_id)\n\t\t\t\t\tleft join bt_s_variables v3 on (v3.var_id=adv.v3_id)\n\t\t\t\t\tleft join bt_s_variables v4 on (v4.var_id=adv.v4_id)\n\t\t\t\t\twhere adv.click_id=?";
             $st = DB::prepare($sql);
             $st->execute(array($click->id()));
             $row = $st->fetch();
             $data['v1'] = $row['v1'];
             $data['v2'] = $row['v2'];
             $data['v3'] = $row['v3'];
             $data['v4'] = $row['v4'];
             $data['clickid'] = $click->id();
             $data['keyword'] = '';
             $data['amount'] = $click->payout;
             $code = replaceTrackerPlaceholders($click->campaign->option('pixel_code')->value, $data);
             $code = str_replace('[[amount]]', $data['amount'], $code);
             switch ($click->campaign->option('pixel_type')->value) {
                 case 1:
                 case 2:
                 case 3:
                     echo $code;
                     break;
                 case 4:
                     $ch = curl_init($code);
                     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 Postback-Bot v1.0');
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                     curl_exec($ch);
                     break;
             }
         }
     }
 }
Exemplo n.º 9
0
 public function delete($id)
 {
     $sql = "DELETE FROM {$this->table} WHERE id = :id";
     $stmt = DB::prepare($sql);
     $stmt->bindParam(':id', $id, PDO::PARAM_INT);
     return $stmt->execute();
 }
Exemplo n.º 10
0
	public function get($ID)
	{
		$q = DB::prepare('Select * FROM AnonProfile WHERE ID=:ID');
		$q->execute(array(':ID' => $ID));
		
		return self::fetch($q->fetch(), 'AnonProfile');
	}
 public static function createPGPKey($username, $password)
 {
     // Can't create a pgp key without a name or a password.
     // Also, if they shouldn't have a whitespace in their name but if they do somehow it could be an exploit.
     if (empty($username) || empty($password)) {
         return false;
     } elseif (preg_match('/(\\s|\\n|\\r|\\/|\\.)/', $username) || preg_match('/\\s\\n\\r/', $password)) {
         trigger_error("{$username} attempted exploit! - PGP Key creation");
         return false;
     }
     // Create batch script for user.
     // RSA Keys
     // 2048 bit
     file_put_contents("/tmp/{$username}", "Key-Type: default\n\t\t\tSubkey-Type: default\n\t\t\tName-Real: {$username}\n\t\t\tName-Comment: generated key for securechatty\n\t\t\tName-Email: noreply@securechatty.com\n\t\t\tExpire-Date: 0\n\t\t\tPassphrase: {$password}\n\t\t\t%pubring /tmp/{$username}.pub\n\t\t\t%secring /tmp/{$username}.sec\n\t\t\t%commit");
     // Create the keys
     $file = escapeshellarg('/tmp/' . $username);
     exec("gpg2 --gen-key --batch {$file}");
     // Retrieve the keys
     $publickey = file_get_contents("/tmp/{$username}.pub");
     $privatekey = file_get_contents("/tmp/{$username}.sec");
     // Remove all unneeded files.
     unlink("/tmp/{$username}");
     unlink("/tmp/{$username}.pub");
     unlink("/tmp/{$username}.sec");
     if (empty($publickey) || empty($privatekey)) {
         trigger_error("Key generation failed for {$username}!");
         return false;
     }
     $db = new DB();
     $update = $db->prepare("UPDATE users SET\n\t\t\t\tpublickey = :publickey,\n\t\t\t\tprivatekey = :privatekey\n\t\t\t WHERE username = :username");
     $update->execute(array(':publickey' => $publickey, ':privatekey' => $privatekey, ':username' => $username));
     return true;
 }
Exemplo n.º 12
0
function getDBUsage($domainID)
{
    $dbSize = 0;
    // get database information for given domain
    $sql_param = array(':domain_id' => $domainID);
    $sql_query = "\n\t\t\tSELECT\n\t\t\t\tsqld_id, sqld_name\n\t\t\tFROM\n\t\t\t\tsql_database\n\t\t\tWHERE\n\t\t\t\tdomain_id = :domain_id\n\t\t";
    DB::prepare($sql_query);
    $sqlData = DB::execute($sql_param);
    // get usage for each database
    $sql_query = '
			SELECT 
				sum(data_length + index_length) size
			FROM 
				information_schema.tables 
			WHERE 
				table_schema = :table_schema
			GROUP BY 
				table_schema
	';
    while ($row = $sqlData->fetch()) {
        $sql_param = array(':table_schema' => $row['sqld_name']);
        DB::prepare($sql_query);
        $sqlSize = DB::execute($sql_param, true);
        $dbSize += $sqlSize[0];
    }
    return $dbSize;
}
Exemplo n.º 13
0
 public function delete($id)
 {
     $qry = "DELETE FROM {$this->tabela} WHERE id = :id";
     $stm = DB::prepare($qry);
     $stm->bindParam(':id', $id, PDO::PARAM_INT);
     return $stm->execute();
 }
Exemplo n.º 14
0
function menu_delete_db()
{
	$s = DB::prepare('DROP TABLE IF EXISTS MenuEntry');
	$s->execute();
	$s = DB::prepare('DROP TABLE IF EXISTS Menu');
	$s->execute();
}
Exemplo n.º 15
0
	private function findFree()
	{
		$args = array();
		$wheres = array();
		foreach ($this->_fixed as $fix)
		{
			$fixDB = $fix.'_db';
			$args[':'.$fix] = $this->_object->$fixDB;
			$wheres[] = $fix.'=:'.$fix;
		}
		$wheres[] = $this->_normalized .'=:_a';
		$q = DB::prepare('SELECT * FROM ' . $this->_class . ' WHERE '. implode(' AND ', $wheres));
		
		$f = $this->_toNormalize;
		$base = $this->normalize($this->_object->$f);
		$i = 0;
		$full = $base;
		$args[':_a'] = $full;
		$q->execute($args);
		while ($q->fetch())
		{
			$i++;
			$full = $base.$i;
			$args[':_a'] = $full;
			$q->execute($args);
		}
		return $full;
	}
Exemplo n.º 16
0
function check_login()
{
    global $db, $mem;
    if (defined('MEM') && MEM == True) {
        $mem = new Memcached('moyoj');
        $mem->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
        if (!count($mem->getServerList())) {
            $mem->addServer(MEM_HOST, MEM_PORT);
        }
    }
    $db = new DB();
    $db->init(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    $db->connect();
    $admin_info = mo_read_cache('mo-admin-' . $_SESSION['aid']);
    if (!$admin_info) {
        $sql = 'SELECT `id`, `username`, `password`, `nickname`, `role` FROM `mo_admin` WHERE `id` = ? AND `role` > 0';
        $db->prepare($sql);
        $db->bind('i', $_SESSION['aid']);
        $result = $db->execute();
        if (!$result || $result[0]['password'] != $_SESSION['admin_password']) {
            unset($_SESSION['aid']);
            header("Location: login.php");
            exit(0);
        }
        mo_write_cache('mo-admin-' . $_SESSION['aid'], $result[0]);
    }
    $mo_settings = array();
    mo_load_settings();
    if (!isset($active)) {
        $active = '';
    }
}
Exemplo n.º 17
0
 /**
  * @return mixed
  */
 public static function CreatePDNSPass()
 {
     System_Daemon::debug('Starting "DaemonConfigDNS::createPDNSPass" subprocess.');
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_DNS.xml');
     System_Daemon::debug('Building the new pdns config file');
     $xml->{'PDNS_USER'} = 'powerdns';
     $xml->{'PDNS_PASS'} = DB::encrypt_data(DaemonCommon::generatePassword(18));
     $xml->{'HOSTNAME'} = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_DNS.xml', "wb");
     fwrite($handle, $xml->asXML());
     fclose($handle);
     DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_DNS.xml', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0640);
     // Create/Update Powerdns control user account if needed
     System_Daemon::debug('Adding the PowerDNS control user');
     $sql_param = array(':PDNS_USER' => $xml->{'PDNS_USER'}, ':PDNS_PASS' => DB::decrypt_data($xml->{'PDNS_PASS'}), ':HOSTNAME' => $xml->{'HOSTNAME'});
     $sql_query = "\n\t\t\tGRANT ALL PRIVILEGES ON powerdns.* TO :PDNS_USER@:HOSTNAME IDENTIFIED BY :PDNS_PASS;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     $sql_param = array(':DATABASE_USER' => DaemonConfig::$cfg->DATABASE_USER, ':DATABASE_HOST' => idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'}));
     $sql_query = "\n\t\t\tGRANT ALL PRIVILEGES ON powerdns.* TO :DATABASE_USER@:DATABASE_HOST;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     System_Daemon::debug('Finished "DaemonConfigDNS::createPDNSPass" subprocess.');
     return true;
 }
Exemplo n.º 18
0
 public function changeKarma()
 {
     if ($this->isError()) {
         return false;
     }
     $this->setPrerequisites('karma');
     $this->checkPrerequisites();
     if ($this->isError()) {
         return false;
     }
     $user = new User($this->getData());
     if (!$user->isModerator()) {
         $this->setUpError("NO RIGHTS");
         return false;
     }
     $karma = $this->karma + $this->get('karma');
     $db = new DB();
     $query = 'UPDATE mototimes_events SET karma=? WHERE id=?';
     $stmt = $db->prepare($query);
     $stmt->bind_param('ii', $karma, $this->id);
     $stmt->execute();
     if ($stmt->errno) {
         $this->setUpError();
     } else {
         $result = array('response' => 'ok');
         $this->setResult($result);
     }
     return true;
 }
Exemplo n.º 19
0
 /**
  * @return mixed
  */
 public static function CreateProFTPdPass()
 {
     System_Daemon::debug('Starting "DaemonConfigFTP::CreateProFTPdPass" subprocess.');
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_FTP.xml');
     System_Daemon::debug('Building the new ftp config file');
     $xml->{'DB_DATABASE'} = DB::$DB_DATABASE;
     $xml->{'DB_HOST'} = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $xml->{'FTP_USER'} = 'vftp';
     $xml->{'FTP_PASSWORD'} = DB::encrypt_data(DaemonCommon::generatePassword(18));
     $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml', "wb");
     fwrite($handle, $xml->asXML());
     fclose($handle);
     System_Daemon::debug('Create/Update Proftpd SQL user data');
     $sql_param = array(':DATABASE_HOST' => $xml->{'DB_HOST'}, ':FTP_USER' => $xml->{'FTP_USER'}, ':FTP_PASSWORD' => DB::decrypt_data($xml->{'FTP_PASSWORD'}));
     $sql_query = "\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_group TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_log TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_users TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON quotalimits TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON quotatallies TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     /*
     
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'ROOT_DIR'} . '/../setup/config.xml');
     
     System_Daemon::debug('Create/Update Proftpd SQL user data');
     
     $sql_param = array(
     	':DATABASE_HOST'=> $xml->{'DB_HOST'},
     	':FTP_USER'		=> $xml->{'FTP_USER'},
     	':FTP_PASSWORD'	=> $xml->{'FTP_PASSWORD'}
     );
     
     $sql_query = "
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_group TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_log TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_users TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON quotalimits TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON quotatallies TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	FLUSH PRIVILEGES;
     ";
     
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     
     if (!file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml')) {
     	$ftp = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_FTP.xml');
     
     	System_Daemon::debug('Building the new ftp config file');
     
     	$ftp->{'DB_DATABASE'}	= $xml->{'DB_DATABASE'};
     	$ftp->{'DB_HOST'}		= $xml->{'DB_HOST'};
     	$ftp->{'FTP_USER'}		= $xml->{'FTP_USER'};
     	$ftp->{'FTP_PASSWORD'}	= DB::encrypt_data($xml->{'FTP_PASSWORD'});
     
     	$handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml', "wb");
     	fwrite($handle, $ftp->asXML());
     	fclose($handle);
     }
     */
     System_Daemon::debug('Finished "DaemonConfigFTP::CreateProFTPdPass" subprocess.');
     return true;
 }
Exemplo n.º 20
0
 public static function enqueue(DB $db, $handler, array $message)
 {
     if (!isset(self::$handlers[$handler])) {
         throw new UnexpectedValueException('Unsupported handler (' . $handler . ').');
     }
     $prepared = $db->prepare("\n\t\t\tINSERT INTO `jobs` (\n\t\t\t\t`handler`,\n\t\t\t\t`status`,\n\t\t\t\t`message`\n\t\t\t) VALUES (\n\t\t\t\t:handler,\n\t\t\t\t:status,\n\t\t\t\t:message\n\t\t\t)\n\t\t");
     $result = $prepared->execute([':handler' => $handler, ':status' => self::QUEUED, ':message' => JSON::encode($message)]);
 }
Exemplo n.º 21
0
 /**
  * Prepares a query for multiple execution with the get methods
  *
  * Creates a query that can be run multiple times.  Each time it is run,
  * the placeholders, if any, will be replaced by the contents of
  * get methods $data arguement.
  * 
  * Get methods are: getOne, getAll, getColumn, getRow
  *
  * Three types of placeholders can be used:
  *   + <kbd>?</kbd>  scalar value (i.e. strings, integers).  The system
  *                   will automatically quote and escape the data.
  *   + <kbd>!</kbd>  value is inserted 'as is'
  *   + <kbd>&</kbd>  requires a file name.  The file's contents get
  *                   inserted into the query (i.e. saving binary
  *                   data in a db)
  *
  * Example 1.
  * <code>
  * $sth = $db->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)');
  * $data = array(
  *     "John's text",
  *     "'it''s good'",
  *     'filename.txt'
  * );
  * $res = $db->getAll($sth, $data);
  * </code>
  *
  * Use backslashes to escape placeholder characters if you don't want
  * them to be interpreted as placeholders:
  * <pre>
  *    "UPDATE foo SET col=? WHERE col='over \& under'"
  * </pre>
  *
  * With some database backends, this is emulated.
  *
  * <b>This documentation was taken from: http://pear.php.net/package/DB/docs/1.7.6/DB/DB_common.html#methodprepare and modified</b>
  *
  * @param string $sql  the query to be prepared
  *
  * @throws An exception in the event of an error
  */
 public function prepare($sql)
 {
     $result = $this->conn->prepare($sql);
     if (DB::isError($result)) {
         throw new LoggedException($result->getMessage(), $result->getCode(), self::module);
     }
     return $result;
 }
 public function findUsuariofetchAll($id_usuario)
 {
     $sql = "SELECT id_usuario, status, permissao FROM {$this->table} WHERE id_usuario = :id_usuario";
     $stmt = DB::prepare($sql);
     $stmt->bindParam(':id_usuario', $id_usuario, PDO::PARAM_INT);
     $stmt->execute();
     return count($stmt->fetchAll()) > 0;
 }
Exemplo n.º 23
0
 function get_listAll()
 {
     $sql = "SELECT * FROM fornecedores";
     $stmt = DB::prepare($sql);
     $stmt->execute();
     $result = $stmt->fetchAll();
     return $result;
 }
Exemplo n.º 24
0
 /**
  * Remove uma resposta
  * @param  int $id ID da resposta
  * @return bool   TRUE em caso de sucesso, FALSE em falhas
  */
 public static function delete($id)
 {
     $DB = new \DB();
     $sql = "DELETE FROM answers WHERE id = :id";
     $stmt = $DB->prepare($sql);
     $stmt->bindParam(':id', $id, \PDO::PARAM_INT);
     return $stmt->execute();
 }
Exemplo n.º 25
0
 public function delete($montadora)
 {
     DB::beginTransaction();
     $smtm = DB::prepare($this->sqlDelete);
     $smtm->bindParam("ID", $montadora->id);
     $smtm->execute();
     DB::commit();
 }
Exemplo n.º 26
0
 public function update($id)
 {
     $sql = "UPDATE {$this->table} SET nome = ?, email = ? WHERE id = ?";
     $stmt = DB::prepare($sql);
     $stmt->bindParam(1, $this->usuario);
     $stmt->bindParam(2, $this->senha);
     $stmt->bindParam(3, $id);
     return $stmt->execute();
 }
Exemplo n.º 27
0
 function __construct()
 {
     $query = "SELECT * FROM subfamilias WHERE id_familia = ? and id_parent is null ORDER BY nombre";
     $this->sthSubFamOfF = DB::prepare($query);
     $query = "SELECT * FROM subfamilias WHERE id_parent = ? ORDER BY nombre";
     $this->sthSubFam = DB::prepare($query);
     $query = "select c.nombre,c.nombre_feed, c.minimo,c.maximo, " . "\ttmp.id as tmp_id, tmp.precio as tmp_precio,tmp.date as tmp_date, " . "  tmp.minimo as tmp_minimo, tmp.maximo as tmp_maximo  " . " FROM conceptos_maestros  c " . " LEFT JOIN precios_insumos_tmp as tmp on tmp.id_concepto_maestro = c.id " . " WHERE c.tipo = 3 AND c.feed = 1 " . "\tAND c.id in (select DISTINCT id_concepto FROM conceptos_subfamilias_maestros where id_subfamilia = ?) ";
     $this->sthInsumosFam = DB::prepare($query);
 }
Exemplo n.º 28
0
 public function update($id)
 {
     $sql = "UPDATE {$this->table} SET nome = :nome, email = :email WHERE id = :id";
     $stmt = DB::prepare($sql);
     $stmt->bindParam(':nome', $this->nome);
     $stmt->bindParam(':email', $this->email);
     $stmt->bindParam(':id', $id);
     return $stmt->execute();
 }
Exemplo n.º 29
0
 /**
  * @brief Retrieves existing buildset.
  *
  * @param buildsetid Buildset ID.
  *
  * @returns Buildset object or @c null if there is no such buildset.
  */
 public static function get($buildsetid)
 {
     $sql = 'SELECT name, revision, timestamp FROM buildsets ' . 'WHERE buildsetid = ?';
     $statement = DB::prepare($sql);
     if (!$statement || $statement->execute([$buildsetid]) !== true || ($buildsetinfo = $statement->fetch()) === false) {
         return null;
     }
     return new Buildset($buildsetid, $buildsetinfo['name'], $buildsetinfo['revision'], $buildsetinfo['timestamp']);
 }
Exemplo n.º 30
0
function blog_delete_db()
{
	$s = DB::prepare('DROP TABLE IF EXISTS BlogSearchIndex');
	$s->execute();
	$s = DB::prepare('DROP TABLE IF EXISTS BlogComment');
	$s->execute();
	$s = DB::prepare('DROP TABLE IF EXISTS Blog');
	$s->execute();
}