Exemplo n.º 1
0
 function cache_file()
 {
     global $_J;
     $this->prefix = 'cache_file_';
     if (defined('TEMPLATE_ROOT_PATH')) {
         $root_path = TEMPLATE_ROOT_PATH;
         $this->prefix .= basename(TEMPLATE_ROOT_PATH) . '_';
     } else {
         $root_path = ROOT_PATH;
     }
     $this->path = $root_path . 'data/cache/cache_file/';
     if ($_J['config']['memory_enable'] && $_J['config']['cache_file_to_memory']) {
         $this->memory = jclass('memory');
     }
     if (!$this->memory) {
         $this->io = jio();
     }
 }
Exemplo n.º 2
0
 function OpenTable()
 {
     $this->unicode_table = array();
     if ($this->config['SourceLang'] == 'GBK' || $this->config['TargetLang'] == 'GBK') {
         $this->table = CODETABLE_DIR . $this->config['GBtoUnicode_table'];
     } elseif ($this->config['SourceLang'] == 'BIG5' || $this->config['TargetLang'] == 'BIG5') {
         $this->table = CODETABLE_DIR . $this->config['BIG5toUnicode_table'];
     }
     $table_cache_file = CACHE_PATH . $this->config['SourceLang'] . '-' . $this->config['TargetLang'] . ".cache.php";
     if (include $table_cache_file) {
         $this->unicode_table = $unicode_table;
         unset($unicode_table);
         return null;
     }
     $fp = @fopen($this->table, 'rb');
     $tabletmp = @fread($fp, filesize($this->table));
     for ($i = 0; $i < strlen($tabletmp); $i += 4) {
         $tmp = unpack('nkey/nvalue', substr($tabletmp, $i, 4));
         if ($this->config['TargetLang'] == 'UTF-8') {
             $this->unicode_table[$tmp['key']] = '0x' . dechex($tmp['value']);
         } elseif ($this->config['SourceLang'] == 'UTF-8') {
             $this->unicode_table[$tmp['value']] = '0x' . dechex($tmp['key']);
         } elseif ($this->config['TargetLang'] == 'UNICODE') {
             $this->unicode_table[$tmp['key']] = dechex($tmp['value']);
         }
     }
     if (!is_dir(CODETABLE_DIR)) {
         jio()->MakeDir(CODETABLE_DIR);
     }
     is_writeable(CODETABLE_DIR) || die("编码缓存目录不可写。请检查:" . CODETABLE_DIR);
     if (!is_dir(dirname($table_cache_file))) {
         jio()->MakeDir(dirname($table_cache_file));
     }
     $fp = @fopen($table_cache_file, 'wb');
     fwrite($fp, "<?php\r\n\$unicode_table=" . var_export($this->unicode_table, true) . ";?>");
     fclose($fp);
 }
Exemplo n.º 3
0
/**
 * 作者:狐狸<*****@*****.**>
 * 功能描述: 图片相关
 * @version $Id: image.func.php 5268 2013-12-16 08:28:12Z wuliyong $
 */
function __is_image($filename, $allow_types = array('gif' => 1, 'jpg' => 1, 'png' => 1, 'bmp' => 1, 'jpeg' => 1))
{
    clearstatcache();
    if (!is_file($filename)) {
        return false;
    }
    $imagetypes = array('1' => 'gif', '2' => 'jpg', '3' => 'png', '4' => 'swf', '5' => 'psd', '6' => 'bmp', '7' => 'tiff', '8' => 'tiff', '9' => 'jpc', '10' => 'jp2', '11' => 'jpx', '12' => 'jb2', '13' => 'swc', '14' => 'iff', '15' => 'wbmp', '16' => 'xbm', '17' => 'jpeg');
    if (!$allow_types) {
        $allow_types = array('gif' => 1, 'jpg' => 1, 'png' => 1, 'bmp' => 1, 'jpeg' => 1);
    }
    $typeid = 0;
    $imagetype = '';
    if (function_exists('exif_imagetype')) {
        $typeid = exif_imagetype($filename);
    } elseif (function_exists('getimagesize')) {
        $_tmps = getimagesize($filename);
        if ($_tmps) {
            $typeid = (int) $_tmps[2];
        }
    } else {
        $str2 = jio()->ReadFile($filename, 2);
        if ($str2) {
            $strInfo = unpack("C2chars", $str2);
            $fileTypes = array(7790 => 'exe', 7784 => 'midi', 8297 => 'rar', 255216 => 'jpg', 7173 => 'gif', 6677 => 'bmp', 13780 => 'png');
            $imagetype = $fileTypes[intval($strInfo['chars1'] . $strInfo['chars2'])];
        }
    }
    $file_ext = strtolower(trim(substr(strrchr($filename, '.'), 1)));
    if ($typeid > 0) {
        $imagetype = $imagetypes[$typeid];
    }
    if ($allow_types && $file_ext && $imagetype && isset($allow_types[$file_ext]) && isset($allow_types[$imagetype])) {
        return true;
    }
    return false;
}
Exemplo n.º 4
0
 function face($p = array(), $modify = 1)
 {
     global $_J;
     $pic_file = $p['pic_file'] && is_image($p['pic_file']) ? $p['pic_file'] : '';
     $pic_url = $p['pic_url'] && false !== strpos($p['pic_url'], ':/' . '/') ? $p['pic_url'] : '';
     $p['pic_field'] = $p['pic_field'] ? $p['pic_field'] : 'face';
     $pic_field = $p['pic_field'] && $_FILES[$p['pic_field']] ? $p['pic_field'] : '';
     if (!$pic_file && !$pic_url && !$pic_field) {
         return jerror('pic is empty', 0);
     }
     $uid = $p['uid'] ? (int) $p['uid'] : MEMBER_ID;
     if ($uid < 1) {
         return jerror('请指定一个用户ID', -1);
     }
     $member = jsg_member_info($uid);
     if (!$member) {
         return jerror('用户已经不存在了', -2);
     }
     if (!$_J['config']['edit_face_enable'] && $member['__face__'] && 'admin' != MEMBER_ROLE_TYPE) {
         return jerror('不允许用户修改头像', -3);
     }
     $src_x = max(0, (int) $p['x']);
     $src_y = max(0, (int) $p['y']);
     $src_w = max(0, (int) $p['w']);
     $src_h = max(0, (int) $p['h']);
     $image_path = RELATIVE_ROOT_PATH . 'images/' . ($_J['config']['face_verify'] ? 'face_verify' : 'face') . '/' . face_path($uid);
     $image_name = $uid . '_b.jpg';
     $image_file = $image_path . $image_name;
     $image_file_small = $image_path . $uid . '_s.jpg';
     $image_file_temp = $image_path . $uid . '_t.jpg';
     if (!is_dir($image_path)) {
         jmkdir($image_path);
     }
     if (!$modify && is_image($image_file)) {
         return jerror('头像已经存在了', -4);
     }
     if ($pic_file) {
         $src_file = $pic_file;
     } elseif ($pic_url) {
         $image_data = dfopen($pic_url, 99999999, '', '', true, 3, $_SERVER['HTTP_USER_AGENT']);
         if ($image_data) {
             jio()->WriteFile($image_file, $image_data);
             if (is_image($image_file)) {
                 $src_file = $image_file;
             }
         }
     } elseif ($pic_field) {
         jupload()->init($image_path, $pic_field, true, false);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result && is_image($image_file)) {
             $src_file = $image_file;
         }
     }
     if (!is_image($src_file)) {
         return jerror('源头像不存在了,请上传正确的图片文件', -5);
     }
     $w = max(50, min(128, $src_w > 50 ? $src_w : 200));
     $make_result = makethumb($src_file, $image_file, $w, $w, 0, 0, $src_x, $src_y, $src_w, $src_h);
     $make_result = makethumb($src_file, $image_file_small, 50, 50, 0, 0, $src_x, $src_y, $src_w, $src_h);
     $face_url = '';
     if ($_J['config']['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $face_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
         if ($ftp_result > 0) {
             ftpcmd('upload', $image_file_small, '', $ftp_key);
             jio()->DeleteFile($image_file);
             jio()->DeleteFile($image_file_small);
         }
     }
     if ($_J['config']['face_verify']) {
         $count = DB::result_first("SELECT COUNT(1) FROM " . DB::table('members_verify') . " WHERE `uid`='{$uid}'");
         if ($count) {
             $sql = "update `" . TABLE_PREFIX . "members_verify` set `face_url`='{$face_url}', `face`='{$image_file_small}' where `uid`='{$uid}'";
         } else {
             $sql = "insert into `" . TABLE_PREFIX . "members_verify` (`uid`,`nickname`,`face_url`,`face`) values('{$uid}','{$member['nickname']}','{$face_url}','{$image_file_small}')";
         }
         DB::query($sql);
         if ($_J['config']['notice_to_admin']) {
             $pm_post = array('message' => $member['nickname'] . " 修改了头像进入审核,<a href='admin.php?mod=verify&code=fs_verify' target='_blank'>点击</a>进入审核。", 'to_user' => str_replace('|', ',', $_J['config']['notice_to_admin']));
             $admin_info = jsg_member_info(1);
             jlogic('pm')->pmSend($pm_post, $admin_info['uid'], $admin_info['username'], $admin_info['nickname']);
         }
     } else {
         $sql = "update `" . TABLE_PREFIX . "members` set `face_url`='{$face_url}', `face`='{$image_file_small}' where `uid`='{$uid}'";
         DB::query($sql);
         if ($_J['config']['extcredits_enable'] && $uid > 0) {
             update_credits_by_action('face', $uid);
         }
     }
     return true;
 }
