コード例 #1
0
 private static function read_template_or_subtemplate_file($y_file_path, $y_use_caching)
 {
     //--
     $y_file_path = (string) $y_file_path;
     //--
     $cached_key = 'read_template_or_subtemplate_file:' . $y_file_path;
     //--
     if (array_key_exists((string) $cached_key, (array) self::$MkTplCache)) {
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             self::$MkTplVars['@SUB-TEMPLATE:' . $y_file_path][] = 'Includding a Sub-Template from VCache';
             SmartFrameworkRegistry::setDebugMsg('extra', 'SMART-TEMPLATING', ['title' => '[TPL-ReadFileTemplate-From-VCache] :: Markers-Templating / File-Read ; Serving from VCache the File Template: ' . $y_file_path . ' ; VCacheFlag: ' . $y_use_caching, 'data' => 'Content: ' . "\n" . SmartParser::text_endpoints(self::$MkTplCache[(string) $cached_key], 255)]);
         }
         //end if
         //--
         return (string) self::$MkTplCache[(string) $cached_key];
         //--
     }
     //end if
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         self::$MkTplFCount[(string) $cached_key]++;
         // register to counter anytime is read from FileSystem
     }
     //end if
     //--
     if ((string) $y_use_caching == 'yes') {
         //--
         self::$MkTplCache[(string) $cached_key] = (string) self::read_template_file($y_file_path);
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             self::$MkTplVars['@SUB-TEMPLATE:' . $y_file_path][] = 'Reading a Sub-Template from FS and REGISTER in VCache';
             SmartFrameworkRegistry::setDebugMsg('extra', 'SMART-TEMPLATING', ['title' => '[TPL-ReadFileTemplate-From-FS-Register-In-VCache] :: Markers-Templating / Registering to VCache the File Template: ' . $y_file_path . ' ;', 'data' => 'Content: ' . "\n" . SmartParser::text_endpoints(self::$MkTplCache[(string) $cached_key], 255)]);
         }
         //end if
         //--
         return (string) self::$MkTplCache[(string) $cached_key];
         //--
     } else {
         //--
         $mtemplate = (string) self::read_template_file($y_file_path);
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             self::$MkTplVars['@SUB-TEMPLATE:' . $y_file_path][] = 'Reading a Sub-Template from FS  ; VCacheFlag: ' . $y_use_caching;
             SmartFrameworkRegistry::setDebugMsg('extra', 'SMART-TEMPLATING', ['title' => '[TPL-ReadFileTemplate-From-FS] :: Markers-Templating / File-Read ; Serving from FS the File Template: ' . $y_file_path . ' ;', 'data' => 'Content: ' . "\n" . SmartParser::text_endpoints($mtemplate, 255)]);
         }
         //end if
         //--
         return (string) $mtemplate;
         //--
     }
     //end if else
     //--
 }
コード例 #2
0
 /**
  * Replace FAX numbers in a text string with HTML links <a href="(faxNum)" target="{target}">[faxNum]</a>
  *
  * @param 	STRING 	$string 			:: The text string to be processed
  * @param 	STRING 	$yaction			:: Action to append the fax-num link to ; Default is: 'efax:' but can be for example: 'script.php?action=fax&number='
  * @param 	STRING	$ytarget			:: URL target ; default is '_blank' ; can be: '_self' or a specific window name: 'myWindow' ...
  *
  * @return 	STRING						:: The HTML processed text with FAX numbers replaced with real tags as links
  */
 public static function text_faxnums($string, $yaction = 'efax:', $ytarget = '_blank')
 {
     $string = (string) $string;
     $expr = SmartValidator::regex_stringvalidation_expression('fax', 'partial');
     $regex = $expr . 'iu';
     //insensitive, with /u modifier for unicode strings
     $string = preg_replace_callback($regex, function ($matches) use($yaction, $ytarget) {
         return '<a title="@eFax@" id="url_recognition" href="' . Smart::escape_html($yaction . rawurlencode(trim($matches[2]))) . '" target="' . $ytarget . '">' . Smart::escape_html(SmartParser::text_endpoints($matches[2], 75)) . '</a>';
     }, $string);
     return (string) $string;
 }
コード例 #3
0
 /**
  * Set a Key into the non-persistent Cache
  *
  * @param STRING 	$y_realm	The Cache Realm
  * @param STRING 	$y_key		The Cache Key
  * @param MIXED 	$y_value	The value to be stored
  *
  * @return BOOLEAN	Always returns true
  */
 public static function setKey($y_realm, $y_key, $y_value)
 {
     //--
     self::$CachedData[(string) $y_realm] = (array) self::$CachedData[(string) $y_realm];
     self::$CachedData[(string) $y_realm][(string) $y_key] = $y_value;
     // mixed
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         SmartFrameworkRegistry::setDebugMsg('extra', 'SMART-CACHE', ['title' => '[SetKey]: ' . $y_realm . ' / ' . $y_key, 'data' => SmartParser::text_endpoints((string) print_r($y_value, 1), 1024)]);
     }
     //end if
     //--
     return true;
     //--
 }
コード例 #4
0
 /**
  * this is the Run Command
  *
  * @access 		private
  * @internal
  *
  */
 private function run_command($method, array $args)
 {
     //--
     if (!$this->socket) {
         $this->error(true, 'Redis Connection / Run', 'Connection Failed', 'Method: ' . $method);
         // fatal error
         return null;
     }
     //end if
     //--
     $method = (string) $method;
     $args = (array) $args;
     //--
     array_unshift($args, $method);
     $cmd = '*' . count($args) . "\r\n";
     // no. of arguments
     foreach ($args as $z => $item) {
         $cmd .= '$' . strlen($item) . "\r\n";
         // str length
         $cmd .= $item . "\r\n";
         // key contents
     }
     //end foreach
     //--
     if ((string) $cmd == '') {
         //--
         $this->error(true, 'Redis Run Command', 'Empty commands are not allowed ...', '');
         // fatal error
         return null;
         //--
     }
     //end if
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //--
         $time_start = microtime(true);
         //--
     }
     //end if
     //--
     @fwrite($this->socket, $cmd);
     //--
     $response = $this->parse_response($method);
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //--
         SmartFrameworkRegistry::setDebugMsg('db', 'redis|total-queries', 1, '+');
         //--
         $time_end = (double) (microtime(true) - (double) $time_start);
         SmartFrameworkRegistry::setDebugMsg('db', 'redis|total-time', $time_end, '+');
         //--
         SmartFrameworkRegistry::setDebugMsg('db', 'redis|log', ['type' => 'nosql', 'data' => strtoupper($method) . ' :: ' . $this->description, 'command' => SmartParser::text_endpoints((string) $cmd, 1024, true, '[...data-longer-than-1024-bytes-is-not-logged-all-here...]'), 'time' => Smart::format_number_dec($time_end, 9, '.', ''), 'connection' => (string) $this->socket]);
         //--
     }
     //end if
     //--
     return $response;
     //--
 }