本文整理汇总了PHP中uniqid函数的典型用法代码示例。如果您正苦于以下问题:PHP uniqid函数的具体用法?PHP uniqid怎么用?PHP uniqid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniqid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: AddTextAdsExample
function AddTextAdsExample(AdWordsUser $user, $adGroupId)
{
// Get the service, which loads the required classes.
$adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
$numAds = 5;
$operations = array();
for ($i = 0; $i < $numAds; $i++) {
// Create text ad.
$textAd = new TextAd();
$textAd->headline = 'Cruise #' . uniqid();
$textAd->description1 = 'Visit the Red Planet in style.';
$textAd->description2 = 'Low-gravity fun for everyone!';
$textAd->displayUrl = 'www.example.com';
$textAd->finalUrls = array('http://www.example.com');
// Create ad group ad.
$adGroupAd = new AdGroupAd();
$adGroupAd->adGroupId = $adGroupId;
$adGroupAd->ad = $textAd;
// Set additional settings (optional).
$adGroupAd->status = 'PAUSED';
// Create operation.
$operation = new AdGroupAdOperation();
$operation->operand = $adGroupAd;
$operation->operator = 'ADD';
$operations[] = $operation;
}
// Make the mutate request.
$result = $adGroupAdService->mutate($operations);
// Display results.
foreach ($result->value as $adGroupAd) {
printf("Text ad with headline '%s' and ID '%s' was added.\n", $adGroupAd->ad->headline, $adGroupAd->ad->id);
}
}
开发者ID:a1pro,项目名称:adwords_dashboard,代码行数:33,代码来源:AddTextAds.php
示例2: addnew
function addnew()
{
if ($_POST) {
$image = $_FILES['logo'];
$image_name = $image['name'];
$image_tmp = $image['tmp_name'];
$image_size = $image['size'];
$error = $image['error'];
$file_ext = explode('.', $image_name);
$file_ext = strtolower(end($file_ext));
$allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
$file_on_server = '';
if (in_array($file_ext, $allowed_ext)) {
if ($error === 0) {
if ($image_size < 3145728) {
$file_on_server = uniqid() . '.' . $file_ext;
$destination = './brand_img/' . $file_on_server;
move_uploaded_file($image_tmp, $destination);
}
}
}
$values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
if ($this->brand->create($values)) {
$this->session->set_flashdata('message', 'New Brand added successfully');
} else {
$this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
}
redirect(base_url() . 'brands/');
}
$this->load->helper('form');
$this->load->view('includes/header', array('title' => 'Add Brand'));
$this->load->view('brand/new_brand');
$this->load->view('includes/footer');
}
开发者ID:PHP-web-artisans,项目名称:ustora_backend,代码行数:34,代码来源:brands.php
示例3: testCreatedCustomerWithSpecifiedRef
public function testCreatedCustomerWithSpecifiedRef()
{
$customerCreateEvent = new CustomerCreateOrUpdateEvent(1, "thelia", "thelia", "street address 1", "street address 2", "street address 3", "0102030405", "0607080910", "63000", "clermont-ferrand", 64, sprintf("%[email protected]", uniqid()), uniqid(), 1, 0, 0, 0, 'My super company', 'testRef');
/** @var Customer $customerAction */
$customerAction = $this->customerAction;
$customerAction->create($customerCreateEvent, null, $this->getMockEventDispatcher());
$customerCreated = $customerCreateEvent->getCustomer();
$this->assertInstanceOf("Thelia\\Model\\Customer", $customerCreated, "new customer created must be an instance of Thelia\\Model\\Customer");
$this->assertFalse($customerCreated->isNew());
$this->assertEquals($customerCreateEvent->getFirstname(), $customerCreated->getFirstname());
$this->assertEquals($customerCreateEvent->getLastname(), $customerCreated->getLastname());
$this->assertEquals($customerCreateEvent->getTitle(), $customerCreated->getTitleId());
$this->assertEquals($customerCreateEvent->getEmail(), $customerCreated->getEmail());
$this->assertEquals($customerCreateEvent->getReseller(), $customerCreated->getReseller());
$this->assertEquals($customerCreateEvent->getSponsor(), $customerCreated->getSponsor());
$this->assertEquals($customerCreateEvent->getDiscount(), $customerCreated->getDiscount());
$this->assertEquals($customerCreateEvent->getRef(), $customerCreated->getRef());
$addressCreated = $customerCreated->getDefaultAddress();
$this->assertInstanceOf("Thelia\\Model\\Address", $addressCreated);
$this->assertEquals($customerCreateEvent->getFirstname(), $addressCreated->getFirstname());
$this->assertEquals($customerCreateEvent->getLastname(), $addressCreated->getLastname());
$this->assertEquals($customerCreateEvent->getTitle(), $addressCreated->getTitleId());
$this->assertEquals($customerCreateEvent->getAddress1(), $addressCreated->getAddress1());
$this->assertEquals($customerCreateEvent->getAddress2(), $addressCreated->getAddress2());
$this->assertEquals($customerCreateEvent->getAddress3(), $addressCreated->getAddress3());
$this->assertEquals($customerCreateEvent->getZipcode(), $addressCreated->getZipcode());
$this->assertEquals($customerCreateEvent->getCity(), $addressCreated->getCity());
$this->assertEquals($customerCreateEvent->getCountry(), $addressCreated->getCountryId());
$this->assertEquals($customerCreateEvent->getPhone(), $addressCreated->getPhone());
$this->assertEquals($customerCreateEvent->getCellphone(), $addressCreated->getCellphone());
$this->assertEquals($customerCreateEvent->getCompany(), $addressCreated->getCompany());
}
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:32,代码来源:CustomerTest.php
示例4: generateHash
function generateHash($password)
{
if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) {
$salt = '$2y$11$' . substr(md5(uniqid(rand(), true)), 0, 22);
return crypt($password, $salt);
}
}
开发者ID:shaochiwang,项目名称:read,代码行数:7,代码来源:register.php
示例5: __construct
public function __construct()
{
$configFile = __DIR__ . '/../config.yml';
$value = Yaml::parse(file_get_contents($configFile));
$ariAddress = $value['examples']['client']['ari_address'];
$dialString = $value['examples']['dial_example']['dial_string'];
$logger = new \Zend\Log\Logger();
$logWriter = new \Zend\Log\Writer\Stream("php://output");
$logger->addWriter($logWriter);
//$filter = new \Zend\Log\Filter\SuppressFilter(true);
$filter = new \Zend\Log\Filter\Priority(\Zend\Log\Logger::NOTICE);
$logWriter->addFilter($filter);
// Connect to the ARI server
$this->client = new Phparia($logger);
$this->client->connect($ariAddress);
$this->client->getAriClient()->onConnect(function () use($dialString) {
try {
$this->client->channels()->createChannel($dialString, null, null, null, null, $this->client->getStasisApplicationName(), 'dialed', '8185551212', 30, null, null, array('MYVARIABLE' => 'value'));
} catch (\phparia\Exception\ServerException $e) {
$this->log($e->getMessage());
}
});
// Listen for the stasis start
$this->client->onStasisStart(function (StasisStart $event) use($dialString) {
if (count($event->getArgs()) > 0 && $event->getArgs()[0] === 'dialed') {
$this->log('Detected outgoing call with variable MYVARIABLE=' . $event->getChannel()->getVariable('MYVARIABLE')->getValue());
// Put the new channel in a bridge
$channel = $event->getChannel();
$this->bridge = $this->client->bridges()->createBridge(uniqid(), 'dtmf_events, mixing', 'dial_example_bridge');
$this->bridge->addChannel($channel->getId());
}
});
$this->client->run();
}
开发者ID:anthraxite,项目名称:phparia,代码行数:34,代码来源:DialExample.php
示例6: start
/**
* 开启事务
* @return Database_Driver_MySQLI_Transaction
*/
public function start()
{
if ($this->id) {
throw new Exception('transaction has started');
}
# 推动连接主数据库
$this->db_driver->connect(true);
# 获取连接ID
$this->_connection_id = $this->db_driver->connection_id();
# 获取唯一ID
$this->id = uniqid('TaId_' . rand());
if (isset(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id])) {
# 已存在事务,则该事务为子事务
if ($this->_set_save_point()) {
//保存事务点
Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id][$this->id] = true;
} else {
$this->id = null;
# 开启事务失败。
throw new Exception('start sub transaction error');
}
} else {
# 开启新事务
$this->_query('SET AUTOCOMMIT=0;');
if (true === $this->_query('START TRANSACTION;')) {
# 如果没有建立到当前主服务器的连接,该操作会隐式的建立
Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id] = array($this->id => true);
} else {
$this->id = null;
# 开启事务失败。
throw new Exception('start transaction error');
}
}
return true;
}
开发者ID:liuyu121,项目名称:myqee,代码行数:39,代码来源:transaction.class.php
示例7: KT_CaptchaImage
/**
* Constructor.
* @param string name to use to store in session the captcha string;
* @return nothing
*/
function KT_CaptchaImage($name)
{
$this->name = 'KT_captcha_' . $name;
$this->text = $this->getRandomText();
$this->filename = substr(md5(uniqid(rand(), true)), 0, 8) . '.png';
$this->lib = $GLOBALS['KT_prefered_image_lib'];
}
开发者ID:Mayoh,项目名称:grupo-ha,代码行数:12,代码来源:KT_CaptchaImage.class.php
示例8: smarty_block_form
function smarty_block_form($params, $content, &$smarty, $repeat)
{
if (!empty($content)) {
// set default output vars
$data = array('search_id' => FALSE, 'submit_token_id' => FALSE, 'class' => '', 'content' => $content, 'method' => 'post');
$modules = $smarty->getTemplateVars('modules');
if (!empty($modules)) {
$module = '';
$prefix = 'module=';
foreach ($modules as $mod) {
$module .= $prefix . $mod . '&';
$prefix = 'sub' . $prefix;
}
}
if (isset($params['target'])) {
$data['action'] = $params['target'];
} else {
$access = AccessObject::Instance();
$pid = $access->getPermission($modules, $params['controller'], $params['action']);
$data['action'] = '/?pid=' . $pid . '&' . $module . 'controller=' . $params['controller'] . '&action=' . $params['action'];
}
if (isset($params['subfunction'])) {
$data['action'] .= '&subfunction=' . $params['subfunction'];
if (isset($params['subfunctionaction'])) {
$data['action'] .= '&subfunctionaction=' . $params['subfunctionaction'];
}
}
if (isset($params['id'])) {
$data['action'] .= '&id=' . $params['id'];
}
foreach ($params as $name => $value) {
if ($name[0] === '_') {
$data['action'] .= '&' . substr($name, 1) . '=' . $value;
}
}
if (isset($params['additional_data'])) {
foreach ($params['additional_data'] as $name => $value) {
$data['action'] .= '&' . $name . '=' . $value;
}
}
if (isset($params['class'])) {
$data['class'] = $params['class'];
}
$data['original_action'] = $smarty->getTemplateVars('action');
if (isset($_GET['search_id'])) {
$data['search_id'] = $_GET['search_id'];
}
// there are some instances where we don't want the submit token
if (strtoupper($params['submit_token']) !== 'FALSE') {
$data['submit_token_id'] = uniqid();
$_SESSION['submit_token'][$data['submit_token_id']] = TRUE;
}
$data['display_tags'] = !isset($params['notags']);
if (isset($params['form_id'])) {
$data['form_id'] = $params['form_id'];
}
// fetch smarty plugin template
return smarty_plugin_template($smarty, $data, 'block.form');
}
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:60,代码来源:block.form.php
示例9: preProcessing
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
{
$params = $compiler->getCompiledParams($params);
$parsedParams = array();
if (!isset($params['*'])) {
$params['*'] = array();
}
foreach ($params['*'] as $param => $defValue) {
if (is_numeric($param)) {
$param = $defValue;
$defValue = null;
}
$param = trim($param, '\'"');
if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
throw new Dwoo_Compilation_Exception($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
}
$parsedParams[$param] = $defValue;
}
$params['name'] = substr($params['name'], 1, -1);
$params['*'] = $parsedParams;
$params['uuid'] = uniqid();
$compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params'] = $params;
return '';
}
开发者ID:netfreak,项目名称:pyrocms,代码行数:26,代码来源:template.php
示例10: testGetValidateHash
public function testGetValidateHash()
{
$password = uniqid();
$hash = $this->_model->getHash($password);
$this->assertTrue(is_string($hash));
$this->assertTrue($this->_model->validateHash($password, $hash));
}
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:ModelTest.php
示例11: renderAudioPlayer
/**
* Renders audio player for the blog
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function renderAudioPlayer($uri, $options = array())
{
// Merge the options with the default options
$options = array_replace_recursive(self::$defaultAudioOptions, $options);
// Generate a random uid
$uniqid = uniqid();
$uid = 'audio-' . EBMM::getHash($uri . $uniqid);
// Url to the audio
$url = $this->normalizeURI($uri);
// Get the track if there is no track provided
if (!$options['track']) {
$options['track'] = basename($url);
}
// Set a default artist if artist isn't set
if (!$options['artist']) {
$options['artist'] = JText::_('COM_EASYBLOG_BLOCKS_AUDIO_ARTIST');
}
$template = EB::template();
$template->set('uid', $uid);
$template->set('showTrack', $options['showTrack']);
$template->set('showDownload', $options['showDownload']);
$template->set('showArtist', $options['showArtist']);
$template->set('autoplay', $options['autoplay']);
$template->set('loop', $options['loop']);
$template->set('artist', $options['artist']);
$template->set('track', $options['track']);
$template->set('url', $url);
$output = $template->output('site/blogs/blocks/audio');
return $output;
}
开发者ID:knigherrant,项目名称:decopatio,代码行数:38,代码来源:media.php
示例12: generateFormkey
/**
* Generate the form key based on IP address
*
* @return string md5sum of IP address + unique number
*/
private function generateFormkey()
{
$ip = $_SERVER['REMOTE_ADDR'];
// mt_rand() is better than rand()
$uniqid = uniqid(mt_rand(), true);
return md5($ip . $uniqid);
}
开发者ID:boots7458,项目名称:elabftw,代码行数:12,代码来源:FormKey.php
示例13: submit
function submit()
{
//Check required Fields
$missing = false;
if (!isset($_POST["sql"]) || strlen($_POST["sql"]) == 0) {
$missing = true;
}
if ($missing) {
$this->res->success = false;
$this->res->message = "missing required field!";
return null;
}
//get vars
$sql = $_POST["sql"];
$schema_id = $this->params['schema_id'];
$schema = Doo::db()->getOne('Schemata', array('where' => 'id = ' . $schema_id));
$async = isset($_POST['async']) ? $_POST['async'] : 0;
$coord_name = isset($_POST['coord_name']) ? $_POST['coord_name'] : null;
$query_id = isset($_POST["query_id"]) ? $_POST["query_id"] : strtoupper(md5(uniqid(rand(), true)));
//init
$shard_query = new ShardQuery($schema->schema_name);
//error!
if (!empty($shard_query->errors)) {
//return
$this->res->message = $shard_query->errors;
$this->res->success = false;
return null;
}
//set async
$shard_query->async = $async == true ? true : false;
//set coord shard
if (isset($coord_name)) {
$shard_query->set_coordinator($coord_name);
}
//execute query
$stmt = $shard_query->query($sql);
//error!
if (!$stmt && !empty($shard_query->errors)) {
//return
$this->res->message = $shard_query->errors;
$this->res->success = false;
return null;
}
//empty results
if ($stmt == null && empty($shard_query->errors)) {
$this->res->data = array();
}
//build data
if (!is_int($stmt)) {
$this->res->data = $this->json_format($shard_query, $stmt);
$shard_query->DAL->my_free_result($stmt);
} else {
//save job_id
$this->res->data = $stmt;
}
//save message
$this->res->message = $query_id;
//return
$this->res->success = true;
}
开发者ID:garv347,项目名称:swanhart-tools,代码行数:60,代码来源:QueryRESTController.php
示例14: get_valid_layout
function get_valid_layout($layout = array())
{
// parse
$layout = wp_parse_args($layout, array('key' => uniqid(), 'name' => '', 'label' => '', 'display' => 'block', 'sub_fields' => array(), 'min' => '', 'max' => ''));
// return
return $layout;
}
开发者ID:Aqro,项目名称:NewDWM,代码行数:7,代码来源:flexible-content.php
示例15: query
/**
* execute query - show be regarded as private to insulate the rest of
* the application from sql differences
* @access private
*/
function query($sql)
{
global $CONF;
if (is_null($this->dblink)) {
$this->_connect();
}
//been passed more parameters? do some smart replacement
if (func_num_args() > 1) {
//query contains ? placeholders, but it's possible the
//replacement string have ? in too, so we replace them in
//our sql with something more unique
$q = md5(uniqid(rand(), true));
$sql = str_replace('?', $q, $sql);
$args = func_get_args();
for ($i = 1; $i <= count($args); $i++) {
$sql = preg_replace("/{$q}/", "'" . preg_quote(mysql_real_escape_string($args[$i])) . "'", $sql, 1);
}
//we shouldn't have any $q left, but it will help debugging if we change them back!
$sql = str_replace($q, '?', $sql);
}
$this->dbresult = mysql_query($sql, $this->dblink);
if (!$this->dbresult) {
die("Query failure: " . mysql_error() . "<br />{$sql}");
}
return $this->dbresult;
}
开发者ID:carriercomm,项目名称:pastebin,代码行数:31,代码来源:legacy.php
示例16: update
public function update($admin_id)
{
$admin_id = $admin_id + 0;
$model = new \Model\AdminModel();
if (IS_POST) {
if ($data = $model->create()) {
$password = I('post.password');
//判断有没有输入新密码
if (empty($password)) {
unset($data['password']);
} else {
//重新生成密码和salt
$str = uniqid();
$salt = substr($str, -6);
$password = I('post.password');
//生成密码
$data['password'] = md5(md5($password) . $salt);
$data['salt'] = $salt;
}
if ($model->save($data) !== false) {
$this->success('修改管理员成功', U('showlist'), 1);
exit;
}
$this->error('修改管理员失败');
}
$this->error($model->getError());
}
//获取要修改管理员的属性并显示
$info = $model->field('admin_id,admin_name,role_id')->join("left join it_admin_role using(admin_id)")->find($admin_id);
$this->assign('info', $info);
//获取角色并遍历显示
$role_list = M('Role')->select();
$this->assign('role_list', $role_list);
$this->display();
}
开发者ID:VenusGrape,项目名称:hymall,代码行数:35,代码来源:AdminController.class.php
示例17: actionCreate
public function actionCreate()
{
$model = new Import();
if ($model->load(Yii::$app->request->post())) {
$file_path = \yii\web\UploadedFile::getInstance($model, 'file_path');
if (!empty($file_path)) {
$model->file_path = \yii\web\UploadedFile::getInstance($model, 'file_path');
$ext = FileHelper::getExtention($model->file_path);
if (!empty($ext)) {
$fileDir = Yii::$app->controller->module->id . '/' . date('Y/m/d/');
$fileName = uniqid() . StringHelper::asUrl(Yii::$app->controller->module->id) . '.' . $ext;
$folder = Yii::$app->params['uploadPath'] . '/' . Yii::$app->params['uploadDir'] . '/' . $fileDir;
FileHelper::createDirectory($folder);
$model->file_path->saveAs($folder . $fileName);
$model->file_path = $fileDir . $fileName;
}
}
if ($model->save()) {
return $this->redirect(['update', 'id' => (string) $model->_id]);
}
}
Yii::$app->view->title = Yii::t($this->module->id, 'Create');
Yii::$app->view->params['breadcrumbs'][] = ['label' => Yii::t($this->module->id, 'Import'), 'url' => ['index']];
Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title;
return $this->render('create', ['model' => $model]);
}
开发者ID:quynhvv,项目名称:stepup,代码行数:26,代码来源:ImportController.php
示例18: addUser
public function addUser($add = array())
{
if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) {
return TRUE;
}
$this->db->where('staff_email', strtolower($add['site_email']));
$this->db->delete('staffs');
$this->db->set('staff_email', strtolower($add['site_email']));
$this->db->set('staff_name', $add['staff_name']);
$this->db->set('staff_group_id', '11');
$this->db->set('staff_location_id', '0');
$this->db->set('language_id', '11');
$this->db->set('timezone', '0');
$this->db->set('staff_status', '1');
$this->db->set('date_added', mdate('%Y-%m-%d', time()));
$query = $this->db->insert('staffs');
if ($this->db->affected_rows() > 0 and $query === TRUE) {
$staff_id = $this->db->insert_id();
$this->db->where('username', $add['username']);
$this->db->delete('users');
$this->db->set('username', $add['username']);
$this->db->set('staff_id', $staff_id);
$this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9));
$this->db->set('password', sha1($salt . sha1($salt . sha1($add['password']))));
$query = $this->db->insert('users');
}
return $query;
}
开发者ID:tastyigniter,项目名称:tastyigniter,代码行数:28,代码来源:Setup_model.php
示例19: initSharedSession
protected function initSharedSession()
{
$cookie_name = $this->getSharedSessionCookieName();
if (isset($_COOKIE[$cookie_name])) {
$data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
// good case
$this->sharedSessionID = $data['id'];
return;
}
// ignoring potentially unreachable data
}
// evil/corrupt/missing case
$base_domain = $this->getBaseDomain();
$this->sharedSessionID = md5(uniqid(mt_rand(), true));
$cookie_value = $this->makeSignedRequest(array('domain' => $base_domain, 'id' => $this->sharedSessionID));
$_COOKIE[$cookie_name] = $cookie_value;
if (!headers_sent()) {
$expire = time() + self::FBSS_COOKIE_EXPIRE;
setcookie($cookie_name, $cookie_value, $expire, '/', '.' . $base_domain);
} else {
// @codeCoverageIgnoreStart
self::errorLog('Shared session ID cookie could not be set! You must ensure you ' . 'create the Facebook instance before headers have been sent. This ' . 'will cause authentication issues after the first request.');
// @codeCoverageIgnoreEnd
}
}
开发者ID:mydos,项目名称:JBIMS-Admission,代码行数:26,代码来源:facebook.php
示例20: testSetName
/**
* @covers Veles\Tools\PhpToken::setName
*/
public function testSetName()
{
$expected = uniqid();
$this->object->setName($expected);
$msg = 'Wrong behavior of PhpToken::setName()';
$this->assertAttributeSame($expected, 'name', $this->object, $msg);
}
开发者ID:nafigator,项目名称:Veles-unit-tests,代码行数:10,代码来源:PhpTokenTest.php
注:本文中的uniqid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论