本文整理汇总了PHP中studip_utf8encode函数的典型用法代码示例。如果您正苦于以下问题:PHP studip_utf8encode函数的具体用法?PHP studip_utf8encode怎么用?PHP studip_utf8encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了studip_utf8encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserDn
function getUserDn($username)
{
if ($this->send_utf8_credentials) {
$username = studip_utf8encode($username);
$reader_password = studip_utf8encode($this->reader_password);
}
$user_dn = "";
if (!($r = @ldap_bind($this->conn, $this->reader_dn, $this->reader_password))) {
$this->error_msg = sprintf(_("Anmeldung von %s fehlgeschlagen."), $this->reader_dn) . $this->getLdapError();
return false;
}
if (!($result = @ldap_search($this->conn, $this->base_dn, $this->getLdapFilter($username), array('dn')))) {
$this->error_msg = _("Durchsuchen des LDAP Baumes fehlgeschlagen.") . $this->getLdapError();
return false;
}
if (!ldap_count_entries($this->conn, $result)) {
$this->error_msg = sprintf(_("%s wurde nicht unterhalb von %s gefunden."), $username, $this->base_dn);
return false;
}
if (!($entry = @ldap_first_entry($this->conn, $result))) {
$this->error_msg = $this->getLdapError();
return false;
}
if (!($user_dn = @ldap_get_dn($this->conn, $entry))) {
$this->error_msg = $this->getLdapError();
return false;
}
return $user_dn;
}
示例2: xml_ready
/**
* Converts a given string to our xml friendly text.
* This step involves purifying the string
*
* @param String $string Input string to reformat
* @return String Reformatted string (optional HTML -> Markdown, UTF-8)
*/
public function xml_ready($string, $convert_to_markdown = true)
{
static $purifier = null;
static $fixer = null;
static $markdown = null;
if ($purifier === null) {
$purifier_config = HTMLPurifier_Config::createDefault();
$purifier_config->set('Cache.SerializerPath', realpath($GLOBALS['TMP_PATH']));
$purifier = new HTMLPurifier($purifier_config);
$markdown = new HTML_To_Markdown();
$markdown->set_option('strip_tags', true);
}
$string = studip_utf8encode($string);
$string = $purifier->purify($string);
if ($convert_to_markdown) {
$string = $markdown->convert($string);
$string = preg_replace('/\\[\\]\\((\\w+:\\/\\/.*?)\\)/', '', $string);
$string = preg_replace('/\\[(\\w+:\\/\\/.*?)\\/?\\]\\(\\1\\/?\\s+"(.*?)"\\)/isxm', '$2: $1', $string);
$string = preg_replace('/\\[(\\w+:\\/\\/.*?)\\/?\\]\\(\\1\\/?\\)/isxm', '$1', $string);
$string = preg_replace('/\\[(.*?)\\]\\((\\w+:\\/\\/.*?)\\)/', '$1: $2', $string);
}
$string = preg_replace('/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/', '', $string);
$string = trim($string);
$string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
return $string;
}
示例3: toJSON
public function toJSON()
{
$json_array = array();
foreach (get_object_vars($this) as $name => $value) {
$json_array[$name] = studip_utf8encode($value);
}
return json_encode($json_array);
}
示例4: configuration_action
public function configuration_action()
{
$template_factory = new Flexi_TemplateFactory(__DIR__ . '/templates');
$template = $template_factory->open('edit');
$template->links = Navigation::getItem('/start');
$template->config = WidgetHelper::getWidgetUserConfig($GLOBALS['user']->id, 'QUICK_SELECTION');
$template->plugin = $this;
header('X-Title: ' . _('Schnellzugriff konfigurieren'));
echo studip_utf8encode($template->render());
}
示例5: exportUser
/**
* Export of a single user
*
* @param User $user Userobject
* @return String vCard export string
*/
private static function exportUser(User $user)
{
// If user is not visible export nothing
if (!get_visibility_by_id($user->id)) {
return "";
}
// vCard exportheader
$vCard['BEGIN'] = 'VCARD';
$vCard['VERSION'] = '3.0';
$vCard['PRODID'] = 'Stud.IP//' . $GLOBALS['UNI_NAME_CLEAN'] . '//DE';
$vCard['REV'] = date('Y-m-d H:i:s');
$vCard['TZ'] = date('O');
// User specific data
//Fullname
$vCard['FN'] = studip_utf8encode($user->getFullname());
//Name
$vCard['N'][] = studip_utf8encode($user->Nachname);
$vCard['N'][] = studip_utf8encode($user->Vorname);
$vCard['N'][] = studip_utf8encode($user->info->title_rear);
$vCard['N'][] = studip_utf8encode($user->info->title_front);
// Adress
if (Visibility::verify('privadr', $user->id)) {
$vCard['ADR;TYPE=HOME'] = studip_utf8encode($user->info->privadr);
}
// Tel
if (Visibility::verify('private_phone', $user->id)) {
$vCard['TEL;TYPE=HOME'] = studip_utf8encode($user->info->privatnr);
}
if (Visibility::verify('private_cell', $user->id)) {
$vCard['TEL;TYPE=CELL'] = studip_utf8encode($user->info->privatcell);
}
// Email
if (get_local_visibility_by_id($user->id, 'email')) {
$vCard['EMAIL'] = studip_utf8encode($user->email);
}
// Photo
if (Visibility::verify('picture', $user->id)) {
// Fetch avatar
$avatar = Avatar::getAvatar($user->id);
// Only export if
if ($avatar->is_customized()) {
$vCard['PHOTO;JPEG;ENCODING=BASE64'] = base64_encode(file_get_contents($avatar->getFilename(Avatar::NORMAL)));
}
}
// vCard end
$vCard['END'] = 'VCARD';
// Produce string
foreach ($vCard as $index => $value) {
$exportString .= $value ? $index . ':' . (is_array($value) ? join(';', $value) : $value) . "\r\n" : "";
}
return $exportString;
}
示例6: up
function up()
{
DBManager::get()->exec("ALTER TABLE `config` MODIFY `type` enum('boolean','integer','string','array') NOT NULL DEFAULT 'boolean'");
DBManager::get()->exec("CREATE TABLE IF NOT EXISTS `user_online` (\n `user_id` char(32) NOT NULL,\n `last_lifesign` int(10) unsigned NOT NULL,\n PRIMARY KEY (`user_id`),\n KEY `last_lifesign` (`last_lifesign`)\n ) ENGINE=MyISAM");
DBManager::get()->exec("INSERT INTO user_online (user_id,last_lifesign) SELECT sid,UNIX_TIMESTAMP(changed) FROM user_data INNER JOIN auth_user_md5 ON sid = user_id");
$stmt = DBManager::get()->prepare("\n REPLACE INTO config\n (config_id, field, value, is_default, `type`, `range`, mkdate, chdate, description, comment)\n VALUES\n (MD5(:name), :name, :value, 1, :type, :range, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description, '')\n ");
foreach ($this->new_configs as $values) {
$stmt->execute($values);
}
$check = DBManager::get()->prepare("DELETE FROM user_config WHERE field=? AND user_id=?");
$stmt = DBManager::get()->prepare("\n REPLACE INTO user_config (userconfig_id, user_id, field, value, mkdate, chdate, comment)\n VALUES (?,?,?,?,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),'')");
//for all users:
$db = DBManager::get()->query("SELECT sid,val FROM user_data INNER JOIN auth_user_md5 ON sid = user_id");
while ($rs = $db->fetch(PDO::FETCH_ASSOC)) {
$user_id = $rs['sid'];
$vars = @unserialize($rs['val']);
if (is_array($vars)) {
foreach (array('my_messaging_settings', 'forum', 'my_schedule_settings', 'calendar_user_control_data') as $key) {
$option = $this->new_configs[$key];
$defaults = json_decode($option['value'], true);
if (is_array($vars[$key])) {
$old_values = array_intersect_key((array) $vars[$key], $defaults);
$new_values = array_merge($defaults, $old_values);
$check->execute(array($option['name'], $user_id));
$stmt->execute(array(md5($option['name'] . $user_id), $user_id, $option['name'], json_encode(studip_utf8encode($new_values))));
}
}
foreach (array('homepage_cache_own', 'CurrentLogin', 'LastLogin', '_my_sem_group_field', '_my_admin_inst_id') as $key) {
$option = $this->new_configs[$key];
if (isset($vars[$key])) {
$check->execute(array($option['name'], $user_id));
$stmt->execute(array(md5($option['name'] . $user_id), $user_id, $option['name'], (string) $vars[$key]));
}
}
if (isset($vars['my_studip_settings']['startpage_redirect'])) {
$option = $this->new_configs['my_studip_settings'];
$check->execute(array($option['name'], $user_id));
$stmt->execute(array(md5($option['name'] . $user_id), $user_id, $option['name'], (int) $vars['my_studip_settings']['startpage_redirect']));
}
if (isset($vars['_my_sem_open'])) {
$option = $this->new_configs['_my_sem_open'];
$check->execute(array($option['name'], $user_id));
$stmt->execute(array(md5($option['name'] . $user_id), $user_id, $option['name'], json_encode($vars['_my_sem_open'])));
}
}
}
DBManager::get()->exec("DROP TABLE `user_data`");
}
示例7: tablemapping_action
public function tablemapping_action($table_id)
{
PageLayout::setTitle(_("Datenmapping einstellen"));
$this->table = new FleximportTable($table_id);
Navigation::activateItem("/fleximport/process_" . $this->table['process_id']);
if (Request::isPost()) {
$tabledata = Request::getArray("tabledata");
$tabledata = array_merge($this->table['tabledata'], $tabledata);
$this->table['tabledata'] = $tabledata;
$this->table->store();
PageLayout::postMessage(MessageBox::success(_("Daten wurden gespeichert.")));
}
$datafield_object_types = array('User' => "user", 'Course' => "sem", 'CourseMember' => "usersemdata");
$this->datafields = Datafield::findBySQL("object_type = :object_type", array('object_type' => $datafield_object_types[$this->table['import_type']]));
if (Request::isAjax() && Request::isPost()) {
$output = array('func' => "STUDIP.Fleximport.updateTable", 'payload' => array('table_id' => $table_id, 'name' => $this->table['name'], 'html' => $this->render_template_as_string("import/_table.php")));
$this->response->add_header("X-Dialog-Execute", json_encode(studip_utf8encode($output)));
}
}
示例8: favor_action
/**
* Toggles whether a certain smiley is favored for the current user
*
* @param int $id Id of the smiley to favor/disfavor
* @param String $view View to return to
*/
function favor_action($id, $view)
{
try {
$state = $this->favorites->toggle($id);
$message = $state ? _('Der Smiley wurde zu Ihren Favoriten hinzugefügt.') : _('Der Smiley gehört nicht mehr zu Ihren Favoriten.');
$msg_box = MessageBox::success($message);
} catch (OutOfBoundsException $e) {
$state = $this->favorites->contain($id);
$message = _('Maximale Favoritenzahl erreicht. Vielleicht sollten Sie mal ausmisten? :)');
$msg_box = MessageBox::error($message);
}
if (Request::isXhr()) {
$this->response->add_header('Content-Type', 'application/json');
$this->render_text(json_encode(array('state' => $state, 'message' => studip_utf8encode($msg_box))));
} else {
PageLayout::postMessage($msg_box);
$this->redirect('smileys/index/' . $view . '#smiley' . $id);
}
}
示例9: triggerFollowingStudips
public static function triggerFollowingStudips($eventname, $release)
{
$output = array();
$payload = json_encode(studip_utf8encode($output));
foreach ($release->followers as $follower) {
$header = array();
if ($follower['security_token']) {
$calculatedHash = hash_hmac("sha1", $payload, $follower['security_token']);
$header[] = "X_HUB_SIGNATURE: sha1=" . $calculatedHash;
}
$header[] = "Content-Type: application/json";
$r = curl_init();
curl_setopt($r, CURLOPT_URL, $follower['url']);
curl_setopt($r, CURLOPT_POST, true);
curl_setopt($r, CURLOPT_HTTPHEADER, $header);
curl_setopt($r, CURLOPT_POSTFIELDS, $payload);
$result = curl_exec($r);
curl_close($r);
}
}
示例10: po_stringify
/**
* Prepares a string for use in .po file.
*
* @param String $string String to use in .po file
* @return String Processed string
*/
function po_stringify($string)
{
$string = studip_utf8encode($string);
$string = str_replace("\r", '', $string);
$chunks = explode("\n", $string);
if (count($chunks) === 1 && strlen($chunks[0]) < MAX_LINE_LENGTH) {
return '"' . po_escape($chunks[0]) . '"';
}
$result = '""' . "\n";
foreach ($chunks as $index => $chunk) {
$chunk = wordwrap($chunk, MAX_LINE_LENGTH);
$parts = explode("\n", $chunk);
foreach ($parts as $idx => $line) {
$current_last = $idx === count($parts) - 1;
$last = $current_last && $index === count($chunks) - 1;
$result .= '"' . po_escape($line) . ($last ? '' : ($current_last ? '\\n' : ' ')) . '"' . "\n";
}
}
return rtrim($result, "\n");
}
示例11: utf8encodeRecursive
/**
* This function tries to encode data of any type from Windows-1252 to
* UTF-8, and returns the encoded version.
*
* If the argument `$data` is an array or an object that implements
* `Traversable`, this function returns an associative array. Its keys
* are encoded to UTF-8 and its values are send to this function
* again.
*
* If the argument `$data` is a string or an object that responds to
* `__toString`, this function casts it to a string and encodes it to
* UTF-8.
*
* If the argument `$data` is of another scalar type (integer, float
* or boolean) or is null, this function just returns that value
* unchanged.
*
* If neither of these criteria match, this functions throws an
* InvalidArgumentException.
*
* @param $data mixed some data of any type that shall be encoded to
* UTF-8 in the aforementioned manner
*
* @return mixed that data encoded to UTF-8 as far as possible, see above
*
* @throws InvalidArgumentException This exception is thrown if there
* is no way to encode such an object to UTF-8, e.g. database
* connections, file handles etc.
*/
private static function utf8encodeRecursive($data)
{
// array-artiges wird rekursiv durchlaufen
if (is_array($data) || $data instanceof \Traversable) {
$new_data = array();
foreach ($data as $key => $value) {
$key = studip_utf8encode((string) $key);
$new_data[$key] = self::utf8encodeRecursive($value);
}
return $new_data;
} else {
if (is_string($data) || is_callable(array($data, '__toString'))) {
return studip_utf8encode((string) $data);
} elseif (is_null($data) || is_scalar($data)) {
return $data;
}
}
// alles andere ist ungültig
throw new \InvalidArgumentException();
}
示例12: before_filter
/**
* Common actions before any other action
*
* @param String $action Action to be executed
* @param Array $args Arguments passed to the action
* @throws Trails_Exception when either no course was found or the user
* may not access this area
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
// Try to find a valid course
if (Course::findCurrent()) {
$course_id = Course::findCurrent()->id;
} else {
throw new Trails_Exception(404, _('Es wurde keine Veranstaltung ausgewählt!'));
}
if (!$GLOBALS['perm']->have_studip_perm('tutor', $course_id)) {
throw new Trails_Exception(400);
}
// Get seminar instance
$this->course = Seminar::getInstance($course_id);
if (Navigation::hasItem('course/admin/dates')) {
Navigation::activateItem('course/admin/dates');
}
$this->show = array('regular' => true, 'irregular' => true, 'roomRequest' => true);
PageLayout::setHelpKeyword('Basis.Veranstaltungen');
PageLayout::addSqueezePackage('raumzeit');
$title = _('Verwaltung von Zeiten und Räumen');
$title = $this->course->getFullname() . ' - ' . $title;
PageLayout::setTitle($title);
$_SESSION['raumzeitFilter'] = Request::get('newFilter');
// bind linkParams for chosen semester and opened dates
URLHelper::bindLinkParam('raumzeitFilter', $_SESSION['raumzeitFilter']);
$this->checkFilter();
$this->selection = $this->getSemestersForCourse($this->course, $_SESSION['raumzeitFilter']);
if (!Request::isXhr()) {
$this->setSidebar();
} elseif (Request::isXhr() && $this->flash['update-times']) {
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE;
if ($semester_id === 'all') {
$semester_id = '';
}
$this->response->add_header('X-Raumzeit-Update-Times', json_encode(studip_utf8encode(array('course_id' => $this->course->id, 'html' => Seminar::GetInstance($this->course->id)->getDatesHTML(array('semester_id' => $semester_id, 'show_room' => true)) ?: _('nicht angegeben')))));
}
}
示例13: purify
/**
* Call HTMLPurifier to create safe HTML.
*
* @param string $dirty_html Unsafe or 'uncleaned' HTML code.
* @return string Clean and safe HTML code.
*/
public static function purify($dirty_html)
{
// remember created purifier so it doesn't have to be created again
static $purifier = NULL;
if ($purifier === NULL) {
$purifier = self::createPurifier();
}
return studip_utf8decode($purifier->purify(studip_utf8encode($dirty_html)));
}
示例14: store
/**
* store new value for existing config entry in database
* posts notification ConfigValueChanged if entry is changed
* @param string $field
* @param string $data
* @throws InvalidArgumentException
* @return boolean
*/
function store($field, $data)
{
if (!is_array($data) || !isset($data['value'])) {
$values['value'] = $data;
} else {
$values = $data;
}
switch ($this->metadata[$field]['type']) {
case 'boolean':
$values['value'] = (bool) $values['value'];
break;
case 'integer':
$values['value'] = (int) $values['value'];
break;
case 'array':
$values['value'] = json_encode(studip_utf8encode($values['value']));
break;
default:
$values['value'] = (string) $values['value'];
}
$entries = ConfigEntry::findByField($field);
if (count($entries) === 0) {
throw new InvalidArgumentException($field . " not found in config table");
}
if (isset($values['value'])) {
if (count($entries) == 1 && $entries[0]->is_default == 1) {
$entries[1] = clone $entries[0];
$entries[1]->setId($entries[1]->getNewId());
$entries[1]->setNew(true);
$entries[1]->is_default = 0;
}
$value_entry = $entries[0]->is_default == 1 ? $entries[1] : $entries[0];
$old_value = $value_entry->value;
$value_entry->value = $values['value'];
}
foreach ($entries as $entry) {
if (isset($values['section'])) {
$entry->section = $values['section'];
}
if (isset($values['comment'])) {
$entry->comment = $values['comment'];
}
// store the default-type for the modified entry
$entry->type = $this->metadata[$field]['type'];
if (count($entries) > 1 && !$entry->is_default && $entry->value == $entries[0]->value) {
$ret += $entry->delete();
} else {
$ret += $entry->store();
}
}
if ($ret) {
$this->fetchData();
if (isset($value_entry)) {
NotificationCenter::postNotification('ConfigValueDidChange', $this, array('field' => $field, 'old_value' => $old_value, 'new_value' => $value_entry->value));
}
}
return $ret > 0;
}
示例15: foreach
<? foreach ($items as $id => $item): ?>
<item>
<title><?php
echo htmlReady(studip_utf8encode($item['topic']));
?>
</title>
<link><?php
echo htmlReady(studip_utf8encode(sprintf($item_url_fmt, $studip_url, $id)));
?>
</link>
<description><![CDATA[<?php
echo studip_utf8encode(formatready($item['body'], 1, 1));
?>
]]></description>
<dc:contributor><![CDATA[<?php
echo studip_utf8encode($item['author']);
?>
]]></dc:contributor>
<dc:date><?php
echo gmstrftime('%Y-%m-%dT%H:%MZ', $item['date']);
?>
</dc:date>
<pubDate><?php
echo date('r', $item['date']);
?>
</pubDate>
</item>
<? endforeach; ?>
</channel>
</rss>