Exemplo n.º 5
0
 function upload($p)
 {
     $sys_config = jconf::get();
     if (!$_FILES[$p['field']] || !$_FILES[$p['field']]['name']) {
         return array('error' => 'attach is empty', 'code' => -1);
     }
     $itemid = is_numeric($p['itemid']) ? $p['itemid'] : 0;
     $item = '';
     if ($itemid > 0) {
         $item = $p['item'];
     }
     $uid = (int) ($p['uid'] ? $p['uid'] : MEMBER_ID);
     if ($uid < 1 || false == ($member_info = jsg_member_info($uid))) {
         return array('error' => 'uid is invalid', 'code' => -2);
     }
     $_FILES[$p['field']]['name'] = get_safe_code($_FILES[$p['field']]['name']);
     $att_id = $this->add($uid, $member_info['nickname'], $item, $itemid);
     if ($att_id < 1) {
         return array('error' => 'write database is invalid', 'code' => -3);
     }
     $filetype = end(explode('.', $_FILES[$p['field']]['name']));
     $att_name = $att_id . '.' . $filetype;
     $att_path = RELATIVE_ROOT_PATH . 'data/attachs/topic/' . face_path($att_id);
     $att_file = $att_path . $att_name;
     if (!is_dir($att_path)) {
         jio()->MakeDir($att_path);
     }
     jupload()->init($att_path, $p['field'], false, true);
     jupload()->setMaxSize($sys_config['attach_size_limit']);
     jupload()->setNewName($att_name);
     $ret = jupload()->doUpload();
     if (!$ret) {
         $this->delete($att_id);
         $rets = jupload()->getError();
         $ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid';
         return array('error' => $ret, 'code' => -5);
     }
     $site_url = '';
     if ($sys_config['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $att_file, '', $ftp_key);
         if ($ftp_result > 0) {
             jio()->DeleteFile($att_file);
             $att_file = $site_url . '/' . str_replace('./', '', $att_file);
         }
     }
     $att_size = filesize($att_file);
     $p = array('id' => $att_id, 'site_url' => $site_url, 'photo' => $att_file, 'name' => $_FILES[$p['field']]['name'], 'filesize' => $att_size, 'filetype' => $filetype, 'tid' => max(0, (int) $p['tid']), 'uid' => $uid, 'username' => $member_info['nickname'], 'dateline' => (int) time());
     $this->modify($p);
     return $p;
 }
Exemplo n.º 6
0
 function DoAddADV()
 {
     $html = '';
     $location = jget('location', 'trim');
     $adid = jget('adid', 'int');
     if ($adid) {
         $sql = " select * from `" . TABLE_PREFIX . "ad` where `adid` = '{$adid}' ";
         $ad_info = DB::fetch_first($sql);
         $ad_info || $this->Messager("您要修改的广告不存在或已删除。", -1);
     }
     $location || $ad_info['location'] || $this->Messager("这个是哪里的广告位?", 'admin.php?mod=income');
     $title = jget('title', 'trim');
     if (!$title) {
         $this->Messager("请输入广告标题", -1);
     }
     $hcode = jget('hcode');
     if (count($hcode['page']) < 1) {
         $this->Messager("广告投放范围必须要有哦", -1);
     }
     $ftime = jget('ftime', 'trim');
     if ($ftime) {
         $ftime = strtotime($ftime);
     }
     $ttime = jget('ttime', 'trim');
     if ($ttime) {
         $ttime = strtotime($ttime);
     }
     $type = jget('type', 'int');
     switch ($type) {
         case 1:
             #代码
             if (!$hcode['html']) {
                 $this->Messager("广告HTML代码必须要有哦", -1);
             }
             $html = $hcode['html'];
             break;
         case 2:
             #文字
             if (!$hcode['word']) {
                 $this->Messager("文字内容必须要有哦", -1);
             }
             if (!$hcode['word_url']) {
                 $this->Messager("文字链接必须要有哦", -1);
             }
             if ($hcode['word_size']) {
                 $word_size = 'style="font-size:' . $hcode['word_size'] . 'px"';
             }
             $html = '<a href="' . $hcode['word_url'] . '" target="_blank"><span ' . $word_size . '>' . $hcode['word'] . '</span></a>';
             break;
         case 3:
             #图片
             if ($_FILES['image']['name']) {
                 $name = time() . MEMBER_ID;
                 $image_name = $name . ".jpg";
                 $image_path = RELATIVE_ROOT_PATH . 'images/ad/';
                 $image_file = $image_path . $image_name;
                 if (!is_dir($image_path)) {
                     jio()->MakeDir($image_path);
                 }
                 jupload()->init($image_path, 'image', true);
                 jupload()->setNewName($image_name);
                 $result = jupload()->doUpload();
                 if ($result) {
                     $result = is_image($image_file);
                 }
                 if (!$result) {
                     unlink($image_file);
                     $this->Messager("图片上传失败。", -1);
                 }
                 if ($this->Config['ftp_on']) {
                     $ftp_key = randgetftp();
                     $get_ftps = jconf::get('ftp');
                     $site_url = $get_ftps[$ftp_key]['attachurl'];
                     $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
                     if ($ftp_result > 0) {
                         jio()->DeleteFile($image_file);
                         $image_file = $site_url . '/' . str_replace('./', '', $image_file);
                     }
                 }
                 $hcode['image'] = $image_file;
             } else {
                 if (!$adid) {
                     $this->Messager("图片必须要有哦", -1);
                 } else {
                     $un_hcode = unserialize(base64_decode($ad_info['hcode']));
                     $hcode['image'] = $un_hcode['image'];
                 }
             }
             $hcode['pic_url'] || $this->Messager("图片链接必须要有哦", -1);
             $image_width_html = $hcode['pic_width'] ? ' width=' . $hcode['pic_width'] : '';
             $image_height_html = $hcode['pic_height'] ? ' height= ' . $hcode['pic_height'] : '';
             $html = '<a href="' . $hcode[pic_url] . '" target="_blank" title="' . $hcode['pic_title'] . '"><img src="' . $hcode['image'] . '" ' . $image_width_html . $image_height_html . '></a>';
             break;
         default:
             $this->Messager("展现方式必须要有哦", -1);
             break;
     }
     $ser_hcode = base64_encode(serialize($hcode));
     #保存到数据库
     $data = array('location' => $location, 'title' => $title, 'type' => $type, 'ftime' => $ftime, 'ttime' => $ttime, 'hcode' => $ser_hcode);
     if ($adid) {
         DB::update('ad', $data, " `adid` = '{$adid}' ");
     } else {
         $adid = DB::insert('ad', $data, true);
     }
     #保存到本地
     $ad = jconf::get('ad');
     if ($un_hcode['page']) {
         foreach ($un_hcode['page'] as $k => $v) {
             if (isset($ad['ad_list'][$v][$location][$adid]) && is_array($ad['ad_list'][$v][$location][$adid])) {
                 unset($ad['ad_list'][$v][$location][$adid]);
             }
         }
     }
     $AdLocationList = $this->AdLocationList();
     $ad_localtions = $AdLocationList[$location]['page'];
     if (isset($ad_localtions['width'])) {
         unset($ad_localtions['width']);
     }
     $unset_ad_pages = array_diff(array_keys($ad_localtions), $hcode['page']);
     if (is_array($unset_ad_pages) && count($unset_ad_pages) > 0) {
         foreach ($unset_ad_pages as $page) {
             if (isset($ad['ad_list'][$page]) && isset($ad['ad_list'][$page][$location]) && isset($ad['ad_list'][$page][$location][$adid]) && is_array($ad['ad_list'][$page][$location][$adid]) && $ad['ad_list'][$page][$location][$adid]) {
                 unset($ad['ad_list'][$page][$location][$adid]);
             }
             if ($ad['ad_list'][$page]) {
                 $ad['ad_list'][$page] = array_filter($ad['ad_list'][$page]);
             }
         }
         $ad['ad_list'] = array_filter($ad['ad_list']);
     }
     $ad['enable'] = 1;
     foreach ($hcode['page'] as $k => $v) {
         if (!is_array($ad['ad_list'][$v][$location])) {
             $ad['ad_list'][$v][$location] = array();
         }
         if (!is_array($ad['ad_list'][$v][$location][$adid])) {
             $ad['ad_list'][$v][$location][$adid] = array();
         }
         $ad['ad_list'][$v][$location][$adid]['html'] = $html;
         $ad['ad_list'][$v][$location][$adid]['ftime'] = $ftime;
         $ad['ad_list'][$v][$location][$adid]['ttime'] = $ttime;
     }
     jconf::set('ad', $ad);
     $this->Messager('设置成功', 'admin.php?mod=income&code=ad_list&op=' . $location);
 }
Exemplo n.º 7
0
 function onloadPic()
 {
     if (!$this->MemberHandler->HasPermission($this->Module, 'create')) {
         js_alert_showmsg($this->MemberHandler->GetError());
     }
     if ('admin' != MEMBER_ROLE_TYPE) {
         $is_allowed = jlogic('event')->allowedCreate(MEMBER_ID, $this->Member);
         if ($is_allowed) {
             js_alert_showmsg($is_allowed);
         }
     }
     if ($_FILES['pic']['name']) {
         $name = time() . MEMBER_ID;
         $image_name = $name . "_b.jpg";
         $image_path = RELATIVE_ROOT_PATH . 'images/event/';
         $image_file = $image_path . $image_name;
         $image_name_show = $name . "_s.jpg";
         $image_file_min = $image_path . $image_name_show;
         if (!is_dir($image_path)) {
             jio()->MakeDir($image_path);
         }
         jupload()->init($image_path, 'pic', true);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file);
         }
         if (!$result) {
             unlink($image_file);
             unlink($image_file_min);
             echo "<script language='Javascript'>";
             echo "parent.document.getElementById('message').style.display='block';";
             echo "parent.document.getElementById('uploading').style.display='none';";
             if ($this->Post['top'] == 'top') {
                 echo "parent.document.getElementById('back1').style.display='block';";
                 echo "parent.document.getElementById('next3').style.display='block';";
             }
             echo "parent.document.getElementById('message').innerHTML='图片上载失败'";
             echo "</script>";
             exit;
         }
         makethumb($image_file, $image_file_min, 60, 60, 0, 0, 0, 0, 0, 0);
         image_thumb($image_file, $image_file, 100, 128, 1, 0, 0);
         if ($this->Config['watermark_enable']) {
             jlogic('image')->watermark($image_file);
         }
         if ($this->Config['ftp_on']) {
             $ftp_key = randgetftp();
             $get_ftps = jconf::get('ftp');
             $site_url = $get_ftps[$ftp_key]['attachurl'];
             $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
             if ($ftp_result > 0) {
                 ftpcmd('upload', $image_file_min, '', $ftp_key);
                 jio()->DeleteFile($image_file);
                 jio()->DeleteFile($image_file_min);
                 $image_file = $site_url . '/' . str_replace('./', '', $image_file);
             }
         }
         $hid_pic = $this->Post['hid_pic'];
         $eid = (int) $this->Post['id'];
         $this->doUnlink($hid_pic, $eid);
         echo "<script language='Javascript'>";
         echo "parent.document.getElementById('uploading').style.display='none';";
         if ($this->Post['top'] == 'top') {
             echo "parent.document.getElementById('back1').style.display='block';";
             echo "parent.document.getElementById('next3').style.display='block';";
         }
         echo "parent.document.getElementById('message').style.display='none';";
         echo "parent.document.getElementById('img').style.display='block';";
         echo "parent.document.getElementById('showimg').src='{$image_file}';";
         echo "parent.document.getElementById('hid_pic').value='{$image_file}';";
         echo "</script>";
         exit;
     }
 }
