本文整理汇总了PHP中WindUtility::generateRandStr方法的典型用法代码示例。如果您正苦于以下问题:PHP WindUtility::generateRandStr方法的具体用法?PHP WindUtility::generateRandStr怎么用?PHP WindUtility::generateRandStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindUtility
的用法示例。
在下文中一共展示了WindUtility::generateRandStr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 初始化安装程序
*/
public function __construct()
{
$this->_appId = 'L000' . time() . WindUtility::generateRandStr(4);
$this->_config = @(include Wind::getRealPath(self::CONF_PATH, true));
$this->tmpPath = Wind::getRealPath($this->getConfig('tmp_dir') . '.' . Pw::getTime(), false);
$this->tmpInstallLog = Wind::getRealPath($this->getConfig('log_dir'), false);
}
示例2: addThread
/**
* 发表帖子 钩子
*/
public function addThread($tid)
{
$data = $this->inputData;
if (intval($data['isopen'] != 1)) {
return false;
}
$tid = intval($tid);
if ($tid < 1) {
return false;
}
$token = strtolower(WindUtility::generateRandStr(10));
$dm = $this->_getEncryptPostsDm();
$dm->setTid($tid)->setToken($token);
return $this->_getEncryptPostsDs()->add($dm);
}
示例3: addAction
public function addAction()
{
$struct = $this->getInput('struct', 'post');
$model = $this->getInput('model', 'post');
$pageid = $this->getInput('pageid', 'post');
if (!$model) {
$this->showError('operate.fail');
}
Wekit::load('design.PwDesignPermissions');
$permissions = $this->_getPermissionsService()->getPermissionsForPage($this->loginUser->uid, $pageid);
if ($permissions < PwDesignPermissions::IS_DESIGN) {
$this->showError("DESIGN:permissions.fail");
}
Wind::import('SRV:design.bo.PwDesignModelBo');
$bo = new PwDesignModelBo($model);
if (!$bo->isModel()) {
$this->showError('operate.fail');
}
$cls = sprintf('PwDesign%sDataService', ucwords($model));
Wind::import('SRV:design.srv.model.' . $model . '.' . $cls);
$service = new $cls();
$decorator = $service->decorateAddProperty($model);
$_models = array();
$service = $this->_getDesignService();
$types = $service->getDesignModelType();
$models = $service->getModelList();
foreach ($models as $k => $v) {
$_models[$v['type']][] = array('name' => $v['name'], 'model' => $k);
}
$ds = $this->_getModuleDs();
$pageInfo = $this->_getPageDs()->getPage($pageid);
$module['module_name'] = $pageInfo['page_name'] . '_' . WindUtility::generateRandStr(4);
$cache['expired'] = 15;
$this->setOutput($cache, 'cache');
$this->setOutput($module, 'module');
$this->setOutput($types, 'types');
$this->setOutput($_models, 'models');
$this->setOutput($bo->getProperty(), 'property');
$this->setOutput($bo->getModel(), 'modelInfo');
$this->setOutput($decorator, 'decorator');
$this->setOutput($model, 'model');
$this->setOutput($pageid, 'pageid');
$this->setOutput($struct, 'struct');
}
示例4: dorunAction
public function dorunAction()
{
$this->getRequest()->isPost() || $this->showError('operate.fail');
list($windid, $serverUrl, $clientId, $clientKey, $connect) = $this->getInput(array('windid', 'serverUrl', 'clientId', 'clientKey', 'connect'), 'post');
if ($windid == 'local') {
$serverUrl = Wekit::C('site', 'info.url') . '/windid';
$clientId = 1;
!$clientKey && ($clientKey = md5(WindUtility::generateRandStr(10)));
$connect = 'db';
}
$config = new PwConfigSet('windid');
$config->set('windid', $windid)->set('serverUrl', $serverUrl)->set('clientId', $clientId)->set('clientKey', $clientKey)->set('connect', $connect);
if ($windid == 'client') {
list($dbhost, $dbport, $dbuser, $dbpwd, $dbname, $dbprefix, $dbcharset) = $this->getInput(array('dbhost', 'dbport', 'dbuser', 'dbpwd', 'dbname', 'dbprefix', 'dbcharset'), 'post');
$config->set('db.host', $dbhost)->set('db.port', $dbport)->set('db.user', $dbuser)->set('db.pwd', $dbpwd)->set('db.name', $dbname)->set('db.prefix', $dbprefix)->set('db.charset', $dbcharset);
}
$config->flush();
if ($clientId) {
Wekit::C()->reload('windid');
$service = WindidApi::api('app');
WindidApi::getDm('app');
if (!$service->getApp($clientId)) {
$charset = Wekit::V('charset');
$charset = str_replace('-', '', strtolower($charset));
if (!in_array($charset, array('gbk', 'utf8', 'big5'))) {
$charset = 'utf8';
}
$dm = new WindidAppDm();
$dm->setId($clientId)->setApiFile('windid.php')->setIsNotify(1)->setIsSyn(1)->setAppName(Wekit::C('site', 'info.name'))->setSecretkey($clientKey)->setAppUrl(Wekit::C('site', 'info.url'))->setAppIp(Wind::getComponent('request')->getClientIp())->setCharset($charset);
$service->addApp($dm);
} elseif ($clientKey) {
$dm = new WindidAppDm($clientId);
$dm->setSecretkey($clientKey)->setAppUrl(Wekit::C('site', 'info.url'))->setCharset($charset);
$service->editApp($dm);
}
}
$_avatarUrl = WindidApi::api('avatar')->getAvatarUrl();
if ($_avatarUrl != WindidError::SERVER_ERROR) {
Wekit::C()->setConfig('site', 'avatarUrl', $_avatarUrl);
}
$this->showMessage('ADMIN:success');
}
示例5: addAction
public function addAction()
{
$rand = WindUtility::generateRandStr(10);
$this->setOutput(md5($rand), 'rand');
$this->setOutput('windid.php', 'apifile');
}
示例6: createOrderNo
public function createOrderNo()
{
return '3' . str_pad(Wekit::getLoginUser()->uid, 10, "0", STR_PAD_LEFT) . Pw::time2str(Pw::getTime(), 'YmdHis') . WindUtility::generateRandStr(5);
}
示例7: doaddAction
public function doaddAction()
{
$model = $this->getInput('model', 'post');
if (!$model) {
$this->showError('operate.fail');
}
Wind::import('SRV:design.bo.PwDesignModelBo');
$bo = new PwDesignModelBo($model);
if (!$bo->isModel()) {
$this->showError('operate.fail');
}
$name = trim($this->getInput('module_name', 'post'));
if (empty($name)) {
$this->showError('DESIGN:module.name.empty');
}
$cache = $this->getInput('cache', 'post');
$property = $this->getInput('property', 'post');
if ($property['limit'] > 200) {
$this->showError('DESIGN:maxlimit.error');
}
$cls = sprintf('PwDesign%sDataService', ucwords($model));
Wind::import('SRV:design.srv.model.' . $model . '.' . $cls);
$service = new $cls();
if (method_exists($service, 'decorateSaveProperty')) {
$property = $service->decorateSaveProperty($property);
if ($property instanceof PwError) {
$this->showError($property->getError());
}
}
$ds = $this->_getModuleDs();
Wind::import('SRV:design.dm.PwDesignModuleDm');
$dm = new PwDesignModuleDm();
$dm->setFlag($model)->setName($name)->setProperty($property)->setCache($cache)->setModuleType(PwDesignModule::TYPE_SCRIPT)->setIsused(1);
if ($property['html_tpl']) {
$dm->setModuleTpl($property['html_tpl']);
}
$resource = $ds->addModule($dm);
if ($resource instanceof PwError) {
$this->showError($resource->getError());
}
$moduleid = (int) $resource;
Wind::import('SRV:design.srv.data.PwAutoData');
$srv = new PwAutoData($moduleid);
$srv->addAutoData();
//调用模块token
$token = WindUtility::generateRandStr(10);
$this->_getScriptDs()->addScript((int) $moduleid, $token, 0);
$tab = array('property', 'template');
Wind::import('SRV:design.bo.PwDesignModelBo');
$bo = new PwDesignModelBo($model);
$modelInfo = $bo->getModel();
if (is_array($modelInfo['tab'])) {
foreach ($tab as $k => $v) {
if (in_array($v, $modelInfo['tab'])) {
$_tab[] = $tab[$k];
}
}
$tab = $_tab;
}
if (in_array('template', $tab)) {
$this->showMessage("operate.success", "design/template/edit?isscript=1&moduleid=" . $moduleid, true);
} else {
$this->showMessage("operate.success", "design/module/run?type=api", true);
}
}
示例8: after
public function after($fileList, $useFtp, $oldList)
{
if (Wekit::cache()->get('system_upgrade_replace')) {
return true;
}
$relativePath_1 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH, Wind::getRealPath('SRC:wekit'));
$relativePath_2 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH . 'aCloud', Wind::getRealPath('SRC:wekit'));
$strtr = $this->getMoveWay();
$move = array();
$entrance = array('index.php', 'read.php', 'install.php', 'windid.php', 'admin.php', 'alipay.php', 'pay99bill.php', 'paypal.php', 'tenpay.php');
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
foreach ($oldList as $v) {
$v = trim($v, '/');
$v = str_replace('/', DIRECTORY_SEPARATOR, $v);
$_v = ROOT_PATH . $v;
$file = $v;
foreach ($strtr as $search => $replace) {
if (0 === strpos($_v, $search)) {
$file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search)));
$file = str_replace('//', '/', $file);
break;
}
}
$move[$file] = $_v;
if (in_array(basename($_v), $entrance)) {
$content = WindFile::read($_v);
if (strpos($content, '../../src/wekit.php')) {
$content = str_replace('../../src/wekit.php', $relativePath_2, $content);
} else {
$content = str_replace('../src/wekit.php', $relativePath_1, $content);
}
$tmp = tempnam($this->tmpPath, basename($_v) . WindUtility::generateRandStr(3));
WindFile::write($tmp, $content);
$move[$file] = $tmp;
}
}
} else {
foreach ($fileList as $f => $hash) {
$_v = ROOT_PATH . $f;
if (in_array(basename($_v), $entrance)) {
$content = WindFile::read($_v);
if (strpos($content, '../../src/wekit.php')) {
$content = str_replace('../../src/wekit.php', $relativePath_2, $content);
} else {
$content = str_replace('../src/wekit.php', $relativePath_1, $content);
}
$tmp = tempnam($this->tmpPath, basename($_v) . WindUtility::generateRandStr(3));
WindFile::write($tmp, $content);
$move[$f] = $tmp;
}
}
}
// MD5SUM
$md5File = WindFile::read(CONF_PATH . 'md5sum');
$sourceMd5 = PwSystemHelper::resolveMd5($md5File);
$data = '';
foreach ($sourceMd5 as $v => $md5) {
$v = trim($v, '/');
$v = str_replace('/', DIRECTORY_SEPARATOR, $v);
$_v = ROOT_PATH . $v;
$file = $v;
foreach ($strtr as $search => $replace) {
if (0 === strpos($_v, $search)) {
$file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search)));
$file = str_replace('//', '/', $file);
break;
}
}
$data .= PwSystemHelper::md5content($md5, $file);
}
$tmp = tempnam($this->tmpPath, 'md5temp');
WindFile::write($tmp, $data);
$move[str_replace(ROOT_PATH, '', CONF_PATH . 'md5sum')] = $tmp;
// 入口文件
if ($useFtp) {
try {
$ftp = $useFtp['sftp'] ? new PwSftpSave($useFtp) : new PwFtpSave($useFtp);
} catch (WindFtpException $e) {
return new PwError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage())));
}
}
foreach ($move as $k => $v) {
if ($useFtp) {
try {
$r = $ftp->upload($v, $k);
if ($useFtp['sftp'] && !$r && ($e = $ftp->getError())) {
return new PwError('APPCENTER:upgrade.upload.fail', array($v . var_export($e, true)));
}
} catch (WindFtpException $e) {
return new PwError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage())));
}
} else {
copy($v, ROOT_PATH . $k);
}
}
$useFtp && $ftp->close();
return true;
}
示例9: getSignSting
/**
* 获取加密字符串,防止伪造请求
*/
public function getSignSting()
{
return WindUtility::generateRandStr(10);
}
示例10: generateGUID
/**
* 获取唯一标识符串,标识符串的长度为16个字节,128位.
* 根据当前时间与sessionID,混合生成一个唯一的串.
*
* @return string GUID串,16个字节
*/
public static function generateGUID()
{
return substr(md5(WindUtility::generateRandStr(8) . microtime()), -16);
}
示例11: _outFlash
private static function _outFlash()
{
if (!class_exists('SWFBitmap')) {
return false;
}
self::_getCodeLenth();
self::_creatImage();
self::_setRandBackground();
self::_creatBackground();
//self::_setPicBackground();
self::_setRandFont();
self::_setRandGraph();
self::_writeImage();
self::_setRandDistortion();
$_tmpPath = Wind::getRealDir('DATA:tmp.');
$_tmp = $_tmpPath . WindUtility::generateRandStr(8) . '.png';
imagepng(self::$_image, $_tmp);
if (!WindFile::isFile($_tmp)) {
return false;
}
imagedestroy(self::$_image);
$bit = new SWFBitmap($_tmp);
$shape = new SWFShape();
$shape->setRightFill($shape->addFill($bit));
$shape->drawLine($bit->getWidth(), 0);
$shape->drawLine(0, $bit->getHeight());
$shape->drawLine(-$bit->getWidth(), 0);
$shape->drawLine(0, -$bit->getHeight());
$movie = new SWFMovie();
$movie->setDimension($bit->getWidth(), $bit->getHeight());
$flash = $movie->add($shape);
header("Pragma:no-cache");
header("Cache-control:no-cache");
header('Content-type: application/x-shockwave-flash');
$movie->output();
WindFolder::clear($_tmpPath);
}
示例12: _writeWindid
/**
* windid更新
*
* @return boolean
*/
private function _writeWindid()
{
$baseUrl = Wekit::url()->base;
$key = md5(WindUtility::generateRandStr(10));
$charset = Wekit::V('charset');
$charset = str_replace('-', '', strtolower($charset));
if (!in_array($charset, array('gbk', 'utf8', 'big5'))) {
$charset = 'utf8';
}
$config = new PwConfigSet('windid');
$config->set('windid', 'local')->set('serverUrl', $baseUrl . '/windid')->set('clientId', 1)->set('clientKey', $key)->set('connect', 'db')->flush();
Wekit::C()->reload('windid');
Wind::import('WINDID:service.app.dm.WindidAppDm');
$dm = new WindidAppDm();
$dm->setApiFile('windid.php')->setIsNotify('1')->setIsSyn('1')->setAppName('phpwind9.0')->setSecretkey($key)->setAppUrl($baseUrl)->setCharset($charset)->setAppIp('');
$service = WindidApi::api('app');
$result = $service->addApp($dm);
if ($result instanceof WindidError) {
$this->showError('INSTALL:windid.init.fail');
}
return true;
}
示例13: importStructure
protected function importStructure($structs)
{
Wind::import('SRV:design.dm.PwDesignStructureDm');
foreach ($structs as $k => $v) {
//TODO structname 唯一性检查
$name = 'I_' . WindUtility::generateRandStr(6);
$dm = new PwDesignStructureDm();
$style = unserialize($v['struct_style']);
$dm->setStructTitle(unserialize($v['struct_title']))->setStructname($name)->setStructStyle($style['font'], $style['link'], $style['border'], $style['margin'], $style['padding'], $style['background'], $style['styleclass']);
$resource = $this->_getStructureDs()->replaceStruct($dm);
if ($resource instanceof PwError) {
return $resource;
}
$this->_structures[] = $name;
$this->_oldstruct[] = $v['struct_name'];
}
return true;
}
示例14: _beforeUpdate
protected function _beforeUpdate()
{
Wind::import("WSRV:user.validator.WindidUserValidator");
if (!$this->uid) {
return new WindidError(WindidError::FAIL);
}
if (isset($this->_data['username'])) {
$result = WindidUserValidator::checkName($this->_data['username'], $this->uid);
if ($result !== true) {
return $result;
}
}
if (isset($this->_data['email'])) {
$result = WindidUserValidator::checkEmail($this->_data['email'], $this->uid);
if ($result !== true) {
return $result;
}
}
if (isset($this->_data['old_password'])) {
$result = WindidUserValidator::checkOldPassword($this->_data['old_password'], $this->uid);
if ($result !== true) {
return $result;
}
}
if (isset($this->_data['password'])) {
$this->_data['salt'] = WindUtility::generateRandStr(6);
$this->_data['password'] = WindidUtility::buildPassword($this->_data['password'], $this->_data['salt']);
}
if (isset($this->_data['question']) && isset($this->_data['answer'])) {
$this->_data['safecv'] = $this->_data['question'] ? substr(md5($this->_data['question'] . $this->_data['answer']), 8, 8) : '';
}
return true;
}
示例15: _writeWindid
/**
* windid更新
*
* @return boolean
*/
private function _writeWindid()
{
$baseUrl = Wind::getApp()->getRequest()->getBaseUrl(true);
$key = md5(WindUtility::generateRandStr(10));
$charset = Wind::getApp()->getResponse()->getCharset();
$charset = str_replace('-', '', strtolower($charset));
if (!in_array($charset, array('gbk', 'utf8', 'big5'))) {
$charset = 'utf8';
}
Wind::import('WINDID:service.app.dm.WindidAppDm');
$dm = new WindidAppDm();
$dm->setApiFile('windid.php')->setIsNotify('1')->setIsSyn('1')->setAppName('phpwind9.0')->setSecretkey($key)->setAppUrl($baseUrl)->setCharset($charset)->setAppIp('');
$result = Windid::load('app.WindidApp')->addApp($dm);
if ($result instanceof WindidError) {
$this->showError('INSTALL:windid.init.fail');
}
$config = array('windid' => 'local', 'serverUrl' => $baseUrl, 'clientId' => (int) $result, 'clientKey' => $key, 'clientDb' => 'mysql', 'clientCharser' => $charset);
WindFile::savePhpData(Wind::getRealPath('ROOT:conf.windidconfig.php', true), $config);
return true;
}