Example #1
0
function extraerTags($ID)
{
    global $db_source, $prefix;
    /*
     * Importación de Categorías
     */
    $m = new mysql();
    #SQL: extrae los tags de WP para el ID del post que se pase como parámetro.
    $m->query("SELECT t.term_id,t.slug,t.name,tr.object_id FROM {$db_source}.wp_terms as t \n\n\t\tinner join {$db_source}.wp_term_taxonomy as tt on tt.term_id = t.term_id \n\n\t\tinner join {$db_source}.wp_term_relationships as tr on tr.term_taxonomy_id = t.term_id \n\n\t\tWHERE tt.taxonomy = 'category' and tr.object_id={$ID} \n\n\t\t");
    $sql_tags = "INSERT INTO " . $prefix . "tags(tag_id,tag,urlfriendly) VALUES ";
    $insertTags = false;
    $sql_relation = "INSERT INTO " . $prefix . "tags_rel(tag_id,post_id) VALUES ";
    $hasTags = false;
    /*
     * Para cada tag del post extraido de WP
     * 1.- Revisar si existe, si no, lo inserta.
     */
    if ($m->total() > 0) {
        while ($m->fetch()) {
            $m2 = new mysql();
            /*
             * Si no existe tag, lo insertamos.
             */
            $m2->query("SELECT * FROM " . $prefix . "tags WHERE tag_id=" . $m->sql_quote($m->row['term_id']) . "");
            if (!$m2->fetch()) {
                $sql_tags .= "(" . $m->sql_quote($m->row['term_id']) . "," . "'" . $m->sql_quote($m->row['name']) . "'," . "'" . $m->sql_quote($m->row['slug']) . "'" . "), ";
                $insertTags = true;
            }
            /*
             * Buscamos si existe la relacion entre el tag y el post, si no, la creamos.
             */
            $m2->query("SELECT * FROM " . $prefix . "tags_rel WHERE tag_id=" . $m->sql_quote($m->row['term_id']) . " AND post_id=" . $ID);
            if (!$m2->fetch()) {
                $sql_relation .= " (" . $m->sql_quote($m->row['term_id']) . "," . $m->sql_quote($ID) . "), ";
                $hasTags = true;
            }
        }
        //while
    } else {
        //no tiene tags, entonces lo ponemos bajo el tag 'general'. Generalmente id=1
        $sql_relation .= " (1," . $m->sql_quote($ID) . "), ";
        $hasTags = true;
    }
    //if
    if ($insertTags) {
        $sql_tags = substr($sql_tags, 0, -2) . ';';
        $m->query($sql_tags);
    }
    if ($hasTags) {
        $sql_relation = substr($sql_relation, 0, -2) . ';';
        $m->query($sql_relation);
    }
}
Example #2
0
 function get_slider($limit, $name_file)
 {
     $sql = 'select * from splash where status=1 order by sort limit ' . $limit;
     $result = mysql::query($sql, 0);
     // выполняем tpl
     return system::show_tpl(array('splash' => $result), $name_file);
 }
 /**
  * выводим материал
  */
 function indexAction()
 {
     $_sql = 'select * from ' . $this->tablename . ' where status=1 order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
 /**
  * Zeigt die Einträge an
  *
  * @param integer $max_entries_pp Anzahl Einträge pro Seite
  */
 private function _view($max_entries_pp)
 {
     $this->_tplfile = 'gbook.tpl';
     $gbook_array = array();
     if (isset($this->_gpc['GET']['page']) && is_numeric($this->_gpc['GET']['page']) && $this->_gpc['GET']['page'] > 0) {
         $page = $this->_gpc['GET']['page'];
     } else {
         $page = 1;
     }
     $gbook_array = $this->_msbox->getEntries($max_entries_pp, $page, 'DESC', 'ASC', $this->_timeformat);
     $this->_mysql->query('SELECT COUNT(*) as many FROM `gbook` WHERE `gbook_ref_ID` = \'0\'');
     $entries = $this->_mysql->fetcharray('num');
     $this->_mysql->query('SELECT COUNT(*) as many FROM `gbook` WHERE `gbook_ref_ID` != \'0\'');
     $comments = $this->_mysql->fetcharray('num');
     $pagesnav_array = Page::get_static_pagesnav_array($entries[0], $max_entries_pp, $this->_gpc['GET']);
     //Inhalt parsen (Smilies) und an Smarty-Array übergeben
     foreach ($gbook_array as $key => $value) {
         $gbook_array[$key] = array('ID' => $value['gbook_ID'], 'title' => htmlentities($value['gbook_title']), 'content' => $this->_smilie->show_smilie(nl2br(htmlentities($value['gbook_content'])), $this->_mysql), 'name' => htmlentities($value['gbook_name']), 'time' => $value['gbook_time'], 'email' => htmlentities($value['gbook_email']), 'hp' => htmlentities($value['gbook_hp']), 'number_of_comments' => $value['number_of_comments']);
         $count = 0;
         //Kommentare durchackern
         foreach ($value['comments'] as $ckey => $cvalue) {
             $gbook_array[$key]['comments'][$ckey] = array('ID' => $cvalue['gbook_ID'], 'title' => htmlentities($cvalue['gbook_title']), 'content' => $this->_smilie->show_smilie(nl2br(htmlentities($cvalue['gbook_content'])), $this->_mysql), 'name' => htmlentities($cvalue['gbook_name']), 'time' => $cvalue['gbook_time'], 'email' => htmlentities($cvalue['gbook_email']), 'hp' => htmlentities($cvalue['gbook_hp']));
             $count++;
         }
     }
     $this->_smarty->assign('gbook', $gbook_array);
     $this->_smarty->assign('pages', $pagesnav_array);
     $this->_smarty->assign('entries', $entries[0]);
     $this->_smarty->assign('comments', $comments[0]);
 }
Example #5
0
 private static function query($arrSea, $isFind)
 {
     $model = get_called_class();
     $limit = isset($arrSea["limit"]) ? "LIMIT " . $arrSea["limit"] : "";
     if (!$isFind) {
         $limit = "LIMIT 1";
     }
     $order = isset($arrSea["order"]) ? "ORDER BY " . $arrSea["order"] : "";
     $where = isset($arrSea["where"]) ? "WHERE " . $arrSea["where"] : "";
     $sql = "SELECT * FROM `{$model}` {$where} {$order} {$limit}";
     $res = mysql::query($sql);
     if ($res) {
         $findArr = array();
         for ($i = 0; $i !== $res->num_rows; $i++) {
             $res->data_seek($i);
             $row = $res->fetch_assoc();
             $class = new $model(false);
             foreach ($class as $key => &$val) {
                 $val = $row[$key];
             }
             if (!$isFind) {
                 return $class;
             }
             array_push($findArr, $class);
         }
         return $findArr;
     } else {
         return false;
     }
 }
Example #6
0
function process_message($msg)
{
    echo "\n############ 信息日志开始 ###############\n";
    echo date('Y-m-d H:i:s') . "=====" . $msg->body;
    echo "\n############ 信息日志结束 ###############\n";
    //执行SQL语句
    $db_config = C("DB_CONFIG");
    $dbConn = new mysql();
    $dbConn->connect($db_config["master1"][0], $db_config["master1"][1], $db_config["master1"][2], '');
    $dbConn->select_db($db_config["master1"][4]);
    $sql = $msg->body;
    $query = $dbConn->query($sql);
    if (!$query) {
        Log::write($sql, Log::ERR);
    } else {
        echo date('Y-m-d H:i:s') . '===== [ok] ', '=====', $sql, "\n";
        //确认消费OK
        $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
    }
    $dbConn->close();
    // Send a message with the string "quit" to cancel the consumer.
    if ($msg->body === 'quit') {
        $msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);
    }
}
Example #7
0
 function query($query)
 {
     $mt = $this->getmicrotime();
     $return = parent::query($query);
     $time = $this->getmicrotime() - $mt;
     $r = mysql_query('EXPLAIN ' . $query, $this->mysql_link);
     $explain = $this->result_to_data($r);
     $ex_echo .= '<table border="1">';
     foreach ($explain as $key => $value) {
         if ($key == 0) {
             $ex_echo .= '<tr>';
             foreach ($value as $key2 => $value2) {
                 $ex_echo .= '<td>' . $key2 . '</td>';
             }
             $ex_echo .= '</tr>';
         }
         $ex_echo .= '<tr>';
         foreach ($value as $key2 => $value2) {
             $ex_echo .= '<td>' . $value2 . '</td>';
         }
         $ex_echo .= '</tr>';
     }
     $ex_echo .= '</table>';
     echo '<tr><td>' . $query . '</td><td>' . $ex_echo . '</td><td>' . $time . '</td></tr>';
     return $return;
 }