Exemplo n.º 8
0
     if ($imageid > 0) {
         /*
         //高级接口,需要额外的申请
         $p['url'] = topic_image($imageid, 'original', 0);
         $rets = sina_weibo_api('2/statuses/upload_url_text', $p);
         */
         $p['pic'] = topic_image($imageid, 'original', 1);
         if ($GLOBALS['_J']['config']['ftp_on']) {
             $p['pic'] = RELATIVE_ROOT_PATH . 'data/cache/temp_images/topic/' . $p['pic'];
             if (!is_file($p['pic'])) {
                 $ppic = topic_image($imageid, 'original', 0);
                 if (false !== strpos($ppic, ':/' . '/')) {
                     $temp_image = dfopen($ppic, 99999999, '', '', true, 3, $_SERVER['HTTP_USER_AGENT']);
                     if (!$temp_image) {
                         jio()->MakeDir(dirname($p['pic']));
                         jio()->WriteFile($p['pic'], $temp_image);
                     }
                 }
             }
         }
         if (is_image($p['pic'])) {
             $rets = sina_weibo_api('2/statuses/upload', $p, 'POST', null, 1);
         } else {
             unset($p['pic']);
             $rets = sina_weibo_api('2/statuses/update', $p);
         }
     } else {
         $rets = sina_weibo_api('2/statuses/update', $p);
     }
 } else {
     if (false == ($xbt = DB::fetch_first("select * from " . DB::table('xwb_bind_topic') . " where `tid`='{$totid}'"))) {
Exemplo n.º 9
0
 function Face()
 {
     if (MEMBER_ID < 1) {
         js_alert_output("请先登录或者注册一个帐号", 'alert');
     }
     $uid = jget('uid', 'int', 'G');
     $uid = $uid ? $uid : MEMBER_ID;
     $member = jsg_member_info($uid);
     if ('admin' != MEMBER_ROLE_TYPE) {
         if (!$this->Config['edit_face_enable'] && $member['__face__']) {
             js_alert_output('本站不允许用户修改头像。', 'alert');
         }
         if ($uid != MEMBER_ID) {
             js_alert_output('您没有权限修改此头像');
         }
     }
     $field = 'face';
     $temp_img_size = intval($_FILES[$field]['size'] / 1024);
     if ($temp_img_size >= 2048) {
         js_alert_output('图片文件过大,2MB以内', 'alert');
     }
     $type = trim(strtolower(end(explode(".", $_FILES[$field]['name']))));
     if ($type != 'gif' && $type != 'jpg' && $type != 'png' && $type != 'jpeg') {
         js_alert_output('图片格式不对', 'alert');
     }
     $image_name = substr(md5($_FILES[$field]['name']), -10) . ".{$type}";
     $image_path = RELATIVE_ROOT_PATH . 'images/temp/face_images/' . $image_name[0] . '/';
     $image_file = $image_path . $image_name;
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     jupload()->init($image_path, $field, true, false);
     jupload()->setNewName($image_name);
     $result = jupload()->doUpload();
     if ($result) {
         $result = is_image($image_file);
     }
     if (!$result) {
         js_alert_output('图片上载失败', 'alert');
     }
     list($w, $h) = getimagesize($image_file);
     if ($w > 601) {
         $tow = 599;
         $toh = round($tow * ($h / $w));
         $result = makethumb($image_file, $image_file, $tow, $toh);
         if (!$result) {
             jio()->DeleteFile($image_file);
             js_alert_output('大图片缩略失败', 'alert');
         }
     }
     $up_image_path = addslashes($image_file);
     echo "<script language='Javascript'>";
     if ($this->Post['temp_face']) {
         echo "window.parent.location.href='{$this->Config[site_url]}/index.php?mod=settings&code=face&temp_face={$up_image_path}'";
     } else {
         echo "parent.document.getElementById('cropbox').src='{$up_image_path}';";
         echo "parent.document.getElementById('img_path').value='{$up_image_path}';";
         echo "parent.document.getElementById('temp_face').value='{$up_image_path}';";
         echo "parent.document.getElementById('jcrop_init_id').onclick();";
         echo "parent.document.getElementById('cropbox_img1').value='{$up_image_path}';";
     }
     echo "</script>";
 }
Exemplo n.º 10
0
 function DoExport()
 {
     global $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
     $excepttables = array(TABLE_PREFIX . "sessions", TABLE_PREFIX . "cache");
     $time = $timestamp = time();
     $tablepre = TABLE_PREFIX;
     $this->DatabaseHandler->Query('SET SQL_QUOTE_SHOW_CREATE=1', 'SKIP_ERROR');
     $filename = get_param('filename');
     if (!$filename || preg_match("/(\\.)(exe|php|jsp|asp|aspx|cgi|fcgi|pl)(\\.|\$)/i", $filename) || !preg_match('~^[\\w\\d\\-\\_]+$~', $filename)) {
         $this->Messager("备份文件名无效");
     }
     $type = get_param('type');
     $setup = get_param('setup');
     $customtables = get_param('customtables');
     $startrow = get_param('startrow');
     $extendins = get_param('extendins');
     $usehex = get_param('usehex');
     $usezip = get_param('usezip');
     $sizelimit = get_param('sizelimit');
     $volume = (int) get_param('volume');
     $method = 'multivol';
     $sqlcharset = get_param('sqlcharset');
     $sqlcompat = get_param('sqlcompat');
     if ($type == 'all_tables') {
         $tables = $this->_array_keys2($this->_fetch_table_list($tablepre), 'Name');
     } elseif ($type == 'custom') {
         $tables = array();
         $cache_id = "tables";
         if (empty($setup)) {
             $tables = cache_file('get', $cache_id);
         } else {
             cache_file('set', $cache_id, $customtables);
             $tables =& $customtables;
         }
         if (!is_array($tables) || empty($tables)) {
             $this->Messager("没有要导出的数据表");
         }
     }
     $volume = intval($volume) + 1;
     $idstring = '# Identify: ' . base64_encode("{$timestamp}," . SYS_VERSION . ",{$type},{$method},{$volume}") . "\n";
     $dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $this->Config['charset']);
     $setnames = $sqlcharset && $this->DatabaseHandler->GetVersion() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41') ? "SET NAMES '{$dumpcharset}';\n\n" : '';
     if ($this->DatabaseHandler->GetVersion() > '4.1') {
         if ($sqlcharset) {
             $this->DatabaseHandler->Query("SET NAMES '" . $sqlcharset . "';\n\n");
         }
         if ($sqlcompat == 'MYSQL40') {
             $this->DatabaseHandler->Query("SET SQL_MODE='MYSQL40'");
         } elseif ($sqlcompat == 'MYSQL41') {
             $this->DatabaseHandler->Query("SET SQL_MODE=''");
         }
     }
     $f = str_replace(array('/', '\\', '.'), '', $filename);
     $f = dir_safe($f);
     $backupdir = 'db/' . $f;
     $backupfilename = './data/backup/' . $backupdir . '/' . $f;
     if (!is_dir($d = dirname($backupfilename))) {
         jio()->MakeDir($d);
     }
     if ($usezip) {
         require_once ROOT_PATH . 'include/func/zip.func.php';
     }
     if ($method == 'multivol') {
         $sqldump = '';
         $tableid = intval(get_param('tableid'));
         $startfrom = intval(get_param('startfrom'));
         $complete = TRUE;
         for (; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
             $sqldump .= $this->_sql_dump_table($tables[$tableid], $startfrom, strlen($sqldump));
             if ($complete) {
                 $startfrom = 0;
             }
         }
         $dumpfile = $backupfilename . "-%s" . '.sql';
         !$complete && $tableid--;
         if (trim($sqldump)) {
             $sqldump = "{$idstring}" . "# <?php exit(); ?>\n" . "# JishiGou Multi-Volume Data Dump Vol.{$volume}\n" . "# Version: JishiGou " . SYS_VERSION . "\n" . "# Time: {$time}\n" . "# Type: {$type}\n" . "# Table Prefix: {$tablepre}\n" . "#\n" . "# JishiGou Home: http:\\/\\/www.jishigou.net\n" . "# Please visit our website for newest infomation about JishiGou\n" . "# --------------------------------------------------------\n\n\n" . "{$setnames}" . $sqldump;
             $dumpfilename = sprintf($dumpfile, $volume);
             $fp = fopen($dumpfilename, 'wb');
             flock($fp, 2);
             if (!fwrite($fp, $sqldump)) {
                 fclose($fp);
                 $this->Messager("备份文件写入失败,请检查是否有足够的权限或联系管理员");
             } else {
                 fclose($fp);
                 if ($usezip == 2) {
                     $fp = @fopen($dumpfilename, "r");
                     $content = @fread($fp, filesize($dumpfilename));
                     fclose($fp);
                     $zip = new zipfile();
                     $zip->addFile($content, basename($dumpfilename));
                     $fp = @fopen(sprintf($backupfilename . "-%s" . '.zip', $volume), 'w');
                     if (fwrite($fp, $zip->file()) !== FALSE) {
                         @unlink($dumpfilename);
                     }
                     fclose($fp);
                 }
                 unset($sqldump, $zip, $content);
                 $this->Messager("分卷备份: 数据文件 #{$volume} 成功创建,程序将自动继续。\r\n", "admin.php?mod=db&code=doexport&type=" . rawurlencode($type) . "&saveto=server&filename=" . rawurlencode($filename) . "&method=multivol&sizelimit=" . rawurlencode($sizelimit) . "&volume=" . rawurlencode($volume) . "&tableid=" . rawurlencode($tableid) . "&startfrom=" . rawurlencode($startrow) . "&extendins=" . rawurlencode($extendins) . "&sqlcharset=" . rawurlencode($sqlcharset) . "&sqlcompat=" . rawurlencode($sqlcompat) . "&exportsubmit=yes&usehex={$usehex}&usezip={$usezip}");
             }
         } else {
             $volume--;
             $filelist = '<ul>';
             if ($usezip == 1) {
                 $zip = new zipfile();
                 $zipfilename = $backupfilename . '.zip';
                 $unlinks = array();
                 for ($i = 1; $i <= $volume; $i++) {
                     $filename = sprintf($dumpfile, $i);
                     $fp = @fopen($filename, "r");
                     $content = @fread($fp, filesize($filename));
                     fclose($fp);
                     $zip->addFile($content, basename($filename));
                     $unlinks[] = $filename;
                     $filelist .= "<li><a href=\"{$filename}\">{$filename}</a></li>\n";
                 }
                 $fp = @fopen($zipfilename, 'w');
                 if (fwrite($fp, $zip->file()) !== FALSE) {
                     foreach ($unlinks as $f) {
                         jio()->DeleteFile($f);
                     }
                 } else {
                     $this->Messager('database_export_multivol_succeed');
                 }
                 unset($sqldump, $zip, $content);
                 fclose($fp);
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 $filename = $zipfilename;
                 $this->Messager("数据成功备份并压缩至服务器  data/backup/db/ 目录下。<br />" . (true === JISHIGOU_FOUNDER ? $filelist : ""), null);
             } else {
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 for ($i = 1; $i <= $volume; $i++) {
                     $filename = sprintf($usezip == 2 ? $backupfilename . "-%s" . '.zip' : $dumpfile, $i);
                     $filelist .= "<li><a href=\"{$filename}\">{$filename}</a></li>\n";
                 }
                 $this->Messager("恭喜您,全部 {$volume} 个备份文件成功创建,备份完成。\r\n" . (true === JISHIGOU_FOUNDER ? $filelist : "<br />文件备份在  data/backup/db/ 目录下"), null);
             }
         }
     } else {
         $tablesstr = '';
         foreach ($tables as $table) {
             $tablesstr .= '"' . $table . '" ';
         }
         $query = $this->DatabaseHandler->Query("SHOW VARIABLES LIKE 'basedir'");
         list(, $mysql_base) = $query->GetRow('row');
         $dumpfile = addslashes(dirname(dirname(__FILE__))) . '/' . $backupfilename . '.sql';
         @unlink($dumpfile);
         $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base) . 'bin/';
         @shell_exec($mysqlbin . 'mysqldump --force --quick ' . ($this->DatabaseHandler->GetVersion() > '4.1' ? '--skip-opt --create-options' : '-all') . ' --add-drop-table' . ($extendins == 1 ? ' --extended-insert' : '') . '' . ($this->DatabaseHandler->GetVersion() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '') . ' --host="' . $this->Config['db_host'] . ($this->Config['db_port'] ? is_numeric($this->Config['db_port']) ? ' --port=' . $this->Config['db_port'] : ' --socket="' . $this->Config['db_port'] . '"' : '') . '" --user="******" --password="******" "' . $this->Config['db_name'] . '" ' . $tablesstr . ' > ' . $dumpfile);
         if (is_file($dumpfile)) {
             if ($usezip) {
                 require_once ROOT_PATH . 'include/func/zip.func.php';
                 $zip = new zipfile();
                 $zipfilename = $backupfilename . '.zip';
                 $fp = @fopen($dumpfile, "r");
                 $content = @fread($fp, filesize($dumpfile));
                 fclose($fp);
                 $zip->addFile($idstring . "# <?exit();?>\n " . $setnames . "\n #" . $content, basename($dumpfile));
                 $fp = @fopen($zipfilename, 'w');
                 fwrite($fp, $zip->file());
                 fclose($fp);
                 @unlink($dumpfile);
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 $filename = $backupfilename . '.zip';
                 unset($sqldump, $zip, $content);
                 $this->Messager('database_export_zip_succeed');
             } else {
                 if (is_writeable($dumpfile)) {
                     $fp = @fopen($dumpfile, 'rb+');
                     fwrite($fp, $idstring . "# <?exit();?>\n " . $setnames . "\n #");
                     fclose($fp);
                 }
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 $filename = $backupfilename . '.sql';
                 $this->Messager('database_export_succeed');
             }
         } else {
             $this->Messager('database_shell_fail');
         }
     }
 }
