function tpl_function_qishi_train_news_show($params, &$smarty)
{
    global $db;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "新闻ID":
                $aset['id'] = $a[1];
                break;
            case "列表名":
                $aset['listname'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['id'] = $aset['id'] ? intval($aset['id']) : 0;
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    unset($arr, $str, $a, $params);
    $sql = "select id,title,content,addtime,train_id from " . table('train_news') . " WHERE  id=" . intval($aset['id']) . " LIMIT 1";
    $val = $db->getone($sql);
    if (empty($val)) {
        header("HTTP/1.1 404 Not Found");
        $smarty->display("404.htm");
        exit;
    }
    $val['keywords'] = $val['title'];
    $val['description'] = cut_str(strip_tags($val['content']), 60, 0, "");
    $smarty->assign($aset['listname'], $val);
}
Beispiel #2
0
function faq__load_answer($faq_id = "")
{
    $pars = array(':faq_id' => $faq_id);
    $query = "SELECT * from " . table('lang') . "\n            WHERE content_type='faq_answer'\n            AND content_name= :faq_id";
    $line = orsee_query($query, $pars);
    return $line;
}
Beispiel #3
0
 /**
  */
 function show()
 {
     $filter_name = $_GET['object'] . '__' . $_GET['action'];
     $default_filter = ['order_by' => 'date', 'order_direction' => 'desc'];
     $sql = 'SELECT * FROM ' . db('log_auth');
     return table($sql, ['filter' => (array) $_SESSION[$filter_name] + $default_filter, 'filter_params' => ['name' => 'like']])->user('user_id')->text('login')->link('group', './?object=user_groups&action=edit&id=%d', main()->get_data('user_groups'))->link('ip', './?object=' . $_GET['object'] . '&action=show_for_ip&id=%d')->date('date', ['format' => 'full', 'nowrap' => 1])->text('user_agent')->text('referer');
 }
function tpl_function_qishi_news_property($params, &$smarty)
{
    global $db;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "名称长度":
                $aset['titlelen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "分类ID":
                $aset['ID'] = $a[1];
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    $aset['titlelen'] = $aset['titlelen'] ? intval($aset['titlelen']) : 8;
    if ($aset['ID']) {
        $wheresql = " WHERE id=" . intval($aset['ID']);
    }
    $List = $db->getall("SELECT id,categoryname,category_order FROM " . table('article_property') . " " . $wheresql);
    $smarty->assign($aset['listname'], $List);
}
function tpl_function_qishi_simple_show($params, &$smarty)
{
    global $db;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "ID":
                $aset['id'] = $a[1];
                break;
            case "ÁбíÃû":
                $aset['listname'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['id'] = $aset['id'] ? intval($aset['id']) : 0;
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    unset($arr, $str, $a, $params);
    $sql = "select * from " . table('simple') . " WHERE  id='{$aset['id']}' AND audit=1  LIMIT 1";
    $val = $db->getone($sql);
    if (empty($val)) {
        header("HTTP/1.1 404 Not Found");
        $smarty->display("404.htm");
        exit;
    }
    $val['keywords'] = "{$val['jobname']} {$val['comname']} ";
    $val['description'] = cut_str(strip_tags($val['detailed']), 60, 0, "");
    $smarty->assign($aset['listname'], $val);
}
Beispiel #6
0
 function generateConfirm($edit)
 {
     $dataInvalid = $this->isDataInvalid($edit);
     if ($this->formbuilder) {
         $this->formbuilder->bulk_set_answers($_POST[$this->event->formkey()]);
         $dataInvalid .= $this->formbuilder->answers_invalid();
     }
     if ($dataInvalid) {
         error_exit($dataInvalid . '<br>Please use your back button to return to the form, fix these errors, and try again.');
     }
     $output = para('Please confirm that this data is correct and click the submit button to proceed to the payment information page.');
     $output .= form_hidden('edit[step]', 'submit');
     $fields = array('Registration Status' => 'payment', 'Notes' => 'notes');
     $rows = array();
     foreach ($fields as $display => $column) {
         array_push($rows, array($display, form_hidden("edit[{$column}]", $edit[$column]) . check_form($edit[$column])));
     }
     $output .= form_group('Registration details', "<div class='pairtable'>" . table(null, $rows) . '</div>');
     if ($this->formbuilder) {
         $form = $this->formbuilder->render_viewable();
         $form .= $this->formbuilder->render_hidden();
         $output .= form_group('Registration answers', $form);
     }
     $output .= para(form_submit('submit'));
     return form($output);
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     DB:
     table('authors')->where('name', '=', 'Ramish Fatima')->delete();
     DB:
     table('authors')->where('name', '=', 'Mahnoor Fatima')->delete();
 }
 function region()
 {
     $session_key = $_GET['object'] . '__' . $_GET['action'];
     $filter = ['filter' => $_SESSION[$session_key], 'filter_params' => ['id' => 'in', 'value' => 'like']];
     $table = table('SELECT * FROM ' . db('shop_regions'), $filter)->text('id', 'Номер')->text('value', 'Название')->btn_edit('', $this->_uri['edit'], ['no_ajax' => 1])->btn_delete('', $this->_uri['delete'])->btn_active('', $this->_uri['active'])->footer_add('', $this->_uri['add'], ['no_ajax' => 1]);
     return $table;
 }
Beispiel #9
0
 public function index()
 {
     $id = intval($_REQUEST['id']);
     $post_key = $this->_get('post_key', 'trim');
     if (empty($id)) {
         $where = array('post_key' => $post_key);
     } else {
         $where = array('id' => $id);
     }
     $where['post_time'] = array('elt', time());
     $where['status'] = 1;
     $res = $this->post_mod->relation(true)->where($where)->find();
     if ($res) {
         $res['cate_list'] = $this->post_cate_re_mod->relation(true)->where(array('post_id' => $res['id']))->select();
         $this->assign('info', $res);
         $tag_list = $this->post_tag_mod->relation(true)->where("post_id={$res['id']}")->select();
         $this->assign('tag_list', $tag_list);
         $this->assign('prev_post', $this->post_mod->where("id>{$res['id']} and status=1 and post_time<=" . time())->order("id asc")->find());
         $this->assign('next_post', $this->post_mod->where("id<{$res['id']} and status=1 and post_time<=" . time())->order("id desc")->find());
         $where = "id in(select post_id from " . table('post_tag') . " where \n                tag_id in(select tag_id from " . table('post_tag') . " where post_id={$res['id']}) \n                and post_id!={$res['id']})";
         $this->assign('like_list', $this->post_mod->where($where)->limit(4)->select());
         $post_tag = '';
         foreach ($tag_list as $val) {
             $post_tag .= $val['tag']['name'];
         }
         $this->_config_seo(C('pin_seo_config.post'), array('post_title' => $res['title'], 'post_tag' => $post_tag, 'user_name' => $res['uname'], 'seo_title' => $res['seo_title'], 'seo_keywords' => $res['seo_keys'], 'seo_description' => $res['seo_desc']));
         $this->comment_list($res['id']);
     } else {
         $this->error("作品不存在");
     }
     $this->display();
 }
Beispiel #10
0
 function score_entry_display()
 {
     global $dbh;
     $sth = $dbh->prepare('SELECT * FROM score_entry WHERE team_id = ? AND game_id = ?');
     $sth->execute(array($this->game->home_team, $this->game->game_id));
     $home = $sth->fetch();
     if (!$home) {
         $home = array('score_for' => 'not entered', 'score_against' => 'not entered', 'defaulted' => 'no');
     } else {
         $entry_person = Person::load(array('user_id' => $home['entered_by']));
         $home['entered_by'] = l($entry_person->fullname, "person/view/{$entry_person->user_id}");
     }
     $sth->execute(array($this->game->away_team, $this->game->game_id));
     $away = $sth->fetch();
     if (!$away) {
         $away = array('score_for' => 'not entered', 'score_against' => 'not entered', 'defaulted' => 'no');
     } else {
         $entry_person = Person::load(array('user_id' => $away['entered_by']));
         $away['entered_by'] = l($entry_person->fullname, "person/view/{$entry_person->user_id}");
     }
     $header = array("&nbsp;", $this->game->home_name . ' (home)', $this->game->away_name . ' (away)');
     $rows = array();
     $rows[] = array("Home Score:", $home['score_for'], $away['score_against']);
     $rows[] = array("Away Score:", $home['score_against'], $away['score_for']);
     $rows[] = array("Defaulted?", $home['defaulted'], $away['defaulted']);
     $rows[] = array("Entered By:", $home['entered_by'], $away['entered_by']);
     $rows[] = array("Entry time:", $home['entry_time'], $away['entry_time']);
     return '<div class="listtable">' . table($header, $rows) . "</div>";
 }
 /**
  */
 function express()
 {
     $date = date("Y-m-d");
     $orders_info = db()->query_fetch_all("SELECT * FROM " . db('shop_orders') . " WHERE delivery_time LIKE '" . $date . "%' AND status = 1");
     if (!empty($orders_info)) {
         $orders = array_keys($orders_info);
         $products = db()->query_fetch_all("SELECT o.*, p.name, p.price, p.cat_id\n\t\t\t\t\t\t\t\t\t\t\tFROM " . db('shop_order_items') . " as o\n\t\t\t\t\t\t\t\t\t\t\tRIGHT JOIN " . db('shop_products') . " as p ON o.product_id = p.id\n\t\t\t\t\t\t\t\t\t\t\tWHERE o.order_id IN(" . implode(",", $orders) . ") AND o.status = 1\n\t\t\t\t\t\t\t\t\t\t\tORDER BY o.order_id DESC");
     }
     $_category = _class("_shop_categories", "modules/shop/");
     //always add one empty row in table for ajax
     if (empty($products)) {
         $products[] = ['product_id' => '-', 'name' => '-', 'quantity' => '-', 'price' => '-', 'order_id' => '-'];
         $orders_info['-']['delivery_time'] = '-';
     }
     foreach ((array) $products as $k => $v) {
         $replace[] = ["product_id" => $v['product_id'], "name" => $v['name'], "quantity" => $v['quantity'], "price" => module('shop')->_format_price(floatval($v['price'])), "order_id" => $v['order_id'], "id" => $v['order_id'] . '_' . $v['product_id'], "time" => str_replace($date, "", $orders_info[$v['order_id']]['delivery_time'])];
         $table_tr[] = 'data-id="' . $v['order_id'] . '_' . $v['product_id'] . '" ';
     }
     if (!empty($_GET['ajax_mode'])) {
         return json_encode($replace);
     }
     $table = table($replace)->text('order_id')->text('time')->text('name')->text('quantity')->text('product_id')->footer_link("PDF " . $date . " 10-12", './?object=' . $_GET['object'] . '&action=express_pdf&hours=10-12')->footer_link("PDF " . $date . " 13-15", './?object=' . $_GET['object'] . '&action=express_pdf&hours=13-15')->footer_link("PDF " . $date . " 17-20", './?object=' . $_GET['object'] . '&action=express_pdf&hours=17-20')->render(['table_attr' => 'id="express_catalog"', 'tr' => $table_tr]);
     $replace = ['table' => $table];
     return tpl()->parse("manage_shop/express", $replace);
 }
 function textile($text, $lite = '')
 {
     if (get_magic_quotes_gpc() == 1) {
         $text = stripslashes($text);
     }
     $text = incomingEntities($text);
     $text = encodeEntities($text);
     $text = fixEntities($text);
     $text = cleanWhiteSpace($text);
     $text = getRefs($text);
     $text = noTextile($text);
     $text = image($text);
     $text = links($text);
     $text = span($text);
     $text = superscript($text);
     $text = footnoteRef($text);
     $text = code($text);
     $text = glyphs($text);
     $text = retrieve($text);
     if ($lite == '') {
         $text = lists($text);
         $text = table($text);
         $text = block($text);
     }
     /* clean up <notextile> */
     $text = preg_replace('/<\\/?notextile>/', "", $text);
     /* turn the temp char back to an ampersand entity */
     $text = str_replace("x%x%", "&amp;", $text);
     $text = str_replace("<br />", "<br />\n", $text);
     return trim($text);
 }
Beispiel #13
0
function batchInsert($table, $data)
{
    $sql = "INSERT INTO" . table($table) . "(";
    $array = $data;
    $keys = array_keys(array_shift($array));
    //print_r($keys);
    $fields = $values = array();
    foreach ($keys as $v) {
        $fields[] = '`' . $v . '`';
    }
    $sql .= implode(',', $fields);
    $sql .= ") VALUES  ";
    foreach ($data as $k1 => $v1) {
        $val = array();
        foreach ($v1 as $v2) {
            //print_r($v2);exit;
            $val[] = $v2;
            //print_r($val);exit;
        }
        $values[] = '(' . implode(',', $val) . ')';
    }
    $sql .= implode(',', $values);
    $sql .= ";";
    mysql_query($sql);
}
 /**
  */
 function show()
 {
     $filter_name = $_GET['object'] . '__' . $_GET['action'];
     $default_filter = ['order_by' => 'date', 'order_direction' => 'desc'];
     $sql = 'SELECT * FROM ' . db('log_redirects') . ' WHERE is_admin="' . strval(!$this->FOR_USER ? 1 : 0) . '"';
     return table($sql, ['filter' => (array) $_SESSION[$filter_name] + $default_filter, 'filter_params' => ['url_from' => 'like', 'url_to' => 'like', 'ip' => 'like', 'user_agent' => 'like', 'referer' => 'like']])->admin('user_id')->link('ip', './?object=' . $_GET['object'] . '&action=show_for_ip&id=%d')->date('date', ['format' => 'full', 'nowrap' => 1])->text('user_agent')->text('referer')->text('url_from')->text('url_to')->text('exec_time');
 }
Beispiel #15
0
 function insertUpdate($table, $rows, $primary)
 {
     $columns = array_keys(reset($rows));
     $prefix = "INSERT INTO " . table($table) . " (" . implode(", ", $columns) . ") VALUES\n";
     $values = array();
     foreach ($columns as $key) {
         $values[$key] = "{$key} = VALUES({$key})";
     }
     $suffix = "\nON DUPLICATE KEY UPDATE " . implode(", ", $values);
     $values = array();
     $length = 0;
     foreach ($rows as $set) {
         $value = "(" . implode(", ", $set) . ")";
         if ($values && strlen($prefix) + $length + strlen($value) + strlen($suffix) > 1000000.0) {
             // 1e6 - default max_allowed_packet
             if (!queries($prefix . implode(",\n", $values) . $suffix)) {
                 return false;
             }
             $values = array();
             $length = 0;
         }
         $values[] = $value;
         $length += strlen($value) + 2;
         // 2 - strlen(",\n")
     }
     return queries($prefix . implode(",\n", $values) . $suffix);
 }
Beispiel #16
0
	public function get_list($status = 0, $user_id = MEMBER_ID)
	{
		$timestamp = time();
		if ($status == 0 ) {
			$sql_limit_status = 'p.overtime > '.$timestamp.' AND p.begintime < '.$timestamp;
		}
		if($status == 1){
			$sql_limit_status = 'p.overtime < '.$timestamp;
		}
		if($status == 2){
			$sql_limit_status = 'p.begintime > '.$timestamp;
		}
		if ($status == -1) {
			$sql_limit_status = '1';
		}

		$sql = 'SELECT p.*, f.uid, f.pid
		FROM
			' . table('favorite') .' f
		,
			' . table('product') . ' p
		WHERE
			'."f.uid = ".$user_id.'
		AND
			f.pid = p.id
		AND
			'. $sql_limit_status;
		$sql = page_moyo($sql);
		$results = dbc(DBCMax)->query($sql)->done();
		return $results;
	}
Beispiel #17
0
 /**
  */
 function show()
 {
     $filter_name = $_GET['object'] . '__' . $_GET['action'];
     $default_filter = ['order_by' => 'add_date', 'order_direction' => 'desc'];
     $sql = 'SELECT * FROM ' . db('comments');
     return table($sql, ['filter' => (array) $_SESSION[$filter_name] + $default_filter, 'filter_params' => ['text' => 'like']])->date('add_date', ['format' => 'full', 'nowrap' => 1])->text('object_name', ['link' => './?object=' . $_GET['object'] . '&action=redirect_view&id=%d', 'link_field_name' => 'id'])->text('object_id', 'oid')->text('text', ['max_length' => $this->TEXT_PREVIEW_LENGTH])->user('user_id')->text('ip', ['link' => './?object=' . $_GET['object'] . '&action=filter_save&page=clear&filter=ip:%d'])->btn_active()->btn_edit()->btn_delete();
 }
Beispiel #18
0
 public function getSignPackage($listid)
 {
     $configs = globaSetting(array("weixin_appId", "shop_logo"));
     $appid = $configs['weixin_appId'];
     $scene_list = mysqld_select('SELECT * FROM' . table('addon10_scene_list') . ' WHERE `id`=:id  ', array(':id' => $listid));
     $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
     $url = "{$protocol}{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
     $jsapiTicket = $this->addon_get_js_ticket();
     $timestamp = time();
     $nonceStr = $this->createNonceStr();
     $string = "jsapi_ticket={$jsapiTicket}&noncestr={$nonceStr}&timestamp={$timestamp}&url={$url}";
     $signature = sha1($string);
     $title = $scene_list['share_title'];
     $imgUrl = WEBSITE_ROOT . "attachment/" . $scene_list['share_thumb'];
     $description = $scene_list['share_content'];
     if (empty($imgUrl)) {
         $imgUrl = WEBSITE_ROOT . "attachment/" . $configs['shop_logo'];
     }
     if (empty($description)) {
         $description = $configs['shop_title'];
     }
     if (empty($title)) {
         $title = $configs['shop_title'];
     }
     $signPackage = array("appId" => $appid, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "title" => $title, "imgUrl" => $imgUrl, "link" => WEBSITE_ROOT . mobile_url('show', array('id' => $listid)), "signature" => $signature, "description" => $description, "rawString" => $string);
     return $signPackage;
 }
Beispiel #19
0
function updateOrderStock($id, $minus = true)
{
    $ordergoods = mysqld_selectall("SELECT * FROM " . table('shop_order_goods') . " WHERE orderid='{$id}'");
    foreach ($ordergoods as $item) {
        $goods = mysqld_select("SELECT * FROM " . table('shop_goods') . "  WHERE id='" . $item['goodsid'] . "'");
        if ($minus) {
            //属性
            if (!empty($item['optionid'])) {
                mysqld_query("update " . table('shop_goods_option') . " set stock=stock-:stock where id=:id", array(":stock" => $item['total'], ":id" => $item['optionid']));
            }
            $data = array();
            if ($goods['totalcnf'] != 1) {
                $data['total'] = $goods['total'] - $item['total'];
            }
            $data['sales'] = $goods['sales'] + $item['total'];
            mysqld_update('shop_goods', $data, array('id' => $item['goodsid']));
        } else {
            //属性
            if (!empty($item['optionid'])) {
                mysqld_query("update " . table('shop_goods_option') . " set stock=stock+:stock where id=:id", array(":stock" => $item['total'], ":id" => $item['optionid']));
            }
            $data = array();
            if ($goods['totalcnf'] != 1) {
                $data['total'] = $goods['total'] + $item['total'];
            }
            $data['sales'] = $goods['sales'] - $item['total'];
            mysqld_update('shop_goods', $data, array('id' => $item['goodsid']));
        }
    }
}
 /**
  */
 function show()
 {
     $filter_name = $_GET['object'] . '__' . $_GET['action'];
     $default_filter = ['order_by' => 'time', 'order_direction' => 'desc'];
     $sql = 'SELECT * FROM ' . db('log_auth_fails');
     return table($sql, ['filter' => (array) $_SESSION[$filter_name] + $default_filter, 'filter_params' => ['name' => 'like']])->text('reason', ['data' => $this->_reasons])->date('time', ['format' => 'full', 'nowrap' => 1])->link('ip', './?object=' . $_GET['object'] . '&action=show_for_ip&id=%d')->text('login')->text('pswd')->text('user_agent')->text('referer');
 }
Beispiel #21
0
 /**
  */
 function users()
 {
     if (empty($_SESSION[$_GET['object'] . '__users'])) {
         $_SESSION[$_GET['object'] . '__users'] = ['order_by' => 'add_date', 'order_direction' => 'desc'];
     }
     return table('SELECT * FROM ' . db('user'), ['filter' => $_SESSION[$_GET['object'] . '__users'], 'filter_params' => ['id' => 'like', 'name' => 'like', 'email' => 'like', 'phone' => 'like', 'address' => 'like', 'add_date' => 'dt_between']])->text('id')->text('name')->text('email')->text('phone')->text('address')->date('add_date', ['format' => 'full', 'nowrap' => 1])->btn_edit('', './?object=' . main()->_get('object') . '&action=user_edit&id=%d', ['no_ajax' => 1])->btn('Login', './?object=manage_users&action=login_as&id=%d')->btn_delete('', './?object=' . main()->_get('object') . '&action=user_delete&id=%d')->btn_active('', './?object=' . main()->_get('object') . '&action=user_activate&id=%d');
 }
Beispiel #22
0
 function dumpTable($table, $style, $is_view = false)
 {
     if ($_POST["format"] == "sql_alter") {
         $create = create_sql($table, $_POST["auto_increment"]);
         if ($is_view) {
             echo substr_replace($create, " OR REPLACE", 6, 0) . ";\n\n";
         } else {
             echo substr_replace($create, " IF NOT EXISTS", 12, 0) . ";\n\n";
             // create procedure which iterates over original columns and adds new and removes old
             $query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table) . " ORDER BY ORDINAL_POSITION";
             echo "DELIMITER ;;\nCREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN\n\tDECLARE _column_name, _collation_name, after varchar(64) DEFAULT '';\n\tDECLARE _column_type, _column_default text;\n\tDECLARE _is_nullable char(3);\n\tDECLARE _extra varchar(30);\n\tDECLARE _column_comment varchar(255);\n\tDECLARE done, set_after bool DEFAULT 0;\n\tDECLARE add_columns text DEFAULT '";
             $fields = array();
             $after = "";
             foreach (get_rows($query) as $row) {
                 $default = $row["COLUMN_DEFAULT"];
                 $row["default"] = $default !== null ? q($default) : "NULL";
                 $row["after"] = q($after);
                 //! rgt AFTER lft, lft AFTER id doesn't work
                 $row["alter"] = escape_string(idf_escape($row["COLUMN_NAME"]) . " {$row['COLUMN_TYPE']}" . ($row["COLLATION_NAME"] ? " COLLATE {$row['COLLATION_NAME']}" : "") . ($default !== null ? " DEFAULT " . ($default == "CURRENT_TIMESTAMP" ? $default : $row["default"]) : "") . ($row["IS_NULLABLE"] == "YES" ? "" : " NOT NULL") . ($row["EXTRA"] ? " {$row['EXTRA']}" : "") . ($row["COLUMN_COMMENT"] ? " COMMENT " . q($row["COLUMN_COMMENT"]) : "") . ($after ? " AFTER " . idf_escape($after) : " FIRST"));
                 echo ", ADD {$row['alter']}";
                 $fields[] = $row;
                 $after = $row["COLUMN_NAME"];
             }
             echo "';\n\tDECLARE columns CURSOR FOR {$query};\n\tDECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;\n\tSET @alter_table = '';\n\tOPEN columns;\n\tREPEAT\n\t\tFETCH columns INTO _column_name, _column_default, _is_nullable, _collation_name, _column_type, _extra, _column_comment;\n\t\tIF NOT done THEN\n\t\t\tSET set_after = 1;\n\t\t\tCASE _column_name";
             foreach ($fields as $row) {
                 echo "\n\t\t\t\tWHEN " . q($row["COLUMN_NAME"]) . " THEN\n\t\t\t\t\tSET add_columns = REPLACE(add_columns, ', ADD {$row['alter']}', IF(\n\t\t\t\t\t\t_column_default <=> {$row['default']} AND _is_nullable = '{$row['IS_NULLABLE']}' AND _collation_name <=> " . (isset($row["COLLATION_NAME"]) ? "'{$row['COLLATION_NAME']}'" : "NULL") . " AND _column_type = " . q($row["COLUMN_TYPE"]) . " AND _extra = '{$row['EXTRA']}' AND _column_comment = " . q($row["COLUMN_COMMENT"]) . " AND after = {$row['after']}\n\t\t\t\t\t, '', ', MODIFY {$row['alter']}'));";
                 //! don't replace in comment
             }
             echo "\n\t\t\t\tELSE\n\t\t\t\t\tSET @alter_table = CONCAT(@alter_table, ', DROP ', '`', REPLACE(_column_name, '`', '``'), '`');\n\t\t\t\t\tSET set_after = 0;\n\t\t\tEND CASE;\n\t\t\tIF set_after THEN\n\t\t\t\tSET after = _column_name;\n\t\t\tEND IF;\n\t\tEND IF;\n\tUNTIL done END REPEAT;\n\tCLOSE columns;\n\tIF @alter_table != '' OR add_columns != '' THEN\n\t\tSET alter_command = CONCAT(alter_command, 'ALTER TABLE " . table($table) . "', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n');\n\tEND IF;\nEND;;\nDELIMITER ;\nCALL adminer_alter(@adminer_alter);\nDROP PROCEDURE adminer_alter;\n\n";
             //! indexes
         }
         return true;
     }
 }
function tpl_function_qishi_help_show($params, &$smarty)
{
    global $db;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "ID":
                $aset['id'] = $a[1];
                break;
            case "ÁбíÃû":
                $aset['listname'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    $sql = "select id,type_id,parentid,title,content,click,addtime from " . table('help') . " WHERE  id=" . intval($aset['id']) . " LIMIT   1";
    $val = $db->getone($sql);
    if (empty($val)) {
        header("HTTP/1.1 404 Not Found");
        $smarty->display("404.htm");
        exit;
    }
    $val['keywords'] = $val['title'];
    $val['description'] = cut_str(strip_tags($val['content']), 60, 0, "");
    $val['content'] = htmlspecialchars_decode($val['content'], ENT_QUOTES);
    $smarty->assign($aset['listname'], $val);
}
Beispiel #24
0
function tpl_function_qishi_link($params, &$smarty)
{
    global $db, $_CFG;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "文字长度":
                $aset['len'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "类型":
                $aset['linktype'] = $a[1];
                break;
            case "调用名称":
                $aset['alias'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['row'] = isset($aset['row']) ? intval($aset['row']) : 60;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['len'] = isset($aset['len']) ? intval($aset['len']) : 8;
    $aset['linktype'] = isset($aset['linktype']) ? intval($aset['linktype']) : 1;
    $aset['dot'] = isset($aset['dot']) ? $aset['dot'] : '';
    if ($aset['linktype'] == "1") {
        $wheresql = " WHERE link_logo='' ";
    } else {
        $wheresql = " WHERE link_logo<>'' ";
    }
    $wheresql .= " AND display=1 ";
    if (intval($_CFG['subsite_id']) > 0) {
        $wheresql .= " AND subsite_id=" . intval($_CFG['subsite_id']) . " ";
    }
    if ($aset['alias']) {
        $wheresql .= " AND alias='" . $aset['alias'] . "' ";
    }
    $limit = " LIMIT " . intval($aset['start']) . ',' . intval($aset['row']);
    $result = $db->query("SELECT link_url,link_name,link_logo FROM " . table('link') . " " . $wheresql . " ORDER BY show_order DESC " . $limit);
    $list = array();
    while ($row = $db->fetch_array($result)) {
        $row['title_'] = $row['link_name'];
        $row['title'] = cut_str($row['link_name'], $aset['len'], 0, $aset['dot']);
        $list[] = $row;
    }
    unset($arr, $str, $a, $params);
    $smarty->assign($aset['listname'], $list);
}
Beispiel #25
0
function get_admin_account($admin_id)
{
    global $db;
    $admin_id = intval($admin_id);
    $account = $db->getone("SELECT * FROM " . table('admin') . " WHERE admin_id = '{$admin_id}'");
    return $account;
}
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema:
     table('category_todolist', function ($table) {
         $table->dropColumn('description');
     });
 }
function tpl_function_qishi_evaluationinfo($params, &$smarty)
{
    global $db, $_CFG;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "分类ID":
                $aset['id'] = $a[1];
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    $aset['id'] = $aset['id'] ? $aset['id'] : 1;
    //测评类型信息
    $sql = "select * from " . table('evaluation_type') . " where id = " . intval($aset['id']) . " LIMIT  1";
    $info = $db->getone($sql);
    //该测评类型的试卷信息
    $paper_sql = "select * from " . table('evaluation_paper') . " where type_id = " . intval($info['id']) . " ";
    $paper_info = $db->getall($paper_sql);
    $info['paper'] = $paper_info;
    $smarty->assign($aset['listname'], $info);
}
Beispiel #28
0
 /**
  */
 function show()
 {
     $filter_name = $_GET['object'] . '__' . $_GET['action'];
     $default_filter = ['order_by' => 'date', 'order_direction' => 'desc'];
     $sql = 'SELECT * FROM ' . db('log_admin_exec');
     return table($sql, ['filter' => (array) $_SESSION[$filter_name] + $default_filter, 'filter_params' => ['ip' => 'like', 'user_agent' => 'like', 'referer' => 'like', 'request_uri' => 'like']])->admin('admin_id')->link('ip', './?object=' . $_GET['object'] . '&action=show_for_ip&id=%d')->date('date', ['format' => 'full', 'nowrap' => 1])->text('user_agent')->text('referer')->text('request_uri')->text('exec_time')->text('num_dbq')->text('page_size');
 }
Beispiel #29
0
function calcular_factura($articulos, $precios, $cantidades, $iva)
{
    //
    global $sep;
    $headings = ["articulo", "precio", "cantidad", "subtotal"];
    $datos = [];
    // array de arrays de datos para table()
    if (strlen($articulos) > 0) {
        // hay datos todavia?, por si acaso
        $aa = explode($sep, $articulos);
        // articulos array
        $pa = explode($sep, $precios);
        // precios array
        $ca = explode($sep, $cantidades);
        // cantidades array
        $total = 0;
        for ($i = 0; $i < count($aa); $i++) {
            $subtotal = $pa[$i] * $ca[$i];
            $total += $subtotal;
            array_push($datos, [$aa[$i], $pa[$i], $ca[$i], $subtotal]);
            // añadimos el subtotal
        }
        $ti = $total * (1 + $iva);
        return "Factura:" . table($headings, $datos) . br() . "Total: {$total}" . br() . "Total ({$iva} de IVA incluido): {$ti}" . br() . br();
    } else {
        return "No se debe nada (todavia).";
    }
}
Beispiel #30
0
	public function save()
	{
		$this->CheckAdminPrivs('privs');
		$uid = post('uid', 'int');
		if($uid == '1'){
			$this->Messager("您不能对此管理员的权限进行任何操作");
		}
		$userinfo = dbc(DBCMax)->query('select uid,username,role_id,role_type,privs from '.table('members').' where uid='.$uid)->limit(1)->done();
		if(!$userinfo){
			$this->Messager("该用户不存在");
		}
		if(!in_array($userinfo['role_type'],array('admin','seller'))){
			$this->Messager("您不能设置该用户的后台操作权限");
		}
		$privs = post('privs_code');
		if($privs && is_array($privs)){
			$privs[] = 'index';
			$dataprivs = implode(',',$privs);
		}else{
			$dataprivs = '';
		}
		if($dataprivs != $userinfo['privs']){
			dbc(DBCMax)->update('members')->data(array('privs'=>$dataprivs,'role_id'=>'0'))->where('uid='.$uid)->done();
		}
		$this->Messager("权限设置成功");
	}