本文整理汇总了PHP中Pw::getUserDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Pw::getUserDir方法的具体用法?PHP Pw::getUserDir怎么用?PHP Pw::getUserDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pw
的用法示例。
在下文中一共展示了Pw::getUserDir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($uid)
{
$this->ftype = array('jpg' => 2000, 'png' => 2000, 'jpeg' => 2000);
$this->mime = array('image/jpeg', 'image/png', 'image/jpg');
$this->uid = $uid;
$this->udir = Pw::getUserDir($this->uid);
}
示例2: __construct
public function __construct(PwUserBo $user)
{
$this->ftype = array('jpg' => 2000, 'png' => 2000, 'jpeg' => 2000);
$this->user = $user;
$this->udir = Pw::getUserDir($this->user->uid);
$this->mime = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif');
}
示例3: getAction
/**
* 获取用户头像
*
* @param $uid
* @param $size big middle small
* @return string
*/
public function getAction()
{
$uid = $this->getInput('uid', 'get');
$size = $this->getInput('size', 'get');
!$size && ($size = 'middle');
$file = $uid . (in_array($size, array('middle', 'small')) ? '_' . $size : '') . '.jpg';
$result = $this->attachUrl . '/avatar/' . Pw::getUserDir($uid) . '/' . $file;
$this->output($result);
}
示例4: avatarAction
/**
* 头像转移
*/
public function avatarAction()
{
$end_uid = $this->getMaxUid();
ini_set('max_execution_time', 0);
$time_start = microtime(true);
list($ftp, $attachDir) = $this->_getFtp();
$defauleDir = rtrim(Wind::getRealDir('PUBLIC:res.images.face', true), '/');
list($start_uid, $end) = $this->_getStartAndLimit(intval($this->getInput('uid', 'get')), $end_uid, $ftp ? true : false);
while ($start_uid < $end) {
$res = $this->_getOldAvatarPath($attachDir, $start_uid);
$big = $res['big'];
$middle = $res['middle'];
$small = $res['small'];
if (!$this->checkFile($middle)) {
$big = $defauleDir . '/face_big.jpg';
$middle = $defauleDir . '/face_middle.jpg';
$small = $defauleDir . '/face_small.jpg';
}
$_toPath = '/avatar/' . Pw::getUserDir($start_uid) . '/';
$to_big = $_toPath . $start_uid . '.jpg';
$to_middle = $_toPath . $start_uid . '_middle.jpg';
$to_small = $_toPath . $start_uid . '_small.jpg';
if ($ftp) {
$ftp->mkdirs($_toPath);
$ftp->upload($big, $to_big);
$ftp->upload($middle, $to_middle);
$ftp->upload($small, $to_small);
} else {
WindFolder::mkRecur($attachDir . $_toPath);
copy($big, $attachDir . $to_big);
copy($middle, $attachDir . $to_middle);
copy($small, $attachDir . $to_small);
}
$start_uid++;
}
if ($end < $end_uid) {
$this->setOutput($end, 'uid');
$this->setOutput($this->getInput('token', 'get'), 'token');
$this->setTemplate('upgrade_avatar');
} else {
$this->showMessage('升级成功!');
}
}
示例5: getAvatar
public function getAvatar($uid, $size = 'middle')
{
$file = $uid . (in_array($size, array('middle', 'small')) ? '_' . $size : '') . '.jpg';
return Wekit::app('windid')->config->site->avatarUrl . '/avatar/' . Pw::getUserDir($uid) . '/' . $file;
}
示例6: restore_avatar
/**
* 初始化用户头像
* @param int $uid
* @param string $url 腾讯头像地址
*/
function restore_avatar($uid, $url)
{
$store = Wind::getComponent('storage');
Wind::import('SRV:upload.PwUpload');
Wind::import('LIB:image.PwImage');
$fileDir = sprintf('avatar/%s/', Pw::getUserDir($uid));
$_avatar = array('.jpg' => 200, '_middle.jpg' => 120, '_small.jpg' => 50);
$file = tempnam(sys_get_temp_dir(), 'avatar');
$img = httpget($url);
file_put_contents($file, $img);
$img = new PwImage($file);
$thumb = new PwImageThumb($img);
foreach ($_avatar as $des => $size) {
$toPath = $store->getAbsolutePath($uid . $des, $fileDir);
PwUpload::createFolder(dirname($toPath));
if ($size < 100) {
$thumb->setWidth($size);
$thumb->setHeight($size);
$thumb->setDstFile($toPath);
$thumb->execute();
} else {
copy($file, $toPath);
}
}
Wind::import('SRV:upload.action.PwAvatarUpload');
Wind::import('SRV:upload.PwUpload');
PwSimpleHook::getInstance('update_avatar')->runDo($uid);
@unlink($file);
return true;
}
示例7: _defaultAvatar
private function _defaultAvatar($uid, $type = 'face')
{
Wind::import('LIB:upload.PwUpload');
$_avatar = array('.jpg' => '_big.jpg', '_middle.jpg' => '_middle.jpg', '_small.jpg' => '_small.jpg');
$defaultBanDir = Wind::getRealDir('ROOT:') . 'res/images/face/';
$fileDir = 'avatar/' . Pw::getUserDir($uid) . '/';
$attachPath = Wind::getRealDir('ROOT:') . 'windid/attachment/';
foreach ($_avatar as $des => $org) {
$toPath = $attachPath . $fileDir . $uid . $des;
$fromPath = $defaultBanDir . $type . $org;
PwUpload::createFolder(dirname($toPath));
PwUpload::copyFile($fromPath, $toPath);
}
return true;
}