本文整理汇总了PHP中generate_key函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_key函数的具体用法?PHP generate_key怎么用?PHP generate_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_password_request
/**
* checks the validity of input parameters, fills $page['errors'] and
* $page['infos'] and send an email with confirmation link
*
* @return bool (true if email was sent, false otherwise)
*/
function process_password_request()
{
global $page, $conf;
if (empty($_POST['username_or_email'])) {
$page['errors'][] = l10n('Invalid username or email');
return false;
}
$user_id = get_userid_by_email($_POST['username_or_email']);
if (!is_numeric($user_id)) {
$user_id = get_userid($_POST['username_or_email']);
}
if (!is_numeric($user_id)) {
$page['errors'][] = l10n('Invalid username or email');
return false;
}
$userdata = getuserdata($user_id, false);
// password request is not possible for guest/generic users
$status = $userdata['status'];
if (is_a_guest($status) or is_generic($status)) {
$page['errors'][] = l10n('Password reset is not allowed for this user');
return false;
}
if (empty($userdata['email'])) {
$page['errors'][] = l10n('User "%s" has no email address, password reset is not possible', $userdata['username']);
return false;
}
$activation_key = generate_key(20);
list($expire) = pwg_db_fetch_row(pwg_query('SELECT ADDDATE(NOW(), INTERVAL 1 HOUR)'));
single_update(USER_INFOS_TABLE, array('activation_key' => pwg_password_hash($activation_key), 'activation_key_expire' => $expire), array('user_id' => $user_id));
$userdata['activation_key'] = $activation_key;
set_make_full_url();
$message = l10n('Someone requested that the password be reset for the following user account:') . "\r\n\r\n";
$message .= l10n('Username "%s" on gallery %s', $userdata['username'], get_gallery_home_url());
$message .= "\r\n\r\n";
$message .= l10n('To reset your password, visit the following address:') . "\r\n";
$message .= get_gallery_home_url() . '/password.php?key=' . $activation_key . '-' . urlencode($userdata['email']);
$message .= "\r\n\r\n";
$message .= l10n('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n";
unset_make_full_url();
$message = trigger_change('render_lost_password_mail_content', $message);
$email_params = array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Password Reset'), 'content' => $message, 'email_format' => 'text/plain');
if (pwg_mail($userdata['email'], $email_params)) {
$page['infos'][] = l10n('Check your email for the confirmation link');
return true;
} else {
$page['errors'][] = l10n('Error sending email');
return false;
}
}
示例2: find_available_feed_id
/**
* search an available feed_id
*
* @return string feed identifier
*/
function find_available_feed_id()
{
while (true) {
$key = generate_key(50);
$query = '
SELECT COUNT(*)
FROM ' . USER_FEED_TABLE . '
WHERE id = \'' . $key . '\'
;';
list($count) = pwg_db_fetch_row(pwg_query($query));
if (0 == $count) {
return $key;
}
}
}
示例3: find_available_check_key
function find_available_check_key()
{
while (true) {
$key = generate_key(16);
$query = '
select
count(*)
from
' . USER_MAIL_NOTIFICATION_TABLE . '
where
check_key = \'' . $key . '\';';
list($count) = pwg_db_fetch_row(pwg_query($query));
if ($count == 0) {
return $key;
}
}
}
示例4: signup
function signup()
{
require_once WPPR_PLUGIN_DIR . '/models/signup-model.php';
$model = new Signup_Model();
$username = sanitize_user($this->username);
$email = sanitize_email($this->email);
$password = $this->password;
$activation_key = generate_key($email);
$userdata = array($username, $email, wp_hash_password($password), $activation_key, CUR_DATE, REMOTE_IP);
if (is_wp_error($this->validate_signup())) {
$attributes['errors'] = $this->validate_signup()->get_error_message();
} else {
$result = $model->insert_signup($userdata);
if (!is_wp_error($result)) {
$attributes['success'] = 'Please check your email for confirmation';
//send email confirmation to user
$this->send_activation_link($username, $email, $password, $activation_key);
} else {
$attributes['errors'] = 'Something went wrong. Please try again later';
}
}
return $attributes;
}
示例5: update
private function update($post)
{
if (isset($post)) {
$account = $_POST['account'];
//Update account password
if ($_POST['submit'] == 1) {
$this->current_password = $account['current_password'];
$this->new_password = $account['new_password'];
$this->confirm_password = $account['confirm_password'];
$valid = $this->validate_password();
if (is_wp_error($valid)) {
$errors[] = $valid->get_error_message();
$result['errors'] = $errors;
} else {
$new_password = wp_hash_password($account['new_password']);
$success = wp_set_password($this->new_password, $this->user_id);
if (!is_wp_error($success)) {
$result['success'] = 1;
} else {
$result['errors'] = $success->get_error_message();
}
}
}
//Update email address
if ($_POST['submit'] == 2) {
$this->email = sanitize_email($account['email']);
$valid = $this->validate_email();
if (is_wp_error($valid)) {
$errors[] = $valid->get_error_message();
$result['errors'] = $errors;
} else {
$userdata = array('ID' => $this->user_id, 'user_email' => $this->email);
$update = wp_update_user($userdata);
if (!is_wp_error($update)) {
//generate key for validation
$this->key = generate_key($this->email);
if (metadata_exists('user', $this->user_id, 'is_email_verified')) {
update_user_meta($this->user_id, 'is_email_verified', 0, get_user_meta($this->user_id, 'is_email_verified', true));
} else {
add_user_meta($this->user_id, 'is_email_verified', 0, true);
}
if (metadata_exists('user', $this->user_id, 'email_verification_key')) {
update_user_meta($this->user_id, 'email_verification_key', $this->key, get_user_meta($this->user_id, 'email_verification_key', true));
} else {
add_user_meta($this->user_id, 'email_verification_key', $this->key, true);
}
//send verification link to email
$this->send_verification_link();
$result['success'] = 2;
} else {
$result['errors'] = $result->get_error_message();
}
}
}
if ($_POST['submit'] == 3) {
//generate key for validation
$this->key = generate_key($this->email);
update_user_meta($this->user_id, 'is_email_verified', 0, get_user_meta($this->user_id, 'is_email_verified', true));
update_user_meta($this->user_id, 'email_verification_key', $this->key, get_user_meta($this->user_id, 'email_verification_key', true));
$this->send_verification_link();
$result['success'] = 2;
}
wp_reset_postdata();
return $result;
}
}
示例6: config_edit
function config_edit()
{
extract($GLOBALS, EXTR_SKIP);
$ucsalt = substr(uniqid(rand()), 0, 6);
$ucfounderpw = md5(md5($ucfounderpw) . $ucsalt);
$regdate = time();
$ucauthkey = generate_key();
$ucsiteid = generate_key();
$ucmykey = generate_key();
$config = "<?php \r\ndefine('UC_DBHOST', '{$dbhost}');\r\n";
$config .= "define('UC_DBUSER', '{$dbuser}');\r\n";
$config .= "define('UC_DBPW', '{$dbpw}');\r\n";
$config .= "define('UC_DBNAME', '{$dbname}');\r\n";
$config .= "define('UC_DBCHARSET', '" . DBCHARSET . "');\r\n";
$config .= "define('UC_DBTABLEPRE', '{$tablepre}');\r\n";
$config .= "define('UC_COOKIEPATH', '/');\r\n";
$config .= "define('UC_COOKIEDOMAIN', '');\r\n";
$config .= "define('UC_DBCONNECT', 0);\r\n";
$config .= "define('UC_CHARSET', '" . CHARSET . "');\r\n";
$config .= "define('UC_FOUNDERPW', '{$ucfounderpw}');\r\n";
$config .= "define('UC_FOUNDERSALT', '{$ucsalt}');\r\n";
$config .= "define('UC_KEY', '{$ucauthkey}');\r\n";
$config .= "define('UC_SITEID', '{$ucsiteid}');\r\n";
$config .= "define('UC_MYKEY', '{$ucmykey}');\r\n";
$config .= "define('UC_DEBUG', false);\r\n";
$config .= "define('UC_PPP', 20);\r\n";
$fp = fopen(CONFIG, 'w');
fwrite($fp, $config);
fclose($fp);
}
示例7: unsubscribe
function unsubscribe($code = '')
{
global $db, $nl_config, $lang;
if (!empty($code)) {
$sql = "SELECT COUNT(abo_id) AS num_subscribe\n\t\t\t\tFROM " . ABO_LISTE_TABLE . "\n\t\t\t\tWHERE abo_id = " . $this->account['abo_id'];
if (!($result = $db->query($sql))) {
trigger_error('Impossible de vérifier la table de jointure', ERROR);
return false;
}
$num_subscribe = $result->column('num_subscribe');
$db->beginTransaction();
$sql = "DELETE FROM " . ABO_LISTE_TABLE . "\n\t\t\t\tWHERE liste_id = " . $this->listdata['liste_id'] . "\n\t\t\t\t\tAND abo_id = " . $this->account['abo_id'];
if (!$db->query($sql)) {
trigger_error('Impossible d\'effacer l\'entrée de la table abo_liste', ERROR);
return false;
}
if ($num_subscribe == 1) {
$sql = 'DELETE FROM ' . ABONNES_TABLE . '
WHERE abo_id = ' . $this->account['abo_id'];
if (!$db->query($sql)) {
trigger_error('Impossible d\'effacer l\'entrée de la table des abonnés', ERROR);
return false;
}
$this->message = $lang['Message']['Unsubscribe_3'];
} else {
$this->message = $lang['Message']['Unsubscribe_2'];
}
$db->commit();
$this->alert_admin(false);
return true;
} else {
$this->account['code'] = generate_key(20);
$sql = "UPDATE " . ABO_LISTE_TABLE . "\n\t\t\t\tSET register_key = '{$this->account['code']}'\n\t\t\t\tWHERE abo_id = {$this->account['abo_id']}\n\t\t\t\t\tAND liste_id = " . $this->listdata['liste_id'];
if (!$db->query($sql)) {
trigger_error('Impossible d\'assigner le nouvelle clé d\'enregistrement', ERROR);
return false;
}
$this->mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name']));
$this->mailer->set_address($this->account['email']);
$this->mailer->set_subject($lang['Subject_email']['Unsubscribe_1']);
$this->mailer->set_priority(3);
$this->mailer->set_return_path($this->listdata['return_email']);
$email_tpl = $this->listdata['use_cron'] ? 'unsubscribe_cron' : 'unsubscribe_form';
$this->mailer->use_template($email_tpl, array('LISTE' => unhtmlspecialchars($this->listdata['liste_name']), 'SITENAME' => $nl_config['sitename'], 'URLSITE' => $nl_config['urlsite'], 'SIG' => $this->listdata['liste_sig']));
if ($this->listdata['use_cron']) {
$this->mailer->assign_tags(array('EMAIL_NEWSLETTER' => $this->liste_email, 'CODE' => $this->account['code']));
} else {
$this->mailer->assign_tags(array('LINK' => $this->make_link()));
}
if (!$this->mailer->send()) {
$this->message = $lang['Message']['Failed_sending'];
return false;
}
$this->message = $lang['Message']['Unsubscribe_1'];
return true;
}
}
示例8: array_udiff
$emails = array_udiff($emails, $emails_ok, 'strcasecmp');
foreach ($emails as $email) {
$db->beginTransaction();
$sql_data = array();
$sql_data['abo_email'] = $email;
$sql_data['abo_status'] = ABO_ACTIF;
if (!$db->build(SQL_INSERT, ABONNES_TABLE, $sql_data)) {
$report .= sprintf('%s : SQL error (#%d: %s)%s', $email, $db->errno, $db->error, WA_EOL);
$db->rollBack();
continue;
}
$sql_data = array();
$sql_data['abo_id'] = $db->lastInsertId();
$sql_data['liste_id'] = $listdata['liste_id'];
$sql_data['format'] = $format;
$sql_data['register_key'] = generate_key(20, false);
$sql_data['register_date'] = $current_time;
$sql_data['confirmed'] = SUBSCRIBE_CONFIRMED;
if (!$db->build(SQL_INSERT, ABO_LISTE_TABLE, $sql_data)) {
trigger_error('Impossible d\'insérer une nouvelle entrée dans la table abo_liste', ERROR);
}
$db->commit();
fake_header(true);
}
}
//
// Selon que des emails ont été refusés ou pas, affichage du message correspondant
// et écriture éventuelle du rapport d'erreur
//
if ($report != '') {
if (is_writable(WA_TMPDIR) && ($fw = fopen(WA_TMPDIR . '/wa_import_report.txt', 'w'))) {
示例9: trim
// Mot de passe perdu
//
if ($mode == 'sendpass') {
$login = !empty($_POST['login']) ? trim($_POST['login']) : '';
$email = !empty($_POST['email']) ? trim($_POST['email']) : '';
if (isset($_POST['submit'])) {
$sql = "SELECT admin_id\n\t\t\tFROM " . ADMIN_TABLE . "\n\t\t\tWHERE LOWER(admin_login) = '" . $db->escape(strtolower($login)) . "'\n\t\t\t\tAND admin_email = '" . $db->escape($email) . "'";
if (!($result = $db->query($sql))) {
trigger_error('Impossible d\'obtenir les informations du compte', CRITICAL_ERROR);
}
if (!($admin_id = $result->column('admin_id'))) {
$error = TRUE;
$msg_error[] = $lang['Message']['Error_sendpass'];
}
if (!$error) {
$new_password = generate_key(12);
require WAMAILER_DIR . '/class.mailer.php';
$mailer = new Mailer(WA_ROOTDIR . '/language/email_' . $nl_config['language'] . '/');
if ($nl_config['use_smtp']) {
$mailer->smtp_path = WAMAILER_DIR . '/';
$mailer->use_smtp($nl_config['smtp_host'], $nl_config['smtp_port'], $nl_config['smtp_user'], $nl_config['smtp_pass']);
}
$mailer->set_charset($lang['CHARSET']);
$mailer->set_format(FORMAT_TEXTE);
$mailer->set_from($email);
$mailer->set_address($email);
$mailer->set_subject($lang['Subject_email']['New_pass']);
$mailer->use_template('new_admin_pass', array('PSEUDO' => $login, 'PASSWORD' => $new_password));
if (!$mailer->send()) {
trigger_error('Failed_sending', ERROR);
}
示例10: gappsconf
function gappsconf($req)
{
/* The following DNS recrods are added:
MX 10 ASPMX.L.GOOGLE.COM
MX 20 ALT1.ASPMX.L.GOOGLE.COM
MX 20 ALT2.ASPMX.L.GOOGLE.COM
MX 30 ASPMX2.GOOGLEMAIL.COM
MX 30 ASPMX3.GOOGLEMAIL.COM
MX 30 ASPMX4.GOOGLEMAIL.COM
MX 30 ASPMX5.GOOGLEMAIL.COM
calendar CNAME ghs.google.com
docs CNAME ghs.google.com
mail CNAME ghs.google.com
sites CNAME ghs.google.com
*/
$domain = $req['form']['domain'];
$rid = $_SESSION['rid'];
$global_salt = $_SESSION['global_salt'];
$user_salt = sha1($rid);
$key = generate_key($user_salt, $global_salt);
$password = symmetric_decrypt($_COOKIE['data'], $key);
$auth_params = "auth-userid={$rid}&auth-password={$password}";
$get_orderid_url = "https://test.httpapi.com/api/domains/orderid.json?{$auth_params}&domain-name={$domain}";
$result = file_get_contents($get_orderid_url);
if (is_equal(false, $result)) {
return array('template' => 'error', 'error_msg' => 'Could not fetch Order ID. Go back and try again.');
}
$orderid = $result;
$activate_url = "https://test.httpapi.com/api/dns/activate.json?{$auth_params}";
$add_cname_url = "https://test.httpapi.com/api/dns/manage/add-cname-record.json?{$auth_params}&domain-name={$domain}";
$add_mx_url = "https://test.httpapi.com/api/dns/manage/add-mx-record.json?{$auth_params}&domain-name={$domain}";
$requests[] = array("{$activate_url}&order-id={$orderid}", 'Activating DNS');
$requests[] = array("{$add_cname_url}&value=ghs.google.com&host=mail", "Adding CNAME for mail.{$domain}");
$requests[] = array("{$add_cname_url}&value=ghs.google.com&host=calendar", "Adding CNAME for calendar.{$domain}");
$requests[] = array("{$add_cname_url}&value=ghs.google.com&host=docs", "Adding CNAME for docs.{$domain}");
$requests[] = array("{$add_cname_url}&value=ghs.google.com&host=sites", "Adding CNAME for sites.{$domain}");
$requests[] = array("{$add_mx_url}&value=ASPMX.L.GOOGLE.COM&priority=10", "Adding MX: ASPMX.L.GOOGLE.COM");
$requests[] = array("{$add_mx_url}&value=ALT1.ASPMX.L.GOOGLE.COM&priority=20", "Adding MX: ALT1.ASPMX.L.GOOGLE.COM");
$requests[] = array("{$add_mx_url}&value=ALT2.ASPMX.L.GOOGLE.COM&priority=20", "Adding MX: ALT2.ASPMX.L.GOOGLE.COM");
$requests[] = array("{$add_mx_url}&value=ASPMX2.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX2.GOOGLEMAIL.COM");
$requests[] = array("{$add_mx_url}&value=ASPMX3.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX3.GOOGLEMAIL.COM");
$requests[] = array("{$add_mx_url}&value=ASPMX4.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX4.GOOGLEMAIL.COM");
$requests[] = array("{$add_mx_url}&value=ASPMX5.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX5.GOOGLEMAIL.COM");
$results = array();
foreach ($requests as $request) {
$result = file_get_contents($request[0]);
if (is_equal(false, $result)) {
return array('template' => 'error', 'error_msg' => "Error while adding {$request[1]}. Go back and try again.");
}
$results[] = array($request[1], json_decode($result, true));
}
return array('results' => $results);
}
示例11: user_options
/**
* Show Two-Step Authentication Options
*
* @codeCoverageIgnore
*
* @param \WP_User $user
*/
function user_options($user)
{
if (!isset($user->ID)) {
return;
}
wp_nonce_field('totp_options', '_nonce_totp_options', false);
$key = get_user_meta($user->ID, '_totp_key', true);
$site_name = get_bloginfo('name', 'display');
?>
<table class="form-table">
<tr id="totp">
<th><label for="totp-authcode"><?php
_e('Two-Step Authentication', 'dovedi');
?>
</label></th>
<td>
<?php
if (false === $key || empty($key)) {
$key = generate_key();
?>
<button type="button" class="button button-secondary" onclick="jQuery('#totp-enable').toggle();"><?php
esc_html_e('Enable', 'dovedi');
?>
</button>
<?php
} else {
?>
<button type="button" class="button button-secondary" onclick="if(confirm('<?php
echo esc_js(__('Are you sure you want to disable two-step authentication?', 'dovedi'));
?>
')){jQuery('[name=totp-key]').val('');}"><?php
esc_html_e('Disable', 'dovedi');
?>
</button>
<?php
}
?>
<div id="totp-enable" style="display:none;">
<br />
<img src="<?php
echo esc_url(get_qr_code($site_name, $user->user_email, $key));
?>
" id="totp-qrcode" />
<p><strong><?php
echo esc_html($key);
?>
</strong></p>
<ul>
<li><?php
esc_html_e('1. Either use your mobile device\'s Authenticator app to scan the QR code above or enter the key manually.', 'dovedi');
?>
</li>
<li><?php
esc_html_e('2. Then, enter an authentication code generated by the app in the field below and click "Update" to complete setup', 'dovedi');
?>
</li>
</ul>
<p>
<strong><label for="totp-authcode"><?php
esc_html_e('Authentication Code:', 'dovedi');
?>
</label></strong>
<input type="hidden" name="totp-key" value="<?php
echo esc_attr($key);
?>
" />
<input type="tel" name="totp-authcode" id="totp-authcode" class="input regular-text" value="" size="20" pattern="[0-9]*" />
</p>
</div>
</td>
</tr>
</table>
<?php
}
示例12: IN
// работа с задачами
// выбираем задачу + данные из таблицы стран относящиеся к задаче + табличку с лимитами ГДЕ id бота в таблице заданий есть как у пришедшего и в списке стран есть страна которая соответствует нашей, и бот не в списке финишировавших для этой задачи
$task = $db->query("SELECT * FROM tasks\r\nLEFT JOIN ccTaskFilter ON ccTaskFilter.taskId = tasks.id \r\nWHERE tasks.bot = '" . $bid . "' \r\nAND (tasks.count < tasks.`limit` OR tasks.`limit` = 0)\r\nAND (ccTaskFilter.cc = '" . $cc . "' OR ccTaskFilter.cc='all') \r\nAND '" . $bid . "' NOT IN (SELECT botId FROM finished WHERE finished.taskId = tasks.id)\r\nAND (tasks.stop = '0' OR tasks.stop = '-1')");
if ($task[0] == 0) {
// выбираем задачу + данные из таблицы стран относящиеся к задаче + табличку с лимитами ГДЕ id бота в таблице заданий для всех и в списке стран есть страна которая соответствует нашей, и бот не в списке финишировавших для этой задачи
$task = $db->query("SELECT * FROM tasks\r\nLEFT JOIN ccTaskFilter ON ccTaskFilter.taskId = tasks.id \r\nWHERE tasks.bot = 'all' \r\nAND (tasks.count < tasks.`limit` OR tasks.`limit` = 0)\r\nAND (ccTaskFilter.cc = '" . $cc . "' OR ccTaskFilter.cc='all') \r\nAND '" . $bid . "' NOT IN (SELECT botId FROM finished WHERE finished.taskId = tasks.id)\r\nAND (tasks.stop = '0' OR tasks.stop = '-1')");
}
$task[0] == 0 ? exit(SECRET_KEY) : false;
// формируем вывод задания
$taskOut = '';
foreach ($task as $k => $v) {
$v['flags'] = trim($v['flags']);
if (!empty($v['flags'])) {
$v['flags'] = str_split($v['flags']);
$v['flags'] = ' -' . implode(' -', $v['flags']);
}
// правка от 2 сентября 2011г.
if ($v['command'] == 'update') {
$v['flags'] = '';
}
$taskOut .= $v['command'] . $v['flags'] . ' ' . $v['url'] . ' ' . $v['functionName'] . "\r\n";
// ставим задачу в завершенные для этого бота
$db->query("INSERT INTO `finished` (`botId`, `taskId`) VALUES ('" . $bid . "', '" . $v['id'] . "');");
// умножаем лимитер на одну тиерацию если задание конечно по лимиту итераций
$db->query("UPDATE `tasks` SET `count` = '" . intval($v['count'] + 1) . "' WHERE `id` ='" . $v['id'] . "'");
}
//echo trim($taskOut,"\r\n");
$xorkey = generate_key(10);
exit($xorkey . encrypt($taskOut, $xorkey));
}
}
示例13: elgg_get_plugin_setting
<?php
namespace MBeckett\ElggCopy;
$key = elgg_get_plugin_setting('request_key', PLUGIN_ID);
if (!$key) {
$key = generate_key();
elgg_set_plugin_setting('request_key', $key, PLUGIN_ID);
}
示例14: generate_key
<?php
function generate_key($lenght)
{
$allowed = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
$key = "";
for ($i = 0; $i < $lenght; $i++) {
$key .= $allowed[rand(0, strlen($allowed) - 1)];
}
return $key;
}
$ssh_key = "";
if (is_numeric($_GET["lenght"]) && !empty($_GET["lenght"])) {
$ssh_key = generate_key($_GET["lenght"]);
} else {
$ssh_key = "impossible de générer une clé.";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<meta charset="utf-8" />
<title>Utils 0.1</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<form method="get" action=".">
<ul>
<li>
<label for="input_id">Longueur : </label>
示例15: pshare_get_key
function pshare_get_key()
{
$candidate = generate_key(30);
// in very rare cases, with Piwigo <2.8, generate_key may return some "="
// at the end
if (!preg_match(PSHARE_KEY_PATTERN, $candidate)) {
return pshare_get_key();
}
$query = '
SELECT
COUNT(*)
FROM ' . PSHARE_KEYS_TABLE . '
WHERE uuid = \'' . $candidate . '\'
;';
list($counter) = pwg_db_fetch_row(pwg_query($query));
if (0 == $counter) {
return $candidate;
} else {
return pshare_get_key();
}
}