Exemplo n.º 11
0
 function DoModify()
 {
     $field = 'theme';
     $image_id = MEMBER_ID;
     $theme_bg_image = str_replace($this->Config['site_url'] . '/', '', $this->Post['theme_bg_image']);
     $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . face_path($image_id);
     $image_name = $image_id . "_o.jpg";
     $image_file = $image_path . $image_name;
     if ($_FILES && $_FILES[$field]['name']) {
         if (!is_dir($image_path)) {
             jio()->MakeDir($image_path);
         }
         jupload()->init($image_path, $field, true);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file);
         }
         if (!$result) {
             jio()->DeleteFile($image_file);
             $this->Messager("[图片上载失败]" . implode(" ", (array) jupload()->getError()), null);
         } else {
             $theme_bg_image = $image_file;
         }
     } else {
         if ($theme_bg_image != $image_file) {
         }
     }
     $theme_id = $this->Post['theme_id'];
     $theme_bg_color = $this->Post['theme_bg_color'];
     $theme_text_color = $this->Post['theme_text_color'];
     $theme_link_color = $this->Post['theme_link_color'];
     $theme_bg_image_type = $this->Post['theme_bg_image_type'];
     $theme_bg_repeat = $this->Post['theme_bg_repeat'] ? 1 : 0;
     $theme_bg_fixed = $this->Post['theme_bg_fixed'] ? 1 : 0;
     $sql = "update " . TABLE_PREFIX . "members set\r\n\t\t\t`theme_bg_image`='{$theme_bg_image}', `theme_bg_color`='{$theme_bg_color}', `theme_text_color`='{$theme_text_color}',\r\n\t\t\t`theme_link_color`='{$theme_link_color}' , theme_id='{$theme_id}' , theme_bg_image_type='{$theme_bg_image_type}' ,\r\n\t\t\t`theme_bg_repeat`='{$theme_bg_repeat}' , `theme_bg_fixed`='{$theme_bg_fixed}'\r\n\t\t\twhere `uid`='" . MEMBER_ID . "'";
     $this->DatabaseHandler->Query($sql);
     if ('admin' == MEMBER_ROLE_TYPE && $this->Post['set_default']) {
         $config = array();
         $config['theme_id'] = $theme_id;
         $config['theme_bg_image'] = $theme_bg_image;
         $config['theme_bg_color'] = $theme_bg_color;
         $config['theme_text_color'] = $theme_text_color;
         $config['theme_link_color'] = $theme_link_color;
         $config['theme_bg_image_type'] = $theme_bg_image_type;
         $config['theme_bg_repeat'] = $theme_bg_repeat;
         $config['theme_bg_fixed'] = $theme_bg_fixed;
         jconf::update($config);
     }
     $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "members where `uid`='" . MEMBER_ID . "'");
     $this->_initTheme($query->GetRow());
     $this->Messager("设置成功", 'index.php?mod=topic&code=myhome');
 }
Exemplo n.º 12
0
 function Delete()
 {
     $ids = $this->Post['ids'] ? $this->Post['ids'] : $this->Get['ids'];
     if (!$ids) {
         $this->Messager("请指定要删除的对象");
     }
     $ids = (array) $ids;
     foreach ($ids as $id) {
         $id = is_numeric($id) ? $id : 0;
         if ($id > 0) {
             $sql = "delete from `" . TABLE_PREFIX . "share` where `id` = '{$id}'";
             $this->DatabaseHandler->Query($sql);
             $file = ROOT_PATH . 'templates/default/share/sharetemp_' . $id . '.html';
             jio()->DeleteFile($file);
             jconf::set('sharetemp_' . $id, array());
             jio()->DeleteFile('./setting/sharetemp_' . $id . '.php');
         }
     }
     $this->Messager("删除成功", "admin.php?mod=share");
 }
Exemplo n.º 13
0
 function doVerify()
 {
     $act = $this->Get['act'];
     $uids = array();
     $uid = (int) $this->Get['uid'];
     $uids = $this->Post['uids'];
     if ($uid) {
         $uids[$uid] = $uid;
     }
     $msg = jget('msg');
     if ($act == 'yes') {
         if ($uids) {
             foreach ($uids as $uid) {
                 if ($uid < 1) {
                     continue;
                 }
                 $message = '';
                 $nickname = DB::result_first(" select `nickname` from `" . TABLE_PREFIX . "members` where `uid` = '{$uid}'");
                 $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "members_verify where `uid` = '{$uid}'");
                 $member_verify = $query->GetRow();
                 if ($member_verify) {
                     if ($member_verify['face'] || $member_verify['face_url']) {
                         $image_path = RELATIVE_ROOT_PATH . 'images/face/' . face_path($uid);
                         if (!is_dir($image_path)) {
                             jio()->MakeDir($image_path);
                         }
                         $image_file_b = $dst_file = $image_path . $uid . '_b.jpg';
                         $image_file_s = $dst_file = $image_path . $uid . '_s.jpg';
                         $image_verify_path = RELATIVE_ROOT_PATH . 'images/face_verify/' . face_path($uid);
                         $image_verify_file_b = $dst_file = $image_verify_path . $uid . '_b.jpg';
                         $image_verify_file_s = $dst_file = $image_verify_path . $uid . '_s.jpg';
                         if ($member_verify['face_url']) {
                             $ftp_key = getftpkey($member_verify['face_url']);
                             if ($ftp_key < 0) {
                                 $this->Messager('请检查FTP是否可用');
                             }
                             ftpcmd('get', $image_file_b, $image_verify_file_b, $ftp_key);
                             ftpcmd('get', $image_file_s, $image_verify_file_s, $ftp_key);
                             $ftp_result = ftpcmd('upload', $image_file_b, '', $ftp_key);
                             $ftp_result = ftpcmd('upload', $image_file_s, '', $ftp_key);
                             $sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file_s}', `face_url`='{$member_verify['face_url']}' where `uid`='" . $uid . "'";
                             $this->DatabaseHandler->Query($sql);
                         } else {
                             if ($member_verify['face']) {
                                 @copy($image_verify_file_b, $image_file_b);
                                 @copy($image_verify_file_s, $image_file_s);
                                 $sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file_s}' where `uid`='" . $uid . "'";
                                 $this->DatabaseHandler->Query($sql);
                             }
                         }
                         if ($this->Config['extcredits_enable'] && $member_verify['uid'] > 0) {
                             update_credits_by_action('face', $member_verify['uid']);
                         }
                         $message .= '你更新的头像已经通过审核,可以通过ctrl+f5强制刷新来查看新头像;';
                     }
                     if ($member_verify["signature"]) {
                         $sql = "update " . TABLE_PREFIX . "members set signature = '{$member_verify['signature']}',signtime = '" . time() . "' where uid = '{$uid}' ";
                         $this->DatabaseHandler->Query($sql);
                         $message .= '你更新的签名已经更过审核;';
                     }
                     $this->DatabaseHandler->Query("delete from " . TABLE_PREFIX . "members_verify where uid = '{$uid}'");
                     $pm_post = array('message' => $message, 'to_user' => $nickname);
                     jlogic('pm')->pmSend($pm_post);
                 }
             }
         }
     } else {
         if ($msg) {
             $to_user = DB::result_first("select `nickname` from `" . TABLE_PREFIX . "members` where `uid` = '{$uid}'");
             if ($to_user) {
                 $pm_post = array('message' => $msg, 'to_user' => $to_user);
                 jlogic('pm')->pmSend($pm_post);
             }
         }
         $this->DatabaseHandler->Query("delete from `" . TABLE_PREFIX . "members_verify` where `uid` = '{$uid}'");
     }
     $this->Messager("操作成功");
 }
