31 if ($errors === null) {
33 echo
"Smarty Installation test...\n";
34 echo
"Testing template directory...\n";
37 $_stream_resolve_include_path = function_exists(
'stream_resolve_include_path');
41 $_template_dir = $template_dir;
42 $template_dir = realpath($template_dir);
45 if ($smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
47 if ($_stream_resolve_include_path) {
48 $template_dir = stream_resolve_include_path($_template_dir);
53 if ($template_dir !==
false) {
54 if ($errors === null) {
55 echo
"$template_dir is OK.\n";
61 $message =
"FAILED: $_template_dir does not exist (and couldn't be found in include_path either)";
62 if ($errors === null) {
63 echo $message .
".\n";
65 $errors[
'template_dir'] = $message;
72 $message =
"FAILED: $_template_dir does not exist";
73 if ($errors === null) {
74 echo $message .
".\n";
76 $errors[
'template_dir'] = $message;
83 if (!is_dir($template_dir)) {
85 $message =
"FAILED: $template_dir is not a directory";
86 if ($errors === null) {
87 echo $message .
".\n";
89 $errors[
'template_dir'] = $message;
91 } elseif (!is_readable($template_dir)) {
93 $message =
"FAILED: $template_dir is not readable";
94 if ($errors === null) {
95 echo $message .
".\n";
97 $errors[
'template_dir'] = $message;
100 if ($errors === null) {
101 echo
"$template_dir is OK.\n";
106 if ($errors === null) {
107 echo
"Testing compile directory...\n";
112 $_compile_dir = realpath($__compile_dir);
113 if (!$_compile_dir) {
115 $message =
"FAILED: {$__compile_dir} does not exist";
116 if ($errors === null) {
117 echo $message .
".\n";
119 $errors[
'compile_dir'] = $message;
121 } elseif (!is_dir($_compile_dir)) {
123 $message =
"FAILED: {$_compile_dir} is not a directory";
124 if ($errors === null) {
125 echo $message .
".\n";
127 $errors[
'compile_dir'] = $message;
129 } elseif (!is_readable($_compile_dir)) {
131 $message =
"FAILED: {$_compile_dir} is not readable";
132 if ($errors === null) {
133 echo $message .
".\n";
135 $errors[
'compile_dir'] = $message;
137 } elseif (!is_writable($_compile_dir)) {
139 $message =
"FAILED: {$_compile_dir} is not writable";
140 if ($errors === null) {
141 echo $message .
".\n";
143 $errors[
'compile_dir'] = $message;
146 if ($errors === null) {
147 echo
"{$_compile_dir} is OK.\n";
151 if ($errors === null) {
152 echo
"Testing plugins directory...\n";
157 $_core_plugins_dir = realpath(dirname(__FILE__) .
'/../plugins');
158 $_core_plugins_available =
false;
160 $_plugin_dir = $plugin_dir;
161 $plugin_dir = realpath($plugin_dir);
164 if ($smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
166 if ($_stream_resolve_include_path) {
167 $plugin_dir = stream_resolve_include_path($_plugin_dir);
172 if ($plugin_dir !==
false) {
173 if ($errors === null) {
174 echo
"$plugin_dir is OK.\n";
180 $message =
"FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)";
181 if ($errors === null) {
182 echo $message .
".\n";
184 $errors[
'plugins_dir'] = $message;
191 $message =
"FAILED: $_plugin_dir does not exist";
192 if ($errors === null) {
193 echo $message .
".\n";
195 $errors[
'plugins_dir'] = $message;
202 if (!is_dir($plugin_dir)) {
204 $message =
"FAILED: $plugin_dir is not a directory";
205 if ($errors === null) {
206 echo $message .
".\n";
208 $errors[
'plugins_dir'] = $message;
210 } elseif (!is_readable($plugin_dir)) {
212 $message =
"FAILED: $plugin_dir is not readable";
213 if ($errors === null) {
214 echo $message .
".\n";
216 $errors[
'plugins_dir'] = $message;
218 } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
219 $_core_plugins_available =
true;
220 if ($errors === null) {
221 echo
"$plugin_dir is OK.\n";
224 if ($errors === null) {
225 echo
"$plugin_dir is OK.\n";
229 if (!$_core_plugins_available) {
231 $message =
"WARNING: Smarty's own libs/plugins is not available";
232 if ($errors === null) {
233 echo $message .
".\n";
234 } elseif (!isset($errors[
'plugins_dir'])) {
235 $errors[
'plugins_dir'] = $message;
239 if ($errors === null) {
240 echo
"Testing cache directory...\n";
245 $_cache_dir = realpath($__cache_dir);
248 $message =
"FAILED: {$__cache_dir} does not exist";
249 if ($errors === null) {
250 echo $message .
".\n";
252 $errors[
'cache_dir'] = $message;
254 } elseif (!is_dir($_cache_dir)) {
256 $message =
"FAILED: {$_cache_dir} is not a directory";
257 if ($errors === null) {
258 echo $message .
".\n";
260 $errors[
'cache_dir'] = $message;
262 } elseif (!is_readable($_cache_dir)) {
264 $message =
"FAILED: {$_cache_dir} is not readable";
265 if ($errors === null) {
266 echo $message .
".\n";
268 $errors[
'cache_dir'] = $message;
270 } elseif (!is_writable($_cache_dir)) {
272 $message =
"FAILED: {$_cache_dir} is not writable";
273 if ($errors === null) {
274 echo $message .
".\n";
276 $errors[
'cache_dir'] = $message;
279 if ($errors === null) {
280 echo
"{$_cache_dir} is OK.\n";
284 if ($errors === null) {
285 echo
"Testing configs directory...\n";
290 $_config_dir = $config_dir;
291 $config_dir = realpath($config_dir);
294 if ($smarty->use_include_path && !preg_match(
'/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
296 if ($_stream_resolve_include_path) {
297 $config_dir = stream_resolve_include_path($_config_dir);
302 if ($config_dir !==
false) {
303 if ($errors === null) {
304 echo
"$config_dir is OK.\n";
310 $message =
"FAILED: $_config_dir does not exist (and couldn't be found in include_path either)";
311 if ($errors === null) {
312 echo $message .
".\n";
314 $errors[
'config_dir'] = $message;
321 $message =
"FAILED: $_config_dir does not exist";
322 if ($errors === null) {
323 echo $message .
".\n";
325 $errors[
'config_dir'] = $message;
332 if (!is_dir($config_dir)) {
334 $message =
"FAILED: $config_dir is not a directory";
335 if ($errors === null) {
336 echo $message .
".\n";
338 $errors[
'config_dir'] = $message;
340 } elseif (!is_readable($config_dir)) {
342 $message =
"FAILED: $config_dir is not readable";
343 if ($errors === null) {
344 echo $message .
".\n";
346 $errors[
'config_dir'] = $message;
349 if ($errors === null) {
350 echo
"$config_dir is OK.\n";
355 if ($errors === null) {
356 echo
"Testing sysplugin files...\n";
359 $source = SMARTY_SYSPLUGINS_DIR;
360 if (is_dir($source)) {
362 "smarty_cacheresource.php" =>
true,
363 "smarty_cacheresource_custom.php" =>
true,
364 "smarty_cacheresource_keyvaluestore.php" =>
true,
365 "smarty_data.php" =>
true,
366 "smarty_internal_cacheresource_file.php" =>
true,
367 "smarty_internal_compile_append.php" =>
true,
368 "smarty_internal_compile_assign.php" =>
true,
369 "smarty_internal_compile_block.php" =>
true,
370 "smarty_internal_compile_break.php" =>
true,
371 "smarty_internal_compile_call.php" =>
true,
372 "smarty_internal_compile_capture.php" =>
true,
373 "smarty_internal_compile_config_load.php" =>
true,
374 "smarty_internal_compile_continue.php" =>
true,
375 "smarty_internal_compile_debug.php" =>
true,
376 "smarty_internal_compile_eval.php" =>
true,
377 "smarty_internal_compile_extends.php" =>
true,
378 "smarty_internal_compile_for.php" =>
true,
379 "smarty_internal_compile_foreach.php" =>
true,
380 "smarty_internal_compile_function.php" =>
true,
381 "smarty_internal_compile_if.php" =>
true,
382 "smarty_internal_compile_include.php" =>
true,
383 "smarty_internal_compile_include_php.php" =>
true,
384 "smarty_internal_compile_insert.php" =>
true,
385 "smarty_internal_compile_ldelim.php" =>
true,
386 "smarty_internal_compile_nocache.php" =>
true,
387 "smarty_internal_compile_private_block_plugin.php" =>
true,
388 "smarty_internal_compile_private_function_plugin.php" =>
true,
389 "smarty_internal_compile_private_modifier.php" =>
true,
390 "smarty_internal_compile_private_object_block_function.php" =>
true,
391 "smarty_internal_compile_private_object_function.php" =>
true,
392 "smarty_internal_compile_private_print_expression.php" =>
true,
393 "smarty_internal_compile_private_registered_block.php" =>
true,
394 "smarty_internal_compile_private_registered_function.php" =>
true,
395 "smarty_internal_compile_private_special_variable.php" =>
true,
396 "smarty_internal_compile_rdelim.php" =>
true,
397 "smarty_internal_compile_section.php" =>
true,
398 "smarty_internal_compile_setfilter.php" =>
true,
399 "smarty_internal_compile_while.php" =>
true,
400 "smarty_internal_compilebase.php" =>
true,
401 "smarty_internal_config_file_compiler.php" =>
true,
402 "smarty_internal_configfilelexer.php" =>
true,
403 "smarty_internal_configfileparser.php" =>
true,
404 "smarty_internal_data.php" =>
true,
405 "smarty_internal_debug.php" =>
true,
406 "smarty_internal_extension_codeframe.php" =>
true,
407 "smarty_internal_extension_config.php" =>
true,
408 "smarty_internal_extension_defaulttemplatehandler.php" =>
true,
409 "smarty_internal_filter_handler.php" =>
true,
410 "smarty_internal_function_call_handler.php" =>
true,
411 "smarty_internal_get_include_path.php" =>
true,
412 "smarty_internal_nocache_insert.php" =>
true,
413 "smarty_internal_parsetree.php" =>
true,
414 "smarty_internal_parsetree_code.php" =>
true,
415 "smarty_internal_parsetree_dq.php" =>
true,
416 "smarty_internal_parsetree_dqcontent.php" =>
true,
417 "smarty_internal_parsetree_tag.php" =>
true,
418 "smarty_internal_parsetree_template.php" =>
true,
419 "smarty_internal_parsetree_text.php" =>
true,
420 "smarty_internal_resource_eval.php" =>
true,
421 "smarty_internal_resource_extends.php" =>
true,
422 "smarty_internal_resource_file.php" =>
true,
423 "smarty_internal_resource_php.php" =>
true,
424 "smarty_internal_resource_registered.php" =>
true,
425 "smarty_internal_resource_stream.php" =>
true,
426 "smarty_internal_resource_string.php" =>
true,
427 "smarty_internal_smartytemplatecompiler.php" =>
true,
428 "smarty_internal_template.php" =>
true,
429 "smarty_internal_templatebase.php" =>
true,
430 "smarty_internal_templatecompilerbase.php" =>
true,
431 "smarty_internal_templatelexer.php" =>
true,
432 "smarty_internal_templateparser.php" =>
true,
433 "smarty_internal_utility.php" =>
true,
434 "smarty_internal_write_file.php" =>
true,
435 "smarty_resource.php" =>
true,
436 "smarty_resource_custom.php" =>
true,
437 "smarty_resource_recompiled.php" =>
true,
438 "smarty_resource_uncompiled.php" =>
true,
439 "smarty_security.php" =>
true,
440 "smarty_template_cached.php" =>
true,
441 "smarty_template_compiled.php" =>
true,
442 "smarty_template_config.php" =>
true,
443 "smarty_template_source.php" =>
true,
444 "smarty_undefined_variable.php" =>
true,
445 "smarty_variable.php" =>
true,
446 "smartycompilerexception.php" =>
true,
447 "smartyexception.php" =>
true,
449 $iterator =
new DirectoryIterator($source);
450 foreach ($iterator as $file) {
451 if (!$file->isDot()) {
452 $filename = $file->getFilename();
453 if (isset($expected[$filename])) {
454 unset($expected[$filename]);
460 $message =
"FAILED: files missing from libs/sysplugins: " . join(
', ', array_keys($expected));
461 if ($errors === null) {
462 echo $message .
".\n";
464 $errors[
'sysplugins'] = $message;
466 } elseif ($errors === null) {
471 $message =
"FAILED: " . SMARTY_SYSPLUGINS_DIR .
' is not a directory';
472 if ($errors === null) {
473 echo $message .
".\n";
475 $errors[
'sysplugins_dir_constant'] = $message;
479 if ($errors === null) {
480 echo
"Testing plugin files...\n";
483 $source = SMARTY_PLUGINS_DIR;
484 if (is_dir($source)) {
486 "block.textformat.php" =>
true,
487 "function.counter.php" =>
true,
488 "function.cycle.php" =>
true,
489 "function.fetch.php" =>
true,
490 "function.html_checkboxes.php" =>
true,
491 "function.html_image.php" =>
true,
492 "function.html_options.php" =>
true,
493 "function.html_radios.php" =>
true,
494 "function.html_select_date.php" =>
true,
495 "function.html_select_time.php" =>
true,
496 "function.html_table.php" =>
true,
497 "function.mailto.php" =>
true,
498 "function.math.php" =>
true,
499 "modifier.capitalize.php" =>
true,
500 "modifier.date_format.php" =>
true,
501 "modifier.debug_print_var.php" =>
true,
502 "modifier.escape.php" =>
true,
503 "modifier.regex_replace.php" =>
true,
504 "modifier.replace.php" =>
true,
505 "modifier.spacify.php" =>
true,
506 "modifier.truncate.php" =>
true,
507 "modifiercompiler.cat.php" =>
true,
508 "modifiercompiler.count_characters.php" =>
true,
509 "modifiercompiler.count_paragraphs.php" =>
true,
510 "modifiercompiler.count_sentences.php" =>
true,
511 "modifiercompiler.count_words.php" =>
true,
512 "modifiercompiler.default.php" =>
true,
513 "modifiercompiler.escape.php" =>
true,
514 "modifiercompiler.from_charset.php" =>
true,
515 "modifiercompiler.indent.php" =>
true,
516 "modifiercompiler.lower.php" =>
true,
517 "modifiercompiler.noprint.php" =>
true,
518 "modifiercompiler.string_format.php" =>
true,
519 "modifiercompiler.strip.php" =>
true,
520 "modifiercompiler.strip_tags.php" =>
true,
521 "modifiercompiler.to_charset.php" =>
true,
522 "modifiercompiler.unescape.php" =>
true,
523 "modifiercompiler.upper.php" =>
true,
524 "modifiercompiler.wordwrap.php" =>
true,
525 "outputfilter.trimwhitespace.php" =>
true,
526 "shared.escape_special_chars.php" =>
true,
527 "shared.literal_compiler_param.php" =>
true,
528 "shared.make_timestamp.php" =>
true,
529 "shared.mb_str_replace.php" =>
true,
530 "shared.mb_unicode.php" =>
true,
531 "shared.mb_wordwrap.php" =>
true,
532 "variablefilter.htmlspecialchars.php" =>
true,
534 $iterator =
new DirectoryIterator($source);
535 foreach ($iterator as $file) {
536 if (!$file->isDot()) {
537 $filename = $file->getFilename();
538 if (isset($expected[$filename])) {
539 unset($expected[$filename]);
545 $message =
"FAILED: files missing from libs/plugins: " . join(
', ', array_keys($expected));
546 if ($errors === null) {
547 echo $message .
".\n";
549 $errors[
'plugins'] = $message;
551 } elseif ($errors === null) {
556 $message =
"FAILED: " . SMARTY_PLUGINS_DIR .
' is not a directory';
557 if ($errors === null) {
558 echo $message .
".\n";
560 $errors[
'plugins_dir_constant'] = $message;
564 if ($errors === null) {
565 echo
"Tests complete.\n";