12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836 |
- <?php
- define('VERSION', '7.53');
- define('DRUPAL_CORE_COMPATIBILITY', '7.x');
- define('DRUPAL_MINIMUM_PHP', '5.2.4');
- define('DRUPAL_MINIMUM_PHP_MEMORY_LIMIT', '32M');
- define('ERROR_REPORTING_HIDE', 0);
- define('ERROR_REPORTING_DISPLAY_SOME', 1);
- define('ERROR_REPORTING_DISPLAY_ALL', 2);
- define('CACHE_PERMANENT', 0);
- define('CACHE_TEMPORARY', -1);
- define('WATCHDOG_EMERGENCY', 0);
- define('WATCHDOG_ALERT', 1);
- define('WATCHDOG_CRITICAL', 2);
- define('WATCHDOG_ERROR', 3);
- define('WATCHDOG_WARNING', 4);
- define('WATCHDOG_NOTICE', 5);
- define('WATCHDOG_INFO', 6);
- define('WATCHDOG_DEBUG', 7);
- define('DRUPAL_BOOTSTRAP_CONFIGURATION', 0);
- define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 1);
- define('DRUPAL_BOOTSTRAP_DATABASE', 2);
- define('DRUPAL_BOOTSTRAP_VARIABLES', 3);
- define('DRUPAL_BOOTSTRAP_SESSION', 4);
- define('DRUPAL_BOOTSTRAP_PAGE_HEADER', 5);
- define('DRUPAL_BOOTSTRAP_LANGUAGE', 6);
- define('DRUPAL_BOOTSTRAP_FULL', 7);
- define('DRUPAL_ANONYMOUS_RID', 1);
- define('DRUPAL_AUTHENTICATED_RID', 2);
- define('DRUPAL_KILOBYTE', 1024);
- define('LANGUAGE_NONE', 'und');
- define('LANGUAGE_TYPE_CONTENT', 'language_content');
- define('LANGUAGE_TYPE_INTERFACE', 'language');
- define('LANGUAGE_TYPE_URL', 'language_url');
- define('LANGUAGE_LTR', 0);
- define('LANGUAGE_RTL', 1);
- define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
- define('CHECK_PLAIN', 0);
- define('PASS_THROUGH', -1);
- define('REGISTRY_RESET_LOOKUP_CACHE', 1);
- define('REGISTRY_WRITE_LOOKUP_CACHE', 2);
- define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
- define('DATE_RFC7231', 'D, d M Y H:i:s \G\M\T');
- abstract class DrupalCacheArray implements ArrayAccess {
-
- protected $cid;
-
- protected $bin;
-
- protected $keysToPersist = array();
-
- protected $storage = array();
-
- public function __construct($cid, $bin) {
- $this->cid = $cid;
- $this->bin = $bin;
- if ($cached = cache_get($this->cid, $this->bin)) {
- $this->storage = $cached->data;
- }
- }
-
- public function offsetExists($offset) {
- return $this->offsetGet($offset) !== NULL;
- }
-
- public function offsetGet($offset) {
- if (isset($this->storage[$offset]) || array_key_exists($offset, $this->storage)) {
- return $this->storage[$offset];
- }
- else {
- return $this->resolveCacheMiss($offset);
- }
- }
-
- public function offsetSet($offset, $value) {
- $this->storage[$offset] = $value;
- }
-
- public function offsetUnset($offset) {
- unset($this->storage[$offset]);
- }
-
- protected function persist($offset, $persist = TRUE) {
- $this->keysToPersist[$offset] = $persist;
- }
-
- abstract protected function resolveCacheMiss($offset);
-
- protected function set($data, $lock = TRUE) {
-
-
- $lock_name = $this->cid . ':' . $this->bin;
- if (!$lock || lock_acquire($lock_name)) {
- if ($cached = cache_get($this->cid, $this->bin)) {
- $data = $cached->data + $data;
- }
- cache_set($this->cid, $data, $this->bin);
- if ($lock) {
- lock_release($lock_name);
- }
- }
- }
-
- public function __destruct() {
- $data = array();
- foreach ($this->keysToPersist as $offset => $persist) {
- if ($persist) {
- $data[$offset] = $this->storage[$offset];
- }
- }
- if (!empty($data)) {
- $this->set($data);
- }
- }
- }
- function timer_start($name) {
- global $timers;
- $timers[$name]['start'] = microtime(TRUE);
- $timers[$name]['count'] = isset($timers[$name]['count']) ? ++$timers[$name]['count'] : 1;
- }
- function timer_read($name) {
- global $timers;
- if (isset($timers[$name]['start'])) {
- $stop = microtime(TRUE);
- $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
- if (isset($timers[$name]['time'])) {
- $diff += $timers[$name]['time'];
- }
- return $diff;
- }
- return $timers[$name]['time'];
- }
- function timer_stop($name) {
- global $timers;
- if (isset($timers[$name]['start'])) {
- $stop = microtime(TRUE);
- $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
- if (isset($timers[$name]['time'])) {
- $timers[$name]['time'] += $diff;
- }
- else {
- $timers[$name]['time'] = $diff;
- }
- unset($timers[$name]['start']);
- }
- return $timers[$name];
- }
- function conf_path($require_settings = TRUE, $reset = FALSE) {
- $conf = &drupal_static(__FUNCTION__, '');
- if ($conf && !$reset) {
- return $conf;
- }
- $confdir = 'sites';
- $sites = array();
- if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
-
- include(DRUPAL_ROOT . '/' . $confdir . '/sites.php');
- }
- $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
- $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
- for ($i = count($uri) - 1; $i > 0; $i--) {
- for ($j = count($server); $j > 0; $j--) {
- $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
- if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
- $dir = $sites[$dir];
- }
- if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir))) {
- $conf = "$confdir/$dir";
- return $conf;
- }
- }
- }
- $conf = "$confdir/default";
- return $conf;
- }
- function drupal_override_server_variables($variables = array()) {
-
- if (isset($variables['url'])) {
- $url = parse_url($variables['url']);
- if (isset($url['host'])) {
- $_SERVER['HTTP_HOST'] = $url['host'];
- }
- if (isset($url['path'])) {
- $_SERVER['SCRIPT_NAME'] = $url['path'];
- }
- unset($variables['url']);
- }
-
-
-
- $defaults = array(
- 'HTTP_HOST' => 'localhost',
- 'SCRIPT_NAME' => NULL,
- 'REMOTE_ADDR' => '127.0.0.1',
- 'REQUEST_METHOD' => 'GET',
- 'SERVER_NAME' => NULL,
- 'SERVER_SOFTWARE' => NULL,
- 'HTTP_USER_AGENT' => NULL,
- );
-
- $_SERVER = $variables + $_SERVER + $defaults;
- }
- function drupal_environment_initialize() {
- if (!isset($_SERVER['HTTP_REFERER'])) {
- $_SERVER['HTTP_REFERER'] = '';
- }
- if (!isset($_SERVER['SERVER_PROTOCOL']) || ($_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.0' && $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.1')) {
- $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
- }
- if (isset($_SERVER['HTTP_HOST'])) {
-
-
-
- $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
- if (!drupal_valid_http_host($_SERVER['HTTP_HOST'])) {
-
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
- exit;
- }
- }
- else {
-
-
- $_SERVER['HTTP_HOST'] = '';
- }
-
-
-
-
-
- $_GET['q'] = request_path();
-
- error_reporting(E_ALL | error_reporting());
-
-
-
-
- ini_set('magic_quotes_runtime', '0');
-
-
- ini_set('session.use_cookies', '1');
- ini_set('session.use_only_cookies', '1');
- ini_set('session.use_trans_sid', '0');
-
-
- ini_set('session.cache_limiter', '');
-
- ini_set('session.cookie_httponly', '1');
-
-
- setlocale(LC_ALL, 'C');
- }
- function drupal_valid_http_host($host) {
-
-
- return strlen($host) <= 1000
-
-
- && substr_count($host, '.') <= 100
- && substr_count($host, ':') <= 100
- && preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host);
- }
- function drupal_settings_initialize() {
- global $base_url, $base_path, $base_root;
-
- global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
- $conf = array();
- if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
- include_once DRUPAL_ROOT . '/' . conf_path() . '/settings.php';
- }
- $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
- if (isset($base_url)) {
-
- $parts = parse_url($base_url);
- if (!isset($parts['path'])) {
- $parts['path'] = '';
- }
- $base_path = $parts['path'] . '/';
-
- $base_root = substr($base_url, 0, strlen($base_url) - strlen($parts['path']));
- }
- else {
-
- $http_protocol = $is_https ? 'https' : 'http';
- $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
- $base_url = $base_root;
-
-
- if ($dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/')) {
- $base_path = $dir;
- $base_url .= $base_path;
- $base_path .= '/';
- }
- else {
- $base_path = '/';
- }
- }
- $base_secure_url = str_replace('http://', 'https://', $base_url);
- $base_insecure_url = str_replace('https://', 'http://', $base_url);
- if ($cookie_domain) {
-
- $session_name = $cookie_domain;
- }
- else {
-
-
- list( , $session_name) = explode('://', $base_url, 2);
-
-
- if (!empty($_SERVER['HTTP_HOST'])) {
- $cookie_domain = $_SERVER['HTTP_HOST'];
-
- $cookie_domain = ltrim($cookie_domain, '.');
- if (strpos($cookie_domain, 'www.') === 0) {
- $cookie_domain = substr($cookie_domain, 4);
- }
- $cookie_domain = explode(':', $cookie_domain);
- $cookie_domain = '.' . $cookie_domain[0];
- }
- }
-
-
- if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
- ini_set('session.cookie_domain', $cookie_domain);
- }
-
-
-
-
-
-
- if ($is_https) {
- ini_set('session.cookie_secure', TRUE);
- }
- $prefix = ini_get('session.cookie_secure') ? 'SSESS' : 'SESS';
- session_name($prefix . substr(hash('sha256', $session_name), 0, 32));
- }
- function drupal_get_filename($type, $name, $filename = NULL, $trigger_error = TRUE) {
-
-
-
-
-
- static $files = array();
-
- if ($type == 'profile') {
- $profile_filename = "profiles/$name/$name.profile";
- $files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE;
- }
- if (!isset($files[$type])) {
- $files[$type] = array();
- }
- if (!empty($filename) && file_exists($filename)) {
-
- $files[$type][$name] = $filename;
- }
- elseif (isset($files[$type][$name])) {
-
-
-
-
- }
- else {
-
-
-
-
- $database_unavailable = TRUE;
- try {
- if (function_exists('db_query')) {
- $file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
- if ($file !== FALSE && file_exists(DRUPAL_ROOT . '/' . $file)) {
- $files[$type][$name] = $file;
- }
- $database_unavailable = FALSE;
- }
- }
- catch (Exception $e) {
-
-
-
-
-
- }
-
-
- if (!isset($files[$type][$name])) {
- $files[$type][$name] = _drupal_get_filename_fallback($type, $name, $trigger_error, $database_unavailable);
- }
- }
- if (isset($files[$type][$name])) {
- return $files[$type][$name];
- }
- }
- function _drupal_get_filename_fallback($type, $name, $trigger_error, $database_unavailable) {
- $file_scans = &_drupal_file_scan_cache();
- $filename = NULL;
-
-
- if (isset($file_scans[$type][$name]) && ($file_scans[$type][$name] === FALSE || file_exists($file_scans[$type][$name]))) {
- $filename = $file_scans[$type][$name];
- }
-
- else {
- $filename = _drupal_get_filename_perform_file_scan($type, $name);
-
-
- $file_scans[$type][$name] = $filename;
- $file_scans['#write_cache'] = TRUE;
- }
-
-
-
-
-
- if ($trigger_error) {
- $error_type = $filename === FALSE ? 'missing' : 'moved';
- if ($error_type == 'missing' || !$database_unavailable) {
- _drupal_get_filename_fallback_trigger_error($type, $name, $error_type);
- }
- }
-
-
-
-
- if ($filename === FALSE) {
- $filename = NULL;
- }
- return $filename;
- }
- function &_drupal_file_scan_cache() {
- $file_scans = &drupal_static(__FUNCTION__, array());
-
-
-
-
- if (!isset($file_scans['#cache_merge_done'])) {
- try {
- if (function_exists('cache_get')) {
- $cache = cache_get('_drupal_file_scan_cache', 'cache_bootstrap');
- if (!empty($cache->data)) {
-
-
- $file_scans = drupal_array_merge_deep($cache->data, $file_scans);
- }
-
-
- $file_scans['#cache_merge_done'] = TRUE;
- }
- }
- catch (Exception $e) {
-
- }
- }
- return $file_scans;
- }
- function _drupal_get_filename_perform_file_scan($type, $name) {
-
-
- static $dirs = array(), $files = array();
-
- $dir = $type . 's';
- if ($type == 'theme_engine') {
- $dir = 'themes/engines';
- $extension = 'engine';
- }
- elseif ($type == 'theme') {
- $extension = 'info';
- }
- else {
- $extension = $type;
- }
-
- if (!isset($dirs[$dir][$extension])) {
-
-
- $dirs[$dir][$extension] = TRUE;
- if (!function_exists('drupal_system_listing')) {
- require_once DRUPAL_ROOT . '/includes/common.inc';
- }
-
-
-
-
- $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0);
- foreach ($matches as $matched_name => $file) {
-
- $files[$type][$matched_name] = $file->uri;
- }
- }
-
-
- return isset($files[$type][$name]) ? $files[$type][$name] : FALSE;
- }
- function _drupal_get_filename_fallback_trigger_error($type, $name, $error_type) {
-
-
- if (empty($name)) {
- return;
- }
-
-
- static $errors_triggered = array();
- if (empty($errors_triggered[$type][$name][$error_type])) {
-
-
-
- if ($error_type == 'missing') {
- _drupal_trigger_error_with_delayed_logging(format_string('The following @type is missing from the file system: %name. For information about how to fix this, see <a href="@documentation">the documentation page</a>.', array('@type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING);
- }
- elseif ($error_type == 'moved') {
- _drupal_trigger_error_with_delayed_logging(format_string('The following @type has moved within the file system: %name. In order to fix this, clear caches or put the @type back in its original location. For more information, see <a href="@documentation">the documentation page</a>.', array('@type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING);
- }
- $errors_triggered[$type][$name][$error_type] = TRUE;
- }
- }
- function _drupal_trigger_error_with_delayed_logging($error_msg, $error_type = E_USER_NOTICE) {
- $delay_logging = &drupal_static(__FUNCTION__, FALSE);
- $delay_logging = TRUE;
- trigger_error($error_msg, $error_type);
- $delay_logging = FALSE;
- }
- function drupal_file_scan_write_cache() {
-
-
-
- $file_scans = &_drupal_file_scan_cache();
- if (isset($file_scans['#write_cache']) && isset($file_scans['#cache_merge_done'])) {
- unset($file_scans['#write_cache']);
- cache_set('_drupal_file_scan_cache', $file_scans, 'cache_bootstrap');
- }
- }
- function variable_initialize($conf = array()) {
-
-
- if ($cached = cache_get('variables', 'cache_bootstrap')) {
- $variables = $cached->data;
- }
- else {
-
- $name = 'variable_init';
- if (!lock_acquire($name, 1)) {
-
-
- lock_wait($name);
- return variable_initialize($conf);
- }
- else {
-
- $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
- cache_set('variables', $variables, 'cache_bootstrap');
- lock_release($name);
- }
- }
- foreach ($conf as $name => $value) {
- $variables[$name] = $value;
- }
- return $variables;
- }
- function variable_get($name, $default = NULL) {
- global $conf;
- return isset($conf[$name]) ? $conf[$name] : $default;
- }
- function variable_set($name, $value) {
- global $conf;
- db_merge('variable')->key(array('name' => $name))->fields(array('value' => serialize($value)))->execute();
- cache_clear_all('variables', 'cache_bootstrap');
- $conf[$name] = $value;
- }
- function variable_del($name) {
- global $conf;
- db_delete('variable')
- ->condition('name', $name)
- ->execute();
- cache_clear_all('variables', 'cache_bootstrap');
- unset($conf[$name]);
- }
- function drupal_page_get_cache($check_only = FALSE) {
- global $base_root;
- static $cache_hit = FALSE;
- if ($check_only) {
- return $cache_hit;
- }
- if (drupal_page_is_cacheable()) {
- $cache = cache_get($base_root . request_uri(), 'cache_page');
- if ($cache !== FALSE) {
- $cache_hit = TRUE;
- }
- return $cache;
- }
- }
- function drupal_page_is_cacheable($allow_caching = NULL) {
- $allow_caching_static = &drupal_static(__FUNCTION__, TRUE);
- if (isset($allow_caching)) {
- $allow_caching_static = $allow_caching;
- }
- return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
- && !drupal_is_cli();
- }
- function bootstrap_invoke_all($hook) {
-
-
-
-
-
-
-
- foreach (module_list(FALSE, TRUE) as $module) {
- drupal_load('module', $module);
- module_invoke($module, $hook);
- }
- }
- function drupal_load($type, $name) {
-
-
- static $files = array();
- if (isset($files[$type][$name])) {
- return TRUE;
- }
- $filename = drupal_get_filename($type, $name);
- if ($filename) {
- include_once DRUPAL_ROOT . '/' . $filename;
- $files[$type][$name] = TRUE;
- return TRUE;
- }
- return FALSE;
- }
- function drupal_add_http_header($name, $value, $append = FALSE) {
-
- $headers = &drupal_static('drupal_http_headers', array());
- $name_lower = strtolower($name);
- _drupal_set_preferred_header_name($name);
- if ($value === FALSE) {
- $headers[$name_lower] = FALSE;
- }
- elseif (isset($headers[$name_lower]) && $append) {
-
-
- $headers[$name_lower] .= ',' . $value;
- }
- else {
- $headers[$name_lower] = $value;
- }
- drupal_send_headers(array($name => $headers[$name_lower]), TRUE);
- }
- function drupal_get_http_header($name = NULL) {
- $headers = &drupal_static('drupal_http_headers', array());
- if (isset($name)) {
- $name = strtolower($name);
- return isset($headers[$name]) ? $headers[$name] : NULL;
- }
- else {
- return $headers;
- }
- }
- function _drupal_set_preferred_header_name($name = NULL) {
- static $header_names = array();
- if (!isset($name)) {
- return $header_names;
- }
- $header_names[strtolower($name)] = $name;
- }
- function drupal_send_headers($default_headers = array(), $only_default = FALSE) {
- $headers_sent = &drupal_static(__FUNCTION__, FALSE);
- $headers = drupal_get_http_header();
- if ($only_default && $headers_sent) {
- $headers = array();
- }
- $headers_sent = TRUE;
- $header_names = _drupal_set_preferred_header_name();
- foreach ($default_headers as $name => $value) {
- $name_lower = strtolower($name);
- if (!isset($headers[$name_lower])) {
- $headers[$name_lower] = $value;
- $header_names[$name_lower] = $name;
- }
- }
- foreach ($headers as $name_lower => $value) {
- if ($name_lower == 'status') {
- header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value);
- }
-
- elseif ($value !== FALSE) {
- header($header_names[$name_lower] . ': ' . $value);
- }
- }
- }
- function drupal_page_header() {
- $headers_sent = &drupal_static(__FUNCTION__, FALSE);
- if ($headers_sent) {
- return TRUE;
- }
- $headers_sent = TRUE;
- $default_headers = array(
- 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
- 'Cache-Control' => 'no-cache, must-revalidate',
-
-
-
- 'X-Content-Type-Options' => 'nosniff',
- );
- drupal_send_headers($default_headers);
- }
- function drupal_serve_page_from_cache(stdClass $cache) {
-
- $page_compression = !empty($cache->data['page_compressed']);
- $return_compressed = $page_compression && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE;
-
- $hook_boot_headers = drupal_get_http_header();
-
-
- $default_headers = array();
- foreach ($cache->data['headers'] as $name => $value) {
-
-
-
- $name_lower = strtolower($name);
- if (in_array($name_lower, array('content-location', 'expires', 'cache-control', 'vary')) && !isset($hook_boot_headers[$name_lower])) {
- drupal_add_http_header($name, $value);
- unset($cache->data['headers'][$name]);
- }
- }
-
-
-
-
-
- $max_age = !isset($_COOKIE[session_name()]) || isset($hook_boot_headers['vary']) ? variable_get('page_cache_maximum_age', 0) : 0;
- $default_headers['Cache-Control'] = 'public, max-age=' . $max_age;
-
- $etag = '"' . $cache->created . '-' . intval($return_compressed) . '"';
- header('Etag: ' . $etag);
-
- $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
- $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
- if ($if_modified_since && $if_none_match
- && $if_none_match == $etag
- && $if_modified_since == $cache->created) {
- header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
- drupal_send_headers($default_headers);
- return;
- }
-
- foreach ($cache->data['headers'] as $name => $value) {
- drupal_add_http_header($name, $value);
- }
- $default_headers['Last-Modified'] = gmdate(DATE_RFC7231, $cache->created);
-
-
-
-
- $default_headers['Expires'] = 'Sun, 19 Nov 1978 05:00:00 GMT';
- drupal_send_headers($default_headers);
-
-
-
-
-
-
- if (!isset($hook_boot_headers['vary']) && !variable_get('omit_vary_cookie')) {
- header('Vary: Cookie');
- }
- if ($page_compression) {
- header('Vary: Accept-Encoding', FALSE);
-
- if ($return_compressed) {
-
-
- ini_set('zlib.output_compression', '0');
- header('Content-Encoding: gzip');
- }
- else {
-
-
- $cache->data['body'] = gzinflate(substr(substr($cache->data['body'], 10), 0, -8));
- }
- }
-
- print $cache->data['body'];
- }
- function bootstrap_hooks() {
- return array('boot', 'exit', 'watchdog', 'language_init');
- }
- function drupal_unpack($obj, $field = 'data') {
- if ($obj->$field && $data = unserialize($obj->$field)) {
- foreach ($data as $key => $value) {
- if (!empty($key) && !isset($obj->$key)) {
- $obj->$key = $value;
- }
- }
- }
- return $obj;
- }
- function t($string, array $args = array(), array $options = array()) {
- global $language;
- static $custom_strings;
-
- if (empty($options['langcode'])) {
- $options['langcode'] = isset($language->language) ? $language->language : 'en';
- }
- if (empty($options['context'])) {
- $options['context'] = '';
- }
-
-
-
-
- if (!isset($custom_strings[$options['langcode']])) {
- $custom_strings[$options['langcode']] = variable_get('locale_custom_strings_' . $options['langcode'], array());
- }
-
- if (isset($custom_strings[$options['langcode']][$options['context']][$string])) {
- $string = $custom_strings[$options['langcode']][$options['context']][$string];
- }
-
- elseif ($options['langcode'] != 'en' && function_exists('locale')) {
- $string = locale($string, $options['context'], $options['langcode']);
- }
- if (empty($args)) {
- return $string;
- }
- else {
- return format_string($string, $args);
- }
- }
- function format_string($string, array $args = array()) {
-
- foreach ($args as $key => $value) {
- switch ($key[0]) {
- case '@':
-
- $args[$key] = check_plain($value);
- break;
- case '%':
- default:
-
- $args[$key] = drupal_placeholder($value);
- break;
- case '!':
-
- }
- }
- return strtr($string, $args);
- }
- function check_plain($text) {
- return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
- }
- function drupal_validate_utf8($text) {
- if (strlen($text) == 0) {
- return TRUE;
- }
-
-
-
- return (preg_match('/^./us', $text) == 1);
- }
- function request_uri() {
- if (isset($_SERVER['REQUEST_URI'])) {
- $uri = $_SERVER['REQUEST_URI'];
- }
- else {
- if (isset($_SERVER['argv'])) {
- $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
- }
- elseif (isset($_SERVER['QUERY_STRING'])) {
- $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
- }
- else {
- $uri = $_SERVER['SCRIPT_NAME'];
- }
- }
-
- $uri = '/' . ltrim($uri, '/');
- return $uri;
- }
- function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL) {
-
- if (empty($message)) {
-
- $message = '%type: !message in %function (line %line of %file).';
- }
-
- if (!is_array($variables)) {
- $variables = array();
- }
- require_once DRUPAL_ROOT . '/includes/errors.inc';
- $variables += _drupal_decode_exception($exception);
- watchdog($type, $message, $variables, $severity, $link);
- }
- function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
- global $user, $base_root;
- static $in_error_state = FALSE;
-
-
- if (!$in_error_state && function_exists('module_implements')) {
- $in_error_state = TRUE;
-
- $user_uid = isset($user->uid) ? $user->uid : 0;
-
- $log_entry = array(
- 'type' => $type,
- 'message' => $message,
- 'variables' => $variables,
- 'severity' => $severity,
- 'link' => $link,
- 'user' => $user,
- 'uid' => $user_uid,
- 'request_uri' => $base_root . request_uri(),
- 'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
- 'ip' => ip_address(),
-
- 'timestamp' => time(),
- );
-
- foreach (module_implements('watchdog') as $module) {
- module_invoke($module, 'watchdog', $log_entry);
- }
-
-
- $in_error_state = FALSE;
- }
- }
- function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
- if ($message || $message === '0' || $message === 0) {
- if (!isset($_SESSION['messages'][$type])) {
- $_SESSION['messages'][$type] = array();
- }
- if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
- $_SESSION['messages'][$type][] = $message;
- }
-
- drupal_page_is_cacheable(FALSE);
- }
-
- return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
- }
- function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
- if ($messages = drupal_set_message()) {
- if ($type) {
- if ($clear_queue) {
- unset($_SESSION['messages'][$type]);
- }
- if (isset($messages[$type])) {
- return array($type => $messages[$type]);
- }
- }
- else {
- if ($clear_queue) {
- unset($_SESSION['messages']);
- }
- return $messages;
- }
- }
- return array();
- }
- function drupal_get_title() {
- $title = drupal_set_title();
-
- if (!isset($title) && function_exists('menu_get_active_title')) {
- $title = check_plain(menu_get_active_title());
- }
- return $title;
- }
- function drupal_set_title($title = NULL, $output = CHECK_PLAIN) {
- $stored_title = &drupal_static(__FUNCTION__);
- if (isset($title)) {
- $stored_title = ($output == PASS_THROUGH) ? $title : check_plain($title);
- }
- return $stored_title;
- }
- function drupal_is_denied($ip) {
-
-
-
- $blocked_ips = variable_get('blocked_ips');
- $denied = FALSE;
- if (isset($blocked_ips) && is_array($blocked_ips)) {
- $denied = in_array($ip, $blocked_ips);
- }
-
-
-
-
-
-
- elseif (class_exists('Database', FALSE)) {
- $denied = (bool)db_query("SELECT 1 FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
- }
- return $denied;
- }
- function drupal_block_denied($ip) {
-
- if (drupal_is_denied($ip)) {
- header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
- print 'Sorry, ' . check_plain(ip_address()) . ' has been banned.';
- exit();
- }
- }
- function drupal_random_key($byte_count = 32) {
- return drupal_base64_encode(drupal_random_bytes($byte_count));
- }
- function drupal_base64_encode($string) {
- $data = base64_encode($string);
-
- return strtr($data, array('+' => '-', '/' => '_', '=' => ''));
- }
- function drupal_random_bytes($count) {
-
- static $random_state, $bytes, $has_openssl;
- $missing_bytes = $count - strlen($bytes);
- if ($missing_bytes > 0) {
-
-
- if (!isset($has_openssl)) {
- $has_openssl = version_compare(PHP_VERSION, '5.3.4', '>=') && function_exists('openssl_random_pseudo_bytes');
- }
-
-
- if ($has_openssl) {
- $bytes .= openssl_random_pseudo_bytes($missing_bytes);
- }
-
-
- elseif ($fh = @fopen('/dev/urandom', 'rb')) {
-
-
-
- $bytes .= fread($fh, max(4096, $missing_bytes));
- fclose($fh);
- }
-
-
-
-
-
-
-
-
- if (strlen($bytes) < $count) {
-
-
- if (!isset($random_state)) {
- $random_state = print_r($_SERVER, TRUE);
- if (function_exists('getmypid')) {
-
- $random_state .= getmypid();
- }
- $bytes = '';
- }
- do {
- $random_state = hash('sha256', microtime() . mt_rand() . $random_state);
- $bytes .= hash('sha256', mt_rand() . $random_state, TRUE);
- }
- while (strlen($bytes) < $count);
- }
- }
- $output = substr($bytes, 0, $count);
- $bytes = substr($bytes, $count);
- return $output;
- }
- function drupal_hmac_base64($data, $key) {
-
-
-
-
- $hmac = base64_encode(hash_hmac('sha256', (string) $data, (string) $key, TRUE));
-
- return strtr($hmac, array('+' => '-', '/' => '_', '=' => ''));
- }
- function drupal_hash_base64($data) {
- $hash = base64_encode(hash('sha256', $data, TRUE));
-
- return strtr($hash, array('+' => '-', '/' => '_', '=' => ''));
- }
- function drupal_array_merge_deep() {
- $args = func_get_args();
- return drupal_array_merge_deep_array($args);
- }
- function drupal_array_merge_deep_array($arrays) {
- $result = array();
- foreach ($arrays as $array) {
- foreach ($array as $key => $value) {
-
-
-
- if (is_integer($key)) {
- $result[] = $value;
- }
-
- elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
- $result[$key] = drupal_array_merge_deep_array(array($result[$key], $value));
- }
-
- else {
- $result[$key] = $value;
- }
- }
- }
- return $result;
- }
- function drupal_anonymous_user() {
- $user = variable_get('drupal_anonymous_user_object', new stdClass);
- $user->uid = 0;
- $user->hostname = ip_address();
- $user->roles = array();
- $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
- $user->cache = 0;
- return $user;
- }
- function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
-
- static $phases = array(
- DRUPAL_BOOTSTRAP_CONFIGURATION,
- DRUPAL_BOOTSTRAP_PAGE_CACHE,
- DRUPAL_BOOTSTRAP_DATABASE,
- DRUPAL_BOOTSTRAP_VARIABLES,
- DRUPAL_BOOTSTRAP_SESSION,
- DRUPAL_BOOTSTRAP_PAGE_HEADER,
- DRUPAL_BOOTSTRAP_LANGUAGE,
- DRUPAL_BOOTSTRAP_FULL,
- );
-
-
- static $final_phase;
-
-
- static $stored_phase = -1;
- if (isset($phase)) {
-
-
- if ($new_phase && $phase >= $stored_phase) {
- $final_phase = $phase;
- }
-
-
- while ($phases && $phase > $stored_phase && $final_phase > $stored_phase) {
- $current_phase = array_shift($phases);
-
-
- if ($current_phase > $stored_phase) {
- $stored_phase = $current_phase;
- }
- switch ($current_phase) {
- case DRUPAL_BOOTSTRAP_CONFIGURATION:
- _drupal_bootstrap_configuration();
- break;
- case DRUPAL_BOOTSTRAP_PAGE_CACHE:
- _drupal_bootstrap_page_cache();
- break;
- case DRUPAL_BOOTSTRAP_DATABASE:
- _drupal_bootstrap_database();
- break;
- case DRUPAL_BOOTSTRAP_VARIABLES:
- _drupal_bootstrap_variables();
- break;
- case DRUPAL_BOOTSTRAP_SESSION:
- require_once DRUPAL_ROOT . '/' . variable_get('session_inc', 'includes/session.inc');
- drupal_session_initialize();
- break;
- case DRUPAL_BOOTSTRAP_PAGE_HEADER:
- _drupal_bootstrap_page_header();
- break;
- case DRUPAL_BOOTSTRAP_LANGUAGE:
- drupal_language_initialize();
- break;
- case DRUPAL_BOOTSTRAP_FULL:
- require_once DRUPAL_ROOT . '/includes/common.inc';
- _drupal_bootstrap_full();
- break;
- }
- }
- }
- return $stored_phase;
- }
- function drupal_get_user_timezone() {
- global $user;
- if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
- return $user->timezone;
- }
- else {
-
-
- return variable_get('date_default_timezone', @date_default_timezone_get());
- }
- }
- function drupal_get_hash_salt() {
- global $drupal_hash_salt, $databases;
-
-
- return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt;
- }
- function _drupal_error_handler($error_level, $message, $filename, $line, $context) {
- require_once DRUPAL_ROOT . '/includes/errors.inc';
- _drupal_error_handler_real($error_level, $message, $filename, $line, $context);
- }
- function _drupal_exception_handler($exception) {
- require_once DRUPAL_ROOT . '/includes/errors.inc';
- try {
-
- _drupal_log_error(_drupal_decode_exception($exception), TRUE);
- }
- catch (Exception $exception2) {
-
-
- if (error_displayable()) {
- print '<h1>Additional uncaught exception thrown while handling exception.</h1>';
- print '<h2>Original</h2><p>' . _drupal_render_exception_safe($exception) . '</p>';
- print '<h2>Additional</h2><p>' . _drupal_render_exception_safe($exception2) . '</p><hr />';
- }
- }
- }
- function _drupal_bootstrap_configuration() {
-
- set_error_handler('_drupal_error_handler');
- set_exception_handler('_drupal_exception_handler');
- drupal_environment_initialize();
-
- timer_start('page');
-
- drupal_settings_initialize();
- }
- function _drupal_bootstrap_page_cache() {
- global $user;
-
-
- require_once DRUPAL_ROOT . '/includes/cache.inc';
- foreach (variable_get('cache_backends', array()) as $include) {
- require_once DRUPAL_ROOT . '/' . $include;
- }
-
- if (variable_get('page_cache_without_database')) {
- $cache_enabled = TRUE;
- }
- else {
- drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
- $cache_enabled = variable_get('cache');
- }
- drupal_block_denied(ip_address());
-
-
- if (!isset($_COOKIE[session_name()]) && $cache_enabled) {
-
-
- $user = drupal_anonymous_user();
-
- $cache = drupal_page_get_cache();
-
- if (is_object($cache)) {
- header('X-Drupal-Cache: HIT');
-
- $_GET['q'] = $cache->data['path'];
- drupal_set_title($cache->data['title'], PASS_THROUGH);
- date_default_timezone_set(drupal_get_user_timezone());
-
-
- if (variable_get('page_cache_invoke_hooks', TRUE)) {
- bootstrap_invoke_all('boot');
- }
- drupal_serve_page_from_cache($cache);
-
-
- if (variable_get('page_cache_invoke_hooks', TRUE)) {
- bootstrap_invoke_all('exit');
- }
-
- exit;
- }
- else {
- header('X-Drupal-Cache: MISS');
- }
- }
- }
- function _drupal_bootstrap_database() {
-
-
-
- if (empty($GLOBALS['databases']) && !drupal_installation_attempted()) {
- include_once DRUPAL_ROOT . '/includes/install.inc';
- install_goto('install.php');
- }
-
-
-
- if ($test_prefix = drupal_valid_test_ua()) {
-
- $test_info = &$GLOBALS['drupal_test_info'];
- $test_info['test_run_id'] = $test_prefix;
- $test_info['in_child_site'] = TRUE;
- foreach ($GLOBALS['databases']['default'] as &$value) {
-
- if (!isset($value['prefix'])) {
- $current_prefix = '';
- }
- elseif (is_array($value['prefix'])) {
- $current_prefix = $value['prefix']['default'];
- }
- else {
- $current_prefix = $value['prefix'];
- }
-
- $value['prefix'] = array(
- 'default' => $current_prefix . $test_prefix,
- );
- }
- }
-
-
- require_once DRUPAL_ROOT . '/includes/database/database.inc';
-
-
-
-
- spl_autoload_register('drupal_autoload_class');
- spl_autoload_register('drupal_autoload_interface');
- if (version_compare(PHP_VERSION, '5.4') >= 0) {
- spl_autoload_register('drupal_autoload_trait');
- }
- }
- function _drupal_bootstrap_variables() {
- global $conf;
-
- require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
- lock_initialize();
-
- $conf = variable_initialize(isset($conf) ? $conf : array());
-
- require_once DRUPAL_ROOT . '/includes/module.inc';
- module_load_all(TRUE);
-
-
-
-
-
-
- if (isset($_GET['destination']) || isset($_REQUEST['destination'])) {
- require_once DRUPAL_ROOT . '/includes/common.inc';
-
- if (isset($_GET['destination']) && url_is_external($_GET['destination'])) {
- unset($_GET['destination']);
- unset($_REQUEST['destination']);
- }
-
-
- if (isset($_REQUEST['destination']) && (!isset($_GET['destination']) || $_REQUEST['destination'] != $_GET['destination']) && url_is_external($_REQUEST['destination'])) {
- unset($_REQUEST['destination']);
- }
- }
- }
- function _drupal_bootstrap_page_header() {
- bootstrap_invoke_all('boot');
- if (!drupal_is_cli()) {
- ob_start();
- drupal_page_header();
- }
- }
- function drupal_get_bootstrap_phase() {
- return drupal_bootstrap(NULL, FALSE);
- }
- function drupal_valid_test_ua() {
-
- static $test_prefix;
- if (isset($test_prefix)) {
- return $test_prefix;
- }
- if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^(simpletest\d+);(.+);(.+);(.+)$/", $_SERVER['HTTP_USER_AGENT'], $matches)) {
- list(, $prefix, $time, $salt, $hmac) = $matches;
- $check_string = $prefix . ';' . $time . ';' . $salt;
-
-
-
- $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__);
- $time_diff = REQUEST_TIME - $time;
-
-
- if ($time_diff >= 0 && $time_diff <= 5 && $hmac == drupal_hmac_base64($check_string, $key)) {
- $test_prefix = $prefix;
- return $test_prefix;
- }
- }
- $test_prefix = FALSE;
- return $test_prefix;
- }
- function drupal_generate_test_ua($prefix) {
- static $key;
- if (!isset($key)) {
-
-
-
- $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__);
- }
-
- $salt = uniqid('', TRUE);
- $check_string = $prefix . ';' . time() . ';' . $salt;
- return $check_string . ';' . drupal_hmac_base64($check_string, $key);
- }
- function drupal_maintenance_theme() {
- require_once DRUPAL_ROOT . '/includes/theme.maintenance.inc';
- _drupal_maintenance_theme();
- }
- function drupal_fast_404() {
- $exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
- if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
- $fast_paths = variable_get('404_fast_paths', FALSE);
- if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
- drupal_add_http_header('Status', '404 Not Found');
- $fast_404_html = variable_get('404_fast_html', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
-
- print strtr($fast_404_html, array('@path' => check_plain(request_uri())));
- exit;
- }
- }
- }
- function drupal_installation_attempted() {
- return defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install';
- }
- function get_t() {
- static $t;
-
-
- if (!isset($t)) {
- $t = drupal_installation_attempted() ? 'st' : 't';
- }
- return $t;
- }
- function drupal_language_initialize() {
- $types = language_types();
-
-
-
-
- $default = language_default();
- foreach ($types as $type) {
- $GLOBALS[$type] = $default;
- }
- if (drupal_multilingual()) {
- include_once DRUPAL_ROOT . '/includes/language.inc';
- foreach ($types as $type) {
- $GLOBALS[$type] = language_initialize($type);
- }
-
-
- bootstrap_invoke_all('language_init');
- }
- }
- function drupal_language_types() {
- return array(
- LANGUAGE_TYPE_INTERFACE => TRUE,
- LANGUAGE_TYPE_CONTENT => FALSE,
- LANGUAGE_TYPE_URL => FALSE,
- );
- }
- function drupal_multilingual() {
-
-
-
- return variable_get('language_count', 1) > 1;
- }
- function language_types() {
- return array_keys(variable_get('language_types', drupal_language_types()));
- }
- function language_list($field = 'language') {
- $languages = &drupal_static(__FUNCTION__);
-
- if (!isset($languages)) {
- if (drupal_multilingual() || module_exists('locale')) {
- $languages['language'] = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC')->fetchAllAssoc('language');
-
-
-
- if (!$languages['language']['en']->enabled && !variable_get('language_native_enabled', TRUE)) {
- unset($languages['language']['en']);
- }
- }
- else {
-
- $default = language_default();
- $languages['language'][$default->language] = $default;
- }
- }
-
- if (!isset($languages[$field])) {
- $languages[$field] = array();
- foreach ($languages['language'] as $lang) {
-
- if (in_array($field, array('enabled', 'weight'))) {
- $languages[$field][$lang->$field][$lang->language] = $lang;
- }
- else {
- $languages[$field][$lang->$field] = $lang;
- }
- }
- }
- return $languages[$field];
- }
- function language_default($property = NULL) {
- $language = variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''));
- return $property ? $language->$property : $language;
- }
- function request_path() {
- static $path;
- if (isset($path)) {
- return $path;
- }
- if (isset($_GET['q']) && is_string($_GET['q'])) {
-
-
-
-
- $path = $_GET['q'];
- }
- elseif (isset($_SERVER['REQUEST_URI'])) {
-
-
- $request_path = strtok($_SERVER['REQUEST_URI'], '?');
- $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
-
- $path = substr(urldecode($request_path), $base_path_len + 1);
-
-
-
-
- if ($path == basename($_SERVER['PHP_SELF'])) {
- $path = '';
- }
- }
- else {
-
- $path = '';
- }
-
-
-
- $path = trim($path, '/');
- return $path;
- }
- function arg($index = NULL, $path = NULL) {
-
-
-
-
-
- static $drupal_static_fast;
- if (!isset($drupal_static_fast)) {
- $drupal_static_fast['arguments'] = &drupal_static(__FUNCTION__);
- }
- $arguments = &$drupal_static_fast['arguments'];
- if (!isset($path)) {
- $path = $_GET['q'];
- }
- if (!isset($arguments[$path])) {
- $arguments[$path] = explode('/', $path);
- }
- if (!isset($index)) {
- return $arguments[$path];
- }
- if (isset($arguments[$path][$index])) {
- return $arguments[$path][$index];
- }
- }
- function ip_address() {
- $ip_address = &drupal_static(__FUNCTION__);
- if (!isset($ip_address)) {
- $ip_address = $_SERVER['REMOTE_ADDR'];
- if (variable_get('reverse_proxy', 0)) {
- $reverse_proxy_header = variable_get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
- if (!empty($_SERVER[$reverse_proxy_header])) {
-
-
- $reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());
-
- $forwarded = explode(',', $_SERVER[$reverse_proxy_header]);
-
- $forwarded = array_map('trim', $forwarded);
-
- $forwarded[] = $ip_address;
-
- $untrusted = array_diff($forwarded, $reverse_proxy_addresses);
- if (!empty($untrusted)) {
-
- $ip_address = array_pop($untrusted);
- }
- else {
-
-
- $ip_address = array_shift($forwarded);
- }
- }
- }
- }
- return $ip_address;
- }
- function drupal_get_schema($table = NULL, $rebuild = FALSE) {
- static $schema;
- if ($rebuild || !isset($table)) {
- $schema = drupal_get_complete_schema($rebuild);
- }
- elseif (!isset($schema)) {
- $schema = new SchemaCache();
- }
- if (!isset($table)) {
- return $schema;
- }
- if (isset($schema[$table])) {
- return $schema[$table];
- }
- else {
- return FALSE;
- }
- }
- class SchemaCache extends DrupalCacheArray {
-
- public function __construct() {
-
- parent::__construct('schema:runtime:' . ($_SERVER['REQUEST_METHOD'] == 'GET'), 'cache');
- }
-
- protected function resolveCacheMiss($offset) {
- $complete_schema = drupal_get_complete_schema();
- $value = isset($complete_schema[$offset]) ? $complete_schema[$offset] : NULL;
- $this->storage[$offset] = $value;
- $this->persist($offset);
- return $value;
- }
- }
- function drupal_get_complete_schema($rebuild = FALSE) {
- static $schema = array();
- if (empty($schema) || $rebuild) {
-
- if (!$rebuild && $cached = cache_get('schema')) {
- $schema = $cached->data;
- }
-
- else {
- $schema = array();
-
-
-
- if (function_exists('module_load_all_includes')) {
-
-
-
-
- module_list(TRUE);
- module_load_all_includes('install');
- }
- require_once DRUPAL_ROOT . '/includes/common.inc';
-
- foreach (module_implements('schema') as $module) {
-
-
-
- $current = (array) module_invoke($module, 'schema');
-
-
- _drupal_schema_initialize($current, $module);
- $schema = array_merge($schema, $current);
- }
- drupal_alter('schema', $schema);
-
-
- if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
- cache_set('schema', $schema);
- }
- if ($rebuild) {
- cache_clear_all('schema:', 'cache', TRUE);
- }
- }
- }
- return $schema;
- }
- function drupal_autoload_interface($interface) {
- return _registry_check_code('interface', $interface);
- }
- function drupal_autoload_class($class) {
- return _registry_check_code('class', $class);
- }
- function drupal_autoload_trait($trait) {
- return _registry_check_code('trait', $trait);
- }
- function _registry_check_code($type, $name = NULL) {
- static $lookup_cache, $cache_update_needed;
- if ($type == 'class' && class_exists($name) || $type == 'interface' && interface_exists($name) || $type == 'trait' && trait_exists($name)) {
- return TRUE;
- }
- if (!isset($lookup_cache)) {
- $lookup_cache = array();
- if ($cache = cache_get('lookup_cache', 'cache_bootstrap')) {
- $lookup_cache = $cache->data;
- }
- }
-
-
- if ($type == REGISTRY_RESET_LOOKUP_CACHE) {
- $cache_update_needed = TRUE;
- $lookup_cache = NULL;
- return;
- }
-
-
- if ($type == REGISTRY_WRITE_LOOKUP_CACHE) {
- if ($cache_update_needed) {
- cache_set('lookup_cache', $lookup_cache, 'cache_bootstrap');
- }
- return;
- }
-
-
- $cache_key = $type[0] . $name;
- if (isset($lookup_cache[$cache_key])) {
- if ($lookup_cache[$cache_key]) {
- include_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key];
- }
- return (bool) $lookup_cache[$cache_key];
- }
-
-
-
- $file = Database::getConnection('default', 'default')
- ->select('registry', 'r', array('target' => 'default'))
- ->fields('r', array('filename'))
-
- ->condition('r.name', db_like($name), 'LIKE')
- ->condition('r.type', $type)
- ->execute()
- ->fetchField();
-
- $cache_update_needed = TRUE;
-
-
- $lookup_cache[$cache_key] = $file;
- if ($file) {
- include_once DRUPAL_ROOT . '/' . $file;
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- function registry_rebuild() {
- system_rebuild_module_data();
- registry_update();
- }
- function registry_update() {
-
-
-
- $in_installer = drupal_installation_attempted();
- if (!$in_installer && !lock_acquire(__FUNCTION__)) {
-
- lock_wait(__FUNCTION__);
- return FALSE;
- }
- require_once DRUPAL_ROOT . '/includes/registry.inc';
- _registry_update();
- if (!$in_installer) {
- lock_release(__FUNCTION__);
- }
- return TRUE;
- }
- function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
- static $data = array(), $default = array();
-
- if (isset($data[$name]) || array_key_exists($name, $data)) {
-
- if ($reset) {
-
- $data[$name] = $default[$name];
- }
- return $data[$name];
- }
-
- if (isset($name)) {
- if ($reset) {
-
-
- return $data;
- }
-
- $default[$name] = $data[$name] = $default_value;
- return $data[$name];
- }
-
-
-
- foreach ($default as $name => $value) {
- $data[$name] = $value;
- }
-
-
- return $data;
- }
- function drupal_static_reset($name = NULL) {
- drupal_static($name, NULL, TRUE);
- }
- function drupal_is_cli() {
- return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
- }
- function drupal_placeholder($text) {
- return '<em class="placeholder">' . check_plain($text) . '</em>';
- }
- function &drupal_register_shutdown_function($callback = NULL) {
-
-
- static $callbacks = array();
- if (isset($callback)) {
-
- if (empty($callbacks)) {
- register_shutdown_function('_drupal_shutdown_function');
- }
- $args = func_get_args();
- array_shift($args);
-
- $callbacks[] = array('callback' => $callback, 'arguments' => $args);
- }
- return $callbacks;
- }
- function _drupal_shutdown_function() {
- $callbacks = &drupal_register_shutdown_function();
-
-
- chdir(DRUPAL_ROOT);
- try {
- while (list($key, $callback) = each($callbacks)) {
- call_user_func_array($callback['callback'], $callback['arguments']);
- }
- }
- catch (Exception $exception) {
-
- require_once DRUPAL_ROOT . '/includes/errors.inc';
- if (error_displayable()) {
- print '<h1>Uncaught exception thrown in shutdown function.</h1>';
- print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
- }
- }
- }
- function drupal_check_memory_limit($required, $memory_limit = NULL) {
- if (!isset($memory_limit)) {
- $memory_limit = ini_get('memory_limit');
- }
-
-
-
-
- return ((!$memory_limit) || ($memory_limit == -1) || (parse_size($memory_limit) >= parse_size($required)));
- }
- function drupal_clear_opcode_cache($filepath) {
- if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
-
- clearstatcache();
- }
- else {
- clearstatcache(TRUE, $filepath);
- }
-
- if (function_exists('opcache_invalidate')) {
- opcache_invalidate($filepath, TRUE);
- }
-
- if (function_exists('apc_delete_file')) {
-
-
-
- @apc_delete_file($filepath);
- }
- }
|