Beispiel #1
0
 public function getKey($key, $fallbackToSiteSetting = false)
 {
     if ($this->mrSiteDb) {
         $key_query = $this->mrSiteDb->Execute('SELECT val ' . 'FROM usersettings ' . 'WHERE userid=' . (int) $this->mUserId . ' ' . 'AND keyname=' . $this->mrSiteDb->Format_Text($key));
         if ($key_query->NumRows()) {
             return $key_query->Fields('val');
         } else {
             if ($fallbackToSiteSetting == true) {
                 import('com.solarix.ampoliros.site.SiteSettings');
                 $sets = new SiteSettings($this->mrSiteDb);
                 return $sets->GetKey($key);
             }
         }
     }
     return '';
 }
Beispiel #2
0
 public function initView()
 {
     //init session
     $storage = new Zend_Auth_Storage_Session();
     $this->session = $storage->read();
     if ($this->session) {
         $this->_me = $this->session;
         $this->view->user = $this->_me;
     }
     $settingsModel = new Settings();
     $offset = date('Z') / 60 / 60;
     $settingsModel->query("SET time_zone = '{$offset}:00'");
     $this->view->currentRoute = Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName();
     $siteSettingsModel = new SiteSettings();
     $this->view->siteSettings = $siteSettingsModel->getById(1);
     $this->init();
 }
 public function disableRss()
 {
     $site_settings = SiteSettings::getSettings();
     $network_settings = NetworkSettings::getSettings();
     $site_disable_rss = !empty($site_settings['disable-rss']);
     $network_disable_rss = !empty($network_settings['disable-rss']);
     if ($site_disable_rss || $network_disable_rss) {
         wp_die('No feeds available.');
     }
 }
 /**
  * Renders the site settings page.
  *
  * This page provides an interface for modifying site settings, especially those handled by the SiteSettings class.
  * It also shows some basic configuration information for the site, along with a nicely formatted readout of the PHP error log.
  * This page requires authentication (and should generally be limited to the root user).
  * Request type: GET
  */
 public function pageSiteSettings()
 {
     // Access-controlled page
     if (!$this->_app->user->checkAccess('uri_site_settings')) {
         $this->_app->notFound();
     }
     // Hook for core and plugins to register their settings
     $this->_app->applyHook("settings.register");
     $this->_app->render('config/site-settings.twig', ['settings' => $this->_app->site->getRegisteredSettings(), 'info' => $this->_app->site->getSystemInfo(), 'error_log' => SiteSettings::getLog(50)]);
 }
 /**
  * Remove a WordPress post or page from search results when it is moved to the trash
  * @param $post_id int
  */
 public function TrashPost($post_id)
 {
     require_once "search/mysql-search-indexer.class.php";
     require_once "data/mysql-connection.class.php";
     $search = new MySqlSearchIndexer(new MySqlConnection($this->settings->DatabaseHost(), $this->settings->DatabaseUser(), $this->settings->DatabasePassword(), $this->settings->DatabaseName()));
     $post = get_post($post_id);
     if ($post and $post->post_type == 'post') {
         $search->DeleteFromIndexById("post" . $post_id);
     } else {
         if ($post and $post->post_type == 'page') {
             $search->DeleteFromIndexById("page" . $post_id);
         }
     }
 }
    public function init()
    {
        add_action('admin_init', function () {
            add_settings_section('swp_settings', 'Site Wide Password', '', 'general');
            add_settings_field('swp_settings-active', 'Password Active', function () {
                $swp_settings = SiteSettings::getSettings();
                $active = !empty($swp_settings['active']);
                ?>
				<input type="checkbox" name="swp_settings[active]" id="swp_settings-active" value="1" <?php 
                checked($active);
                ?>
/>
				<?php 
            }, 'general', 'swp_settings');
            add_settings_field('swp_settings-password', 'Site Password', function () {
                $swp_settings = SiteSettings::getSettings();
                $password = empty($swp_settings['password']) ? '' : $swp_settings['password'];
                ?>
				<input type="password" name="swp_settings[password]" id="swp_settings-password" value="<?php 
                echo esc_attr($password);
                ?>
"/>
				<?php 
            }, 'general', 'swp_settings');
            add_settings_field('swp_settings-disable-rss', 'Disable RSS feed', function () {
                $swp_settings = SiteSettings::getSettings();
                $disable_rss = !empty($swp_settings['disable-rss']);
                ?>
				<input type="checkbox" name="swp_settings[disable-rss]" id="swp_settings-disable-rss" value="1" <?php 
                checked($disable_rss);
                ?>
/>
				<?php 
            }, 'general', 'swp_settings');
            register_setting('general', 'swp_settings', function () {
                $newSettings = [];
                $swp_settings = empty($_POST['swp_settings']) ? array() : $_POST['swp_settings'];
                $newSettings['active'] = !empty($swp_settings['active']);
                $newSettings['password'] = empty($swp_settings['password']) ? '' : esc_attr($swp_settings['password']);
                $newSettings['disable-rss'] = !empty($swp_settings['disable-rss']);
                return $newSettings;
            });
        });
    }
