function template($file) { if (!is_file($file)) { halting_error('template no encontrado ( ' . $file . ' )'); } global $template_dir; $template_dir = $file[0] == '/' ? dirname($file) : realpath(dirname(getcwd() . '/' . $file)); $compile_dir = $template_dir . '/tmp'; if (!is_writeable($compile_dir)) { halting_error('/tmp sin permisos de escritura'); } $ftime = max(filemtime($file), filemtime($_SERVER['SCRIPT_FILENAME'])); $comp = $compile_dir . '/' . basename($file) . '.php'; $file = file_get_contents($file); $file = preg_replace('/[ \\t]*<!--/', "<!--", $file); $file = preg_replace('/{{(.+)}}/U', '{UTIL::escapeHTML( $1 )}', $file); $file = preg_replace('/{([^}\\s][^}\\r\\n]*)\\s*\\|\\|\\s*(["\'].+["\'])}/', "<?php print \$1 ? \$1 : \$2; ?>", $file); $file = preg_replace('/{([^$}\\s][^\\$\\)}\\r\\n]*)}/', "<?php print \$\$1; ?>", $file); $file = preg_replace('/{([^}\\s][^}\\r\\n]*)}/', "<?php print \$1; ?>", $file); $file = str_replace(array('<!--', '-->'), array('<?php ', ' ?>'), $file); file_put_contents($comp, $file); @chmod($comp, 0664); @touch($comp, $ftime); return $comp; }
function getParametros($section) { require '../.parametros.php'; if (isset($data[$section])) { return $data[$section]; } else { halting_error('El parametro no existe'); } }
public function query($sql) { $this->sql = $sql; try { if (preg_match("/^\n(select|describe|pragma) /i", $this->sql)) { $res = $this->link->query($this->sql); } else { if (preg_match("/^\n(delete|insert|update) /i", $this->sql)) { $res = $this->link->exec($this->sql); } } } catch (PDOException $e) { halting_error('sql: ' . $this->sql . '; error: ' . $e->getMessage()); exit; } return $res; }