本文整理汇总了PHP中get_random_string函数的典型用法代码示例。如果您正苦于以下问题:PHP get_random_string函数的具体用法?PHP get_random_string怎么用?PHP get_random_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_random_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render
public function render($module, $model)
{
$rtn = "\n[[[\r\n \$prepopulate = (\$object->isNew() ? (isset(\$_POST['" . $this->name . "']) ? strip_tags(\$_POST['" . $this->name . "']) : '') : \$object->get" . DBObject::tableNameToClassName($this->name) . "() * 1000);\r\n \$alt_prepopulate = \$prepopulate;\r\n if (preg_match('/^\\d+\$/', \$prepopulate)) {\r\n \$alt_prepopulate = date('Y-m-d', \$prepopulate/1000);\r\n }\r\n]]]\n";
$id = get_random_string(5);
$rtn .= "\n<div id='{$id}' class='form-group'>\r\n <label class='col-sm-2 control-label' for='{$this->name}'>{$this->name} " . ($this->required ? $this->mandatory_field : '') . "</label>\r\n <div class='col-sm-10'>\r\n <div class='input-group'>\r\n <span class='input-group-addon'><i class='fa fa-calendar'></i></span>\r\n <input disabled='disabled' value='[[[ echo htmlentities(str_replace('\\'', '\"', \$alt_prepopulate)) ]]]' type='text' class='form-control altFormat' " . ($this->required ? ' required' : '') . " />\r\n <input value='[[[ echo htmlentities(str_replace('\\'', '\"', \$prepopulate)) ]]]' type='text' id='{$this->name}' name='{$this->name}' class='datepicker form-control' " . ($this->required ? ' required' : '') . " style='position: absolute; top:0; left: 0; z-index: -1' />\r\n </div>\r\n </div>\r\n</div>\r\n<div class='hr-line-dashed'></div>\r\n";
$rtn .= "\r\n <script type='text/javascript'>\r\n \$('#{$id} .datepicker').datepicker({\r\n " . (isset($this->options['dateFormat']) ? 'dateFormat: ' . "'" . $this->options['dateFormat'] . "'" : '') . "\r\n " . (isset($this->options['altFormat']) ? ',altField: "#' . $id . ' .altFormat", altFormat: "' . $this->options['altFormat'] . '"' : '') . "\r\n " . (isset($this->options['changeMonth']) ? ',changeMonth: ' . $this->options['changeMonth'] : '') . "\r\n " . (isset($this->options['changeYear']) ? ',changeYear: ' . $this->options['changeYear'] : '') . "\r\n " . (isset($this->options['yearRange']) ? ',yearRange: ' . "'" . $this->options['yearRange'] . "'" : '') . "\r\n });\r\n \$('#{$id} .input-group-addon').css('cursor', 'pointer').on('click', function(){\r\n \$('#{$id} .datepicker').datepicker('show');\r\n });\r\n </script>\r\n";
return $rtn;
}
开发者ID:jeffreycai,项目名称:ct21,代码行数:8,代码来源:FormWidgetDatepicker.class.php
示例2: generateSpamToken
/**
* Generate a spam token and store in session
*/
static function generateSpamToken($unique_id)
{
$token_key = get_random_string(8);
$token_value = get_random_string(12);
if (!isset($_SESSION['spam_tokens'])) {
$_SESSION['spam_tokens'] = array();
}
// store the generated token in session
$_SESSION['spam_tokens'][$unique_id] = array();
$_SESSION['spam_tokens'][$unique_id]['key'] = $token_key;
$_SESSION['spam_tokens'][$unique_id]['value'] = $token_value;
return array('key' => $token_key, 'value' => $token_value);
}
开发者ID:jeffreycai,项目名称:chaoliu,代码行数:16,代码来源:Form.class.php
示例3: new_lease_for_video
function new_lease_for_video($id, $expiry = -1)
{
global $db;
delete_expired_leases();
$id = (int) $id;
$ip = addslashes($_SERVER['REMOTE_ADDR']);
if ($lease = lease_for_video($id)) {
return $lease;
}
if ($expiry == -1) {
$expiry = EXPIRY;
}
$now = new DateTime();
$now->modify("+{$expiry} seconds");
$expiry = $now->format('Y-m-d H:i:s');
$url = get_random_string("abcdefghijklmnopqrstuvwxyz0123456789", 3);
$query = "INSERT INTO leases(video, url, ip, expiry) VALUES({$id}, \"{$url}\", \"{$ip}\", \"{$expiry}\")";
if ($result = $db->query($query)) {
return $url;
}
return false;
}
开发者ID:JikkuJose,项目名称:drop,代码行数:22,代码来源:functions.php
示例4: render
public function render($module, $model)
{
$rtn = "";
$prepopulate = '($object->isNew() ? ' . "(isset(\$_POST['{$this->name}']) ? strip_tags(\$_POST['{$this->name}']) : '')" . ' : $object->get' . format_as_class_name($this->name) . '())';
$id = get_random_string(5);
$rtn .= "\n<div id='{$id}' class='form-group'>\r\n <label class='col-sm-2 control-label' for='{$this->name}'>{$this->name} " . ($this->required ? $this->mandatory_field : '') . "</label>\r\n <div class='col-sm-10'>\r\n <div class='input-group'>\r\n <span class='input-group-addon'><i class='fa fa-calendar'></i></span><input value='[[[ echo htmlentities(str_replace('\\'', '\"', {$prepopulate})) ]]]' type='text' class='form-control' id='{$this->name}' name='{$this->name}'" . ($this->required ? ' required' : '') . " />\r\n </div>\r\n </div>\r\n</div>\r\n<div class='hr-line-dashed'></div>\r\n";
$rtn .= '
[[[ // include jquery-ui library if not
$already_included_at_frontend = Asset::checkAssetAdded(\'jquery-ui\', \'js\', \'frontend\') || Asset::checkAssetAdded(\'jquery_ui\', \'js\', \'frontend\');
if (!$already_included_at_frontend) {
echo( "\\n".\'<script type="text/javascript" src="\'.uri(\'modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js\').\'"></script>\'."\\n" );
echo( "\\n".\'<script type="text/javascript">loadCSS("\'.uri(\'modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js\').\'")</script>\'."\\n" );
Asset::addDynamicAsset(\'jquery_ui\', \'js\', \'frontend\', \'<script type="text/javascript" src="\'.uri(\'modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js\').\'"></script>\');
}
$already_included_at_backend = Asset::checkAssetAdded(\'jquery-ui\', \'js\', \'backend\') || Asset::checkAssetAdded(\'jquery_ui\', \'js\', \'backend\');
if (!$already_included_at_backend) {
echo( "\\n".\'<script type="text/javascript" src="\'.uri(\'modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js\').\'"></script>\'."\\n" );
echo( "\\n".\'<script type="text/javascript">loadCSS("\'.uri(\'modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js\').\'")</script>\'."\\n" );
Asset::addDynamicAsset(\'jquery_ui\', \'js\', \'backend\', \'<script type="text/javascript" src="\'.uri(\'modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js\').\'"></script>\');
}
]]]
';
// $already_included_at_frontend = Asset::checkAssetAdded('jquery-ui', 'js', 'frontend') || Asset::checkAssetAdded('jquery_ui', 'js', 'frontend');
// if (!$already_included_at_frontend) {
// $rtn .= "\n".'<script type="text/javascript" src="'.uri('modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js').'"></script>'."\n";
// $rtn .= "\n".'<script type="text/javascript">loadCSS('.uri('modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js').')</script>'."\n";
// Asset::addDynamicAsset('jquery_ui', 'js', 'frontend', '<script type="text/javascript" src="'.uri('modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js').'"></script>');
// }
// $already_included_at_backend = Asset::checkAssetAdded('jquery-ui', 'js', 'backend') || Asset::checkAssetAdded('jquery_ui', 'js', 'backend');
// if (!$already_included_at_backend) {
// $rtn .= "\n".'<script type="text/javascript" src="'.uri('modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js').'"></script>'."\n";
// $rtn .= "\n".'<script type="text/javascript">loadCSS('.uri('modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js').')</script>'."\n";
// Asset::addDynamicAsset('jquery_ui', 'js', 'backend', '<script type="text/javascript" src="'.uri('modules/core/assets/jquery-ui-1.11.4.custom/jquery-ui.min.js').'"></script>');
// }
return $rtn;
}
开发者ID:jeffreycai,项目名称:chaoliu,代码行数:36,代码来源:FormWidgetDatepicker.class.php
示例5: nulluhr
function nulluhr()
{
global $db;
update_all_ranks();
$db->query('DELETE FROM ' . DB_PRE . 'ecp_messages WHERE fromdel = 1 AND del = 1');
$result = $db->query('SELECT ID FROM ' . DB_PRE . 'ecp_user WHERE (ondelete < ' . time() . ' AND ondelete != 0) OR (status = 0 AND registerdate < ' . (time() - DELETE_UNAKTIV * 86400) . ')');
while ($row = mysql_fetch_assoc($result)) {
delete_user($row['ID']);
}
$result = $db->query('SELECT ID, money FROM ' . DB_PRE . 'ecp_user LEFT JOIN ' . DB_PRE . 'ecp_ranks ON (rID = rankID)');
while ($row = mysql_fetch_assoc($result)) {
if ($row['money'] != '') {
$db->query('UPDATE ' . DB_PRE . 'ecp_user_stats SET money = money + ' . $row['money'] . ' WHERE userID = ' . $row['ID']);
}
}
if (BACKUP_AKTIV) {
$last = $db->result(DB_PRE . 'ecp_stats', 'lastdbbackup', '1');
if (BACKUP_CYCLE == 'day' or $last + (BACKUP_CYCLE == 'month' ? 2592000 : 604800) < time()) {
$backup_obj = new MySQL_Backup();
$backup_obj->server = MYSQL_HOST;
$backup_obj->username = MYSQL_USER;
$backup_obj->password = MYSQL_PASS;
$backup_obj->database = MYSQL_DATABASE;
$backup_obj->tables = array();
$backup_obj->drop_tables = true;
$backup_obj->struct_only = false;
$backup_obj->comments = true;
$backup_obj->fname_format = 'd_m_y__H_i_s';
$string = get_random_string(8, 2);
if ($backup_obj->Execute(MSB_SAVE, 'uploads/forum/' . $string . '.sql.gz', true)) {
$m = new XMail();
// set from address and name
$m->From(SITE_EMAIL);
// add to address and name
$m->AddTo(BACKUP_EMAIL);
// set subject
$m->Subject(BACKUP_AUTO);
// set text/plain version of message
$m->Text(DATE . ': ' . date('d.m.Y H:i:s'));
// add attachment ('text/plain' file)
$m->Attach(date('Y_m_d') . '.sql.gz', 'application/x-gzip');
$f = 'uploads/forum/' . $string . '.sql.gz';
$id = MIME::unique();
// add inline attachment '$f' file with ID '$id'
$m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'attachment', $id);
if (SMTP_AKTIV) {
$c = $m->Connect(SMTP_HOST, (int) SMTP_PORT, SMTP_USER, SMTP_PASS, 'tls', 10, 'localhost', null, 'plain');
//or die(print_r($m->Result));
}
if ($m->Send(SMTP_AKTIV ? $c : null)) {
$db->query('UPDATE ' . DB_PRE . 'ecp_stats SET lastdbbackup = ' . strtotime('today 00:00:00'));
}
unlink('uploads/forum/' . $string . '.sql.gz');
}
}
}
$result = $db->query('SELECT attachID, strname FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000));
while ($row = $db->fetch_assoc()) {
@unlink('upload/forum/' . $row['attachID'] . '_' . $row['strname']);
}
$db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000));
// Buchungen durchf�hren
$buchresult = $db->query('SELECT `ID`, `verwendung`, `intervall`, `betrag`, `nextbuch`, `tagmonat` FROM ' . DB_PRE . 'ecp_clankasse_auto WHERE nextbuch <= \'' . time() . '\'');
while ($row = mysql_fetch_assoc($buchresult)) {
$db->query('INSERT INTO ' . DB_PRE . 'ecp_clankasse_transaktion (`geld`, `verwendung`, `datum`, `userID`) VALUES
(-' . $row['betrag'] . ', \'' . mysql_real_escape_string($row['verwendung']) . '\', ' . time() . ', 0)');
$db->query('UPDATE ' . DB_PRE . 'ecp_clankasse SET kontostand = kontostand - ' . $row['betrag']);
switch ($row['tagmonat']) {
case 1:
$nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
break;
case 15:
$nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
break;
case 28:
$nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
}
$db->query('UPDATE ' . DB_PRE . 'ecp_clankasse_auto SET `nextbuch` = \'' . $nextdate . '\'');
}
$db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_search WHERE datum < ' . (time() - 86400));
$result = $db->query('SELECT COUNT(sID) as anzahl, sID FROM ' . DB_PRE . 'ecp_server_stats GROUP BY sID');
while ($row = mysql_fetch_assoc($result)) {
if ($row['anzahl'] > SERVER_MAX_LOG) {
$db->query('DELETE FROM ' . DB_PRE . 'ecp_server_stats WHERE sID = ' . $row['sID'] . ' ORDER BY datum ASC LIMIT ' . ($row['anzahl'] - SERVER_MAX_LOG));
}
}
}
开发者ID:ECP-Black,项目名称:ECP,代码行数:87,代码来源:functions.php
示例6: trim
$auto_enroll_id = $_REQUEST['auto_enroll_id'];
} else {
$auto_enroll_id = 0;
}
if (isset($_POST['save']) || isset($_POST['add'])) {
/* insert or update a category */
// $cat_parent_id = intval($_POST['cat_parent_id']);
$name = trim($_POST['name']);
$name = $addslashes($name);
$name = validate_length($name, 50);
if (isset($_POST['add']) && !$_POST['add_ids']) {
$msg->addError('NO_ITEM_SELECTED');
}
if (!$msg->containsErrors()) {
if ($auto_enroll_id == 0) {
$sql = "INSERT INTO " . TABLE_PREFIX . "auto_enroll(associate_string, name) \n\t\t\t VALUES ('" . get_random_string(6, 10) . "', '" . $name . "')";
$result = mysql_query($sql, $db) or die(mysql_error());
$auto_enroll_id = mysql_insert_id($db);
write_to_log(AT_ADMIN_LOG_INSERT, 'auto_enroll', mysql_affected_rows($db), $sql);
} else {
$sql = "UPDATE " . TABLE_PREFIX . "auto_enroll\n\t\t\t SET name = '" . $name . "'\n\t\t\t WHERE auto_enroll_id = " . $auto_enroll_id;
$result = mysql_query($sql, $db);
write_to_log(AT_ADMIN_LOG_UPDATE, 'auto_enroll', mysql_affected_rows($db), $sql);
}
if (isset($_POST['add'])) {
foreach ($_POST['add_ids'] as $elem) {
$sql = "SELECT count(*) cnt FROM " . TABLE_PREFIX . "auto_enroll_courses\n\t\t\t\t WHERE auto_enroll_id = " . $auto_enroll_id . "\n\t\t\t\t AND course_id = " . $elem;
$result = mysql_query($sql, $db) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if ($row["cnt"] == 0) {
$sql = "INSERT INTO " . TABLE_PREFIX . "auto_enroll_courses (auto_enroll_id, course_id)\n\t\t\t\t\t VALUES (" . $auto_enroll_id . ", " . $elem . ")";
开发者ID:vicentborja,项目名称:ATutor,代码行数:31,代码来源:auto_enroll_edit.php
示例7: __construct
function __construct()
{
parent::__construct();
global $objLogin;
$this->params = array();
if (isset($_POST['album_code'])) {
$this->params['album_code'] = prepare_input($_POST['album_code']);
}
if (isset($_POST['album_type'])) {
$this->params['album_type'] = prepare_input($_POST['album_type']);
}
if (isset($_POST['priority_order'])) {
$this->params['priority_order'] = prepare_input($_POST['priority_order']);
}
if (isset($_POST['is_active'])) {
$this->params['is_active'] = prepare_input($_POST['is_active']);
} else {
$this->params['is_active'] = '0';
}
$this->primaryKey = 'id';
$this->tableName = TABLE_GALLERY_ALBUMS;
$this->dataSet = array();
$this->error = '';
$this->formActionURL = 'index.php?admin=mod_gallery_management';
$this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true);
$this->actionIcons = true;
$this->allowRefresh = true;
$this->allowTopButtons = true;
$this->allowLanguages = false;
$this->languageId = $objLogin->GetPreferredLang();
$this->WHERE_CLAUSE = '';
// WHERE...
$this->ORDER_CLAUSE = 'ORDER BY priority_order ASC';
// ORDER BY date_created DESC
$this->isAlterColorsAllowed = true;
$this->isPagingAllowed = true;
$this->pageSize = 20;
$this->isSortingAllowed = true;
$this->isFilteringAllowed = false;
// define filtering fields
$this->arrFilteringFields = array();
///////////////////////////////////////////////////////////////////////////////
// 1. prepare translation fields array
$this->arrTranslations = $this->PrepareTranslateFields(array('name', 'description'));
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// 2. prepare translations array for edit/detail modes
$sql_translation_description = $this->PrepareTranslateSql(TABLE_GALLERY_ALBUMS_DESCRIPTION, 'gallery_album_id', array('name', 'description'));
///////////////////////////////////////////////////////////////////////////////
// prepare album types array
$arr_album_types = array('images' => _IMAGES, 'video' => _VIDEO);
$arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>');
//----------------------------------------------------------------------
// VIEW MODE
//----------------------------------------------------------------------
$this->VIEW_MODE_SQL = 'SELECT
ga.' . $this->primaryKey . ',
ga.album_code,
ga.album_type,
UCASE(ga.album_code) as mod_album_code,
CONCAT(UCASE(SUBSTRING(ga.album_type, 1, 1)),LCASE(SUBSTRING(ga.album_type, 2))) as mod_album_type,
gad.name,
gad.description,
ga.priority_order,
ga.is_active,
CONCAT("<a href=index.php?admin=mod_gallery_upload_items&album=", album_code, ">' . _UPLOAD . '</a> (", (SELECT COUNT(*) as cnt FROM ' . TABLE_GALLERY_ALBUM_ITEMS . ' gi WHERE gi.album_code = ga.album_code) , ")") as link_upload_items
FROM (' . $this->tableName . ' ga
LEFT OUTER JOIN ' . TABLE_GALLERY_ALBUMS_DESCRIPTION . ' gad ON ga.id = gad.gallery_album_id AND gad.language_id = \'' . $this->languageId . '\')';
// define view mode fields
$this->arrViewModeFields = array('name' => array('title' => _ALBUM_NAME, 'type' => 'label', 'align' => 'left', 'width' => '15%', 'maxlength' => '30'), 'description' => array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '50'), 'mod_album_code' => array('title' => _ALBUM_CODE, 'type' => 'label', 'align' => 'center', 'width' => '12%'), 'mod_album_type' => array('title' => _TYPE, 'type' => 'label', 'align' => 'center', 'width' => '8%'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '8%', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active), 'priority_order' => array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '8%', 'movable' => true), 'link_upload_items' => array('title' => _ITEMS, 'type' => 'label', 'align' => 'center', 'width' => '12%'));
//----------------------------------------------------------------------
// ADD MODE
//----------------------------------------------------------------------
// define add mode fields
$max_order = self::GetParameter('action') == 'add' ? $this->GetMaxOrder('priority_order', 999) : 0;
$this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'album_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => get_random_string(8)), 'album_type' => array('title' => _TYPE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'source' => $arr_album_types), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'maxlength' => '3', 'default' => $max_order, 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0', 'default' => '1')));
//----------------------------------------------------------------------
// EDIT MODE
//----------------------------------------------------------------------
// define edit mode fields
$this->EDIT_MODE_SQL = 'SELECT
' . $this->tableName . '.' . $this->primaryKey . ',
UCASE(' . $this->tableName . '.album_code) as album_code,
' . $this->tableName . '.album_type,
CONCAT(UCASE(SUBSTRING(' . $this->tableName . '.album_type, 1, 1)),LCASE(SUBSTRING(' . $this->tableName . '.album_type, 2))) as mod_album_type,
' . $sql_translation_description . '
' . $this->tableName . '.priority_order,
' . $this->tableName . '.is_active
FROM ' . $this->tableName . '
WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
// define edit mode fields
$this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'album_code' => array('title' => _CODE, 'type' => 'label'), 'album_type' => array('title' => _TYPE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'source' => $arr_album_types), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'maxlength' => '3', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0')));
//----------------------------------------------------------------------
// DETAILS MODE
//----------------------------------------------------------------------
$this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
$this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'album_code' => array('title' => _CODE, 'type' => 'label'), 'mod_album_type' => array('title' => _TYPE, 'type' => 'label'), 'priority_order' => array('title' => _ORDER, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active)));
///////////////////////////////////////////////////////////////////////////////
// 3. add translation fields to all modes
$this->AddTranslateToModes($this->arrTranslations, array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '410px', 'required' => true, 'maxlength' => '125', 'readonly' => false), 'description' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '410px', 'height' => '90px', 'required' => false, 'maxlength' => '255', 'validation_maxlength' => '255', 'readonly' => false)));
//.........这里部分代码省略.........
开发者ID:mozdial,项目名称:Directory,代码行数:101,代码来源:GalleryAlbums.class.php
示例8: get_random_string
<?php
function get_random_string($valid_chars, $length)
{
// start with an empty random string
$random_string = "";
// count the number of chars in the valid chars string so we know how many choices we have
$num_valid_chars = strlen($valid_chars);
// repeat the steps until we've created a string of the right length
for ($i = 0; $i < $length; $i++) {
// pick a random number from 1 up to the number of valid chars
$random_pick = mt_rand(1, $num_valid_chars);
// take the random character out of the string of valid chars
// subtract 1 from $random_pick because strings are indexed starting at 0, and we started picking at 1
$random_char = $valid_chars[$random_pick - 1];
// add the randomly-chosen char onto the end of our string so far
$random_string .= $random_char;
}
// return our finished random string
return $random_string;
}
$valid_chars = 'abcdefghijklmnopqurstuvwxvz09865135462!@#$$%^&*(()_{}:LABCDEFGHJHIKLMNOPEQREURSTYUWXYZ';
for ($i = 0; $i < 1000; $i++) {
echo "INSERT INTO `spreadit`.`posts` (`id`, `user_id`, `created_at`, `type`, `data`, `updated_at`, `section_id`, `title`, `upvotes`, `downvotes`, `url`, `comment_count`, `markdown`) VALUES (NULL, " . rand(0, 40) . ", " . time() . ", 1, '" . get_random_string($valid_chars, rand(0, 2000)) . "', " . time() . ", " . rand(0, 10) . ", '" . get_random_string($valid_chars, rand(6, 128)) . "', " . rand(0, 100) . ", " . rand(0, 100) . ", '" . get_random_string($valid_chars, rand(10, 128)) . "', " . rand(0, 100) . ", '" . get_random_string($valid_chars, rand(0, 4000)) . "');";
}
开发者ID:hrenos,项目名称:spreadit,代码行数:25,代码来源:createsql.php
示例9: curPageURL
echo '<script>window.location.replace("' . curPageURL() . '?e=token");</script>';
}
exit;
}
//Functions
if ($_POST[$_SESSION['token']['act']] == 'admin_user_add') {
if (trim(preg_replace('/\\s+/', '', $_POST['name'])) != '' && preg_match('/^[A-Za-z0-9À-ÿ\\/\\s\'-]+$/', $_POST['name'])) {
$_POST['name'] = trim(preg_replace('/\\s+/', ' ', $_POST['name']));
} else {
header('Content-Type: application/json; charset=utf-8');
echo json_encode(array(0 => 'Invalid Name: only alphanumeric and single quote allowed'));
exit;
}
$_POST['mail'] = trim(preg_replace('/\\s+/', '', $_POST['mail']));
$_POST['mail'] = $_POST['mail'] != '' && filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL) ? $_POST['mail'] : exit;
$pass = get_random_string(5);
$dpass = hash('whirlpool', crypt($pass, '$#%H4!df84a$%#RZ@£'));
$_POST['role'] = is_numeric($_POST['role']) ? $_POST['role'] : exit;
try {
$DBH = new PDO("mysql:host={$Hostname};dbname={$DatabaseName}", $Username, $Password);
$DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "INSERT INTO " . $SupportUserTable . " (`name`,`mail`,`password`,`status`,`ip_address`) VALUES (?,?,?,?,?) ";
$STH = $DBH->prepare($query);
$ip = '127.0.0.1';
$STH->bindParam(1, $_POST['name'], PDO::PARAM_STR);
$STH->bindParam(2, $_POST['mail'], PDO::PARAM_STR);
$STH->bindParam(3, $dpass, PDO::PARAM_STR);
$STH->bindParam(4, $_POST['role'], PDO::PARAM_STR);
$STH->bindParam(5, $ip, PDO::PARAM_STR);
$STH->execute();
$uid = $DBH->lastInsertId();
开发者ID:noikiy,项目名称:Responsive-Support-Tickets-System,代码行数:31,代码来源:admin_function.php
示例10: invite_member
function invite_member($email, $userid, $group = '', $groupname = '')
{
$regcode = get_random_string();
if (empty($group)) {
$group = 'NULL';
}
$sql = "INSERT INTO `goingdutch`.`register` (`email` ,`userid`, `code` , `group`, `timestamp`)\n VALUES ('" . mysql_real_escape_string(email) . "', {$userid}, '" . mysql_real_escape_string($regcode) . "', {$group}, CURRENT_TIMESTAMP )";
if (!($result = mysql_query($sql))) {
return false;
}
// send email
$regcodes = space_code($regcode);
$from = '[email protected]';
$from_name = 'Going Dutch';
if (!empty($groupname)) {
$groupname = 'group "' . $groupname . '"';
}
$subject = "Invitation to join Going Dutch {$groupname}";
//$website = 'http://inthere.nl/dutch';
$website = LOGIN_URL;
$link = "<a href=\"{$website}?code={$regcode}\">this link</a>";
$html = "Please register using {$link}<br /><br>";
$html .= "Or register on {$website} with this code<br />{$regcodes}";
if (!smtpmailer($email, $from, $from_name, $subject, $html, array('[email protected]', 'Do not reply to this address'), 'to')) {
echo " something went wrong <br />";
echo $smtpmailer_error;
}
}
开发者ID:Whiskey24,项目名称:GoingDutchApi,代码行数:28,代码来源:functions.php
示例11: SendPassword
/**
* Send forgotten password
* @param $email
*/
public function SendPassword($email)
{
global $objSettings;
$lang = Application::Get('lang');
// deny all operations in demo version
if (strtolower(SITE_MODE) == 'demo') {
$this->error = _OPERATION_BLOCKED;
return false;
}
if (!empty($email)) {
if (check_email_address($email)) {
if (!PASSWORDS_ENCRYPTION) {
$sql = 'SELECT id, first_name, last_name, user_name, password, preferred_language FROM ' . TABLE_ACCOUNTS . ' WHERE email = ' . quote_text(encode_text($email)) . ' AND is_active = 1';
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'aes') {
$sql = 'SELECT id, first_name, last_name, user_name, AES_DECRYPT(password, ' . quote_text(PASSWORDS_ENCRYPT_KEY) . ') as password, preferred_language FROM ' . TABLE_ACCOUNTS . ' WHERE email = ' . quote_text(encode_text($email)) . ' AND is_active = 1';
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'md5') {
$sql = 'SELECT id, first_name, last_name, user_name, \'\' as password, preferred_language FROM ' . TABLE_ACCOUNTS . ' WHERE email = ' . quote_text($email) . ' AND is_active = 1';
}
}
}
$temp = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY);
if (is_array($temp) && count($temp) > 0) {
//////////////////////////////////////////////////////////////////
if (!PASSWORDS_ENCRYPTION) {
$password = $temp['password'];
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'aes') {
$password = $temp['password'];
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'md5') {
$password = get_random_string(8);
$sql = 'UPDATE ' . TABLE_ACCOUNTS . ' SET password = ' . quote_text(md5($password)) . ' WHERE id = ' . (int) $temp['id'];
database_void_query($sql);
}
}
}
send_email($email, $objSettings->GetParameter('admin_email'), 'password_forgotten', array('{FIRST NAME}' => $temp['first_name'], '{LAST NAME}' => $temp['last_name'], '{USER NAME}' => $temp['user_name'], '{USER PASSWORD}' => $password, '{BASE URL}' => APPHP_BASE, '{WEB SITE}' => $_SERVER['SERVER_NAME'], '{YEAR}' => date('Y')), $temp['preferred_language']);
//////////////////////////////////////////////////////////////////
return true;
} else {
$this->error = _EMAIL_NOT_EXISTS;
return false;
}
} else {
$this->error = _EMAIL_IS_WRONG;
return false;
}
} else {
$this->error = _EMAIL_EMPTY_ALERT;
return false;
}
return true;
}
开发者ID:mozdial,项目名称:Directory,代码行数:59,代码来源:Accounts.class.php
示例12: forum_edit_replay
function forum_edit_replay($id, $bid, $tid)
{
global $db;
$thread = $db->fetch_assoc('SELECT `threadID`, `bID`, `threadname`, a.boardparentID, ' . DB_PRE . 'ecp_forum_threads.closed,userID, comment, attachs,postname, adatum,
a.editcom,a.editmocom,a.rightsread, a.commentsperpost, a.moneyperpost, a.boardparentID,
a.name, a.attachments, a.attachmaxsize, a.postcom, a.attachfiles, b.rightsread as parentRead
FROM ' . DB_PRE . 'ecp_forum_threads
LEFT JOIN ' . DB_PRE . 'ecp_forum_boards AS a ON (bID = a.boardID)
LEFT JOIN ' . DB_PRE . 'ecp_forum_boards AS b ON (b.boardID = a.boardparentID)
LEFT JOIN ' . DB_PRE . 'ecp_forum_comments ON (comID = ' . $id . ')
WHERE threadID = ' . $tid . ' AND bID = ' . $bid);
if (@$_SESSION['userID'] and find_access($thread['rightsread']) and find_access($thread['parentRead']) and (find_access($thread['editcom']) and $_SESSION['userID'] == $thread['userID'] or find_access($thread['editmocom'])) and $db->errorNum() == 0) {
if (isset($_POST['comment'])) {
if ($_POST['comment'] == '' or isset($_POST['username']) and $_POST['username'] == '' or isset($_POST['title']) and $_POST['title'] == '') {
table(ERROR, NOT_NEED_ALL_INPUTS);
$tpl = new smarty();
$tpl->assign('func', 'edit');
$tpl->assign('func2', '&comID=' . $id);
$tpl->assign('comment', $_POST['comment']);
if ($db->result(DB_PRE . 'ecp_forum_comments', 'COUNT(comID)', 'tID = ' . $tid . ' AND adatum < ' . $thread['adatum'] . ' ORDER BY adatum ASC') == 0) {
$tpl->assign('title', $thread['threadname']);
}
if ($thread['userID'] == 0) {
$tpl->assign('username', $thread['postname']);
}
ob_start();
if ($thread['attachments'] and $thread['attachmaxsize']) {
$attachs = $db->result(DB_PRE . 'ecp_forum_attachments', 'COUNT(attachID)', 'mID = ' . $id . ' AND tID = ' . $tid);
if ($thread['attachments'] > $attachs) {
$rand = get_random_string(16, 2);
$tpl->assign('attach', find_access($thread['attachfiles']));
$tpl->assign('maxsize', $thread['attachmaxsize']);
$tpl->assign('rand', $rand);
$tpl->assign('sid', session_name() . '=' . session_id());
$tpl->assign('maxuploads', $thread['attachments'] - $attachs);
$tpl->assign('uploadinfo', str_replace(array('{anzahl}', '{max}'), array($thread['attachments'] - $attachs, goodsize($thread['attachmaxsize'])), FORUM_ATTACH_INFO));
$_SESSION['forum']['attach'][$bid] = $rand;
}
}
$tpl->assign('quote', true);
$tpl->display(DESIGN . '/tpl/forum/comments_add_edit' . ((UPLOAD_METHOD == 'old' and $thread['attachments'] and $thread['attachmaxsize']) ? '_old' : '') . '.html');
$content = ob_get_contents();
ob_end_clean();
main_content(FORUM_POST_EDIT, $content, '', 1);
} else {
if ($db->query(sprintf('UPDATE ' . DB_PRE . 'ecp_forum_comments SET postname = \'%s\', comment = \'%s\', edits =edits +1, editdatum = %d, edituserID = %d WHERE comID = %d', strsave(htmlspecialchars(@$_POST['username'])), strsave(comment_save($_POST['comment'])), time(), @(int) $_SESSION['userID'], $id))) {
if (find_access($thread['attachfiles'])) {
if (UPLOAD_METHOD == 'old') {
$maxattach = $thread['attachments'] - $db->result(DB_PRE . 'ecp_forum_attachments', 'COUNT(attachID)', 'bID = ' . $bid . ' AND mID = ' . $id);
foreach ($_FILES as $key => $value) {
if ($_FILES[$key] == '' or $maxattach <= 0 or $_FILES[$key]['size'] > $thread['attachmaxsize']) {
continue;
}
$mine = getMimeType($_FILES[$key]['tmp_name'], $_FILES[$key]['name']);
if ($mine == 'application/zip' or $mine == 'application/x-rar-compressed' or $mine == 'image/bmp' or $mine == 'image/gif' or $mine == 'image/jpeg' or $mine == 'image/png' or $mine == 'application/pdf' or $mine == 'text/plain' or $mine == 'text/css' or $mine == 'text/html') {
$sha1 = sha1_file($_FILES[$key]['tmp_name']);
if ($db->query(sprintf('INSERT INTO ' . DB_PRE . 'ecp_forum_attachments (`bID`, `userID`, `name`, `size`, `strname`, uploadzeit, IP, tID, mID) VALUES (%d, %d, \'%s\', %d, \'%s\', %d, \'%s\', %d, %d)', $bid, @(int) $_SESSION['userID'], strsave($_FILES[$key]['name']), (int) $_FILES[$key]['size'], $sha1, time(), $_SERVER['REMOTE_ADDR'], $tid, $id))) {
move_uploaded_file($_FILES[$key]['tmp_name'], 'uploads/forum/' . $db->last_id() . '_' . $sha1);
umask(0);
chmod('uploads/forum/' . $db->last_id() . '_' . $sha1, CHMOD);
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_threads SET anhaenge = 1 WHERE threadID = ' . $tid);
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_comments SET attachs = 1 WHERE comID = ' . $id);
}
$maxattach--;
}
}
} else {
$db->query(sprintf('UPDATE ' . DB_PRE . 'ecp_forum_attachments SET `tID` = %d, `mID` = %d WHERE validation = \'%s\' AND bID = %d', $id, $comid, strsave($_GET['rand']), $bid));
if ($db->affekt_rows()) {
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_threads SET anhaenge = 1 WHERE threadID = ' . $id);
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_comments SET attachs = 1 WHERE comID = ' . $comid);
}
}
}
if ($db->result(DB_PRE . 'ecp_forum_comments', 'COUNT(comID)', 'tID = ' . $tid . ' AND adatum < ' . $thread['adatum'] . ' ORDER BY adatum ASC') == 0) {
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_threads SET threadname = \'' . strsave(htmlspecialchars($_POST['title'])) . '\', vonname = \'' . strsave(htmlspecialchars(@$_POST['username'])) . '\' WHERE threadID = ' . $tid);
}
$last = $db->fetch_assoc('SELECT userID,postname,adatum, tID FROM ' . DB_PRE . 'ecp_forum_comments WHERE boardID = ' . $bid . ' ORDER BY adatum DESC LIMIT 1');
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_boards SET `lastpostuserID` = ' . (int) $last['userID'] . ', `lastpostuser` = \'' . $last['postname'] . '\', `lastpost` = ' . (int) $last['adatum'] . ', lastthreadID = ' . (int) $last['tID'] . ' WHERE (boardID = ' . $bid . ' OR boardID = ' . $thread['boardparentID'] . ')');
$last = $db->fetch_assoc('SELECT userID,postname,adatum FROM ' . DB_PRE . 'ecp_forum_comments WHERE tID = ' . $tid . ' ORDER BY adatum DESC LIMIT 1');
$db->query('UPDATE ' . DB_PRE . 'ecp_forum_threads SET `lastuserID` = ' . $last['userID'] . ', `lastusername` = \'' . $last['postname'] . '\', `lastreplay` = ' . $last['adatum'] . ' WHERE threadID = ' . $tid);
unset($_SESSION['forum']['attach'][$bid]);
$anzahl = $db->result(DB_PRE . 'ecp_forum_comments', 'COUNT(comID)', 'tID = ' . $tid . ' AND boardID =' . $bid . ' AND adatum < ' . $thread['adatum']);
header1('?section=forum&action=thread&boardID=' . $bid . '&threadID=' . $tid . '&page=' . (ceil(($anzahl - 1) / LIMIT_FORUM_COMMENTS) + 1) . '#com_' . $id);
}
}
} else {
$tpl = new smarty();
$tpl->assign('comment', htmlspecialchars($thread['comment']));
$tpl->assign('func', 'edit');
$tpl->assign('func2', '&comID=' . $id);
if ($db->result(DB_PRE . 'ecp_forum_comments', 'COUNT(comID)', 'tID = ' . $tid . ' AND adatum < ' . $thread['adatum'] . ' ORDER BY adatum ASC') == 0) {
$tpl->assign('title', $thread['threadname']);
}
if ($thread['userID'] == 0) {
$tpl->assign('username', $thread['postname']);
}
ob_start();
if ($thread['attachments'] and $thread['attachmaxsize']) {
$attachs = $db->result(DB_PRE . 'ecp_forum_attachments', 'COUNT(attachID)', 'mID = ' . $id . ' AND tID = ' . $tid);
//.........这里部分代码省略.........
开发者ID:ECP-Black,项目名称:ECP,代码行数:101,代码来源:index.php
示例13: get_nonce
/**
* Russell, 2012-11-10: Shared functionality useed in index.php and
* codetester.php.
* Side-affect, can't use browser's back button to get old results as
* a re-post will have a different nonce so will block
*/
function get_nonce()
{
$nonce = isset($_SESSION['nonce']) ? $_SESSION['nonce'] : hash('sha512', get_random_string());
$_SESSION['nonce'] = $nonce;
return $nonce;
}
开发者ID:relliance,项目名称:easyphp-codetester-fix,代码行数:12,代码来源:functions.inc.php
示例14: Reactivate
/**
* Send activation email
* @param $email
*/
public static function Reactivate($email)
{
global $objSettings;
// deny all operations in demo version
if (strtolower(SITE_MODE) == 'demo') {
self::$static_error = _OPERATION_BLOCKED;
return false;
}
if (!empty($email)) {
if (check_email_address($email)) {
$sql = 'SELECT id, first_name, last_name, user_name, registration_code, preferred_language, is_active ';
if (!PASSWORDS_ENCRYPTION) {
$sql .= ', user_password ';
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'aes') {
$sql .= ', AES_DECRYPT(user_password, \'' . PASSWORDS_ENCRYPT_KEY . '\') as user_password ';
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'md5') {
$sql .= ', \'\' as user_password ';
}
}
}
$sql .= 'FROM ' . TABLE_CUSTOMERS . ' WHERE email = \'' . $email . '\'';
$temp = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY);
if (is_array($temp) && count($temp) > 0) {
if ($temp['registration_code'] != '' && $temp['is_active'] == '0') {
////////////////////////////////////////////////////////
if (!PASSWORDS_ENCRYPTION) {
$user_password = $temp['user_password'];
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'aes') {
$user_password = $temp['user_password'];
} else {
if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'md5') {
$user_password = get_random_string(8);
$sql = 'UPDATE ' . TABLE_CUSTOMERS . ' SET user_password = \'' . md5($user_password) . '\' WHERE id = ' . $temp['id'];
database_void_query($sql);
}
}
}
send_email($email, $objSettings->GetParameter('admin_email'), 'new_account_created_confirm_by_email',
|
请发表评论