Example #1
0
 static function getNewGoods($count)
 {
     $res = DB::query('SELECT
       DISTINCT p.id,
       CONCAT(c.parent_url,c.url) as category_url,
       p.url as product_url,
       p.*, pv.product_id as variant_exist
     FROM `' . PREFIX . 'product` p
     LEFT JOIN `' . PREFIX . 'category` c
       ON c.id = p.cat_id
     LEFT JOIN `' . PREFIX . 'product_variant` pv
       ON p.id = pv.product_id
     LEFT JOIN (
       SELECT pv.product_id, SUM( pv.count ) AS varcount
       FROM  `' . PREFIX . 'product_variant` AS pv
       GROUP BY pv.product_id
     ) AS temp ON p.id = temp.product_id WHERE new = 1 LIMIT ' . $count . '');
     if (DB::numRows($res) != 0) {
         while ($row = DB::fetchAssoc($res)) {
             if ($row['image_url']) {
                 $img = explode('|', $row['image_url']);
                 $row['image_url'] = $img[0];
             }
             $array[] = $row;
         }
         return $array;
     }
 }
Example #2
0
 static function getProduct($count)
 {
     $res = DB::query('SELECT
       DISTINCT p.id,
       CONCAT(c.parent_url,c.url) as category_url,
       p.url as product_url,
       p.*, v.views, pv.product_id as variant_exist
     FROM `' . PREFIX . self::$pluginName . '_visits` v
     INNER JOIN `' . PREFIX . 'product` p ON v.id_product = p.id
     LEFT JOIN `' . PREFIX . 'category` c
       ON c.id = p.cat_id
     LEFT JOIN `' . PREFIX . 'product_variant` pv
       ON p.id = pv.product_id
     LEFT JOIN (
       SELECT pv.product_id, SUM( pv.count ) AS varcount
       FROM  `' . PREFIX . 'product_variant` AS pv
       GROUP BY pv.product_id
     ) AS temp ON p.id = temp.product_id ORDER BY v.views DESC LIMIT ' . $count . '');
     if (DB::numRows($res) != 0) {
         while ($row = DB::fetchAssoc($res)) {
             if ($row['image_url']) {
                 $img = explode('|', $row['image_url']);
                 $row['image_url'] = $img[0];
             }
             $array[] = $row;
         }
         return $array;
     }
 }
Example #3
0
 /**
  *  Gather all the info on the selected user id
  * @param string $id 
  */
 function __construct($id)
 {
     $this->id = $id;
     $db = new DB("users");
     $db->setColPrefix("user_");
     $db->select("user_id = '{$id}'");
     if ($db->numRows()) {
         $db->nextRecord();
         foreach ($db->record as $name => $value) {
             if ($value == "0") {
                 $value = false;
             } else {
                 if ($value == "1") {
                     $value = true;
                 }
             }
             $this->__set($name, $value);
         }
         $db = new DB("groups");
         $db->setColPrefix("group_");
         $db->select("group_id = '" . $this->_user['group'] . "'");
         $db->nextRecord();
         $this->__set("group_name", $db->name);
         $this->__set("group_access", $db->acl);
     } else {
         $this->__set("id", "0");
         $this->__set("group_access", "");
         $this->__set("name", "Unknown");
         $this->__set("avatar", "");
     }
 }
Example #4
0
 /**
  *  Check if the selected addon is installed.
  * @return boolean 
  */
 function isInstalled()
 {
     $db = new DB("addons");
     $db->select("addon_name = '" . $db->escape($this->_name) . "' and addon_installed = '1'");
     if ($db->numRows()) {
         return true;
     }
 }
Example #5
0
 static function getOption($name)
 {
     $res = DB::query("\n\t\t\tSELECT value FROM `" . PREFIX . self::$pluginName . "` WHERE `option` = '{$name}'\n\t\t");
     if (DB::numRows($res) != 0) {
         while ($row = DB::fetchAssoc($res)) {
             $array[] = $row;
         }
         return $array[0]['value'];
     }
 }
Example #6
0
function isInstalled()
{
    $db = new DB($GLOBALS['db_name'], $GLOBALS['mysql_server'], $GLOBALS['db_user'], $GLOBALS['db_pw']);
    $result = $db->query("SELECT user_id FROM grammafone_users");
    if ($db->numRows($result) > 0) {
        return true;
    } else {
        return false;
    }
}
Example #7
0
/**
 * Return the last post
 * @param int $id
 * @return array 
 */
function getLastPost($id)
{
    $db = new DB("forum_posts");
    $db->select("post_id = '" . $id . "'");
    if (!$db->numRows()) {
        return false;
    }
    $db->nextRecord();
    return $db->record;
}
Example #8
0
 static function getEntity()
 {
     $res = DB::query("\n\t\t\tSELECT * FROM `" . PREFIX . self::$pluginName . "` WHERE invisible = 1 ORDER BY `sort` ASC\n\t\t");
     if (DB::numRows($res) != 0) {
         while ($row = DB::fetchAssoc($res)) {
             $array[] = $row;
         }
         return $array;
     }
 }
Example #9
0
 /**
  * Создает таблицу плагина в БД
  */
 static function createDateBase()
 {
     DB::query("\r\n     CREATE TABLE IF NOT EXISTS `" . PREFIX . self::$pluginName . "` (\r\n      `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Порядковый номер записи',\r\n      `type` varchar(255) NOT NULL COMMENT 'Тип слайда картинка или HTML',\r\n\t    `nameaction` text NOT NULL COMMENT 'Название слайда',\r\n      `href` text NOT NULL COMMENT 'ссылка', \r\n      `value` text NOT NULL COMMENT 'значение',      \r\n      `sort` int(11) NOT NULL COMMENT 'Порядок слайдов',\r\n      `invisible` int(1) NOT NULL COMMENT 'видимость',\r\n      PRIMARY KEY (`id`)\r\n    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     // запрос для проверки, был ли плагин установлен ранее.
     $res = DB::query("\r\n      SELECT id\r\n      FROM `" . PREFIX . self::$pluginName . "`\r\n      WHERE id in (1,2,3) \r\n    ");
     // если плагин впервые активирован то задаются настройки по умолчанию
     if (!DB::numRows($res)) {
         DB::query("\r\n      INSERT INTO `" . PREFIX . self::$pluginName . "` (`id`, `type`,`nameaction`, `href`, `value`, `sort`, `invisible`) VALUES\r\n        (1, 'img', 'Акция 1','" . SITE . "/catalog', " . DB::quote("<img src='" . SITE . '/mg-plugins/' . self::$pluginName . "/images/pic/slide1.jpg' alt=''>") . ", 1,1),\r\n        (2, 'img', 'Акция 2','" . SITE . "/feedback', " . DB::quote("<img src='" . SITE . '/mg-plugins/' . self::$pluginName . "/images/pic/slide2.jpg' alt=''>") . ", 2,1),\r\n        (3, 'html', 'Акция 3','" . SITE . "/contacts', '<div style=\"background-color: blue; width: 1000px; height: 300px; text-align: center; background:rgb(214, 214, 214);\"><br />\n<span style=\"color:#006400;\"><span style=\"font-size:24px;\"><strong><font face=\"georgia, serif\">Название акциии<br />\n<br />\n<br />\n<br />\n<br />\nЛюбой HTML контент</font></strong></span></span><br />\n<br />\n<br />\n&nbsp;</div>\n', 3,1);\r\n      ");
         $array = array('width' => '', 'height' => '', 'speed' => '2000', 'pause' => '1500', 'mode' => 'horizontal', 'position' => 'left');
         MG::setOption(array('option' => 'sliderActionOption', 'value' => addslashes(serialize($array))));
     }
 }
Example #10
0
 /**
  * Carrega os dados de um determinado pelo $id.
  * Caso exista carrega os dados em
  * $_SESSION['ll']['user'] e $_ll['user'],
  * retornando <b>TRUE</b>;
  * Retorna uma Exception se o usuario não existe.
  * 
  * @param integer|string $id
  * @return boolean 
  */
 public function login($id)
 {
     global $_ll;
     $id = parent::antiInjection($id);
     $q = parent::select('SELECT id, login, nome, email, foto, grupo, themer FROM ' . $this . ' WHERE id="' . $id . '"');
     if (parent::numRows($q) == 0) {
         throw new Exception('Usuario não existe', 0);
     }
     $_SESSION['ll']['user'] = $q[0];
     $_ll['user'] =& $_SESSION['ll']['user'];
     return TRUE;
 }
Example #11
0
 /**
  * Load notifications
  * @param type $limit 
  */
 function load($limit = 5)
 {
     $db = new DB("notifications");
     $db->setColPrefix("notification_");
     $db->setSort("notification_added DESC");
     if (intval($limit)) {
         $db->setLimit($limit);
     }
     $db->select("notification_user = '" . USER_ID . "'");
     if ($db->numRows()) {
         $return = "";
         while ($db->nextRecord()) {
             $return .= "<li>";
             switch ($db->type) {
                 case 'friend':
                     $data = json_decode($db->data);
                     $user = new Acl($data->user);
                     switch ($data->type) {
                         case 'accept':
                             $return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has accepted your friend request");
                             break;
                         case 'decline':
                             $return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has declined your friend request");
                             break;
                         case 'remove':
                             $return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has removed you from his friends list");
                             break;
                     }
                     break;
                 case 'system':
                     $data = json_decode($db->data);
                     $group = new DB("groups");
                     $group->setColPrefix("group_");
                     $group->select("group_id = '" . $data->group . "'");
                     $group->nextRecord();
                     switch ($data->type) {
                         case 'upgrade':
                             $return .= _t("You have been upgraded to ") . "<b>" . $group->name . "</b><br /><small>" . get_date($db->added) . "</small>";
                             break;
                         case 'downgrade':
                             $return .= _t("You have been demoted to ") . "<b>" . $group->name . "</b><br /><small>" . get_date($db->added) . "</small>";
                             break;
                     }
                     break;
             }
             $return .= "</li>";
         }
     } else {
         $return = "<li>" . _t("No notifications found") . "</li>";
     }
     echo $return;
 }
Example #12
0
function get_links()
{
    include_once "db.inc.php";
    $db = new DB();
    $db->open();
    $query = "SELECT * FROM links ORDER BY order_";
    $result = $db->query($query);
    $num_results = $db->numRows($result);
    for ($i = 0; $i < $num_results; $i++) {
        $row = $db->fetchArray($result);
        $txttitle = str_replace("_", " ", $row[title]);
        echo '<li><a href="' . $row[url] . '">' . $txttitle . '</a></li>';
    }
}
Example #13
0
 static function getImgCat($id)
 {
     if (!empty($id)) {
         $res = DB::query("SELECT * FROM `" . PREFIX . self::$pluginName . "` WHERE `id_cat`=" . $id);
         if (DB::numRows($res) > 0) {
             $arr = DB::fetchAssoc($res);
             if (!empty($arr['img'])) {
                 return PLUGIN_DIR . self::$pluginName . '/img/' . $arr['img'];
             }
         }
     } else {
         echo 'Не указан обязательный атрибут id';
     }
 }
Example #14
0
 static function createTable()
 {
     DB::query("\n\t     CREATE TABLE IF NOT EXISTS `" . PREFIX . "call_back` (\n\t      `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Порядковый номер записи',\n\t\t  `name` text NOT NULL COMMENT 'Имя',\n\t      `phone` text NOT NULL COMMENT 'Телефон',      \n\t      `time` timestamp DEFAULT NOW() COMMENT 'Время добавления заявки',\n\t      `invisible` int(1) NOT NULL COMMENT 'Просмотр заявки',\n\t      `comment` text NULL COMMENT 'Комментарий к заявке',\n\t      PRIMARY KEY (`id`)\n\t    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     DB::query("\n\t    \tCREATE TABLE IF NOT EXISTS `" . PREFIX . "call_back_config` (\n\t    \t`id` int(11) NOT NULL AUTO_INCREMENT ,\n\t    \t`send_mail` ENUM('0','1') DEFAULT '0',\n\t    \t`email_address` VARCHAR(200) NOT NULL DEFAULT '" . MG::getOption('adminEmail') . "',\n\t    \tPRIMARY KEY (`id`)\n\t    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
     $seeds = DB::query("SELECT * FROM `" . PREFIX . 'call_back_config' . "`");
     $numb = DB::numRows($seeds);
     if ($numb == 0) {
         DB::query("\n\t    \t\tINSERT INTO `" . PREFIX . 'call_back_config' . "` VALUES(NULL, '0', '" . MG::getOption('adminEmail') . "')\n\t    \t");
     }
     // Был ли плагин активирован ранее?
     $res = DB::query("\n\t    \tSELECT id\n\t    \tFROM `" . PREFIX . "call_back`\n\t    \tWHERE id in (1,2,3)\n\t    ");
     // Если плагин впервые активирован, то задаются настройки по умолчанию
     if (!DB::numRows($res)) {
         $array = array('countRows' => '10');
         MG::setOption(array('option' => 'call-backOption', 'value' => addslashes(serialize($array))));
     }
 }
Example #15
0
 /**
  * Update the pref values on the selected target. 
  */
 function update()
 {
     $db = new DB("pref");
     $db->setColPrefix("pref_");
     foreach ($this->_vars as $name => $value) {
         $db->select("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'");
         if ($db->numRows()) {
             $db->value = $value;
             $db->update("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'");
         } else {
             $db->name = $name;
             $db->value = $value;
             $db->target = $this->target;
             $db->insert();
         }
     }
 }
Example #16
0
 /**
  *
  * @return array
  */
 private function _tagsRandomRange()
 {
     DB::select('id');
     DB::from('tag');
     DB::run();
     $tagsCount = DB::numRows();
     $rangeSize = Config::get('tagsRangeSize', 'tags');
     if ($rangeSize >= $tagsCount) {
         return array('start' => 1, 'end' => $tagsCount);
     }
     $rangeStart = rand(1, $tagsCount);
     if ($rangeStart + $rangeSize > $tagsCount) {
         $rangeStart -= $rangeStart + $rangeSize - $tagsCount;
     }
     $rangeEnd = $rangeStart + $rangeSize;
     return array('start' => $rangeStart, 'end' => $rangeEnd);
 }
Example #17
0
function getBestSeller($count = 4)
{
    $getOrder = DB::query("SELECT order_content FROM `" . PREFIX . 'order' . "`");
    if (DB::numRows($getOrder) != 0) {
        $product = new Models_Product();
        while ($row = DB::fetchArray($getOrder)) {
            $orderData[] = unserialize(stripslashes($row['order_content']));
        }
        $res = array();
        foreach ($orderData as $k => $v) {
            foreach ($v as $key => $val) {
                $res[] = $product->getProduct($val['id']);
            }
        }
        $goodsSale = getCount($res);
        return array_slice($goodsSale, 0, $count);
    }
}
Example #18
0
function vote()
{
    if (isset($_GET['dir']) && isset($_GET['did'])) {
        $d = new Diff();
        if ($d->populateDiff($_GET['did'])) {
            if ($_GET['dir'] == 1 || $_GET['dir'] == -1) {
                $db = new DB();
                $db->query("SELECT * FROM `rating` WHERE `did` = '{$_GET['did']}' AND `uid` = '{$_SESSION['uid']}';");
                if ($db->numRows() == 0) {
                    $db->query("INSERT INTO `rating` (`did`, `uid`, `rating`) VALUES ('{$_GET['did']}', '{$_SESSION['uid']}', '{$_GET['dir']}');");
                } else {
                    $db->query("UPDATE `rating` SET `rating` = '{$_GET['dir']}' WHERE `did` = '{$_GET['did']}' AND `uid` = '{$_SESSION['uid']}';");
                }
                $db->close();
            }
        }
    }
}
Example #19
0
 /**
  * Создает таблицу плагина в БД
  */
 static function createDateBase()
 {
     // Запрос для проверки, был ли плагин установлен ранее.
     $exist = false;
     $result = DB::query('SHOW TABLES LIKE "' . PREFIX . self::$pluginName . '"');
     if (DB::numRows($result)) {
         $exist = true;
     }
     if (!$exist) {
         DB::query("\r\n     CREATE TABLE IF NOT EXISTS `" . PREFIX . self::$pluginName . "` (\r\n       `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Порядковый номер',      \r\n       `title` text NOT NULL COMMENT 'Загаловок',\r\n       `settings` text NOT NULL COMMENT 'Настройки',       \r\n       PRIMARY KEY (`id`)\r\n    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
         DB::query("\r\n     CREATE TABLE IF NOT EXISTS `" . PREFIX . self::$pluginName . "-elements` (\r\n       `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Порядковый номер',      \r\n       `parent` int(11) NOT NULL COMMENT 'id блока',\r\n       `text` text  NOT NULL COMMENT 'Текст триггера',\r\n       `icon` text  NOT NULL COMMENT 'Иконка или url картинки',\r\n       `sort` int(11) NOT NULL COMMENT 'Сортировка',\r\n       PRIMARY KEY (`id`)\r\n    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
         $settings = array('form' => 'square', 'place' => 'left', 'color_icon' => '000', 'background_icon' => 'fff', 'background' => 'fff', 'width' => '31', 'height' => '90', 'layout' => 'horfloat');
         DB::query("INSERT INTO `" . PREFIX . self::$pluginName . "` SET `id`=1,\r\n        `settings` = " . DB::quote(addslashes(serialize($settings))) . " ");
         DB::query("INSERT INTO `" . PREFIX . self::$pluginName . "-elements` (`id`, `parent`, `text`, `icon`, `sort`) VALUES\r\n(8, 1, '<div><span style=\"color: rgb(0, 0, 0); font-family: Tahoma, Verdana, sans-serif; line-height: 21px;\">Гарантия качества на все товары</span></div>\n', '<i class=\"fa fa-check-circle-o fa-5x\"></i>', 8),\r\n(10, 1, '<div><span style=\"color: rgb(0, 0, 0); font-family: Tahoma, Verdana, sans-serif; line-height: 21px;\">Оплата Visa и MasterCard</span></div>\n', '<i class=\"fa fa-cc-visa fa-4x\"></i>', 10),\r\n(9, 1, '<div><span style=\"color: rgb(0, 0, 0); font-family: Tahoma, Verdana, sans-serif; line-height: 21px;\">Бесплатная доставка от 3 тыс. руб.</span></div>\n', '<i class=\"fa fa-truck fa-4x\"></i>', 9)");
         // Если плагин впервые активирован, то задаются настройки по умолчанию
         MG::setOption(array('option' => 'countPrintRowsTrigger', 'value' => 10));
     }
 }
Example #20
0
 /**
  * Build the navigation
  * @return string
  */
 function build()
 {
     $db = new DB("navigations");
     $db->setColPrefix("navigation_");
     $db->setSort("navigation_sorting ASC");
     $db->select("navigation_lang = '" . CURRENT_LANGUAGE . "'");
     if (!$db->numRows()) {
         $db->select("navigation_lang = '" . DEFAULT_LANGUAGE . "'");
     }
     $menu = "";
     while ($db->nextRecord()) {
         if ($db->module != "") {
             $menu .= $this->item($db->title, $db->application, $db->module);
         } else {
             $menu .= $this->item($db->title, $db->application);
         }
     }
     return $menu;
 }
Example #21
0
 function __construct($force = false)
 {
     $db = new DB("avps");
     $db->select();
     $doclean = false;
     if (!$db->numRows()) {
         $db->last_cleantime = time();
         $db->insert();
         $doclean = true;
     } else {
         $db->nextRecord();
         $time = time() - 1800;
         if ($db->last_cleantime < $time) {
             $doclean = true;
         } else {
             $doclean = false;
         }
     }
     if ($force) {
         $doclean = true;
     }
     if ($doclean) {
         set_time_limit(0);
         ignore_user_abort(1);
         $this->deadtime_peers = time() - floor(60 * 30 * 1.3);
         // 39 minutes.
         $this->deadtime_torrents = time() - floor(60 * 60 * 24 * 3);
         // 3 Days
         $this->deadtime_users = time() - floor(60 * 60 * 24 * 56);
         // 56 Days
         $this->torrents();
         $this->groups();
         $db = new DB("avps");
         $db->last_cleantime = time();
         $db->update();
     }
 }
Example #22
0
 function populateDiff($did)
 {
     $db = new DB();
     $db->query("SELECT * FROM diff WHERE did = {$did};");
     if ($db->numRows() > 0) {
         $diffinfo = $db->fetchRow();
         $this->did = $did;
         $this->sid = $diffinfo[1];
         $this->uid = $diffinfo[2];
         $this->toreplace = $diffinfo[3];
         $this->replacewith = $diffinfo[4];
         $this->time = $diffinfo[5];
         $this->ip = long2ip($diffinfo[7]);
         $this->comment = $diffinfo[6];
         $db->query("SELECT SUM(rating) FROM rating WHERE did = {$this->did};");
         $row = $db->fetchRow();
         $this->rating = $row[0];
         $db->close();
         return true;
     } else {
         $db->close();
         return false;
     }
 }
Example #23
0
    $classes[$x]['status'] = 'enabled';
}
$week1 = "";
$week2 = "";
$week3 = "";
$week4 = "";
$times = array("none", "9:30-12:30", "1:30-4:30", "1:30-4:30", "9:30-12:30", "1:30-4:30", "1:30-4:30", "9:30-12:30", "1:30-4:30", "1:30-4:30", "9:30-12:30", "1:30-4:30", "1:30-4:30");
$toggles = array("0", "0", "3", "2", "0", "6", "5", "0", "9", "8", "0", "12", "11");
$sql = "SELECT * FROM forms.summer_program_class";
$db->do_query($sql);
while ($row = $db->fetchObject()) {
    // count how many are already in this class, disable it if it's 12 or more
    $thisClassId = $row->id;
    $sql2 = "SELECT * FROM forms.summer_program_class_registration WHERE class_id = {$thisClassId} and paid_for = '1'";
    $db2->do_query($sql2);
    $registeredCount = $db2->numRows();
    if ($registeredCount >= $maxStudentsPerClass) {
        $thisStatus = 'disabled';
        $thisClosedMessage = "<span>(Class is filled)</span>";
    } else {
        $thisStatus = "";
        $thisClosedMessage = "";
    }
    if ($classes[$row->id]['count'] >= $maxStudentsPerClass) {
        $classes[$row->id]['status'] = 'disabled';
    }
    $week = $row->week;
    $thisCount = $classes[$row->id]['count'];
    $thisTitle = $row->title;
    $thisClassIdName = "class" . $row->id;
    if ($row->id == '6') {
Example #24
0
 public function saveComment()
 {
     USER::AccessOnly('1,4', 'exit()');
     $this->messageSucces = 'Комментарий отредактирован';
     $res = DB::query("UPDATE `" . PREFIX . "comments` SET \r\n\t\t\t\tname = '%s',\r\n\t\t\t\temail = '%s',\r\n\t\t\t\tcomment = '%s',\r\n\t\t\t\tapproved = '%s'\r\n\t\t\tWHERE id = '%d'", $_POST['name'], $_POST['email'], $_POST['comment'], $_POST['approved'], $_POST['id']);
     if ($res) {
         $sql = "\r\n  \t\tSELECT `id`\r\n      FROM `" . PREFIX . "comments`\r\n      WHERE `approved`=0";
         $res = DB::query($sql);
         $count = DB::numRows($res);
         $count = $count ? $count : 0;
         $this->data = array('count' => $count);
         return true;
     } else {
         return false;
     }
 }
Example #25
0
 /**
  * Получаем количество новых комментариев 
  */
 static function getNewCommentsCount()
 {
     $exist = false;
     $result = DB::query('SHOW TABLES');
     while ($row = DB::fetchArray($result)) {
         if (PREFIX . "comments" == $row[0]) {
             $exist = true;
         }
     }
     if ($exist) {
         $sql = "\n        SELECT `id`\n        FROM `" . PREFIX . "comments`\n        WHERE `approved`=0";
         $res = DB::query($sql);
         $count = DB::numRows($res);
     }
     return $count ? $count : 0;
 }
Example #26
0
    if ($db->numRows()) {
        $mail = "<span class='msgAlert'>" . $db->numRows() . "</span>";
    }
    $db = new DB("friends");
    $db->select("friend_receiver = '" . USER_ID . "' AND friend_status = '0'");
    $friends = "";
    if ($db->numRows()) {
        $friends = "<span class='msgAlert'>" . $db->numRows() . "</span>";
    }
    $sup = new DB("support");
    $sup->select("ticket_user = '" . USER_ID . "'");
    $count = 0;
    while ($sup->nextRecord()) {
        $db = new DB("support_messages");
        $db->select("message_ticket = '" . $sup->ticket_id . "' AND message_unread = '0'");
        $count += $db->numRows();
    }
    $support = "";
    if ($count > 0) {
        $support = "<span class='msgAlert'>" . $count . "</span>";
    }
    ?>

                    <li class="rel" title="<?php 
    echo _t("Mailbox");
    ?>
">
                        <a href="<?php 
    echo page("profile", "mailbox");
    ?>
">
Example #27
0
<?php

$this->setTitle("Create Topic");
try {
    $acl = new Acl(USER_ID);
    $forum_id = isset($_GET['forum']) ? 0 + $_GET['forum'] : false;
    if (!$forum_id) {
        throw new Exception("missing forum id");
    }
    if (!intval($forum_id)) {
        throw new Exception("invalid forum id");
    }
    $db = new DB("forum_forums");
    $db->setColPrefix("forum_");
    $db->select("forum_id = '" . $db->escape($forum_id) . "'");
    if (!$db->numRows()) {
        throw new Exception("forum not found");
    }
    $db->nextRecord();
    if ($db->group > $acl->group) {
        throw new Exception("Access denied");
    }
    if (isset($_POST['create'])) {
        try {
            if ($_POST['secure_input'] != $_SESSION['secure_token']) {
                throw new Exception("Wrong secured token");
            }
            if (empty($_POST['subject'])) {
                throw new Exception("Missing subject name");
            }
            if (empty($_POST['content'])) {
Example #28
0
            </div>

            <?php 
    }
    echo "</div>";
}
$db = new DB("friends");
$db->select("friend_receiver = '" . USER_ID . "' AND friend_status = '1'");
$friends = "";
?>
    <h4><?php 
echo _t("my friends");
?>
</h4>
    <?php 
if ($db->numRows()) {
    while ($db->nextRecord()) {
        $acl = new Acl($db->friend_sender);
        $time = time() - 200;
        $online = $acl->last_access < $time ? get_date($acl->last_access) : "<b><font color='green'>Online</font></b>";
        ?>
            <div class="user" style="float:left; margin: 3px; border: 1px solid #ddd; padding:5px; padding-bottom: 10px; background-color: #f8f8f8; width: 47%;">
                <img width="50px" src="<?php 
        echo $acl->avatar();
        ?>
" style="float:left; margin-right: 5px;" alt="">
                <a href="<?php 
        echo page("profile", "view", $acl->name);
        ?>
"><b><?php 
        echo $acl->name;
 function getsilenced($roomname, $ip, $sitesilence)
 {
     include_once "db.inc.php";
     $db = new DB();
     $db->open();
     $query = "SELECT * from sitesilence";
     $result = $db->query($query);
     $num_results = $db->numRows($result);
     if ($DEBUG) {
         echo $query . "<br>\n";
     }
     if ($DEBUG) {
         echo 'Invalid query: ' . mysql_error() . "<br>\n";
     }
     for ($i = 0; $i < $num_results; $i++) {
         $row = $db->fetchArray($result);
         if (strstr($ip, $row[silencedip])) {
             $sitesilence = '1';
         }
     }
     return $sitesilence;
 }
Example #30
0
 $res = $db->fetchArray();
 $saturdayDinnerChild = $res['SUM(saturdayDinnerChild)'];
 $sql = "SELECT SUM(sundayBrunchAdults) FROM family_weekend_2014 WHERE date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}'";
 $db->do_query($sql);
 $res = $db->fetchArray();
 $sundayBrunchAdults = $res['SUM(sundayBrunchAdults)'];
 $sql = "SELECT SUM(sundayBrunchChild) FROM family_weekend_2014 WHERE date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}'";
 $db->do_query($sql);
 $res = $db->fetchArray();
 $sundayBrunchChild = $res['SUM(sundayBrunchChild)'];
 // Totals
 $totalAdults = 0;
 //	$sql = "SELECT * FROM family_weekend_2014 WHERE relative1Class NOT LIKE '%Other%';";
 $sql = "SELECT * FROM family_weekend_2014 WHERE (relative1Class LIKE '%Parent%' OR relative1Class LIKE '%Other%') AND date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}'";
 $db->do_query($sql);
 $totalAdults += $db->numRows();
 $sql = "SELECT * FROM family_weekend_2014 WHERE (relative2Class LIKE '%Parent%' OR relative2Class LIKE '%Other%') AND date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}'";
 $db->do_query($sql);
 $totalAdults += $db->numRows();
 $sql = "SELECT * FROM family_weekend_2014 WHERE (relative3Class LIKE '%Parent%' OR relative3Class LIKE '%Other%') AND date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}'";
 $db->do_query($sql);
 $totalAdults += $db->numRows();
 $sql = "SELECT * FROM family_weekend_2014 WHERE (relative4Class LIKE '%Parent%' OR relative4Class LIKE '%Other%) AND date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}''";
 $db->do_query($sql);
 $totalAdults += $db->numRows();
 $sql = "SELECT * FROM family_weekend_2014 WHERE (relative5Class LIKE '%Parent%' OR relative5Class LIKE '%Other%) AND date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}''";
 $db->do_query($sql);
 $totalAdults += $db->numRows();
 $totalChildren = 0;
 //	$sql = "SELECT * FROM family_weekend_2014 WHERE relative1Class NOT LIKE '%Other%';";
 $sql = "SELECT * FROM family_weekend_2014 WHERE relative1Class LIKE '%Child%' AND date_submitted > '{$rangestart}' AND date_submitted < '{$rangeend}'";