Esempio n. 1
0
 public function index()
 {
     $userid = session('userid');
     $user = M('user')->where('id=' . $userid)->find();
     $user_level = M('user_level')->where('id=' . $user['user_type'])->find();
     $level_config = json_decode($user_level['config'], true);
     if ($level_config['refer'] != 1) {
         $this->message2('<font color=red>你目前的会员级别无推广权限</font>请先升级会员!', 'uplevel');
     }
     $config = M('config')->where('id=1')->find();
     $tuiguang_url = 'http://' . $_SERVER['HTTP_HOST'] . __APP__ . '?ruid=' . session('userid');
     if ($config['tuiguang_shorturl'] == 1) {
         if (!class_exists('Short_Url')) {
             require 'Public/Short_Url.php';
         }
         $short_url = new Short_Url();
         $tuiguang_url = $short_url->url_short($tuiguang_url);
     }
     $image_url = 'http://' . $_SERVER['HTTP_HOST'] . $config['tg_images'];
     $tg_content1 = '';
     $tg_content2 = '';
     $tg_content3 = '';
     if ($config['tg_content1'] != '') {
         $tg_content1 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content1']);
     }
     if ($config['tg_content2'] != '') {
         $tg_content2 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content2']);
     }
     if ($config['tg_content3'] != '') {
         $tg_content3 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content3']);
     }
     $this->assign('image_url', $image_url);
     $this->assign('tuiguang_url', $tuiguang_url);
     $this->assign('tg_content', array($tg_content1, $tg_content2, $tg_content3));
     $kongbao_page = json_decode($config['kongbao_page'], true);
     $kongbao_page_temp = array();
     foreach ($kongbao_page as $key1 => $v1) {
         $kongbao_page_temp[$key1] = stripslashes(htmlspecialchars_decode($v1));
     }
     $this->assign('kongbao_page', $kongbao_page_temp);
     $refer_nums = D('user')->where('refer_id=' . session('userid'))->count();
     $this->assign('refer_nums', $refer_nums);
     $reg_setting = M('user')->where('id=' . session('userid'))->find();
     $wrefer_id = $reg_setting['refer_id'];
     $vip_setting = json_decode($reg_setting['vip_set'], true);
     $wrefer = M('user')->where('id=' . $wrefer_id)->find();
     $wusername = $wrefer['username'];
     $this->assign('wusername', $wusername);
     $this->assign('vip_setting', $vip_setting);
     $this->display();
 }