Beispiel #7
0
function pass_settheme($eventData)
{
    global $hui_mainstatus, $amp_locale, $hui_page, $env;
    $log = new Logger(AMP_LOG);
    if ($env['currentuser'] == $env['currentsite']) {
        $user = $key_name = 'sitetheme';
    } else {
        $key_name = $env['currentuser'] . '-theme';
    }
    $site_cfg = new SiteSettings($env['db']);
    $site_cfg->EditKey($key_name, $eventData['theme']);
    $env['hui']['theme']['name'] = $eventData['theme'];
    $env['hui']['theme']['handler'] = new HuiTheme($env['ampdb'], $eventData['theme']);
    header('Location: ' . build_events_call_string('', array(array('main', 'default', ''), array('pass', 'settheme2', ''))));
}
 /**
  * Decrypt an e-mail address encrypted by the ApplyEmailProtection() method
  * @param $address string
  */
 public function DecryptProtectedEmail($address)
 {
     $encryption_key = $this->settings->GetEmailAddressEncryptionKey();
     $address = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($encryption_key), base64_decode($address), MCRYPT_MODE_CBC, md5(md5($encryption_key))), "");
     return $address;
 }
 /**
  * Gets the format to use for a competition's short URLs
  *
  * @param SiteSettings
  * @return ShortUrlFormat
  */
 public static function GetShortUrlFormatForType(SiteSettings $settings)
 {
     return new ShortUrlFormat($settings->GetTable('Competition'), 'short_url', array('competition_id'), array('GetId'), array('{0}' => $settings->GetUrl('Competition') . '{0}', '{0}/statistics' => '/play/statistics/summary-competition.php?competition={0}', '{0}/map' => "/play/competitions/map.php?competition={0}"));
 }
 /**
  * @return string
  * @desc Gets the URL for deleting the match
  */
 public function GetDeleteNavigateUrl()
 {
     return $this->o_settings->GetClientRoot() . $this->GetShortUrl() . '/delete';
 }
 /**
  * Gets the format to use for a player's short URLs
  *
  * @param SiteSettings
  * @return ShortUrlFormat
  */
 public static function GetShortUrlFormatForType(SiteSettings $settings)
 {
     return new ShortUrlFormat($settings->GetTable('Player'), 'short_url', array('player_id'), array('GetId'), array('{0}' => '/play/statistics/player-batting.php?player={0}', '{0}/bowling' => '/play/statistics/player-bowling.php?player={0}', '{0}/edit' => '/play/statistics/playeredit.php?item={0}', '{0}/delete' => '/play/statistics/playerdelete.php?item={0}', '{0}/batting.json' => "/play/statistics/player-batting.js.php?player={0}", '{0}/bowling.json' => "/play/statistics/player-bowling.js.php?player={0}"));
 }