Example #8
0
 public function query($sql)
 {
     if ($this->params && strtoupper(substr($sql, 0, 6)) == 'SELECT') {
         parent::getInstance_slave($this->params);
         return parent::query($sql, self::$instance_slave->db_link);
     } else {
         return parent::query($sql);
     }
 }
 /**
  * отображаем весь список материалов
  */
 function indexAction()
 {
     $this->table_name = $_GET['tablename'];
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->table_name . ' where id>0 ' . general::get_status_for_filter($_GET['tablename']) . ' order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
Example #10
0
 static function get_otvet($name_file, $id_parent)
 {
     // выбираем вопрос
     $_sql = "SELECT\n\t\t\tvoting.id,\n\t\t\tvoting.id_parent,\n\t\t\tvoting.`text`,\n\t\t\tvoting.kolvo,\n\t\t\tROUND(voting.kolvo*100/voting.summa) as summa\n\t\t\tFROM\n\t\t\t\tvoting\n\t\t\tjoin (select SUM(voting.kolvo) as summa from voting WHERE voting.status = 1 and voting.id_parent = " . intval($id_parent) . ") as voting\n\t\t\tWHERE\n\t\t\t\tvoting.status = 1 and\n\t\t\t\tvoting.id_parent = " . intval($id_parent) . "\n\t\t\torder by voting.sort\n\t\t\t";
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     // выполняем tpl
     return system::show_tpl(array('otvet' => $result), $name_file);
 }
Example #11
0
 public function testAction()
 {
     $conn = new mysql();
     $conn->open(getSqlConfig('main'));
     $sql = "select * from userinfo";
     $result = $conn->query_select($sql);
     var_dump($result);
     $r1 = $conn->query($sql);
     echo Carbon\Carbon::today();
     return false;
 }
Example #12
0
 /**
  * Destroys a record in the table
  *
  * @param integer $id ()
  * @access public
  */
 function destroy($id)
 {
     $sql = "DELETE FROM {$this->table} WHERE {$this->primary_key} = {$id}";
     $result = $this->db->query($sql);
     if ($this->debug) {
         echo '<p><strong>Destroy SQL:</strong> ' . $sql . '</p>';
         if ($this->db->isError()) {
             echo $this->db->getErrorMsg();
             return false;
         }
     }
     return true;
 }
 /**
  * редактирование настроек
  */
 function editAction()
 {
     if ($_POST) {
         // записываем в базу
         forms::multy_update_form_all_records($this->tablename, 'zna', 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where status=1 order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/edit.php');
 }
Example #14
0
 /**
  * отображаем весь список материалов
  */
 function indexAction()
 {
     // если перешли по get ссылке из меню
     //if(isset($_GET['status'])) { $_POST['status']=$_GET['status']; }
     if (isset($_POST['status'])) {
         $_SESSION['status'] = $_POST['status'];
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where id>0 ' . general::get_status_for_filter($this->tablename) . ' order by id desc';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
Example #15
0
 private function __construct()
 {
     //-----------需要页面显示调试信息,	注释掉下面两行即可---
     set_error_handler(array("Core", 'appError'));
     set_exception_handler(array("Core", 'appException'));
     date_default_timezone_set("Asia/Shanghai");
     if (version_compare(PHP_VERSION, '5.4.0', '<')) {
         @set_magic_quotes_runtime(0);
         define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc() ? True : False);
     }
     //设置根目录
     if (!defined('WEB_PATH')) {
         define("WEB_PATH", "/data/web/notice.valsun.cn/");
     }
     //加载通用检测方法
     include_once WEB_PATH . "lib/common.php";
     //加载全局配置信息
     C(include_once WEB_PATH . 'conf/common.php');
     include_once WEB_PATH . "lib/auth.php";
     //鉴权
     //Auth::setAccess(include WEB_PATH.'conf/access.php');
     include_once WEB_PATH . "lib/log.php";
     include_once WEB_PATH . "lib/page.php";
     include_once WEB_PATH . "lib/authuser.class.php";
     include_once WEB_PATH . "lib/opensys_functions.php";
     //加载数据接口层及所需支撑
     include_once WEB_PATH . "lib/service/http.php";
     //网络接口
     include_once WEB_PATH . "lib/functions.php";
     include_once WEB_PATH . "lib/cache/cache.php";
     //memcache
     if (C("DATAGATE") == "db") {
         $db = C("DB_TYPE");
         include_once WEB_PATH . "lib/db/" . $db . ".php";
         //db直连
         if ($db == "mysql") {
             global $dbConn;
             $db_config = C("DB_CONFIG");
             $dbConn = new mysql();
             $dbConn->connect($db_config["master1"][0], $db_config["master1"][1], $db_config["master1"][2]);
             $dbConn->select_db($db_config["master1"][4]);
             $dbConn->query('set names utf8');
         }
         if ($db == "mongodb") {
             //.......
         }
     }
     //自动加载类
     spl_autoload_register(array('Core', 'autoload'));
 }
    /**
     * выбираем все заказы юзера
     */
    static function get_Order($id)
    {
        // строим запрос
        $_sql = 'SELECT orders.*
				FROM orders 
				WHERE orders.number_order=' . intval($id);
        // выполняем запрос + при необходимости выводим сам запрос
        $result = mysql::query($_sql, 0);
        if ($result) {
            return $result;
        } else {
            return false;
        }
    }
    /**
     * отображаем весь список материалов
     */
    function indexAction()
    {
        // строим запрос
        $_sql = 'SELECT
					price.*,
					count(price.id) as count
				FROM
					price
				GROUP BY
					price.id desc';
        // выполняем запрос + при необходимости выводим сам запрос
        $result = mysql::query($_sql, 0);
        return system::show_tpl(array('result' => $result, 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
    }
 function _post($response)
 {
     include_once "../main.php";
     // ищем группы меню и проверяем на СуперАдмина
     if (general::sadmin()) {
         $_sql = "select * from menu where id_parent=0 and status=1 order by zindex";
     } else {
         $_sql = "select * from menu where id_parent=0 and status=1 and adm!=1 order by zindex";
     }
     $result = mysql::query($_sql, 0);
     $this->menu = system::show_tpl(array('result' => $result), 'mainmenu/menu.php');
     $this->center_block = $response;
     echo system::show_tpl((array) $this, $this->layout);
 }
 /**
  * add new podrazdel
  */
 function add_answerAction()
 {
     if ($_POST) {
         // проверяем на checkbox
         forms::check_box(array('status'));
         // записываем в базу
         forms::multy_insert_form($this->tablename, 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
         $_GET['id_parent'] = $_POST['FORM']['id_parent'];
     }
     // выбираем разделы у которых могут быть подразделы
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where id=' . $_GET['id_parent'];
     $select = mysql::query($_sql, 0);
     return system::show_tpl(array('select' => $select, 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/add_answer.php');
 }
    /**
     * отображаем весь список материалов
     */
    function indexAction()
    {
        // если перешли по get ссылке из меню
        //if(isset($_GET['status'])) { $_POST['status']=$_GET['status']; }
        if (isset($_POST['status'])) {
            $_SESSION['status'] = $_POST['status'];
        }
        // строим запрос
        $_sql = 'SELECT news_gb.*, news.zag as zag 
				FROM news_gb, news 
				WHERE news.id=news_gb.id_news ' . general::get_status_for_filter('news_gb') . ' 
				ORDER by id desc';
        // выполняем запрос + при необходимости выводим сам запрос
        $result = mysql::query($_sql, 0);
        return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
    }
Example #21
0
 /**
  * @descrpition 从微信服务器获取微信ACCESS_TOKEN
  * @return Ambigous|bool
  */
 private static function _getAccessToken()
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . WECHAT_APPID . '&secret=' . WECHAT_APPSECRET;
     $accessToken = Curl::callWebServer($url, '', 'GET');
     if (!isset($accessToken['access_token'])) {
         return Msg::returnErrMsg(MsgConstant::ERROR_GET_ACCESS_TOKEN, '获取ACCESS_TOKEN失败');
     }
     $accessToken['time'] = time();
     $accessTokenJson = json_encode($accessToken);
     //存入数据库
     $db = new mysql();
     $db->connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
     $sql = "update accesstoken set access_token='" . $accessTokenJson . "' where id=1";
     $db->query($sql);
     return $accessToken;
 }
Example #22
0
 /**
  * @descrpition 从微信服务器获取js sdk api_ticket
  * @return Ambigous|bool
  */
 private static function _getJsapiTicket()
 {
     $accessToken = AccessToken::getAccessToken();
     $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=" . $accessToken;
     $JsapiTicket = Curl::callWebServer($url, '', 'GET');
     if (!isset($JsapiTicket['ticket'])) {
         return Msg::returnErrMsg(MsgConstant::ERROR_GET_ACCESS_TOKEN, '获取js ticket失败');
     }
     $JsapiTicket['time'] = time();
     $JsapiTicketJson = json_encode($JsapiTicket);
     //存入数据库
     $db = new mysql();
     $db->connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
     $sql = "update jsapiticket set ticket='" . $JsapiTicketJson . "' where id=1";
     $db->query($sql);
     return $JsapiTicket;
 }
    /**
     * отображаем весь список материалов
     */
    function indexAction()
    {
        if (isset($_POST['status'])) {
            $_SESSION['status'] = $_POST['status'];
        }
        // строим запрос
        $_sql = 'SELECT *
				FROM
					gallery_grupa
				WHERE gallery_grupa.id_parent=0' . general::get_status_for_filter('gallery_grupa') . '
				GROUP BY
					gallery_grupa.id
				order by gallery_grupa.sort';
        // выполняем запрос + при необходимости выводим сам запрос
        $result = mysql::query($_sql, 0);
        return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
    }
 /**
  * отображаем весь список материалов
  */
 function indexAction()
 {
     if (isset($_POST['status'])) {
         $_SESSION['status'] = $_POST['status'];
     }
     if (isset($_POST['status'])) {
         $limit = 1000;
     } else {
         $_total_news = dbh::news_get_total_count();
         $limit = pager::pager_limit($_total_news, ADMIN_NEWS_AT_PAGE);
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where id>0 ' . general::get_status_for_filter($this->tablename) . ' order by created_at desc, sort limit ' . $limit;
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 3);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder, '_total_news' => $_total_news), $this->tpl_folder . '/index.php');
 }
 /**
  * добавляем новый материал
  */
 function addAction()
 {
     global $_sklad;
     if ($_POST) {
         // проверяем на checkbox
         forms::check_box(array('status'));
         //for($i=0; $i<50; $i++) {
         // записываем в базу
         forms::multy_insert_form($this->tablename, 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
         //}
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where id>0 order by sort desc';
     // выполняем запрос + при необходимости выводим сам запрос
     $select = mysql::query($_sql, 0);
     return system::show_tpl(array('city' => dbh::get_city(), 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/add.php');
 }
Example #26
0
function get_content($action)
{
    $lang = '_' . $_GET['lang'];
    // выбираем родителя
    // запрос
    $_sql = 'SELECT * FROM content where status=1 and action="' . $action . '"';
    // выполняем запрос + при необходимости выводим сам запрос
    $parent = mysql::query_one($_sql, 0);
    // выбираем детей
    $_sql = "select name_" . $_GET['lang'] . ", action from content where id_parent=" . $parent->id . " order by sort";
    // выполняем запрос + при необходимости выводим сам запрос
    $child = mysql::query($_sql, 0);
    // выбираем файлы загруженные к этому разделу
    $_sql_files = 'SELECT * FROM files where id_content=' . $parent->id . ' order by id';
    $_files = mysql::query($_sql_files, 0);
    // выполняем tpl
    return system::show_tpl(array('parent' => $parent, 'child' => $child, 'gallery_grupa' => $gallery_grupa, '_files' => $_files), '/frontend/content/index.php');
}
    /**
     * 	get guestbook first page
     *	@param  int		$limit 		- count of news for return
     * 			text	$name_file 	- name of tamplate (plus path '/tpl/....') 
     */
    static function get_guestbook_first_page($name_file, $limit = false)
    {
        $__limit = '';
        if ($limit) {
            $__limit = 'limit ' . $limit;
        }
        $_sql = 'SELECT *
					FROM guestbook
					WHERE status=1 
					order by rand() ' . $__limit;
        // выполняем запрос + при необходимости выводим сам запрос
        $result = mysql::query($_sql, 0);
        if ($result) {
            return system::show_tpl(array('gallery' => $result), $name_file);
        } else {
            return '';
        }
    }
Example #28
0
    /**
     * 	get gallery first page
     *	@param  int		$limit 		- count of news for return
     * 			text	$name_file 	- name of tamplate (plus path '/tpl/....') 
     */
    static function get_gallery_first_page($name_file, $limit = false)
    {
        $__limit = '';
        if ($limit) {
            $__limit = 'limit ' . $limit;
        }
        $_sql = 'SELECT gallery.*, gallery_grupa.url 
					FROM gallery, gallery_grupa
					WHERE gallery.id_parent=gallery_grupa.id and gallery.status=1 and gallery.firstpage=1 
					order by rand() ' . $__limit;
        // выполняем запрос + при необходимости выводим сам запрос
        $result = mysql::query($_sql, 0);
        if ($result) {
            return system::show_tpl(array('gallery' => $result), $name_file);
        } else {
            return '';
        }
    }
 /**
  * 执行SQL语句
  * @param  string $sql 需要执行的sql语句
  */
 public function query($sql)
 {
     if (empty($sql)) {
         return false;
     }
     $this->sql = $sql;
     try {
         $this->connect();
         return $this->db->query($this->sql);
     } catch (\Exception $e) {
         if ($this->config['debug'] !== false) {
             throw new \Exception($e->getMessage());
         } else {
             $this->error = $e->getMessage();
         }
     }
     return;
 }
Example #30
0
 function synlogin($user)
 {
     global $timestamp, $uc_key;
     list($winduid, $windid, $windpwd) = explode("\t", $this->base->strcode($user, false));
     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     require_once "../../config/db.config.php";
     require_once "../../app/include/mysql.class.php";
     require_once "../../app/include/public.function.php";
     require_once "../../data/plus/config.php";
     $ip = fun_ip_get();
     $time = time();
     if ($config[sy_pw_type] == "pw_center") {
         $db = new mysql($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname'], ALL_PS, $db_config['charset']);
         $user_query = $db->query("SELECT * FROM {$db_config['def']}member WHERE `username`='{$windid}'");
         while ($userrs = $db->fetch_array($user_query)) {
             $userinfo = $userrs;
         }
         //判断是否是重名用户
         if ($userinfo["uid"] > 0) {
             if ($userinfo["pw_repeat"] != "1") {
                 //判断账户名密码是否一致
                 if ($userinfo["password"] == md5($windpwd . $userinfo[salt])) {
                     $db->query("UPDATE {$db_config['def']}member SET `pwuid`='{$winduid}' WHERE `uid`='{$userinfo['uid']}'");
                     $this->unset_cookie();
                     $this->add_cookie($userinfo[uid], $userinfo[username], $userinfo[salt], $userinfo[email], $userinfo[password]);
                 } else {
                     //不一致标注为重名用户
                     $db->query("UPDATE {$db_config['def']}member SET `pw_repeat`='1' WHERE `uid`='{$userinfo['uid']}'");
                 }
             }
         } else {
             //用户不存在 新建一个用户
             $salt = substr(uniqid(rand()), -6);
             $pass = md5($windpwd . $salt);
             $db->query("INSERT INTO {$db_config['def']}member SET `username`='{$windid}',`password`='{$pass}',`salt`='{$salt}',`usertype`='1',`reg_ip`='{$ip}',`reg_date`='{$time}',`pwuid`='{$winduid}'");
             $uid = $db->insert_id();
             $db->query("INSERT INTO {$db_config['def']}resume SET `uid`='" . $uid . "'");
             $db->query("INSERT INTO {$db_config['def']}member_statis SET `uid`='" . $uid . "'");
             $this->unset_cookie();
             $this->add_cookie($winduid, $windid, $salt, "", $pass);
         }
     }
 }