Exemplo n.º 14
0
 function VipIntro()
 {
     if (MEMBER_ID < 1) {
         $this->Messager("请先<a href='index.php?mod=login'>点此登录</a>或者<a href='index.php?mod=member'>点此注册</a>一个帐号", 'index.php?mod=member&code-login', 3);
     }
     $member = jsg_member_info(MEMBER_ID);
     $notUpToStandardVipConditions = $this->CheckVipCpnditions();
     if (!$notUpToStandardVipConditions) {
         Load::logic('validate_category');
         $this->ValidateLogic = new ValidateLogic($this);
         $is_card_pic = $this->Config['card_pic_enable']['is_card_pic'];
         if ($this->Post['postFlag']) {
             $validate_info = $this->Post['validate_remark'];
             $validate_info = trim(strip_tags((string) $validate_info));
             if (empty($validate_info)) {
                 $this->Messager('认证说明不能为空', -1);
             }
             $f_rets = filter($validate_info);
             if ($f_rets && $f_rets['error']) {
                 $this->Messager($f_rets['msg'], -1);
             }
             $category_fid = $this->Post['category_fid'];
             $category_id = $this->Post['category_id'];
             if (empty($category_fid) || empty($category_id)) {
                 $this->Messager('认证类别不能为空', -1);
             }
             $city = (int) $this->Post['city'];
             if ($city < 1) {
                 $this->Messager('请填写所在区域', -1);
             }
             $validate_true_name = strip_tags(jpost('validate_true_name', 'txt'));
             if (empty($validate_true_name)) {
                 $this->Messager('真实姓名不能为空', -1);
             }
             $validate_card_type = jpost('validate_card_type', 'txt');
             if (empty($validate_card_type)) {
                 $this->Messager('证件类型不能为空', -1);
             }
             $validate_card_id = strip_tags(jpost('validate_card_id', 'txt'));
             if (empty($validate_card_id)) {
                 $this->Messager('证件号码不能为空', -1);
             }
             if ($is_card_pic) {
                 $field = 'card_pic';
                 if (empty($_FILES) || !$_FILES[$field]['name']) {
                     $this->Messager("请上传证件图片", -1);
                 }
             }
             $data = array('uid' => MEMBER_ID, 'category_fid' => (int) $this->Post['category_fid'], 'category_id' => (int) $this->Post['category_id'], 'province' => jpost('province', 'txt'), 'city' => jpost('city', 'txt'), 'is_audit' => 0, 'dateline' => TIMESTAMP);
             $return_info = $this->ValidateLogic->Member_Validate_Add($data);
             if ($return_info['ids']) {
                 if ($is_card_pic) {
                     $image_id = $return_info['ids'];
                     if (empty($_FILES) || !$_FILES[$field]['name']) {
                         $this->Messager("请上传证件图片", -1);
                     }
                     $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . $image_id . '/';
                     $image_name = $image_id . "_o.jpg";
                     $image_file = $image_path . $image_name;
                     $image_file_small = $image_path . $image_id . "_s.jpg";
                     if (!is_dir($image_path)) {
                         jio()->MakeDir($image_path);
                     }
                     jupload()->init($image_path, $field, true);
                     jupload()->setNewName($image_name);
                     $result = jupload()->doUpload();
                     if ($result) {
                         $result = is_image($image_file);
                     }
                     if (!$result) {
                         $this->Messager("上传图片失败", -1);
                     }
                     list($w, $h) = getimagesize($image_file);
                     if ($w > 601) {
                         $tow = 599;
                         $toh = round($tow * ($h / $w));
                         $result = makethumb($image_file, $image_file, $tow, $toh);
                         if (!$result) {
                             jio()->DeleteFile($image_file);
                             js_alert_output('大图片缩略失败');
                         }
                     }
                     $image_file = addslashes($image_file);
                     $validate_card_pic = " `validate_card_pic` = '{$image_file}' ,";
                 }
                 $sql = "update " . TABLE_PREFIX . "memberfields\r\n\t\t\t\t\t\tset {$validate_card_pic}\r\n\t\t\t\t\t\t\t`validate_remark` = '" . jpost('validate_remark', 'txt') . "' ,\r\n\t\t\t\t\t\t\t`validate_true_name`='" . jpost('validate_true_name', 'txt') . "' ,\r\n\t\t\t\t\t\t\t`validate_card_id` = '" . jpost('validate_card_id', 'txt') . "' ,\r\n\t\t\t\t\t\t\t`validate_card_type` = '" . jpost('validate_card_type', 'txt') . "'\r\n\t\t\t\t\t\twhere `uid`='" . MEMBER_ID . "'";
                 $this->DatabaseHandler->Query($sql);
                 if ($notice_to_admin = $this->Config['notice_to_admin']) {
                     $message = "用户" . MEMBER_NICKNAME . "申请了身份认证,<a href='admin.php?mod=vipintro&code=vipintro_manage' target='_blank'>点击</a>进入审核。";
                     $pm_post = array('message' => $message, 'to_user' => str_replace('|', ',', $notice_to_admin));
                     $admin_info = DB::fetch_first('select `uid`,`username`,`nickname` from `' . TABLE_PREFIX . 'members` where `uid` = 1');
                     load::logic('pm');
                     $PmLogic = new PmLogic();
                     $PmLogic->pmSend($pm_post, $admin_info['uid'], $admin_info['username'], $admin_info['nickname']);
                 }
             }
             if ($return_info['msg_info']) {
                 $this->Messager($return_info['msg_info']);
             }
         }
         $sql = "select * from `" . TABLE_PREFIX . "validate_category_fields` where `uid`='" . MEMBER_ID . "' ";
         $query = $this->DatabaseHandler->Query($sql);
         $validate_info = $query->GetRow();
         $sql = "select * from `" . TABLE_PREFIX . "memberfields` where `uid`='" . MEMBER_ID . "'";
         $query = $this->DatabaseHandler->Query($sql);
         $memberfields = $query->GetRow();
         $memberfields['validate_card_type'] = $memberfields['validate_card_type'] ? $memberfields['validate_card_type'] : '未知';
         $dateline = date('Y-m-d', $validate_info['dateline']);
         if (empty($validate_info['uid']) || $validate_info['is_audit'] == -1) {
             if (!$memberfields) {
                 $memberfields = array();
                 $memberfields['uid'] = $member['uid'];
                 $sql = "insert into `" . TABLE_PREFIX . "memberfields` (`uid`) values ('{$member['uid']}')";
                 $this->DatabaseHandler->Query($sql);
             }
             $_options = array('0' => array('name' => '请选择', 'value' => '0'), '身份证' => array('name' => '身份证', 'value' => '身份证'), '学生证' => array('name' => '学生证', 'value' => '学生证'), '军官证' => array('name' => '军官证', 'value' => '军官证'), '护照' => array('name' => '护照', 'value' => '护照'), '营业执照' => array('name' => '营业执照', 'value' => '营业执照'), '官方公函' => array('name' => '官方公函', 'value' => '官方公函'), '其他' => array('name' => '其他', 'value' => '其他'));
             $select_value = $memberfields['validate_card_type'] ? $memberfields['validate_card_type'] : "身份证";
             $validate_card_type_select = jform()->Select('validate_card_type', $_options, $select_value);
             $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "common_district where `upid` = '0' order by list");
             while ($rsdb = $query->GetRow()) {
                 $province[$rsdb['id']]['value'] = $rsdb['id'];
                 $province[$rsdb['id']]['name'] = $rsdb['name'];
                 if ($member['province'] == $rsdb['name']) {
                     $province_id = $rsdb['id'];
                 }
             }
             $province_list = jform()->Select("province", $province, $province_id, "onchange=\"changeProvince();\"");
             $member_city = DB::fetch_first("SELECT * FROM " . DB::table('common_district') . " WHERE `name`='{$member['city']}'");
         }
         $where_list = " `category_id` = '' ";
         $query = DB::query("SELECT *\r\n\t\t\t\t\t\t\tFROM " . DB::table('validate_category') . "\r\n\t\t\t\t\t\t\twhere {$where_list}  ORDER BY id ASC");
         $category_list = array();
         while ($value = DB::fetch($query)) {
             $category_list[] = $value;
         }
         if ($this->Post['category_fid']) {
             $sub_category_list = $this->ValidateLogic->Small_CategoryList($this->Post['category_fid']);
         }
     }
     $this->Title = "{$this->Config['site_name']}身份验证";
     include template('other/topic_vip');
 }
Exemplo n.º 15
0
 function upload_pic($id)
 {
     $image_name = $id . ".png";
     $image_path = RELATIVE_ROOT_PATH . 'images/channel/' . face_path($id);
     $image_file = $image_path . $image_name;
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     jupload()->init($image_path, 'image', true);
     jupload()->setMaxSize(1000);
     jupload()->setNewName($image_name);
     $result = jupload()->doUpload();
     if ($result) {
         $result = is_image($image_file);
     }
     if (!$result) {
         unlink($image_file);
         return false;
     } else {
         if ($GLOBALS['_J']['config']['ftp_on']) {
             $ftp_key = randgetftp();
             $get_ftps = jconf::get('ftp');
             $site_url = $get_ftps[$ftp_key]['attachurl'];
             $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
             if ($ftp_result > 0) {
                 jio()->DeleteFile($image_file);
                 $image_file = $site_url . '/' . str_replace('./', '', $image_file);
             }
         }
         DB::update('channel', array('picture' => $image_file), array('ch_id' => $id));
     }
     return true;
 }
Exemplo n.º 16
0
 function Disallow()
 {
     $name = trim($this->Get['name']);
     $disallow = 'disallow1' == $this->Code ? 1 : 0;
     $sql = "update `" . TABLE_PREFIX . "robot` set `disallow`='{$disallow}' where `name`='{$name}'";
     $this->DatabaseHandler->Query($sql);
     $sql = "select `name`,`disallow` from `" . TABLE_PREFIX . "robot` where `disallow`=1";
     $query = $this->DatabaseHandler->Query($sql);
     $robot_config = jconf::get('robot');
     $robot_config['list'] = array();
     while (false != ($row = $query->GetRow())) {
         $robot_config['list'][$row['name']]['disallow'] = $row['disallow'];
     }
     jconf::set('robot', $robot_config);
     $disallow_string = "User-agent: {$name}\r\nDisallow: /\r\n\r\n";
     $robots_path = ROOT_PATH . 'robots.txt';
     $robots_string_new = $robots_string = jio()->ReadFile($robots_path);
     $disallow_string_strpos = strpos($robots_string, $disallow_string);
     if ($disallow && false === $disallow_string_strpos) {
         $robots_string_new = $disallow_string . $robots_string_new;
     } elseif (!$disallow && false !== $disallow_string_strpos) {
         $robots_string_new = str_replace($disallow_string, "", $robots_string_new);
     }
     if ($robots_string_new != $robots_string) {
         $return = jio()->WriteFile($robots_path, $robots_string_new);
         if (!$return) {
             $this->Messager("写入 <b>{$robots_path}</b> 文件失败,请检查是否有可读写的权限", null);
         }
     }
     $this->Messager("修改成功");
 }
