本文整理汇总了PHP中gen_uuid函数的典型用法代码示例。如果您正苦于以下问题:PHP gen_uuid函数的具体用法?PHP gen_uuid怎么用?PHP gen_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gen_uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save($id, $account)
{
// Update ....
if (!$account['isNew']) {
$this->db->update('person', ["firstname" => $account['firstname'], "lastname" => $account['lastname']], "id = '{$id}'");
$this->db->update('accountrole', ["role" => $account['role']], "accountid = '{$id}'");
if (isset($account['password']) && strlen($account['password']) > 5) {
$this->db->update('account', ["password" => md5($account['password'])], "id = '{$id}'");
} else {
$this->latestErr = "Password didn't match or shoter than 5 characters.";
return false;
}
} else {
$username = $account['username'];
$this->db->from('account');
$this->db->where('username', $username);
if (count($this->db->get()->result())) {
$this->latestErr = "Email has already taken.";
return false;
}
$this->db->insert('account', buildBaseParam(["id" => $id, "username" => $account['username'], "password" => md5($account['password']), "status" => 0], $id));
$this->db->insert('person', buildBaseParam(["id" => $id, "firstname" => $account['firstname'], "lastname" => $account['lastname']], $id));
$this->db->insert('accountrole', buildBaseParam(["id" => gen_uuid(), "accountid" => $id, "role" => strtolower($account['role'])], $id));
}
return true;
}
示例2: initSession
private function initSession(){
// init a session id if we don't already have one
if(!isset($_SESSION["uuid"])){
// all our access will be through this uuid
$_SESSION["uuid"] = gen_uuid();
}
}
示例3: submit_data_to_google
function submit_data_to_google($order_data, $content_data, $order_source)
{
// Формирование данных для аналитики
$gaurl = 'https://ssl.google-analytics.com/collect';
// https://developers.google.com/analytics/devguides/collection/protocol/v1/reference#transport
$gaid = '';
// Идентификатор GA
$gav = '1';
// Версия GA
$gasitename = '';
// Название сайта
// Список параметров https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#
$cid = gen_uuid();
// Client ID
$uid = gen_uuid();
// User ID
$cn = '';
// Campaign Name
$cs = '';
// Campaign Source
$cm = '';
// Campaign Medium
// https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#in
$data_transaction = array('v' => $gav, 'tid' => $gaid, 'cid' => $cid, 'uid' => $uid, 'cn' => $cn, 'cs' => $cs, 'cm' => $cm, 't' => 'transaction', 'ti' => '', 'ta' => $gasitename, 'tr' => '', 'ts' => '', 'tt' => '');
$data_item = array('v' => $gav, 'tid' => $gaid, 'cid' => $cid, 'uid' => $uid, 'cn' => $cn, 'cs' => $cs, 'cm' => $cm, 't' => 'item', 'ti' => '', 'ic' => '', 'in' => '', 'ip' => '', 'iq' => '', 'iv' => 'tea');
// Выполнить запрос к GA
$result_transaction = execute_request_to_google($data_transaction, $gaurl);
$result_item = execute_request_to_google($data_item, $gaurl);
// Вернуть результат данных отправленных в аналитику
return array('result_transaction' => $result_transaction, 'result_item' => $result_item, 'data_transaction' => $data_transaction, 'data_item' => $data_item);
}
示例4: edit
public function edit($arg = null)
{
$account = new stdClass();
if ($arg != null) {
$account = $this->Mdl_Accounts->get($arg);
$account->isNew = false;
} else {
$account->isNew = true;
$account->id = gen_uuid();
$account->username = "";
$account->firstname = "";
$account->lastname = "";
$account->status = 1;
$account->role = "administrator";
}
$arrRoles = ["Free user", "Concreteprotector"];
$account->rolesHTML = "<select name='role'>";
foreach ($arrRoles as $role) {
$selected = "";
$selected = $role == $account->role ? " selected " : "";
$Role = ucfirst($role);
$account->rolesHTML .= "<option {$selected} value='{$role}'>{$Role}</option>";
}
$account->rolesHTML .= "</select>";
parent::initView(get_class($this) . '/edit', 'Accounts', 'Edit account information.', $account);
parent::loadView();
}
示例5: add_data_header
function add_data_header($link)
{
$access_id = gen_uuid();
$delete_code = gen_uuid();
$sql = "INSERT INTO `impact`.`header_data` (`id`, `access_id`, `delete_code`, `created`) VALUES (NULL, '" . $access_id . "', '" . $delete_code . "', CURRENT_TIMESTAMP)";
$result = $link->query($sql);
return array("id" => mysqli_insert_id($link), "access_id" => $access_id, "delete_code" => $delete_code);
}
示例6: edit
public function edit($id = null)
{
$record = new stdClass();
$ings = $this->Mdl_Systems->getIngredients();
if ($id != null) {
$record = $this->Mdl_Systems->get($id);
$record->isNew = false;
} else {
$record->isNew = true;
$record->id = gen_uuid();
$record->name = "";
$record->saleprice = "";
$record->share = "f";
$record->status = true;
}
$share = "";
$active = "";
if ($record->share == "t") {
$share = "checked";
}
if ($record->status) {
$active = "checked";
}
$record->shareHTML = "<input {$share} id='share' type='checkbox' name='_share'><label for='share'> Share</label>";
$record->activeHTML = "<input {$active} id='status' type='checkbox' name='_status'><label for='status'> Active</label>";
/*
Colors....
*/
$record->ingredientsHTML = "";
foreach ($ings as $ing) {
$checked = "";
$extra = "";
$factor = "";
if (!$record->isNew) {
foreach ($record->selIngs as $selIng) {
if ($selIng->ingredientid == $ing->id) {
$checked = "checked";
$extra = $selIng->extra;
$factor = $selIng->factor;
}
}
}
$record->ingredientsHTML .= "<div class='row ing'>";
$record->ingredientsHTML .= "<div class='col-md-8'>";
$record->ingredientsHTML .= "<input {$checked} id='{$ing->id}' type='checkbox' name='{$ing->id}' value='1'><label for='{$ing->id}'> {$ing->name}</label><br>";
$record->ingredientsHTML .= "</div>";
$record->ingredientsHTML .= "<div class='col-md-2'>";
$record->ingredientsHTML .= "<div class='row item'><div class='col-md-4'><label >{$ing->purchaseprice}</label></div><div class='col-md-8'><input class='_extra' name='{$ing->id}' value='{$extra}'/></div>";
$record->ingredientsHTML .= "</div></div>";
$record->ingredientsHTML .= "<div class='col-md-2'>";
$record->ingredientsHTML .= "<div class='row item'><div class='col-md-4'><label >Units extra</label></div><div class='col-md-8'><input class='_factor' name='{$ing->id}' value='{$factor}'/></div>";
$record->ingredientsHTML .= "</div></div>";
$record->ingredientsHTML .= "</div>";
}
parent::initView("Systems/edit", "Systems", 'Edit Systems information.', $record);
parent::loadView();
}
示例7: renderContent
protected function renderContent()
{
if (isset($this->block) && $this->block != null) {
$model = new UserAvatarForm();
if (isset($_POST['UserAvatarForm'])) {
$model->attributes = $_POST['UserAvatarForm'];
$model->image = CUploadedFile::getInstance($model, 'image');
if ($model->validate()) {
//Get the User Id to determine the folder
$folder = user()->id >= 1000 ? (string) (round(user()->id / 1000) * 1000) : '1000';
$filename = user()->id . '_' . gen_uuid();
if (!(file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder) && AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder)) {
mkdir(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder, 0777, true);
}
if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename . '.' . strtolower(CFileHelper::getExtension($model->image->name)))) {
$filename .= '_' . time();
}
$filename = $filename . '.' . strtolower(CFileHelper::getExtension($model->image->name));
$path = $folder . DIRECTORY_SEPARATOR . $filename;
if ($model->image->saveAs(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $path)) {
//Generate thumbs
//
GxcHelpers::generateAvatarThumb($filename, $folder, $filename);
//So we will start to check the info from the user
$current_user = User::model()->findByPk(user()->id);
if ($current_user) {
if ($current_user->avatar != null && $current_user->avatar != '') {
//We will delete the old avatar here
$old_avatar_path = $current_user->avatar;
$current_user->avatar = $path;
if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $old_avatar_path)) {
@unlink(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $old_avatar_path);
}
//Delete old file Sizes
$sizes = AvatarSize::getSizes();
foreach ($sizes as $size) {
if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $old_avatar_path)) {
@unlink(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $old_avatar_path);
}
}
} else {
//$current_user
$current_user->avatar = $path;
}
$current_user->save();
}
} else {
throw new CHttpException('503', 'Error while uploading!');
}
}
}
$this->render(BlockRenderWidget::setRenderOutput($this), array('model' => $model));
} else {
echo '';
}
}
示例8: alphaId
public static function alphaId($len = 10)
{
$hex = md5("statme" . uniqid("", true));
$pack = pack('H*', $hex);
$tmp = base64_encode($pack);
$uid = preg_replace("#(*UTF8)[^A-Za-z0-9]#", "", $tmp);
$len = max(4, min(128, $len));
while (strlen($uid) < $len) {
$uid .= gen_uuid(22);
}
return substr($uid, 0, $len);
}
示例9: edit
public function edit($id = null)
{
$color = new stdClass();
if ($id != null) {
$color = $this->Mdl_Patterns->get($id);
$color->isNew = false;
} else {
$color->isNew = true;
$color->id = gen_uuid();
$color->name = "";
}
parent::initView("Patterns/edit", "Patterns", 'Edit pattern information.', $color);
parent::loadView();
}
示例10: store_result
public function store_result($result_data)
{
$success = TRUE;
// Generate unique id from application/helpers/uuid_helper.php
$uuid = gen_uuid();
$result_data['resid'] = $uuid;
// Transaction
$this->db->trans_start();
if (!$this->db->insert('results', $result_data)) {
$success = FALSE;
}
$this->db->trans_complete();
return $success;
}
示例11: edit
public function edit($id = null)
{
$color = new stdClass();
if ($id != null) {
$color = $this->Mdl_Colors->get($id);
$color->isNew = false;
} else {
$color->isNew = true;
$color->id = gen_uuid();
$color->name = "";
}
parent::initView(get_class($this) . '/edit', 'Colors', 'Edit color information.', $color);
parent::loadView();
}
示例12: edit
public function edit($id = null)
{
$record = new stdClass();
$colors = $this->Mdl_Ingredients->getColors();
$patterns = $this->Mdl_Ingredients->getPatterns();
if ($id != null) {
$record = $this->Mdl_Ingredients->get($id);
$record->isNew = false;
} else {
$record->isNew = true;
$record->id = gen_uuid();
$record->name = "";
$record->coverage = "";
$record->purchaseprice = "";
}
/*
Colors....
*/
$record->colorsHTML = "";
foreach ($colors as $col) {
$checked = "";
if (!$record->isNew) {
foreach ($record->selectedColors as $selCol) {
if ($selCol->colorid == $col->id) {
$checked = "checked";
}
}
}
$record->colorsHTML .= "<input {$checked} id='{$col->id}' type='checkbox' name='{$col->id}' value='1'><label for='{$col->id}'> {$col->name}</label><br>";
}
/*
Patterns....
*/
$record->patternsHTML = "";
foreach ($patterns as $pat) {
$checked = "";
if (!$record->isNew) {
foreach ($record->selectedPatterns as $selPat) {
if ($selPat->patternid == $pat->id) {
$checked = "checked";
}
}
}
$record->patternsHTML .= "<input {$checked} id='{$pat->id}' type='checkbox' name='{$pat->id}' value='1'><label for='{$pat->id}'> {$pat->name}</label><br>";
}
parent::initView("Ingredients/edit", "Ingredients", 'Edit ingredient information.', $record);
parent::loadView();
}
示例13: activate_addon
function activate_addon()
{
$guid_option_name = "lfeguid";
$base_url_option_name = "base_url";
if (!get_option($guid_option_name)) {
add_option($guid_option_name, gen_uuid());
}
$base_url = 'http://apps.lfe.com';
if (get_option($base_url_option_name)) {
update_option($base_url_option_name, $base_url);
} else {
add_option($base_url_option_name, $base_url);
}
//file_get_contents
wp_remote_get($base_url . '/WidgetEndPoint/Plugin/Install?' . http_build_query(array('uid' => get_option($guid_option_name), 'domain' => get_site_url(), 'type' => 3, 'version' => get_bloginfo('version'), 'pluginVersion' => "1.0.0")));
}
示例14: api_createSession
function api_createSession($uid)
{
include "db_config.php";
mysql_set_charset('UTF8');
$date = date("Y-m-d H:i:s");
//Date Actuel
$UUID = gen_uuid();
// génération UUID
$conn = mysql_connect($DB_host, $DB_login, $DB_pass);
$db = mysql_select_db($DB_select, $conn);
if (!$conn) {
die('Erreur de connexion: ' . mysql_error());
}
$SQL = "INSERT INTO session(UUID,dateSession,uid) VALUES ('{$UUID}', '{$date}',{$uid})";
$reponse = mysql_query($SQL);
return $UUID;
}
示例15: BuildOCPSoap
function BuildOCPSoap()
{
/*
Select the right region for your CRM
crmna:dynamics.com - North America
crmemea:dynamics.com - Europe, the Middle East and Africa
crmapac:dynamics.com - Asia Pacific
*/
$region = 'crmapac:dynamics.com';
$OCPRequest = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:MessageID>urn:uuid:%s</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">%s</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>%sZ</u:Created>
<u:Expires>%sZ</u:Expires>
</u:Timestamp>
<o:UsernameToken u:Id="uuid-cdb639e6-f9b0-4c01-b454-0fe244de73af-1">
<o:Username>%s</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%s</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>' . $region . '</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>';
$OCPRequest = sprintf($OCPRequest, gen_uuid(), 'https://login.microsoftonline.com/RST2.srf', getCurrentTime(), getNextDayTime(), $this->username, $this->password);
return $OCPRequest;
}