コード例 #1
0
ファイル: admin.config.php プロジェクト: mroussel/flatpress
 function onsave()
 {
     global $fp_config;
     $l = explode(',', $_POST['lang']);
     $fp_config['general'] = array('www' => $_POST['www'], 'title' => html_entity_decode(stripslashes($_POST['title'])), 'subtitle' => html_entity_decode(stripslashes($_POST['subtitle'])), 'footer' => html_entity_decode(stripslashes($_POST['blogfooter'])), 'author' => $_POST['author'], 'email' => $_POST['email'], 'startpage' => $_POST['startpage'] == ':NULL:' ? null : $_POST['startpage'], 'maxentries' => $_POST['maxentries'], 'notify' => isset($_POST['notify']), 'theme' => $fp_config['general']['theme'], 'style' => @$fp_config['general']['style'], 'blogid' => $fp_config['general']['blogid'], 'charset' => 'utf-8');
     $fp_config['locale'] = array('timeoffset' => $_POST['timeoffset'], 'timeformat' => $_POST['timeformat'], 'dateformat' => $_POST['dateformat'], 'dateformatshort' => $_POST['dateformatshort'], 'charset' => $_POST['charset'], 'lang' => $_POST['lang']);
     // 'LANG'	=> $l[0],
     // 'CHARSET'=> $l[1],
     $success = config_save() ? 1 : -1;
     $this->smarty->assign('success', $success);
     return 1;
 }
コード例 #2
0
 function doselect($id)
 {
     global $fp_config;
     if ($id) {
         $id = sanitize_title($id);
         if (theme_style_exists($id)) {
             $fp_config['general']['style'] = $id;
             $return = config_save() ? 1 : -1;
         } else {
             $return = -2;
         }
         $this->smarty->assign('success', $return);
         return 2;
     }
 }
コード例 #3
0
ファイル: core.plugins.php プロジェクト: mroussel/flatpress
function plugin_saveoptions($null = null)
{
    return config_save();
}
コード例 #4
0
function delete_option($name)
{
    $options = get_alloptions();
    unset($options[$name]);
    return config_save($options);
}
コード例 #5
0
ファイル: frontend.php プロジェクト: bwssytems/domuslink
    $config['heyu_subdir'] = $_POST["heyu_subdir"];
    $config['heyuconf'] = $_POST["heyuconf"];
    $config['heyuexec'] = $_POST["heyuexec"];
    $config['use_domus_security'] = $_POST["use_domus_security"];
    $config['hvac_house_code'] = $_POST["hvac_house_code"];
    $config['lang'] = $_POST["lang"];
    $config['url_path'] = $_POST["url_path"];
    $config['theme'] = $_POST["theme"];
    $config['themeview'] = $_POST["themeview"];
    $config['thememobile'] = $_POST["thememobile"];
    $config['mobileselect'] = $_POST["mobileselect"];
    $config['imgs'] = $_POST["imgs"];
    $config['codes'] = $_POST["codes"];
    $config['refresh'] = $_POST["refresh"];
    if (file_exists(CONFIG_FILE_LOCATION) && is_writable(CONFIG_FILE_LOCATION) || !file_exists(CONFIG_FILE_LOCATION)) {
        createHeyuSubdir($_POST["heyu_subdir"]);
        config_save($config);
        $_SESSION['frontObj']->getConfig(true);
        $_SESSION['frontObj']->getLanguageFile(true);
        $_SESSION['frontObj']->getHeyuConf(true);
        $_SESSION['frontObj']->getHeyuSched(true);
    } else {
        gen_error(null, CONFIG_FILE_LOCATION . " " . $lang['error_filerw']);
        exit;
    }
    header("Location: " . $_SERVER['PHP_SELF']);
    exit;
}
## Display the page
$tpl->set('content', $tpl_body);
echo $tpl->fetch(TPL_FILE_LOCATION . 'layout.tpl');
コード例 #6
0
     $xml->fritzbox->address = $r_fritzboxAddress;
     $xml->fritzbox->username = $r_fritzboxUsername;
     $xml->fritzbox->password = $r_fritzboxPassword;
     $xml->global->multiDeviceSleep = $r_multiDeviceSleep;
     $xml->gui->showDeviceStatus = $r_showDeviceStatus;
     $xml->gui->showRoomButtonInDevices = $r_showRoomButtonInDevices;
     $xml->gui->showMenuOnLoad = $r_showMenuOnLoad;
     $xml->gui->showAllOnOffBtnInMenu = $r_showAllOnOffBtnInMenu;
     $xml->gui->sortOrderDevices = $r_sortOrderDevices;
     $xml->gui->sortOrderGroups = $r_sortOrderGroups;
     $xml->gui->sortOrderRooms = $r_sortOrderRooms;
     $xml->gui->sortOrderTimers = $r_sortOrderTimers;
     $xml->gui->theme = $r_theme;
     if (check_config_global()) {
         echo "ok";
         config_save();
     }
     break;
 case "rebootconnair":
     foreach ($xml->connairs->connair as $connair) {
         $address = (string) $connair->address;
         $page = file_get_contents("http://" . $address . "/rebooting.cgi?restart=true&Submit=REBOOT");
         if (strpos($page, "Rebooting") !== false) {
             //alles gut
         }
     }
     echo "ok";
     break;
 default:
     echo "action unsupported";
     break;
