public function store($file, $content) { if (!isset($file) || $file == '' || !isset($content) || $content == '') { return false; } $file = absolutePath($this->_docRoot . '/' . $file); /*try {*/ if (!file_exists($file)) { $fh = fopen_recursive($file, 'w'); } else { if (!is_writable($file)) { throw new Exception(sprintf('file %s not writeable.', $file)); } else { $fh = fopen($file, 'w'); } } if (!$fh) { throw new Exception(sprintf('failed opening file %s.', $file)); } if (!flock($fh, LOCK_EX)) { throw new Exception(sprintf('failed obtaining write lock on file %s.', $file)); } fwrite($fh, $content); flock($fh, LOCK_UN); fclose($fh); /*} catch(Exception $e) { die($e->getMessage()); }*/ return true; }
function relativePath($from, $to) { $fromPath = absolutePath($from); $toPath = absolutePath($to); $fromPathParts = explode(DIRECTORY_SEPARATOR, rtrim($fromPath, DIRECTORY_SEPARATOR)); $toPathParts = explode(DIRECTORY_SEPARATOR, rtrim($toPath, DIRECTORY_SEPARATOR)); while (count($fromPathParts) && count($toPathParts) && $fromPathParts[0] == $toPathParts[0]) { array_shift($fromPathParts); array_shift($toPathParts); } return str_pad("", count($fromPathParts) * 3, '..' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $toPathParts); }
function executeSqlFile($filename, $tablePrfx = DB_TABLENAME_PREFIX, $Quiet = false) { $fp = false; if (!file_exists($filename)) { $filename = absolutePath($filename); } if (file_exists($filename)) { $fp = fopen($filename, "r"); } # show error if file could not be opened if ($fp == false) { if ($Quiet) { return false; } Fatal::error("Error reading file: " . H($filename)); } else { $dir = dirname($filename); $sql_charset = DB_CHARSET; if (file_exists($dir . "/sqlcharset.php")) { include $dir . "/sqlcharset.php"; } $this->UseLinkCharset($sql_charset); $sqlStmt = ""; while (!feof($fp)) { $char = fgetc($fp); $sqlStmt .= $char; if ($char == ";") { //replace table prefix, we're doing it here as the install script may //want to override the required prefix (eg. during upgrade / conversion //process) $sql = str_replace("%prfx%", $tablePrfx, $sqlStmt); $sql = $this->PreprocessSQL($sql); //replace ENGINE with TYPE for old MySQL versions $MySQLn = explode('.', implode('', explode('-', $this->server_info))); if ($MySQLn[0] < '5') { $sql = str_replace("ENGINE=", "TYPE=", $sql); $sql = str_replace("engine=", "type=", $sql); } else { $sql = str_replace("TYPE=", "ENGINE=", $sql); $sql = str_replace("type=", "engine=", $sql); } $this->exec($sql); $sqlStmt = ""; } } fclose($fp); } return true; }
<?php require_once '../absolutePATH.php'; $rootDIR = absolutePath('/fonts'); //print_r($rootDIR); if (is_dir($rootDIR[1])) { if ($dh = opendir($rootDIR[1])) { while (($file = readdir($dh)) !== false) { $fontProp = explode(".", $file); if (!empty($fontProp[0]) && $fontProp[1] != 'php') { echo "@font-face { font-family: '" . $fontProp[0] . "'; src: url('" . $rootDIR[2] . "/" . $fontProp[0] . "." . $fontProp[1] . "');"; } } closedir($dh); } }
<?php //this code inlines to InstallQuery.check_SqlRelations. //environment have $dir, $dir_sub, &$files, $rel_script, $script_dir echo '<h3>' . "install sql update relations on files " . '</h3>'; echo '<table> <tr>'; foreach ($files as $name) { echo '<tr><td>' . H($name) . '</td></tr>'; } echo '</table>'; $this->addNewSqlFilesInDir($files, $dir, $script_dir . '/../0.8.1/' . $dir_sub); $this->append_SqlRelations(absolutePath($dir . '/' . $script_dir . '/../0.8.1/' . $dir_sub), $files); echo '<h3>' . "install sql updated by relations " . H($script_name) . '</h3>'; echo '<table><tr>'; foreach ($files as $name) { echo '<tr><td>' . H($name) . '</td></tr>'; } echo '</table>';