Inheritance: extends REST_Controller
示例#1
1
function get()
{
    $settings = new Settings();
    $atlantis = array('lat' => doubleval($settings->getSettings('Atlantis', 'lat')), 'long' => doubleval($settings->getSettings('Atlantis', 'long')));
    $bdd = getBDD();
    $req = $bdd->query('SELECT arr.*, IFNULL(arr2.nom, at_users.nom) nom FROM (SELECT t1.* FROM at_geo t1 LEFT JOIN at_geo t2 ON (t1.mac = t2.mac AND t1.timestamp < t2.timestamp) WHERE t2.timestamp IS NULL AND t1.date = CURDATE()) AS arr LEFT JOIN (SELECT at_devices.mac, at_users.nom FROM at_devices INNER JOIN at_users ON at_devices.username = at_users.id) AS arr2 ON arr.mac = arr2.mac LEFT JOIN at_users ON arr.mac = at_users.cle');
    $result = $req->fetchAll(PDO::FETCH_ASSOC);
    $req->closeCursor();
    http_response_code(202);
    $output = array('atlantis' => $atlantis, 'positions' => $result);
    return $output;
}
示例#2
0
 protected function createComponentAddSetting()
 {
     $form = new Form();
     $form->addText('key', 'Klíč')->setRequired('Zadejte klíč nastavení');
     $form->addText('value', 'Hodnota')->setRequired('Zadejte hodnotu nastavení');
     $form->addSubmit('send', 'Zapsat');
     $form->onSuccess[] = function (Form $f) {
         try {
             $val = $f->values;
             $this->settings->set($val->key, $val->value);
             $this->settings->push();
             //Write
             $this->logger->log('System', 'edit', "%user% změnila(a) nastavení");
             $msg = $this->flashMessage("Nastavení bylo zapsáno", 'success');
             $msg->title = 'Yehet!';
             $msg->icon = 'check';
             $this->redirect('this');
         } catch (\PDOException $e) {
             \Nette\Diagnostics\Debugger::log($e);
             $msg = $this->flashMessage("Něco se podělalo. Zkuste to prosím později.", 'danger');
             $msg->title = 'Oh shit!';
             $msg->icon = 'warning';
         }
     };
     return $form;
 }
 public function getConfigurationEntries($tprefix)
 {
     require_once 'Settings.php';
     $obj_sett = new Settings();
     $arr_config = $obj_sett->getSettings($tprefix);
     return $arr_config;
 }
 /**
  * Get settings
  *
  * @param  string $name
  * @param  mixed $default
  * @return mixed
  */
 public function getSetting($name, $default = null)
 {
     if (!$this->settings) {
         return null;
     }
     return $this->settings->getSetting($name, $default);
 }
示例#5
0
/**
 * writeToDb writes the OBJECT to the database
 * @param Array $data
 */
function writeToDB($data)
{
    //    echo print_r(array_keys($data), true);
    require_once dirname(realpath(__FILE__)) . '/../includes/classes/settings.class.php';
    $settings = new Settings();
    $settings->writeObject($data);
}
示例#6
0
 function __construct()
 {
     $settings = new Settings();
     $this->oc = $settings->getSettings('ownCloud', 'path');
     $this->admin_username = $settings->getSettings('ownCloud', 'username');
     $this->admin_password = $settings->getSettings('ownCloud', 'password');
 }
示例#7
0
function get()
{
    $pid = (new Settings())->getSettings('Daemon', 'pid');
    if ($pid == -1) {
        $daemon = false;
    } else {
        exec("ps -p {$pid}", $result);
        if (count($result) > 1) {
            $result = $result[1];
            $result = preg_replace("/\\s+/", " ", $result);
            $data = explode(" ", $result);
            if ($data[count($data) - 1] == 'php') {
                $daemon = true;
            } else {
                $daemon = false;
            }
        } else {
            $daemon = false;
        }
    }
    $free_disk = disk_free_space('/') / disk_total_space('/');
    $settings = new Settings();
    $output = array('daemon' => $daemon, 'free_hdd' => $free_disk, 'nightFrom' => $settings->getSettings('Mode', 'nightFrom'), 'nightTo' => $settings->getSettings('Mode', 'nightTo'), 'nightAuto' => $settings->getSettings('Mode', 'nightAuto'));
    return $output;
}
示例#8
0
 public function triggerWebtreesAdminTasks()
 {
     $settings = new Settings();
     $this->logger = \Piwik\Container\StaticContainer::get('Psr\\Log\\LoggerInterface');
     $this->logger->info('Webtrees Admin Task triggered');
     $rooturl = $settings->getSetting('webtreesRootUrl');
     if (!$rooturl || strlen($rooturl->getValue()) === 0) {
         return;
     }
     $token = $settings->getSetting('webtreesToken');
     if (!$token || strlen($token->getValue()) === 0) {
         return;
     }
     $taskname = $settings->getSetting('webtreesTaskName');
     if (!$taskname || strlen($taskname->getValue()) === 0) {
         return;
     }
     $url = sprintf('%1$s/module.php?mod=perso_admintasks&mod_action=trigger&force=%2$s&task=%3$s', $rooturl->getValue(), $token->getValue(), $taskname->getValue());
     $this->logger->info('webtrees url : {url}', array('url' => $url));
     try {
         \Piwik\Http::sendHttpRequest($url, Webtrees::SOCKET_TIMEOUT);
     } catch (Exception $e) {
         $this->logger->warning('an error occured', array('exception' => $e));
     }
 }