コード例 #7
0
ファイル: timer.php プロジェクト: power-web/connair-webapp
function timer_switch($timer, $action)
{
    global $xml;
    global $debug_timer;
    debug_timer("timer_switch " . $timer->id . " " . $action);
    // Timer mit Device
    if ($timer->type == "device") {
        $devicesFound = $xml->xpath("//devices/device/id[text()='" . $timer->typeid . "']/parent::*");
        $device = $devicesFound[0];
        timer_send_message($device, $action);
    }
    // Timer mit Room
    if ($timer->type == "room") {
        $devicesFound = $xml->xpath("//devices/device/room[text()='" . $timer->typeid . "']/parent::*");
        foreach ($devicesFound as $device) {
            timer_send_message($device, $action);
            usleep(300000);
        }
    }
    // Timer mit Group
    if ($timer->type == "group") {
        $groupsFound = $xml->xpath("//groups/group/id[text()='" . $timer->typeid . "']/parent::*");
        foreach ($groupsFound[0]->deviceid as $deviceid) {
            $devicesFound = $xml->xpath("//devices/device/id[text()='" . $deviceid . "']/parent::*");
            $device = $devicesFound[0];
            $deviceaction = strtolower($action) . "action";
            debug_timer("Device " . $deviceid . " mit Action '" . $deviceaction . "' ist '" . $deviceid[$deviceaction] . "'");
            if (empty($deviceid[$deviceaction])) {
                timer_send_message($device, $action);
            } else {
                switch ($deviceid[$deviceaction]) {
                    case "on":
                        timer_send_message($device, "ON");
                        break;
                    case "off":
                        timer_send_message($device, "OFF");
                        break;
                    case "none":
                        break;
                }
            }
            usleep(300000);
        }
    }
    config_save();
}
コード例 #8
0
ファイル: account.php プロジェクト: Kheros/Plexis
 public function register()
 {
     // Redirect to the users dashboard if already logged in
     if ($this->user['logged_in']) {
         redirect('account');
     }
     // Make sure the config says we can register
     if (config('allow_registration') == FALSE) {
         output_message('error', 'reg_disabled');
         $this->load->view('blank');
         return;
     }
     // Do our captcha check
     $enable_captcha = config('enable_captcha');
     if ($enable_captcha) {
         $Captcha = $this->load->library('Captcha');
         if ($Captcha == FALSE) {
             // Captcha class doesnt work, disable it in the config
             config_set('enable_captcha', false);
             config_save();
             $enable_captcha = FALSE;
         }
         unset($Captcha);
     }
     // Load our secret questions
     $data['secret_questions'] = get_secret_questions();
     // See if the admin requires a registration key, and IF there is one
     if (config('reg_registration_key')) {
         // Check for a key
         $key = $this->Input->cookie('reg_key', TRUE);
         if (!$key) {
             // Check if the user recently posted the key
             if (isset($_POST['key'])) {
                 // If key is posted, If so we must validate it
                 $result = $this->DB->query("SELECT * FROM `pcms_reg_keys` WHERE `key`=?", array($_POST['key']))->fetchRow();
                 // 'usedby' will only not equal -1 if someone has already signed up with it, so we need to prevent further use of the key.
                 if (!$result || $result['usedby'] >= 0) {
                     // Key form
                     output_message('error', 'reg_failed_invalid_key');
                     $this->load->view('registration_key');
                     return;
                 } else {
                     // Give the user 1 hour to register, otherwise he must re-enter the reg key
                     $this->Input->set_cookie('reg_key', $result['key'], time() + 3600);
                     $this->load->view('register', $data);
                     return;
                 }
             } else {
                 // No posted info, load the Key form
                 $this->load->view('registration_key');
                 return;
             }
         } else {
             // Process if key is valid
             $result = $this->DB->query("SELECT * FROM `pcms_reg_keys` WHERE `key`=?", array($key))->fetchRow();
             // 'usedby' will only not equal -1 if someone has already signed up with it, so we need to prevent further use of the key.
             if (!$result || $result['usedby'] >= 0) {
                 // Reset the Registration key and start over... load the Key form
                 $this->Input->set_cookie('reg_key', $key, time() - 1);
                 output_message('error', 'reg_failed_invalid_key');
                 $this->load->view('registration_key');
                 return;
             } else {
                 // Key is valid, lets go!
                 goto Posted;
             }
         }
     } else {
         Posted:
         // Process if we have POST information
         if (isset($_POST['action']) && $_POST['action'] == "register") {
             goto Process;
         } else {
             $this->load->view('register', $data);
             return;
         }
     }
     // Our main registration processing station
     Process:
     // Load the Form Validation script
     $this->load->library('validation');
     // Tell the validator that the username and password must NOT be empty, as well
     // as match a pattern. Same goes for the email field.
     $enable_captcha == TRUE ? $add = array('sa' => 'required|min[3]|max[24]') : ($add = array());
     $this->validation->set(array('username' => 'required|pattern[(^[A-Za-z0-9_-]{3,24}$)]', 'password1' => 'required|min[3]|max[24]', 'password2' => 'required|min[3]|max[24]', 'email' => 'required|email') + $add);
     // If everything passes validation, we are good to go
     if ($this->validation->validate()) {
         // Check for captcha validation
         if ($enable_captcha == TRUE) {
             $captcha = strtolower($this->Input->post('captcha'));
             if ($captcha != strtolower($_SESSION['Captcha'])) {
                 output_message('error', 'captcha_incorrect');
                 $this->load->view('register', $data);
                 return;
             }
         }
         // Use the XSS filter on these!
         $username = $this->Input->post('username', TRUE);
         $password = $this->Input->post('password1', TRUE);
         $password2 = $this->Input->post('password2', TRUE);
         $email = $this->Input->post('email', TRUE);
         $sq = $this->Input->post('sq');
         $sa = $this->Input->post('sa', TRUE);
         // Check that the 2 passwords matched
         if ($password != $password2) {
             output_message('error', 'passwords_dont_match');
             $this->load->view('register');
             return;
         }
         // Check if the email is already in use
         if (config('reg_unique_email') == TRUE) {
             // Check the DB for the email address
             if ($this->realm->emailExists($email)) {
                 output_message('error', 'reg_failed_email_exists');
                 $this->load->view('register', $data);
                 return;
             }
         }
         // Use the AUTH class to register the user officially
         $id = $this->User->register($username, $password, $email, $sq, $sa);
         if ($id != false) {
             // Remove registration key IF enabled
             if (config('reg_registration_key')) {
                 // Set the 'usedby' field for the reg key.
                 $this->DB->update("pcms_reg_keys", array('usedby' => $id), "`key` = '{$key}'");
                 $this->Input->set_cookie('reg_key', $key, time() - 1);
             }
             // Check for email verification
             if (config('reg_email_verification')) {
                 // Setup our variables and load our extensions
                 $path = path(SYSTEM_PATH, 'language', $GLOBALS['language'], 'emails.xml');
                 $XML = simplexml_load_file($path);
                 $this->email = $this->load->library('email');
                 // Generate a activation key
                 $genkey = $this->account->create_key($username);
                 // Create out email message, parse variables
                 $find = array('{username}', '{activate_link}');
                 $replace = array($username, SITE_URL . "/account/activate/" . $genkey);
                 $message = str_replace($find, $replace, trim($XML->account_activation_req->message));
                 // Build the email
                 $this->email->to($email, $username);
                 $this->email->from(config('site_support_email'), config('site_title'));
                 $this->email->subject($XML->account_activation_req->subject);
                 $this->email->message($message);
                 // Send the email
                 $this->email->send(true) == true ? output_message('success', 'reg_success_activation_required') : output_message('warning', 'reg_success_email_error');
                 $this->load->view('blank');
             } else {
                 // Log the user in, and redirect
                 $this->User->login($username, $password);
                 output_message('success', 'reg_success');
                 $this->load->view('blank', array('username' => $username));
             }
         } else {
             // Message will already be there, no need to make one
             $this->load->view('register', $data);
         }
     } else {
         output_message('error', 'reg_failed_field_invalid');
         $this->load->view('register', $data);
     }
 }