Beispiel #12
0
function main_edit($eventData)
{
    global $env, $hui_mainframe, $amp_locale, $hui_titlebar;
    $site_sets = new SiteSettings($env['db']);
    $hui_grid = new HuiGrid('grid', array('rows' => '11', 'cols' => '2'));
    $hui_grid->AddChild(new HuiLabel('sitecompletenamelabel', array('label' => $amp_locale->GetStr('sitecompletename_label'))), 0, 0);
    $hui_grid->AddChild(new HuiString('sitecompletename', array('value' => $site_sets->GetKey('sitecompletename'), 'disp' => 'pass')), 0, 1);
    $hui_grid->AddChild(new HuiLabel('siteaddressalabel', array('label' => $amp_locale->GetStr('siteaddressa_label'))), 1, 0);
    $hui_grid->AddChild(new HuiString('siteaddressa', array('value' => $site_sets->GetKey('siteaddressa'), 'disp' => 'pass')), 1, 1);
    $hui_grid->AddChild(new HuiLabel('siteaddressblabel', array('label' => $amp_locale->GetStr('siteaddressb_label'))), 2, 0);
    $hui_grid->AddChild(new HuiString('siteaddressb', array('value' => $site_sets->GetKey('siteaddressb'), 'disp' => 'pass')), 2, 1);
    $hui_grid->AddChild(new HuiLabel('sitetownlabel', array('label' => $amp_locale->GetStr('sitetown_label'))), 3, 0);
    $hui_grid->AddChild(new HuiString('sitetown', array('value' => $site_sets->GetKey('sitetown'), 'disp' => 'pass')), 3, 1);
    $hui_grid->AddChild(new HuiLabel('sitestatelabel', array('label' => $amp_locale->GetStr('sitestate_label'))), 4, 0);
    $hui_grid->AddChild(new HuiString('sitestate', array('value' => $site_sets->GetKey('sitestate'), 'disp' => 'pass')), 4, 1);
    $hui_grid->AddChild(new HuiLabel('siteziplabel', array('label' => $amp_locale->GetStr('sitezip_label'))), 5, 0);
    $hui_grid->AddChild(new HuiString('sitezip', array('value' => $site_sets->GetKey('sitezip'), 'disp' => 'pass')), 5, 1);
    $hui_grid->AddChild(new HuiLabel('sitecountrylabel', array('label' => $amp_locale->GetStr('sitecountry_label'))), 6, 0);
    $hui_grid->AddChild(new HuiString('sitecountry', array('value' => $site_sets->GetKey('sitecountry'), 'disp' => 'pass')), 6, 1);
    $hui_grid->AddChild(new HuiLabel('sitefiscalcodelabel', array('label' => $amp_locale->GetStr('sitefiscalcode_label'))), 7, 0);
    $hui_grid->AddChild(new HuiString('sitefiscalcode', array('value' => $site_sets->GetKey('sitefiscalcode'), 'disp' => 'pass')), 7, 1);
    $hui_grid->AddChild(new HuiLabel('siteemaillabel', array('label' => $amp_locale->GetStr('siteemail_label'))), 8, 0);
    $hui_grid->AddChild(new HuiString('siteemail', array('value' => $site_sets->GetKey('siteemail'), 'disp' => 'pass')), 8, 1);
    $hui_grid->AddChild(new HuiLabel('sitephonelabel', array('label' => $amp_locale->GetStr('sitephone_label'))), 9, 0);
    $hui_grid->AddChild(new HuiString('sitephone', array('value' => $site_sets->GetKey('sitephone'), 'disp' => 'pass')), 9, 1);
    $hui_grid->AddChild(new HuiLabel('sitefaxlabel', array('label' => $amp_locale->GetStr('sitefax_label'))), 10, 0);
    $hui_grid->AddChild(new HuiString('sitefax', array('value' => $site_sets->GetKey('sitefax'), 'disp' => 'pass')), 10, 1);
    /*
    $tmpmod = new moduledep( $env[ampdb] );
    
    if ( $tmpmod->isenabled( 'magellan', $env[sitedata][siteid] ) )
    {
        $data = $sets->getkey( 'sitelogo' );
    
        $query = &$env[db]->Execute( 'select * from medias order by medianame' );
        $mvalues[] = 'none';
        $mcaptions[] = $adloc->GetStr( 'nomedia' );
    
        while ( !$query->eof )
        {
            $mdata = $query->fields();
            $mvalues[] = $mdata[id];
            if ( $mdata[id] == $data ) $selected = $mdata[id];
            $mcaptions[] = $mdata['medianame'];
            $query->MoveNext();
        }
    
        $row++;
        $table[0][$row] = new htmltext( $adloc->GetStr( 'logodesc' ) );
        $table[1][$row] = new htmlformselect( '', 'sitelogo', $selected, $mvalues, $mcaptions  );
        $row++;
        $table[0][$row] = new htmltext( $adloc->GetStr( 'logonote' ) );
        $table[0][$row]->colspan = 2;
    }
    
    $hui_grid->AddChild( new HuiLabel( 'sitelogolabel', array( 'label' => $amp_locale->GetStr( 'sitelogo_label' ) ) ), 11, 0 );
    $hui_grid->AddChild( new HuiString( 'sitelogo', array( 'value' => $site_sets->GetKey( 'sitelogo' ), 'disp' => 'pass' ) ), 11, 1 );
    */
    $hui_vgroup = new HuiVertGroup('vertgroup', array('align' => 'center'));
    $hui_vgroup->AddChild($hui_grid);
    $hui_vgroup->AddChild(new HuiSubmit('submit', array('caption' => $amp_locale->GetStr('editdata_submit'))));
    $form_events_call = new HuiEventsCall();
    $form_events_call->AddEvent(new HuiEvent('main', 'default', ''));
    $form_events_call->AddEvent(new HuiEvent('pass', 'edit', ''));
    $hui_form = new HuiForm('form', array('action' => $form_events_call->GetEventsCallString()));
    $hui_form->AddChild($hui_vgroup);
    $hui_mainframe->AddChild($hui_form);
    $hui_titlebar->mTitle .= ' - ' . $amp_locale->GetStr('edit_title');
}
 /**
  * Gets the format to use for a season's short URLs
  *
  * @param SiteSettings
  * @return ShortUrlFormat
  */
 public static function GetShortUrlFormatForType(SiteSettings $settings)
 {
     return new ShortUrlFormat($settings->GetTable('Season'), 'short_url', array('season_id'), array('GetId'), array('{0}' => $settings->GetUrl('Season') . '{0}', '{0}/matches/friendlies/add' => '/play/matches/matchadd.php?season={0}', '{0}/matches/league/add' => '/play/matches/matchadd.php?season={0}&type=' . MatchType::LEAGUE, '{0}/matches/cup/add' => '/play/matches/matchadd.php?season={0}&type=' . MatchType::CUP, '{0}/matches/practices/add' => '/play/matches/matchadd.php?season={0}&type=' . MatchType::PRACTICE, '{0}/matches/tournaments/add' => "/play/tournaments/add.php?season={0}", '{0}/matches/edit' => $settings->GetUrl('SeasonResults'), '{0}/calendar' => $settings->GetUrl('SeasonCalendar'), '{0}/statistics' => '/play/statistics/summary-season.php?season={0}', '{0}/table' => '/play/competitions/table.php?season={0}', '{0}/map' => '/play/competitions/map.php?season={0}'));
 }