示例#9
0
 public function action_index()
 {
     $settings = new Settings();
     $settings->add_setting(new Setting_Preferences($this->user));
     $settings->add_setting(new Setting_Profile($this->user));
     $settings->add_setting(new Setting_Account($this->user));
     // Run the events.
     Event::fire('user.settings', array($this->user, $settings));
     if ($this->request->method() == HTTP_Request::POST) {
         $setting = $settings->get_by_id($this->request->post('settings-tab'));
         if ($setting) {
             $post = $this->request->post();
             $validation = $setting->get_validation($post);
             if ($validation->check()) {
                 try {
                     $setting->save($post);
                     Hint::success('Updated ' . $setting->title . '!');
                 } catch (ORM_Validation_Exception $e) {
                     Hint::error($e->errors('models'));
                 }
             } else {
                 Hint::error($validation->errors());
             }
         } else {
             Hint::error('Invalid settings id!');
         }
     }
     $this->view = new View_User_Settings();
     $this->view->settings = $settings;
 }
 public function testDefaultSettings()
 {
     $settings = new Settings();
     $this->assertEquals(Settings::DEFAULT_LENGTH, $settings->getLength());
     $this->assertEquals(Settings::DEFAULT_WIDTH, $settings->getWidth());
     $this->assertEquals(Settings::DEFAULT_BOMB_COUNT, $settings->getBombCount());
 }
示例#11
0
 public function testResolvePartialPath()
 {
     $resolver = $this->prophesize('asylgrp\\workbench\\PathResolver');
     $resolver->resolve('foo')->willReturn('resolved');
     $settings = new Settings(['baz' => '[path:foo]/bar'], $resolver->reveal());
     $this->assertSame('resolved/bar', $settings->read('baz'));
 }
示例#12
0
 /**
  * Save settings
  *
  * @param Newscoop\News\Item $item
  * @return void
  */
 public function save(array $values, Settings $settings)
 {
     $settings->setArticleTypeName($values['article_type']);
     $settings->setPublicationId($values['publication']);
     $settings->setSectionNumber($values['section']);
     $this->odm->persist($settings);
     $this->odm->flush();
 }
示例#13
0
 function __construct($json, $supported_protocols)
 {
     $s = new Settings();
     if ($json !== "") {
         $s->fromJson($json);
     }
     $this->settings = $s;
 }
 public function writeablePathsCreated()
 {
     $Settings = new Settings();
     $Settings->loadSettings();
     if (trim($Settings->settings['TemplatesWriteablePath'] . chr(32)) != "" && trim($Settings->settings['SrcWriteablePath'] . chr(32)) != "" && trim($Settings->settings['ClassesWriteablePath'] . chr(32)) != "") {
         return true;
     }
     return false;
 }
示例#15
0
function message($arr)
{
    light_notification(false);
    $settings = new Settings();
    if ($settings->getSettings('CallNotifier', 'voice')) {
        (new Player())->sound(Player::NOTIFICATION);
        (new Player())->sound(Player::INCOMING_MESSAGE);
    }
}
示例#16
0
 protected function isAuth()
 {
     $Settings = new Settings();
     $settings = $Settings->get('admin');
     if (@$_COOKIE['pass'] == $settings['s_val']) {
         return true;
     } else {
         return false;
     }
 }
示例#17
0
 function del()
 {
     $model = new Settings();
     $model->del();
     if ($_GET['parent'] != 0) {
         $this->redirect('/settings/' . $_GET['parent'] . '/');
     } else {
         $this->redirect('/settings/');
     }
 }
