当前位置: 首页>>代码示例>>PHP>>正文


PHP unique_id函数代码示例

本文整理汇总了PHP中unique_id函数的典型用法代码示例。如果您正苦于以下问题:PHP unique_id函数的具体用法?PHP unique_id怎么用?PHP unique_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了unique_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 public function send()
 {
     if (!$this->_to || !$this->_subject || !$this->_view) {
         return FALSE;
     }
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         ini_set('sendmail_from', $this->_from);
     }
     $headers = array('From: ' . $this->_from, 'Reply-to: ' . $this->_from);
     $this->config->base_url = 'http://' . $_SERVER['HTTP_HOST'] . url();
     $this->template->parse_data($this->_data, $this->load);
     $message = $html = $this->load->view('emails/' . $this->_view, $this->_data);
     $text = $this->load->view('emails/' . $this->_view . '.txt', $this->_data);
     if ($text) {
         $headers[] = 'MIME-Version: 1.0';
         $headers[] = 'Content-Type: multipart/alternative;' . "\n" . ' boundary="' . ($boundary = '--------' . unique_id()) . '"';
         $message = '--' . $boundary . "\n";
         $message .= 'Content-Type: text/plain; charset=UTF-8; format=flowed' . "\n\n";
         $message .= str_replace('\\r', '', $text) . "\n\n";
         $message .= '--' . $boundary . "\n";
         $message .= 'Content-Type: text/html; charset=UTF-8;' . "\n\n";
         $message .= str_replace('\\r', '', $html) . "\n\n";
     }
     $result = mail(trim_word($this->_to, ', '), $this->config->nf_name . ' :: ' . $this->_subject, wordwrap($message, 70), implode("\r\n", $headers));
     $this->reset();
     return $result;
 }
开发者ID:agreements,项目名称:neofrag-cms,代码行数:27,代码来源:email.php

示例2: confirm_image

    public function confirm_image($max_attempts, &$confirm_id)
    {
        global $db, $user, $template;
        global $phpbb_root_path, $phpEx;
        $user->confirm_gc($this->confirm_type);
        if ($max_attempts) {
            $sql = 'SELECT COUNT(session_id) AS attempts
				FROM ' . CONFIRM_TABLE . "\n\t\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\t\tAND confirm_type = {$this->confirm_type}";
            $result = $db->sql_query($sql);
            $attempts = (int) $db->sql_fetchfield('attempts');
            $db->sql_freeresult($result);
            if ($attempts > $max_attempts) {
                return false;
            }
        }
        $code = gen_rand_string(mt_rand(5, 8));
        $confirm_id = md5(unique_id($user->ip));
        $seed = hexdec(substr(unique_id(), 4, 10));
        // compute $seed % 0x7fffffff
        $seed -= 0x7fffffff * floor($seed / 0x7fffffff);
        $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array('confirm_id' => (string) $confirm_id, 'session_id' => (string) $user->session_id, 'confirm_type' => (int) $this->confirm_type, 'code' => (string) $code, 'seed' => (int) $seed));
        $db->sql_query($sql);
        $template->assign_var('S_CONFIRM_CODE', true);
        return '<img src="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=confirm&amp;id=' . $confirm_id . '&amp;type=' . $this->confirm_type) . '" alt="" title="" />';
    }
开发者ID:phpbbmodders-30x-mods,项目名称:modders-libs,代码行数:25,代码来源:phpbb_confirm_handler.php

示例3: uploadAttributes

 function uploadAttributes($file_name, $file_size, $path, $id = '')
 {
     $access_key_id = $this->getOption('AWSAccessKeyID');
     $secret_access_key = $this->getOption('AWSSecretAccessKey');
     $bucket = $this->getOption('S3Bucket');
     if (!($bucket && $access_key_id && $secret_access_key)) {
         throw new UnexpectedValueException('Configuration options AWSAccessKeyID, AWSSecretAccessKey, SQSQueueURL, S3Bucket required');
     }
     $extension = file_extension($file_name);
     $mime = mime_from_path($file_name);
     if (!($mime && $extension)) {
         throw new UnexpectedValueException('Could not determine mime type or extension of: ' . $file_name);
     }
     if (!$id) {
         $id = unique_id($mime);
     }
     $s3_options = array();
     $s3_options['bucket'] = $bucket;
     $s3_options['AWSAccessKeyId'] = $access_key_id;
     $s3_options['AWSSecretAccessKey'] = $secret_access_key;
     $s3_options['uniq_id'] = $id;
     $s3_options['path'] = $path . '.' . $extension;
     $s3_options['mime'] = $mime;
     $s3data = s3_upload_data($s3_options);
     $result = '';
     if (!empty($s3data)) {
         $s3data['mime'] = $mime;
         $s3data['keyid'] = $access_key_id;
         //$s3data['id'] = $id;
         foreach ($s3data as $k => $v) {
             $result .= ' ' . $k . '="' . $v . '"';
         }
     }
     return $result;
 }
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:35,代码来源:S3.php

