Example #1
0
 /**  
  * 初始化设置 
  * @param array $config 内存服务器优化设置
  * @return void
  */
 function init($config)
 {
     $this->config = $config;
     $this->prefix = empty($config['prefix']) ? substr(md5($_SERVER['HTTP_HOST']), 0, 6) . '_' : $config['prefix'];
     $this->keys = array();
     if ($this->extension['memcache'] && !empty($config['memcache']['server'])) {
         require_once fimport('class/memcache');
         $this->memory = new Memcache();
         $this->memory->init($this->config['memcache']);
         if (!$this->memory->enable) {
             $this->memory = NULL;
         }
     }
     if (!is_object($this->memory) && $this->extension['eaccelerator'] && $this->config['eaccelerator']) {
         require_once fimport('class/eaccelerator');
         $this->memory = new Eaccelerator();
         $this->memory->init(NULL);
     }
     if (!is_object($this->memory) && $this->extension['xcache'] && $this->config['xcache']) {
         require_once fimport('class/xcache');
         $this->memory = new Xcache();
         $this->memory->init(NULL);
     }
     if (!is_object($this->memory) && $this->extension['apc'] && $this->config['apc']) {
         require_once fimport('class/apc');
         $this->memory = new Apc();
         $this->memory->init(null);
     }
     if (is_object($this->memory)) {
         $this->enable = true;
         $this->type = get_class($this->memory);
         $this->keys = $this->get('memory_system_keys');
         $this->keys = !is_array($this->keys) ? array() : $this->keys;
     }
 }
 public function photo()
 {
     global $_FANWE;
     if ($_FANWE['uid'] == 0) {
         $redir_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         fSetCookie('redir_url', $redir_url, time() + 3600);
         require_once fimport('dynamic/user');
         include template('page/user/user_login');
     } else {
         FanweService::instance()->cache->loadCache('albums');
         $imgs = $_FANWE['request']['imgUrl'];
         $pageUrl = $_FANWE['request']['pageUrl'];
         $img_list = explode(",", $imgs);
         $count_img = count($img_list);
         $videos = $_FANWE['request']['videoUrl'];
         $video_list = explode(",", $videos);
         $count_video = count($video_list);
         if ($_FANWE['request']['showType'] == 1) {
             include template("page/collection/collection_photos");
         } else {
             include template("page/collection/collection_photo");
         }
     }
     display();
 }
