46 private final function __construct()
64 if (function_exists(
'set_time_limit')) {
65 @set_time_limit($time_limit);
67 $smarty->force_compile = $force_compile;
72 $_compileDirs =
new RecursiveDirectoryIterator($_dir);
73 $_compile =
new RecursiveIteratorIterator($_compileDirs);
74 foreach ($_compile as $_fileinfo) {
75 $_file = $_fileinfo->getFilename();
76 if (substr(basename($_fileinfo->getPathname()),0,1) ==
'.' || strpos($_file,
'.svn') !==
false)
continue;
78 if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
79 $_template_file = $_file;
81 $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
83 echo
'<br>', $_dir,
'---', $_template_file;
85 $_start_time = microtime(
true);
87 $_tpl = $smarty->
createTemplate($_template_file,null,null,null,
false);
88 if ($_tpl->mustCompile()) {
89 $_tpl->compileTemplateSource();
91 echo
' compiled in ', microtime(
true) - $_start_time,
' seconds';
94 echo
' is up to date';
98 catch (Exception $e) {
99 echo
'Error: ', $e->getMessage(),
"<br><br>";
103 $smarty->template_objects = array();
104 $_tpl->smarty->template_objects = array();
106 if ($max_errors !== null && $_error_count == $max_errors) {
107 echo
'<br><br>too many errors';
128 if (function_exists(
'set_time_limit')) {
129 @set_time_limit($time_limit);
131 $smarty->force_compile = $force_compile;
136 $_compileDirs =
new RecursiveDirectoryIterator($_dir);
137 $_compile =
new RecursiveIteratorIterator($_compileDirs);
138 foreach ($_compile as $_fileinfo) {
139 $_file = $_fileinfo->getFilename();
140 if (substr(basename($_fileinfo->getPathname()),0,1) ==
'.' || strpos($_file,
'.svn') !==
false)
continue;
142 if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
143 $_config_file = $_file;
145 $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
147 echo
'<br>', $_dir,
'---', $_config_file;
149 $_start_time = microtime(
true);
152 if ($_config->mustCompile()) {
153 $_config->compileConfigSource();
155 echo
' compiled in ', microtime(
true) - $_start_time,
' seconds';
158 echo
' is up to date';
162 catch (Exception $e) {
163 echo
'Error: ', $e->getMessage(),
"<br><br>";
166 if ($max_errors !== null && $_error_count == $max_errors) {
167 echo
'<br><br>too many errors';
187 $_compile_id = isset($compile_id) ? preg_replace(
'![^\w\|]+!',
'_', $compile_id) : null;
188 $_dir_sep = $smarty->use_sub_dirs ? DS :
'^';
189 if (isset($resource_name)) {
190 $_save_stat = $smarty->caching;
191 $smarty->caching =
false;
192 $tpl =
new $smarty->template_class($resource_name, $smarty);
193 $smarty->caching = $_save_stat;
197 if ($smarty->allow_ambiguous_resources) {
198 $_templateId =
$tpl->source->unique_resource .
$tpl->cache_id .
$tpl->compile_id;
200 $_templateId = $smarty->joined_template_dir .
'#' . $resource_name .
$tpl->cache_id .
$tpl->compile_id;
202 if (isset($_templateId[150])) {
203 $_templateId = sha1($_templateId);
205 unset($smarty->template_objects[$_templateId]);
207 if (
$tpl->source->exists) {
208 $_resource_part_1 = basename(str_replace(
'^',
'/',
$tpl->compiled->filepath));
209 $_resource_part_1_length = strlen($_resource_part_1);
214 $_resource_part_2 = str_replace(
'.php',
'.cache.php',$_resource_part_1);
215 $_resource_part_2_length = strlen($_resource_part_2);
217 $_dir = $_compile_dir;
218 if ($smarty->use_sub_dirs && isset($_compile_id)) {
219 $_dir .= $_compile_id . $_dir_sep;
221 if (isset($_compile_id)) {
222 $_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep;
223 $_compile_id_part_length = strlen($_compile_id_part);
227 $_compileDirs =
new RecursiveDirectoryIterator($_dir);
229 }
catch (Exception $e) {
232 $_compile =
new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
233 foreach ($_compile as $_file) {
234 if (substr(basename($_file->getPathname()), 0, 1) ==
'.' || strpos($_file,
'.svn') !==
false)
237 $_filepath = (string) $_file;
239 if ($_file->isDir()) {
240 if (!$_compile->isDot()) {
242 @rmdir($_file->getPathname());
246 if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length)))
247 && (!isset($resource_name)
248 || (isset($_filepath[$_resource_part_1_length])
249 && substr_compare($_filepath, $_resource_part_1, -$_resource_part_1_length, $_resource_part_1_length) == 0)
250 || (isset($_filepath[$_resource_part_2_length])
251 && substr_compare($_filepath, $_resource_part_2, -$_resource_part_2_length, $_resource_part_2_length) == 0))) {
252 if (isset($exp_time)) {
253 if (time() - @filemtime($_filepath) >= $exp_time) {
261 if ($unlink && @unlink($_filepath)) {
280 $template->smarty->get_used_tags =
true;
282 return $template->used_tags;
299 if ($errors === null) {
301 echo
"Smarty Installation test...\n";
302 echo
"Testing template directory...\n";
305 $_stream_resolve_include_path = function_exists(
'stream_resolve_include_path');
309 $_template_dir = $template_dir;
310 $template_dir = realpath($template_dir);
312 if (!$template_dir) {
313 if ($smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
315 if ($_stream_resolve_include_path) {
316 $template_dir = stream_resolve_include_path($_template_dir);
321 if ($template_dir !==
false) {
322 if ($errors === null) {
323 echo
"$template_dir is OK.\n";
329 $message =
"FAILED: $_template_dir does not exist (and couldn't be found in include_path either)";
330 if ($errors === null) {
331 echo $message .
".\n";
333 $errors[
'template_dir'] = $message;
340 $message =
"FAILED: $_template_dir does not exist";
341 if ($errors === null) {
342 echo $message .
".\n";
344 $errors[
'template_dir'] = $message;
351 if (!is_dir($template_dir)) {
353 $message =
"FAILED: $template_dir is not a directory";
354 if ($errors === null) {
355 echo $message .
".\n";
357 $errors[
'template_dir'] = $message;
359 }
elseif (!is_readable($template_dir)) {
361 $message =
"FAILED: $template_dir is not readable";
362 if ($errors === null) {
363 echo $message .
".\n";
365 $errors[
'template_dir'] = $message;
368 if ($errors === null) {
369 echo
"$template_dir is OK.\n";
375 if ($errors === null) {
376 echo
"Testing compile directory...\n";
381 $_compile_dir = realpath($__compile_dir);
382 if (!$_compile_dir) {
384 $message =
"FAILED: {$__compile_dir} does not exist";
385 if ($errors === null) {
386 echo $message .
".\n";
388 $errors[
'compile_dir'] = $message;
390 }
elseif (!is_dir($_compile_dir)) {
392 $message =
"FAILED: {$_compile_dir} is not a directory";
393 if ($errors === null) {
394 echo $message .
".\n";
396 $errors[
'compile_dir'] = $message;
398 }
elseif (!is_readable($_compile_dir)) {
400 $message =
"FAILED: {$_compile_dir} is not readable";
401 if ($errors === null) {
402 echo $message .
".\n";
404 $errors[
'compile_dir'] = $message;
406 }
elseif (!is_writable($_compile_dir)) {
408 $message =
"FAILED: {$_compile_dir} is not writable";
409 if ($errors === null) {
410 echo $message .
".\n";
412 $errors[
'compile_dir'] = $message;
415 if ($errors === null) {
416 echo
"{$_compile_dir} is OK.\n";
421 if ($errors === null) {
422 echo
"Testing plugins directory...\n";
427 $_core_plugins_dir = realpath(dirname(__FILE__) .
'/../plugins');
428 $_core_plugins_available =
false;
430 $_plugin_dir = $plugin_dir;
431 $plugin_dir = realpath($plugin_dir);
434 if ($smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
436 if ($_stream_resolve_include_path) {
437 $plugin_dir = stream_resolve_include_path($_plugin_dir);
442 if ($plugin_dir !==
false) {
443 if ($errors === null) {
444 echo
"$plugin_dir is OK.\n";
450 $message =
"FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)";
451 if ($errors === null) {
452 echo $message .
".\n";
454 $errors[
'plugins_dir'] = $message;
461 $message =
"FAILED: $_plugin_dir does not exist";
462 if ($errors === null) {
463 echo $message .
".\n";
465 $errors[
'plugins_dir'] = $message;
472 if (!is_dir($plugin_dir)) {
474 $message =
"FAILED: $plugin_dir is not a directory";
475 if ($errors === null) {
476 echo $message .
".\n";
478 $errors[
'plugins_dir'] = $message;
480 }
elseif (!is_readable($plugin_dir)) {
482 $message =
"FAILED: $plugin_dir is not readable";
483 if ($errors === null) {
484 echo $message .
".\n";
486 $errors[
'plugins_dir'] = $message;
488 }
elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
489 $_core_plugins_available =
true;
490 if ($errors === null) {
491 echo
"$plugin_dir is OK.\n";
494 if ($errors === null) {
495 echo
"$plugin_dir is OK.\n";
499 if (!$_core_plugins_available) {
501 $message =
"WARNING: Smarty's own libs/plugins is not available";
502 if ($errors === null) {
503 echo $message .
".\n";
504 }
elseif (!isset($errors[
'plugins_dir'])) {
505 $errors[
'plugins_dir'] = $message;
509 if ($errors === null) {
510 echo
"Testing cache directory...\n";
516 $_cache_dir = realpath($__cache_dir);
519 $message =
"FAILED: {$__cache_dir} does not exist";
520 if ($errors === null) {
521 echo $message .
".\n";
523 $errors[
'cache_dir'] = $message;
525 }
elseif (!is_dir($_cache_dir)) {
527 $message =
"FAILED: {$_cache_dir} is not a directory";
528 if ($errors === null) {
529 echo $message .
".\n";
531 $errors[
'cache_dir'] = $message;
533 }
elseif (!is_readable($_cache_dir)) {
535 $message =
"FAILED: {$_cache_dir} is not readable";
536 if ($errors === null) {
537 echo $message .
".\n";
539 $errors[
'cache_dir'] = $message;
541 }
elseif (!is_writable($_cache_dir)) {
543 $message =
"FAILED: {$_cache_dir} is not writable";
544 if ($errors === null) {
545 echo $message .
".\n";
547 $errors[
'cache_dir'] = $message;
550 if ($errors === null) {
551 echo
"{$_cache_dir} is OK.\n";
556 if ($errors === null) {
557 echo
"Testing configs directory...\n";
562 $_config_dir = $config_dir;
563 $config_dir = realpath($config_dir);
566 if ($smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
568 if ($_stream_resolve_include_path) {
569 $config_dir = stream_resolve_include_path($_config_dir);
574 if ($config_dir !==
false) {
575 if ($errors === null) {
576 echo
"$config_dir is OK.\n";
582 $message =
"FAILED: $_config_dir does not exist (and couldn't be found in include_path either)";
583 if ($errors === null) {
584 echo $message .
".\n";
586 $errors[
'config_dir'] = $message;
593 $message =
"FAILED: $_config_dir does not exist";
594 if ($errors === null) {
595 echo $message .
".\n";
597 $errors[
'config_dir'] = $message;
604 if (!is_dir($config_dir)) {
606 $message =
"FAILED: $config_dir is not a directory";
607 if ($errors === null) {
608 echo $message .
".\n";
610 $errors[
'config_dir'] = $message;
612 }
elseif (!is_readable($config_dir)) {
614 $message =
"FAILED: $config_dir is not readable";
615 if ($errors === null) {
616 echo $message .
".\n";
618 $errors[
'config_dir'] = $message;
621 if ($errors === null) {
622 echo
"$config_dir is OK.\n";
628 if ($errors === null) {
629 echo
"Testing sysplugin files...\n";
632 $source = SMARTY_SYSPLUGINS_DIR;
633 if (is_dir($source)) {
635 "smarty_cacheresource.php" =>
true,
636 "smarty_cacheresource_custom.php" =>
true,
637 "smarty_cacheresource_keyvaluestore.php" =>
true,
638 "smarty_config_source.php" =>
true,
639 "smarty_internal_cacheresource_file.php" =>
true,
640 "smarty_internal_compile_append.php" =>
true,
641 "smarty_internal_compile_assign.php" =>
true,
642 "smarty_internal_compile_block.php" =>
true,
643 "smarty_internal_compile_break.php" =>
true,
644 "smarty_internal_compile_call.php" =>
true,
645 "smarty_internal_compile_capture.php" =>
true,
646 "smarty_internal_compile_config_load.php" =>
true,
647 "smarty_internal_compile_continue.php" =>
true,
648 "smarty_internal_compile_debug.php" =>
true,
649 "smarty_internal_compile_eval.php" =>
true,
650 "smarty_internal_compile_extends.php" =>
true,
651 "smarty_internal_compile_for.php" =>
true,
652 "smarty_internal_compile_foreach.php" =>
true,
653 "smarty_internal_compile_function.php" =>
true,
654 "smarty_internal_compile_if.php" =>
true,
655 "smarty_internal_compile_include.php" =>
true,
656 "smarty_internal_compile_include_php.php" =>
true,
657 "smarty_internal_compile_insert.php" =>
true,
658 "smarty_internal_compile_ldelim.php" =>
true,
659 "smarty_internal_compile_nocache.php" =>
true,
660 "smarty_internal_compile_private_block_plugin.php" =>
true,
661 "smarty_internal_compile_private_function_plugin.php" =>
true,
662 "smarty_internal_compile_private_modifier.php" =>
true,
663 "smarty_internal_compile_private_object_block_function.php" =>
true,
664 "smarty_internal_compile_private_object_function.php" =>
true,
665 "smarty_internal_compile_private_print_expression.php" =>
true,
666 "smarty_internal_compile_private_registered_block.php" =>
true,
667 "smarty_internal_compile_private_registered_function.php" =>
true,
668 "smarty_internal_compile_private_special_variable.php" =>
true,
669 "smarty_internal_compile_rdelim.php" =>
true,
670 "smarty_internal_compile_section.php" =>
true,
671 "smarty_internal_compile_setfilter.php" =>
true,
672 "smarty_internal_compile_while.php" =>
true,
673 "smarty_internal_compilebase.php" =>
true,
674 "smarty_internal_config.php" =>
true,
675 "smarty_internal_config_file_compiler.php" =>
true,
676 "smarty_internal_configfilelexer.php" =>
true,
677 "smarty_internal_configfileparser.php" =>
true,
678 "smarty_internal_data.php" =>
true,
679 "smarty_internal_debug.php" =>
true,
680 "smarty_internal_filter_handler.php" =>
true,
681 "smarty_internal_function_call_handler.php" =>
true,
682 "smarty_internal_get_include_path.php" =>
true,
683 "smarty_internal_nocache_insert.php" =>
true,
684 "smarty_internal_parsetree.php" =>
true,
685 "smarty_internal_resource_eval.php" =>
true,
686 "smarty_internal_resource_extends.php" =>
true,
687 "smarty_internal_resource_file.php" =>
true,
688 "smarty_internal_resource_registered.php" =>
true,
689 "smarty_internal_resource_stream.php" =>
true,
690 "smarty_internal_resource_string.php" =>
true,
691 "smarty_internal_smartytemplatecompiler.php" =>
true,
692 "smarty_internal_template.php" =>
true,
693 "smarty_internal_templatebase.php" =>
true,
694 "smarty_internal_templatecompilerbase.php" =>
true,
695 "smarty_internal_templatelexer.php" =>
true,
696 "smarty_internal_templateparser.php" =>
true,
697 "smarty_internal_utility.php" =>
true,
698 "smarty_internal_write_file.php" =>
true,
699 "smarty_resource.php" =>
true,
700 "smarty_resource_custom.php" =>
true,
701 "smarty_resource_recompiled.php" =>
true,
702 "smarty_resource_uncompiled.php" =>
true,
703 "smarty_security.php" =>
true,
705 $iterator =
new DirectoryIterator($source);
706 foreach ($iterator as $file) {
707 if (!$file->isDot()) {
710 unset($expected[$filename]);
716 $message =
"FAILED: files missing from libs/sysplugins: ". join(
', ', array_keys($expected));
717 if ($errors === null) {
718 echo $message .
".\n";
720 $errors[
'sysplugins'] = $message;
722 }
elseif ($errors === null) {
727 $message =
"FAILED: ". SMARTY_SYSPLUGINS_DIR .
' is not a directory';
728 if ($errors === null) {
729 echo $message .
".\n";
731 $errors[
'sysplugins_dir_constant'] = $message;
735 if ($errors === null) {
736 echo
"Testing plugin files...\n";
739 $source = SMARTY_PLUGINS_DIR;
740 if (is_dir($source)) {
742 "block.textformat.php" =>
true,
743 "function.counter.php" =>
true,
744 "function.cycle.php" =>
true,
745 "function.fetch.php" =>
true,
746 "function.html_checkboxes.php" =>
true,
747 "function.html_image.php" =>
true,
748 "function.html_options.php" =>
true,
749 "function.html_radios.php" =>
true,
750 "function.html_select_date.php" =>
true,
751 "function.html_select_time.php" =>
true,
752 "function.html_table.php" =>
true,
753 "function.mailto.php" =>
true,
754 "function.math.php" =>
true,
755 "modifier.capitalize.php" =>
true,
756 "modifier.date_format.php" =>
true,
757 "modifier.debug_print_var.php" =>
true,
758 "modifier.escape.php" =>
true,
759 "modifier.regex_replace.php" =>
true,
760 "modifier.replace.php" =>
true,
761 "modifier.spacify.php" =>
true,
762 "modifier.truncate.php" =>
true,
763 "modifiercompiler.cat.php" =>
true,
764 "modifiercompiler.count_characters.php" =>
true,
765 "modifiercompiler.count_paragraphs.php" =>
true,
766 "modifiercompiler.count_sentences.php" =>
true,
767 "modifiercompiler.count_words.php" =>
true,
768 "modifiercompiler.default.php" =>
true,
769 "modifiercompiler.escape.php" =>
true,
770 "modifiercompiler.from_charset.php" =>
true,
771 "modifiercompiler.indent.php" =>
true,
772 "modifiercompiler.lower.php" =>
true,
773 "modifiercompiler.noprint.php" =>
true,
774 "modifiercompiler.string_format.php" =>
true,
775 "modifiercompiler.strip.php" =>
true,
776 "modifiercompiler.strip_tags.php" =>
true,
777 "modifiercompiler.to_charset.php" =>
true,
778 "modifiercompiler.unescape.php" =>
true,
779 "modifiercompiler.upper.php" =>
true,
780 "modifiercompiler.wordwrap.php" =>
true,
781 "outputfilter.trimwhitespace.php" =>
true,
782 "shared.escape_special_chars.php" =>
true,
783 "shared.literal_compiler_param.php" =>
true,
784 "shared.make_timestamp.php" =>
true,
785 "shared.mb_str_replace.php" =>
true,
786 "shared.mb_unicode.php" =>
true,
787 "shared.mb_wordwrap.php" =>
true,
788 "variablefilter.htmlspecialchars.php" =>
true,
790 $iterator =
new DirectoryIterator($source);
791 foreach ($iterator as $file) {
792 if (!$file->isDot()) {
795 unset($expected[$filename]);
801 $message =
"FAILED: files missing from libs/plugins: ". join(
', ', array_keys($expected));
802 if ($errors === null) {
803 echo $message .
".\n";
805 $errors[
'plugins'] = $message;
807 }
elseif ($errors === null) {
812 $message =
"FAILED: ". SMARTY_PLUGINS_DIR .
' is not a directory';
813 if ($errors === null) {
814 echo $message .
".\n";
816 $errors[
'plugins_dir_constant'] = $message;
820 if ($errors === null) {
821 echo
"Tests complete.\n";
static testInstall(Smarty $smarty, &$errors=null)
diagnose Smarty setup
createTemplate($template, $cache_id=null, $compile_id=null, $parent=null, $do_clone=true)
creates a template object
static compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
Compile all template files.
static getIncludePath($filepath)
Return full file path from PHP include_path.
static getTags(Smarty_Internal_Template $template)
Return array of tag/attributes of all tags used by an template.
getConfigDir($index=null)
Get config directory.
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
static clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
Delete compiled template file.
static compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
Compile all config files.
getPluginsDir()
Get plugin directories.
Smarty plugin to format text blocks.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
getTemplateDir($index=null)
Get template directories.
compileTemplateSource()
Compiles the template.
getCompileDir()
Get compiled directory.
getCacheDir()
Get cache directory.