示例4: write

 public function write($data)
 {
     if (!isset($data['id']) || empty($data['id'])) {
         $data['id'] = unique_id();
     }
     return parent::create($data);
 }
开发者ID:shuai959980629,项目名称:TTDV1,代码行数:7,代码来源:Admin_log_model.php

示例5: add_apa

 public function add_apa($type, $options = array())
 {
     //generate unique id
     $unique_id = unique_id();
     //check if all necessary information are given
     if (!$this->type_exists($type)) {
         return false;
     }
     $required = $this->get_apa_type($type)->required();
     foreach ($required as $field) {
         if (!isset($options[$field])) {
             return false;
         }
     }
     $options['type'] = $type;
     //run pre-save-hook
     $options = $this->get_apa_type($type)->pre_save_func($unique_id, $options);
     //add apa to apatab
     $this->apa_tab[$unique_id] = $options;
     //save apatab
     $this->save_apa_tab($this->apa_tab);
     //maybe layout change necessary
     $this->get_apa_type($type)->add_layout_changes($unique_id);
     //run apa?
     return true;
 }
开发者ID:rswiders,项目名称:core,代码行数:26,代码来源:auto_point_adjustments.class.php

示例6: _post

 function _post($type)
 {
     $dir_jobs_queued = $this->_options['DirJobsQueued'];
     $job_id = empty($this->_options['JobID']) ? '' : $this->_options['JobID'];
     // make sure needed configuration is there
     if (!$dir_jobs_queued) {
         throw new UnexpectedValueException('Configuration option DirJobsQueued required');
     }
     // if no JobID configuration option was set make up an ID
     if (!$job_id) {
         $job_id = unique_id($type . 'job');
     }
     $path = end_with_slash($dir_jobs_queued);
     $path .= $job_id . '.xml';
     // make sure we have a directory to write the job xml file to
     if (!safe_path($path)) {
         throw new RuntimeException('Could not create path: ' . $path);
     }
     // build job xml and write to file
     $xml_str = $this->_xmlBody($type);
     if (!@file_put_contents($path, $xml_str)) {
         throw new RuntimeException('Could not create file: ' . $path);
     }
     return $job_id;
 }
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:25,代码来源:Local.php

示例7: main

 function main($id, $mode)
 {
     global $config, $template, $phpbb_admin_path, $phpEx;
     $collect_url = "http://www.phpbb.com/stats/receive_stats.php";
     $this->tpl_name = 'acp_send_statistics';
     $this->page_title = 'ACP_SEND_STATISTICS';
     // generate a unique id if necessary
     if (!isset($config['questionnaire_unique_id'])) {
         $install_id = unique_id();
         set_config('questionnaire_unique_id', $install_id);
     } else {
         $install_id = $config['questionnaire_unique_id'];
     }
     $collector = new phpbb_questionnaire_data_collector($install_id);
     // Add data provider
     $collector->add_data_provider(new phpbb_questionnaire_php_data_provider());
     $collector->add_data_provider(new phpbb_questionnaire_system_data_provider());
     $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config));
     $template->assign_vars(array('U_COLLECT_STATS' => $collect_url, 'RAW_DATA' => $collector->get_data_for_form(), 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}")));
     $raw = $collector->get_data_raw();
     foreach ($raw as $provider => $data) {
         if ($provider == 'install_id') {
             $data = array($provider => $data);
         }
         $template->assign_block_vars('providers', array('NAME' => htmlspecialchars($provider)));
         foreach ($data as $key => $value) {
             if (is_array($value)) {
                 $value = utf8_wordwrap(serialize($value), 75, "\n", true);
             }
             $template->assign_block_vars('providers.values', array('KEY' => utf8_htmlspecialchars($key), 'VALUE' => utf8_htmlspecialchars($value)));
         }
     }
 }
开发者ID:ahmatjan,项目名称:Crimson,代码行数:33,代码来源:acp_send_statistics.php