Example #3
0
    public function detail()
    {
        global $_FANWE;
        $id = intval($_FANWE['request']['id']);
        if ($id == 0) {
            fHeader("location: " . FU('index/index'));
        }
        include fimport('dynamic/u');
        //获取相关的分享ID
        $eventinfo = FDB::fetchFirst("select * from " . FDB::table("event") . " where id=" . $id);
        if (intval($eventinfo['share_id']) == 0) {
            fHeader("location: " . FU('index/index'));
        }
        $eventinfo['share'] = FS('Share')->getShareDetail($eventinfo['share_id']);
        if ($share_detail === false) {
            fHeader("location: " . FU('index'));
        }
        $user_share_collect = FS('Share')->getShareCollectUser($eventinfo['share_id']);
        $page_title = preg_replace("/\\[[^\\]]+\\]/i", "", $eventinfo['title']);
        $_FANWE['nav_title'] = $page_title . ' - ' . lang('common', 'event');
        $_FANWE['seo_description'] = $page_title;
        $_FANWE['setting']['site_description'] = '';
        //分享评论
        $page_args = array('id' => $id);
        $count = $eventinfo['thread_count'];
        $post_list = array();
        if ($count > 0) {
            $pager = buildPage('event/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 10);
            $sql = 'SELECT share_id FROM ' . FDB::table('event_share') . ' 
				WHERE event_id = ' . $id . ' ORDER BY share_id DESC LIMIT ' . $pager['limit'];
            $ids = array();
            $res = FDB::query($sql);
            while ($data = FDB::fetch($res)) {
                $ids[] = $data['share_id'];
            }
            $ids = implode(',', $ids);
            $sql = 'SELECT * from ' . FDB::table('share') . ' where share_id IN (' . $ids . ') ORDER BY share_id';
            $list = FDB::fetchAll($sql);
            $post_list = FS('Share')->getShareDetailList($list, true, true, true);
        }
        $args = array('share_list' => &$post_list, 'pager' => &$pager, 'current_share_id' => $eventinfo['share_id']);
        $post_html = tplFetch("inc/share/post_share_list", $args);
        //热门话题
        $hot_event_list = FS("event")->getHotEvent(10);
        if (intval($_FANWE['uid']) > 0) {
            //我发布的
            $me_event_list = FS("event")->getUserEvent($_FANWE['uid'], 5);
            //我参与的
            $me_join_event_list = FS("event")->getUserJoinevent($_FANWE['uid'], 5);
        }
        if (intval($_FANWE['page']) == 1) {
            FDB::query('UPDATE ' . FDB::table('share') . ' SET click_count = click_count + 1 WHERE share_id = ' . $eventinfo['share_id']);
        }
        include template('page/event/event_detail');
        display();
    }
Example #4
0
 public function all()
 {
     define("ACTION_NAME", "all");
     require fimport('function/user');
     require fimport("function/share");
     if (intval($GLOBALS['fanwe']->var['uid']) == 0) {
         fHeader("location: " . FU('user/login'));
     }
     global $_FANWE;
     $list_html = getAllList();
     include template('page/home');
     display();
 }
Example #5
0
function bindCacheCity()
{
    $citys = array();
    $res = FDB::query("SELECT * FROM " . FDB::table('region') . " ORDER BY id ASC");
    while ($data = FDB::fetch($res)) {
        if ($data['parent_id'] == 0) {
            $citys['province'][] = $data['id'];
        } elseif ($data['parent_id'] > 0) {
            $citys['city'][$data['parent_id']][] = $data['id'];
        }
        $citys['all'][$data['id']] = $data;
    }
    include_once fimport('class/json');
    $json = new JSON();
    writeFile(PUBLIC_ROOT . './js/city.js', 'var CITYS = ' . $json->encode($citys) . ';');
    FanweService::instance()->cache->saveCache('citys', $citys);
}
Example #6
0
 public function sendDemo()
 {
     vendor("common");
     global $_FANWE;
     $stmp = $_REQUEST;
     require_once fimport('mail.class', 'class');
     $mail = new Mail();
     $mail->setStmp($stmp);
     $name = '测试邮件';
     $email = trim($stmp['mail_address']);
     $subject = '测试邮件';
     $content = '测试邮件';
     if ($mail->send($name, $email, $subject, $content)) {
         echo '发送成功';
     } else {
         echo '发送失败';
     }
     exit;
 }
Example #7
0
 public function verify()
 {
     global $_FANWE;
     $seccode = random(6, 1);
     $seccodeunits = '';
     $s = sprintf('%04s', base_convert($seccode, 10, 24));
     $seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
     $seccode = '';
     for ($i = 0; $i < 4; $i++) {
         $unit = ord($s[$i]);
         $seccode .= $unit >= 0x30 && $unit <= 0x39 ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57];
     }
     $rhash = $_FANWE['request']['rhash'];
     fSetCookie('verify' . $rhash, authcode(strtoupper($seccode) . "\t" . (TIME_UTC - 180) . "\t" . $rhash . "\t" . FORM_HASH, 'ENCODE', $_FANWE['config']['security']['authkey']), 0, 1, true);
     @header("Expires: -1");
     @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
     @header("Pragma: no-cache");
     require fimport('class/verify');
     $verify = new Verify();
     $verify->code = $seccode;
     $verify->width = 100;
     $verify->height = 36;
     $verify->display();
 }
 public function systemClear()
 {
     $system_clear = $_SESSION['cache_system_clear'];
     if (empty($system_clear)) {
         $this->redirect('Cache/system');
     } else {
         $_SESSION['cache_system_clear'] = $system_clear;
     }
     @set_time_limit(3600);
     if (function_exists('ini_set')) {
         ini_set('max_execution_time', 3600);
         ini_set("memory_limit", "256M");
     }
     $this->display();
     ob_start();
     ob_end_flush();
     ob_implicit_flush(1);
     if (isset($system_clear['is_admin'])) {
         clearCache();
         echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS6') . '\',1);</script>');
     }
     Vendor('common');
     if (isset($system_clear['is_data'])) {
         usleep(100);
         include_once fimport('class/cache');
         Cache::getInstance()->updateCache();
         echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS7') . '\',1);</script>');
     }
     if (isset($system_clear['is_tpl'])) {
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/caches/static');
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/caches/dynamic');
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/compiled');
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/caches/adv_position');
         @file_put_contents(FANWE_ROOT . './public/data/tpl/caches/page/is_clear.lock', TIMESTAMP);
         echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS8') . '\',1);</script>');
     }
     usleep(100);
     echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS9') . '\',3);</script>');
     exit;
 }
    function forgetPassword()
    {
        global $_FANWE;
        $method = strtolower($_SERVER["REQUEST_METHOD"]);
        if ($method == 'post') {
            $data = array('email' => $_FANWE['request']['email'], 'user_name' => $_FANWE['request']['user_name']);
            $data_error = false;
            $send_error = true;
            $vservice = FS('Validate');
            $validate = array(array('email', 'required', lang('user', 'register_email_require')), array('email', 'email', lang('user', 'register_email_error')), array('user_name', 'required', lang('user', 'register_user_name_require')), array('user_name', 'range_length', lang('user', 'register_user_name_len'), 2, 20), array('user_name', '/^[\\x{4e00}-\\x{9fa5}a-zA-Z][\\x{4e00}-\\x{9fa5}a-zA-Z0-9_]+$/u', lang('user', 'register_user_name_error')));
            if (!$vservice->validation($validate, $data)) {
                $data_error = true;
            } else {
                $uid = FDB::resultFirst('SELECT uid
					FROM ' . FDB::table('user') . '
					WHERE user_name = \'' . $data['user_name'] . '\' AND email = \'' . $data['email'] . '\'');
                $uid = intval($uid);
                if ($uid == 0) {
                    $data_error = true;
                } else {
                    $reset_hash = md5(microtime(true) . random(8));
                    FDB::query('UPDATE ' . FDB::table('user_status') . '
						SET reset_hash = \'' . $reset_hash . '\'
						WHERE uid = ' . $uid);
                    $site_name = $_FANWE['setting']['site_name'];
                    $reset_url = $_FANWE['site_url'] . 'user.php?action=resetpassword&resethash=' . $reset_hash;
                    $title = sprintf(lang('user', 'get_pwd_title'), $site_name);
                    $content = sprintf(lang('user', 'get_pwd_html'), $site_name, $reset_url, $reset_url, $site_name, $_FANWE['site_url'], $site_name);
                    include fimport("class/mail");
                    $mail = new Mail();
                    if ($mail->send($data['user_name'], $data['email'], $title, $content, 1)) {
                        $send_error = false;
                    }
                }
            }
        }
        include template('page/user/user_getpwd');
        display();
    }
Example #10
0
 private function show($current_type = '')
 {
     global $_FANWE;
     $share_id = intval($_FANWE['request']['sid']);
     $id = intval($_FANWE['request']['id']);
     $share_detail = FS('Share')->getShareDetail($share_id);
     include fimport('dynamic/u');
     if ($share_detail === false) {
         fHeader("location: " . FU('index'));
     }
     $page_title = preg_replace("/\\[[^\\]]+\\]/i", "", $share_detail['content']);
     $_FANWE['nav_title'] = $page_title . ' - ' . lang('common', 'share');
     $_FANWE['seo_description'] = $page_title;
     $_FANWE['setting']['site_description'] = '';
     FDB::query('UPDATE ' . FDB::table('share') . ' SET click_count = click_count + 1 WHERE share_id = ' . $share_id);
     //上一个,下一个分享
     //$pns = FS('Share')->getPrevNextShares($share_detail['uid'],$share_id);
     //发布分享的会员
     $share_user = FS('User')->getUserById($share_detail['uid']);
     //喜欢分享的会员
     $share_detail['collects'] = FS('Share')->getShareCollectUser($share_id);
     if (!isset($share_detail['collects'][$_FANWE['uid']])) {
         if (FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid'])) {
             $share_detail['collects'][$_FANWE['uid']] = $_FANWE['uid'];
         }
     }
     //会员显示名称
     $user_show_name = FS('User')->getUserShowName($share_detail['uid']);
     //会员勋章
     $user_medals = FS('User')->getUserMedal($share_detail['uid']);
     //分享标签
     $share_tags = $share_detail['cache_data']['tags']['user'];
     FS('Share')->tagsFormat($share_tags);
     foreach ($share_tags as $seo_tag) {
         $_FANWE['seo_keywords'] .= $seo_tag['tag_name'] . ',';
     }
     //是否可编辑标签
     $is_eidt_tag = FS('Share')->getIsEditTag($share_detail);
     //喜欢分享的会员还喜欢
     $fav_user_fav_share = FS('Share')->getCollectShareByShare($share_id);
     //发布分享的会员喜欢的分享
     $user_collect_share = FS('Share')->getCollectShareByUser($share_user['uid']);
     //是否可删除标签
     $is_remove_comment = FS('Share')->getIsRemoveComment($share_detail);
     //分享评论
     $share_detail['comments'] = FS('Share')->getShareCommentList($share_id, '0,10');
     //分享评论分页
     $pager = buildPage('', array(), $share_detail['comment_count'], $_FANWE['page'], 10);
     unset($share_detail['cache_data']);
     $current_obj = NULL;
     if ($current_type == '' || $id == 0) {
         if (!empty($share_detail['imgs'])) {
             $current_obj = current($share_detail['imgs']);
             if ($current_obj['type'] == 'g') {
                 $current_type = 'bao';
             } else {
                 $current_type = 'photo';
             }
         }
     } else {
         switch ($current_type) {
             case 'bao':
                 foreach ($share_detail['imgs'] as $img) {
                     $current_obj = $img;
                     if ($img['type'] == 'g' && $img['id'] == $id) {
                         break;
                     }
                 }
                 break;
             case 'photo':
                 foreach ($share_detail['imgs'] as $img) {
                     $current_obj = $img;
                     if ($img['type'] == 'm' && $img['id'] == $id) {
                         break;
                     }
                 }
                 break;
         }
     }
     if (!empty($current_obj['name'])) {
         $_FANWE['nav_title'] = $current_obj['name'] . ' - ' . lang('common', 'share');
     }
     switch ($current_type) {
         case 'bao':
             //会员最被喜欢的宝贝
             $best_goods_share = FS('Share')->getBestCollectGoodsShareByUser($share_user['uid']);
             //会员分享店铺信息
             $shop_percent_html = FS('Shop')->getUserShareShopHtml($share_user['uid']);
             break;
         case 'photo':
             //会员最被喜欢的照片
             $best_photo_share = FS('Share')->getBestCollectPhotoShareByUser($share_user['uid']);
             //会员喜欢的照片
             $user_fav_photo = FS('Share')->getUserFavPhotoShare($share_user['uid']);
             break;
         default:
             //获取原文分享
             $share_detail['is_relay'] = false;
             $share_detail['is_rec'] = false;
             if ($share_detail['parent_id'] > 0 && $share_detail['base_id'] > 0) {
                 $share_detail['is_relay'] = true;
                 $parent_share = FS('Share')->getShareDetail($share_detail['base_id']);
             } elseif ($share_detail['rec_id'] > 0 && $share_detail['base_id'] > 0) {
                 $share_detail['is_rec'] = true;
                 $parent_share = FS('Share')->getShareDetail($share_detail['base_id']);
             }
             $current_type = 'other';
             break;
     }
     include template('page/note/note_index');
     display();
 }
Example #11
0
<?php

define('MODULE_NAME', 'Book');
$actions = array('cate', 'shopping', 'search', 'dapei', 'look');
if (isset($_REQUEST['action'])) {
    $action = strtolower($_REQUEST['action']);
    if (!in_array($action, $actions)) {
        $action = 'shopping';
    }
}
define('ACTION_NAME', $action);
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->initialize();
require fimport('module/book');
switch (ACTION_NAME) {
    case 'cate':
        BookModule::cate();
        break;
    case 'shopping':
        BookModule::shopping();
        break;
    case 'search':
        BookModule::search();
        break;
    case 'dapei':
        define('IS_DAPAI', true);
        BookModule::dapei();
        break;
    case 'look':
        define('IS_DAPAI', true);
 function error($message, $tpl_name)
 {
     require_once fimport('class/error');
     FanweError::templateError($message, $tpl_name);
 }
Example #13
0
 public function save()
 {
     global $_FANWE;
     if ($_FANWE['uid'] == 0) {
         exit;
     }
     include_once fimport('class/image');
     $image = new Image();
     if (intval($_FANWE['setting']['max_upload']) > 0) {
         $image->max_size = intval($_FANWE['setting']['max_upload']);
     }
     $daren = array();
     $daren['uid'] = $_FANWE['uid'];
     $daren['reason'] = $_FANWE['request']['reason'];
     $daren['status'] = 0;
     $daren['create_time'] = TIME_UTC;
     //个人街拍照
     $img = $_FILES['img'];
     if (!empty($img)) {
         $image->init($img, 'daren');
         if ($image->save()) {
             $daren['img'] = $image->file['target'];
         }
     }
     $index_img = $_FILES['index_img'];
     if (!empty($index_img)) {
         $image->init($index_img, 'daren');
         if ($image->save()) {
             $daren['index_img'] = $image->file['target'];
         }
     }
     $id = FDB::insert('user_daren', $daren, true, false, true);
     if ($id > 0) {
         showSuccess('提交申请成功', '你的达人申请已经成功提交,我们会尽快处理你的达人申请!', FU('daren/index'));
     } else {
         showError('提交申请失败', '你的达人申请提交失败,请重新提交达人申请', -1);
     }
 }
Example #14
0
 function halt($message = '', $sql = '')
 {
     require_once fimport('class/error');
     FanweError::dbError($message, $sql);
 }
 public function getUserWeiBoFollowers($uid)
 {
     $uid = (int) $uid;
     if (!$uid) {
         return false;
     }
     $binds = UserService::getUserBindList($uid);
     if ($binds) {
         foreach ($binds as $type => $bind) {
             include fimport('class/' . $type, 'user');
             $type = ucfirst($type) . 'User';
             $weibo = new $type();
             $followers = $weibo->getFollowers($uid);
         }
     }
 }
 private function buildCron()
 {
     if ($this->is_cron) {
         require fimport("class/cron");
         Cron::run();
     }
 }
Example #17
0
}
if (!checkAuthority('share', 'edit')) {
    exit;
}
$manage_lock = checkIsManageLock('share', $share_id);
if ($manage_lock !== false) {
    exit;
}
$old_share = FS("Share")->getShareById($share_id);
if (empty($old_share)) {
    deleteManageLock('share', $share_id);
    exit;
}
$is_index = (int) $_FANWE['request']['is_index'];
if ($is_index == 1) {
    include_once fimport('class/image');
    $image = new Image();
    if (intval($_FANWE['setting']['max_upload']) > 0) {
        $image->max_size = intval($_FANWE['setting']['max_upload']);
    }
    $img = $_FILES['index_img'];
    $index_img = "";
    if (!empty($img)) {
        $image->init($img, 'images');
        if ($image->save()) {
            $index_img = $image->file['target'];
        }
    }
    if (!empty($index_img) && !empty($old_share['index_img'])) {
        @unlink(FANWE_ROOT . $old_share['index_img']);
    }
Example #18
0
<?php

require fimport('service/share');
$result = array();
$id = intval($_FANWE['request']['id']);
if ($id == 0) {
    exit;
}
//!checkAuthority('share','delete')
$share = FS('Share')->getShareById($id);
if (empty($share)) {
    $result['status'] = 1;
    outputJson($result);
}
$authoritys = FS('Share')->getIsEditShare($share);
if ($authoritys == 0) {
    $result['status'] = 0;
    outputJson($result);
}
$type = intval($_FANWE['request']['type']);
if ($type == 0) {
    if ($share['type'] == 'bar_post') {
        FS('Topic')->deletePost($id);
    } elseif ($share['type'] == 'ask_post') {
        FS('Ask')->deletePost($id);
    } elseif ($share['type'] == 'album') {
        FS('Album')->deleteAlbum($share['rec_id']);
    } elseif ($share['type'] == 'album_item') {
        FS('Album')->deleteAlbumItem($id);
    } elseif ($share['type'] == 'ershou') {
        FS("Second")->deleteGoods($share['rec_id']);
Example #19
0
<?php

define('MODULE_NAME', 'Note');
$actions = array('index', 'g', 'm');
$action = 'index';
if (isset($_REQUEST['action'])) {
    $action = strtolower($_REQUEST['action']);
    if (!in_array($action, $actions)) {
        $action = 'index';
    }
}
define('ACTION_NAME', $action);
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->initialize();
require fimport('module/note');
switch (ACTION_NAME) {
    case 'index':
        NoteModule::index();
        break;
    case 'g':
        NoteModule::goods();
        break;
    case 'm':
        NoteModule::photo();
        break;
}
Example #20
0
<?php

define('MODULE_NAME', 'Second');
$actions = array('index', 'create', 'save');
$action = 'index';
if (isset($_REQUEST['action'])) {
    $action = strtolower($_REQUEST['action']);
    if (!in_array($action, $actions)) {
        $action = 'index';
    }
}
define('ACTION_NAME', $action);
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->cache_list[] = 'seconds';
$fanwe->initialize();
require fimport('module/second');
$_FANWE['nav_title'] = lang('common', 'second');
switch (ACTION_NAME) {
    case 'index':
        FanweService::instance()->cache->loadCache('citys');
        SecondModule::index();
        break;
    case 'create':
        SecondModule::create();
        break;
    case 'save':
        SecondModule::save();
        break;
}
/**
*
* @param $origin_path 原始物理图片地址
* @param array $sizes 缩略图大小信息 为空则取后台设置
	 	可生成多个缩略图
		数组 参数1 为宽度,
			 参数2为高度,
			 参数3为处理方式:0(缩放,默认),1(剪裁),
			 参数4为是否水印 默认为 0(不生成水印)
	 	array(
			array(300,300,0,0),
			array(100,100,0,0),
			...
		),
* @param $path 存储的路径
* @param $file_name 保存的文件名
* @param $del_temp 是否删除临时文件
* @param $id 关联编号,将根据编号生成目录
*
* 返回 复制成功的信息,如为false则复制失败
* array(
* 	'path'	=>	xxx  //物理路径
*  'url'	=>	xxx  //相对路径
* );
*
* by fzmatthew
*/
function copyImage($origin_path, $sizes = array(), $path = 'share', $del_temp = true, $id = 0)
{
    global $_FANWE;
    static $size_setting = NULL, $image = NULL;
    if ($image === NULL) {
        include_once fimport('class/image');
        $image = new Image();
    }
    if ($path == 'temp') {
        $dir = './public/upload/temp/' . fToDate(NULL, 'Y/m/d/H');
    } else {
        if ($id > 0) {
            $dir = './public/upload/' . $path . '/' . getDirsById($id);
        } else {
            $dir = './public/upload/' . $path . '/' . fToDate(NULL, 'Y/m/d');
        }
    }
    makeDir(FANWE_ROOT . $dir);
    $file_name = md5(microtime(true)) . random('6') . '.jpg';
    $file_path = FANWE_ROOT . $dir . "/" . $file_name;
    $bln = false;
    if (file_exists($origin_path) && @copy($origin_path, $file_path)) {
        $bln = true;
    } else {
        $data = getUrlContent($origin_path);
        if (!empty($data) && @file_put_contents($file_path, $data) > 0) {
            $bln = true;
        }
    }
    if ($bln) {
        $info = $image->getImageInfo($file_path);
        if ($info['type'] != 'jpg' && $info['type'] != 'jpeg') {
            if (!$image->convertType($file_path, $file_path)) {
                return false;
            }
        }
        $water_image = $_FANWE['setting']['water_image'];
        if (!empty($water_image)) {
            $water_image = FANWE_ROOT . $water_image;
        }
        $water_mark = intval($_FANWE['setting']['water_mark']);
        $alpha = intval($_FANWE['setting']['water_alpha']);
        $place = intval($_FANWE['setting']['water_position']);
        if ($sizes !== false && empty($sizes)) {
            if ($size_setting === NULL) {
                if (!isset($_FANWE['cache']['image_sizes'])) {
                    FanweService::instance()->cache->loadCache('image_sizes');
                }
                $size_setting = $_FANWE['cache']['image_sizes'];
            }
            $sizes = $size_setting;
        }
        foreach ($sizes as $size) {
            if ($size[0] > 0 || $size[1] > 0) {
                $thumb_bln = false;
                $thumb_type = isset($size[2]) ? intval($size[2]) : 0;
                if ($thumb = $image->thumb($file_path, $size[0], $size[1], $thumb_type)) {
                    if (isset($size[3]) && intval($size[3]) > 0) {
                        $image->water($thumb['path'], $water_image, $alpha, $place);
                    }
                }
            }
        }
        if ($del_temp) {
            @unlink($origin_path);
        }
        return array('path' => $file_path, 'url' => $dir . "/" . $file_name, 'width' => $info[0], 'height' => $info[1]);
    } else {
        return false;
    }
}
Example #22
0
define('MODULE_NAME', 'Club');
$actions = array('index', 'donewtopic', 'newtopic', 'forum', 'best', 'detail', 'post');
$action = 'index';
if (isset($_REQUEST['action'])) {
    $action = strtolower($_REQUEST['action']);
    if (!in_array($action, $actions)) {
        $action = 'index';
    }
}
define('ACTION_NAME', $action);
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->cache_list[] = 'forums';
$fanwe->initialize();
require fimport('module/club');
switch (ACTION_NAME) {
    case 'index':
        ClubModule::index();
        break;
    case 'donewtopic':
        ClubModule::donewtopic();
        break;
    case 'newtopic':
        ClubModule::newtopic();
        break;
    case 'forum':
        ClubModule::forum();
        break;
    case 'best':
        ClubModule::best();
    private function show($current_type = '')
    {
        global $_FANWE;
        $share_id = intval($_FANWE['request']['sid']);
        $id = intval($_FANWE['request']['id']);
        $share_detail = FS('Share')->getShareDetail($share_id);
        include fimport('dynamic/u');
        if ($share_detail === false) {
            fHeader("location: " . FU('index'));
        }
        $page_title = preg_replace("/\\[[^\\]]+\\]/i", "", $share_detail['content']);
        $_FANWE['nav_title'] = $page_title . ' - ' . lang('common', 'share');
        $_FANWE['seo_description'] = $page_title;
        $_FANWE['setting']['site_description'] = '';
        $current_img = FDB::resultFirst("select img from " . FDB::table("share_photo") . " where share_id = " . $share_id . " and img <> '' ");
        if ($current_img['img_width'] > 468) {
            $current_img['img_width'] = 468;
        }
        $current_img_arr = FDB::fetchFirst("select * from " . FDB::table("share_photo") . " where share_id = " . $share_id . " and img <> '' ");
        //var_dump($current_img_arr);
        FDB::query('UPDATE ' . FDB::table('share') . ' SET click_count = click_count + 1 WHERE share_id = ' . $share_id);
        //上一个,下一个分享
        $pns = FS('Share')->getSameAlbumNextShares($share_detail['uid'], $share_id);
        $other_album_share = FS('share')->getSameAlbumShares($share_id);
        $current_location = $other_album_share['location'];
        unset($other_album_share['location']);
        $same_album_count = $other_album_share['count'];
        unset($other_album_share['count']);
        $aid = FDB::resultFirst("select album_id from " . FDB::table('album_share') . " where share_id = " . $share_id);
        $album_sql = 'select al.id as id,al.title as title from ' . FDB::table('album') . ' as al 
					 left join ' . FDB::table('album_share') . ' as als on al.id = als.album_id 
					 where als.share_id = ' . $share_id;
        $album_data = FDB::fetchFirst($album_sql);
        $is_follow_album = FS('album')->getIsFollow($aid, $_FANWE['uid']);
        //发布分享的会员
        $share_user = FS('User')->getUserById($share_detail['uid']);
        //喜欢分享的会员
        $share_detail['collects'] = FS('Share')->getShareCollectUser($share_id);
        if (!isset($share_detail['collects'][$_FANWE['uid']])) {
            if (FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid'])) {
                $share_detail['collects'][$_FANWE['uid']] = $_FANWE['uid'];
            }
        }
        //会员显示名称
        $user_show_name = FS('User')->getUserShowName($share_detail['uid']);
        //会员勋章
        $user_medals = FS('User')->getUserMedal($share_detail['uid']);
        //分享标签
        $share_tags = $share_detail['cache_data']['tags']['user'];
        FS('Share')->tagsFormat($share_tags);
        foreach ($share_tags as $seo_tag) {
            $_FANWE['seo_keywords'] .= $seo_tag['tag_name'] . ',';
        }
        //是否可编辑标签
        $is_eidt_tag = FS('Share')->getIsEditTag($share_detail);
        //喜欢分享的会员还喜欢
        $fav_user_fav_share = FS('Share')->getCollectShareByShare($share_id);
        //发布分享的会员喜欢的分享
        $user_collect_share = FS('Share')->getCollectShareByUser($share_user['uid']);
        //是否可删除标签
        $is_remove_comment = FS('Share')->getIsRemoveComment($share_detail);
        //分享评论
        $share_detail['comments'] = FS('Share')->getShareCommentList($share_id, '0,10');
        //分享评论分页
        $pager = buildPage('', array(), $share_detail['comment_count'], $_FANWE['page'], 10);
        unset($share_detail['cache_data']);
        $current_obj = NULL;
        if ($current_type == '' || $id == 0) {
            if (!empty($share_detail['imgs'])) {
                $current_obj = current($share_detail['imgs']);
                if ($current_obj['type'] == 'g') {
                    $current_type = 'bao';
                } else {
                    $current_type = 'photo';
                }
            }
        } else {
            switch ($current_type) {
                case 'bao':
                    foreach ($share_detail['imgs'] as $img) {
                        $current_obj = $img;
                        if ($img['type'] == 'g' && $img['id'] == $id) {
                            break;
                        }
                    }
                    break;
                case 'photo':
                    foreach ($share_detail['imgs'] as $img) {
                        $current_obj = $img;
                        if ($img['type'] == 'm' && $img['id'] == $id) {
                            break;
                        }
                    }
                    break;
            }
        }
        if (!empty($current_obj['name'])) {
            $_FANWE['nav_title'] = $current_obj['name'] . ' - ' . lang('common', 'share');
        }
        $current_img_id = FDB::resultFirst("select photo_id from " . FDB::table("share_photo") . " where share_id = " . $share_id);
        //会员最被喜欢的照片
        $best_photo_share = FS('Share')->getBestCollectPhotoShareByUser($share_user['uid']);
        $current_type = FDB::resultFirst("select type from " . FDB::table("share_photo") . " where share_id = " . $share_id);
        if ($current_type == 'video') {
            $current_video = FDB::resultFirst("select video from " . FDB::table("share_photo") . " where share_id = " . $share_id);
        }
        //会员喜欢的照片
        $user_fav_photo = FS('Share')->getUserFavPhotoShare($share_user['uid']);
        $is_follow = FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid']);
        include template('page/note/note_index');
        display();
    }
Example #24
0
<?php

define('MODULE_NAME', 'Index');
define('ACTION_NAME', 'index');
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->cache_list[] = 'forums';
$fanwe->initialize();
require fimport('module/index');
IndexModule::index();
Example #25
0
<?php

define('MODULE_NAME', 'User');
$actions = array('login', 'logout', 'ajax_login', 'register', 'ajax_register', 'forgetpassword', 'resetpassword', 'interest', 'followdaren', 'agreement', 'bind', 'savebind');
if (isset($_REQUEST['action'])) {
    $action = strtolower($_REQUEST['action']);
    if (!in_array($action, $actions)) {
        $action = 'login';
    }
}
define('ACTION_NAME', $action);
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->initialize();
require fimport('module/user');
switch (ACTION_NAME) {
    case 'logout':
        UserModule::logout();
        break;
    case 'login':
        UserModule::login();
        break;
    case 'ajax_login':
        UserModule::ajaxLogin();
        break;
    case 'register':
        UserModule::register();
        break;
    case 'ajax_register':
        UserModule::ajaxRegister();
    case 'forgetpassword':
 public function send()
 {
     $content = trim($_REQUEST['content']);
     $user_names = trim($_REQUEST['user_names']);
     if (empty($content)) {
         $this->error(L('CONTENT_REQUIRE'));
     }
     $pids = NULL;
     if (!empty($user_names)) {
         $user_names = explode(',', $user_names);
         $user_names = array_unique($user_names);
         $condition = array('user_name' => array('in', $user_names), 'status' => 1);
         $users = D('User')->where($condition)->field('uid')->findAll();
         $uids = array();
         foreach ($users as $user) {
             $uids[] = (int) $user['uid'];
         }
         if (count($uids) > 0) {
             $pids = array();
             $condition = array('clientid' => array('in', $uids), 'status' => 'active');
             $devices = D('ApnsDevices')->where($condition)->field('pid')->findAll();
             foreach ($devices as $device) {
                 $pids[] = (int) $devices['pid'];
             }
             if (count($pids) == 0) {
                 $this->error(L('UIDS_ERROR2'));
             }
         } else {
             $this->error(L('UIDS_ERROR1'));
         }
     }
     Vendor('common');
     require fimport('class/apns');
     $apns = new APNS();
     $apns->newMessage($pids);
     $apns->addMessageAlert($content);
     //$apns->addMessageBadge(2);
     $apns->addMessageSound('bingbong.aiff');
     $apns->queueMessage();
     $fp = fsockopen($_SERVER['HTTP_HOST'], 80, &$errno, &$errstr, 5);
     if ($fp) {
         $request = "GET " . SITE_URL . "apns.php?process=1 HTTP/1.0\r\n";
         $request .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
         $request .= "Connection: Close\r\n\r\n";
         fwrite($fp, $request);
         while (!feof($fp)) {
             fgets($fp, 128);
             break;
         }
         fclose($fp);
     }
     $this->success(L('SEND_SUCCESS'));
 }
 /**
  * 更新缓存数据
  * @param string $cache_name 缓存键名 为空则更新所有缓存
  * @return void
  */
 public function updateCache($cache_names = '')
 {
     $update_list = empty($cache_names) ? array() : (is_array($cache_names) ? $cache_names : array($cache_names));
     if (!$update_list) {
         @(require_once fimport('cache/setting'));
         bindCacheSetting();
         $cache_dir = FANWE_ROOT . './core/cache';
         $cache_dir_handle = dir($cache_dir);
         while ($entry = $cache_dir_handle->read()) {
             if (!in_array($entry, array('.', '..')) && preg_match("/^([\\w]+)\\.cache\\.php\$/", $entry, $entryr) && $entryr[1] != 'setting' && substr($entry, -10) == '.cache.php' && is_file($cache_dir . '/' . $entry)) {
                 require_once fimport('cache/' . $entryr[1]);
                 call_user_func('bindCache' . ucfirst($entryr[1]));
             }
         }
     } else {
         foreach ($update_list as $entry) {
             require_once fimport('cache/' . $entry);
             call_user_func('bindCache' . ucfirst($entry));
         }
     }
 }
Example #28
0
<?php

define('MODULE_NAME', 'Daren');
$actions = array('index', 'all', 'apply', 'save');
$action = 'index';
if (isset($_REQUEST['action'])) {
    $action = strtolower($_REQUEST['action']);
    if (!in_array($action, $actions)) {
        $action = 'index';
    }
}
define('ACTION_NAME', $action);
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->cache_list[] = 'citys';
$fanwe->initialize();
require fimport('module/daren');
switch (ACTION_NAME) {
    case 'index':
        DarenModule::index();
        break;
    case 'all':
        DarenModule::all();
        break;
    case 'apply':
        DarenModule::apply();
        break;
    case 'save':
        DarenModule::save();
        break;
}
    private function getList()
    {
        global $_FANWE;
        $_FANWE['user_click_share_id'] = (int) $_FANWE['request']['sid'];
        unset($_FANWE['request']['sid']);
        $cache_file = getTplCache('page/book/book_index', $_FANWE['request'], 2);
        if (getCacheIsUpdate($cache_file, BOOK_CACHE_PAGE_TIME)) {
            $category = urldecode($_FANWE['request']['cate']);
            $is_root = false;
            $page_args = array();
            if (isset($_FANWE['cache']['goods_category']['cate_code'][$category])) {
                $page_args['cate'] = $_FANWE['request']['cate'];
                $cate_id = $_FANWE['cache']['goods_category']['cate_code'][$category];
                $goods_cate_code = $category;
            } else {
                $is_root = true;
                $cate_id = $_FANWE['cache']['goods_category']['root'];
            }
            $sort = $_FANWE['request']['sort'];
            $sort = !empty($sort) ? $sort : "pop";
            $category_data = $_FANWE['cache']['goods_category']['all'][$cate_id];
            $category_tags = array();
            $_FANWE['nav_title'] = $category_data['cate_name'];
            if (!empty($category_data['seo_keywords'])) {
                $_FANWE['seo_keywords'] = $category_data['seo_keywords'];
                $_FANWE['setting']['site_keywords'] = '';
            }
            if (!empty($category_data['seo_desc'])) {
                $_FANWE['seo_description'] = $category_data['seo_desc'];
                $_FANWE['setting']['site_description'] = '';
            }
            $child_ids = array();
            if (isset($category_data['child'])) {
                $child_ids = $category_data['child'];
                if (!$is_root) {
                    $tagurlpara['cate'] = urlencode($category_data['cate_code']);
                }
                foreach ($category_data['child'] as $child_id) {
                    $child_cate = $_FANWE['cache']['goods_category']['all'][$child_id];
                    $tag_key = 'goods_category_tags_' . $child_id;
                    FanweService::instance()->cache->loadCache($tag_key);
                    foreach ($_FANWE['cache'][$tag_key] as $k => $tag) {
                        $tagurlpara['tag'] = urlencode($tag['tag_name']);
                        $tag['url'] = FU("book/" . ACTION_NAME, $tagurlpara);
                        $child_cate['tags'][] = $tag;
                        if ($k > 16) {
                            break;
                        }
                    }
                    $category_tags[] = $child_cate;
                }
            }
            $hot_tags = array();
            if (!$is_root) {
                $child_ids[] = $cate_id;
                require fimport("function/share");
                $hot_tags = getHotTags($child_ids, $category, 10);
            }
            $condition = " WHERE s.share_data IN ('goods','photo','goods_photo')";
            if (!$is_root) {
                $cids = array();
                FS('Share')->getChildCids($cate_id, $cids);
                $condition .= " AND sc.cate_id IN (" . implode(',', $cids) . ")";
            }
            $title = $category_data['short_name'];
            $is_match = false;
            $tag = urldecode($_FANWE['request']['kw']);
            if (!empty($tag)) {
                $_FANWE['nav_title'] = $tag . ' - ' . $_FANWE['nav_title'];
                $title = htmlspecialchars($tag);
                $is_match = true;
                //$match_key = FS('Words')->segment($tag,10);
                //$match_key = tagToUnicode($match_key,'+');
                $match_key = segmentToUnicode($tag, '+');
                $condition .= " AND match(sm.content_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
                $page_args['tag'] = urlencode($tag);
            }
            //输出排序URL
            $sort_page_args = $page_args;
            $sort_page_args['sort'] = 'hot7';
            $hot7_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args);
            if ($sort == 'hot7') {
                $hot7_url['act'] = 1;
            }
            $sort_page_args['sort'] = 'hot30';
            $hot30_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args);
            if ($sort == 'hot30') {
                $hot30_url['act'] = 1;
            }
            $sort_page_args['sort'] = 'new';
            $new_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args);
            if ($sort == 'new') {
                $new_url['act'] = 1;
            }
            $sort_page_args['sort'] = 'pop';
            $pop_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args);
            if ($sort == 'pop') {
                $pop_url['act'] = 1;
            }
            if (!empty($_FANWE['request']['sort'])) {
                $page_args['sort'] = $sort;
            } else {
                $page_args['sort'] = 'pop';
            }
            $today_time = getTodayTime();
            switch ($sort) {
                //7天最热 点击次数
                case 'hot7':
                    $day7_time = $today_time - 604800;
                    $field = ",(s.create_time > {$day7_time}) AS time_sort ";
                    $sort = " ORDER BY time_sort DESC,s.click_count DESC";
                    break;
                    //30天最热 点击次数
                //30天最热 点击次数
                case 'hot30':
                    $day30_time = $today_time - 2592000;
                    $field = ",(s.create_time > {$day30_time}) AS time_sort ";
                    $sort = " ORDER BY time_sort DESC,s.click_count DESC";
                    break;
                    //最新
                //最新
                case 'new':
                    $field = '';
                    $sort = " ORDER BY s.share_id DESC";
                    break;
                    //潮流  喜欢人数
                //潮流  喜欢人数
                case 'pop':
                default:
                    $day7_time = $today_time - 604800;
                    $field = ",(s.create_time > {$day7_time}) AS time_sort ";
                    $sort = " ORDER BY time_sort DESC,s.collect_count DESC";
                    break;
            }
            $sql = 'SELECT DISTINCT(s.share_id),s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data ' . $field . '
					FROM ' . FDB::table('share') . ' AS s ';
            if (!$is_root) {
                $sql .= 'INNER JOIN ' . FDB::table('share_category') . ' AS sc ON s.share_id = sc.share_id ';
            }
            if ($is_match) {
                $sql .= 'INNER JOIN ' . FDB::table('share_match') . ' AS sm ON sm.share_id = s.share_id ';
            }
            $sql .= $condition . $sort;
            $sql_count = 'SELECT COUNT(DISTINCT s.share_id)
				FROM ' . FDB::table('share') . ' AS s ';
            if (!$is_root) {
                $sql_count .= 'INNER JOIN ' . FDB::table('share_category') . ' AS sc ON s.share_id = sc.share_id ';
            }
            if ($is_match) {
                $sql_count .= 'INNER JOIN ' . FDB::table('share_match') . ' AS sm ON sm.share_id = s.share_id ';
            }
            $sql_count .= $condition;
            $page_size = 50;
            $max_page = 100;
            $count = FDB::resultFirst($sql_count);
            if ($count > $max_page * $page_size) {
                $count = $max_page * $page_size;
            }
            if ($_FANWE['page'] > $max_page) {
                $_FANWE['page'] = $max_page;
            }
            $pager = buildPage('book/' . $action, $page_args, $count, $_FANWE['page'], $page_size, '', 3);
            $share_datas = array();
            $sql = $sql . ' LIMIT ' . $pager['limit'];
            $share_list = FDB::fetchAll($sql);
            $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2);
            $col = 4;
            $index = 0;
            $share_display = array();
            foreach ($share_list as $share) {
                $mod = $index % $col;
                $share_display['col' . $mod][] = $share;
                $index++;
            }
            include template('page/book/book_index');
            display($cache_file);
            exit;
        } else {
            include $cache_file;
            display();
        }
    }
Example #30
0
<?php

define('MODULE_NAME', 'adv');
define('ACTION_NAME', 'show');
require dirname(__FILE__) . '/core/fanwe.php';
$fanwe =& FanweService::instance();
$fanwe->cache_list = array();
$fanwe->initialize();
require fimport('module/adv');
AdvModule::show();