本文整理汇总了PHP中Ak::randomString方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::randomString方法的具体用法?PHP Ak::randomString怎么用?PHP Ak::randomString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::randomString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setImage
public function setImage($image_path)
{
$this->Image = new AkImage($image_path);
$this->Image->transform('resize', array('size' => '24x24'));
$this->_tmp_file = AK_TMP_DIR . DS . '__AkImageColorScheme_' . Ak::randomString(32) . '.jpg';
$this->Image->save($this->_tmp_file);
}
示例2: Test_of_encrypt_decrypt
public function Test_of_encrypt_decrypt()
{
$original = "Este es el texto que quiero encriptar";
$this->assertEqual(Ak::decrypt(Ak::encrypt($original)), $original);
$key = Ak::randomString(20);
$file = file_get_contents(__FILE__);
$ecripted = Ak::encrypt($file, $key);
$this->assertEqual(Ak::decrypt($ecripted, $key), $file);
}
示例3: trace
/**
* Trace helper function for development purposes
*
* @access public
* @static
* @param string $text Helper text
* @param string $line Helper line
* @param string $file Helper file
* @return echoes result to screen
*/
static function trace($text = null, $line = null, $file = null, $method = null, $escape_html_entities = true)
{
static $counter = 0;
if (AK_PRODUCTION_MODE) {
return;
}
$html_entities_function = $escape_html_entities ? 'htmlentities' : 'trim';
list($default_file, $default_line, $default_method) = self::getLastFileAndLineAndMethod();
$default_method = is_bool($text) || empty($text) ? 'var_dump' : $default_method;
$line = is_null($line) ? $default_line : $line;
$file = is_null($file) ? $default_file : $file;
$method = is_null($method) ? $default_method : $method;
if (AK_CLI) {
$text = self::dump($text, 'print_r');
} elseif (!empty($text) && !is_scalar($text)) {
$rand = Ak::randomString();
$formatted = '';
$methods = array('print_r', 'var_dump', 'var_export');
foreach ($methods as $method) {
$pre_style = 'display:none;';
if (defined('AK_TRACE_DUMP_METHOD')) {
if (AK_TRACE_DUMP_METHOD == $method) {
$pre_style = '';
}
} elseif ($method == 'print_r') {
$pre_style = '';
}
$element_id = $method . '_' . $rand;
$formatted .= "<div style='margin:10px;'><a href='javascript:void(0);' onclick='e_{$element_id} = document.getElementById(\"{$element_id}\"); e_{$element_id}.style.display = (e_{$element_id}.style.display == \"none\"?\"block\":\"none\");' title='Set the constant AK_TRACE_DUMP_METHOD to your favourite default method'>{$method}</a><br />" . '<pre style="' . $pre_style . '" id="' . $element_id . '">' . $html_entities_function(self::dump($text, $method)) . '</pre></div>';
}
$text = $formatted;
} elseif (is_bool($text) || empty($text)) {
$text = '<pre style="margin:10px;">' . $html_entities_function(self::dump($text, $default_method)) . '</pre>';
} elseif (is_scalar($text)) {
$text = '<pre style="margin:10px;">' . $html_entities_function($text) . '</pre>';
}
if (!isset($text)) {
$counter++;
$text = '';
} else {
$text = AK_CLI ? '---> ' . $text : $text;
}
$include_file_and_line = strlen(trim($file . $line)) > 0;
if ($include_file_and_line) {
echo AK_CLI ? "----------------\n{$file} ({$line}):\n {$text}\n----------------\n" : "<div style='background-color:#fff;margin:10px;color:#000;font-family:sans-serif;border:3px solid #fc0;font-size:12px;'><div style='background-color:#ffc;padding:10px;color:#000;font-family:sans-serif;'>{$file} <span style='font-weight:bold'>{$line}</span></div>" . $text . "</div>\n";
} else {
echo AK_CLI ? "----------------\n {$text}\n----------------\n" : "<div style='background-color:#fff;margin:10px;color:#000;font-family:sans-serif;border:1px solid #ccc;font-size:12px;'>" . $text . "</div>\n";
}
}
示例4: init
function init()
{
$this->ext = empty($this->ext) ? 'doc' : strtolower(trim($this->ext, '.'));
$this->tmp_name = Ak::randomString();
if (empty($this->source_file)) {
$this->source_file = AK_CACHE_DIR . DS . $this->tmp_name . '.' . $this->ext;
Ak::file_put_contents($this->source_file, $this->source);
$this->delete_source_file = true;
$this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file;
} else {
$this->delete_source_file = false;
$this->keep_destination_file = true;
}
$this->convert_to = 'txt';
$this->destination_file_name = empty($this->destination_file_name) ? $this->tmp_name . '.' . $this->convert_to : $this->destination_file_name . (strstr($this->destination_file_name, '.') ? '' : '.' . $this->convert_to);
$this->destination_file = empty($this->destination_file) ? AK_CACHE_DIR . DS . $this->destination_file_name : $this->destination_file;
}
示例5: init
public function init()
{
$this->ext = empty($this->ext) ? 'xls' : strtolower(trim($this->ext, '.'));
$this->tmp_name = Ak::randomString();
if (empty($this->source_file)) {
$this->source_file = AK_TMP_DIR . DS . $this->tmp_name . '.' . $this->ext;
Ak::file_put_contents($this->source_file, $this->source);
$this->delete_source_file = true;
$this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file;
} else {
$this->delete_source_file = false;
$this->keep_destination_file = true;
}
$this->convert_to = !empty($this->convert_to) && empty($this->_file_type_codes[$this->convert_to]) ? 'csv' : (empty($this->convert_to) ? 'csv' : $this->convert_to);
$this->destination_file_name = empty($this->destination_file_name) ? $this->tmp_name . '.' . $this->convert_to : $this->destination_file_name . (strstr($this->destination_file_name, '.') ? '' : '.' . $this->convert_to);
$this->destination_file = empty($this->destination_file) ? AK_TMP_DIR . DS . $this->destination_file_name : $this->destination_file;
}
示例6: init
function init()
{
if (empty($this->handler)) {
require_once AK_VENDOR_DIR . DS . 'Excel' . DS . 'reader.php';
$this->handler = new Spreadsheet_Excel_Reader();
$this->handler->setRowColOffset(empty($this->first_column) ? 0 : $this->first_column);
}
$this->tmp_name = Ak::randomString();
if (empty($this->source_file)) {
$this->source_file = AK_CACHE_DIR . DS . $this->tmp_name . '.xls';
Ak::file_put_contents($this->source_file, $this->source);
$this->delete_source_file = true;
$this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file;
} else {
$this->delete_source_file = false;
$this->keep_destination_file = true;
}
}
示例7: _setAssociatedMemberId
public function _setAssociatedMemberId(&$Member)
{
if (empty($Member->__hasAndBelongsToManyMemberId)) {
$Member->__hasAndBelongsToManyMemberId = Ak::randomString();
}
$object_id = $Member->getId();
if (!empty($object_id)) {
$this->associated_ids[$object_id] = $Member->__hasAndBelongsToManyMemberId;
}
}
示例8: _setAssociatedMemberId
public function _setAssociatedMemberId(&$Member)
{
if (empty($Member->__hasManyMemberId)) {
$Member->__hasManyMemberId = Ak::randomString();
}
$object_id = method_exists($Member, 'getId') ? $Member->getId() : null;
if (!empty($object_id)) {
$this->associated_ids[$object_id] = $Member->__hasManyMemberId;
}
}
示例9: uncompress
function uncompress($compressed_data, $format = 'gzip')
{
$key = Ak::randomString(15);
$compressed_file = AK_TMP_DIR . DS . 's' . $key;
$uncompressed_file = AK_TMP_DIR . DS . 'd' . $key;
if (Ak::file_put_contents($compressed_file, $compressed_data, array('base_path' => AK_TMP_DIR))) {
$compressed = gzopen($compressed_file, "r");
$uncompressed = fopen($uncompressed_file, "w");
while (!gzeof($compressed)) {
$string = gzread($compressed, 4096);
fwrite($uncompressed, $string, strlen($string));
}
gzclose($compressed);
fclose($uncompressed);
} else {
trigger_error(Ak::t('Could not write to temporary directory for generating uncompressing file using Ak::uncompress(). Please provide write access to %dirname', array('%dirname' => AK_TMP_DIR)), E_USER_ERROR);
}
$result = Ak::file_get_contents($uncompressed_file, array('base_path' => AK_TMP_DIR));
return $result;
}
示例10: form_authenticity_token
public static function form_authenticity_token()
{
if (!isset($_SESSION['_csrf_token'])) {
$_SESSION['_csrf_token'] = sha1(Ak::uuid() . Ak::randomString());
}
return $_SESSION['_csrf_token'];
}
示例11: test_should_create_base_path_ticket_148
public function test_should_create_base_path_ticket_148()
{
$tmp_dir = AkConfig::getDir('tmp') . DS . Ak::randomString();
$base_path = AkConfig::getDir('tmp') . 'new_dir_' . time();
AkFileSystem::make_dir($base_path, array('base_path' => $base_path));
$this->assertTrue(is_dir($base_path), 'Could base_path directory ' . $base_path);
clearstatcache();
}
示例12: sendDataAsStream
/**
* Creates a file for streaming from a file.
* This way you might free memory usage is file is too large
*/
function sendDataAsStream($data, $options)
{
$temp_file_name = tempnam(AK_TMP_DIR, Ak::randomString());
$fp = fopen($temp_file_name, 'w');
fwrite($fp, $data);
fclose($fp);
$this->sendFile($temp_file_name, $options);
}
示例13: test_framework_config_locale_update
function test_framework_config_locale_update()
{
$langs=Ak::langs();
$translation_key=Ak::randomString(8);
$this->assertEqual(Ak::t($translation_key),$translation_key);
AkLocaleManager::updateLocaleFiles();
list($locales,$core_dictionary) = AkLocaleManager::getCoreDictionary(AK_FRAMEWORK_LANGUAGE);
$this->assertTrue(isset($core_dictionary[$translation_key]));
foreach($langs as $lang) {
list($locales,$core_dictionary) = AkLocaleManager::getCoreDictionary($lang);
$this->assertTrue(isset($core_dictionary[$translation_key]));
}
}
示例14: test_should_delete_nested_directories_when_include_hidden_files
function test_should_delete_nested_directories_when_include_hidden_files()
{
$dir_name = AK_TMP_DIR . Ak::randomString();
Ak::make_dir($dir_name);
Ak::make_dir($dir_name . DS . '.hidden');
$this->assertTrue(is_dir($dir_name), 'Could not create test directory ' . $dir_name);
$this->assertTrue(Ak::directory_delete($dir_name));
clearstatcache();
$this->assertFalse(is_dir($dir_name));
}
示例15: getBoundaryString
public function getBoundaryString()
{
return md5(Ak::randomString(10) . time());
}