本文整理汇总了PHP中sm_encode_html_special_chars函数的典型用法代码示例。如果您正苦于以下问题:PHP sm_encode_html_special_chars函数的具体用法?PHP sm_encode_html_special_chars怎么用?PHP sm_encode_html_special_chars使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sm_encode_html_special_chars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_viewheader
function parse_viewheader($imapConnection, $id, $passed_ent_id)
{
$header_output = array();
$second = array();
$first = array();
if (!$passed_ent_id) {
$read = sqimap_run_command($imapConnection, "FETCH {$id} BODY[HEADER]", true, $a, $b, TRUE);
} else {
$query = "FETCH {$id} BODY[" . $passed_ent_id . '.HEADER]';
$read = sqimap_run_command($imapConnection, $query, true, $a, $b, TRUE);
}
$cnum = 0;
for ($i = 1; $i < count($read); $i++) {
$line = sm_encode_html_special_chars($read[$i]);
switch (true) {
case preg_match('/^>/i', $line):
$second[$i] = $line;
$first[$i] = ' ';
$cnum++;
break;
// FIXME: is the pipe character below a mistake? I think the original author might have thought it carried special meaning in the character class, which it does not... but then again, I am not currently trying to understand what this code actually does
// FIXME: is the pipe character below a mistake? I think the original author might have thought it carried special meaning in the character class, which it does not... but then again, I am not currently trying to understand what this code actually does
case preg_match('/^[ |\\t]/', $line):
$second[$i] = $line;
$first[$i] = '';
break;
case preg_match('/^([^:]+):(.+)/', $line, $regs):
$first[$i] = $regs[1] . ':';
$second[$i] = $regs[2];
$cnum++;
break;
default:
$second[$i] = trim($line);
$first[$i] = '';
break;
}
}
for ($i = 0; $i < count($second); $i = $j) {
$f = isset($first[$i]) ? $first[$i] : '';
$s = isset($second[$i]) ? nl2br($second[$i]) : '';
$j = $i + 1;
while ($first[$j] == '' && $j < count($first)) {
$s .= ' ' . nl2br($second[$j]);
$j++;
}
$lowf = strtolower($f);
/* do not mark these headers as emailaddresses */
if ($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
parseEmail($s);
}
if ($f) {
$header_output[] = array($f, $s);
}
}
sqimap_logout($imapConnection);
return $header_output;
}
示例2: print_response
/**
* Print the IMAP response to options.php
*
* @param array $response results of imap command
* @access private
*/
function print_response($response)
{
foreach ($response as $value) {
if (is_array($value)) {
print_response($value);
} else {
print sm_encode_html_special_chars($value) . "<br />\n";
}
}
}
示例3: formatAddressList
/**
* Format the address book into a format that is easy for template authors
* to use
*
* @param array $addresses all contacts as given by calling $abook->list_addr()
* @return array
* @author Steve Brown
* @since 1.5.2
*/
function formatAddressList($addresses)
{
if (!is_array($addresses) || count($addresses) == 0) {
return array();
}
$contacts = array();
while (list($undef, $row) = each($addresses)) {
$contact = array('FirstName' => sm_encode_html_special_chars($row['firstname']), 'LastName' => sm_encode_html_special_chars($row['lastname']), 'FullName' => sm_encode_html_special_chars($row['name']), 'NickName' => sm_encode_html_special_chars($row['nickname']), 'Email' => sm_encode_html_special_chars($row['email']), 'FullAddress' => sm_encode_html_special_chars(AddressBook::full_address($row)), 'RawFullAddress' => AddressBook::full_address($row), 'Info' => sm_encode_html_special_chars($row['label']), 'Extra' => isset($row['extra']) ? $row['extra'] : NULL, 'Source' => sm_encode_html_special_chars($row['source']), 'JSEmail' => sm_encode_html_special_chars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES));
$contacts[] = $contact;
}
return $contacts;
}
示例4: drawmonthview
/**
* main logic for month view of calendar
* @return void
* @access private
*/
function drawmonthview()
{
global $year, $month, $color, $calendardata, $todayis;
$aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
$days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
while ($aday <= $days_in_month) {
echo html_tag('tr');
for ($j = 1; $j <= 7; $j++) {
$cdate = "{$month}";
$aday < 10 ? $cdate = $cdate . "0{$aday}" : ($cdate = $cdate . "{$aday}");
$cdate = $cdate . "{$year}";
if ($aday <= $days_in_month && $aday > 0) {
echo html_tag('td', '', 'left', $color[4], 'height="50" valign="top"') . "\n" . html_tag('div', '', 'right');
echo $cdate == $todayis ? '<font size="-1" color="' . $color[1] . '">[ ' . _("TODAY") . " ] " : '<font size="-1">';
echo "<a href=day.php?year={$year}&month={$month}&day=";
echo $aday < 10 ? "0" : "";
echo "{$aday}>{$aday}</a></font></div>";
} else {
echo html_tag('td', '', 'left', $color[0]) . "\n" . " ";
}
if (isset($calendardata[$cdate])) {
$i = 0;
while ($calfoo = each($calendardata[$cdate])) {
$calbar = $calendardata[$cdate][$calfoo['key']];
// FIXME: how to display multiline task
$title = '[' . $calfoo['key'] . '] ' . str_replace(array("\r", "\n"), array(' ', ' '), sm_encode_html_special_chars($calbar['message']));
// FIXME: link to nowhere
echo "<a href=\"#\" style=\"text-decoration:none; color: " . ($calbar['priority'] == 1 ? $color[1] : $color[6]) . "\" title=\"{$title}\">" . sm_encode_html_special_chars($calbar['title']) . "</a><br />\n";
$i = $i + 1;
if ($i == 2) {
break;
}
}
}
echo "\n</td>\n";
$aday++;
}
echo '</tr>';
}
}
示例5: fortune_function
/**
* Show fortune
* @access private
* @since 1.5.1
*/
function fortune_function()
{
global $oTemplate, $fortune_visible, $color, $fortune_command;
if (!$fortune_visible) {
return;
}
/* open handle and get all command output*/
$handle = popen($fortune_command, 'r');
$fortune = '';
while ($read = fread($handle, 1024)) {
$fortune .= $read;
}
/* if pclose return != 0, popen command failed. Yes, I know that it is broken when --enable-sigchild is used */
if (pclose($handle)) {
// i18n: %s shows executed fortune cookie command.
$fortune = sprintf(_("Unable to execute \"%s\"."), $fortune_command);
}
$oTemplate->assign('color', $color);
$oTemplate->assign('fortune', sm_encode_html_special_chars($fortune));
$output = $oTemplate->fetch('plugins/fortune/mailbox_index_before.tpl');
return array('mailbox_index_before' => $output);
}
示例6: folders_delete_ask
/**
* Presents a confirmation dialog to the user asking whether they're
* sure they want to delete this folder.
*/
function folders_delete_ask($imapConnection, $folder_name)
{
global $color, $default_folder_prefix, $oTemplate;
if ($folder_name == '') {
plain_error_message(_("You have not selected a folder to delete. Please do so.") . '<br /><a href="../src/folders.php">' . _("Click here to go back") . '</a>.', $color);
sqimap_logout($imapConnection);
$oTemplate->display('footer.tpl');
exit;
}
// hide default folder prefix (INBOX., mail/ or other)
$visible_folder_name = imap_utf7_decode_local($folder_name);
$quoted_prefix = preg_quote($default_folder_prefix, '/');
$prefix_length = preg_match("/^{$quoted_prefix}/", $visible_folder_name) ? strlen($default_folder_prefix) : 0;
$visible_folder_name = substr($visible_folder_name, $prefix_length);
sqimap_logout($imapConnection);
$oTemplate->assign('dialog_type', 'delete');
$oTemplate->assign('folder_name', sm_encode_html_special_chars($folder_name));
$oTemplate->assign('visible_folder_name', sm_encode_html_special_chars($visible_folder_name));
$oTemplate->display('folder_manip_dialog.tpl');
$oTemplate->display('footer.tpl');
exit;
}
示例7: fetch
/**
* Applies the template and returns the resultant content string.
*
* @param string $file The template file to use
*
* @return string The template contents after applying the given template
*
*/
function fetch($file)
{
// get right template file
//
$template = $this->get_template_file_path($file);
// special case stylesheet.tpl falls back to SquirrelMail's
// own default stylesheet
//
if (empty($template) && $file == 'css/stylesheet.tpl') {
$template = SM_PATH . 'css/default.css';
}
if (empty($template)) {
trigger_error('The template "' . sm_encode_html_special_chars($file) . '" could not be fetched!', E_USER_ERROR);
} else {
$aPluginOutput = array();
$temp = array(&$aPluginOutput, &$this);
$aPluginOutput = concat_hook_function('template_construct_' . $file, $temp, TRUE);
$this->assign('plugin_output', $aPluginOutput);
//$output = $this->apply_template($template);
$rendering_engine = $this->get_rendering_template_engine_object($file);
$output = $rendering_engine->apply_template($template);
// CAUTION: USE OF THIS HOOK IS HIGHLY DISCOURAGED AND CAN
// RESULT IN NOTICABLE PERFORMANCE DEGREDATION. Plugins
// using this hook will probably be rejected by the
// SquirrelMail team.
//
do_hook('template_output', $output);
return $output;
}
}
示例8: _
echo '<input type="submit" name="send1" value="' . _("Send Spam Report") . "\" />\n";
} else {
$spam_message = mime_fetch_body($imap_stream, $passed_id, $passed_ent_id, 50000);
if (strlen($spam_message) == 50000) {
$Warning = "\n[truncated by SpamCop]\n";
$spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
}
$action_url = "http://members.spamcop.net/sc";
if (isset($js_web) && $js_web) {
echo "<form method=\"post\" action=\"{$action_url}\" name=\"submitspam\"" . " enctype=\"multipart/form-data\">\n";
} else {
echo "<form method=\"post\" action=\"{$action_url}\" name=\"submitspam\"" . " enctype=\"multipart/form-data\" target=\"_blank\">\n";
}
?>
<input type="hidden" name="action" value="submit" />
<input type="hidden" name="oldverbose" value="1" />
<input type="hidden" name="spam" value="<?php
echo sm_encode_html_special_chars($spam_message);
?>
" />
<?php
echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
}
?>
</form>
</td>
</tr>
</table>
</body>
</html>
示例9: addSelect
/**
* Function to create a selectlist from an array.
* @param string $sName Field name
* @param array $aValues Field values array(key => value) results in:
* <option value="key">value</option>,
* although if $bUsekeys is FALSE, then it changes to:
* <option value="value">value</option>
* @param mixed $default The key(s) that will be selected (it is OK to pass
* in an array here in the case of multiple select lists)
* @param boolean $bUsekeys Use the keys of the array as option value or not
* @param array $aAttribs (since 1.5.1) Extra attributes
* @param boolean $bMultiple When TRUE, a multiple select list will be shown
* (OPTIONAL; default is FALSE (single select list))
* @param int $iSize Desired height of multiple select boxes
* (OPTIONAL; default is SMOPT_SIZE_NORMAL)
* (only applicable when $bMultiple is TRUE)
*
* @return string html formated selection box
* @todo add attributes argument for option tags and default css
*/
function addSelect($sName, $aValues, $default = null, $bUsekeys = false, $aAttribs = array(), $bMultiple = FALSE, $iSize = SMOPT_SIZE_NORMAL)
{
// only one element
if (!$bMultiple && count($aValues) == 1) {
$k = key($aValues);
$v = array_pop($aValues);
return addHidden($sName, $bUsekeys ? $k : $v, $aAttribs) . sm_encode_html_special_chars($v);
}
if (!isset($aAttribs['id'])) {
$aAttribs['id'] = $sName;
}
// make sure $default is an array, since multiple select lists
// need the chance to have more than one default...
//
if (!is_array($default)) {
$default = array($default);
}
global $oTemplate;
//FIXME: all the values in the $aAttribs list and $sName and both the keys and values in $aValues used to go thru sm_encode_html_special_chars()... I would propose that most everything that is assigned to the template should go thru that *in the template class* on its way between here and the actual template file. Otherwise we have to do something like: foreach ($aAttribs as $key => $value) $aAttribs[$key] = sm_encode_html_special_chars($value); $sName = sm_encode_html_special_chars($sName); $aNewValues = array(); foreach ($aValues as $key => $value) $aNewValues[sm_encode_html_special_chars($key)] = sm_encode_html_special_chars($value); $aValues = $aNewValues; And probably this too because it has to be matched to a value that has already been sanitized: $default = sm_encode_html_special_chars($default); (oops, watch out for when $default is an array! (multiple select lists))
$oTemplate->assign('aAttribs', $aAttribs);
$oTemplate->assign('aValues', $aValues);
$oTemplate->assign('bUsekeys', $bUsekeys);
$oTemplate->assign('default', $default);
$oTemplate->assign('name', $sName);
$oTemplate->assign('multiple', $bMultiple);
$oTemplate->assign('size', $iSize);
return $oTemplate->fetch('select.tpl');
}
示例10: error_message
/**
* Displays error message and URL to message listing
*
* Fifth argument ($color array) is removed in 1.5.2.
* @param string $message error message
* @param string $mailbox mailbox name
* @param integer $sort sort order
* @param integer $startMessage first message
* @since 1.0
*/
function error_message($message, $mailbox, $sort, $startMessage)
{
$urlMailbox = urlencode($mailbox);
$link = array('URL' => sqm_baseuri() . "src/right_main.php?sort={$sort}&startMessage={$startMessage}&mailbox={$urlMailbox}", 'TEXT' => sprintf(_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : sm_encode_html_special_chars(imap_utf7_decode_local($mailbox))));
error_box($message, $link);
}
示例11: sqsession_register
//
if (!sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION)) {
$just_logged_in = false;
}
$temp_just_logged_in = $just_logged_in;
$just_logged_in = false;
sqsession_register($just_logged_in, 'just_logged_in');
// now we're done with the PHP session, can send output to browser
//
displayPageHeader($color, $mailbox, $onload);
/* display a message to the user that their mail has been sent */
if (isset($mail_sent) && $mail_sent == 'yes') {
$note = _("Your mail has been sent.");
}
if (isset($note)) {
$oTemplate->assign('note', sm_encode_html_special_chars($note));
$oTemplate->display('note.tpl');
}
if ($temp_just_logged_in || $show_motd) {
$motd = trim($motd);
if ($show_motd || strlen($motd) > 0) {
$oTemplate->assign('motd', $motd);
$oTemplate->display('motd.tpl');
}
}
if ($aMailbox['EXISTS'] > 0) {
$aTemplateVars = showMessagesForMailbox($imapConnection, $aMailbox, $aProps, $iError);
if ($iError) {
}
foreach ($aTemplateVars as $k => $v) {
$oTemplate->assign($k, $v);
示例12: prepareMessageList
//.........这里部分代码省略.........
if (isset($aSearch) && count($aSearch) > 1 && $aQuery) {
$aQuery[] = "where=" . $aSearch[0];
$aQuery[] = "what=" . $aSearch[1];
}
$iUid = isset($aMsg['UID']) ? $aMsg['UID'] : $aId[$i];
if ($aQuery) {
$aQuery[] = "passed_id={$aId[$i]}";
$aQuery[] = "startMessage={$iPageOffset}";
}
foreach ($aCol as $k => $v) {
$title = $link = $target = $onclick = $link_extra = '';
$aColumns[$k] = array();
$value = isset($aMsg[$v]) ? $aMsg[$v] : '';
$sUnknown = _("Unknown recipient");
switch ($k) {
case SQM_COL_FROM:
$sUnknown = _("Unknown sender");
case SQM_COL_TO:
case SQM_COL_CC:
case SQM_COL_BCC:
$sTmp = false;
if ($value) {
if ($highlight_list && !$bHighLight) {
$bHighLight = highlightMessage($aCol[$k], $value, $highlight_list, $aFormattedMessages[$iUid]);
}
$aAddressList = parseRFC822Address($value);
$sTmp = getAddressString($aAddressList, array('best' => true));
$title = $title_maybe = '';
foreach ($aAddressList as $aAddr) {
$sPersonal = isset($aAddr[SQM_ADDR_PERSONAL]) ? $aAddr[SQM_ADDR_PERSONAL] : '';
$sMailbox = isset($aAddr[SQM_ADDR_MAILBOX]) ? $aAddr[SQM_ADDR_MAILBOX] : '';
$sHost = isset($aAddr[SQM_ADDR_HOST]) ? $aAddr[SQM_ADDR_HOST] : '';
if ($sPersonal) {
$title .= sm_encode_html_special_chars($sMailbox . '@' . $sHost) . ', ';
} else {
// if $value gets truncated we need to add the addresses with no
// personal name as well
$title_maybe .= sm_encode_html_special_chars($sMailbox . '@' . $sHost) . ', ';
}
}
if ($title) {
$title = substr($title, 0, -2);
// strip ', ';
}
$sTmp = decodeHeader($sTmp);
if (isset($aColumnDesc[$k]['truncate']) && $aColumnDesc[$k]['truncate']) {
$sTrunc = sm_truncate_string($sTmp, $aColumnDesc[$k]['truncate'], '...', TRUE);
if ($sTrunc != $sTmp) {
if (!$title) {
$title = $sTmp;
} else {
if ($title_maybe) {
$title = $title . ', ' . $title_maybe;
$title = substr($title, 0, -2);
// strip ', ';
}
}
}
$sTmp = $sTrunc;
}
}
$value = $sTmp ? substr($sTmp, 0, 6) == '"' && substr($sTmp, -6) == '"' ? substr(substr($sTmp, 0, -6), 6) : $sTmp : $sUnknown;
break;
case SQM_COL_SUBJ:
// subject is mime encoded, decode it.
// value is sanitized in decoding function.
示例13: sqspell_handle_crypt_panic
/**
* Displays form that allows to enter different password for dictionary decryption.
* If language is not set, function provides form to handle older dictionary files.
* @param string $lang language
* @since 1.5.1 (sqspell 0.5)
*/
function sqspell_handle_crypt_panic($lang = false)
{
if (!sqgetGlobalVar('SCRIPT_NAME', $SCRIPT_NAME, SQ_SERVER)) {
$SCRIPT_NAME = '';
}
/**
* AAAAAAAAAAAH!!!!! OK, ok, breathe!
* Let's hope the decryption failed because the user changed his
* password. Bring up the option to key in the old password
* or wipe the file and start over if everything else fails.
*
* The _("SquirrelSpell...) line has to be on one line, otherwise
* gettext will bork. ;(
*/
$msg = html_tag('p', "\n" . '<strong>' . _("ATTENTION:") . '</strong><br />' . _("SquirrelSpell was unable to decrypt your personal dictionary. This is most likely due to the fact that you have changed your mailbox password. In order to proceed, you will have to supply your old password so that SquirrelSpell can decrypt your personal dictionary. It will be re-encrypted with your new password after this. If you haven't encrypted your dictionary, then it got mangled and is no longer valid. You will have to delete it and start anew. This is also true if you don't remember your old password -- without it, the encrypted data is no longer accessible."), 'left') . "\n" . ($lang ? html_tag('p', sprintf(_("Your %s dictionary is encrypted with password that differs from your current password."), sm_encode_html_special_chars($lang)), 'left') : '') . '<blockquote>' . "\n" . '<form method="post" onsubmit="return AYS()">' . "\n" . '<input type="hidden" name="MOD" value="crypto_badkey" />' . "\n" . ($lang ? '<input type="hidden" name="dict_lang" value="' . sm_encode_html_special_chars($lang) . '" />' : '<input type="hidden" name="old_setup" value="yes" />') . html_tag('p', "\n" . '<input type="checkbox" name="delete_words" value="ON" id="delete_words" />' . '<label for="delete_words">' . _("Delete my dictionary and start a new one") . '</label><br /><label for="old_key">' . _("Decrypt my dictionary with my old password:") . '</label><input type="text" name="old_key" id="old_key" size="10" />', 'left') . "\n" . '</blockquote>' . "\n" . html_tag('p', "\n" . '<input type="submit" value="' . _("Proceed") . ' >>" />', 'center') . "\n" . '</form>' . "\n";
/**
* Add some string vars so they can be i18n'd.
*/
$msg .= "<script type=\"text/javascript\"><!--\n" . "var ui_choice = \"" . _("You must make a choice") . "\";\n" . "var ui_candel = \"" . _("You can either delete your dictionary or type in the old password. Not both.") . "\";\n" . "var ui_willdel = \"" . _("This will delete your personal dictionary file. Proceed?") . "\";\n" . "//--></script>\n";
/**
* See if this happened in the pop-up window or when accessing
* the SpellChecker options page.
* This is a dirty solution, I agree.
* TODO: make this prettier.
*/
if (strstr($SCRIPT_NAME, "sqspell_options")) {
sqspell_makePage(_("Error Decrypting Dictionary"), "decrypt_error.js", $msg);
} else {
sqspell_makeWindow(null, _("Error Decrypting Dictionary"), "decrypt_error.js", $msg);
}
exit;
}
示例14: sqimap_mailbox_list_all
if ($show_only_subscribed_folders && !$no_list_for_subscribe) {
// FIXME: fix subscription options when top folder is not subscribed and sub folder is subscribed
// TODO: use checkboxes instead of select options.
// DONE Steve Brown 2006-08-08
/** SUBSCRIBE TO FOLDERS **/
$boxes_all = sqimap_mailbox_list_all($imapConnection);
// here we filter out all boxes we're already subscribed to,
// so we keep only the unsubscribed ones.
foreach ($boxes_all as $box_a) {
$use_folder = true;
foreach ($boxes as $box) {
if ($box_a['unformatted'] == $box['unformatted'] || $box_a['unformatted-dm'] == $folder_prefix) {
$use_folder = false;
}
}
if ($use_folder) {
$box_enc = sm_encode_html_special_chars($box_a['unformatted-dm']);
$box_disp = sm_encode_html_special_chars(imap_utf7_decode_local($box_a['unformatted-disp']));
$subbox_option_list[] = array('Value' => $box_enc, 'Display' => $box_disp);
}
}
}
sqimap_logout($imapConnection);
$oTemplate->assign('show_subfolders_option', $show_contain_subfolders_option);
$oTemplate->assign('show_only_subscribed_folders', $show_only_subscribed_folders == 1);
$oTemplate->assign('no_list_for_subscribe', $no_list_for_subscribe);
$oTemplate->assign('mbx_option_list', $mbx_option_list);
$oTemplate->assign('rendel_folder_list', $rendel_folder_list);
$oTemplate->assign('subbox_option_list', $subbox_option_list);
$oTemplate->display('folder_manip.tpl');
$oTemplate->display('footer.tpl');
示例15: cpw_peardb_passwd_hash
/**
* Encode password
* @param string $password plain text password
* @param string $crypto used crypto
* @param array $msgs error messages
* @param string $forced_salt old password used to create password hash for verification
* @return string hashed password. false, if hashing fails
*/
function cpw_peardb_passwd_hash($password, $crypto, &$msgs, $forced_salt = '')
{
global $username;
$crypto = strtolower($crypto);
$ret = false;
$salt = '';
// extra symbols used for random string in crypt salt
// squirrelmail GenerateRandomString() adds alphanumerics with third argument = 7.
$extra_salt_chars = './';
switch ($crypto) {
case 'plain-md5':
$ret = '{PLAIN-MD5}' . md5($password);
break;
case 'digest-md5':
// split username into user and domain parts
if (preg_match("/(.*)@(.*)/", $username, $match)) {
$ret = '{DIGEST-MD5}' . md5($match[1] . ':' . $match[2] . ':' . $password);
} else {
array_push($msgs, _("Unable to use digest-md5 crypto."));
}
break;
case 'tagged_crypt':
case 'crypt':
if (!defined('CRYPT_STD_DES') || CRYPT_STD_DES == 0) {
array_push($msgs, sprintf(_("Unsupported crypto: %s"), 'crypt'));
break;
}
if ($forced_salt == '') {
$salt = GenerateRandomString(2, $extra_salt_chars, 7);
} else {
$salt = $forced_salt;
}
$ret = $crypto == 'tagged_crypt' ? '{crypt}' : '';
$ret .= crypt($password, $salt);
break;
case 'tagged_md5crypt':
case 'md5crypt':
if (!defined('CRYPT_MD5') || CRYPT_MD5 == 0) {
array_push($msgs, sprintf(_("Unsupported crypto: %s"), 'md5crypt'));
break;
}
if ($forced_salt == '') {
$salt = '$1$' . GenerateRandomString(9, $extra_salt_chars, 7);
} else {
$salt = $forced_salt;
}
$ret = $crypto == 'tagged_md5crypt' ? '{crypt}' : '';
$ret .= crypt($password, $salt);
break;
case 'tagged_extcrypt':
case 'extcrypt':
if (!defined('CRYPT_EXT_DES') || CRYPT_EXT_DES == 0) {
array_push($msgs, sprintf(_("Unsupported crypto: %s"), 'extcrypt'));
break;
}
if ($forced_salt == '') {
$salt = '_' . GenerateRandomString(8, $extra_salt_chars, 7);
} else {
$salt = $forced_salt;
}
$ret = $crypto == 'tagged_extcrypt' ? '{crypt}' : '';
$ret .= crypt($password, $salt);
break;
case 'tagged_blowfish':
case 'blowfish':
if (!defined('CRYPT_BLOWFISH') || CRYPT_BLOWFISH == 0) {
array_push($msgs, sprintf(_("Unsupported crypto: %s"), 'blowfish'));
break;
}
if ($forced_salt == '') {
$salt = '$2a$12$' . GenerateRandomString(13, $extra_salt_chars, 7);
} else {
$salt = $forced_salt;
}
$ret = $crypto == 'tagged_blowfish' ? '{crypt}' : '';
$ret .= crypt($password, $salt);
break;
case 'plain':
case 'plaintext':
$ret = $password;
break;
default:
array_push($msgs, sprintf(_("Unsupported crypto: %s"), sm_encode_html_special_chars($crypto)));
}
return $ret;
}