Exemplo n.º 17
0
 public function cutProfile()
 {
     $w = (int) $this->Post['w'];
     $h = (int) $this->Post['h'];
     $x = (int) $this->Post['x'];
     $y = (int) $this->Post['y'];
     $image_path = RELATIVE_ROOT_PATH . 'images/temp/profile/' . face_path(MEMBER_ID);
     $image_name = MEMBER_ID . "_o.jpg";
     $image_file = $image_path . $image_name;
     if (!$image_file) {
         if ($this->Get['home']) {
             echo '<script>parent.show_message("剪切错误!请重新上传图片");parent.closeDialog("showuploadform");</script>';
             exit;
         } else {
             $this->Messager("剪切错误!请重新上传图片");
         }
     }
     $member = $this->_member();
     $image_thumb_file = RELATIVE_ROOT_PATH . 'images/profile/' . face_path($member['uid']) . "_o.jpg";
     if (!is_dir($image_thumb_dir = dirname($image_thumb_file))) {
         jmkdir($image_thumb_dir);
     }
     list($w_src, $h_src) = getimagesize($image_file);
     if (!$w_src) {
         if ($this->Get['home']) {
             echo '<script>parent.show_message("剪切图片已不存在!");parent.closeDialog("showuploadform");</script>';
             exit;
         } else {
             $this->Messager("剪切图片已不存在", jurl('index.php?mod=settings&code=profile'));
         }
     }
     if (!$w || !$h) {
         if ($w_src < 750) {
             $w = $w_src;
             $h = (int) ($w * (5 / 16));
         } else {
             $w = 750;
             $h = (int) ($w * (5 / 16));
         }
     }
     if ($w_src > 750) {
         $bili = $w_src / 750;
         round($w * $bili);
         $result = makethumb($image_file, $image_thumb_file, round($w * $bili), round($h * $bili), 0, 0, round($x * $bili), round($y * $bili), round($w * $bili), round($h * $bili));
         if ($result) {
             jio()->DeleteFile($image_file);
         }
     } else {
         $result = makethumb($image_file, $image_thumb_file, $w, $h, 0, 0, $x, $y, $w, $h);
         if ($result) {
             jio()->DeleteFile($image_file);
         }
     }
     if ($this->Config['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $image_thumb_file, '', $ftp_key);
         if ($ftp_result > 0) {
             jio()->DeleteFile($image_thumb_file);
             $image_thumb_file = $site_url . '/' . str_replace('./', '', $image_thumb_file);
         }
     }
     if ($result) {
         $sql = "update `" . TABLE_PREFIX . "members` set profile_image='" . $image_thumb_file . "' where `uid`='" . MEMBER_ID . "'";
         $this->DatabaseHandler->Query($sql);
         if ($this->Get['home']) {
             echo '<script>parent.show_message("已保存!");parent.location.replace(parent.location.href);parent.closeDialog("showuploadform");</script>';
             exit;
         } else {
             $this->Messager("已保存", jurl('index.php?mod=settings&code=profile'));
         }
     } else {
         if ($this->Get['home']) {
             echo '<script>parent.show_message("保存失败!");parent.closeDialog("showuploadform");</script>';
             exit;
         } else {
             $this->Messager("保存失败", jurl('index.php?mod=settings&code=profile'));
         }
     }
 }
Exemplo n.º 18
0
 function upload_pic($id)
 {
     $image_name = $id . ".png";
     $image_path = RELATIVE_ROOT_PATH . 'images/talk/' . face_path($id);
     $image_file = $image_path . $image_name;
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     jupload()->init($image_path, 'image', true);
     jupload()->setMaxSize(1000);
     jupload()->setNewName($image_name);
     $result = jupload()->doUpload();
     if ($result) {
         $result = is_image($image_file);
     }
     if (!$result) {
         unlink($image_file);
         return false;
     } else {
         DB::update('talk', array('image' => $image_file), array('lid' => $id));
     }
     return true;
 }
Exemplo n.º 19
0
 public function modify_left_icon()
 {
     $key = $this->Get['key'];
     $group = $this->Get['group'];
     $name = $this->Get['name'];
     $file = $key;
     $slide = $this->Post['slide'];
     if ($_FILES[$file]['name']) {
         $image_name = dir_safe($key) . ".jpg";
         $image_path = RELATIVE_ROOT_PATH . 'images/lefticon/';
         $image_file = $image_path . $image_name;
         if (!is_dir($image_path)) {
             jio()->MakeDir($image_path);
         }
         jupload()->init($image_path, $file, true);
         jupload()->setMaxSize(512);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file);
         }
         if (!$result) {
             $this->_js_output('alert("图片上传失败");');
         }
         image_thumb($image_file, $image_file, 100, 100);
         if ($this->Config['ftp_on']) {
             $ftp_key = randgetftp();
             $get_ftps = jconf::get('ftp');
             $site_url = $get_ftps[$ftp_key]['attachurl'];
             $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
             if ($ftp_result > 0) {
                 jio()->DeleteFile($image_file);
                 $image_file = $site_url . '/' . str_replace('./', '', $image_file);
             }
         }
     } else {
         echo "<script type='text/javascript'>";
         echo "alert('没有图片');";
         echo "</script>";
         exit;
     }
     $slide_config = jconf::get('left_navigation');
     foreach ($slide_config[$group] as &$v) {
         if ($v['code'] == $name) {
             $v['icon'] = $image_file;
         }
     }
     jconf::set('left_navigation', $slide_config);
     echo "<script type='text/javascript'>";
     echo "parent.document.getElementById('show_image_{$key}').src='{$image_file}';";
     echo "parent.document.getElementById('show_image_{$key}').style.display='block';";
     echo "parent.document.getElementById('show_image_{$key}_value').value='{$image_file}';";
     echo "parent.document.location.reload();";
     echo "</script>";
     exit;
 }
Exemplo n.º 20
0
 function Upload()
 {
     $image_id = 0;
     $field = 'topic';
     if (empty($_FILES) || !$_FILES[$field]['name']) {
         return 0;
     } else {
         $timestamp = time();
         $uid = $this->Post['touid'] ? $this->Post['touid'] : MEMBER_ID;
         $username = $this->Post['tousername'] ? $this->Post['tousername'] : MEMBER_NAME;
         $image_id = jlogic('image')->add($uid, $username);
         if ($image_id < 1) {
             return 0;
         }
         $sub_path = './images/' . $field . '/' . face_path($image_id);
         $image_path = RELATIVE_ROOT_PATH . $sub_path;
         $image_path_abs = ROOT_PATH . $sub_path;
         $image_path2 = './images/' . $field . '/' . face_path($image_id);
         $image_name = $image_id . "_o.jpg";
         $image_file = $image_path . $image_name;
         $image_file_abs = $image_path_abs . $image_name;
         $image_file2 = $image_path2 . $image_name;
         $image_file_small = $image_path . $image_id . "_s.jpg";
         $image_file_small_abs = $image_path_abs . $image_id . "_s.jpg";
         if (!is_dir($image_path_abs)) {
             jio()->MakeDir($image_path_abs);
         }
         jupload()->init($image_path_abs, $field, true);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file_abs);
         }
         if (false == $result) {
             jio()->DeleteFile($image_file_abs);
             jlogic('image')->delete($image_id);
             $error_msg = implode(" ", (array) jupload()->getError());
         } else {
             $this->_removeTopicImage($image_id);
             list($image_width, $image_height, $image_type, $image_attr) = getimagesize($image_file_abs);
             $result = makethumb($image_file_abs, $image_file_small_abs, min($this->Config['thumbwidth'], $image_width), min($this->Config['thumbwidth'], $image_height), $this->Config['maxthumbwidth'], $this->Config['maxthumbheight']);
             if (!$result && !is_file($image_file_small_abs)) {
                 @copy($image_file_abs, $image_file_small_abs);
             }
             if ($this->Config['watermark_enable']) {
                 jlogic('image')->watermark($image_file_abs);
             }
             $image_size = filesize($image_file_abs);
             $name = addslashes($_FILES[$field]['name']);
             $site_url = '';
             if ($this->Config['ftp_on']) {
                 $ftp_key = randgetftp();
                 $get_ftps = jconf::get('ftp');
                 $site_url = $get_ftps[$ftp_key]['attachurl'];
                 $ftp_result = ftpcmd('upload', $image_file_abs, '', $ftp_key);
                 if ($ftp_result > 0) {
                     ftpcmd('upload', $image_file_small_abs, '', $ftp_key);
                     jio()->DeleteFile($image_file_abs);
                     jio()->DeleteFile($image_file_small_abs);
                     $image_file_small = $site_url . '/' . $image_file_small;
                 }
             }
             jlogic('image')->modify(array('id' => $image_id, 'site_url' => $site_url, 'photo' => $image_file2, 'name' => $name, 'filesize' => $image_size, 'width' => $image_width, 'height' => $image_height));
         }
     }
     return $image_id;
 }
Exemplo n.º 21
0
 function DoEditTheme()
 {
     $id = $this->Post['id'];
     if (!$id) {
         $this->Messager("主题不存在", "admin.php?mod=show&code=modify_theme");
     }
     $theme_arr = jconf::get('theme');
     $theme_arr['theme_list'][$id]['theme_bg_color'] = $this->Post['theme_bg_color'] ? $this->Post['theme_bg_color'] : "#2F97CA";
     $theme_arr['theme_list'][$id]['theme_link_color'] = $this->Post['theme_link_color'] ? $this->Post['theme_link_color'] : "#0073B2";
     $theme_arr['theme_list'][$id]['theme_text_color'] = $this->Post['theme_text_color'] ? $this->Post['theme_text_color'] : "#333333";
     $theme_arr['theme_list'][$id]['theme_bg_image_type'] = $this->Post['theme_bg_image_type'] ? $this->Post['theme_bg_image_type'] : "center";
     jconf::set('theme', $theme_arr);
     $config = array();
     if ($this->Post['set_system_theme'] == 1) {
         $config['theme_bg_color'] = $this->Post['theme_bg_color'] ? $this->Post['theme_bg_color'] : '#2F97CA';
         $config['theme_bg_image_type'] = $this->Post['theme_bg_image_type'] ? $this->Post['theme_bg_image_type'] : 'center';
         $config['theme_id'] = $id;
         $config['theme_link_color'] = $this->Post['theme_link_color'] ? $this->Post['theme_link_color'] : '#0073B2';
         $config['theme_text_color'] = $this->Post['theme_text_color'] ? $this->Post['theme_text_color'] : '#333333';
         jconf::update($config);
     }
     if ($_FILES['changePic']['name']) {
         $type = trim(strtolower(end(explode(".", $_FILES['changePic']['name']))));
         $themebg = "themebg";
         $image_name = $themebg . ".jpg";
         $image_path = RELATIVE_ROOT_PATH . './theme/' . $id . '/images/';
         $image_file = $image_path . $image_name;
         if (!is_dir($image_path)) {
             jio()->MakeDir($image_path);
         }
         jupload()->init($image_path, 'changePic', true);
         jupload()->setMaxSize(5120);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         $themebg_preview = "themebg_preview";
         $themebg_preview_name = $themebg_preview . ".jpg";
         $themebg_preview_path = RELATIVE_ROOT_PATH . './theme/' . $id . "/";
         $image_file_min = $themebg_preview_path . $themebg_preview_name;
         image_thumb($image_file, $image_file_min, 76, 76);
         if ($result) {
             $result = is_image($image_file);
         }
         if (!$result) {
             unlink($image_file);
             unlink($image_file_min);
             $this->Messager("上传失败", -1);
         }
     }
     $this->Messager("设置成功", "admin.php?mod=show&code=modify_theme");
 }