示例#18
0
 function __construct($city = 'rennes')
 {
     $settings = new Settings();
     $this->city = $city;
     $this->appid = $settings->getSettings('Weather', 'appid');
     $result = $this->fetchURL($city, 7);
     if ($result->cod != null && $result->cod == '200') {
         $this->data = $result;
     }
 }
示例#19
0
 public function settings()
 {
     $settings = array();
     $first = TRUE;
     foreach ($this->settings->get_all() as $setting) {
         $settings[] = array('id' => $setting->id(), 'title' => $setting->title, 'active' => $first, 'view' => $setting->view());
         $first = FALSE;
     }
     return $settings;
 }
示例#20
0
    public function output(Settings $settings)
    {
        $class = $this->getClass($settings->getDivClass());
        $style = $this->getStyles();
        $attrs = $this->getAttrsAsString();
        return <<<RETURN
<div class="{$class}"{$attrs}>
<div id="{$this->divId}">
<script type="text/javascript" defer>
googletag.cmd.push(function() { googletag.display('{$this->divId}'); });
googletag.cmd.push(function() {
    \$(function() {
        var slideTimer = setTimeout(function() {
            clearTimeout(slideTimer);
            \$('div.{$class}').each(function() {
                var ad = \$(this);
                var container = \$('[data-role="pageskin"]');
                var closed = false;
                var scrolled = false;
                var showAd = function(force) {
                    if(! closed || force) {
                        ad.fadeIn('fast'); scrolled = true; closed = false;
                        container.css('margin-top', '90px');
                        container.css('z-index', '2');
                        container.css('position', 'relative');
                        ad.css('top', container.offset().top - 90);
                    }
                };
                var hideAd = function() {
                    ad.fadeOut('fast');
                    container.css('margin-top', '0');
                    closed = true;
                }

                            if(ad.find('div').css('display') != 'none') {
                                showAd();
                                \$(window).scroll(function () {
                                    if (!scrolled && !closed && \$(this).scrollTop() > 40) {
                                        showAd();
                                    }
                                });
                                ad.find('.pageskin_ad_close').click(function(e) {
                                    e.preventDefault();
                                    hideAd();
                                });
                            }
                        });
                    }, 2000);
    });
});
</script>
</div>
</div>
RETURN;
    }
示例#21
0
 public function load($templateName, $generalSettingsInstance = false)
 {
     //set default template as messy
     if (!$templateName) {
         foreach ($this->getAllTemplates() as $tpl) {
             list($template_all) = explode('-', $tpl);
             if ($template_all == 'messy') {
                 $templateName = $tpl;
                 break;
             } else {
                 $templateName = 'default';
             }
         }
         //save in settings
         $settings = new Settings(false);
         $settings->update('template', 'template', array('value' => $templateName));
         $settings->save();
     }
     $this->name = $templateName;
     $tPath = self::$options['TEMPLATES_FULL_SERVER_PATH'] . $this->name;
     if (!file_exists($tPath)) {
         $template = explode('-', $this->name);
         $template = $template[0];
         //try to get same template with different version if not exists
         foreach ($this->getAllTemplates() as $tpl) {
             list($template_all) = explode('-', $tpl);
             if ($template_all == $template) {
                 $this->name = $tpl;
                 break;
                 //default template = messy
             } else {
                 $this->name = 'default';
             }
         }
         $tPath = self::$options['TEMPLATES_FULL_SERVER_PATH'] . $this->name;
     }
     if (file_exists($tPath) && file_exists($tPath . '/template.conf.php')) {
         $this->smarty->template_dir = $tPath;
         $this->smarty->plugins_dir = array('plugins', self::$options['TEMPLATES_FULL_SERVER_PATH'] . '_plugins', $tPath . '/plugins');
         list($this->sectionTypes, $this->settingsDefinition) = (include $tPath . '/template.conf.php');
         $this->templateHTML = @file_get_contents($tPath . '/template.tpl');
         $this->templateFile = $tPath . '/template.tpl';
         $this->settings = new Settings($this->settingsDefinition, $generalSettingsInstance, $this->name);
         // instantiate settings for each section type definition (extend $this->settings)
         reset($this->sectionTypes);
         while (list($tName, $t) = each($this->sectionTypes)) {
             $this->sectionTypes[$tName]['settings'] = new Settings(false, $this->settings, false, isset($t['settings']) ? $t['settings'] : false);
         }
         return true;
     }
     return false;
 }
 /**
  * method: verifyUser
  * when: called
  * with: userAndPassword
  * should: returnToken
  */
 public function test_verifyUser_called_userAndPassword_returnToken()
 {
     $settings = new Settings();
     $postfields = array();
     $postfields['auth'] = array();
     $postfields['auth']['passwordCredentials'] = array();
     $postfields['auth']['passwordCredentials']['username'] = '******';
     $postfields['auth']['passwordCredentials']['password'] = '******';
     $postfields['auth']['tenantName'] = 'eyeos';
     $settings->setPostFields(json_encode($postfields));
     $this->oauthProviderMock->expects($this->once())->method('verifyUser')->with($settings)->will($this->returnValue('AB'));
     $this->sut->verifyUser($settings);
 }
