/** returns the value for $string **/
function getPref($username, $string) {
$filename = "../data/$username.pref";
+ if (!file_exists($filename)) {
+ echo "Preference file \"$filename\" not found. Exiting abnormally";
+ exit;
+ }
+
$file = fopen($filename, "r");
/** read in all the preferences **/
$pref = fgets($file, 1024);
if (substr($pref, 0, strpos($pref, "=")) == $string) {
fclose($file);
- return substr($pref, strpos($pref, "=")+1);
+ return trim(substr($pref, strpos($pref, "=")+1));
}
}
fclose($file);
/** This checks if there is a pref file, if there isn't, it will create it. **/
function checkForPrefs($username) {
- $filename = "../data/default_pref";
+ $filename = "../data/$username.pref";
if (!file_exists($filename)) {
- if (!copy("../config/default.pref", $filename)) {
+ if (!copy("../data/default_pref", $filename)) {
echo "Error opening $filename";
exit;
}