Exemple #1
0
 function avatar($size = "24")
 {
     $_dir = ceil(self::$userid / 500);
     $avatar = 'avatar/' . $_dir . '/' . self::$userid . '_' . $size . '.gif';
     if (file_exists(iFS::fp($avatar, '+iPATH'))) {
         return iFS::fp($avatar);
     } else {
         return iCMS_PUBLIC_URL . '/common/avatar_' . $size . '.gif';
     }
 }
Exemple #2
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: push.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
function push_list($vars)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $where_sql = "WHERE `status`='1'";
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if (isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    isset($vars['pid']) && ($where_sql .= " AND `type` ='{$vars['pid']}'");
    isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
    isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
    isset($vars['startdate']) && ($where_sql .= " AND `addtime`>='" . strtotime($vars['startdate']) . "'");
    isset($vars['enddate']) && ($where_sql .= " AND `addtime`<='" . strtotime($vars['enddate']) . "'");
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "addtime":
            $order_sql = " ORDER BY `addtime` {$by}";
            break;
        case "disorder":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` DESC";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/push/' . md5($where_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__push` {$where_sql} {$order_sql} LIMIT {$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['pic'] && ($value['pic'] = iFS::fp($value['pic'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['metadata'] && ($value['metadata'] = unserialize($value['metadata']));
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #3
0
function get_pic($src, $size = 0, $thumb = 0)
{
    if (empty($src)) {
        return array();
    }
    $data = array('src' => $src, 'url' => iFS::fp($src, '+http'));
    if ($size) {
        $data['width'] = $size['w'];
        $data['height'] = $size['h'];
    }
    if ($size && $thumb) {
        $data += bitscale(array("tw" => (int) $thumb['width'], "th" => (int) $thumb['height'], "w" => (int) $size['w'], "h" => (int) $size['h']));
    }
    return $data;
}
Exemple #4
0
 public static function delete($frp)
 {
     if (!self::$config['enable']) {
         return false;
     }
     foreach ((array) self::$config['sdk'] as $vendor => $conf) {
         $fp = ltrim(iFS::fp($frp, '-iPATH'), '/');
         $client = self::yun($vendor);
         if ($client) {
             $res = $client->delete($conf['Bucket'], $fp);
             $res = json_decode($res, true);
             if ($res['error']) {
                 self::$error[$vendor] = array('action' => 'delete', 'code' => 0, 'state' => 'Error', 'msg' => $res['msg']);
             }
         }
     }
 }
Exemple #5
0
 public static function router($uid, $type, $size = 0)
 {
     switch ($type) {
         case 'avatar':
             return iCMS_FS_URL . get_user_pic($uid, $size);
             break;
         case 'url':
             return iPHP::router(array('/{uid}/', $uid), iPHP_ROUTER_REWRITE);
             break;
         case 'coverpic':
             $dir = get_user_dir($uid, 'coverpic');
             return array('pc' => iFS::fp($dir . '/' . $uid . ".jpg", '+http'), 'mo' => iFS::fp($dir . '/m_' . $uid . ".jpg", '+http'));
             break;
         case 'urls':
             return array('inbox' => iPHP::router(array('/user/inbox/{uid}', $uid), iPHP_ROUTER_REWRITE), 'home' => iPHP::router(array('/{uid}/', $uid), iPHP_ROUTER_REWRITE), 'comment' => iPHP::router(array('/{uid}/comment/', $uid), iPHP_ROUTER_REWRITE), 'favorite' => iPHP::router(array('/{uid}/favorite/', $uid), iPHP_ROUTER_REWRITE), 'fans' => iPHP::router(array('/{uid}/fans/', $uid), iPHP_ROUTER_REWRITE), 'follower' => iPHP::router(array('/{uid}/follower/', $uid), iPHP_ROUTER_REWRITE));
             break;
     }
 }
Exemple #6
0
 function getpic($path)
 {
     $uri = parse_url(iCMS_FS_URL);
     $pic = iS::escapeStr($path);
     if (stripos($pic, $uri['host']) === false) {
         stripos($pic, 'http://') === false or $pic = iFS::http($pic);
     } else {
         $pic = iFS::fp($pic, "-http");
     }
     return $pic;
 }
Exemple #7
0
    echo $rs[$i]['name'];
    ?>
</a>
          </div>

        <?php 
    if ($rs[$i]['haspic']) {
        ?>
        <a href="<?php 
        echo APP_URI;
        ?>
&do=preview&id=<?php 
        echo $rs[$i]['id'];
        ?>
" data-toggle="modal" title="预览"><img src="<?php 
        echo iFS::fp($rs[$i]['pic']);
        ?>
" style="height:120px;"/></a>
        <?php 
    }
    ?>
          </td>
          <td><a href="<?php 
    echo APP_DOURI;
    ?>
&cid=<?php 
    echo $rs[$i]['cid'];
    echo $uri;
    ?>
"><?php 
    echo $C['name'];
Exemple #8
0
          <thead>
            <tr>
              <th><i class="fa fa-arrows-v"></i></th>
              <th>ID</th>
              <th style="width:50px;">关联ID</th>
              <th style="width:50px;">用户ID</th>
              <th >路径</th>
              <th style="width:80px;">文件大小</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            <?php 
for ($i = 0; $i < $_count; $i++) {
    $filepath = $rs[$i]['path'] . $rs[$i]['filename'] . '.' . $rs[$i]['ext'];
    $href = iFS::fp($filepath, "+http");
    ?>
            <tr id="tr<?php 
    echo $rs[$i]['id'];
    ?>
">
              <td><input type="checkbox" name="id[]" value="<?php 
    echo $rs[$i]['id'];
    ?>
" /></td>
              <td><?php 
    echo $rs[$i]['id'];
    ?>
</td>
              <td><?php 
    echo $rs[$i]['indexid'];
Exemple #9
0
 public function API_mobileUp()
 {
     $this->auth or iPHP::code(0, 'iCMS:!login', 0, 'json');
     $F = iFS::upload('upfile');
     $F['path'] && ($url = iFS::fp($F['path'], '+http'));
     iPHP::js_callback(array('url' => $url, 'code' => $F['code']));
 }
Exemple #10
0
&frame=iPHP" class="tip-bottom" target="iPHP_FRAME" title="生成静态文件"><i class="fa fa-file"></i></a>
                  <?php 
        }
        ?>
                </div>
                <?php 
        if ($value['pic'] && iCMS::$config['publish']['showpic']) {
            ?>
                <a href="<?php 
            echo APP_URI;
            ?>
&do=preview&id=<?php 
            echo $value['id'];
            ?>
" data-toggle="modal" title="预览"><img src="<?php 
            echo iFS::fp($value['pic']);
            ?>
" style="height:120px;"/></a>
                <?php 
        }
        ?>
              </td>
              <td><?php 
        if ($value['pubdate']) {
            echo get_date($value['pubdate'], 'Y-m-d H:i');
        }
        ?>
<br />
                <?php 
        if ($value['postime']) {
            echo get_date($value['postime'], 'Y-m-d H:i');
Exemple #11
0
 function do_uploadscrawl()
 {
     if ($_GET["action"] == "tmpImg") {
         // 背景上传
         iFS::$callback = false;
         $F = iFS::upload('upfile', 'scrawl/tmp');
         $F === false && exit;
         $F['path'] && ($url = iFS::fp($F['path'], '+http'));
         echo "<script>parent.ue_callback('" . $url . "','SUCCESS')</script>";
     } else {
         iFS::$callback = true;
         $F = iFS::base64ToFile($_POST['upfile'], 'scrawl/' . get_date(0, 'Y/md'));
         $F === false && exit(iFS::$ERROR);
         $F['path'] && ($url = iFS::fp($F['path'], '+http'));
         $tmp = iFS::get_dir() . "scrawl/tmp/";
         iFS::rmdir($tmp);
         iPHP::json(array("url" => $url, "state" => 'SUCCESS'));
     }
 }
Exemple #12
0
 function picdata($pic = '', $mpic = '', $spic = '')
 {
     $picdata = array();
     if ($pic) {
         list($width, $height, $type, $attr) = @getimagesize(iFS::fp($pic, '+iPATH'));
         $picdata['b'] = array('w' => $width, 'h' => $height);
     }
     if ($mpic) {
         list($width, $height, $type, $attr) = @getimagesize(iFS::fp($mpic, '+iPATH'));
         $picdata['m'] = array('w' => $width, 'h' => $height);
     }
     if ($spic) {
         list($width, $height, $type, $attr) = @getimagesize(iFS::fp($spic, '+iPATH'));
         $picdata['s'] = array('w' => $width, 'h' => $height);
     }
     return $picdata ? addslashes(serialize($picdata)) : '';
 }
Exemple #13
0
 public static function http($http, $ret = '', $times = 0)
 {
     list($RootPath, $FileDir) = self::mk_udir($udir);
     // 文件保存目录方式
     $frs = self::getFileData('ofilename', $http);
     if ($frs) {
         if ($ret == 'array') {
             return self::_array(1, $frs, $RootPath);
         }
         return $frs->filepath;
     }
     $FileExt = self::valid_ext($http);
     //判断过滤文件类型
     if ($FileExt === false) {
         return false;
     }
     $fdata = self::remote($http);
     if ($fdata) {
         $file_md5 = md5($fdata);
         $frs = self::getFileData('filename', $file_md5);
         if ($frs) {
             $FilePath = $frs->filepath;
             $FileRootPath = iFS::fp($FilePath, "+iPATH");
             if (!is_file($FileRootPath)) {
                 self::mkdir(dirname($FileRootPath));
                 self::write($FileRootPath, $fdata);
                 self::watermark($FileExt, $FileRootPath);
                 self::yun_write($FileRootPath);
             }
             if ($ret == 'array') {
                 return self::_array(1, $frs, $RootPath);
             }
         } else {
             $FileName = $file_md5 . "." . $FileExt;
             $FilePath = $FileDir . $FileName;
             $FileRootPath = $RootPath . $FileName;
             self::write($FileRootPath, $fdata);
             self::watermark($FileExt, $FileRootPath);
             self::yun_write($FileRootPath);
             $FileSize = @filesize($FileRootPath);
             empty($FileSize) && ($FileSize = 0);
             $fid = self::insFileData(array('filename' => $file_md5, 'ofilename' => $http, 'path' => $FileDir, 'intro' => $intro, 'ext' => $FileExt, 'size' => $FileSize), 1);
             if ($ret == 'array') {
                 return array('code' => 1, 'fid' => $fid, 'md5' => $file_md5, 'size' => $FileSize, 'oname' => $http, 'name' => $FileName, 'fname' => $FileName . "." . $FileExt, 'dir' => $FileDir, 'ext' => $FileExt, 'RootPath' => $FileRootPath, 'path' => $FilePath, 'dirRootPath' => $RootPath);
             }
         }
         return $FilePath;
     } else {
         // if ($times < 3) {
         //     $times++;
         //     return self::http($http,$ret,$times);
         // } else {
         return false;
         // }
     }
 }
Exemple #14
0
 function do_delfile()
 {
     iACP::MP('FILE.DELETE', 'alert');
     $_GET['path'] or iPHP::alert("请选择要删除的文件");
     strpos($_GET['path'], '..') !== false && iPHP::alert("文件路径中带有..");
     $hash = md5($_GET['path']);
     $FileRootPath = iFS::fp($_GET['path'], '+iPATH');
     if (iFS::del($FileRootPath)) {
         $msg = 'success:#:check:#:文件删除完成!';
         $_GET['ajax'] && iPHP::json(array('code' => 1, 'msg' => $msg));
     } else {
         $msg = 'warning:#:warning:#:找不到相关文件,文件删除失败!';
         $_GET['ajax'] && iPHP::json(array('code' => 0, 'msg' => $msg));
     }
     iPHP::dialog($msg, 'js:parent.$("#' . $hash . '").remove();');
 }
Exemple #15
0
 public static function folder($dir = '', $type = NULL)
 {
     $dir = trim($dir, '/');
     $sDir = $dir;
     $_GET['dir'] && ($gDir = trim($_GET['dir'], '/'));
     // print_r('$dir='.$dir.'<br />');
     // print_r('$gDir='.$gDir.'<br />');
     //$gDir && $dir	= $gDir;
     //strstr($dir,'.')!==false	&& self::alert('What are you doing?','',1000000);
     //strstr($dir,'..')!==false	&& self::alert('What are you doing?','',1000000);
     $sDir_PATH = iFS::path_join(iPATH, $sDir);
     $iDir_PATH = iFS::path_join($sDir_PATH, $gDir);
     // print_r('$sDir_PATH='.$sDir_PATH."\n");
     // print_r('$iDir_PATH='.$iDir_PATH."\n");
     strpos($iDir_PATH, $sDir_PATH) === false && self::alert("对不起!您访问的目录有问题!");
     if (!is_dir($iDir_PATH)) {
         return false;
     }
     $url = buildurl(false, 'dir');
     if ($handle = opendir($iDir_PATH)) {
         while (false !== ($rs = readdir($handle))) {
             // print_r('$rs='.$rs."\n");
             $filepath = iFS::path_join($iDir_PATH, $rs);
             $filepath = rtrim($filepath, '/');
             //				print_r('$filepath='.$filepath."\n");
             $sFileType = @filetype($filepath);
             //				print_r('$sFileType='.$sFileType."\n");
             // var_dump($sDir_PATH,$filepath);
             $path = str_replace($sDir_PATH, '', $filepath);
             $path = ltrim($path, '/');
             if ($sFileType == "dir" && !in_array($rs, array('.', '..', 'admincp'))) {
                 $dirArray[] = array('path' => $path, 'name' => $rs, 'url' => $url . urlencode($path));
             }
             if ($sFileType == "file" && !in_array($rs, array('..', '.iPHP'))) {
                 $filext = iFS::get_ext($rs);
                 $fileinfo = array('path' => $path, 'dir' => dirname($path), 'url' => iFS::fp($path, '+http'), 'name' => $rs, 'modified' => get_date(filemtime($filepath), "Y-m-d H:i:s"), 'md5' => md5_file($filepath), 'ext' => $filext, 'size' => iFS::sizeUnit(filesize($filepath)));
                 if ($type) {
                     in_array(strtolower($filext), $type) && ($fileArray[] = $fileinfo);
                 } else {
                     $fileArray[] = $fileinfo;
                 }
             }
         }
     }
     $a['DirArray'] = (array) $dirArray;
     $a['FileArray'] = (array) $fileArray;
     $a['pwd'] = str_replace($sDir_PATH, '', $iDir_PATH);
     $a['pwd'] = trim($a['pwd'], '/');
     $pos = strripos($a['pwd'], '/');
     $a['parent'] = ltrim(substr($a['pwd'], 0, $pos), '/');
     $a['URI'] = $url;
     // var_dump($a);
     //    	exit;
     return $a;
 }