├── LICENSE ├── README.md ├── classes ├── AdminController.php ├── AjaxController.php ├── AuthController.php ├── BaseController.php ├── BaseModel.php ├── ClaimController.php ├── Config.php ├── DB.php ├── FaucetHub.php ├── HomeController.php └── User.php ├── database.sql ├── includes ├── CSRF.php ├── config.php └── core.php ├── index.php ├── libs ├── Autoloader.php ├── Smarty.class.php ├── SmartyBC.class.php ├── debug.tpl ├── plugins │ ├── block.textformat.php │ ├── function.counter.php │ ├── function.cycle.php │ ├── function.fetch.php │ ├── function.html_checkboxes.php │ ├── function.html_image.php │ ├── function.html_options.php │ ├── function.html_radios.php │ ├── function.html_select_date.php │ ├── function.html_select_time.php │ ├── function.html_table.php │ ├── function.mailto.php │ ├── function.math.php │ ├── modifier.capitalize.php │ ├── modifier.date_format.php │ ├── modifier.debug_print_var.php │ ├── modifier.escape.php │ ├── modifier.regex_replace.php │ ├── modifier.replace.php │ ├── modifier.spacify.php │ ├── modifier.truncate.php │ ├── modifiercompiler.cat.php │ ├── modifiercompiler.count_characters.php │ ├── modifiercompiler.count_paragraphs.php │ ├── modifiercompiler.count_sentences.php │ ├── modifiercompiler.count_words.php │ ├── modifiercompiler.default.php │ ├── modifiercompiler.escape.php │ ├── modifiercompiler.from_charset.php │ ├── modifiercompiler.indent.php │ ├── modifiercompiler.lower.php │ ├── modifiercompiler.noprint.php │ ├── modifiercompiler.string_format.php │ ├── modifiercompiler.strip.php │ ├── modifiercompiler.strip_tags.php │ ├── modifiercompiler.to_charset.php │ ├── modifiercompiler.unescape.php │ ├── modifiercompiler.upper.php │ ├── modifiercompiler.wordwrap.php │ ├── outputfilter.trimwhitespace.php │ ├── shared.escape_special_chars.php │ ├── shared.literal_compiler_param.php │ ├── shared.make_timestamp.php │ ├── shared.mb_str_replace.php │ ├── shared.mb_unicode.php │ ├── shared.mb_wordwrap.php │ └── variablefilter.htmlspecialchars.php └── sysplugins │ ├── smarty_cacheresource.php │ ├── smarty_cacheresource_custom.php │ ├── smarty_cacheresource_keyvaluestore.php │ ├── smarty_data.php │ ├── smarty_internal_cacheresource_file.php │ ├── smarty_internal_compile_append.php │ ├── smarty_internal_compile_assign.php │ ├── smarty_internal_compile_block.php │ ├── smarty_internal_compile_break.php │ ├── smarty_internal_compile_call.php │ ├── smarty_internal_compile_capture.php │ ├── smarty_internal_compile_config_load.php │ ├── smarty_internal_compile_continue.php │ ├── smarty_internal_compile_debug.php │ ├── smarty_internal_compile_eval.php │ ├── smarty_internal_compile_extends.php │ ├── smarty_internal_compile_for.php │ ├── smarty_internal_compile_foreach.php │ ├── smarty_internal_compile_function.php │ ├── smarty_internal_compile_if.php │ ├── smarty_internal_compile_include.php │ ├── smarty_internal_compile_include_php.php │ ├── smarty_internal_compile_insert.php │ ├── smarty_internal_compile_ldelim.php │ ├── smarty_internal_compile_nocache.php │ ├── smarty_internal_compile_private_block_plugin.php │ ├── smarty_internal_compile_private_foreachsection.php │ ├── smarty_internal_compile_private_function_plugin.php │ ├── smarty_internal_compile_private_modifier.php │ ├── smarty_internal_compile_private_object_block_function.php │ ├── smarty_internal_compile_private_object_function.php │ ├── smarty_internal_compile_private_php.php │ ├── smarty_internal_compile_private_print_expression.php │ ├── smarty_internal_compile_private_registered_block.php │ ├── smarty_internal_compile_private_registered_function.php │ ├── smarty_internal_compile_private_special_variable.php │ ├── smarty_internal_compile_rdelim.php │ ├── smarty_internal_compile_section.php │ ├── smarty_internal_compile_setfilter.php │ ├── smarty_internal_compile_shared_inheritance.php │ ├── smarty_internal_compile_while.php │ ├── smarty_internal_compilebase.php │ ├── smarty_internal_config_file_compiler.php │ ├── smarty_internal_configfilelexer.php │ ├── smarty_internal_configfileparser.php │ ├── smarty_internal_data.php │ ├── smarty_internal_debug.php │ ├── smarty_internal_extension_clear.php │ ├── smarty_internal_extension_handler.php │ ├── smarty_internal_method_addautoloadfilters.php │ ├── smarty_internal_method_adddefaultmodifiers.php │ ├── smarty_internal_method_append.php │ ├── smarty_internal_method_appendbyref.php │ ├── smarty_internal_method_assignbyref.php │ ├── smarty_internal_method_assignglobal.php │ ├── smarty_internal_method_clearallassign.php │ ├── smarty_internal_method_clearallcache.php │ ├── smarty_internal_method_clearassign.php │ ├── smarty_internal_method_clearcache.php │ ├── smarty_internal_method_clearcompiledtemplate.php │ ├── smarty_internal_method_clearconfig.php │ ├── smarty_internal_method_compileallconfig.php │ ├── smarty_internal_method_compilealltemplates.php │ ├── smarty_internal_method_configload.php │ ├── smarty_internal_method_createdata.php │ ├── smarty_internal_method_getautoloadfilters.php │ ├── smarty_internal_method_getconfigvars.php │ ├── smarty_internal_method_getdebugtemplate.php │ ├── smarty_internal_method_getdefaultmodifiers.php │ ├── smarty_internal_method_getregisteredobject.php │ ├── smarty_internal_method_getstreamvariable.php │ ├── smarty_internal_method_gettags.php │ ├── smarty_internal_method_gettemplatevars.php │ ├── smarty_internal_method_loadfilter.php │ ├── smarty_internal_method_loadplugin.php │ ├── smarty_internal_method_mustcompile.php │ ├── smarty_internal_method_registercacheresource.php │ ├── smarty_internal_method_registerclass.php │ ├── smarty_internal_method_registerdefaultconfighandler.php │ ├── smarty_internal_method_registerdefaultpluginhandler.php │ ├── smarty_internal_method_registerdefaulttemplatehandler.php │ ├── smarty_internal_method_registerfilter.php │ ├── smarty_internal_method_registerobject.php │ ├── smarty_internal_method_registerplugin.php │ ├── smarty_internal_method_registerresource.php │ ├── smarty_internal_method_setautoloadfilters.php │ ├── smarty_internal_method_setdebugtemplate.php │ ├── smarty_internal_method_setdefaultmodifiers.php │ ├── smarty_internal_method_unloadfilter.php │ ├── smarty_internal_method_unregistercacheresource.php │ ├── smarty_internal_method_unregisterfilter.php │ ├── smarty_internal_method_unregisterobject.php │ ├── smarty_internal_method_unregisterplugin.php │ ├── smarty_internal_method_unregisterresource.php │ ├── smarty_internal_nocache_insert.php │ ├── smarty_internal_parsetree.php │ ├── smarty_internal_parsetree_code.php │ ├── smarty_internal_parsetree_dq.php │ ├── smarty_internal_parsetree_dqcontent.php │ ├── smarty_internal_parsetree_tag.php │ ├── smarty_internal_parsetree_template.php │ ├── smarty_internal_parsetree_text.php │ ├── smarty_internal_resource_eval.php │ ├── smarty_internal_resource_extends.php │ ├── smarty_internal_resource_file.php │ ├── smarty_internal_resource_php.php │ ├── smarty_internal_resource_registered.php │ ├── smarty_internal_resource_stream.php │ ├── smarty_internal_resource_string.php │ ├── smarty_internal_runtime_cachemodify.php │ ├── smarty_internal_runtime_codeframe.php │ ├── smarty_internal_runtime_filterhandler.php │ ├── smarty_internal_runtime_foreach.php │ ├── smarty_internal_runtime_getincludepath.php │ ├── smarty_internal_runtime_hhvm.php │ ├── smarty_internal_runtime_inheritance.php │ ├── smarty_internal_runtime_subtemplate.php │ ├── smarty_internal_runtime_tplfunction.php │ ├── smarty_internal_runtime_updatecache.php │ ├── smarty_internal_runtime_updatescope.php │ ├── smarty_internal_runtime_validatecompiled.php │ ├── smarty_internal_runtime_var.php │ ├── smarty_internal_runtime_writefile.php │ ├── smarty_internal_smartytemplatecompiler.php │ ├── smarty_internal_template.php │ ├── smarty_internal_templatebase.php │ ├── smarty_internal_templatecompilerbase.php │ ├── smarty_internal_templatelexer.php │ ├── smarty_internal_templateparser.php │ ├── smarty_internal_testinstall.php │ ├── smarty_internal_undefined.php │ ├── smarty_resource.php │ ├── smarty_resource_custom.php │ ├── smarty_resource_recompiled.php │ ├── smarty_resource_uncompiled.php │ ├── smarty_security.php │ ├── smarty_template_cached.php │ ├── smarty_template_compiled.php │ ├── smarty_template_config.php │ ├── smarty_template_resource_base.php │ ├── smarty_template_source.php │ ├── smarty_undefined_variable.php │ ├── smarty_variable.php │ ├── smartycompilerexception.php │ └── smartyexception.php └── templates └── default ├── 404.tpl ├── admin.tpl ├── footer.tpl ├── header.tpl ├── home.tpl ├── index.tpl └── verify.tpl /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Faucetscript 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FaucetHub-Script 2 | FaucetScript is a brand new faucet script made with simplicity and security in mind. Your user will claim and collect their satoshis on a site balance. They then can withdraw their balance, if they have at least the withdraw threshold (if set). 3 | 4 | 5 | # System Requirements 6 | 7 | - Webserver 8 | - PHP >= 5.5 9 | - MySQL database 10 | 11 | # How to install? 12 | 13 | 1. Download the files 14 | 2. Upload the files to your webserver (using FTP for instance) 15 | 3. Import the database.sql using PHPMyAdmin 16 | 4. Go to the faucet_settings table and set your reCaptcha keys (THIS IS MANDATORY, since you require a account to become a site admin) 17 | 4. Change includes/config.php accordingly with your MySQL credentials. 18 | 5. Go to http://www.yoursite.nl/ and register. After registration go back to PhpMyAdmin and in table faucet_user_list set admin = 1 at your user row. 19 | 6. Now go to http://www.yoursite.nl/index.php?route=admin/home and configure your faucet. Make sure you are logged in before browsing to mentioned page. 20 | 7. You're done. Good luck! 21 | 22 | # Demo 23 | 24 | This faucet script is used on: 25 | - http://www.coinfaucet.space 26 | 27 | If you want to have your faucet added to this list, contact bitcoinniels at bitcointalk.org 28 | 29 | # Fee 30 | 31 | To support my work, at each claim a small fee of up to 5 satoshi will be sent to me. If you really require this fee to be removed, contact us to get a quote on a paid version. -------------------------------------------------------------------------------- /classes/AdminController.php: -------------------------------------------------------------------------------- 1 | isAuthenticated() || $this->getUser()->admin != 1) { 6 | $this->tplEngine->display('404.tpl'); 7 | exit(); 8 | } 9 | 10 | $this->tplEngine->display('admin.tpl'); 11 | } 12 | 13 | public function postUpdate() { 14 | switch($_GET['action']) { 15 | case "general": 16 | if(isset($_POST['faucet_name']) && isset($_POST['timer']) && isset($_POST['min_reward']) && isset($_POST['max_reward']) && isset($_POST['reCaptcha_privKey']) && isset($_POST['reCaptcha_pubKey']) && isset($_POST['faucethub_key']) && isset($_POST['referral_percent'])) { 17 | $fName = $_POST['faucet_name']; 18 | $fSlogan = $_POST['faucet_slogan']; 19 | $timer = $_POST['timer']; 20 | $minReward = $_POST['min_reward']; 21 | $maxReward = $_POST['max_reward']; 22 | $rePriv = $_POST['reCaptcha_privKey']; 23 | $rePub = $_POST['reCaptcha_pubKey']; 24 | $fHubKey = $_POST['faucethub_key']; 25 | $refPercent = $_POST['referral_percent']; 26 | 27 | $this->setConfig('faucet_name', $fName); 28 | $this->setConfig('faucet_slogan', $fSlogan); 29 | $this->setConfig('timer', $timer); 30 | $this->setConfig('min_reward', $minReward); 31 | $this->setConfig('max_reward', $maxReward); 32 | $this->setConfig('reCaptcha_privKey', $rePriv); 33 | $this->setConfig('reCaptcha_pubKey', $rePub); 34 | $this->setConfig('faucethub_key', $fHubKey); 35 | $this->setConfig('referral_percent', $refPercent); 36 | $this->tplEngine->assign('results', $this->alert('success', 'Settings are saved.')); 37 | } else { 38 | $this->tplEngine->assign('results', $this->alert("The fields can't be blank.")); 39 | } 40 | break; 41 | case "ads": 42 | if(isset($_POST['space_top']) && isset($_POST['space_left']) && isset($_POST['space_right']) && isset($_POST['space_bottom'])) { 43 | $spaceTop = $_POST['space_top']; 44 | $spaceLeft = $_POST['space_left']; 45 | $spaceRight = $_POST['space_right']; 46 | $spaceBottom = $_POST['space_bottom']; 47 | 48 | $this->setConfig('space_top', $spaceTop); 49 | $this->setConfig('space_left', $spaceLeft); 50 | $this->setConfig('space_right', $spaceRight); 51 | $this->setConfig('space_bottom', $spaceBottom); 52 | $this->tplEngine->assign('results', $this->alert('success', 'Settings are saved.')); 53 | } else { 54 | $this->tplEngine->assign('results', $this->alert("The fields can't be blank.")); 55 | } 56 | break; 57 | 58 | 59 | } 60 | $this->tplEngine->display('admin.tpl'); 61 | } 62 | } -------------------------------------------------------------------------------- /classes/AjaxController.php: -------------------------------------------------------------------------------- 1 | isAuthenticated()) { 6 | 7 | $lastClaim = $this->getUser()->last_claim; 8 | $nextClaim = $lastClaim + (60 * $this->getConfig('timer')); 9 | $difference = $nextClaim - time(); 10 | if($difference > 0) { 11 | $hours = floor($difference / 3600); 12 | if($hours != 0) { 13 | $difference = $difference - ($hours * 3600); 14 | } 15 | $minutes = floor($difference / 60); 16 | $seconds = $difference - ($minutes * 60); 17 | 18 | if($hours != 0) { 19 | $claimIn = "in " . $hours . " hours, " . $minutes . " minutes and " . $seconds . " seconds"; 20 | } else { 21 | $claimIn = "in " . $minutes . " minutes and " . $seconds . " seconds"; 22 | } 23 | echo $claimIn; 24 | } else { 25 | echo "now"; 26 | } 27 | 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /classes/BaseModel.php: -------------------------------------------------------------------------------- 1 | tplEngine->display('404.tpl'); 6 | exit(); 7 | } 8 | 9 | public function getFinish() { 10 | $this->tplEngine->display('404.tpl'); 11 | exit(); 12 | } 13 | 14 | public function postVerify() { 15 | if(!$this->isAuthenticated()) { 16 | $this->tplEngine->display('404.tpl'); 17 | exit(); 18 | } 19 | return $this->tplEngine->display('verify.tpl'); 20 | } 21 | 22 | public function postFinish() { 23 | if(!$this->isAuthenticated()) { 24 | $this->tplEngine->display('404.tpl'); 25 | exit(); 26 | } 27 | $lastClaim = $this->getUser()->last_claim; 28 | $nextClaim = $lastClaim + (60 * $this->getConfig('timer')); 29 | $difference = $nextClaim - time(); 30 | if($difference > 0) { 31 | echo "You are not allowed to claim now."; 32 | exit(); 33 | } 34 | $captchaCheck = json_decode($this->checkCaptcha($_POST['g-recaptcha-response']))->success; 35 | if($captchaCheck){ 36 | // valid, pay out 37 | $payOut = rand($this->getConfig('min_reward'), $this->getConfig('max_reward')); 38 | if($this->getUser()->payOut($payOut)) { 39 | $this->tplEngine->assign('resultClaim', $this->alert("success", "Awesome! You've claimed successfully " . $payOut . " satoshi.
You can claim again in " . $this->getConfig('timer') . " minutes!")); 40 | if($this->getUser()->referred_by != 0) { 41 | $this->getUser()->payReferer($payOut, $this->getConfig('referral_percent')); 42 | } 43 | $this->getShare($payOut); 44 | $newUser = $this->getUser(); 45 | $newUser->balanceInSat = $newUser->balanceInSat; 46 | $this->tplEngine->assign('user', $newUser); 47 | } 48 | } else { 49 | // invalid. Person did not master the captcha. 50 | $this->tplEngine->assign('resultClaim', $this->alert("danger", "You failed the captcha. Please try again.")); 51 | } 52 | return $this->tplEngine->display('home.tpl'); 53 | } 54 | } -------------------------------------------------------------------------------- /classes/Config.php: -------------------------------------------------------------------------------- 1 | _pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/db'), Config::get('mysql/username'), Config::get('mysql/password')); 10 | $this->_pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); 11 | $this->_pdo->setAttribute( \PDO::ATTR_EMULATE_PREPARES, false ); 12 | 13 | } catch(PDOException $e) { 14 | echo "Database error: " . $e->getMessage(); 15 | exit(); 16 | } 17 | DB::$_instance = $this->_pdo; 18 | } 19 | 20 | public static function getInstance() { 21 | if (!isset(self::$_instance)) { 22 | new DB(); 23 | } 24 | return self::$_instance; 25 | } 26 | } -------------------------------------------------------------------------------- /classes/HomeController.php: -------------------------------------------------------------------------------- 1 | isAuthenticated()) { 6 | $this->tplEngine->display('home.tpl'); 7 | } else { 8 | $this->tplEngine->display('index.tpl'); 9 | } 10 | } 11 | 12 | public function getWithdraw() { 13 | if($this->isAuthenticated()) { 14 | if($this->getConfig('withdraw_min') < $this->getUser()->balanceInSat) { 15 | $result = $this->faucethub->send($this->getUser()->address, $this->getUser()->balanceInSat, $this->ip); 16 | if($result["success"] === true){ 17 | $payOut = $this->getUser()->balanceInSat / 100000000; 18 | $updateUser = $db->prepare("UPDATE faucet_user_list SET balance = 0, last_activity = :timestamp WHERE id = :id"); 19 | $updateUser->execute([':id' => $this->id, ':payout' => $payOut, ':timestamp' => $this->timestamp]); 20 | $transaction = $db->prepare("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES (:id, 'Withdrawal', :payout, :timestamp)"); 21 | $transaction->execute([':id' => $this->id, ':payout' => $payOut, ':timestamp' => $this->timestamp]); 22 | 23 | $this->tplEngine->assign('resultClaim', result["html"]); 24 | 25 | } else { 26 | $this->tplEngine->assign('resultClaim', $this->alert('danger', "Unfortunately, we were unable to withdraw your funds. Please try again later.")); 27 | } 28 | } else { 29 | $this->tplEngine->assign('resultClaim', $this->alert('danger', 'You don\'t have sufficient satoshis to withdraw. You need at least ' . $this->getConfig('withdraw_min') . ' satoshis.')); 30 | } 31 | $this->tplEngine->display('home.tpl'); 32 | } else { 33 | $this->tplEngine->display('index.tpl'); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /classes/User.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `faucet_user_list` WHERE id = :id"); 7 | $query->execute([':id' => $userId]); 8 | if($query->rowCount() == 1) { 9 | $user = $query->fetch(PDO::FETCH_ASSOC); 10 | foreach($user as $key => $value) { 11 | $this->$key = $value; 12 | } 13 | $this->balanceInSat = $this->toSatoshi($this->balance); 14 | return true; 15 | } 16 | return null; 17 | } 18 | 19 | public static function findByAddress($address) { 20 | $db = DB::getInstance(); 21 | $query = $db->prepare("SELECT * FROM `faucet_user_list` WHERE address = :address"); 22 | $query->execute([':address' => $address]); 23 | if($query->rowCount() == 1) { 24 | $user = $query->fetch(PDO::FETCH_ASSOC); 25 | return new User($user['id']); 26 | } 27 | return null; 28 | } 29 | 30 | public function getRefLink() { 31 | $siteUrl = $_SERVER["SERVER_NAME"]; 32 | return 'http://' . $siteUrl . '/index.php?ref=' . $this->address; 33 | } 34 | 35 | public function payReferer($amount, $feePercentage) { 36 | $referer = $this->referred_by; 37 | $refFee = $amount * ($feePercentage / 100); 38 | return $this->payOut($refFee, $referer, true); 39 | } 40 | 41 | public function payOut($amount, $uId = null, $ref = false) { 42 | if(is_null($uId)) { 43 | $uId = $this->id; 44 | } 45 | if($ref == false) { 46 | $type = 'Payout'; 47 | } else { 48 | $type = 'Referral'; 49 | } 50 | $timestamp = time(); 51 | $db = DB::getInstance(); 52 | $payOut = $amount / 100000000; 53 | $updateUser = $db->prepare("UPDATE faucet_user_list SET balance = balance + :payout, last_claim = :timestamp WHERE id = :id"); 54 | $updateUser->execute([':id' => $uId, ':payout' => $payOut, ':timestamp' => $timestamp]); 55 | $transaction = $db->prepare("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES (:id, :type, :payout, :timestamp)"); 56 | $transaction->execute([':id' => $uId, ':payout' => $payOut, ':timestamp' => $timestamp, ':type' => $type]); 57 | return true; 58 | } 59 | } -------------------------------------------------------------------------------- /includes/CSRF.php: -------------------------------------------------------------------------------- 1 | deleteExpiredTokens(); 19 | 20 | if (!isset($_SESSION['security']['csrf'])) { 21 | $_SESSION['security']['csrf'] = []; 22 | } 23 | } 24 | 25 | /* 26 | * Prints the json string with all the sessions. 27 | * @return void 28 | */ 29 | 30 | public function debug() { 31 | echo json_encode($_SESSION['security']['csrf'], JSON_PRETTY_PRINT); 32 | } 33 | 34 | /* 35 | * Sets the time in hours till the token expires. 36 | * @param string $time 37 | * @return boolean 38 | */ 39 | 40 | public function set_time($time) { 41 | if (is_int($time) && is_numeric($time)) { 42 | $this->_time = $time; 43 | 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | /* 50 | * Removes the session if it exists and returns true or false. 51 | * @return boolean 52 | */ 53 | 54 | public function delete($token) { 55 | $this->deleteExpiredTokens(); 56 | 57 | if ($this->get($token)) { 58 | unset($_SESSION['security']['csrf'][$token]); 59 | return true; 60 | } 61 | 62 | return false; 63 | } 64 | 65 | /* 66 | * Walks through all the sessions to check if they are expired. 67 | * @return void 68 | */ 69 | 70 | public function deleteExpiredTokens() { 71 | if(isset($_SESSION['security']['csrf']) && isset($_SESSION['security'])) { 72 | foreach ($_SESSION['security']['csrf'] AS $token => $time) { 73 | if (time() >= $time) { 74 | unset($_SESSION['security']['csrf'][$token]); 75 | } 76 | } 77 | } 78 | } 79 | 80 | /* 81 | * Creates the session token. 82 | * @return string 83 | */ 84 | 85 | public function set($time = true, $multiplier = 3600) { 86 | 87 | if (function_exists('openssl_random_pseudo_bytes')) { 88 | $key = substr(bin2hex(openssl_random_pseudo_bytes(128)), 0, 128); 89 | } else { 90 | $key = sha1(mt_rand() . rand()); 91 | } 92 | $value = (time() + (($time ? $this->_time : $time) * $multiplier)); 93 | 94 | $_SESSION['security']['csrf'][$key] = $value; 95 | return $key; 96 | } 97 | 98 | /* 99 | * Checks if a session exists and returns true or false. 100 | * @return boolean 101 | */ 102 | 103 | public function get($token) { 104 | $this->deleteExpiredTokens(); 105 | return isset($_SESSION['security']['csrf'][$token]); 106 | } 107 | 108 | /* 109 | * returns the last key in the session array. 110 | * @return string 111 | */ 112 | 113 | public function last() { 114 | return end($_SESSION['security']['csrf']); 115 | } 116 | 117 | } -------------------------------------------------------------------------------- /includes/config.php: -------------------------------------------------------------------------------- 1 | array ( 5 | 'host' => 'localhost', 6 | 'db' => 'faucetscript', 7 | 'username' => 'root', 8 | 'password' => '' 9 | ) 10 | ); -------------------------------------------------------------------------------- /includes/core.php: -------------------------------------------------------------------------------- 1 | force_compile = true; 25 | $smarty->debugging = false; 26 | $smarty->caching = false; 27 | $smarty->cache_lifetime = 0; -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | set(3, 3600); 12 | 13 | $routeParts = explode('/', $route); 14 | $controller = ucfirst($routeParts[0]) . 'Controller'; 15 | $method = ucfirst($routeParts[1]); 16 | 17 | if(count($routeParts) == 1) { 18 | header("Location: index.php?route=" . $routeParts[0] . '/home'); 19 | exit(); 20 | } 21 | 22 | $reqMethod = 'get'; 23 | if($_SERVER['REQUEST_METHOD'] == 'POST') { 24 | if(isset($_POST['token'])) { 25 | if($security->get($token)) { 26 | $security->delete($token); 27 | $reqMethod = 'post'; 28 | } 29 | } 30 | } 31 | 32 | $smarty->assign('csrf_field', ''); 33 | 34 | $method = $reqMethod . $method; 35 | if(class_exists($controller)) { 36 | $controller = new $controller($smarty, $security, $db, $controller . '.' . $method); 37 | if(method_exists($controller, $method)) { 38 | print $controller->$method(); 39 | } else { 40 | echo 404; 41 | } 42 | } else { 43 | echo 404; 44 | } -------------------------------------------------------------------------------- /libs/plugins/function.counter.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: counter
13 | * Purpose: print out a counter value 14 | * 15 | * @author Monte Ohrt 16 | * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} 17 | * (Smarty online manual) 18 | * 19 | * @param array $params parameters 20 | * @param Smarty_Internal_Template $template template object 21 | * 22 | * @return string|null 23 | */ 24 | function smarty_function_counter($params, $template) 25 | { 26 | static $counters = array(); 27 | 28 | $name = (isset($params['name'])) ? $params['name'] : 'default'; 29 | if (!isset($counters[$name])) { 30 | $counters[$name] = array( 31 | 'start' => 1, 32 | 'skip' => 1, 33 | 'direction' => 'up', 34 | 'count' => 1 35 | ); 36 | } 37 | $counter =& $counters[$name]; 38 | 39 | if (isset($params['start'])) { 40 | $counter['start'] = $counter['count'] = (int) $params['start']; 41 | } 42 | 43 | if (!empty($params['assign'])) { 44 | $counter['assign'] = $params['assign']; 45 | } 46 | 47 | if (isset($counter['assign'])) { 48 | $template->assign($counter['assign'], $counter['count']); 49 | } 50 | 51 | if (isset($params['print'])) { 52 | $print = (bool) $params['print']; 53 | } else { 54 | $print = empty($counter['assign']); 55 | } 56 | 57 | if ($print) { 58 | $retval = $counter['count']; 59 | } else { 60 | $retval = null; 61 | } 62 | 63 | if (isset($params['skip'])) { 64 | $counter['skip'] = $params['skip']; 65 | } 66 | 67 | if (isset($params['direction'])) { 68 | $counter['direction'] = $params['direction']; 69 | } 70 | 71 | if ($counter['direction'] == "down") { 72 | $counter['count'] -= $counter['skip']; 73 | } else { 74 | $counter['count'] += $counter['skip']; 75 | } 76 | 77 | return $retval; 78 | } 79 | -------------------------------------------------------------------------------- /libs/plugins/function.math.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: math
14 | * Purpose: handle math computations in template 15 | * 16 | * @link http://www.smarty.net/manual/en/language.function.math.php {math} 17 | * (Smarty online manual) 18 | * @author Monte Ohrt 19 | * 20 | * @param array $params parameters 21 | * @param Smarty_Internal_Template $template template object 22 | * 23 | * @return string|null 24 | */ 25 | function smarty_function_math($params, $template) 26 | { 27 | static $_allowed_funcs = array( 28 | 'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true, 29 | 'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true, 30 | 'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true 31 | ); 32 | // be sure equation parameter is present 33 | if (empty($params['equation'])) { 34 | trigger_error("math: missing equation parameter", E_USER_WARNING); 35 | 36 | return; 37 | } 38 | 39 | $equation = $params['equation']; 40 | 41 | // make sure parenthesis are balanced 42 | if (substr_count($equation, "(") != substr_count($equation, ")")) { 43 | trigger_error("math: unbalanced parenthesis", E_USER_WARNING); 44 | 45 | return; 46 | } 47 | 48 | // match all vars in equation, make sure all are passed 49 | preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match); 50 | 51 | foreach ($match[1] as $curr_var) { 52 | if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) { 53 | trigger_error("math: function call $curr_var not allowed", E_USER_WARNING); 54 | 55 | return; 56 | } 57 | } 58 | 59 | foreach ($params as $key => $val) { 60 | if ($key != "equation" && $key != "format" && $key != "assign") { 61 | // make sure value is not empty 62 | if (strlen($val) == 0) { 63 | trigger_error("math: parameter $key is empty", E_USER_WARNING); 64 | 65 | return; 66 | } 67 | if (!is_numeric($val)) { 68 | trigger_error("math: parameter $key: is not numeric", E_USER_WARNING); 69 | 70 | return; 71 | } 72 | $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); 73 | } 74 | } 75 | $smarty_math_result = null; 76 | eval("\$smarty_math_result = " . $equation . ";"); 77 | 78 | if (empty($params['format'])) { 79 | if (empty($params['assign'])) { 80 | return $smarty_math_result; 81 | } else { 82 | $template->assign($params['assign'], $smarty_math_result); 83 | } 84 | } else { 85 | if (empty($params['assign'])) { 86 | printf($params['format'], $smarty_math_result); 87 | } else { 88 | $template->assign($params['assign'], sprintf($params['format'], $smarty_math_result)); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /libs/plugins/modifier.date_format.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: date_format
13 | * Purpose: format datestamps via strftime
14 | * Input:
15 | * - string: input date string 16 | * - format: strftime format for output 17 | * - default_date: default date if $string is empty 18 | * 19 | * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) 20 | * @author Monte Ohrt 21 | * 22 | * @param string $string input date string 23 | * @param string $format strftime format for output 24 | * @param string $default_date default date if $string is empty 25 | * @param string $formatter either 'strftime' or 'auto' 26 | * 27 | * @return string |void 28 | * @uses smarty_make_timestamp() 29 | */ 30 | function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto') 31 | { 32 | if ($format === null) { 33 | $format = Smarty::$_DATE_FORMAT; 34 | } 35 | /** 36 | * require_once the {@link shared.make_timestamp.php} plugin 37 | */ 38 | require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); 39 | if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { 40 | $timestamp = smarty_make_timestamp($string); 41 | } elseif ($default_date != '') { 42 | $timestamp = smarty_make_timestamp($default_date); 43 | } else { 44 | return; 45 | } 46 | if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { 47 | if (DS == '\\') { 48 | $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); 49 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); 50 | if (strpos($format, '%e') !== false) { 51 | $_win_from[] = '%e'; 52 | $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); 53 | } 54 | if (strpos($format, '%l') !== false) { 55 | $_win_from[] = '%l'; 56 | $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); 57 | } 58 | $format = str_replace($_win_from, $_win_to, $format); 59 | } 60 | 61 | return strftime($format, $timestamp); 62 | } else { 63 | return date($format, $timestamp); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /libs/plugins/modifier.regex_replace.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: regex_replace
13 | * Purpose: regular expression search/replace 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php 16 | * regex_replace (Smarty online manual) 17 | * @author Monte Ohrt 18 | * 19 | * @param string $string input string 20 | * @param string|array $search regular expression(s) to search for 21 | * @param string|array $replace string(s) that should be replaced 22 | * @param int $limit the maximum number of replacements 23 | * 24 | * @return string 25 | */ 26 | function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1) 27 | { 28 | if (is_array($search)) { 29 | foreach ($search as $idx => $s) { 30 | $search[$idx] = _smarty_regex_replace_check($s); 31 | } 32 | } else { 33 | $search = _smarty_regex_replace_check($search); 34 | } 35 | 36 | return preg_replace($search, $replace, $string, $limit); 37 | } 38 | 39 | /** 40 | * @param string $search string(s) that should be replaced 41 | * 42 | * @return string 43 | * @ignore 44 | */ 45 | function _smarty_regex_replace_check($search) 46 | { 47 | // null-byte injection detection 48 | // anything behind the first null-byte is ignored 49 | if (($pos = strpos($search, "\0")) !== false) { 50 | $search = substr($search, 0, $pos); 51 | } 52 | // remove eval-modifier from $search 53 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { 54 | $search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); 55 | } 56 | 57 | return $search; 58 | } 59 | -------------------------------------------------------------------------------- /libs/plugins/modifier.replace.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: replace
13 | * Purpose: simple search/replace 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) 16 | * @author Monte Ohrt 17 | * @author Uwe Tews 18 | * 19 | * @param string $string input string 20 | * @param string $search text to search for 21 | * @param string $replace replacement text 22 | * 23 | * @return string 24 | */ 25 | function smarty_modifier_replace($string, $search, $replace) 26 | { 27 | if (Smarty::$_MBSTRING) { 28 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); 29 | 30 | return smarty_mb_str_replace($search, $replace, $string); 31 | } 32 | 33 | return str_replace($search, $replace, $string); 34 | } 35 | -------------------------------------------------------------------------------- /libs/plugins/modifier.spacify.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: spacify
13 | * Purpose: add spaces between characters in a string 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) 16 | * @author Monte Ohrt 17 | * 18 | * @param string $string input string 19 | * @param string $spacify_char string to insert between characters. 20 | * 21 | * @return string 22 | */ 23 | function smarty_modifier_spacify($string, $spacify_char = ' ') 24 | { 25 | // well… what about charsets besides latin and UTF-8? 26 | return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY)); 27 | } 28 | -------------------------------------------------------------------------------- /libs/plugins/modifier.truncate.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: truncate
13 | * Purpose: Truncate a string to a certain length if necessary, 14 | * optionally splitting in the middle of a word, and 15 | * appending the $etc string or inserting $etc into the middle. 16 | * 17 | * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) 18 | * @author Monte Ohrt 19 | * 20 | * @param string $string input string 21 | * @param integer $length length of truncated text 22 | * @param string $etc end string 23 | * @param boolean $break_words truncate at word boundary 24 | * @param boolean $middle truncate in the middle of text 25 | * 26 | * @return string truncated string 27 | */ 28 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) 29 | { 30 | if ($length == 0) { 31 | return ''; 32 | } 33 | 34 | if (Smarty::$_MBSTRING) { 35 | if (mb_strlen($string, Smarty::$_CHARSET) > $length) { 36 | $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); 37 | if (!$break_words && !$middle) { 38 | $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)); 39 | } 40 | if (!$middle) { 41 | return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; 42 | } 43 | 44 | return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); 45 | } 46 | 47 | return $string; 48 | } 49 | 50 | // no MBString fallback 51 | if (isset($string[$length])) { 52 | $length -= min($length, strlen($etc)); 53 | if (!$break_words && !$middle) { 54 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); 55 | } 56 | if (!$middle) { 57 | return substr($string, 0, $length) . $etc; 58 | } 59 | 60 | return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); 61 | } 62 | 63 | return $string; 64 | } 65 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.cat.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: cat
13 | * Date: Feb 24, 2003
14 | * Purpose: catenate a value to a variable
15 | * Input: string to catenate
16 | * Example: {$var|cat:"foo"} 17 | * 18 | * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat 19 | * (Smarty online manual) 20 | * @author Uwe Tews 21 | * 22 | * @param array $params parameters 23 | * 24 | * @return string with compiled code 25 | */ 26 | function smarty_modifiercompiler_cat($params) 27 | { 28 | return '(' . implode(').(', $params) . ')'; 29 | } 30 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.count_characters.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: count_characteres
13 | * Purpose: count the number of characters in a text 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_count_characters($params) 23 | { 24 | if (!isset($params[1]) || $params[1] != 'true') { 25 | return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)'; 26 | } 27 | if (Smarty::$_MBSTRING) { 28 | return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; 29 | } 30 | // no MBString fallback 31 | return 'strlen(' . $params[0] . ')'; 32 | } 33 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.count_paragraphs.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: count_paragraphs
13 | * Purpose: count the number of paragraphs in a text 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php 16 | * count_paragraphs (Smarty online manual) 17 | * @author Uwe Tews 18 | * 19 | * @param array $params parameters 20 | * 21 | * @return string with compiled code 22 | */ 23 | function smarty_modifiercompiler_count_paragraphs($params) 24 | { 25 | // count \r or \n characters 26 | return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)'; 27 | } 28 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.count_sentences.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: count_sentences 13 | * Purpose: count the number of sentences in a text 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php 16 | * count_sentences (Smarty online manual) 17 | * @author Uwe Tews 18 | * 19 | * @param array $params parameters 20 | * 21 | * @return string with compiled code 22 | */ 23 | function smarty_modifiercompiler_count_sentences($params) 24 | { 25 | // find periods, question marks, exclamation marks with a word before but not after. 26 | return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)'; 27 | } 28 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.count_words.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: count_words
13 | * Purpose: count the number of words in a text 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_count_words($params) 23 | { 24 | if (Smarty::$_MBSTRING) { 25 | // return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)'; 26 | // expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592 27 | return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)'; 28 | } 29 | // no MBString fallback 30 | return 'str_word_count(' . $params[0] . ')'; 31 | } 32 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.default.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: default
13 | * Purpose: designate default value for empty variables 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_default($params) 23 | { 24 | $output = $params[0]; 25 | if (!isset($params[1])) { 26 | $params[1] = "''"; 27 | } 28 | 29 | array_shift($params); 30 | foreach ($params as $param) { 31 | $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; 32 | } 33 | 34 | return $output; 35 | } 36 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.from_charset.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: from_charset
13 | * Purpose: convert character encoding from $charset to internal encoding 14 | * 15 | * @author Rodney Rehm 16 | * 17 | * @param array $params parameters 18 | * 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_from_charset($params) 22 | { 23 | if (!Smarty::$_MBSTRING) { 24 | // FIXME: (rodneyrehm) shouldn't this throw an error? 25 | return $params[0]; 26 | } 27 | 28 | if (!isset($params[1])) { 29 | $params[1] = '"ISO-8859-1"'; 30 | } 31 | 32 | return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')'; 33 | } 34 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.indent.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: indent
13 | * Purpose: indent lines of text 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | 23 | function smarty_modifiercompiler_indent($params) 24 | { 25 | if (!isset($params[1])) { 26 | $params[1] = 4; 27 | } 28 | if (!isset($params[2])) { 29 | $params[2] = "' '"; 30 | } 31 | 32 | return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')'; 33 | } 34 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.lower.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: lower
13 | * Purpose: convert string to lowercase 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual) 16 | * @author Monte Ohrt 17 | * @author Uwe Tews 18 | * 19 | * @param array $params parameters 20 | * 21 | * @return string with compiled code 22 | */ 23 | 24 | function smarty_modifiercompiler_lower($params) 25 | { 26 | if (Smarty::$_MBSTRING) { 27 | return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; 28 | } 29 | // no MBString fallback 30 | return 'strtolower(' . $params[0] . ')'; 31 | } 32 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.noprint.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: noprint
13 | * Purpose: return an empty string 14 | * 15 | * @author Uwe Tews 16 | * @return string with compiled code 17 | */ 18 | function smarty_modifiercompiler_noprint() 19 | { 20 | return "''"; 21 | } 22 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.string_format.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: string_format
13 | * Purpose: format strings via sprintf 14 | * 15 | * @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_string_format($params) 23 | { 24 | return 'sprintf(' . $params[1] . ',' . $params[0] . ')'; 25 | } 26 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.strip.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: strip
13 | * Purpose: Replace all repeated spaces, newlines, tabs 14 | * with a single space or supplied replacement string.
15 | * Example: {$var|strip} {$var|strip:" "}
16 | * Date: September 25th, 2002 17 | * 18 | * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual) 19 | * @author Uwe Tews 20 | * 21 | * @param array $params parameters 22 | * 23 | * @return string with compiled code 24 | */ 25 | 26 | function smarty_modifiercompiler_strip($params) 27 | { 28 | if (!isset($params[1])) { 29 | $params[1] = "' '"; 30 | } 31 | 32 | return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; 33 | } 34 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.strip_tags.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: strip_tags
13 | * Purpose: strip html tags from text 14 | * 15 | * @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_strip_tags($params) 23 | { 24 | if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') { 25 | return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; 26 | } else { 27 | return 'strip_tags(' . $params[0] . ')'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.to_charset.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: to_charset
13 | * Purpose: convert character encoding from internal encoding to $charset 14 | * 15 | * @author Rodney Rehm 16 | * 17 | * @param array $params parameters 18 | * 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_to_charset($params) 22 | { 23 | if (!Smarty::$_MBSTRING) { 24 | // FIXME: (rodneyrehm) shouldn't this throw an error? 25 | return $params[0]; 26 | } 27 | 28 | if (!isset($params[1])) { 29 | $params[1] = '"ISO-8859-1"'; 30 | } 31 | 32 | return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; 33 | } 34 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.unescape.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: unescape
13 | * Purpose: unescape html entities 14 | * 15 | * @author Rodney Rehm 16 | * 17 | * @param array $params parameters 18 | * 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_unescape($params) 22 | { 23 | if (!isset($params[1])) { 24 | $params[1] = 'html'; 25 | } 26 | if (!isset($params[2])) { 27 | $params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; 28 | } else { 29 | $params[2] = "'" . $params[2] . "'"; 30 | } 31 | 32 | switch (trim($params[1], '"\'')) { 33 | case 'entity': 34 | case 'htmlall': 35 | if (Smarty::$_MBSTRING) { 36 | return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')'; 37 | } 38 | 39 | return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')'; 40 | 41 | case 'html': 42 | return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)'; 43 | 44 | case 'url': 45 | return 'rawurldecode(' . $params[0] . ')'; 46 | 47 | default: 48 | return $params[0]; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.upper.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: lower
13 | * Purpose: convert string to uppercase 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_upper($params) 23 | { 24 | if (Smarty::$_MBSTRING) { 25 | return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; 26 | } 27 | // no MBString fallback 28 | return 'strtoupper(' . $params[0] . ')'; 29 | } 30 | -------------------------------------------------------------------------------- /libs/plugins/modifiercompiler.wordwrap.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: wordwrap
13 | * Purpose: wrap a string of text at a given length 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * @param $compiler 20 | * 21 | * @return string with compiled code 22 | */ 23 | function smarty_modifiercompiler_wordwrap($params, $compiler) 24 | { 25 | if (!isset($params[1])) { 26 | $params[1] = 80; 27 | } 28 | if (!isset($params[2])) { 29 | $params[2] = '"\n"'; 30 | } 31 | if (!isset($params[3])) { 32 | $params[3] = 'false'; 33 | } 34 | $function = 'wordwrap'; 35 | if (Smarty::$_MBSTRING) { 36 | if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { 37 | $compiler->parent_compiler->template->compiled->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; 38 | $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; 39 | } else { 40 | $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; 41 | $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; 42 | } 43 | $function = 'smarty_mb_wordwrap'; 44 | } 45 | 46 | return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')'; 47 | } 48 | -------------------------------------------------------------------------------- /libs/plugins/shared.escape_special_chars.php: -------------------------------------------------------------------------------- 1 | =')) { 10 | /** 11 | * escape_special_chars common function 12 | * Function: smarty_function_escape_special_chars
13 | * Purpose: used by other smarty functions to escape 14 | * special chars except for already escaped ones 15 | * 16 | * @author Monte Ohrt 17 | * 18 | * @param string $string text that should by escaped 19 | * 20 | * @return string 21 | */ 22 | function smarty_function_escape_special_chars($string) 23 | { 24 | if (!is_array($string)) { 25 | $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); 26 | } 27 | 28 | return $string; 29 | } 30 | } else { 31 | /** 32 | * escape_special_chars common function 33 | * Function: smarty_function_escape_special_chars
34 | * Purpose: used by other smarty functions to escape 35 | * special chars except for already escaped ones 36 | * 37 | * @author Monte Ohrt 38 | * 39 | * @param string $string text that should by escaped 40 | * 41 | * @return string 42 | */ 43 | function smarty_function_escape_special_chars($string) 44 | { 45 | if (!is_array($string)) { 46 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); 47 | $string = htmlspecialchars($string); 48 | $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); 49 | } 50 | 51 | return $string; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /libs/plugins/shared.literal_compiler_param.php: -------------------------------------------------------------------------------- 1 | 11 | * Purpose: used by other smarty functions to make a timestamp from a string. 12 | * 13 | * @author Monte Ohrt 14 | * 15 | * @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime() 16 | * 17 | * @return int 18 | */ 19 | function smarty_make_timestamp($string) 20 | { 21 | if (empty($string)) { 22 | // use "now": 23 | return time(); 24 | } elseif ($string instanceof DateTime || (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)) { 25 | return (int) $string->format('U'); // PHP 5.2 BC 26 | } elseif (strlen($string) == 14 && ctype_digit($string)) { 27 | // it is mysql timestamp format of YYYYMMDDHHMMSS? 28 | return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), 29 | substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4)); 30 | } elseif (is_numeric($string)) { 31 | // it is a numeric string, we handle it as timestamp 32 | return (int) $string; 33 | } else { 34 | // strtotime should handle it 35 | $time = strtotime($string); 36 | if ($time == - 1 || $time === false) { 37 | // strtotime() was not able to parse $string, use "now": 38 | return time(); 39 | } 40 | 41 | return $time; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libs/plugins/shared.mb_str_replace.php: -------------------------------------------------------------------------------- 1 | $width) { 37 | if ($cut) { 38 | $_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); 39 | } 40 | } 41 | 42 | foreach ($_tokens as $token) { 43 | $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); 44 | $token_length = mb_strlen($token, Smarty::$_CHARSET); 45 | $length += $token_length; 46 | 47 | if ($length > $width) { 48 | // remove space before inserted break 49 | if ($_previous) { 50 | $t = mb_substr($t, 0, - 1, Smarty::$_CHARSET); 51 | } 52 | 53 | if (!$_space) { 54 | // add the break before the token 55 | if (!empty($t)) { 56 | $t .= $break; 57 | } 58 | $length = $token_length; 59 | } 60 | } elseif ($token == "\n") { 61 | // hard break must reset counters 62 | $_previous = 0; 63 | $length = 0; 64 | } 65 | $_previous = $_space; 66 | // add the token 67 | $t .= $token; 68 | } 69 | } 70 | 71 | return $t; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /libs/plugins/variablefilter.htmlspecialchars.php: -------------------------------------------------------------------------------- 1 | dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); 55 | $this->smarty = $smarty; 56 | if (is_object($_parent)) { 57 | // when object set up back pointer 58 | $this->parent = $_parent; 59 | } elseif (is_array($_parent)) { 60 | // set up variable values 61 | foreach ($_parent as $_key => $_val) { 62 | $this->tpl_vars[$_key] = new Smarty_Variable($_val); 63 | } 64 | } elseif ($_parent != null) { 65 | throw new SmartyException("Wrong type for template variables"); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_append.php: -------------------------------------------------------------------------------- 1 | required_attributes = array('var', 'value'); 32 | $this->shorttag_order = array('var', 'value'); 33 | $this->optional_attributes = array('scope', 'index'); 34 | // check and get attributes 35 | $_attr = $this->getAttributes($compiler, $args); 36 | // map to compile assign attributes 37 | if (isset($_attr['index'])) { 38 | $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']'; 39 | unset($_attr['index']); 40 | } else { 41 | $_params['smarty_internal_index'] = '[]'; 42 | } 43 | $_new_attr = array(); 44 | foreach ($_attr as $key => $value) { 45 | $_new_attr[] = array($key => $value); 46 | } 47 | // call compile assign 48 | return parent::compile($_new_attr, $compiler, $_params); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_break.php: -------------------------------------------------------------------------------- 1 | true, 'foreach' => true, 'while' => true, 'section' => true); 48 | // check and get attributes 49 | $_attr = $this->getAttributes($compiler, $args); 50 | 51 | if ($_attr['nocache'] === true) { 52 | $compiler->trigger_template_error('nocache option not allowed', null, true); 53 | } 54 | 55 | if (isset($_attr['levels'])) { 56 | if (!is_numeric($_attr['levels'])) { 57 | $compiler->trigger_template_error('level attribute must be a numeric constant', null, true); 58 | } 59 | $_levels = $_attr['levels']; 60 | } else { 61 | $_levels = 1; 62 | } 63 | $level_count = $_levels; 64 | $stack_count = count($compiler->_tag_stack) - 1; 65 | while ($level_count > 0 && $stack_count >= 0) { 66 | if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) { 67 | $level_count --; 68 | } 69 | $stack_count --; 70 | } 71 | if ($level_count != 0) { 72 | $compiler->trigger_template_error("cannot break {$_levels} level(s)", null, true); 73 | } 74 | 75 | return ""; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_call.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 55 | // save possible attributes 56 | if (isset($_attr['assign'])) { 57 | // output will be stored in a smarty variable instead of being displayed 58 | $_assign = $_attr['assign']; 59 | } 60 | //$_name = trim($_attr['name'], "'\""); 61 | $_name = $_attr['name']; 62 | unset($_attr['name'], $_attr['assign'], $_attr['nocache']); 63 | // set flag (compiled code of {function} must be included in cache file 64 | if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) { 65 | $_nocache = 'true'; 66 | } else { 67 | $_nocache = 'false'; 68 | } 69 | $_paramsArray = array(); 70 | foreach ($_attr as $_key => $_value) { 71 | if (is_int($_key)) { 72 | $_paramsArray[] = "$_key=>$_value"; 73 | } else { 74 | $_paramsArray[] = "'$_key'=>$_value"; 75 | } 76 | } 77 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 78 | //$compiler->suppressNocacheProcessing = true; 79 | // was there an assign attribute 80 | if (isset($_assign)) { 81 | $_output = 82 | "smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; 83 | } else { 84 | $_output = 85 | "smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n"; 86 | } 87 | return $_output; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_continue.php: -------------------------------------------------------------------------------- 1 | true, 'foreach' => true, 'while' => true, 'section' => true); 48 | // check and get attributes 49 | $_attr = $this->getAttributes($compiler, $args); 50 | 51 | if ($_attr['nocache'] === true) { 52 | $compiler->trigger_template_error('nocache option not allowed', null, true); 53 | } 54 | 55 | if (isset($_attr['levels'])) { 56 | if (!is_numeric($_attr['levels'])) { 57 | $compiler->trigger_template_error('level attribute must be a numeric constant', null, true); 58 | } 59 | $_levels = $_attr['levels']; 60 | } else { 61 | $_levels = 1; 62 | } 63 | $level_count = $_levels; 64 | $stack_count = count($compiler->_tag_stack) - 1; 65 | while ($level_count > 0 && $stack_count >= 0) { 66 | if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) { 67 | $level_count --; 68 | } 69 | $stack_count --; 70 | } 71 | if ($level_count != 0) { 72 | $compiler->trigger_template_error("cannot continue {$_levels} level(s)", null, true); 73 | } 74 | 75 | return ""; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_debug.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 32 | 33 | // compile always as nocache 34 | $compiler->tag_nocache = true; 35 | 36 | // display debug template 37 | $_output = "display_debug(\$_smarty_tpl);\n"; 38 | $_output .= "unset(\$_smarty_debug);\n?>"; 39 | return $_output; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_eval.php: -------------------------------------------------------------------------------- 1 | required_attributes = array('var'); 52 | $this->optional_attributes = array('assign'); 53 | // check and get attributes 54 | $_attr = $this->getAttributes($compiler, $args); 55 | if (isset($_attr['assign'])) { 56 | // output will be stored in a smarty variable instead of being displayed 57 | $_assign = $_attr['assign']; 58 | } 59 | 60 | // create template object 61 | $_output = "\$_template = new {$compiler->smarty->template_class}('eval:'." . $_attr['var'] . ", \$_smarty_tpl->smarty, \$_smarty_tpl);"; 62 | //was there an assign attribute? 63 | if (isset($_assign)) { 64 | $_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());"; 65 | } else { 66 | $_output .= "echo \$_template->fetch();"; 67 | } 68 | 69 | return ""; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_ldelim.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 32 | if ($_attr['nocache'] === true) { 33 | $compiler->trigger_template_error('nocache option not allowed', null, true); 34 | } 35 | // this tag does not return compiled code 36 | $compiler->has_code = true; 37 | 38 | return $compiler->smarty->left_delimiter; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_nocache.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 38 | $this->openTag($compiler, 'nocache', array($compiler->nocache)); 39 | // enter nocache mode 40 | $compiler->nocache = true; 41 | // this tag does not return compiled code 42 | $compiler->has_code = false; 43 | 44 | return true; 45 | } 46 | } 47 | 48 | /** 49 | * Smarty Internal Plugin Compile Nocacheclose Class 50 | * 51 | * @package Smarty 52 | * @subpackage Compiler 53 | */ 54 | class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase 55 | { 56 | /** 57 | * Compiles code for the {/nocache} tag 58 | * This tag does not generate compiled output. It only sets a compiler flag. 59 | * 60 | * @param array $args array with attributes from parser 61 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object 62 | * 63 | * @return bool 64 | */ 65 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) 66 | { 67 | $_attr = $this->getAttributes($compiler, $args); 68 | // leave nocache mode 69 | list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); 70 | // this tag does not return compiled code 71 | $compiler->has_code = false; 72 | 73 | return true; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_private_function_plugin.php: -------------------------------------------------------------------------------- 1 | has_output = true; 50 | 51 | // check and get attributes 52 | $_attr = $this->getAttributes($compiler, $args); 53 | if ($_attr['nocache'] === true) { 54 | $compiler->tag_nocache = true; 55 | } 56 | unset($_attr['nocache']); 57 | // convert attributes into parameter array string 58 | $_paramsArray = array(); 59 | foreach ($_attr as $_key => $_value) { 60 | if (is_int($_key)) { 61 | $_paramsArray[] = "$_key=>$_value"; 62 | } else { 63 | $_paramsArray[] = "'$_key'=>$_value"; 64 | } 65 | } 66 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 67 | // compile code 68 | $output = "\n"; 69 | 70 | return $output; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_private_object_function.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 42 | if ($_attr['nocache'] === true) { 43 | $compiler->tag_nocache = true; 44 | } 45 | unset($_attr['nocache']); 46 | $_assign = null; 47 | if (isset($_attr['assign'])) { 48 | $_assign = $_attr['assign']; 49 | unset($_attr['assign']); 50 | } 51 | // method or property ? 52 | if (method_exists($compiler->smarty->registered_objects[$tag][0], $method)) { 53 | // convert attributes into parameter array string 54 | if ($compiler->smarty->registered_objects[$tag][2]) { 55 | $_paramsArray = array(); 56 | foreach ($_attr as $_key => $_value) { 57 | if (is_int($_key)) { 58 | $_paramsArray[] = "$_key=>$_value"; 59 | } else { 60 | $_paramsArray[] = "'$_key'=>$_value"; 61 | } 62 | } 63 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 64 | $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params},\$_smarty_tpl)"; 65 | } else { 66 | $_params = implode(",", $_attr); 67 | $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params})"; 68 | } 69 | } else { 70 | // object property 71 | $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}"; 72 | } 73 | 74 | if (empty($_assign)) { 75 | // This tag does create output 76 | $compiler->has_output = true; 77 | $output = "\n"; 78 | } else { 79 | $output = "assign({$_assign},{$return});?>\n"; 80 | } 81 | 82 | return $output; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_private_registered_function.php: -------------------------------------------------------------------------------- 1 | has_output = true; 41 | // check and get attributes 42 | $_attr = $this->getAttributes($compiler, $args); 43 | if ($_attr['nocache']) { 44 | $compiler->tag_nocache = true; 45 | } 46 | unset($_attr['nocache']); 47 | if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) { 48 | $tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag]; 49 | } else { 50 | $tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_FUNCTION][$tag]; 51 | } 52 | // not cachable? 53 | $compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[1]; 54 | // convert attributes into parameter array string 55 | $_paramsArray = array(); 56 | foreach ($_attr as $_key => $_value) { 57 | if (is_int($_key)) { 58 | $_paramsArray[] = "$_key=>$_value"; 59 | } elseif ($compiler->template->caching && in_array($_key, $tag_info[2])) { 60 | $_value = str_replace("'", "^#^", $_value); 61 | $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; 62 | } else { 63 | $_paramsArray[] = "'$_key'=>$_value"; 64 | } 65 | } 66 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 67 | $function = $tag_info[0]; 68 | // compile code 69 | if (!is_array($function)) { 70 | $output = "\n"; 71 | } elseif (is_object($function[0])) { 72 | $output = "smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n"; 73 | } else { 74 | $output = "\n"; 75 | } 76 | 77 | return $output; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_rdelim.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 31 | if ($_attr['nocache'] === true) { 32 | $compiler->trigger_template_error('nocache option not allowed', null, true); 33 | } 34 | // this tag does not return compiled code 35 | $compiler->has_code = true; 36 | 37 | return $compiler->smarty->right_delimiter; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_setfilter.php: -------------------------------------------------------------------------------- 1 | variable_filter_stack[] = $compiler->variable_filters; 31 | $compiler->variable_filters = $parameter['modifier_list']; 32 | // this tag does not return compiled code 33 | $compiler->has_code = false; 34 | 35 | return true; 36 | } 37 | } 38 | 39 | /** 40 | * Smarty Internal Plugin Compile Setfilterclose Class 41 | * 42 | * @package Smarty 43 | * @subpackage Compiler 44 | */ 45 | class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase 46 | { 47 | /** 48 | * Compiles code for the {/setfilter} tag 49 | * This tag does not generate compiled output. It resets variable filter. 50 | * 51 | * @param array $args array with attributes from parser 52 | * @param object $compiler compiler object 53 | * 54 | * @return string compiled code 55 | */ 56 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) 57 | { 58 | $_attr = $this->getAttributes($compiler, $args); 59 | // reset variable filter to previous state 60 | if (count($compiler->variable_filter_stack)) { 61 | $compiler->variable_filters = array_pop($compiler->variable_filter_stack); 62 | } else { 63 | $compiler->variable_filters = array(); 64 | } 65 | // this tag does not return compiled code 66 | $compiler->has_code = false; 67 | 68 | return true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_compile_shared_inheritance.php: -------------------------------------------------------------------------------- 1 | _cache['inheritanceInit'])) { 28 | $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), 29 | array($initChildSequence), 'inheritanceInit', $initChildSequence); 30 | 31 | $compiler->_cache['inheritanceInit'] = true; 32 | } 33 | } 34 | 35 | /** 36 | * Compile inheritance initialization code as prefix 37 | * 38 | * @param \Smarty_Internal_TemplateCompilerBase $compiler 39 | * @param bool|false $initChildSequence if true force child template 40 | */ 41 | static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) 42 | { 43 | $compiler->prefixCompiledCode .= "ext->_inheritance->init(\$_smarty_tpl, " . 44 | var_export($initChildSequence, true) . ");\n?>\n"; 45 | } 46 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_addautoloadfilters.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 32 | if ($type !== null) { 33 | $this->_checkFilterType($type); 34 | if (!empty($smarty->autoload_filters[$type])) { 35 | $smarty->autoload_filters[$type] = array_merge($smarty->autoload_filters[$type], (array) $filters); 36 | } else { 37 | $smarty->autoload_filters[$type] = (array) $filters; 38 | } 39 | } else { 40 | foreach ((array) $filters as $type => $value) { 41 | $this->_checkFilterType($type); 42 | if (!empty($smarty->autoload_filters[$type])) { 43 | $smarty->autoload_filters[$type] = array_merge($smarty->autoload_filters[$type], (array) $value); 44 | } else { 45 | $smarty->autoload_filters[$type] = (array) $value; 46 | } 47 | } 48 | } 49 | return $obj; 50 | } 51 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_adddefaultmodifiers.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (is_array($modifiers)) { 36 | $this->default_modifiers = array_merge($smarty->default_modifiers, $modifiers); 37 | } else { 38 | $smarty->default_modifiers[] = $modifiers; 39 | } 40 | return $obj; 41 | } 42 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_append.php: -------------------------------------------------------------------------------- 1 | $_val) { 41 | if ($_key != '') { 42 | $this->append($data, $_key, $_val, $merge, $nocache); 43 | } 44 | } 45 | } else { 46 | if ($tpl_var != '' && isset($value)) { 47 | if (!isset($data->tpl_vars[$tpl_var])) { 48 | $tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false); 49 | if ($tpl_var_inst instanceof Smarty_Undefined_Variable) { 50 | $data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache); 51 | } else { 52 | $data->tpl_vars[$tpl_var] = clone $tpl_var_inst; 53 | } 54 | } 55 | if (!(is_array($data->tpl_vars[$tpl_var]->value) || 56 | $data->tpl_vars[$tpl_var]->value instanceof ArrayAccess) 57 | ) { 58 | settype($data->tpl_vars[$tpl_var]->value, 'array'); 59 | } 60 | if ($merge && is_array($value)) { 61 | foreach ($value as $_mkey => $_mval) { 62 | $data->tpl_vars[$tpl_var]->value[$_mkey] = $_mval; 63 | } 64 | } else { 65 | $data->tpl_vars[$tpl_var]->value[] = $value; 66 | } 67 | } 68 | if ($data->_objType == 2 && $data->scope) { 69 | $data->ext->_updateScope->updateScope($data, $tpl_var); 70 | } 71 | } 72 | return $data; 73 | } 74 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_appendbyref.php: -------------------------------------------------------------------------------- 1 | tpl_vars[$tpl_var])) { 32 | $data->tpl_vars[$tpl_var] = new Smarty_Variable(); 33 | } 34 | if (!is_array($data->tpl_vars[$tpl_var]->value)) { 35 | settype($data->tpl_vars[$tpl_var]->value, 'array'); 36 | } 37 | if ($merge && is_array($value)) { 38 | foreach ($value as $_key => $_val) { 39 | $data->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key]; 40 | } 41 | } else { 42 | $data->tpl_vars[$tpl_var]->value[] = &$value; 43 | } 44 | if ($data->_objType == 2 && $data->scope) { 45 | $data->ext->_updateScope->updateScope($data, $tpl_var); 46 | } 47 | } 48 | return $data; 49 | } 50 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_assignbyref.php: -------------------------------------------------------------------------------- 1 | tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache); 29 | $data->tpl_vars[$tpl_var]->value = &$value; 30 | if ($data->_objType == 2 && $data->scope) { 31 | $data->ext->_updateScope->updateScope($data, $tpl_var); 32 | } 33 | } 34 | return $data; 35 | } 36 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_assignglobal.php: -------------------------------------------------------------------------------- 1 | _objType == 2) { 37 | $ptr->tpl_vars[$varName] = clone Smarty::$global_tpl_vars[$varName]; 38 | $ptr = $ptr->parent; 39 | } 40 | } 41 | return $data; 42 | } 43 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_clearallassign.php: -------------------------------------------------------------------------------- 1 | tpl_vars = array(); 34 | 35 | return $data; 36 | } 37 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_clearallcache.php: -------------------------------------------------------------------------------- 1 | invalidLoadedCache($smarty); 38 | return $_cache_resource->clearAll($smarty, $exp_time); 39 | } 40 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_clearassign.php: -------------------------------------------------------------------------------- 1 | tpl_vars[$curr_var]); 37 | } 38 | } else { 39 | unset($data->tpl_vars[$tpl_var]); 40 | } 41 | 42 | return $data; 43 | } 44 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_clearcache.php: -------------------------------------------------------------------------------- 1 | invalidLoadedCache($smarty); 41 | return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); 42 | } 43 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_clearconfig.php: -------------------------------------------------------------------------------- 1 | config_vars[$name]); 36 | } else { 37 | $data->config_vars = array(); 38 | } 39 | return $data; 40 | } 41 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_compileallconfig.php: -------------------------------------------------------------------------------- 1 | compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true); 31 | } 32 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_createdata.php: -------------------------------------------------------------------------------- 1 | smarty) ? $this->smarty : $obj; 38 | $dataObj = new Smarty_Data($parent, $smarty, $name); 39 | if ($smarty->debugging) { 40 | Smarty_Internal_Debug::register_data($dataObj); 41 | } 42 | return $dataObj; 43 | } 44 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_getautoloadfilters.php: -------------------------------------------------------------------------------- 1 | array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type 26 | * was specified 27 | */ 28 | public function getAutoloadFilters(Smarty_Internal_TemplateBase $obj, $type = null) 29 | { 30 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; 31 | if ($type !== null) { 32 | $this->_checkFilterType($type); 33 | return isset($smarty->autoload_filters[$type]) ? $smarty->autoload_filters[$type] : array(); 34 | } 35 | return $smarty->autoload_filters; 36 | } 37 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_getconfigvars.php: -------------------------------------------------------------------------------- 1 | config_vars[$varname])) { 40 | return $_ptr->config_vars[$varname]; 41 | } 42 | } else { 43 | $var_array = array_merge($_ptr->config_vars, $var_array); 44 | } 45 | // not found, try at parent 46 | if ($search_parents) { 47 | $_ptr = $_ptr->parent; 48 | } else { 49 | $_ptr = null; 50 | } 51 | } 52 | if (isset($varname)) { 53 | return ''; 54 | } else { 55 | return $var_array; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_getdebugtemplate.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 33 | return $smarty->debug_tpl; 34 | } 35 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_getdefaultmodifiers.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 33 | return $smarty->default_modifiers; 34 | } 35 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_getregisteredobject.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 36 | if (!isset($smarty->registered_objects[$object_name])) { 37 | throw new SmartyException("'$object_name' is not a registered object"); 38 | } 39 | if (!is_object($smarty->registered_objects[$object_name][0])) { 40 | throw new SmartyException("registered '$object_name' is not an object"); 41 | } 42 | return $smarty->registered_objects[$object_name][0]; 43 | } 44 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_getstreamvariable.php: -------------------------------------------------------------------------------- 1 | smarty) ? $data->smarty : $data; 45 | if ($smarty->error_unassigned) { 46 | throw new SmartyException('Undefined stream variable "' . $variable . '"'); 47 | } else { 48 | return null; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_gettags.php: -------------------------------------------------------------------------------- 1 | smarty) ? $this->smarty : $obj; 37 | if ($obj->_objType == 2 && !isset($template)) { 38 | $tpl = clone $obj; 39 | } elseif (isset($template) && $template->_objType == 2) { 40 | $tpl = clone $template; 41 | } elseif (isset($template) && is_string($template)) { 42 | /* @var Smarty_Internal_Template $tpl */ 43 | $tpl = new $smarty->template_class($template, $smarty); 44 | // checks if template exists 45 | if (!$tpl->source->exists) { 46 | throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'"); 47 | } 48 | } 49 | if (isset($tpl)) { 50 | $tpl->smarty = clone $tpl->smarty; 51 | $tpl->smarty->_cache['get_used_tags'] = true; 52 | $tpl->_cache['used_tags'] = array(); 53 | $tpl->smarty->merge_compiled_includes = false; 54 | $tpl->smarty->disableSecurity(); 55 | $tpl->caching = false; 56 | $tpl->loadCompiler(); 57 | $tpl->compiler->compileTemplate($tpl); 58 | return $tpl->_cache['used_tags']; 59 | } 60 | throw new SmartyException("Missing template specification"); 61 | } 62 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_loadfilter.php: -------------------------------------------------------------------------------- 1 | true, 'post' => true, 'output' => true, 'variable' => true); 27 | 28 | /** 29 | * load a filter of specified type and name 30 | * 31 | * @api Smarty::loadFilter() 32 | * 33 | * @link http://www.smarty.net/docs/en/api.load.filter.tpl 34 | * 35 | * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj 36 | * @param string $type filter type 37 | * @param string $name filter name 38 | * 39 | * @return bool 40 | * @throws SmartyException if filter could not be loaded 41 | */ 42 | public function loadFilter(Smarty_Internal_TemplateBase $obj, $type, $name) 43 | { 44 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; 45 | $this->_checkFilterType($type); 46 | $_plugin = "smarty_{$type}filter_{$name}"; 47 | $_filter_name = $_plugin; 48 | if (is_callable($_plugin)) { 49 | $smarty->registered_filters[$type][$_filter_name] = $_plugin; 50 | return true; 51 | } 52 | if ($smarty->loadPlugin($_plugin)) { 53 | if (class_exists($_plugin, false)) { 54 | $_plugin = array($_plugin, 'execute'); 55 | } 56 | if (is_callable($_plugin)) { 57 | $smarty->registered_filters[$type][$_filter_name] = $_plugin; 58 | return true; 59 | } 60 | } 61 | throw new SmartyException("{$type}filter \"{$name}\" not found or callable"); 62 | } 63 | 64 | /** 65 | * Check if filter type is valid 66 | * 67 | * @param string $type 68 | * 69 | * @throws \SmartyException 70 | */ 71 | public function _checkFilterType($type) 72 | { 73 | if (!isset($this->filterTypes[$type])) { 74 | throw new SmartyException("Illegal filter type \"{$type}\""); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_mustcompile.php: -------------------------------------------------------------------------------- 1 | source->exists) { 34 | if (isset($_template->parent) && $_template->parent->_objType == 2) { 35 | $parent_resource = " in '$_template->parent->template_resource}'"; 36 | } else { 37 | $parent_resource = ''; 38 | } 39 | throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); 40 | } 41 | if ($_template->mustCompile === null) { 42 | $_template->mustCompile = (!$_template->source->handler->uncompiled && 43 | ($_template->smarty->force_compile || $_template->source->handler->recompiled || !$_template->compiled->exists || 44 | ($_template->smarty->compile_check && $_template->compiled->getTimeStamp() < $_template->source->getTimeStamp()))); 45 | } 46 | 47 | return $_template->mustCompile; 48 | } 49 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registercacheresource.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 36 | $smarty->registered_cache_resources[$name] = $resource_handler; 37 | return $obj; 38 | } 39 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerclass.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 38 | // test if exists 39 | if (!class_exists($class_impl)) { 40 | throw new SmartyException("Undefined class '$class_impl' in register template class"); 41 | } 42 | // register the class 43 | $smarty->registered_classes[$class_name] = $class_impl; 44 | return $obj; 45 | } 46 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (is_callable($callback)) { 36 | $smarty->default_config_handler_func = $callback; 37 | } else { 38 | throw new SmartyException("Default config handler not callable"); 39 | } 40 | return $obj; 41 | } 42 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 36 | if (is_callable($callback)) { 37 | $smarty->default_plugin_handler_func = $callback; 38 | } else { 39 | throw new SmartyException("Default plugin handler '$callback' not callable"); 40 | } 41 | return $obj; 42 | } 43 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (is_callable($callback)) { 36 | $smarty->default_template_handler_func = $callback; 37 | } else { 38 | throw new SmartyException("Default template handler not callable"); 39 | } 40 | return $obj; 41 | } 42 | 43 | /** 44 | * get default content from template or config resource handler 45 | * 46 | * @param Smarty_Template_Source $source 47 | */ 48 | public static function _getDefaultTemplate(Smarty_Template_Source $source) 49 | { 50 | if ($source->isConfig) { 51 | $default_handler = $source->smarty->default_config_handler_func; 52 | } else { 53 | $default_handler = $source->smarty->default_template_handler_func; 54 | } 55 | $_content = $_timestamp = null; 56 | $_return = call_user_func_array($default_handler, array($source->type, $source->name, &$_content, &$_timestamp, 57 | $source->smarty)); 58 | if (is_string($_return)) { 59 | $source->exists = is_file($_return); 60 | if ($source->exists) { 61 | $source->timestamp = filemtime($_return); 62 | } 63 | $source->filepath = $_return; 64 | } elseif ($_return === true) { 65 | $source->content = $_content; 66 | $source->timestamp = $_timestamp; 67 | $source->exists = true; 68 | $source->handler->recompiled = true; 69 | $source->filepath = false; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerfilter.php: -------------------------------------------------------------------------------- 1 | true, 'post' => true, 'output' => true, 'variable' => true); 27 | 28 | /** 29 | * Registers a filter function 30 | * 31 | * @api Smarty::registerFilter() 32 | * 33 | * @link http://www.smarty.net/docs/en/api.register.filter.tpl 34 | * 35 | * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj 36 | * @param string $type filter type 37 | * @param callback $callback 38 | * @param string|null $name optional filter name 39 | * 40 | * @return \Smarty|\Smarty_Internal_Template 41 | * @throws \SmartyException 42 | */ 43 | public function registerFilter(Smarty_Internal_TemplateBase $obj, $type, $callback, $name = null) 44 | { 45 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; 46 | $this->_checkFilterType($type); 47 | $name = isset($name) ? $name : $this->_getFilterName($callback); 48 | if (!is_callable($callback)) { 49 | throw new SmartyException("{$type}filter \"{$name}\" not callable"); 50 | } 51 | $smarty->registered_filters[$type][$name] = $callback; 52 | return $obj; 53 | } 54 | 55 | /** 56 | * Return internal filter name 57 | * 58 | * @param callback $function_name 59 | * 60 | * @return string internal filter name 61 | */ 62 | public function _getFilterName($function_name) 63 | { 64 | if (is_array($function_name)) { 65 | $_class_name = (is_object($function_name[0]) ? get_class($function_name[0]) : $function_name[0]); 66 | 67 | return $_class_name . '_' . $function_name[1]; 68 | } elseif (is_string($function_name)) { 69 | return $function_name; 70 | } else { 71 | return 'closure'; 72 | } 73 | } 74 | 75 | /** 76 | * Check if filter type is valid 77 | * 78 | * @param string $type 79 | * 80 | * @throws \SmartyException 81 | */ 82 | public function _checkFilterType($type) 83 | { 84 | if (!isset($this->filterTypes[$type])) { 85 | throw new SmartyException("Illegal filter type \"{$type}\""); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerplugin.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 41 | if (isset($smarty->registered_plugins[$type][$name])) { 42 | throw new SmartyException("Plugin tag \"{$name}\" already registered"); 43 | } elseif (!is_callable($callback)) { 44 | throw new SmartyException("Plugin \"{$name}\" not callable"); 45 | } else { 46 | $smarty->registered_plugins[$type][$name] = array($callback, (bool) $cacheable, (array) $cache_attr); 47 | } 48 | return $obj; 49 | } 50 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_registerresource.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 40 | $smarty->registered_resources[$name] = $resource_handler instanceof 41 | Smarty_Resource ? $resource_handler : array($resource_handler, false); 42 | return $obj; 43 | } 44 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_setautoloadfilters.php: -------------------------------------------------------------------------------- 1 | true, 'post' => true, 'output' => true, 'variable' => true); 27 | 28 | /** 29 | * Set autoload filters 30 | * 31 | * @api Smarty::setAutoloadFilters() 32 | * 33 | * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj 34 | * @param array $filters filters to load automatically 35 | * @param string $type "pre", "output", … specify the 36 | * filter type to set. Defaults to 37 | * none treating $filters' keys as 38 | * the appropriate types 39 | * 40 | * @return \Smarty|\Smarty_Internal_Template 41 | */ 42 | public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null) 43 | { 44 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; 45 | if ($type !== null) { 46 | $this->_checkFilterType($type); 47 | $smarty->autoload_filters[$type] = (array) $filters; 48 | } else { 49 | foreach ((array) $filters as $type => $value) { 50 | $this->_checkFilterType($type); 51 | } 52 | $smarty->autoload_filters = (array) $filters; 53 | } 54 | return $obj; 55 | } 56 | 57 | /** 58 | * Check if filter type is valid 59 | * 60 | * @param string $type 61 | * 62 | * @throws \SmartyException 63 | */ 64 | public function _checkFilterType($type) 65 | { 66 | if (!isset($this->filterTypes[$type])) { 67 | throw new SmartyException("Illegal filter type \"{$type}\""); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_setdebugtemplate.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (!is_readable($tpl_name)) { 36 | throw new SmartyException("Unknown file '{$tpl_name}'"); 37 | } 38 | $smarty->debug_tpl = $tpl_name; 39 | return $obj; 40 | } 41 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_setdefaultmodifiers.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | $smarty->default_modifiers = (array) $modifiers; 36 | return $obj; 37 | } 38 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_unloadfilter.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 30 | $this->_checkFilterType($type); 31 | if (isset($smarty->registered_filters[$type])) { 32 | $_filter_name = "smarty_{$type}filter_{$name}"; 33 | if (isset($smarty->registered_filters[$type][$_filter_name])) { 34 | unset ($smarty->registered_filters[$type][$_filter_name]); 35 | if (empty($smarty->registered_filters[$type])) { 36 | unset($smarty->registered_filters[$type]); 37 | } 38 | } 39 | } 40 | return $obj; 41 | } 42 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_unregistercacheresource.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (isset($smarty->registered_cache_resources[$name])) { 36 | unset($smarty->registered_cache_resources[$name]); 37 | } 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_unregisterfilter.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 30 | $this->_checkFilterType($type); 31 | if (isset($smarty->registered_filters[$type])) { 32 | $name = is_string($callback) ? $callback : $this->_getFilterName($callback); 33 | if (isset($smarty->registered_filters[$type][$name])) { 34 | unset($smarty->registered_filters[$type][$name]); 35 | if (empty($smarty->registered_filters[$type])) { 36 | unset($smarty->registered_filters[$type]); 37 | } 38 | } 39 | } 40 | return $obj; 41 | } 42 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_unregisterobject.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (isset($smarty->registered_objects[$object_name])) { 36 | unset($smarty->registered_objects[$object_name]); 37 | } 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_unregisterplugin.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 36 | if (isset($smarty->registered_plugins[$type][$name])) { 37 | unset($smarty->registered_plugins[$type][$name]); 38 | } 39 | return $obj; 40 | } 41 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_method_unregisterresource.php: -------------------------------------------------------------------------------- 1 | smarty) ? $obj->smarty : $obj; 35 | if (isset($smarty->registered_resources[$type])) { 36 | unset($smarty->registered_resources[$type]); 37 | } 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_nocache_insert.php: -------------------------------------------------------------------------------- 1 | assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . ",\$_smarty_tpl), true);?>"; 41 | } else { 42 | $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>"; 43 | } 44 | $_tpl = $_template; 45 | while (isset($_tpl->parent) && $_tpl->parent->_objType == 2) { 46 | $_tpl = $_tpl->parent; 47 | } 48 | 49 | return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_parsetree.php: -------------------------------------------------------------------------------- 1 | data = null; 49 | $this->subtrees = null; 50 | } 51 | 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_parsetree_code.php: -------------------------------------------------------------------------------- 1 | data = $data; 29 | } 30 | 31 | /** 32 | * Return buffer content in parentheses 33 | * 34 | * @param \Smarty_Internal_Templateparser $parser 35 | * 36 | * @return string content 37 | */ 38 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 39 | { 40 | return sprintf("(%s)", $this->data); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_parsetree_dq.php: -------------------------------------------------------------------------------- 1 | subtrees[] = $subtree; 29 | if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { 30 | $parser->block_nesting_level = count($parser->compiler->_tag_stack); 31 | } 32 | } 33 | 34 | /** 35 | * Append buffer to subtree 36 | * 37 | * @param \Smarty_Internal_Templateparser $parser 38 | * @param Smarty_Internal_ParseTree $subtree parse tree buffer 39 | */ 40 | public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree) 41 | { 42 | $last_subtree = count($this->subtrees) - 1; 43 | if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $parser->block_nesting_level) { 44 | if ($subtree instanceof Smarty_Internal_ParseTree_Code) { 45 | $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, 'data . ';?>'); 46 | } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) { 47 | $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, 'data . '";?>'); 48 | } else { 49 | $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data); 50 | } 51 | } else { 52 | $this->subtrees[] = $subtree; 53 | } 54 | if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { 55 | $parser->block_nesting_level = count($parser->compiler->_tag_stack); 56 | } 57 | } 58 | 59 | /** 60 | * Merge subtree buffer content together 61 | * 62 | * @param \Smarty_Internal_Templateparser $parser 63 | * 64 | * @return string compiled template code 65 | */ 66 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 67 | { 68 | $code = ''; 69 | foreach ($this->subtrees as $subtree) { 70 | if ($code !== "") { 71 | $code .= "."; 72 | } 73 | if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { 74 | $more_php = $subtree->assign_to_var($parser); 75 | } else { 76 | $more_php = $subtree->to_smarty_php($parser); 77 | } 78 | 79 | $code .= $more_php; 80 | 81 | if (!$subtree instanceof Smarty_Internal_ParseTree_DqContent) { 82 | $parser->compiler->has_variable_string = true; 83 | } 84 | } 85 | 86 | return $code; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_parsetree_dqcontent.php: -------------------------------------------------------------------------------- 1 | data = $data; 29 | } 30 | 31 | /** 32 | * Return content as double quoted string 33 | * 34 | * @param \Smarty_Internal_Templateparser $parser 35 | * 36 | * @return string doubled quoted string 37 | */ 38 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 39 | { 40 | return '"' . $this->data . '"'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_parsetree_tag.php: -------------------------------------------------------------------------------- 1 | data = $data; 38 | $this->saved_block_nesting = $parser->block_nesting_level; 39 | } 40 | 41 | /** 42 | * Return buffer content 43 | * 44 | * @param \Smarty_Internal_Templateparser $parser 45 | * 46 | * @return string content 47 | */ 48 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 49 | { 50 | return $this->data; 51 | } 52 | 53 | /** 54 | * Return complied code that loads the evaluated output of buffer content into a temporary variable 55 | * 56 | * @param \Smarty_Internal_Templateparser $parser 57 | * 58 | * @return string template code 59 | */ 60 | public function assign_to_var(Smarty_Internal_Templateparser $parser) 61 | { 62 | $var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number); 63 | $tmp = $parser->compiler->appendCode('', $this->data); 64 | $tmp = $parser->compiler->appendCode($tmp, ""); 65 | $parser->compiler->prefix_code[] = sprintf("%s", $tmp); 66 | 67 | return $var; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_parsetree_text.php: -------------------------------------------------------------------------------- 1 | data = $data; 27 | } 28 | 29 | /** 30 | * Return buffer content 31 | * 32 | * @param \Smarty_Internal_Templateparser $parser 33 | * 34 | * @return string text 35 | */ 36 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 37 | { 38 | return $this->data; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_resource_eval.php: -------------------------------------------------------------------------------- 1 | uid = $source->filepath = sha1($source->name); 32 | $source->timestamp = false; 33 | $source->exists = true; 34 | } 35 | 36 | /** 37 | * Load template's source from $resource_name into current template object 38 | * 39 | * @uses decode() to decode base64 and urlencoded template_resources 40 | * 41 | * @param Smarty_Template_Source $source source object 42 | * 43 | * @return string template source 44 | */ 45 | public function getContent(Smarty_Template_Source $source) 46 | { 47 | return $this->decode($source->name); 48 | } 49 | 50 | /** 51 | * decode base64 and urlencode 52 | * 53 | * @param string $string template_resource to decode 54 | * 55 | * @return string decoded template_resource 56 | */ 57 | protected function decode($string) 58 | { 59 | // decode if specified 60 | if (($pos = strpos($string, ':')) !== false) { 61 | if (!strncmp($string, 'base64', 6)) { 62 | return base64_decode(substr($string, 7)); 63 | } elseif (!strncmp($string, 'urlencode', 9)) { 64 | return urldecode(substr($string, 10)); 65 | } 66 | } 67 | 68 | return $string; 69 | } 70 | 71 | /** 72 | * modify resource_name according to resource handlers specifications 73 | * 74 | * @param Smarty $smarty Smarty instance 75 | * @param string $resource_name resource_name to make unique 76 | * @param boolean $isConfig flag for config resource 77 | * 78 | * @return string unique resource name 79 | */ 80 | public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) 81 | { 82 | return get_class($this) . '#' . $this->decode($resource_name); 83 | } 84 | 85 | /** 86 | * Determine basename for compiled filename 87 | * 88 | * @param Smarty_Template_Source $source source object 89 | * 90 | * @return string resource's basename 91 | */ 92 | public function getBasename(Smarty_Template_Source $source) 93 | { 94 | return ''; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_resource_registered.php: -------------------------------------------------------------------------------- 1 | filepath = $source->type . ':' . $source->name; 32 | $source->uid = sha1($source->filepath); 33 | if ($source->smarty->compile_check) { 34 | $source->timestamp = $this->getTemplateTimestamp($source); 35 | $source->exists = !!$source->timestamp; 36 | } 37 | } 38 | 39 | /** 40 | * populate Source Object with timestamp and exists from Resource 41 | * 42 | * @param Smarty_Template_Source $source source object 43 | * 44 | * @return void 45 | */ 46 | public function populateTimestamp(Smarty_Template_Source $source) 47 | { 48 | $source->timestamp = $this->getTemplateTimestamp($source); 49 | $source->exists = !!$source->timestamp; 50 | } 51 | 52 | /** 53 | * Get timestamp (epoch) the template source was modified 54 | * 55 | * @param Smarty_Template_Source $source source object 56 | * 57 | * @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp 58 | */ 59 | public function getTemplateTimestamp(Smarty_Template_Source $source) 60 | { 61 | // return timestamp 62 | $time_stamp = false; 63 | call_user_func_array($source->smarty->registered_resources[$source->type][0][1], array($source->name, &$time_stamp, $source->smarty)); 64 | 65 | return is_numeric($time_stamp) ? (int) $time_stamp : $time_stamp; 66 | } 67 | 68 | /** 69 | * Load template's source by invoking the registered callback into current template object 70 | * 71 | * @param Smarty_Template_Source $source source object 72 | * 73 | * @return string template source 74 | * @throws SmartyException if source cannot be loaded 75 | */ 76 | public function getContent(Smarty_Template_Source $source) 77 | { 78 | // return template string 79 | $content = null; 80 | $t = call_user_func_array($source->smarty->registered_resources[$source->type][0][0], array($source->name, &$content, $source->smarty)); 81 | if (is_bool($t) && !$t) { 82 | throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); 83 | } 84 | 85 | return $content; 86 | } 87 | 88 | /** 89 | * Determine basename for compiled filename 90 | * 91 | * @param Smarty_Template_Source $source source object 92 | * 93 | * @return string resource's basename 94 | */ 95 | public function getBasename(Smarty_Template_Source $source) 96 | { 97 | return basename($source->name); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_resource_stream.php: -------------------------------------------------------------------------------- 1 | resource, '://') !== false) { 33 | $source->filepath = $source->resource; 34 | } else { 35 | $source->filepath = str_replace(':', '://', $source->resource); 36 | } 37 | $source->uid = false; 38 | $source->content = $this->getContent($source); 39 | $source->timestamp = false; 40 | $source->exists = !!$source->content; 41 | } 42 | 43 | /** 44 | * Load template's source from stream into current template object 45 | * 46 | * @param Smarty_Template_Source $source source object 47 | * 48 | * @return string template source 49 | * @throws SmartyException if source cannot be loaded 50 | */ 51 | public function getContent(Smarty_Template_Source $source) 52 | { 53 | $t = ''; 54 | // the availability of the stream has already been checked in Smarty_Resource::fetch() 55 | $fp = fopen($source->filepath, 'r+'); 56 | if ($fp) { 57 | while (!feof($fp) && ($current_line = fgets($fp)) !== false) { 58 | $t .= $current_line; 59 | } 60 | fclose($fp); 61 | 62 | return $t; 63 | } else { 64 | return false; 65 | } 66 | } 67 | 68 | /** 69 | * modify resource_name according to resource handlers specifications 70 | * 71 | * @param Smarty $smarty Smarty instance 72 | * @param string $resource_name resource_name to make unique 73 | * @param boolean $isConfig flag for config resource 74 | * 75 | * @return string unique resource name 76 | */ 77 | public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) 78 | { 79 | return get_class($this) . '#' . $resource_name; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_resource_string.php: -------------------------------------------------------------------------------- 1 | uid = $source->filepath = sha1($source->name); 32 | $source->timestamp = 0; 33 | $source->exists = true; 34 | } 35 | 36 | /** 37 | * Load template's source from $resource_name into current template object 38 | * 39 | * @uses decode() to decode base64 and urlencoded template_resources 40 | * 41 | * @param Smarty_Template_Source $source source object 42 | * 43 | * @return string template source 44 | */ 45 | public function getContent(Smarty_Template_Source $source) 46 | { 47 | return $this->decode($source->name); 48 | } 49 | 50 | /** 51 | * decode base64 and urlencode 52 | * 53 | * @param string $string template_resource to decode 54 | * 55 | * @return string decoded template_resource 56 | */ 57 | protected function decode($string) 58 | { 59 | // decode if specified 60 | if (($pos = strpos($string, ':')) !== false) { 61 | if (!strncmp($string, 'base64', 6)) { 62 | return base64_decode(substr($string, 7)); 63 | } elseif (!strncmp($string, 'urlencode', 9)) { 64 | return urldecode(substr($string, 10)); 65 | } 66 | } 67 | 68 | return $string; 69 | } 70 | 71 | /** 72 | * modify resource_name according to resource handlers specifications 73 | * 74 | * @param Smarty $smarty Smarty instance 75 | * @param string $resource_name resource_name to make unique 76 | * @param boolean $isConfig flag for config resource 77 | * 78 | * @return string unique resource name 79 | */ 80 | public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) 81 | { 82 | return get_class($this) . '#' . $this->decode($resource_name); 83 | } 84 | 85 | /** 86 | * Determine basename for compiled filename 87 | * Always returns an empty string. 88 | * 89 | * @param Smarty_Template_Source $source source object 90 | * 91 | * @return string resource's basename 92 | */ 93 | public function getBasename(Smarty_Template_Source $source) 94 | { 95 | return ''; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_runtime_cachemodify.php: -------------------------------------------------------------------------------- 1 | isCached() && !$_template->compiled->has_nocache_code; 22 | $_last_modified_date = 23 | @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); 24 | if ($_isCached && $cached->timestamp <= strtotime($_last_modified_date)) { 25 | switch (PHP_SAPI) { 26 | case 'cgi': // php-cgi < 5.3 27 | case 'cgi-fcgi': // php-cgi >= 5.3 28 | case 'fpm-fcgi': // php-fpm >= 5.3.3 29 | header('Status: 304 Not Modified'); 30 | break; 31 | 32 | case 'cli': 33 | if ( /* ^phpunit */ 34 | !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ 35 | ) { 36 | $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified'; 37 | } 38 | break; 39 | 40 | default: 41 | if ( /* ^phpunit */ 42 | !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ 43 | ) { 44 | $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified'; 45 | } else { 46 | header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); 47 | } 48 | break; 49 | } 50 | } else { 51 | switch (PHP_SAPI) { 52 | case 'cli': 53 | if ( /* ^phpunit */ 54 | !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ 55 | ) { 56 | $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 57 | 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT'; 58 | } 59 | break; 60 | default: 61 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT'); 62 | break; 63 | } 64 | echo $content; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_runtime_filterhandler.php: -------------------------------------------------------------------------------- 1 | smarty->autoload_filters[$type])) { 37 | foreach ((array) $template->smarty->autoload_filters[$type] as $name) { 38 | $plugin_name = "Smarty_{$type}filter_{$name}"; 39 | if (function_exists($plugin_name)) { 40 | $callback = $plugin_name; 41 | } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) { 42 | $callback = array($plugin_name, 'execute'); 43 | } elseif ($template->smarty->loadPlugin($plugin_name, false)) { 44 | if (function_exists($plugin_name)) { 45 | // use loaded Smarty2 style plugin 46 | $callback = $plugin_name; 47 | } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) { 48 | // loaded class of filter plugin 49 | $callback = array($plugin_name, 'execute'); 50 | } else { 51 | throw new SmartyException("Auto load {$type}-filter plugin method \"{$plugin_name}::execute\" not callable"); 52 | } 53 | } else { 54 | // nothing found, throw exception 55 | throw new SmartyException("Unable to auto load {$type}-filter plugin \"{$plugin_name}\""); 56 | } 57 | $content = call_user_func($callback, $content, $template); 58 | } 59 | } 60 | // loop over registered filters of specified type 61 | if (!empty($template->smarty->registered_filters[$type])) { 62 | foreach ($template->smarty->registered_filters[$type] as $key => $name) { 63 | $content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template); 64 | } 65 | } 66 | // return filtered output 67 | return $content; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_runtime_foreach.php: -------------------------------------------------------------------------------- 1 | getIterator()); 29 | } elseif ($value instanceof Iterator) { 30 | if ($value instanceof Generator) { 31 | return 1; 32 | } 33 | return iterator_count($value); 34 | } elseif ($value instanceof PDOStatement) { 35 | return $value->rowCount(); 36 | } elseif ($value instanceof Traversable) { 37 | return iterator_count($value); 38 | } elseif ($value instanceof ArrayAccess) { 39 | if ($value->offsetExists(0)) { 40 | return 1; 41 | } 42 | } elseif (is_object($value)) { 43 | return count($value); 44 | } 45 | return 0; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_runtime_hhvm.php: -------------------------------------------------------------------------------- 1 | scope) { 23 | return; 24 | } 25 | foreach (array($scope, $tpl->scope) as $s) { 26 | $s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s; 27 | if ($bubble_up && $s) { 28 | $ptr = $tpl->parent; 29 | if (isset($ptr)) { 30 | $ptr->tpl_vars[$varName] = $tpl->tpl_vars[$varName]; 31 | $ptr = $ptr->parent; 32 | } 33 | if ($s == Smarty::SCOPE_PARENT) { 34 | continue; 35 | } 36 | while (isset($ptr) && $ptr->_objType == 2) { 37 | $ptr->tpl_vars[$varName] = $tpl->tpl_vars[$varName]; 38 | $ptr = $ptr->parent; 39 | } 40 | if ($s == Smarty::SCOPE_TPL_ROOT) { 41 | continue; 42 | } elseif ($s == Smarty::SCOPE_SMARTY) { 43 | $tpl->smarty->tpl_vars[$varName] = $tpl->tpl_vars[$varName]; 44 | } elseif ($s == Smarty::SCOPE_GLOBAL) { 45 | Smarty::$global_tpl_vars[$varName] = $tpl->tpl_vars[$varName]; 46 | } elseif ($s == Smarty::SCOPE_ROOT) { 47 | while (isset($ptr->parent)) { 48 | $ptr = $ptr->parent; 49 | } 50 | $ptr->tpl_vars[$varName] = $tpl->tpl_vars[$varName]; 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_runtime_var.php: -------------------------------------------------------------------------------- 1 | tpl_vars[$varName])) { 23 | $tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache); 24 | } else { 25 | $tpl->tpl_vars[$varName] = clone $tpl->tpl_vars[$varName]; 26 | if (!(is_array($tpl->tpl_vars[$varName]->value) || 27 | $tpl->tpl_vars[$varName]->value instanceof ArrayAccess) 28 | ) { 29 | settype($tpl->tpl_vars[$varName]->value, 'array'); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_runtime_writefile.php: -------------------------------------------------------------------------------- 1 | _file_perms : 0644; 33 | $_dir_perms = property_exists($smarty, '_dir_perms') ? (isset($smarty->_dir_perms) ? $smarty->_dir_perms : 0777) : 0771; 34 | if ($_file_perms !== null) { 35 | $old_umask = umask(0); 36 | } 37 | 38 | $_dirpath = dirname($_filepath); 39 | // if subdirs, create dir structure 40 | if ($_dirpath !== '.' && !file_exists($_dirpath)) { 41 | mkdir($_dirpath, $_dir_perms, true); 42 | } 43 | 44 | // write to tmp file, then move to overt file lock race condition 45 | $_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true)); 46 | if (!file_put_contents($_tmp_file, $_contents)) { 47 | error_reporting($_error_reporting); 48 | throw new SmartyException("unable to write file {$_tmp_file}"); 49 | } 50 | 51 | /* 52 | * Windows' rename() fails if the destination exists, 53 | * Linux' rename() properly handles the overwrite. 54 | * Simply unlink()ing a file might cause other processes 55 | * currently reading that file to fail, but linux' rename() 56 | * seems to be smart enough to handle that for us. 57 | */ 58 | if (Smarty::$_IS_WINDOWS) { 59 | // remove original file 60 | if (is_file($_filepath)) { 61 | @unlink($_filepath); 62 | } 63 | // rename tmp file 64 | $success = @rename($_tmp_file, $_filepath); 65 | } else { 66 | // rename tmp file 67 | $success = @rename($_tmp_file, $_filepath); 68 | if (!$success) { 69 | // remove original file 70 | if (is_file($_filepath)) { 71 | @unlink($_filepath); 72 | } 73 | // rename tmp file 74 | $success = @rename($_tmp_file, $_filepath); 75 | } 76 | } 77 | if (!$success) { 78 | error_reporting($_error_reporting); 79 | throw new SmartyException("unable to write file {$_filepath}"); 80 | } 81 | if ($_file_perms !== null) { 82 | // set file permissions 83 | chmod($_filepath, $_file_perms); 84 | umask($old_umask); 85 | } 86 | error_reporting($_error_reporting); 87 | 88 | return true; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_internal_undefined.php: -------------------------------------------------------------------------------- 1 | cached->valid = false; 29 | } else { 30 | $tpl->mustCompile = true; 31 | } 32 | return false; 33 | } 34 | 35 | /** 36 | * Call error handler for undefined method 37 | * 38 | * @param string $name unknown method-name 39 | * @param array $args argument array 40 | * 41 | * @return mixed 42 | * @throws SmartyException 43 | */ 44 | public function __call($name, $args) 45 | { 46 | throw new SmartyException(get_class($args[0]) . "->{$name}() undefined method"); 47 | } 48 | } -------------------------------------------------------------------------------- /libs/sysplugins/smarty_resource_custom.php: -------------------------------------------------------------------------------- 1 | filepath = $source->type . ':' . $source->name; 51 | $source->uid = sha1($source->type . ':' . $source->name); 52 | 53 | $mtime = $this->fetchTimestamp($source->name); 54 | if ($mtime !== null) { 55 | $source->timestamp = $mtime; 56 | } else { 57 | $this->fetch($source->name, $content, $timestamp); 58 | $source->timestamp = isset($timestamp) ? $timestamp : false; 59 | if (isset($content)) { 60 | $source->content = $content; 61 | } 62 | } 63 | $source->exists = !!$source->timestamp; 64 | } 65 | 66 | /** 67 | * Load template's source into current template object 68 | * 69 | * @param Smarty_Template_Source $source source object 70 | * 71 | * @return string template source 72 | * @throws SmartyException if source cannot be loaded 73 | */ 74 | public function getContent(Smarty_Template_Source $source) 75 | { 76 | $this->fetch($source->name, $content, $timestamp); 77 | if (isset($content)) { 78 | return $content; 79 | } 80 | 81 | throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); 82 | } 83 | 84 | /** 85 | * Determine basename for compiled filename 86 | * 87 | * @param Smarty_Template_Source $source source object 88 | * 89 | * @return string resource's basename 90 | */ 91 | public function getBasename(Smarty_Template_Source $source) 92 | { 93 | return basename($source->name); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_resource_recompiled.php: -------------------------------------------------------------------------------- 1 | filepath = false; 44 | $compiled->timestamp = false; 45 | $compiled->exists = false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_resource_uncompiled.php: -------------------------------------------------------------------------------- 1 | filepath = false; 52 | $compiled->timestamp = false; 53 | $compiled->exists = false; 54 | } 55 | 56 | /** 57 | * render compiled template code 58 | * 59 | * @param Smarty_Internal_Template $_template 60 | * 61 | * @return string 62 | * @throws Exception 63 | */ 64 | public function render($_template) 65 | { 66 | $level = ob_get_level(); 67 | ob_start(); 68 | try { 69 | $this->renderUncompiled($_template->source, $_template); 70 | return ob_get_clean(); 71 | } 72 | catch (Exception $e) { 73 | while (ob_get_level() > $level) { 74 | ob_end_clean(); 75 | } 76 | throw $e; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /libs/sysplugins/smarty_undefined_variable.php: -------------------------------------------------------------------------------- 1 | value = $value; 34 | $this->nocache = $nocache; 35 | } 36 | 37 | /** 38 | * <> String conversion 39 | * 40 | * @return string 41 | */ 42 | public function __toString() 43 | { 44 | return (string) $this->value; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /libs/sysplugins/smartycompilerexception.php: -------------------------------------------------------------------------------- 1 | Smarty Compiler: ' . $this->message . ' <-- '; 13 | } 14 | 15 | /** 16 | * The line number of the template error 17 | * 18 | * @type int|null 19 | */ 20 | public $line = null; 21 | /** 22 | * The template source snippet relating to the error 23 | * 24 | * @type string|null 25 | */ 26 | public $source = null; 27 | /** 28 | * The raw text of the error message 29 | * 30 | * @type string|null 31 | */ 32 | public $desc = null; 33 | /** 34 | * The resource identifier or template name 35 | * 36 | * @type string|null 37 | */ 38 | public $template = null; 39 | } 40 | -------------------------------------------------------------------------------- /libs/sysplugins/smartyexception.php: -------------------------------------------------------------------------------- 1 | Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /templates/default/404.tpl: -------------------------------------------------------------------------------- 1 | {include file="header.tpl"} 2 |
3 |
4 |
5 |
6 |

404

7 |
8 |
9 |
10 |
11 |
12 | We can't seem to find the page you are looking for. 13 |
14 |
15 |
16 |
17 | 18 | {include file="footer.tpl"} 19 | -------------------------------------------------------------------------------- /templates/default/home.tpl: -------------------------------------------------------------------------------- 1 | {include file="header.tpl"} 2 | 3 |
4 |
5 |
6 |
7 | 10 |
11 |
12 |
13 |
14 |

Faucet

15 |
16 |
17 |
18 |
19 |
20 | {if isset($resultClaim)} 21 | {$resultClaim} 22 | {/if} 23 |
24 | Rewards: {$minReward} to {$maxReward} satoshi every {$timer} minutes 25 |
26 |

Address

27 | {$user->address}
28 |

Your balance

29 | {$user->balanceInSat} satoshis
30 |
31 | 32 |
33 | 34 | Please note: You require a Faucethub.io account to receive your payment. Click here to create one. 35 | 36 |
37 | Withdraw to FaucetHub

38 | 39 |

1. Claim


40 | {if (time() - ($timer * 60)) > $user->last_claim} 41 |
42 | {$csrf_field} 43 | 44 |
45 | {else} 46 | 47 | {/if} 48 |
49 |

50 | Your personal referral link: {$user->getRefLink()} 51 |

52 |
Share this link with your friends and earn {$settings['referral_percent']}% referral commission
53 |
54 |
55 |
56 |
57 |
58 | 61 |
62 |
63 |
64 |
65 | {include file="footer.tpl"} 66 | -------------------------------------------------------------------------------- /templates/default/verify.tpl: -------------------------------------------------------------------------------- 1 | {include file="header.tpl"} 2 | 3 |
4 |
5 |
6 |
7 | 10 |
11 |
12 | 13 |
14 |
15 |

Faucet

16 |
17 |
18 |
19 |
20 |
21 |

2. Solve Captcha


22 |
23 |
24 | {$csrf_field} 25 |
26 | 27 |
28 |
29 |
30 | 31 |
32 |
33 | 36 |
37 |
38 |
39 | {include file="footer.tpl"} 40 | --------------------------------------------------------------------------------