Beispiel #14
0
 public function cleanMotd()
 {
     if (is_object($this->sitedb)) {
         $sets = new SiteSettings($this->sitedb);
         return $sets->DeleteKey('SITE_MOTD');
     }
     return false;
 }
Beispiel #15
0
 public function settingsAction()
 {
     if ($this->_me->admin != 1) {
         $this->_redirect("/");
     }
     $siteSettingsModel = new SiteSettings();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if ($siteSettingsModel->update($data, 1)) {
             $this->view->success = "Settings updated.";
         }
     }
     $this->view->settings = $siteSettingsModel->getById(1);
 }
Beispiel #16
0
function pass_setcountry($eventData)
{
    global $hui_mainstatus, $amp_locale, $env, $hui_page;
    $site_sets = new SiteSettings($env['db']);
    $site_sets->EditKey($env['currentuser'] . '-country', $eventData['country']);
    if ($env['currentuser'] == $env['currentsite']) {
        $site_sets->EditKey('sitecountry', $eventData['country']);
    }
    $hui_page->mArgs['javascript'] = 'parent.frames.sum.location.reload()';
    $hui_mainstatus->mArgs['status'] = $amp_locale->GetStr('countryset_status');
}
    /**
     * Helper to build and send the email when a match has been added by a public user
     *
     * @param Match $o_match
     * @param User $o_user
     * @param bool $b_is_new_match
     * @param bool $b_is_deleted_match
     * @param string $s_email
     * @param Season[] $seasons
     */
    private function SendMatchUpdatedEmail(Match $o_match, User $o_user, $b_is_new_match, $b_is_deleted_match, $s_email, $seasons = null)
    {
        # text of email
        $s_season_list = '';
        if (is_array($seasons)) {
            $i_total_seasons = count($seasons);
            for ($i = 0; $i < $i_total_seasons; $i++) {
                if ($i == 0) {
                    $s_season_list = "'" . $seasons[$i]->GetCompetitionName() . "'";
                } else {
                    if ($i == $i_total_seasons - 1) {
                        $s_season_list .= " and '" . $seasons[$i]->GetCompetitionName() . "'";
                    } else {
                        $s_season_list .= ", '" . $seasons[$i]->GetCompetitionName() . "'";
                    }
                }
            }
        }
        $s_season = $s_season_list ? " in the {$s_season_list}" : '';
        $s_why = $s_season_list ? $s_season_list : 'matches';
        $new = $b_is_new_match ? 'new ' : '';
        $verb = $b_is_new_match ? 'added' : 'updated';
        if ($b_is_deleted_match) {
            $verb = 'deleted';
        }
        $match_text = $o_match->GetMatchType() == MatchType::TOURNAMENT ? 'tournament' : 'match';
        $s_title = html_entity_decode($o_match->GetTitle());
        $s_date = ucfirst($o_match->GetStartTimeFormatted());
        $s_ground = is_object($o_match->GetGround()) ? $o_match->GetGround()->GetNameAndTown() : '';
        $s_notes = $o_match->GetNotes();
        $s_domain = $this->settings->GetDomain();
        $s_url = 'https://' . $s_domain . $o_match->GetNavigateUrl();
        $s_contact_url = 'https://' . $s_domain . $this->settings->GetFolder('Contact');
        $s_home_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetHomeTeam()->GetName());
        $s_away_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetAwayTeam()->GetName());
        $s_bat_first = is_null($o_match->Result()->GetHomeBattedFirst()) ? 'Not known which team batted first' : ($o_match->Result()->GetHomeBattedFirst() ? $s_home_name : $s_away_name) . ' batted first';
        $s_home_runs = is_null($o_match->Result()->GetHomeRuns()) ? '(not known)' : $o_match->Result()->GetHomeRuns();
        $s_home_wickets = is_null($o_match->Result()->GetHomeWickets()) ? '(not known)' : $o_match->Result()->GetHomeWickets();
        if ($s_home_wickets == -1) {
            $s_home_wickets = 'all out';
        } else {
            $s_home_wickets = 'for ' . $s_home_wickets . ' wickets';
        }
        $s_away_runs = is_null($o_match->Result()->GetAwayRuns()) ? '(not known)' : $o_match->Result()->GetAwayRuns();
        $s_away_wickets = is_null($o_match->Result()->GetAwayWickets()) ? '(not known)' : $o_match->Result()->GetAwayWickets();
        if ($s_away_wickets == -1) {
            $s_away_wickets = 'all out';
        } else {
            $s_away_wickets = 'for ' . $s_away_wickets . ' wickets';
        }
        $s_user = $o_user->GetName();
        $s_body = wordwrap("A {$new}{$match_text} has been {$verb} on the Stoolball England website at {$s_domain}{$s_season}.\n\n" . "The {$match_text} was {$verb} by {$s_user}.\n\n" . "The {$match_text} details are as follows:\n\n" . "    {$s_title}\n" . "    {$s_date}\n" . "    {$s_ground}");
        if ($s_notes) {
            $s_notes = "\n\n" . wordwrap($s_notes, 70);
            $s_notes = str_replace("\n", "\n    ", $s_notes);
            $s_body .= $s_notes;
        }
        if ($o_match->GetStartTime() <= gmdate('U') and !$b_is_new_match and $o_match->GetMatchType() != MatchType::TOURNAMENT) {
            $s_body .= <<<EMAILBODY


\t{$s_bat_first}
EMAILBODY;
            if ($o_match->Result()->GetHomeBattedFirst() === false) {
                $s_body .= <<<EMAILBODY

\t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets}
\t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets}
EMAILBODY;
            } else {
                $s_body .= <<<EMAILBODY

\t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets}
\t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets}
EMAILBODY;
            }
        }
        $s_body .= "\n\n";
        if (!$b_is_deleted_match) {
            $s_body .= wordwrap("You can view the {$match_text} at {$s_url}\n\n");
        }
        $s_body .= wordwrap("You have received this email because you are the administrative contact for {$s_why} on {$s_domain}.\n\n" . "We let you know when a {$match_text} is {$verb} by a member of the public, so that you can check there's nothing wrong.\n\n" . "If this email has been sent to the wrong address, or if the {$match_text} details are wrong, please let us know using the contact form at {$s_contact_url}.\n\n");
        # send email, copy to me
        require_once 'Zend/Mail.php';
        $o_email = new Zend_Mail('UTF-8');
        $o_email->addTo($s_email);
        $o_email->setFrom('*****@*****.**', 'Stoolball England alerts');
        $o_email->setSubject(ucfirst($match_text) . " {$verb}: {$s_title}, {$s_date}");
        $o_email->setBodyText($s_body);
        try {
            $o_email->send();
        } catch (Zend_Mail_Transport_Exception $e) {
            # Do nothing - failure to send this email should not be a fatal error
        }
    }
 /**
  * Gets the format to use for a team's short URLs
  *
  * @param SiteSettings
  * @return ShortUrlFormat
  */
 public static function GetShortUrlFormatForType(SiteSettings $settings)
 {
     return new ShortUrlFormat("nsa_team", 'short_url', array('team_id'), array('GetId'), array('{0}' => $settings->GetUrl('Team') . '{0}', '{0}/edit' => "/play/teams/teamedit.php?item={0}", '{0}/delete' => "/play/teams/teamdelete.php?item={0}", '{0}/matches/friendlies/add' => '/play/matches/matchadd.php?team={0}', '{0}/matches/league/add' => '/play/matches/matchadd.php?team={0}&type=' . MatchType::LEAGUE, '{0}/matches/cup/add' => '/play/matches/matchadd.php?team={0}&type=' . MatchType::CUP, '{0}/matches/practices/add' => '/play/matches/matchadd.php?team={0}&type=' . MatchType::PRACTICE, '{0}/matches/tournaments/add' => '/play/tournaments/add.php?team={0}', '{0}/matches/edit' => $settings->GetUrl('TeamResults'), '{0}/calendar' => $settings->GetUrl('TeamCalendar'), '{0}/statistics' => $settings->GetUrl('TeamStats'), '{0}/players' => '/play/teams/players.php?team={0}', '{0}/players/add' => $settings->GetUrl('PlayerAdd'), '{0}/statistics.json' => "/play/statistics/team.js.php?team={0}"));
 }
 /**
  * Gets the format to use for a ground's short URLs
  *
  * @param SiteSettings
  * @return ShortUrlFormat
  */
 public static function GetShortUrlFormatForType(SiteSettings $settings)
 {
     return new ShortUrlFormat($settings->GetTable('Ground'), 'short_url', array('ground_id'), array('GetId'), array('{0}' => '/play/grounds/ground.php?item={0}', '{0}/statistics' => $settings->GetUrl('GroundStatistics'), '{0}/edit' => '/play/grounds/groundedit.php?item={0}', '{0}/delete' => '/play/grounds/grounddelete.php?item={0}'));
 }