Exemplo n.º 22
0
 function DoModify()
 {
     $medal_id = jget('medal_id', 'int');
     $sql = "SELECT * FROM " . TABLE_PREFIX . 'medal' . " WHERE id='{$medal_id}'";
     $query = $this->DatabaseHandler->Query($sql);
     $medal_info = $query->GetRow();
     $error_msg = '';
     $field = 'medal';
     $datetime = time();
     $medal_name = $this->Post['medal_name'];
     $medal_depict = $this->Post['medal_depict'];
     $checkvalue = array('type' => $this->Post['type'], 'day' => $this->Post['day'], 'endday' => $this->Post['endday'], 'tagname' => $this->Post['tagname'], 'invite' => $this->Post['invite'], 'fans' => $this->Post['fans'], 'sign' => $this->Post['sign']);
     $checkvalue = serialize($checkvalue);
     $medal_name = $this->Post['medal_name'];
     $medal_depict = $this->Post['medal_depict'];
     if (empty($_FILES) || !$_FILES[$field]['name']) {
         $image_file = $medal_info['medal_img'];
         $image_file_small = $medal_info['medal_img2'];
     } else {
         jio()->DeleteFile($medal_info['medal_img']);
         jio()->DeleteFile($medal_info['medal_img2']);
         $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . $datetime . '/';
         $image_name = $medal_info['id'] . "_o.jpg";
         $image_file = $image_path . $image_name;
         $image_file_small = $image_path . $medal_info['id'] . "_s.jpg";
         if (!is_dir($image_path)) {
             jio()->MakeDir($image_path);
         }
         jupload()->init($image_path, $field, true);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file);
         }
         if (!$result) {
             $this->Messager("上传图片失败", "admin.php?mod=medal");
         }
         makethumb($image_file, $image_file_small, 60, 60, 0, 0, 0, 0, 0, 0);
         image_thumb($image_file, $image_file, 60, 60);
         image_thumb($image_file_small, $image_file_small, 60, 60);
         $image_file = addslashes($image_file);
         $image_file_small = addslashes($image_file_small);
         $img = grayJpeg($image_file_small);
         imagejpeg($img, $image_file_small, 100);
         imagedestroy($img);
     }
     $sql = "update `" . TABLE_PREFIX . "medal` set  `medal_img`='{$image_file}' ,`medal_img2` = '{$image_file_small}', `medal_name`='{$medal_name}' ,`medal_depict` = '{$medal_depict}' , `conditions` = '{$checkvalue}'   where `id`='" . (int) $this->Post['medal_id'] . "'";
     $this->DatabaseHandler->Query($sql);
     if ($error_msg) {
         $this->Messager($error_msg);
     }
     $this->Messager("编辑成功", 'admin.php?mod=medal');
 }
Exemplo n.º 23
0
 function DoModify()
 {
     $id = (int) get_param('id');
     $info = DB::fetch_first("select * from " . DB::table('output') . " where `id`='{$id}'");
     if (!$info) {
         $this->Messager('您要编辑的内容已经不存在了');
     }
     $data = get_param('data');
     $data['name'] = trim($data['name']);
     $data['lock_host'] = trim(strtolower($data['lock_host']));
     $data['content_default'] = strip_tags($data['content_default']);
     $data['type_first'] = $data['type_first'] ? 1 : 0;
     $data['per_page_num'] = max(0, (int) $data['per_page_num']);
     $data['width'] = $data['width'] ? $data['width'] : '100%';
     $data['height'] = $data['height'] ? $data['height'] : '1000px';
     $data['tpl_enable'] = $data['tpl_enable'] ? 1 : 0;
     if ($data['tpl_enable'] && true === JISHIGOU_FOUNDER) {
         $data['tpl_file'] = $data['tpl_file'] && false !== strpos($data['tpl_file'], 'output/') ? dir_safe(str_replace(array('.html', '.htm'), '', $data['tpl_file'])) : 'output/output_' . $id;
         $data['tpl_data'] = trim($data['tpl_data']);
         if ($data['tpl_enable']) {
             $tpl_file = ROOT_PATH . 'templates/default/' . $data['tpl_file'] . '.html';
             jio()->MakeDir(dirname($tpl_file));
             jio()->WriteFile($tpl_file, jstripslashes($data['tpl_data']));
         }
     } else {
         unset($data['tpl_file']);
     }
     unset($data['tpl_data']);
     DB::update('output', $data, array('id' => $id));
     $this->Messager('修改成功');
 }