示例8: __construct

 public function __construct()
 {
     parent::__construct();
     if ($this->config->nf_http_authentication && is_null($this->session('user_id')) && $this->session('session', 'http_authentication')) {
         $this->session->destroy('session', 'http_authentication');
         if (isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
             $login = $_SERVER['PHP_AUTH_USER'];
             $password = $_SERVER['PHP_AUTH_PW'];
         } else {
             if (isset($_SERVER['REDIRECT_REMOTE_USER']) && preg_match('/Basic (.*)/', $_SERVER['REDIRECT_REMOTE_USER'], $matches)) {
                 list($login, $password) = explode(':', base64_decode($matches[1]));
             }
         }
         if (isset($login, $password)) {
             $user = $this->db->select('user_id', 'password', 'salt')->from('nf_users')->where('last_activity_date <>', 0)->where('deleted', FALSE)->where('BINARY username', $login, 'OR', 'BINARY email', $login)->row();
             if ($user) {
                 if (!$user['salt'] && $this->load->library('password')->is_valid($password, $user['password'], FALSE)) {
                     $this->db->where('user_id', (int) $user['user_id'])->update('nf_users', array('password' => $user['password'] = $this->password->encrypt($password . ($salt = unique_id())), 'salt' => $user['salt'] = $salt));
                 }
                 if ($this->load->library('password')->is_valid($password . $user['salt'], $user['password'])) {
                     $this->login((int) $user['user_id'], FALSE);
                     if ($this->config->request_url == 'user/logout.html') {
                         redirect();
                     }
                 }
             }
         }
     }
     $this->_init();
 }
开发者ID:agreements,项目名称:neofrag-cms,代码行数:30,代码来源:user.php

示例9: _row

	public function _row($filepath, $filename) {
		$row = (object) array(
			'extension' => extension($filename),
			'name' => strtolower($filename),
			'random' => time() . '_' . substr(md5(unique_id()), 0, 10)
		);

		$row->filename = $row->random . '.' . $row->extension;
		$row->filepath = $filepath . $row->filename;

		return $row;
	}
开发者ID:nopticon,项目名称:rockr,代码行数:12,代码来源:upload.php

示例10: quick_reply

/**
 * This function will load everything needed for the evil quick reply
 *
 * @param int $topic_id
 * @param int $forum_id
 * @param array $topic_data
 */
function quick_reply($topic_id, $forum_id, &$topic_data)
{
    global $template, $user, $auth, $db;
    global $phpbb_root_path, $phpEx, $config;
    // Some little config for the quick reply, allows the admin to change these default values through the database.
    $qr_config = array('enabled' => true, 'display_subject' => true, 'hide_box' => false, 'resize' => false);
    // do evil_qr_ prefixed of the config values exist in $config
    // /me slaps highway of life
    foreach (array_keys($qr_config) as $key) {
        if (isset($config['evil_qr_' . $key])) {
            $qr_config[$key] = $config['evil_qr_' . $key];
        }
    }
    // Check if user has reply permissions for this forum or the topic is locked (thanks damnian)
    if (!$auth->acl_get('f_reply', $forum_id) || $topic_data['topic_status'] == ITEM_LOCKED && !$auth->acl_get('m_lock', $forum_id) || !$qr_config['enabled']) {
        return;
    }
    // Hidden fields
    $s_hidden_fields = array('t' => $topic_id, 'f' => $forum_id, 'mode' => 'reply', 'lastclick' => time(), 'icon' => 0);
    // Set preferences such as allow smilies, bbcode, attachsig
    $reply_prefs = array('disable_bbcode' => $config['allow_bbcode'] && $user->optionget('bbcode') ? false : true, 'disable_smilies' => $config['allow_smilies'] && $user->optionget('smilies') ? false : true, 'disable_magic_url' => false, 'attach_sig' => $config['allow_sig'] && $user->optionget('attachsig') ? true : false, 'notify' => $config['allow_topic_notify'] && ($user->data['user_notify'] || isset($topic_data['notify_status'])) ? true : false, 'lock_topic' => $topic_data['topic_status'] == ITEM_LOCKED && $auth->acl_get('m_lock', $forum_id) ? true : false);
    foreach ($reply_prefs as $name => $value) {
        if ($value) {
            $s_hidden_fields[$name] = 1;
        }
    }
    $subject = (strpos($topic_data['topic_title'], 'Re: ') !== 0 ? 'Re: ' : '') . censor_text($topic_data['topic_title']);
    if (!$qr_config['display_subject']) {
        // /me is a show-off
        list($s_hidden_fields['subject'], $subject) = array($subject, '');
    }
    // Confirmation code handling (stolen from posting.php)
    if ($config['enable_post_confirm'] && !$user->data['is_registered']) {
        // Show confirm image
        $sql = 'DELETE FROM ' . CONFIRM_TABLE . "\r\n\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\r\n\t\t\t\tAND confirm_type = " . CONFIRM_POST;
        $db->sql_query($sql);
        // Generate code
        $code = gen_rand_string(mt_rand(5, 8));
        $confirm_id = md5(unique_id($user->ip));
        $seed = hexdec(substr(unique_id(), 4, 10));
        // compute $seed % 0x7fffffff
        $seed -= 0x7fffffff * floor($seed / 0x7fffffff);
        $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array('confirm_id' => (string) $confirm_id, 'session_id' => (string) $user->session_id, 'confirm_type' => (int) CONFIRM_POST, 'code' => (string) $code, 'seed' => (int) $seed));
        $db->sql_query($sql);
        $template->assign_vars(array('S_CONFIRM_CODE' => true, 'CONFIRM_ID' => $confirm_id, 'CONFIRM_IMAGE' => '<img src="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=confirm&amp;id=' . $confirm_id . '&amp;type=' . CONFIRM_POST) . '" alt="" title="" />'));
    }
    // new RC6/RC7 stuff
    add_form_key('posting');
    // Page title & action URL, include session_id for security purpose
    $s_action = append_sid("{$phpbb_root_path}posting.{$phpEx}", false, true, $user->session_id);
    // Assign template variables
    $template->assign_vars(array('QR_SUBJECT' => $subject, 'S_QR_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_QR_POST_ACTION' => $s_action, 'S_QR_ENABLED' => $qr_config['enabled'], 'S_QR_SUBJECT' => $qr_config['display_subject'], 'S_QR_HIDE_BOX' => $qr_config['hide_box'], 'S_QR_RESIZE' => $qr_config['resize']));
}
开发者ID:sietf,项目名称:sietf.org,代码行数:60,代码来源:functions_quick_reply.php

