本文整理汇总了PHP中Safe类的典型用法代码示例。如果您正苦于以下问题:PHP Safe类的具体用法?PHP Safe怎么用?PHP Safe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Safe类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: inputExists
public function inputExists( Safe $inputType = null, Safe $inputName, Safe $inputDefault = null ){
if( $inputType !== null ){
$inputType = $inputType->toString();
}
if( $inputDefault !== null ){
$inputDefault = $inputDefault->toString();
}
foreach( $this->_inputArray as $inputArray ){
if( $inputArray['inputType'] == $inputType && $inputArray['inputName'] == $inputName->toString() && $inputArray['inputDefault'] == $inputDefault ){
return true;
}
}
return false;
}
开发者ID:robertkeizer,项目名称:language-compositor,代码行数:15,代码来源:FunctionNode.php
示例2: POST_emailAction
/**
* 通过邮箱找回密码
* @method POST_emailAction
* @author NewFuture
*/
public function POST_emailAction()
{
$response['status'] = 0;
if (!Input::post('email', $email, 'email')) {
$response['info'] = '邮箱格式有误或者不支持!';
} elseif (!Input::post('account', $account, Config::get('regex.account'))) {
$response['info'] = '学号格式有误!';
} elseif (!Safe::checkTry('pwd_email_' . $account)) {
$response['info'] = '尝试次数过多,临时封禁!';
} elseif (!($Printer = PrinterModel::where('account', $account)->field('id,email')->find())) {
$response['info'] = '尚未注册,或者账号错误';
} elseif (empty($Printer['email'])) {
$response['info'] = '未绑定邮箱,或邮箱不存在';
} elseif ($Printer['email'] != $email) {
$response['info'] = '绑定邮箱不一致,或者邮箱错误';
} elseif (!Mail::findPwd($email, $code = Random::code(6))) {
$response['info'] = '邮件发送出错,请联系我们!';
} else {
/*发送成功*/
$find = ['id' => $user['id'], 'account' => $account, 'code' => strtoupper($code)];
Session::set('find_info_p', $find);
Safe::del('pwd_email_' . $account);
$response['status'] = 1;
$response['info'] = '验证邮件已发送!';
}
$this->response = $response;
}
开发者ID:derek-chow,项目名称:YunYinService,代码行数:32,代码来源:Password.php
示例3: POST_emailAction
/**
* 通过邮箱找回密码
* @method POST_emailAction
* @author NewFuture
*/
public function POST_emailAction()
{
$response['status'] = 0;
if (!Input::post('email', $email, 'email')) {
$response['info'] = '邮箱格式有误或者不支持!';
} elseif (!Input::post('number', $number, 'card')) {
$response['info'] = '学号格式有误!';
} elseif (!Safe::checkTry('pwd_email_' . $number)) {
$response['info'] = '尝试次数过多,临时封禁!';
} elseif (!($user = UserModel::where('number', $number)->field('id,name,email')->find())) {
$response['info'] = '尚未注册,或者学号错误';
} elseif (empty($user['email'])) {
$response['info'] = '未绑定邮箱,或者学号错误';
} elseif (Encrypt::decryptEmail($user['email']) != $email) {
$response['info'] = '绑定邮箱不一致,或者邮箱错误';
} elseif (!Mail::findPwd($email, $code = Random::code(6), $user['name'])) {
$response['info'] = '邮件发送出错,请联系我们!';
} else {
/*发送成功*/
$findPwd = ['id' => $user['id'], 'number' => $number, 'code' => strtoupper($code)];
Session::set('find_info', $findPwd);
Safe::del('pwd_email_' . $number);
$response['status'] = 1;
$response['info'] = '找回验证码已发送到' . $email;
}
$this->response = $response;
}
开发者ID:derek-chow,项目名称:YunYinService,代码行数:32,代码来源:Password.php
示例4: indexAction
/**
* 登录注册验证
* @method indexAction
* @return [type] [description]
* @author NewFuture
*/
public function indexAction()
{
if (Input::post('number', $number, 'card') && Input::post('password', $password, 'trim')) {
Input::post('sch_id', $sch_id, 'int');
$safekey = $sch_id . 'auth_' . $number;
if (!Safe::checkTry($safekey, 5)) {
$this->response(0, '尝试次过度,账号临时封禁');
} elseif (Input::post('code', $code, 'ctype_alnum')) {
/*输入验证码直接验证*/
if ($this->verify($number, $password, $sch_id, $code)) {
/*验证通过*/
Safe::del($safekey);
} else {
$this->response(-1, '学校账号验证失败,请检查密码是否正确,您也可尝试登录该系统!');
}
} elseif ($result = $this->login($number, md5($password), $sch_id)) {
/*登录成功*/
Safe::del($safekey);
} elseif ($sch_id && false === $result) {
/*指定学校后登录失败*/
$this->response(-1, '登录失败!请检查学号和密码是否正确,或者找回密码!');
} elseif ($this->verify($number, $password, $sch_id)) {
/*验证成功*/
Safe::del($safekey);
} else {
/*注册验证失败*/
$this->response(-1, '验证出错,请检查学号或者密码是否正确!');
}
} else {
$this->response(-1, '学号或者密码无效!');
}
}
开发者ID:derek-chow,项目名称:YunYinService,代码行数:38,代码来源:Auth.php
示例5: de
/**
* 通过Cookie_Key解密数据或数组
*
* @param $data
* @return array|string
*/
public function de($data)
{
if ($data === null) {
return $data;
}
return is_array($data) ? array_map(array($this, 'de'), $data) : Safe::decrypt($data, COOKIE_KEY);
}
开发者ID:Wanyor,项目名称:ProjectManager,代码行数:13,代码来源:cookie.php
示例6: check_file
function check_file($node)
{
global $context;
global $footprints;
$key = substr($node, strlen($context['path_to_root']));
// no extension to check
if (strpos($key, '.') === FALSE) {
} elseif (!strncmp($node, 'scripts/staging', 16)) {
} elseif (!strcmp($key, 'footprints.php')) {
} elseif (!strncmp(substr($key, -9), 'index.php', 9) && ($content = Safe::file_get_contents($node)) && !strcmp($content, Safe::mkdir_index_content())) {
} elseif (!strncmp($key, 'temporary/cache_i18n_locale_', 28)) {
} elseif (!strncmp(substr($key, -4), '.php', 4)) {
// one of the parameter files created by yacs
if (preg_match('/parameters\\/(agents|control|feeds|files|hooks|letters|root|scripts|services|skins|users|virtual_.+)\\.include\\.php$/i', $key)) {
} elseif (isset($footprints[$key])) {
$expected = $footprints[$key];
$actual = Scripts::hash($node);
if ($expected[0] != $actual[0] || $expected[1] != $actual[1]) {
$context['text'] .= sprintf(i18n::s('ERROR: File %s is missing or corrupted.'), $key) . BR . "\n";
}
} else {
$context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
}
// not a safe file
} elseif (!preg_match('/\\.(bak|bat|css|done|dtd|fdb|flv|gif|ico|jpeg|jpg|js|jsmin|htc|htm|html|mo|off|on|pdf|png|po|pot|reg|sh|sql|swf|tgz|txt|xml|zip)$/i', $key)) {
$context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
}
}
开发者ID:rair,项目名称:yacs,代码行数:28,代码来源:check.php
示例7: render
/**
* render graphviz object
*
* @return string the rendered text
**/
public function render($matches)
{
global $context;
list($text, $variant) = $matches;
// sanity check
if (!$text) {
$text = 'Hello->World!';
}
// remove tags put by WYSIWYG editors
$text = strip_tags(str_replace(array('>', '<', '&', '"', '\\"'), array('>', '<', '&', '"', '"'), str_replace(array('<br />', '</p>'), "\n", $text)));
// build the .dot content
switch ($variant) {
case 'digraph':
default:
$text = 'digraph G { ' . $text . ' }' . "\n";
break;
}
// id for this object
$hash = md5($text);
// path to cached files
$path = $context['path_to_root'] . 'temporary/graphviz.';
// we cache content
if ($content = Safe::file_get_contents($path . $hash . '.html')) {
return $content;
}
// build a .dot file
if (!Safe::file_put_contents($path . $hash . '.dot', $text)) {
$content = '[error writing .dot file]';
return $content;
}
// process the .dot file
if (isset($context['dot.command'])) {
$command = $context['dot.command'];
} else {
$command = 'dot';
}
// $font = '"/System/Library/Fonts/Times.dfont"';
// $command = '/sw/bin/dot -v -Nfontname='.$font
$command .= ' -Tcmapx -o "' . $path . $hash . '.map"' . ' -Tpng -o "' . $path . $hash . '.png"' . ' "' . $path . $hash . '.dot"';
if (Safe::shell_exec($command) == NULL) {
$content = '[error while using graphviz]';
return $content;
}
// produce the HTML
$content = '<img src="' . $context['url_to_root'] . 'temporary/graphviz.' . $hash . '.png" usemap="#mainmap" />';
$content .= Safe::file_get_contents($path . $hash . '.map');
// put in cache
Safe::file_put_contents($path . $hash . '.html', $content);
// done
return $content;
}
开发者ID:rair,项目名称:yacs,代码行数:56,代码来源:code_graphviz.php
示例8: login
/**
* login
*
* The script checks provided name and password against remote server.
*
* This is done by transmitting the user name and the password
* while opening a FTP session to the server.
*
* @param string the nickname of the user
* @param string the submitted password
* @return TRUE on succesful authentication, FALSE othewise
*/
function login($name, $password)
{
global $context;
// we need some parameters
if (!isset($this->attributes['authenticator_parameters']) || !$this->attributes['authenticator_parameters']) {
Logger::error(i18n::s('Please provide parameters to the authenticator.'));
return FALSE;
}
// prepare network parameters
$server = $this->attributes['authenticator_parameters'];
if (strstr($server, ':')) {
list($server, $port) = explode(':', $server, 2);
} else {
$port = 21;
}
// open network socket
if (!($handle = Safe::fsockopen($server, $port))) {
Logger::error(sprintf(i18n::s('Impossible to connect to %.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// read welcome banner
if (!($line = fgets($handle, 256)) || !strstr($line, '2')) {
fclose($handle);
Logger::error(sprintf(i18n::s('Invalid banner message from %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// submit name
fputs($handle, "USER {$username}\r\n");
if (!($line = fgets($handle, 256)) || !strstr($line, '3')) {
fclose($handle);
Logger::error(sprintf(i18n::s('Impossible to submit name to %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// submit password
fputs($handle, "PASS {$password}\r\n");
if (!($line = fgets($handle, 256)) || !strstr($line, '2')) {
fclose($handle);
Logger::error(sprintf(i18n::s('Impossible to submit password to %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// close ftp session
fputs($handle, "QUIT\r\n");
fclose($handle);
// this is a valid user
return TRUE;
}
开发者ID:rair,项目名称:yacs,代码行数:58,代码来源:ftp.php
示例9: allow
/**
* check access rights
*
* @param string script name
* @paral string target anchor, if any
* @return boolean FALSE if access is denied, TRUE otherwise
*/
function allow($script, $anchor = NULL)
{
global $context;
// limit the scope of our check
if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
return TRUE;
}
// sanity check
if (!$anchor) {
die(i18n::s('No anchor has been found.'));
}
// stop here if the agreement has been gathered previously
if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
foreach ($agreements as $agreement) {
if ($agreement == $anchor) {
return TRUE;
}
}
}
// which agreement?
if (!$this->parameters) {
die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
}
// do we have a related file to display?
if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
}
// splash message
$context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
// load and display the file to be displayed
$context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
// target link to record agreement
if ($context['with_friendly_urls'] == 'Y') {
$agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
} else {
$agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
}
// display confirmation buttons at the end of the agreement
$context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
$context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
$context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
// render the skin based only on text provided by this behavior
render_skin();
exit;
}
开发者ID:rair,项目名称:yacs,代码行数:52,代码来源:agree_on_file_access.php
示例10: POST_indexAction
/**
* 打印店登录
* @method loginAction
* @return [type] [description]
* @author NewFuture
*/
public function POST_indexAction()
{
$response['status'] = 0;
if (!Input::post('account', $account, Config::get('regex.account'))) {
$response['info'] = '账号格式错误';
} elseif (!Input::post('password', $password, 'isMd5')) {
$response['info'] = '密码未加密处理';
} elseif (!Safe::checkTry('printer_auth_' . $account)) {
$response['info'] = '尝试次数过多账号临时封禁,稍后重试或者联系我们';
} elseif (!($Printer = PrinterModel::where('account', $account)->field('id,sch_id,password,status,name')->find())) {
$response['info'] = '账号错误';
} elseif (Encrypt::encryptPwd($password, $account) != $Printer['password']) {
$response['info'] = '密码错误';
} else {
Safe::del('printer_auth_' . $account);
unset($Printer['password']);
$sid = Session::start();
Session::set('printer', ['id' => $Printer['id'], 'sch_id' => $Printer['sch_id']]);
$response['status'] = 1;
$response['info'] = ['sid' => $sid, 'printer' => $Printer];
}
$this->response = $response;
}
开发者ID:derek-chow,项目名称:YunYinService,代码行数:29,代码来源:Auth.php
示例11: validateDocumentPost
// build the form
$context['text'] .= Skin::build_form($fields);
// the submit button
$context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
// end of the form
$context['text'] .= '</div></form>';
// the script used for form handling at the browser
Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' // letter_title is mandatory' . "\n" . ' if(!container.letter_title.value) {' . "\n" . ' alert("' . i18n::s('No title has been provided.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . "\n" . 'document.main_form.letter_title.focus();' . "\n");
// no mail in demo mode
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
// handle posted data
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
// ensure all letters will be sent even if the browser connection dies
Safe::ignore_user_abort(TRUE);
// always archive the letter
$anchor = Sections::lookup('letters');
// no section yet, create one
if (!$anchor) {
$context['text'] .= i18n::s('Creating a section for archived letters') . BR . "\n";
$fields['nick_name'] = 'letters';
$fields['title'] = i18n::c('Archived letters');
$fields['introduction'] = i18n::c('To remember our previous messages');
$fields['description'] = i18n::c('YACS puts automatically sent letters into this section.');
$fields['locked'] = 'Y';
// no direct contributions
$fields['index_map'] = 'N';
// listed only to associates
$fields['rank'] = 30000;
// at the end of the list
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:new.php
示例12: elseif
} elseif (!$permitted) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
// touch the related anchor before actual deletion, since the table has to be accessible at that time
if (is_object($anchor)) {
$anchor->touch('table:delete', $item['id']);
}
// delete and go back to the anchor or to the index page
if (Tables::delete($item['id'])) {
Tables::clear($item);
if (is_object($anchor)) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url());
} else {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'articles/');
}
}
// deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
Logger::error(i18n::s('The action has not been confirmed.'));
} else {
// commands
$menu = array();
$menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this table'), NULL, NULL, 'confirmed');
if (is_object($anchor)) {
$menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), 'span');
}
// the submit button
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n";
// set the focus
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php
示例13: encode
/**
* encode a sequence of HTML tags, or plain text, to PDF
*
* @param string the text to append
* @return the content of PDF
* @see articles/fetch_as_pdf.php
*/
function encode($text)
{
global $context;
//
// meta information
//
// encode it to iso8859 -- sorry
// document title
if ($context['page_title']) {
$this->SetTitle(utf8::to_iso8859(Safe::html_entity_decode($context['page_title'], ENT_COMPAT, 'ISO-8859-15')));
}
// document author
if ($context['page_author']) {
$this->SetAuthor(utf8::to_iso8859(Safe::html_entity_decode($context['page_author'], ENT_COMPAT, 'ISO-8859-15')));
}
// document subject
if ($context['subject']) {
$this->SetSubject(utf8::to_iso8859(Safe::html_entity_decode($context['subject'], ENT_COMPAT, 'ISO-8859-15')));
}
// document creator (typically, the tool used to produce the document)
$this->SetCreator('yacs');
//
// PDF content
//
// start the rendering engine
$this->AliasNbPages();
$this->AddPage();
$this->SetFont('Arial', 'B', 16);
// reference view.php instead of ourself to achieve correct links
$text = str_replace('/fetch_as_pdf.php', '/view.php', $text);
// remove all unsupported tags
$text = strip_tags($text, "<a><b><blockquote><br><code><div><em><font><h1><h2><h3><h4><hr><i><img><li><p><pre><strong><table><tr><tt><u><ul>");
// spaces instead of carriage returns
$text = str_replace("\n", ' ', $text);
// transcode to ISO8859-15 characters
$text = utf8::to_iso8859(Safe::html_entity_decode($text, ENT_COMPAT, 'ISO-8859-15'));
// locate every HTML/XML tag
$areas = preg_split('/<(.*)>/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$height = 5;
$link = '';
foreach ($areas as $index => $entity) {
// a tag entity
if ($index % 2) {
@(list($tag, $attributes) = explode(' ', $entity, 2));
switch (strtolower($tag)) {
case 'a':
if (preg_match('/href="(.*)"/i', $attributes, $matches)) {
$link = $matches[1];
// suppress local references (eg, in table of content)
if (preg_match('/(#.*)/', $link)) {
$link = '';
} elseif ($link[0] == '/') {
$link = $context['url_to_home'] . $link;
}
}
break;
case 'b':
$this->SetFont('', 'B');
break;
case '/b':
$this->SetFont('', '');
break;
case 'blockquote':
$this->Ln($height);
break;
case '/blockquote':
$this->Ln($height);
break;
case 'br':
$this->Ln($height);
break;
case 'code':
$this->SetFont('Courier', '', 11);
$this->SetFontSize(11);
break;
case '/code':
$this->SetFont('Times', '', 12);
$this->SetFontSize(12);
break;
case 'div':
case '/div':
$this->Ln($height);
break;
case 'em':
$this->SetFont('', 'I');
break;
case '/em':
$this->SetFont('', '');
break;
case 'font':
if (preg_match('/color="#(.{6})"/i', $attributes, $matches)) {
$color = $matches[1];
$r = hexdec($color[0] . $color[1]);
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:pdf.php
示例14: while
$context['text'] .= Skin::build_block(sprintf(i18n::s('Analyzing table %s...'), SQL::table_name('comments')), 'title');
// scan up to 20000 items
$count = 0;
$query = "SELECT id, anchor FROM " . SQL::table_name('comments') . " ORDER BY anchor LIMIT 0, 100000";
if (!($result = SQL::query($query))) {
return;
} else {
// fetch one anchor and the linked member
$errors_count = 0;
while ($row = SQL::fetch($result)) {
// animate user screen and take care of time
$count++;
if (!($count % 500)) {
$context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
// ensure enough execution time
Safe::set_time_limit(30);
}
// check that the anchor exists, if any
if ($row['anchor'] && !Anchors::get($row['anchor'])) {
$context['text'] .= sprintf(i18n::s('Orphan: %s'), 'comment ' . Skin::build_link(Comments::get_url($row['id']), $row['id'])) . BR . "\n";
if (++$errors_count >= 5) {
$context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n";
break;
}
} else {
$errors_count = 0;
}
}
}
// ending message
$context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:check.php
示例15: natsort
}
if ($file == 'index.php') {
continue;
}
if ($file == 'behavior.php') {
continue;
}
if ($file == 'behaviors.php') {
continue;
}
if (!preg_match('/(.*)\\.php$/i', $file, $matches)) {
continue;
}
$behaviors[] = $matches[1];
}
Safe::closedir($dir);
if (@count($behaviors)) {
natsort($behaviors);
foreach ($behaviors as $behavior) {
$context['text'] .= '<li>' . $behavior . "</li>\n";
}
}
}
$context['text'] .= '</ul>';
// how to use behaviors
if (Surfer::is_associate()) {
$context['text'] .= '<p>' . sprintf(i18n::s('For example, if you want to apply the behavior <code>foo</code>, go to the %s , and select a target section, or add a new one.'), Skin::build_link('sections/', i18n::s('site map'), 'shortcut')) . '</p>' . '<p>' . i18n::s('In the form used to edit the section, type the keyword <code>foo</code> in the behavior field, then save changes.') . '</p>';
}
// referrals, if any
$context['components']['referrals'] =& Skin::build_referrals('behaviors/index.php');
// render the skin
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php
示例16: addcslashes
}
if (isset($_REQUEST['switch_contact'])) {
$content .= '$context[\'switch_contact\']=\'' . addcslashes($_REQUEST['switch_contact'], "\\'") . "';\n";
}
$content .= '?>' . "\n";
// save switch parameters, if any
if (!Safe::file_put_contents('parameters/switch.include.php', $content)) {
// not enough rights to write the file
Logger::error(sprintf(i18n::s('Impossible to write to %s.'), 'parameters/switch.include.php.'));
// allow for a manual update
$context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/switch.include.php') . "</p>\n";
// display updated parameters
$context['text'] .= Skin::build_box(i18n::s('Configuration'), Safe::highlight_string($content), 'folded');
}
// rename the switch file
if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) {
Logger::error(i18n::s('The server has been switched OFF. Switch it back on as soon as possible.'));
// remember the change
$label = i18n::c('The server has been switched off.');
Logger::remember('control/switch.php: ' . $label);
// if the server is currently switched off
} elseif (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
Logger::error(i18n::s('The server is currently switched off. All users are redirected to the closed page.'));
} else {
Logger::error(i18n::s('Impossible to rename the file parameters/switch.on to parameters/switch.off. Do it yourself manually if you like.'));
}
// follow-up commands
$menu = array();
// do it again
if (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
$menu = array_merge($menu, array('control/switch.php?action=on' => i18n::s('Switch on')));
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:switch.php
示例17: elseif
// not found
if (!$item['id']) {
include '../error.php';
// permission denied
} elseif (!$permitted) {
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Servers::get_url($item['id'])));
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Servers::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
Safe::header('Status: 301 Moved Permanently', TRUE, 301);
Safe::header('Location: ' . $canonical);
Logger::error(Skin::build_link($canonical));
// display the server profile
} else {
$text = '';
// initialize the rendering engine
Codes::initialize(Servers::get_url($item['id']));
// the nick name
if ($item['host_name'] && Surfer::is_associate()) {
$details[] = '"' . $item['host_name'] . '"';
}
// information on last update
if ($item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// restricted to logged members
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php
示例18: elseif
} elseif (isset($context['arguments'][0])) {
$search = $context['arguments'][0];
}
$search = strip_tags($search);
// search type
$type = '';
if (isset($_REQUEST['type'])) {
$type = $_REQUEST['type'];
}
$type = strip_tags($type);
// load localized strings
i18n::bind('services');
// load a skin engine
load_skin('services');
// loads feeding parameters
Safe::load('parameters/feeds.include.php');
// set default values
if (!$context['channel_title']) {
$context['channel_title'] = $context['site_name'];
}
if (!$context['channel_description']) {
$context['channel_description'] = $context['site_description'];
}
// channel attributes
$values = array();
$values['channel'] = array();
// set channel information
if ($search) {
$values['channel']['title'] = sprintf(i18n::s('%s at %s'), $search, $context['channel_title']);
} else {
$values['channel']['title'] = $context['channel_title'];
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:search.php
示例19: render_embed
//.........这里部分代码省略.........
// if there is a static image for this video, use it
if (isset($item['icon_url']) && $item['icon_url']) {
$flashvars .= '&startimage=' . urlencode($item['icon_url']);
}
// if there is a subtitle file for this video, use it
if (isset($item['file_name']) && ($srt = 'files/' . str_replace(':', '/', $item['anchor']) . '/' . str_replace('.' . $extension, '.srt', $item['file_name'])) && file_exists($context['path_to_root'] . $srt)) {
$flashvars .= '&srt=1&srturl=' . urlencode($context['url_to_home'] . $context['url_to_root'] . $srt);
}
// if there is a logo file in the skin, use it
Skin::define_img_href('FLV_IMG_HREF', 'codes/flvplayer_logo.png', '');
if (FLV_IMG_HREF) {
$flashvars .= '&top1=' . urlencode(FLV_IMG_HREF . '|10|10');
}
// rely on Flash
if (Surfer::has_flash()) {
// the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
$output = '<div id="flv_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showfullscreen:1, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "file_' . $item['id'] . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "flv_' . $item['id'] . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
// native support
} else {
// <video> is HTML5, <object> is legacy
$output = '<video width="' . $width . '" height="' . $height . '" autoplay="" controls="" src="' . $url . '" >' . "\n" . ' <object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . ' <param value="' . $url . '" name="movie" />' . "\n" . ' <param value="true" name="allowFullScreen" />' . "\n" . ' <param value="always" name="allowscriptaccess" />' . "\n" . ' <a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . ' </object>' . "\n" . '</video>' . "\n";
}
// job done
return $output;
// a ganttproject timeline
// a ganttproject timeline
case 'gan':
// where the file is
$path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
// we actually use a transformed version of the file
$cache_id = Cache::hash($path) . '.xml';
// apply the transformation
if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) < filemtime($context['path_to_root'] . $path) || !($text = Safe::file_get_contents($context['path_to_root'] . $cache_id))) {
// transform from GanttProject to SIMILE Timeline
$text = Files::transform_gan_to_simile($path);
// put in cache
Safe::file_put_contents($cache_id, $text);
}
// load the SIMILE Timeline javascript library in shared/global.php
$context['javascript']['timeline'] = TRUE;
// cache would kill the loading of the library
cache::poison();
// 1 week ago
$now = gmdate('M d Y H:i:s', time() - 7 * 24 * 60 * 60);
// load the right file
$output = '<div id="gantt" style="height: ' . $height . '; width: ' . $width . '; border: 1px solid #aaa; font-family: Trebuchet MS, Helvetica, Arial, sans serif; font-size: 8pt"></div>' . "\n";
Page::insert_script('var simile_handle;' . "\n" . 'function onLoad() {' . "\n" . ' var eventSource = new Timeline.DefaultEventSource();' . "\n" . ' var theme = Timeline.ClassicTheme.create();' . "\n" . ' theme.event.bubble.width = 350;' . "\n" . ' theme.event.bubble.height = 300;' . "\n" . ' var bandInfos = [' . "\n" . ' Timeline.createBandInfo({' . "\n" . ' eventSource: eventSource,' . "\n" . ' date: "' . $now . '",' . "\n" . ' width: "80%",' . "\n" . ' intervalUnit: Timeline.DateTime.WEEK,' . "\n" . ' intervalPixels: 200,' . "\n" . ' theme: theme,' . "\n" . ' layout: "original" // original, overview, detailed' . "\n" . ' }),' . "\n" . ' Timeline.createBandInfo({' . "\n" . ' showEventText: false,' . "\n" . ' trackHeight: 0.5,' . "\n" . ' trackGap: 0.2,' . "\n" . ' eventSource: eventSource,' . "\n" . ' date: "' . $now . '",' . "\n" . ' width: "20%",' . "\n" . ' intervalUnit: Timeline.DateTime.MONTH,' . "\n" . ' intervalPixels: 50' . "\n" . ' })' . "\n" . ' ];' . "\n" . ' bandInfos[1].syncWith = 0;' . "\n" . ' bandInfos[1].highlight = true;' . "\n" . ' bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());' . "\n" . ' simile_handle = Timeline.create(document.getElementById("gantt"), bandInfos, Timeline.HORIZONTAL);' . "\n" . ' simile_handle.showLoadingMessage();' . "\n" . ' Timeline.loadXML("' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", function(xml, url) { eventSource.loadXML(xml, url); });' . "\n" . ' simile_handle.hideLoadingMessage();' . "\n" . '}' . "\n" . "\n" . 'var resizeTimerID = null;' . "\n" . 'function onResize() {' . "\n" . ' if (resizeTimerID == null) {' . "\n" . ' resizeTimerID = window.setTimeout(function() {' . "\n" . ' resizeTimerID = null;' . "\n" . ' simile_handle.layout();' . "\n" . ' }, 500);' . "\n" . ' }' . "\n" . '}' . "\n" . "\n" . '// observe page major events' . "\n" . '$(document).ready( onLoad);' . "\n" . '$(window).resize(onResize);' . "\n");
// job done
return $output;
// a Freemind map
// a Freemind map
case 'mm':
// if we have an external reference, use it
i
|
请发表评论