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; } }
function get_user_pic($uid, $size = 0, $dir = 'avatar') { $path = get_user_dir($uid, $dir) . '/' . $uid . ".jpg"; if ($size) { $path .= '_' . $size . 'x' . $size . '.jpg'; } return $path; }
private function __action_profile_avatar() { iFS::$watermark = false; iFS::$checkFileData = false; $dir = get_user_dir(user::$userid); $F = iFS::upload('upfile', $dir, user::$userid, 'jpg'); if (empty($F)) { if ($_POST['format'] == 'json') { iPHP::code(0, 'user:iCMS:error', 0, 'json'); } else { iPHP::js_callback(array("code" => 0)); } } $url = iFS::fp($F['path'], '+http'); if ($_POST['format'] == 'json') { iPHP::code(1, 'user:profile:avatar', $url, 'json'); } $array = array("code" => $F["code"], "value" => $F["path"], "url" => $url, "fid" => $F["fid"], "fileType" => $F["ext"], "image" => in_array($F["ext"], array('gif', 'jpg', 'jpeg', 'png')) ? 1 : 0, "original" => $F["oname"], "state" => $F['code'] ? 'SUCCESS' : $F['state']); iPHP::js_callback($array); }