Exemplo n.º 1
0
 public static function removeByViewId($_view_id)
 {
     $value = array('view_id' => $_view_id);
     $sql = 'DELETE FROM viewZone
             WHERE view_id=:view_id';
     return DB::Prepare($sql, $value, DB::FETCH_TYPE_ROW);
 }
Exemplo n.º 2
0
 public static function byPlugin($_plugin)
 {
     $values = array('plugin' => '%' . $_plugin . '%');
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
     FROM jeeNetwork
     WHERE plugin LIKE :plugin';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 3
0
 public static function byId($_id)
 {
     $values = array('id' => $_id);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
     FROM ' . __CLASS__ . '
     WHERE id=:id';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 4
0
 public static function byEqLogic_id($_eqLogic_id)
 {
     $values = array('eqLogic_id' => $_eqLogic_id);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
             FROM energy
             WHERE eqLogic_id=:eqLogic_id';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 5
0
 public static function byuserIdAndEntity($_user_id, $_entity)
 {
     $values = array('user_id' => $_user_id, 'entity' => $_entity);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
             FROM `rights`
             WHERE entity=:entity
                 AND user_id=:user_id';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 6
0
 public static function byviewZoneId($_viewZone_id)
 {
     $value = array('viewZone_id' => $_viewZone_id);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
             FROM viewData
             WHERE viewZone_id=:viewZone_id
             ORDER BY `order`';
     return DB::Prepare($sql, $value, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 7
0
 public static function byElement($_element_id)
 {
     $values = array('expression' => $_element_id);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
     FROM ' . __CLASS__ . '
     WHERE expression=:expression
     AND `type`= "element"';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 8
0
 public static function unbind_user($_id, $_user_id)
 {
     $sql = 'DELETE FROM `users_interests` WHERE `user_id` = :user_id AND `interest_id` = :id';
     $params = array('id' => $_id, 'user_id' => $_user_id);
     try {
         DB::Prepare($sql, $params);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Exemplo n.º 9
0
 public static function byTypeLinkId($_type, $_link_id = '')
 {
     $values = array('type' => $_type);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
             FROM dataStore
             WHERE type=:type';
     if ($_link_id != '') {
         $values['link_id'] = $_link_id;
         $sql .= ' AND link_id=:link_id';
     }
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 10
0
 public static function searchEvent($_event)
 {
     if (strpos($_event, '#') !== false) {
         $value = array('event' => '%' . $_event . '%');
     } else {
         $value = array('event' => '%#' . $_event . '#%');
     }
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
             FROM listener
             WHERE `event` LIKE :event';
     return DB::Prepare($sql, $value, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 11
0
 public static function change_email($_id, $_email)
 {
     $email = htmlentities($_email);
     $sql = 'UPDATE `users` SET `email` = :email WHERE `id` = :id';
     $params = array('id' => $_id, 'email' => $email);
     try {
         DB::Prepare($sql, $params);
         $_SESSION['user']['email'] = $email;
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Exemplo n.º 12
0
 public static function byScenarioElementId($_scenarioElementId, $_type = '')
 {
     $values = array('scenarioElement_id' => $_scenarioElementId);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '  
             FROM ' . __CLASS__ . ' 
             WHERE scenarioElement_id=:scenarioElement_id ';
     if ($_type != '') {
         $values['type'] = $_type;
         $sql .= ' AND type=:type ';
         return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
     }
     $sql .= ' ORDER BY `order`';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 13
0
 public static function byLogicalId($_logicalId, $_cat)
 {
     $values = array('logicalId' => $_logicalId, 'cat' => $_cat);
     $sql = 'SELECT id
             FROM eqReal
             WHERE logicalId=:logicalId
                 AND cat=:cat';
     $results = DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL);
     $return = array();
     foreach ($results as $result) {
         $return[] = self::byId($result['id']);
     }
     return $return;
 }
Exemplo n.º 14
0
    public static function allUnite()
    {
        $sql = 'SELECT distinct(unite) as unite
		FROM cmd';
        return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL);
    }
Exemplo n.º 15
0
 public static function recognize($_query)
 {
     $values = array('query' => $_query);
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
 FROM interactQuery
 WHERE LOWER(query)=LOWER(:query)';
     $query = DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
     if (is_object($query)) {
         log::add('interact', 'debug', 'Je prend : ' . $query->getQuery());
         return $query;
     }
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . ', MATCH query AGAINST (:query IN NATURAL LANGUAGE MODE) as score
 FROM interactQuery
 GROUP BY id
 HAVING score > 1';
     $queries = DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
     if (count($queries) == 0) {
         $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
     FROM interactQuery
     WHERE query=:query';
         $queries = DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
         if (is_object($queries)) {
             return $queries;
         }
         $queries = self::all();
     }
     $caracteres = array('À' => 'a', 'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', '@' => 'a', 'È' => 'e', 'É' => 'e', 'Ê' => 'e', 'Ë' => 'e', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', '€' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i', 'Ï' => 'i', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Ö' => 'o', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'ö' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'µ' => 'u', 'Œ' => 'oe', 'œ' => 'oe', '$' => 's');
     $shortest = 999;
     $closest = null;
     $_query = strtolower(preg_replace('#[^A-Za-z0-9 \\n\\.\'=\\*:]+#', '', strtr($_query, $caracteres)));
     foreach ($queries as $query) {
         $input = strtolower(preg_replace('#[^A-Za-z0-9 \\n\\.\'=\\*:]+#', '', strtr($query->getQuery(), $caracteres)));
         preg_match_all("/#(.*?)#/", $input, $matches);
         foreach ($matches[1] as $match) {
             $input = str_replace('#' . $match . '#', '', $input);
         }
         $lev = levenshtein($input, $_query);
         log::add('interact', 'debug', 'Je compare : ' . $_query . ' avec ' . $input . ' => ' . $lev);
         if ($lev == 0) {
             $shortest = 0;
             $closest = $query;
             break;
         }
         if ($lev <= $shortest || $shortest < 0) {
             $closest = $query;
             $shortest = $lev;
         }
     }
     if (str_word_count($_query) == 1 && config::byKey('interact::confidence1') > 0 && $shortest > config::byKey('interact::confidence1')) {
         log::add('interact', 'debug', 'Correspondance trop éloigné : ' . $shortest);
         return null;
     } else {
         if (str_word_count($_query) == 2 && config::byKey('interact::confidence2') > 0 && $shortest > config::byKey('interact::confidence2')) {
             log::add('interact', 'debug', 'Correspondance trop éloigné : ' . $shortest);
             return null;
         } else {
             if (str_word_count($_query) == 3 && config::byKey('interact::confidence3') > 0 && $shortest > config::byKey('interact::confidence3')) {
                 log::add('interact', 'debug', 'Correspondance trop éloigné : ' . $shortest);
                 return null;
             } else {
                 if (str_word_count($_query) > 3 && config::byKey('interact::confidence') > 0 && $shortest > config::byKey('interact::confidence')) {
                     log::add('interact', 'debug', 'Correspondance trop éloigné : ' . $shortest);
                     return null;
                 }
             }
         }
     }
     return $closest;
 }
Exemplo n.º 16
0
function update_activity($action_name, $action_id = '')
{
    if (!isset($_SESSION['UID'])) {
        return false;
    }
    $sql = DB::Prepare('INSERT INTO {P}Activity (time, uid, action_name, action_id) VALUES (UNIX_TIMESTAMP(), ?, ?, ?) ON DUPLICATE KEY UPDATE time = UNIX_TIMESTAMP(), action_name = ?, action_id = ?;');
    DB::Execute($sql, array($_SESSION['UID'], $action_name, $action_id, $action_name, $action_id));
    $_SESSION['MyLastActions'][$action_name] = time();
}
Exemplo n.º 17
0
 public function collectInProgress()
 {
     $values = array('eqLogic_id' => $this->getId());
     $sql = 'SELECT count(*)
 FROM cmd
 WHERE eqLogic_id=:eqLogic_id
 AND collect=1
 AND eventOnly=0';
     $results = DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW);
     if ($results['count(*)'] > 0) {
         return true;
     }
     return false;
 }
Exemplo n.º 18
0
        // Delete replies.
        $sql = DB::Prepare('SELECT id, parent_id FROM {P}Replies WHERE body LIKE ? AND time > ?');
        $res = DB::Execute($sql, array($phrase, $affect_posts_after));
        $victim_parents = array();
        while (list($parent_id) = $res->FetchRow()) {
            $victim_parents[] = $parent_id;
        }
        $fetch_parents->close();
        $sql = DB::Prepare('DELETE FROM {P}Replies WHERE body LIKE ? AND time > ?');
        DB::Execute($sql, array($phrase, $affect_posts_after));
        $sql = DB::Prepare('UPDATE {P}Topics SET replies = replies - 1 WHERE id = ?');
        foreach ($victim_parents as $parent_id) {
            DB::Execute($sql, array($parent_id));
        }
        // Delete topics.
        $sql = DB::Prepare('DELETE FROM topics WHERE body LIKE ? OR headline LIKE ? AND time > ?');
        DB::Execute($sql, array($phrase, $phrase, $affect_posts_after));
        $_SESSION['notice'] = 'Finished.';
    }
}
$start_time = $_SERVER['REQUEST_TIME'];
$_SESSION['exterminate_start_time'] = $start_time;
?>

<p>This features removes all posts that contain anywhere in the body or headline the exact phrase that you specify.</p>

<form action="" method="post">
	<div class="noscreen">
		<input type="hidden" name="start_time" value="<?php 
echo $start_time;
?>
Exemplo n.º 19
0
<?php

try {
    $sql = 'ALTER TABLE history DROP CONSTRAINT fk_history_cmd1;';
    DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
    $sql = 'ALTER TABLE history 
			ADD CONSTRAINT fk_history_cmd1
			FOREIGN KEY (`cmd_id`)
		    REFERENCES `cmd` (`id`)
		    ON DELETE CASCADE
		    ON UPDATE CASCADE';
    DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {
}
Exemplo n.º 20
0
 public static function all()
 {
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
             FROM planHeader';
     return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 21
0
require 'includes/header.php';
$page_title = 'Recover ID by e-mail';
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$onload_javascript = 'focusId(\'e-mail\');';
if (!empty($_POST['e-mail'])) {
    // Validate e-mail address.
    if (!filter_var($_POST['e-mail'], FILTER_VALIDATE_EMAIL)) {
        add_error('That doesn\'t look like a valid e-mail address.');
    }
    // Deny flooders (hack; should be done from the database for security).
    if ($_SESSION['recovery_email_count'] > 4) {
        add_error('How many times do you need to recover your password in one day?');
    }
    $sql = DB::Prepare('SELECT user_settings.uid, users.password FROM user_settings INNER JOIN users ON user_settings.uid = users.uid WHERE user_settings.email = ? LIMIT 50');
    $res = DB::Execute($sql, array($_POST['e-mail']));
    $ids_for_email = array();
    while (list($uid, $password) = $res->FetchRow()) {
        $ids_for_email[$uid] = $password;
    }
    if (empty($ids_for_email)) {
        add_error('There are no IDs associated with that e-mail.');
    }
    if (!$erred) {
        $num_ids = count($ids_for_email);
        if ($num_ids == 1) {
            $email_body = 'Your ID is ' . key($ids_for_email) . ' and your password is ' . current($ids_for_email) . '. To restore your ID, follow this link: ' . DOMAIN . 'restore_ID/' . key($ids_for_email) . '/' . current($ids_for_email);
        } else {
            $email_body = 'The following IDs are associated with your e-mail address:' . "\n\n";
            foreach ($ids_for_email as $id => $password) {
Exemplo n.º 22
0
 public static function searchKey($_key, $_plugin = 'core')
 {
     $values = array('plugin' => $_plugin, 'key' => '%' . $_key . '%');
     $sql = 'SELECT *
             FROM config
             WHERE `key` LIKE :key
                 AND plugin=:plugin';
     $results = DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL);
     foreach ($results as &$result) {
         if (is_json($result['value'])) {
             $result['value'] = json_decode($result['value'], true);
         }
     }
     return $results;
 }
Exemplo n.º 23
0
 public static function listPlugin($_activateOnly = false, $_orderByCaterogy = false, $_translate = true)
 {
     $listPlugin = array();
     if ($_activateOnly) {
         $sql = "SELECT plugin\n            FROM config\n            WHERE `key`='active'\n            AND `value`='1'";
         $results = DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL);
         foreach ($results as $result) {
             try {
                 $listPlugin[] = plugin::byId($result['plugin'], $_translate);
             } catch (Exception $e) {
                 log::add('plugin', 'error', $e->getMessage(), 'pluginNotFound::' . $result['plugin']);
             }
         }
     } else {
         $rootPluginPath = dirname(__FILE__) . '/../../plugins';
         foreach (ls($rootPluginPath, '*') as $dirPlugin) {
             if (is_dir($rootPluginPath . '/' . $dirPlugin)) {
                 $pathInfoPlugin = $rootPluginPath . '/' . $dirPlugin . '/plugin_info/info.xml';
                 if (file_exists($pathInfoPlugin)) {
                     try {
                         $listPlugin[] = plugin::byId($pathInfoPlugin, $_translate);
                     } catch (Exception $e) {
                         log::add('plugin', 'error', $e->getMessage(), 'pluginNotFound::' . $pathInfoPlugin);
                     }
                 }
             }
         }
     }
     if ($_orderByCaterogy) {
         $return = array();
         if (count($listPlugin) > 0) {
             foreach ($listPlugin as $plugin) {
                 $category = $plugin->getCategory();
                 if ($category == '') {
                     $category = __('Autre', __FILE__);
                 }
                 if (!isset($return[$category])) {
                     $return[$category] = array();
                 }
                 $return[$category][] = $plugin;
             }
             foreach ($return as &$category) {
                 usort($category, 'plugin::orderPlugin');
             }
             ksort($return);
         }
         return $return;
     } else {
         if (isset($listPlugin) && is_array($listPlugin) && count($listPlugin) > 0) {
             usort($listPlugin, 'plugin::orderPlugin');
             return $listPlugin;
         } else {
             return array();
         }
     }
 }
Exemplo n.º 24
0
 public static function searchByQuery($_query)
 {
     $values = array('query' => '%' . $_query . '%');
     $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
     FROM interactDef
     WHERE query LIKE :query';
     return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
 }
Exemplo n.º 25
0
 public static function cron()
 {
     $sql = 'DELETE FROM `connection` 
             WHERE id NOT IN 
             (SELECT * FROM (
                 SELECT id 
                 FROM `connection`
                 ORDER BY `datetime` DESC LIMIT 100
             ) tmp);';
     DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
     if (is_numeric(config::byKey('security::bantime'))) {
         $sql = 'UPDATE `connection`
             SET `status` = "Not connected"
             WHERE status="Ban"
                 AND `datetime` < DATE_SUB(NOW(),INTERVAL ' . config::byKey('security::bantime') . ' MINUTE)';
         DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
     }
 }
Exemplo n.º 26
0
			'<a href="/IP_address/' . $topic_ip_address . '">' . $topic_ip_address . '</a>',
			replies($topic_id, $topic_replies),
			format_number($topic_visits),
			'<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>'
		);
								
		$topics->Row($values);
	}
	echo $topics;
}

if($id_num_replies > 0)
{
	echo '<h4 class="section">Replies</h4>';

	$sql=DB::Prepare('SELECT replies.id, replies.parent_id, replies.time, replies.body, replies.author_ip, topics.headline, topics.time FROM {P}Replies as replies INNER JOIN {P}Topics as topics ON replies.parent_id = topics.id WHERE replies.author = ? ORDER BY id DESC');
	$res=DB::Execute($sql,array($_GET['uid']));

	$stmt->bind_result;
	
	$replies = new TablePrinter('tblReplies');
	$columns = array
	(
		'Reply snippet',
		'Topic',
		'IP address',
		'Age ▼'
	);
	$replies->DefineColumns($columns, 'Topic');
	$replies->SetTDClass('Topic', 'topic_headline');
	$replies->SetTDClass('Reply snippet', 'reply_body_snippet');
Exemplo n.º 27
0
<?php

require 'includes/header.php';
if (!ctype_digit($_GET['id'])) {
    add_error('Invalid ID.', true);
}
$stmt = DB::Prepare('SELECT headline, visits, replies, author FROM {P}Topics WHERE id = ?');
$stmt = DB::Execute($stmt, array($_GET['id']));
if ($stmt->RecordCount() < 1) {
    $page_title = 'Non-existent topic';
    add_error('There is no such topic. It may have been deleted.', true);
}
list($topic_headline, $topic_visits, $topic_replies, $topic_author) = $stmt->FetchRow();
update_activity('topic_trivia', $_GET['id']);
$page_title = 'Trivia for topic: <a href="/topic/' . $_GET['id'] . '">' . htmlspecialchars($topic_headline) . '</a>';
$statistics = array();
$topic_watchers = DB::GetOne("SELECT count(*) FROM {P}Watchlists WHERE topic_id = " . DB::Q($_GET['id']));
$topic_readers = DB::GetOne("SELECT count(*) FROM {P}Activity WHERE action_name = 'topic' AND action_id = " . DB::Q($_GET['id']));
$topic_writers = DB::GetOne("SELECT count(*) FROM {P}Activity WHERE action_name = 'replying' AND action_id = " . DB::Q($_GET['id']));
$topic_participants = DB::GetOne("SELECT count(DISTINCT author) FROM {P}Replies WHERE parent_id = " . DB::Q($_GET['id']) . " AND author != " . DB::Q($topic_author));
// Alternatively, we could select the most recent poster_number. I'm not sure which method would be fastest.
?>

<table>
	<tr>
		<th class="minimal">Total visits</th>
		<td><?php 
echo format_number($topic_visits);
?>
</td>
	</tr>
Exemplo n.º 28
0
function remove()
{
    DB::Prepare('DROP TABLE IF EXISTS `energy`', array(), DB::FETCH_TYPE_ROW);
}
Exemplo n.º 29
0
 public static function hasDefaultIdentification()
 {
     $sql = 'SELECT count(id) as nb
     FROM user
     WHERE login="******"
     AND password=SHA1("admin")
     AND `enable` = 1';
     $result = DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
     return $result['nb'];
 }
Exemplo n.º 30
0
 public function emptyCacheWidget()
 {
     $sql = 'DELETE FROM cache
 WHERE `key` LIKE "scenarioHtml%' . $this->getId() . '"';
     DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
 }