示例#23
0
    /**
     * Output the DFP code for this ad unit
     *
     * @param Nodrew\Bundle\DfpBundle\Model\Settings $settings
     * @return string
     */
    public function output(Settings $settings)
    {
        $class = $settings->getDivClass();
        $style = $this->getStyles();
        return <<<RETURN

<div id="{$this->divId}" class="{$class}" style="{$style}">
<script type="text/javascript">
googletag.cmd.push(function() { googletag.display('{$this->divId}'); });
</script>
</div>
RETURN;
    }
示例#24
0
 public function __construct($local = null)
 {
     $settings = new Settings();
     $this->url = $settings->getSettings("Zwave", "IP");
     $this->port = $settings->getSettings("Zwave", "Port");
     $this->username = $settings->getSettings("Zwave", "username");
     $this->password = $settings->getSettings("Zwave", "password");
     if ($local == null) {
         $this->rawData = null;
     } else {
         $this->rawData = $this->loadRawData();
     }
 }
 public function testTestmode()
 {
     $local = './localsettings.json';
     @unlink($local);
     Initbootstrap::init();
     $localSettings = new Settings('local');
     $localSettings->wppath_test = 'foobar';
     file_put_contents($local, $localSettings->toString());
     define('TESTMODE', true);
     $localSettings = new Settings('local');
     //print_r($localSettings);
     $this->assertEquals('foobar', $localSettings->wppath);
 }
示例#26
0
 public function __construct($dbHost, $dbUser, $dbPassword, $dbName, $dbTablePrefix)
 {
     # Define
     defineTablePrefix($dbTablePrefix);
     # Connect
     $this->database = Database::connect($dbHost, $dbUser, $dbPassword, $dbName);
     # Check connection
     if ($this->database->connect_errno) {
         die('Error: Could not connect to the lychee database. Is the path to lychee correct? ' . $this->database->connect_error);
     }
     # Load settings
     $settings = new Settings($this->database);
     $this->settings = $settings->get();
 }
示例#27
0
    /**
     * Output the DFP code for this ad unit
     *
     * @param Settings $settings
     * @return string
     */
    public function output(Settings $settings)
    {
        $class = $this->getClass($settings->getDivClass());
        $attrs = $this->getAttrsAsString();
        return <<<RETURN
<div class="{$class}"{$attrs}>
<div id="{$this->divId}">
<script type="text/javascript" defer>
googletag.cmd.push(function() { googletag.display('{$this->divId}'); });
</script>
</div>
</div>
RETURN;
    }
示例#28
0
 public function save()
 {
     $settings = Settings::whereRaw("section='laramce' AND setting_name='plugins'")->first();
     if (!$settings->id) {
         $settings = new Settings();
     }
     $settings->area = 'backend';
     $settings->section = 'laramce';
     $settings->setting_name = 'plugins';
     $settings->setting_value = implode(" ", Input::get('plugins'));
     $settings->autoload = 1;
     $settings->save();
     return Redirect::to('backend/laramce')->withMessage($this->notifyView(Lang::get('messages.settings_saved'), 'success'));
 }
示例#29
0
 public function checkSMSStatus()
 {
     $flag = false;
     require_once 'Settings.php';
     $obj_settings = new Settings();
     $obj_arr = $obj_settings->getSettings();
     $status = $obj_arr["sms_status"];
     if ($status == "enabled") {
         $flag = true;
     } else {
         $this->obj_misc->alert('You are unable to Send SMS ,Please Contact Administrator');
     }
     return $flag;
 }
示例#30
0
 public function actionSettings()
 {
     if (isset($_REQUEST["Settings"])) {
         $S = new Settings();
         $settings = $S->findByPk(Yii::app()->my->id);
         foreach ($_REQUEST['Settings'] as $key => $value) {
             $settings->{$key} = $value;
         }
         $settings->save();
     } else {
         $S = new Settings();
         $settings = $S->findByPk(Yii::app()->my->id);
     }
     $this->render('settings', array('settings' => $settings));
 }