示例11: mybb_import_attachment

function mybb_import_attachment($source)
{
	global $convert_row, $convert;

	$target = phpbb_user_id($convert_row['uid']) . '_' . md5(unique_id());
	import_attachment($source, $target);

	if (mybb_has_thumbnail($convert_row['thumbnail']))
	{
		_import_check('upload_path', $convert_row['thumbnail'], 'thumb_' . $target);
	}

	return $target;
}
开发者ID:phimax,项目名称:zoroak,代码行数:14,代码来源:functions_mybb16.php

示例12: _construct

 public function _construct()
 {
     if (empty($this->name)) {
         $this->name = unique_id();
     }
     if (empty($this->id)) {
         $this->id = unique_id();
     }
     $acc_opts = array();
     foreach ($this->accordion_opts as $opt) {
         $acc_opts[$opt] = $this->{$opt};
     }
     $this->out = $this->jquery->Accordion($this->name, $this->options, $acc_opts);
 }
开发者ID:rswiders,项目名称:core,代码行数:14,代码来源:haccordion.class.php

示例13: phpbb_hash

function phpbb_hash($password)
{
    $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    $random_state = unique_id();
    $random = '';
    $count = 6;
    $random = '';
    for ($i = 0; $i < $count; $i += 16) {
        $random_state = md5(unique_id() . $random_state);
        $random .= pack('H*', md5($random_state));
    }
    $random = substr($random, 0, $count);
    $hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
    return $hash;
}
开发者ID:huiwei19,项目名称:oursustc-php,代码行数:15,代码来源:user.php

示例14: clean_filename

 /**
  * Cleans destination filename
  * 
  * @access public
  * @param real|unique $mode real creates a realname, filtering some characters, lowering every character. Unique creates an unique filename
  * @param string $prefix Prefix applied to filename
  */
 function clean_filename($mode = 'unique', $prefix = '')
 {
     if ($this->init_error) {
         return;
     }
     switch ($mode) {
         case 'real':
             // Replace any chars which may cause us problems with _
             $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
             $this->realname = rawurlencode(str_replace($bad_chars, '_', strtolower($this->realname)));
             $this->realname = preg_replace("/%(\\w{2})/", '_', $this->realname);
             $this->realname = $prefix . $this->realname . '_.' . $this->extension;
             break;
         case 'unique':
         default:
             $this->realname = $prefix . md5(unique_id()) . '.' . $this->extension;
     }
 }
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:25,代码来源:functions_upload.php

示例15: upload

 public function upload($files, $dir = NULL, &$filename = NULL, $file_id = NULL, $var = NULL)
 {
     if (!file_exists($dir = './upload/' . ($dir ?: 'unknow'))) {
         if (!mkdir($dir, 0777, TRUE)) {
             return FALSE;
         }
     }
     do {
         $file = unique_id() . '.' . extension(basename($var ? $files['name'][$var] : $files['name']));
     } while (file_exists($filename = $dir . '/' . $file));
     if (move_uploaded_file($var ? $files['tmp_name'][$var] : $files['tmp_name'], $filename)) {
         if ($file_id) {
             $this->_unlink($file_id);
             $this->db->where('file_id', $file_id)->update('nf_files', array('user_id' => $this->user() ? $this->user('user_id') : NULL, 'path' => $filename, 'name' => $var ? $files['name'][$var] : $files['name']));
             return $file_id;
         } else {
             return $this->add($filename, $var ? $files['name'][$var] : $files['name']);
         }
     }
     return FALSE;
 }
开发者ID:agreements,项目名称:neofrag-cms,代码行数:21,代码来源:file.php


注:本文中的unique_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。