本文整理汇总了PHP中Fisharebest\Webtrees\Filter::server方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::server方法的具体用法?PHP Filter::server怎么用?PHP Filter::server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Filter
的用法示例。
在下文中一共展示了Filter::server方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* Upgrade to to the next version
*/
public function upgrade()
{
$WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\\./i', '', Filter::server('SERVER_NAME'));
// Default settings for new trees. No defaults for:
// imported, title, CONTACT_USER_ID, WEBMASTER_USER_ID
// The following settings have defaults, but may need overwriting:
// LANGUAGE, SURNAME_TRADITION
Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES" . "(-1, 'ADVANCED_NAME_FACTS', 'NICK,_AKA')," . "(-1, 'ADVANCED_PLAC_FACTS', '')," . "(-1, 'ALLOW_THEME_DROPDOWN', '1')," . "(-1, 'CALENDAR_FORMAT', 'gregorian')," . "(-1, 'CHART_BOX_TAGS', '')," . "(-1, 'COMMON_NAMES_ADD', '')," . "(-1, 'COMMON_NAMES_REMOVE', '')," . "(-1, 'COMMON_NAMES_THRESHOLD', '40')," . "(-1, 'DEFAULT_PEDIGREE_GENERATIONS', '4')," . "(-1, 'EXPAND_RELATIVES_EVENTS', '0')," . "(-1, 'EXPAND_SOURCES', '0')," . "(-1, 'FAM_FACTS_ADD', 'CENS,MARR,RESI,SLGS,MARR_CIVIL,MARR_RELIGIOUS,MARR_PARTNERS,RESN')," . "(-1, 'FAM_FACTS_QUICK', 'MARR,DIV,_NMR')," . "(-1, 'FAM_FACTS_UNIQUE', 'NCHI,MARL,DIV,ANUL,DIVF,ENGA,MARB,MARC,MARS')," . "(-1, 'FAM_ID_PREFIX', 'F')," . "(-1, 'FORMAT_TEXT', 'markdown')," . "(-1, 'FULL_SOURCES', '0')," . "(-1, 'GEDCOM_ID_PREFIX', 'I')," . "(-1, 'GEDCOM_MEDIA_PATH', '')," . "(-1, 'GENERATE_UIDS', '0')," . "(-1, 'HIDE_GEDCOM_ERRORS', '1')," . "(-1, 'HIDE_LIVE_PEOPLE', '1')," . "(-1, 'INDI_FACTS_ADD', 'AFN,BIRT,DEAT,BURI,CREM,ADOP,BAPM,BARM,BASM,BLES,CHRA,CONF,FCOM,ORDN,NATU,EMIG,IMMI,CENS,PROB,WILL,GRAD,RETI,DSCR,EDUC,IDNO,NATI,NCHI,NMR,OCCU,PROP,RELI,RESI,SSN,TITL,BAPL,CONL,ENDL,SLGC,_MILI,ASSO,RESN')," . "(-1, 'INDI_FACTS_QUICK', 'BIRT,BURI,BAPM,CENS,DEAT,OCCU,RESI')," . "(-1, 'INDI_FACTS_UNIQUE', '')," . "(-1, 'KEEP_ALIVE_YEARS_BIRTH', '')," . "(-1, 'KEEP_ALIVE_YEARS_DEATH', '')," . "(-1, 'LANGUAGE', 'en-US')," . "(-1, 'MAX_ALIVE_AGE', '120')," . "(-1, 'MAX_DESCENDANCY_GENERATIONS', '15')," . "(-1, 'MAX_PEDIGREE_GENERATIONS', '10')," . "(-1, 'MEDIA_DIRECTORY', 'media/')," . "(-1, 'MEDIA_ID_PREFIX', 'M')," . "(-1, 'MEDIA_UPLOAD', :MEDIA_UPLOAD)," . "(-1, 'META_DESCRIPTION', '')," . "(-1, 'META_TITLE', :META_TITLE)," . "(-1, 'NOTE_FACTS_ADD', 'SOUR,RESN')," . "(-1, 'NOTE_FACTS_QUICK', '')," . "(-1, 'NOTE_FACTS_UNIQUE', '')," . "(-1, 'NOTE_ID_PREFIX', 'N')," . "(-1, 'NO_UPDATE_CHAN', '0')," . "(-1, 'PEDIGREE_FULL_DETAILS', '1')," . "(-1, 'PEDIGREE_LAYOUT', '1')," . "(-1, 'PEDIGREE_ROOT_ID', '')," . "(-1, 'PEDIGREE_SHOW_GENDER', '0')," . "(-1, 'PREFER_LEVEL2_SOURCES', '1')," . "(-1, 'QUICK_REQUIRED_FACTS', 'BIRT,DEAT')," . "(-1, 'QUICK_REQUIRED_FAMFACTS', 'MARR')," . "(-1, 'REPO_FACTS_ADD', 'PHON,EMAIL,FAX,WWW,RESN')," . "(-1, 'REPO_FACTS_QUICK', '')," . "(-1, 'REPO_FACTS_UNIQUE', 'NAME,ADDR')," . "(-1, 'REPO_ID_PREFIX', 'R')," . "(-1, 'REQUIRE_AUTHENTICATION', '0')," . "(-1, 'SAVE_WATERMARK_IMAGE', '0')," . "(-1, 'SAVE_WATERMARK_THUMB', '0')," . "(-1, 'SHOW_AGE_DIFF', '0')," . "(-1, 'SHOW_COUNTER', '1')," . "(-1, 'SHOW_DEAD_PEOPLE', :SHOW_DEAD_PEOPLE)," . "(-1, 'SHOW_EST_LIST_DATES', '0')," . "(-1, 'SHOW_FACT_ICONS', '1')," . "(-1, 'SHOW_GEDCOM_RECORD', '0')," . "(-1, 'SHOW_HIGHLIGHT_IMAGES', '1')," . "(-1, 'SHOW_LDS_AT_GLANCE', '0')," . "(-1, 'SHOW_LEVEL2_NOTES', '1')," . "(-1, 'SHOW_LIVING_NAMES', :SHOW_LIVING_NAMES)," . "(-1, 'SHOW_MEDIA_DOWNLOAD', '0')," . "(-1, 'SHOW_NO_WATERMARK', :SHOW_NO_WATERMARK)," . "(-1, 'SHOW_PARENTS_AGE', '1')," . "(-1, 'SHOW_PEDIGREE_PLACES', '9')," . "(-1, 'SHOW_PEDIGREE_PLACES_SUFFIX', '0')," . "(-1, 'SHOW_PRIVATE_RELATIONSHIPS', '1')," . "(-1, 'SHOW_RELATIVES_EVENTS', '_BIRT_CHIL,_BIRT_SIBL,_MARR_CHIL,_MARR_PARE,_DEAT_CHIL,_DEAT_PARE,_DEAT_GPAR,_DEAT_SIBL,_DEAT_SPOU')," . "(-1, 'SOURCE_ID_PREFIX', 'S')," . "(-1, 'SOUR_FACTS_ADD', 'NOTE,REPO,SHARED_NOTE,RESN')," . "(-1, 'SOUR_FACTS_QUICK', 'TEXT,NOTE,REPO')," . "(-1, 'SOUR_FACTS_UNIQUE', 'AUTH,ABBR,TITL,PUBL,TEXT')," . "(-1, 'SUBLIST_TRIGGER_I', '200')," . "(-1, 'SURNAME_LIST_STYLE', 'style2')," . "(-1, 'SURNAME_TRADITION', 'paternal')," . "(-1, 'THUMBNAIL_WIDTH', '100')," . "(-1, 'USE_RIN', '0')," . "(-1, 'USE_SILHOUETTE', '1')," . "(-1, 'WATERMARK_THUMB', '0')," . "(-1, 'WEBTREES_EMAIL', :WEBTREES_EMAIL)," . "(-1, 'WORD_WRAPPED_NOTES', '0')")->execute(array('MEDIA_UPLOAD' => Auth::PRIV_USER, 'META_TITLE' => WT_WEBTREES, 'SHOW_DEAD_PEOPLE' => Auth::PRIV_PRIVATE, 'SHOW_LIVING_NAMES' => Auth::PRIV_USER, 'SHOW_NO_WATERMARK' => Auth::PRIV_USER, 'WEBTREES_EMAIL' => $WEBTREES_EMAIL));
// Previous versions of webtrees allowed this setting to be empty.
Database::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name ='WEBTREES_EMAIL' AND setting_value = ''")->execute();
Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " SELECT gedcom_id, 'WEBTREES_EMAIL', :WEBTREES_EMAIL" . " FROM `##gedcom` WHERE gedcom_id > 0")->execute(array('WEBTREES_EMAIL' => $WEBTREES_EMAIL));
// Default restrictions
Database::prepare("INSERT IGNORE INTO `##default_resn` (gedcom_id, tag_type, resn) VALUES " . "(-1, 'SSN', 'confidential')," . "(-1, 'SOUR', 'privacy')," . "(-1, 'REPO', 'privacy')," . "(-1, 'SUBM', 'confidential')," . "(-1, 'SUBN', 'confidential')")->execute();
}
示例2: decryptFromSafeBase64
/**
* Decode and encrypt a text from base64 compatible with URL use
*
* @param string $encrypted Text to decrypt
* @return string Decrypted text
*/
public static function decryptFromSafeBase64($encrypted)
{
if (!self::isEncryptionCompatible()) {
throw new \Exception('MCrypt PHP extension is required to use encryption.');
}
$key = 'STANDARDKEYIFNOSERVER';
if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) {
$key = md5(Filter::server('SERVER_NAME') . Filter::server('SERVER_SOFTWARE'));
}
$encrypted = str_replace('-', '+', $encrypted);
$encrypted = str_replace('_', '/', $encrypted);
$encrypted = str_replace('*', '=', $encrypted);
$encrypted = base64_decode($encrypted);
if (!$encrypted) {
throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
}
if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) {
throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
}
$iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE);
$encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec);
return preg_replace('~(?:\\000+)$~', '', $decrypted);
}
示例3: render
/**
* Render the image to the output.
*/
public function render()
{
if (!$this->media || !$this->media->canShow()) {
Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
$this->renderError();
}
$serverFilename = $this->media->getServerFilename();
if (!file_exists($serverFilename)) {
Log::addMediaLog('Image Builder error: >' . I18N::translate('The media object does not exist.') . '< for path >' . $serverFilename . '<');
$this->renderError();
}
$mimetype = $this->media->mimeType();
$imgsize = $this->media->getImageAttributes();
$filetime = $this->media->getFiletime();
$filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';
$expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT';
$type = Functions::isImageTypeSupported($imgsize['ext']);
$usewatermark = false;
// if this image supports watermarks and the watermark module is intalled...
if ($type) {
$usewatermark = $this->isShowWatermark();
}
// determine whether we have enough memory to watermark this image
if ($usewatermark) {
if (!FunctionsMedia::hasMemoryForImage($serverFilename)) {
// not enough memory to watermark this file
$usewatermark = false;
}
}
$etag = $this->media->getEtag();
// parse IF_MODIFIED_SINCE header from client
$if_modified_since = 'x';
if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) {
$if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE'));
}
// parse IF_NONE_MATCH header from client
$if_none_match = 'x';
if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) {
$if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH'));
}
// add caching headers. allow browser to cache file, but not proxy
header('Last-Modified: ' . $filetimeHeader);
header('ETag: "' . $etag . '"');
header('Expires: ' . $expireHeader);
header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate');
// if this file is already in the user’s cache, don’t resend it
// first check if the if_modified_since param matches
if ($if_modified_since === $filetimeHeader) {
// then check if the etag matches
if ($if_none_match === $etag) {
http_response_code(304);
return;
}
}
// send headers for the image
header('Content-Type: ' . $mimetype);
header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"');
if ($usewatermark) {
// generate the watermarked image
$imCreateFunc = 'imagecreatefrom' . $type;
$imSendFunc = 'image' . $type;
if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
$im = $imCreateFunc($serverFilename);
$im = $this->applyWatermark($im);
// send the image
$imSendFunc($im);
imagedestroy($im);
return;
} else {
// this image is defective. log it
Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage());
}
}
// determine filesize of image (could be original or watermarked version)
$filesize = filesize($serverFilename);
// set content-length header, send file
header('Content-Length: ' . $filesize);
// Some servers disable fpassthru() and readfile()
if (function_exists('readfile')) {
readfile($serverFilename);
} else {
$fp = fopen($serverFilename, 'rb');
if (function_exists('fpassthru')) {
fpassthru($fp);
} else {
while (!feof($fp)) {
echo fread($fp, 65536);
}
}
fclose($fp);
}
}
示例4: adminPlaces
//.........这里部分代码省略.........
echo Filter::escapeHtml($escparent), '<br>';
}
}
}
}
}
$parent = 0;
}
if ($action === 'ImportFile') {
echo '<h2>' . I18N::translate('Upload geographic data') . '</h2>';
$placefiles = $this->findFiles(WT_MODULES_DIR . 'googlemap/extra');
sort($placefiles);
?>
<form class="form-horizontal" method="post" enctype="multipart/form-data" id="importfile" name="importfile" action="module.php?mod=googlemap&mod_action=admin_places&action=ImportFile2">
<!-- PLACES FILE -->
<div class="form-group">
<label class="control-label col-sm-4" for="placesfile">
<?php
echo I18N::translate('A file on your computer');
?>
</label>
<div class="col-sm-8">
<div class="btn btn-default">
<input id="placesfile" type="file" name="placesfile">
</div>
</div>
</div>
<!-- LOCAL FILE -->
<div class="form-group">
<label class="control-label col-sm-4" for="localfile">
<?php
echo I18N::translate('A file on the server');
?>
</label>
<div class="col-sm-8">
<div class="input-group">
<span class="input-group-addon">
<?php
echo WT_MODULES_DIR . 'googlemap/extra/';
?>
</span>
<?php
foreach ($placefiles as $p => $placefile) {
unset($placefiles[$p]);
$p = Filter::escapeHtml($placefile);
if (substr($placefile, 0, 1) == "/") {
$placefiles[$p] = substr($placefile, 1);
} else {
$placefiles[$p] = $placefile;
}
}
echo FunctionsEdit::selectEditControl('localfile', $placefiles, '', '', 'class="form-control"');
?>
</div>
</div>
</div>
<!-- CLEAR DATABASE -->
<fieldset class="form-group">
<legend class="control-label col-sm-4">
<?php
echo I18N::translate('Delete all existing geographic data before importing the file.');
?>
</legend>
示例5: VALUES
switch ($rule) {
case 'allow':
$SEARCH_SPIDER = false;
break;
case 'deny':
http_response_code(403);
exit;
case 'robot':
case 'unknown':
// Search engines don’t send cookies, and so create a new session with every visit.
// Make sure they always use the same one
Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
$SEARCH_SPIDER = true;
break;
case '':
Database::prepare("INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')")->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
$SEARCH_SPIDER = true;
break;
}
// Store our session data in the database.
session_set_save_handler(function () {
return true;
}, function () {
return true;
}, function ($id) {
return Database::prepare("SELECT session_data FROM `##session` WHERE session_id=?")->execute(array($id))->fetchOne();
}, function ($id, $data) {
// Only update the session table once per minute, unless the session data has actually changed.
Database::prepare("INSERT INTO `##session` (session_id, user_id, ip_address, session_data, session_time)" . " VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP))" . " ON DUPLICATE KEY UPDATE" . " user_id = VALUES(user_id)," . " ip_address = VALUES(ip_address)," . " session_data = VALUES(session_data)," . " session_time = CURRENT_TIMESTAMP - SECOND(CURRENT_TIMESTAMP)")->execute(array($id, (int) Auth::id(), WT_CLIENT_IP, $data));
return true;
}, function ($id) {
示例6: http_response_code
//.........这里部分代码省略.........
break;
case 205:
$text = 'Reset Content';
break;
case 206:
$text = 'Partial Content';
break;
case 300:
$text = 'Multiple Choices';
break;
case 301:
$text = 'Moved Permanently';
break;
case 302:
$text = 'Moved Temporarily';
break;
case 303:
$text = 'See Other';
break;
case 304:
$text = 'Not Modified';
break;
case 305:
$text = 'Use Proxy';
break;
case 400:
$text = 'Bad Request';
break;
case 401:
$text = 'Unauthorized';
break;
case 402:
$text = 'Payment Required';
break;
case 403:
$text = 'Forbidden';
break;
case 404:
$text = 'Not Found';
break;
case 405:
$text = 'Method Not Allowed';
break;
case 406:
$text = 'Not Acceptable';
break;
case 407:
$text = 'Proxy Authentication Required';
break;
case 408:
$text = 'Request Time-out';
break;
case 409:
$text = 'Conflict';
break;
case 410:
$text = 'Gone';
break;
case 411:
$text = 'Length Required';
break;
case 412:
$text = 'Precondition Failed';
break;
case 413:
$text = 'Request Entity Too Large';
break;
case 414:
$text = 'Request-URI Too Large';
break;
case 415:
$text = 'Unsupported Media Type';
break;
case 500:
$text = 'Internal Server Error';
break;
case 501:
$text = 'Not Implemented';
break;
case 502:
$text = 'Bad Gateway';
break;
case 503:
$text = 'Service Unavailable';
break;
case 504:
$text = 'Gateway Time-out';
break;
case 505:
$text = 'HTTP Version not supported';
break;
default:
throw new \DomainException();
}
$http_response_code = $code;
$protocol = Filter::server('SERVER_PROTOCOL', null, 'HTTP/1.0');
header($protocol . ' ' . $code . ' ' . $text);
}
return $http_response_code;
}
示例7: array
use PDO;
define('WT_SCRIPT_NAME', 'admin_site_access.php');
require './includes/session.php';
$rules_display = array('unknown' => I18N::translate('unknown'), 'allow' => I18N::translate('allow'), 'deny' => I18N::translate('deny'), 'robot' => I18N::translate('robot'));
$rules_edit = array('unknown' => I18N::translate('unknown'), 'allow' => I18N::translate('allow'), 'deny' => I18N::translate('deny'), 'robot' => I18N::translate('robot'));
// Form actions
switch (Filter::post('action')) {
case 'save':
if (Filter::checkCsrf()) {
$site_access_rule_id = Filter::postInteger('site_access_rule_id');
$ip_address_start = Filter::post('ip_address_start', WT_REGEX_IPV4);
$ip_address_end = Filter::post('ip_address_end', WT_REGEX_IPV4);
$user_agent_pattern = Filter::post('user_agent_pattern');
$rule = Filter::post('rule', 'allow|deny|robot');
$comment = Filter::post('comment');
$user_agent_string = Filter::server('HTTP_USER_AGENT');
$ip_address = WT_CLIENT_IP;
if ($ip_address_start !== null && $ip_address_end !== null && $user_agent_pattern !== null && $rule !== null) {
// This doesn't work with named placeholders. The :user_agent_string parameter is not recognised...
$oops = $rule !== 'allow' && Database::prepare("SELECT INET_ATON(:ip_address) BETWEEN INET_ATON(:ip_address_start) AND INET_ATON(:ip_address_end)" . " AND :user_agent_string LIKE :user_agent_pattern")->execute(array('ip_address' => $ip_address, 'ip_address_start' => $ip_address_start, 'ip_address_end' => $ip_address_end, 'user_agent_string' => $user_agent_string, 'user_agent_pattern' => $user_agent_pattern))->fetchOne();
if ($oops) {
FlashMessages::addMessage(I18N::translate('You cannot create a rule which would prevent yourself from accessing the website.'), 'danger');
} elseif ($site_access_rule_id === null) {
Database::prepare("INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, rule, comment) VALUES (INET_ATON(:ip_address_start), INET_ATON(:ip_address_end), :user_agent_pattern, :rule, :comment)")->execute(array('ip_address_start' => $ip_address_start, 'ip_address_end' => $ip_address_end, 'user_agent_pattern' => $user_agent_pattern, 'rule' => $rule, 'comment' => $comment));
FlashMessages::addMessage(I18N::translate('The website access rule has been created.'), 'success');
} else {
Database::prepare("UPDATE `##site_access_rule` SET ip_address_start = INET_ATON(:ip_address_start), ip_address_end = INET_ATON(:ip_address_end), user_agent_pattern = :user_agent_pattern, rule = :rule, comment = :comment WHERE site_access_rule_id = :site_access_rule_id")->execute(array('ip_address_start' => $ip_address_start, 'ip_address_end' => $ip_address_end, 'user_agent_pattern' => $user_agent_pattern, 'rule' => $rule, 'comment' => $comment, 'site_access_rule_id' => $site_access_rule_id));
FlashMessages::addMessage(I18N::translate('The website access rule has been updated.'), 'success');
}
}
}