Esempio n. 2
0
 /**
  * Get the instance of short url class.
  *
  * @return Short_Url
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
         self::$instance->setup_actions();
         self::$instance->load_language();
     }
     return self::$instance;
 }
Esempio n. 3
0
            #将分段的位与0x3fffffff做位与,0x3fffffff表示二进制数的30个1,即30位以后的加密串都归零
            $hex = hexdec($urlhash_piece) & 0x3fffffff;
            #此处需要用到hexdec()将16进制字符串转为10进制数值型,否则运算会不正常
            $short_url = "http://t.cn/";
            #生成6位短连接
            for ($j = 0; $j < 6; $j++) {
                #将得到的值与0x0000003d,3d为61,即charset的坐标最大值
                $short_url .= self::$charset[$hex & 0x3d];
                #循环完以后将hex右移5位
                $hex = $hex >> 5;
            }
            $short_url_list[] = $short_url;
        }
        return $short_url_list;
    }
    public function console($log = '')
    {
        switch (empty($log)) {
            case False:
                $out = json_encode($log);
                $GLOBALS['console'] .= 'console.log(' . $out . ');';
                break;
            default:
                echo '<script type="text/javascript">' . $GLOBALS['console'] . '</script>';
        }
    }
}
$url = "http://www.cnblogs.com/zemliu/";
$short = Short_Url::short($url);
print_r($short);
//$short->console($short);
Esempio n. 4
0
 private function getReferInfo()
 {
     $userid = session('userid');
     $user = M('user')->where('id=' . $userid)->find();
     $user_level = M('user_level')->where('id=' . $user['user_type'])->find();
     $level_config = json_decode($user_level['config'], true);
     $this->assign('allow_refer', $level_config['refer']);
     if ($level_config['refer'] == 1) {
         $config = M('config')->where('id=1')->find();
         $tuiguang_url = 'http://' . $_SERVER['HTTP_HOST'] . __APP__ . '?ruid=' . session('userid');
         if ($config['tuiguang_shorturl'] == 1) {
             if (!class_exists('Short_Url')) {
                 require 'Public/Short_Url.php';
             }
             $short_url = new Short_Url();
             $tuiguang_url = $short_url->url_short($tuiguang_url);
         }
         $image_url = 'http://' . $_SERVER['HTTP_HOST'] . $config['tg_images'];
         $tg_content1 = '';
         $tg_content2 = '';
         $tg_content3 = '';
         if ($config['tg_content1'] != '') {
             $tg_content1 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content1']);
         }
         if ($config['tg_content2'] != '') {
             $tg_content2 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content2']);
         }
         if ($config['tg_content3'] != '') {
             $tg_content3 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content3']);
         }
         $this->assign('image_url', $image_url);
         $this->assign('tuiguang_url', $tuiguang_url);
         $this->assign('tg_content', array($tg_content1, $tg_content2, $tg_content3));
     }
 }
Esempio n. 5
0
 /**
  * Load the short and its url parts
  *
  * @param string $name
  */
 public static function loadShort($name)
 {
     require_once 'Short/Url.php';
     require_once 'Short/UrlHost.php';
     require_once 'Short/UrlScheme.php';
     $items = array();
     //Prepare select
     $select = static::getSelect();
     $select->setIntegrityCheck(false)->reset();
     //Prepare the join
     $select->from(array('short' => static::getTableName()));
     $select->join(array('url' => Short_Url::getTableName()), 'short.url_id = url.id', array('path', 'host_id'));
     $select->join(array('url_host' => Short_UrlHost::getTableName()), 'url.host_id = url_host.id', array('host', 'port', 'scheme_id'));
     $select->join(array('url_scheme' => Short_UrlScheme::getTableName()), 'url_host.scheme_id = url_scheme.id', array('scheme'));
     $select->where('short.name = ? ', $name);
     $data = static::getTable()->fetchRow($select);
     if (!$data) {
         return null;
     } else {
         $data = $data->toArray();
     }
     $short = new Short_Short($data);
     $short->_url = new Short_Url($data);
     $short->_url->id = $short->url_id;
     $short->_url->_host = new Short_UrlHost($data);
     $short->_url->_host->id = $short->_url->host_id;
     $short->_url->_host->_scheme = new Short_UrlScheme($data);
     $short->_url->_host->_scheme->id = $short->_url->_host->scheme_id;
     return $short;
 }