Exemplo n.º 24
0
 function ModAttach()
 {
     if ($this->MemberHandler->HasPermission($this->Module, 'attach') == false) {
         $this->_mod_attach_error('您没有上传文件的权限,无法继续操作!');
     }
     $id = max(0, (int) $this->Post['id']);
     if ($id < 1) {
         $this->_mod_attach_error('附件ID 错误');
     }
     $attach_info = $this->AttachLogic->get_info($id);
     if (!$attach_info) {
         $this->_mod_attach_error('您要更新的附件已经不存在了');
     }
     if (MEMBER_ROLE_TYPE != 'admin') {
         if (MEMBER_ID != $attach_info['uid']) {
             $this->_mod_attach_error('您没有权限更新该附件');
         }
     }
     if (empty($_FILES) || !$_FILES['mafile']['name']) {
         $this->_mod_attach_error('没有文件上传');
     }
     $attach_size = min(is_numeric($this->Config['attach_size_limit']) ? $this->Config['attach_size_limit'] : 1024, 51200);
     $attach_path = str_replace($id . '.' . $attach_info['filetype'], '', $attach_info['file']);
     $attach_type = strtolower(end(explode('.', $_FILES['mafile']['name'])));
     $attach_name = $id . '.' . $attach_type;
     $attach_file = $attach_path . $attach_name;
     if (!is_dir($attach_path)) {
         jio()->MakeDir($attach_path);
     }
     jupload()->init($attach_path, 'mafile', false, true);
     jupload()->setMaxSize($attach_size);
     jupload()->setNewName($attach_name);
     $ret = jupload()->doUpload();
     if ($ret) {
         $ret = true;
     }
     if (!$ret) {
         jio()->DeleteFile($attach_file);
         $rets = jupload()->getError();
         $ret = $rets ? implode(" ", (array) $rets) : 'attach file is invalid';
         $this->_mod_attach_error($ret);
     }
     $site_url = '';
     if ($this->Config['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $attach_file, '', $ftp_key);
         if ($ftp_result > 0) {
             jio()->DeleteFile($attach_file);
         }
     }
     $attach_size = filesize($attach_file);
     $name = addslashes($_FILES['mafile']['name']);
     $p = array('id' => $id, 'site_url' => $site_url, 'file' => $attach_file, 'name' => $name, 'filetype' => $attach_type, 'filesize' => $attach_size);
     $this->AttachLogic->modify($p);
     $retval = array('src' => 'images/filetype/' . $attach_type . '.gif', 'name' => $name, 'size' => $attach_size > 1024 * 1024 ? round($attach_size / (1024 * 1024), 2) . 'MB' : ($attach_size == 0 ? '未知' : round($attach_size / 1024, 1) . 'KB'));
     echo "<script type='text/javascript'>window.parent.aupcomplete({$id},'{$retval['src']}','{$retval['name']}','{$retval['size']}');</script>";
 }
Exemplo n.º 25
0
 function _writeHtaccess($abs_path)
 {
     $un_writes = array();
     $is_local = preg_match("~^localhost|127\\.0\\.0\\.1|192\\.168\\.\\d+\\.\\d+\$~", $_SERVER['SERVER_ADDR']);
     $str = "# BEGIN JishiGou\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\n" . ($is_local ? "Options FollowSymLinks" : "") . "\r\nRewriteBase {$abs_path}\r\nRewriteCond %{REQUEST_URI}\t!\\.(gif|jpeg|png|jpg|bmp)\$\r\nRewriteCond %{REQUEST_URI}  !^{$abs_path}(wap|mobile)\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . index.php [L]\r\n</IfModule>\r\n# END JishiGou";
     @($len = jio()->WriteFile(ROOT_PATH . ".htaccess", $str));
     if (!$len) {
         $un_writes[] = '.htaccess';
     }
     $_dirs = array('images/', 'templates/', 'theme/', 'wap/templates/');
     foreach ($_dirs as $_dir) {
         $_path = ROOT_PATH . $_dir;
         if (!is_dir($_path)) {
             jmkdir($_path);
         } else {
             if (!file_exists($_path . 'index.html')) {
                 @touch($_path . 'index.html');
             }
         }
         $str = "# BEGIN JishiGou dir safe protect for {$_dir}\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\n" . ($is_local ? "Options FollowSymLinks" : "") . "\r\nRewriteBase {$abs_path}{$_dir}\r\nRewriteRule ^.*\\.(php|php3|php4|asp|aspx|jsp|cgi)\$ index.html [NC,L]\r\n</IfModule>\r\n# END JishiGou " . date("Y-m-d H:i:s");
         @($len = jio()->WriteFile($_path . '.htaccess', $str));
         if (!$len) {
             $un_writes[] = "{$_dir}.htaccess";
         }
     }
     $_dirs = array('api/pw_api/', 'api/pw_client/', 'include/', 'install/', 'modules/', 'setting/', 'wap/data/', 'wap/include/', 'wap/modules/');
     foreach ($_dirs as $_dir) {
         $_path = ROOT_PATH . $_dir;
         if (!is_dir($_path)) {
             jmkdir($_path);
         } else {
             if (!file_exists($_path . 'index.html')) {
                 @touch($_path . 'index.html');
             }
         }
         $str = "# BEGIN JishiGou dir safe protect for {$_dir}\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\n" . ($is_local ? "Options FollowSymLinks" : "") . "\r\nRewriteBase {$abs_path}{$_dir}\r\nRewriteRule . index.html [L]\r\n</IfModule>\r\n# END JishiGou " . date("Y-m-d H:i:s");
         @($len = jio()->WriteFile($_path . '.htaccess', $str));
         if (!$len) {
             $un_writes[] = "{$_dir}.htaccess";
         }
     }
     if ($un_writes) {
         $this->Messager("以下文件无法写入,请检查相应的目录是否有可写权限。<br /><br />" . implode("<br />", $un_writes), null);
     }
 }
Exemplo n.º 26
0
 function getOtherStatistics()
 {
     $other_list = array('member' => array('name' => '<b>会员总数</b>', 'table' => 'members', 'url' => 'admin.php?mod=member&code=newm'), 'sessions' => array('name' => '<b>在线人数</b>', 'table' => 'sessions', 'url' => 'admin.php?mod=sessions'), 'tag' => array('name' => '<b>话题数量</b>', 'table' => 'tag', 'url' => 'admin.php?mod=tag&code=list'), 'attach' => array('name' => '<b>附件大小</b>', 'table' => 'topic_attach', 'code' => 'filesize'), 'image' => array('name' => '<b>图片大小</b>', 'table' => 'topic_image', 'code' => 'filesize'), 'database' => array('name' => '<b>数据库大小</b>', 'database' => 1, 'url' => 'admin.php?mod=db&code=optimize', 'title' => "点击优化"));
     $cache_id = 'misc/other_statistics';
     if (false === ($other_list_r = cache_file('get', $cache_id))) {
         $other_list_r['data'] = $other_list;
         foreach ($other_list as $k => $v) {
             if ($v['table'] && !$v['code']) {
                 $other_list_r['data'][$k]['num'] = DB::result_first("  select count(*) from `" . TABLE_PREFIX . "{$v['table']}` ");
             } else {
                 if ($v['table'] && $v['code']) {
                     $other_list_r['data'][$k]['num'] = DB::result_first("  select sum(`{$v['code']}`) from `" . TABLE_PREFIX . "{$v['table']}` ");
                     $other_list_r['data'][$k]['num'] = jio()->SizeConvert($other_list_r['data'][$k]['num']);
                 } else {
                     if ($v['database']) {
                         $cache_id1 = "misc/data_length";
                         if (false === ($data_length = cache_file('get', $cache_id1))) {
                             $sys_config = jconf::get();
                             $sql = "show table status from `{$sys_config['db_name']}` like '" . TABLE_PREFIX . "%'";
                             $query = DB::query($sql, "SKIP_ERROR");
                             $data_length = 0;
                             while ($row = DB::fetch($query)) {
                                 $data_length += $row['Data_length'] + $row['Index_length'];
                             }
                             if ($data_length > 0) {
                                 $data_length = jio()->SizeConvert($data_length);
                             }
                             cache_file('set', $cache_id1, $data_length, 3600);
                         }
                         $other_list_r['data'][$k]['num'] = $data_length;
                     }
                 }
             }
             if ($v['title']) {
                 $title = "title='{$v['title']}'";
             }
             if ($v['url']) {
                 $other_list_r['data'][$k]['num'] = "<a href='{$v['url']}' {$title}>" . $other_list_r['data'][$k]['num'] . "</a>";
             }
         }
         $other_list_r['time'] = time();
         cache_file('set', $cache_id, $other_list_r, 3600);
     }
     return $other_list_r;
 }
Exemplo n.º 27
0
 function _parse_url_attach($data, $attach_url)
 {
     $__is_attach = false;
     $uid = $data['uid'];
     $username = $data['username'];
     $attach_id = jlogic('attach')->add($uid, $username);
     $p = array('id' => $attach_id, 'tid' => $data['tid'], 'file_url' => $attach_url);
     jlogic('attach')->modify($p);
     $attach_path = RELATIVE_ROOT_PATH . 'data/attachs/topic/' . face_path($attach_id) . '/';
     $attach_type = strtolower(end(explode('.', $attach_url)));
     $attach_name = $attach_id . '.' . $attach_type;
     $attach_file = $attach_path . $attach_name;
     if (!is_file($attach_file)) {
         if (!is_dir($attach_path)) {
             jio()->MakeDir($attach_path);
         }
         if (($temp_attach = dfopen($attach_url)) && jio()->WriteFile($attach_file, $temp_attach) && is_attach($attach_file)) {
             $attach_size = filesize($attach_file);
             $site_url = '';
             if ($GLOBALS['_J']['config']['ftp_on']) {
                 $ftp_key = randgetftp();
                 $get_ftps = jconf::get('ftp');
                 $site_url = $get_ftps[$ftp_key]['attachurl'];
                 $ftp_result = ftpcmd('upload', $attach_file, '', $ftp_key);
             }
             $p = array('id' => $attach_id, 'vtid' => $data['id'], 'site_url' => $site_url, 'file' => $attach_file, 'name' => basename($attach_url), 'filesize' => $attach_size, 'filetype' => $attach_type);
             jlogic('attach')->modify($p);
             $__is_attach = true;
         }
     }
     if (false === $__is_attach && $attach_id > 0) {
         jlogic('attach')->delete($attach_id);
         $attach_id = 0;
     }
     return $attach_id;
 }
Exemplo n.º 28
0
 function upload_icon($upload_data)
 {
     extract($upload_data);
     $u_setting = $this->upload_setting();
     $allow_exts = $u_setting['allow_exts'];
     $max_size = $u_setting['img_size'];
     $type = trim(strtolower(end(explode(".", $_FILES[$field]['name']))));
     if (!in_array($type, $allow_exts)) {
         return -1;
     }
     $image_name = substr(md5($_FILES[$field]['name']), -10) . ".{$type}";
     $image_path = $this->qun_avatar_path($upload_data['qid']);
     if (empty($image_path)) {
         return;
     }
     $image_file = $image_path . $image_name;
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     jupload()->init($image_path, $field, true);
     jupload()->setMaxSize($max_size);
     jupload()->setNewName($image_name);
     $result = jupload()->doUpload();
     if ($result) {
         $result = is_image($image_file);
     }
     if (!$result) {
         jio()->DeleteFile($image_file);
         return -2;
     }
     list($w, $h) = getimagesize($image_file);
     $dst_file = $image_path . $upload_data['qid'] . '_b.jpg';
     if (file_exists($dst_file)) {
         unlink($dst_file);
     }
     $make_result = image_thumb($image_file, $dst_file, 80, 80, 2);
     $lst_file = $image_path . $upload_data['qid'] . '_s.jpg';
     if (file_exists($lst_file)) {
         unlink($lst_file);
     }
     $make_result = image_thumb($image_file, $lst_file, 50, 50, 2);
     unlink($image_file);
     if ($GLOBALS['_J']['config']['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $lst_file, '', $ftp_key);
         if ($ftp_result > 0) {
             $ftp_result = ftpcmd('upload', $dst_file, '', $ftp_key);
             jio()->DeleteFile($lst_file);
             jio()->DeleteFile($dst_file);
             $lst_file = $site_url . '/' . str_replace('./', '', $lst_file);
         }
     }
     if (!empty($upload_data['qid'])) {
         DB::query("UPDATE " . DB::table('qun') . " SET icon='{$lst_file}' WHERE qid='{$upload_data['qid']}'");
     }
     return 1;
 }
Exemplo n.º 29
0
$t_result = array();
if ($totid < 1) {
    //视频、音乐待添加
    $imageid = (int) $imageid;
    //取出第一个图片ID
    if ($imageid > 0 && ($topic_image = jlogic('image')->get_info($imageid))) {
        $tpic = topic_image($imageid, 'original', 1);
        if ($GLOBALS['_J']['config']['ftp_on']) {
            $tpic = RELATIVE_ROOT_PATH . 'data/cache/temp_images/topic/' . $tpic;
            if (!is_file($tpic)) {
                $ppic = topic_image($imageid, 'original', 0);
                if (false !== strpos($ppic, ':/' . '/')) {
                    $temp_image = dfopen($ppic, 99999999, '', '', true, 3, $_SERVER['HTTP_USER_AGENT']);
                    if (!$temp_image) {
                        jio()->MakeDir(dirname($tpic));
                        jio()->WriteFile($tpic, $temp_image);
                    }
                }
            }
        }
        if (is_file($tpic) && ($ps = getimagesize($tpic) && ($p_data = file_get_contents($tpic)))) {
            $p_name = basename($topic_image['name'] ? $topic_image['name'] : $tpic);
            if (!$p_name) {
                $p_name = mt_rand();
            }
            $p_name = array_iconv($GLOBALS['_J']['config']['charset'], 'UTF-8', $p_name);
            $pic = array($ps['mime'], $p_name, $p_data);
            $t_result = $QQAuth->tAddPic($content, $pic);
        } else {
            $t_result = $QQAuth->tAdd($content);
        }
Exemplo n.º 30
-1
 function _qmd_img_list($pic_path = '', $user_uid = 0, $user_face = '', $topic_content = '', $topic_dateline)
 {
     header("Content-type: image/png");
     $bg = imagecreatefromjpeg($pic_path);
     $white = imagecolorallocate($bg, 00, 00, 00);
     $content = str_split($topic_content, 40);
     $content = array_iconv($this->Config['charset'], 'utf-8', $content);
     $topic_url = $this->Config['site_url'];
     $topic_date = array_iconv($this->Config['charset'], 'utf-8', $topic_dateline . ' | ' . '记事狗微博');
     imagettftext($bg, 9, 0, 130, 25, $white, "images/simsun.ttc", $content[0]);
     imagettftext($bg, 9, 0, 130, 45, $white, "images/simsun.ttc", $content[1]);
     imagettftext($bg, 9, 0, 130, 70, $white, "images/simsun.ttc", $topic_date);
     imagettftext($bg, 9, 0, 218, 90, $white, "images/simsun.ttc", $topic_url);
     $dst_im = imagecreatefromjpeg($bg);
     $dst_info = getimagesize($bg);
     $src = $user_face;
     $src_im = imagecreatefromjpeg($src);
     $src_info = getimagesize($src);
     $dst_x = 20;
     $dst_y = 12;
     $src_x = 0;
     $src_y = 0;
     $src_w = $src_info[0];
     $src_h = $src_info[1];
     $alpha = 100;
     imagecopymerge($bg, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $alpha);
     $image_path = RELATIVE_ROOT_PATH . 'images/qmd/' . face_path(MEMBER_ID);
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     $image_file = $image_path . MEMBER_ID . '_o.png';
     imagepng($bg, $image_file);
     imagedestroy($bg);
     return $image_file;
 }