public function saveToFile($path = false) { if ($path) { $savePath = $path; } else { $savePath = $this->loadedFromPath; } Website::putFileContents($savePath, '<?php' . chr(0xa) . $this->getConfigAsString() . '?>'); }
function setServerPath($newPath) { $file = fopen("./config/config.php", "r"); $lines = array(); while (!feof($file)) { $lines[] = fgets($file); } fclose($file); $newConfig = array(); foreach ($lines as $i => $line) { if (substr($line, 0, strlen('$config[\'site\'][\'serverPath\']')) == '$config[\'site\'][\'serverPath\']') { $newConfig[] = '$config[\'site\'][\'serverPath\'] = "' . str_replace('"', '\\"', $newPath) . '";' . PHP_EOL; } else { $newConfig[] = $line; } } Website::putFileContents("./config/config.php", implode('', $newConfig)); }