function exec($args, $stdin, &$stdout, &$stderr, &$system) { if (!empty($args)) { $args_split = splitArgs($args); if (count($args_split) >= 2) { $name = $args_split[0]; $value = $args_split[1]; if (isset($args_split[2])) $theme = $args_split[2]; if (!isAdmin()) { $stderr = ucf(i18n("not enough rights")); return true; } $result = setSetting($name, $value, $theme); if ($result === true) $stdout = ucf(i18n("setting set successfully")); else $stdout = $result; } } else { $stdout = "Usage: sset [settingname] [value]\n"; $stdout .= "Example: sset TITLE \"Murrix title\""; } return true; }
public function process() { setSetting('routes', $this->getElementValue('routes')); }
function saveSetting($key, $value) { //echo ("Forsøker å lagre: " . $key . " med verdi: " . $value); // Fetch the datatype of the key $type = getSettingType($key); // check which type, and if the input is valid if ($type == "boolean") { $accepted_input = checkValidBoolean($value); } else { if ($type == "integer") { $accepted_input = checkValidInteger($value); } else { if ($type == "string") { $accepted_input = checkValidString($value); } else { $accepted_input = false; } } } // if input is valid for that key, save if ($accepted_input == true) { return setSetting($key, $value); } else { // not ok, failed/invalid return false; } }
<?php /***************************************************************************** * * file : settings.php * created : 2005-08-01 * copyright : (C) 2005 The ComaCMS-Team * email : comacms@williblau.de * *****************************************************************************/ /***************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * *****************************************************************************/ setSetting("default_page", "Standart Startseite", "Auf diese Seite wird jeder besucher geleitet, der keine Seite angegeben hat.", "home"); setSetting("pagename", "Seitenname", "Hier wird der Name der Seite definiert.", "ComaCMS");
} if ($_REQUEST['authentication'] == $_MGM['apiAuthentication'] && $_MGM['path'][1] == "text") { $results = databaseQuery("SELECT * FROM members WHERE preferredMethod='Text' OR preferredMethod='Both'"); $members = array(); while ($result = databaseFetchAssoc($results)) { array_push($members, $result); } header("Content-Type: application/json"); echo json_encode($members); } if (isset($_MGM['user']) && $_MGM['user']['level'] == 1 && $_MGM['path'][1] == "settings") { if ($_MGM['path'][2] == "save") { $email = isset($_REQUEST['email']) ? trim($_REQUEST['email']) : ""; $replyToEmail = isset($_REQUEST['replyToEmail']) ? trim($_REQUEST['replyToEmail']) : ""; setSetting("email", $email); setSetting("replyToEmail", $replyToEmail); } exit; } if (isset($_MGM['user']) && $_MGM['user']['level'] == 1 && $_MGM['path'][1] == "sidebar") { if ($_MGM['path'][2] == "list") { $results = databaseQuery("SELECT * FROM `sidebar` ORDER BY `order`"); while ($result = databaseFetchAssoc($results)) { ?> <tr><td class="id"><?php echo htmlspecialchars($result['id'], ENT_COMPAT | ENT_HTML401, 'UTF-8', true); ?> </td><td class="title"><?php echo htmlspecialchars($result['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8', true); ?> </td><td class="url"><?php
function actionFinish(&$system, $args) { global $abspath, $db_prefix, $root_id, $anonymous_id; $db_prefix = $this->db['prefix']; if (empty($args['theme'])) { $system->addAlert("You must enter select a theme"); return; } if (empty($args['imgsize'])) { $system->addAlert("You must enter a imagesize"); return; } if (empty($args['thumbsize'])) { $system->addAlert("You must enter a thumbnailsize"); return; } if (empty($args['default_lang'])) { $system->addAlert("You must enter a default language"); return; } if (empty($args['default_path'])) { $system->addAlert("You must enter a default path"); return; } if (empty($args['password'])) { $system->addAlert("You must enter a password"); return; } unset($args['action']); $this->config = $args; $logtext = ""; if (!$db_conn = mysql_pconnect($this->db['adress'], $this->db['username'], $this->db['password'])) { $system->addAlert("Error connecting to MySQL: " . mysql_errno() . " " . mysql_error()); return; } if (!mysql_select_db($this->db['name'])) { if (mysql_query("CREATE DATABASE `".$this->db['name']."`")) $logtext .= "Database ".$this->db['name']." created.<br/>"; else { $system->addAlert("Failed to create database ".$this->db['name'].". Error: " . mysql_errno() . " " . mysql_error()); return; } } mysql_select_db($this->db['name']); $files = GetSubfiles("$abspath/scripts/install/db"); foreach ($files as $file) { $query = "DROP TABLE IF EXISTS `".$this->db['prefix'].basename($file, ".sql")."`"; mysql_query($query); $query = str_replace("%PREFIX%", $this->db['prefix'], implode("", file("$abspath/scripts/install/db/$file"))); if (mysql_query($query)) $logtext .= "Imported $file successfully.<br/>"; else { $system->addAlert("Failed to import $file. Error: " . mysql_errno() . " " . mysql_error()."\n$query"); return; } } $xml = new mXml(); $files = GetSubfiles("$abspath/scripts/install/classes"); foreach ($files as $file) { $filedata = getFileData($file, "$abspath/scripts/install/classes/$file"); $msgid = $xml->parseXML(array("node_id" => 0, "data" => $filedata)); $logtext .= mMsg::getText($msgid); if (mMsg::isError($msgid)) { $system->addAlert(mMsg::getError($msgid)); return; } else $logtext .= "Imported $file successfully.<br/>"; } $files = GetSubfiles("$abspath/scripts/install/objects"); foreach ($files as $file) { $filedata = getFileData($file, "$abspath/scripts/install/objects/$file"); $msgid = $xml->parseXML(array("node_id" => 0, "data" => $filedata)); $logtext .= mMsg::getText($msgid); if (mMsg::isError($msgid)) { $system->addAlert(mMsg::getError($msgid)); return; } else $logtext .= "Imported $file successfully.<br/>"; } $root_id = 1; $admin_group_id = createGroup("admins", "Administrators group", true); $anon_group_id = createGroup("anonymous", "Anonymous group", false); $anon_user_id = createUserSimple("Anonymous", "anonymous", "", "", "anonymous", false); $anonymous_id = $anon_user_id; $admin_user_id = createUserSimple("Administrator", "admin", $this->config['password'], "", "admins", true); $files = GetSubfiles("$abspath/cache"); foreach ($files as $file) unlink("$abspath/cache/$file"); $files = GetSubfiles("$abspath/files"); foreach ($files as $file) unlink("$abspath/files/$file"); $files = GetSubfiles("$abspath/thumbnails"); foreach ($files as $file) unlink("$abspath/thumbnails/$file"); // Insert initial objects /* $root_obj = new mObject(); $root_obj->setClassName("folder"); $root_obj->loadVars(); $root_obj->setLanguage("eng"); $root_obj->setName("root"); $root_obj->setIcon("murrix"); $root_obj->setRights("all=r"); $root_obj->setVarValue("description", "This is the root node"); if ($root_obj->save()) { $root_obj->setMeta("initial_rights", "admins=rwc"); $logtext .= "Created ".$root_obj->getName().".<br/>"; } else { $logtext .= "Failed to create ".$root_obj->getName().".<br/>"; $logtext .= $root_obj->error; $this->done = false; } $home_obj = new mObject(); $home_obj->setClassName("folder"); $home_obj->loadVars(); $home_obj->setLanguage("eng"); $home_obj->setName("home"); $home_obj->setIcon("home"); $home_obj->setRights("all=r"); $home_obj->setVarValue("description", "This folder contain home folders"); if ($home_obj->save()) { $home_obj->linkWithNode($root_obj->getNodeId()); $logtext .= "Created ".$home_obj->getName().".<br/>"; } else { $logtext .= "Failed to create ".$home_obj->getName().".<br/>"; $logtext .= $home_obj->error; $this->done = false; } $users_home_obj = new mObject(); $users_home_obj->setClassName("folder"); $users_home_obj->loadVars(); $users_home_obj->setLanguage("eng"); $users_home_obj->setName("users"); $users_home_obj->setIcon("user"); $users_home_obj->setRights("all=r"); $users_home_obj->setVarValue("description", "This folder contain home folders"); if ($users_home_obj->save()) { $users_home_obj->linkWithNode($home_obj->getNodeId()); $logtext .= "Created ".$users_home_obj->getName().".<br/>"; } else { $logtext .= "Failed to create ".$users_home_obj->getName().".<br/>"; $logtext .= $users_home_obj->error; $this->done = false; } $group_home_obj = new mObject(); $group_home_obj->setClassName("folder"); $group_home_obj->loadVars(); $group_home_obj->setLanguage("eng"); $group_home_obj->setName("groups"); $group_home_obj->setIcon("group2"); $group_home_obj->setRights("all=r"); $users_home_obj->setVarValue("description", "This folder contain group folders"); if ($group_home_obj->save()) { $group_home_obj->linkWithNode($home_obj->getNodeId()); $logtext .= "Created ".$group_home_obj->getName().".<br/>"; } else { $logtext .= "Failed to create ".$group_home_obj->getName().".<br/>"; $logtext .= $group_home_obj->error; $this->done = false; } $adminhome_obj = new mObject(); $adminhome_obj->setClassName("folder"); $adminhome_obj->loadVars(); $adminhome_obj->setLanguage("eng"); $adminhome_obj->setName($this->admin_username); $adminhome_obj->setRights("admins=rwc"); $adminhome_obj->setVarValue("description", "This is the home for ".$this->admin_username); if ($adminhome_obj->save()) { $adminhome_obj->linkWithNode($users_home_obj->getNodeId()); $logtext .= "Created ".$adminhome_obj->getName().".<br/>"; $administrator->home_id = $adminhome_obj->getNodeId(); $administrator->save(); } else { $logtext .= "Failed to create ".$adminhome_obj->getName().".<br/>"; $logtext .= $adminhome_obj->error; $this->done = false; } $adminshome_obj = new mObject(); $adminshome_obj->setClassName("folder"); $adminshome_obj->loadVars(); $adminshome_obj->setLanguage("eng"); $adminshome_obj->setName("admins"); $adminshome_obj->setRights("admins=rwc"); $adminshome_obj->setVarValue("description", "This is the home for admins"); if ($adminshome_obj->save()) { $adminshome_obj->linkWithNode($group_home_obj->getNodeId()); $logtext .= "Created ".$adminshome_obj->getName().".<br/>"; $administrator_group->home_id = $adminshome_obj->getNodeId(); $administrator_group->save(); } else { $logtext .= "Failed to create ".$adminshome_obj->getName().".<br/>"; $logtext .= $adminshome_obj->error; $this->done = false; } $public_obj = new mObject(); $public_obj->setClassName("folder"); $public_obj->loadVars(); $public_obj->setLanguage("eng"); $public_obj->setName("public"); $public_obj->setRights("all=r"); $public_obj->setVarValue("description", "This folder is readable by anyone"); if ($public_obj->save()) { $public_obj->linkWithNode($root_obj->getNodeId()); $logtext .= "Created ".$public_obj->getName().".<br/>"; } else { $logtext .= "Failed to create ".$public_obj->getName().".<br/>"; $logtext .= $public_obj->error; $this->done = false; } */ setSetting("ROOT_NODE_ID", 1, "any"); setSetting("ANONYMOUS_ID", $anonymous->id, "any"); setSetting("TRANSPORT", $this->config['transport'], "any"); setSetting("DEFAULT_THEME", $this->config['theme'], "any"); setSetting("IMGSIZE", $this->config['imgsize'], $this->config['theme']); setSetting("THUMBSIZE", $this->config['thumbsize'], $this->config['theme']); setSetting("INSTANTTHUMBS", $this->config['instantthumbs'], $this->config['theme']); setSetting("DEFAULT_PATH", $this->config['default_path'], $this->config['theme']); setSetting("DEFAULT_LANG", $this->config['default_lang'], $this->config['theme']); $confdata = "<?\n"; $confdata .= "\$mysql_address = \"".$this->db['adress']."\";\n"; $confdata .= "\$mysql_user = \"".$this->db['username']."\";\n"; $confdata .= "\$mysql_pass = \"".$this->db['password']."\";\n"; $confdata .= "\$mysql_db = \"".$this->db['name']."\";\n"; $confdata .= "\$db_prefix = \"".$this->db['prefix']."\";\n"; $confdata .= "?>"; if (is_writable($abspath)) { $conffile = fopen("$abspath/config.inc.php", "w"); fwrite($conffile, $confdata); fclose($conffile); chmod("$abspath/config.inc.php", 0600); $logtext .= "Wrote config, $abspath/config.inc.php.<br/>"; } else { $logtext .= "Unable to write config file.<br/>"; $logtext .= "Please put the folowing into \"config.inc.php\" and place it in MURRiXs rootpath:<br/>"; $logtext .= "<br/>"; $logtext .= nl2br(htmlentities($confdata)); $logtext .= "<br/>"; } $logtext .= "Installation complete!<br/>"; $data = compiletpl("finish", array("logtext"=>$logtext)); $system->setZoneData($this->zone, utf8e($data)); $data = compiletpl("menu", array("action"=>"finish")); $system->setZoneData("zone_menu", utf8e($data)); }
<?php define("USE_GZIP", 1); require_once "overall.php"; $url = preg_replace('/\\?.*/s', '', $_SERVER['REQUEST_URI']); setSetting("index_url", ($_SERVER['SERVER_PORT'] == 443 ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $url); list($to, $back, $period) = parseToBackPeriod($_GET); $data = generateTableData($to, getSetting("cols", 30) + 1, $period, @$_GET['tag'], null, @$_GET['re']); $html = generateHtmlTableFromData($data); $SELECT_PERIODS = getPeriods(); $name = getSetting("instance"); template("index", array("title" => ($name ? $name . ": " : "") . $SELECT_PERIODS[$period] . " statistics for " . date("Y-m-d", trunkTime($to) - 1), "to" => $to, "htmlTable" => $html));
<?php if (isLoggedIn() && isAdmin()) { if (isset($_POST['save'])) { if (!isValidSessionkey()) { die("Hack attempt blocked."); } foreach ($_POST['value'] as $key => $value) { setSetting($key, $value); } header("Location: index.php?page=admin_settings"); exit; } ?> <div class="block"> <div class="blocktitle">[Admin] Settings</div> <div class="blockcontent"> <form method="post" action="index.php?page=admin_settings"> <table> <tr> <th width="25%">Key</th> <th width="75%">Value</th> </tr> <?php $res = sqlQuery("SELECT * FROM \"settings\""); foreach ($res as $row) { ?> <tr> <td><?php echo makeSafeHTML($row['Key']); ?>