コード例 #9
0
ファイル: main.lib.php プロジェクト: mroussel/flatpress
function validate()
{
    if (!ctype_alnum($_POST['fpuser'])) {
        $err[] = "{$_POST['fpuser']} is not a valid username. \n\t\tUsername must be alphanumeric and should not contain spaces.";
    }
    if (strlen(trim($_POST['fppwd'])) < 6) {
        $err[] = "Password must contain at least 6 non-space characters";
    }
    if ($_POST['fppwd'] != $_POST['fppwd2']) {
        $err[] = "Passwords did not match";
    }
    if (!(preg_match('!@.*@|\\.\\.|\\,|\\;!', $_POST['email']) || preg_match('!^.+\\@(\\[?)[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$!', $_POST['email']))) {
        $err[] = "{$_POST['email']} is not a valid email address";
    }
    $www = $_POST['www'];
    if (!(preg_match('!^http(s)?://[\\w-]+\\.[\\w-]+(\\S+)?$!i', $www) || preg_match('!^http(s)?://localhost!', $www))) {
        $err[] = "{$www} is not a valid URL";
    }
    if ($www && $www[strlen($www) - 1] != '/') {
        $www .= '/';
    }
    global $fp_config;
    $fp_config['general']['author'] = $user['userid'] = $_POST['fpuser'];
    $user['password'] = $_POST['fppwd'];
    $fp_config['general']['www'] = $user['www'] = $www;
    $fp_config['general']['email'] = $user['email'] = $_POST['email'];
    if (isset($err)) {
        $GLOBALS['err'] = $err;
        return false;
    }
    $fp_config['general']['blogid'] = system_generate_id(BLOG_ROOT . $user['www'] . $user['email'] . $user['userid']);
    config_save();
    system_hashsalt_save();
    user_add($user);
    return true;
}
コード例 #10
0
        keyword_cancel($id, $option, $task);
        break;
    case 'keyword.delete':
        keyword_delete($cid, $option, $task);
        break;
    case 'keyword':
    case 'keyword.list':
        keyword_list($option, $task);
        break;
        // ------------------------------------ Config
    // ------------------------------------ Config
    case 'config':
    case 'config.edit':
        config_edit($option);
        break;
    case 'config.save':
        config_save($option);
        break;
        // ------------------------------------ Default / Home
    // ------------------------------------ Default / Home
    default:
    case 'home':
    case 'support':
        home_display($option, $task);
        break;
}
// Administrator Heading
/**
 * TODO: Move to view
 */