Esempio n. 6
0
 public function index()
 {
     $exp_time = time();
     $exp_datetime = date('Y-m-d H:i:s', $exp_time);
     $config = M('config')->where('id=1')->find();
     $tuiguang_url = 'http://' . $_SERVER['HTTP_HOST'] . __APP__ . '?ruid=' . session('userid');
     if ($config['tuiguang_shorturl'] == 1) {
         if (!class_exists('Short_Url')) {
             require 'Public/Short_Url.php';
         }
         $short_url = new Short_Url();
         $tuiguang_url = $short_url->url_short($tuiguang_url);
     }
     $image_url = 'http://' . $_SERVER['HTTP_HOST'] . $config['tg_images'];
     $tg_content1 = '';
     $tg_content2 = '';
     $tg_content3 = '';
     if ($config['tg_content1'] != '') {
         $tg_content1 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content1']);
     }
     if ($config['tg_content2'] != '') {
         $tg_content2 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content2']);
     }
     if ($config['tg_content3'] != '') {
         $tg_content3 = str_replace('{refer_url}', $tuiguang_url, $config['tg_content3']);
     }
     $this->assign('image_url', $image_url);
     $this->assign('tuiguang_url', $tuiguang_url);
     $this->assign('tg_content', array($tg_content1, $tg_content2, $tg_content3));
     $refer_nums = D('user')->where('refer_id=' . session('userid'))->count();
     $this->assign('refer_nums', $refer_nums);
     $reg_setting = M('user')->where('id=' . session('userid'))->find();
     $wrefer_id = $reg_setting['refer_id'];
     $vip_setting = json_decode($reg_setting['vip_set'], true);
     $wrefer = M('user')->where('id=' . $wrefer_id)->find();
     $wusername = $wrefer['username'];
     $this->assign('wusername', $wusername);
     $this->assign('vip_setting', $vip_setting);
     $refer_id = I('ruid', 0);
     if (0 < $refer_id) {
         $refer_user = M('user')->where('id=' . $refer_id)->find();
         if (!empty($refer_user)) {
             $refer_user_type = $refer_user['user_type'];
             $user_level = M('user_level')->where('id=' . $refer_user_type)->find();
             $level_config = json_decode($user_level['config'], true);
             if ($level_config['refer'] == 1) {
                 $cruid = cookie('vgs-referid');
                 if (!$cruid) {
                     cookie('vgs-referid', $refer_id, 604800);
                 }
             }
         }
     }
     $model = new Model('gonggao');
     $gonggao = $model->order('time desc')->limit(8)->select();
     $this->assign('gonggao_list', $gonggao);
     $config = M('config')->where('id=1')->find();
     $kongbao_config = json_decode($config['kongbao_config'], true);
     $model = new Model('kongbao_type');
     $list = $model->where('is_true=0')->order('sort_order asc')->select();
     $type_list = array();
     foreach ($list as $k => $v) {
         if ($kongbao_config['stop_view'] == 0 && $v['state'] == 1) {
             continue;
         }
         if ($v['state'] == 0) {
             $v['name'] = $v['name'] . '(正常出售)';
         }
         if ($v['state'] == 1) {
             $v['name'] = $v['name'] . '(暂停出售)';
         }
         $v['config'] = json_decode($v['config'], true);
         $type_list[] = $v;
     }
     $this->assign('type_list', $type_list);
     $user = M('user')->where('id=' . $userid)->find();
     $user_type = $user['user_type'];
     $user_default_kuaidi = $user['default_kuaidi'];
     $this->assign('user_default_kuaidi', $user_default_kuaidi);
     $config = M('config');
     $setting = $config->where('id=1')->find();
     $mibao_setting = json_decode($setting['mibao_setting'], true);
     $this->assign('mibao_setting', $mibao_setting);
     $cwsz_config = json_decode($this->user['cwsz_config'], true);
     $this->assign('cwsz_config', $cwsz_config);
     $model = new Model('help');
     $help = $model->order('time desc')->limit(8)->select();
     $this->assign('help_list', $help);
     $model = new Model('article');
     $article = $model->order('article_time desc')->limit(8)->select();
     $this->assign('article_list', $article);
     $model = new Model('about');
     $about = $model->order('time desc')->limit(8)->select();
     $this->assign('about_list', $about);
     $model = new UserOrderViewModel();
     $where = array();
     $where['type'] = 1;
     $where['status'] = 1;
     $recharge_list = $model->where($where)->order('addtime desc')->limit(100)->select();
     $this->assign('recharge_list', $recharge_list);
     $where['type'] = 0;
     $where['status'] = 1;
     $pay_order_list = $model->where($where)->order('addtime desc')->limit(100)->select();
     $this->assign('order_list', $pay_order_list);
     if (session('IS_LOGIN') == 1) {
         $userid = session('userid');
         $model = new UserViewModel();
         $user = $model->where('user.id=' . $userid)->find();
         $this->assign('user', $user);
     } else {
         $sys_config = M('config')->where('id=1')->find();
         $current_moban = $sys_config['site_template'];
         if ($current_moban == 'default' || $current_moban == 'longxiang' || $current_moban == 'php') {
             $this->display('index_login');
             exit;
         }
     }
     $this->display();
 }
Esempio n. 7
0
<?php

/**
 * Plugin Name: Short url
 * Description: Short url to the permalink, like Simple Address in EPiServer.
 * Author: Fredrik Forsmo
 * Author URI: https://frozzare.com/
 * Version: 2.0.5
 * Plugin URI: https://github.com/frozzare/short-url
 */
// Load short url files.
require_once __DIR__ . '/src/class-short-url.php';
require_once __DIR__ . '/src/functions.php';
/**
 * Load Short Url plugin.
 *
 * @return Short_Url
 */
add_action('plugins_loaded', function () {
    return Short_Url::instance();
});