wbAdvert_AdminHelper::htmlFooter();
コード例 #11
0
ファイル: admin.themes.php プロジェクト: mroussel/flatpress
 function doselect($id)
 {
     global $fp_config;
     //$id = isset($_GET['select'])? $_GET['select'] : null;
     if ($id) {
         $id = sanitize_title($id);
         if (theme_exists($id)) {
             $fp_config['general']['theme'] = $id;
             unset($fp_config['general']['style']);
             //$t = theme_loadsettings();
             //$fp_config['general']['style'] = $t['default_style'];
             $return = config_save() ? 1 : -1;
         } else {
             $return = -2;
         }
         $this->smarty->assign('success', $return);
         return 1;
     }
 }
コード例 #12
0
ファイル: admin_ajax.php プロジェクト: Kheros/Plexis
 public function update()
 {
     // Make sure we arent directly accessed and the user has perms
     $this->check_access('sa');
     // Process action
     if (isset($_POST['action'])) {
         $action = trim($this->Input->post('action'));
         switch ($action) {
             case "get_latest":
                 // cURL exist? If not we need to verify the user has openssl installed and https support
                 $curl = function_exists('curl_exec');
                 if (!$curl) {
                     // Make sure the Openssl extension is loaded
                     if (!extension_loaded('openssl')) {
                         echo json_encode(array('success' => false, 'message' => 'Openssl extension not found. Please enable the openssl extension in your php.ini file'));
                         return;
                     }
                     // Check for https support
                     if (!in_array('https', stream_get_wrappers())) {
                         echo json_encode(array('success' => false, 'message' => 'Unable to find the stream wrapper "https" - did you forget to enable it when you configured PHP?'));
                         return;
                     }
                 }
                 // Make sure the client server allows fopen of urls
                 if (ini_get('allow_url_fopen') == 1 || $curl == true) {
                     // Get the file changes from github
                     $start = microtime(1);
                     \Debug::silent_mode(true);
                     $page = getPageContents('https://api.github.com/repos/Plexis/Plexis/commits?per_page=1', false);
                     \Debug::silent_mode(false);
                     $stop = microtime(1);
                     if ($page == FALSE || empty($page)) {
                         echo json_encode(array('success' => false, 'message' => 'Unable to connect to the update server'));
                         return;
                     }
                     // Decode the results
                     $commits = json_decode($page, TRUE);
                     // Defaults
                     $count = 0;
                     $latest = 0;
                     echo json_encode(array('success' => true, 'message' => $commits));
                     return;
                 } else {
                     echo json_encode(array('success' => false, 'message' => 'allow_url_fopen not enabled in php.ini'));
                     return;
                 }
                 break;
             case "init":
                 config_set('site_updating', 1);
                 config_save('app');
                 break;
             case "finish":
                 // Enable the site again
                 config_set('site_updating', 0);
                 config_save('app');
                 break;
             case "next":
                 // Load the commit.info file
                 $sha = $type = trim($this->Input->post('sha'));
                 $url = 'https://raw.github.com/Plexis/Plexis/' . $sha . '/commit.info';
                 // Get the file changes from github
                 $start = microtime(1);
                 \Debug::silent_mode(true);
                 $page = trim(getPageContents($url, false));
                 \Debug::silent_mode(false);
                 $stop = microtime(1);
                 if ($page == FALSE || empty($page)) {
                     echo json_encode(array('success' => false, 'data' => 'Error fetching updates'));
                     return;
                 }
                 echo json_encode(array('success' => true, 'data' => json_decode($page)));
                 break;
             case "update":
                 // Grab POSTS
                 $type = trim($this->Input->post('status'));
                 $sha = trim($this->Input->post('sha'));
                 $file = trim(str_replace(array('/', '\\'), '/', $this->Input->post('filename')));
                 $url = 'https://raw.github.com/Plexis/Plexis/' . $sha . '/' . $file;
                 $filename = ROOT . DS . str_replace('/', DS, $file);
                 $dirname = dirname($filename);
                 // Load our Filesystem Class
                 $Fs = $this->load->library('Filesystem');
                 // Build our default Json return
                 $return = array();
                 $success = TRUE;
                 $removed = FALSE;
                 // Hush errors
                 \Debug::silent_mode(true);
                 // Get file contents
                 $contents = trim(getPageContents($url, false));
                 $mod = substr($type, 0, 1);
                 switch ($mod) {
                     case "A":
                     case "M":
                         // Make sure the Directory exists!
                         if (!is_dir($dirname)) {
                             // Ignore install files if the install directory doesnt exist
                             if (strpos($dirname, ROOT . DS . 'install') !== false) {
                                 $this->output(true, '');
                                 return;
                             }
                             // Create the directory for the new file if it doesnt exist
                             if (!$Fs->create_dir($dirname)) {
                                 $this->output(false, 'Error creating directory "' . $dirname . '"');
                                 return;
                             }
                         }
                         // Create cache file of modified files to prevent update errors
                         if ($mod == 'M') {
                             if (!$this->addfileids($sha, 'M', $filename)) {
                                 \Debug::write_debuglog('updater.xml');
                                 $this->output(false, 'Error creating/writting to the updater.cache file. A Detailed trace log has been generated "system/logs/debug/updater.xml"');
                                 return;
                             }
                             // Set cache filename
                             $filename = $filename . '.tmp';
                         }
                         // Now attempt to write to the file, create it if it doesnt exist
                         if (!$Fs->create_file($filename, $contents)) {
                             $this->output(false, 'Error creating/opening file "' . $filename . '"');
                             return;
                         }
                         // Add file to modify list
                         break;
                     case "D":
                         if (!$this->addfileids($sha, 'D', $filename)) {
                             \Debug::write_debuglog('updater.xml');
                             $this->output(false, 'Error creating/writting to the updater.cache file. A Detailed trace log has been generated "system/logs/debug/updater.xml"');
                             return;
                         }
                         break;
                 }
                 // Output success
                 $this->output(true, '');
                 break;
             case 'finalize':
                 // Load our Filesystem Class
                 $Fs = $this->load->library('Filesystem');
                 // Add trace for debugging
                 \Debug::trace('Finalizing updates...', __FILE__, __LINE__);
                 // We need to rename all modified files from thier cache version, and remove deleted files
                 $cfile = path(SYSTEM_PATH, 'cache', 'updater.cache');
                 if (file_exists($cfile)) {
                     $data = unserialize(file_get_contents($cfile));
                     unset($data['sha']);
                     foreach ($data['files'] as $file) {
                         // If we are missing a file name or mode, then continue to the next loop
                         if (!isset($file['mode']) || !isset($file['filename'])) {
                             continue;
                         }
                         // Modified file
                         if ($file['mode'] == 'M') {
                             $tmp = $file['filename'] . '.tmp';
                             if (!$Fs->copy($tmp, $file['filename'])) {
                                 // Add trace for debugging
                                 \Debug::trace('Failed to copy {' . $tmp . '} to {' . $file['filename'] . '}', __FILE__, __LINE__);
                                 \Debug::write_debuglog('updater.xml');
                                 $this->output(false, 'Error copying cache contents of file ' . $file['filename'] . '. Update failed.');
                                 die;
                             }
                             $Fs->delete_file($tmp);
                         } else {
                             // Deleted file / dir
                             $Fs->delete($data['filename']);
                             // Re-read the directory
                             clearstatcache();
                             $files = $Fs->read_dir($dirname);
                             // If empty, delete .DS / .htaccess files and remove dir!
                             if (empty($files) || sizeof($files) == 1 && $files[0] == '.htaccess') {
                                 $Fs->remove_dir($dirname);
                             }
                         }
                     }
                     // Remove the updater cache file
                     $Fs->delete_file($cfile);
                     // Output success
                     $this->output(true, '');
                 } else {
                     // Add trace for debugging
                     \Debug::trace('updater.cache file doesnt exist. Update failed.', __FILE__, __LINE__);
                     \Debug::write_debuglog('updater.xml');
                     $this->output(false, 'Unable to open the updater.cache file. Update failed.');
                 }
                 break;
         }
         // End Swicth $action
     } else {
         $this->output(false, 'Invalid Post Action');
     }
 }