Records settings for the anonymous users (default report, default date)
509820
public function recordAnonymousUserSettings()
    {
        $response = new ResponseBuilder(Common::getRequestVar('format'));
        try {
            Piwik::checkUserHasSuperUserAccess();
            $this->checkTokenInUrl();

            $anonymousDefaultReport = Common::getRequestVar('anonymousDefaultReport');
            $anonymousDefaultDate = Common::getRequestVar('anonymousDefaultDate');
            $userLogin = 'anonymous';
            APIUsersManager::getInstance()->setUserPreference($userLogin,
                APIUsersManager::PREFERENCE_DEFAULT_REPORT,
                $anonymousDefaultReport);
            APIUsersManager::getInstance()->setUserPreference($userLogin,
                APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE,
                $anonymousDefaultDate);
            $toReturn = $response->getResponse();
        } catch (Exception $e) {
            $toReturn = $response->getResponseException($e);
        }

        return $toReturn;
    }
144518
def handle_anonymous_user(self, response):
        
        try:
            ulogin = ULoginUser.objects.get(network=response['network'],
                                            uid=response['uid'])
        except ULoginUser.DoesNotExist:
            user = create_user(request=self.request,
                               ulogin_response=response)
            ulogin = ULoginUser.objects.create(user=user,
                                               network=response['network'],
                                               identity=response['identity'],
                                               uid=response['uid'])
            registered = True
        else:
            user = ulogin.user
            registered = False

        # Authenticate user
        if not hasattr(user, 'backend'):
            user.backend = settings.AUTHENTICATION_BACKEND
        login(self.request, user)

        return user, ulogin, registered
346955
protected function insertDayReports()
    {
        $this->insertDayNumericMetrics();

        // insert DataTable reports
        foreach ($this->getRecordNames() as $recordName) {
            $blob = $this->getDataArray($recordName)->asDataTable()->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
            $this->getProcessor()->insertBlobRecord($recordName, $blob);
        }
    }
304299
function(report) {
		if (edbml.debug) {
			if (gui.KeyMaster.isKey(this.id)) {
				report = report.replace(this.id, "(anonymous)");
			}
			console.debug(report);
		}
	}
612988
private void populateDateTimeSettings(Record record, ProjectProperties properties)
   {
      properties.setDateOrder(record.getDateOrder(0));
      properties.setTimeFormat(record.getTimeFormat(1));

      Date time = getTimeFromInteger(record.getInteger(2));
      if (time != null)
      {
         properties.setDefaultStartTime(time);
      }

      Character c = record.getCharacter(3);
      if (c != null)
      {
         properties.setDateSeparator(c.charValue());
      }

      c = record.getCharacter(4);
      if (c != null)
      {
         properties.setTimeSeparator(c.charValue());
      }

      properties.setAMText(record.getString(5));
      properties.setPMText(record.getString(6));
      properties.setDateFormat(record.getDateFormat(7));
      properties.setBarTextDateFormat(record.getDateFormat(8));
   }
45211
public function requireDefaultRecords()
    {
        parent::requireDefaultRecords();

        // Add default author group if no other group exists
        $allGroups = Group::get();
        if (!$allGroups->count()) {
            $authorGroup = new Group();
            $authorGroup->Code = 'content-authors';
            $authorGroup->Title = _t(__CLASS__ . '.DefaultGroupTitleContentAuthors', 'Content Authors');
            $authorGroup->Sort = 1;
            $authorGroup->write();
            Permission::grant($authorGroup->ID, 'CMS_ACCESS_CMSMain');
            Permission::grant($authorGroup->ID, 'CMS_ACCESS_AssetAdmin');
            Permission::grant($authorGroup->ID, 'CMS_ACCESS_ReportAdmin');
            Permission::grant($authorGroup->ID, 'SITETREE_REORGANISE');
        }

        // Add default admin group if none with permission code ADMIN exists
        $adminGroups = Permission::get_groups_by_permission('ADMIN');
        if (!$adminGroups->count()) {
            $adminGroup = new Group();
            $adminGroup->Code = 'administrators';
            $adminGroup->Title = _t(__CLASS__ . '.DefaultGroupTitleAdministrators', 'Administrators');
            $adminGroup->Sort = 0;
            $adminGroup->write();
            Permission::grant($adminGroup->ID, 'ADMIN');
        }

        // Members are populated through Member->requireDefaultRecords()
    }
108005
function _setDefaults()
    {
    	$this->options['db_type']	= 'mysql';
        $this->options['table']       = 'auth';
        $this->options['usernamecol'] = 'username';
        $this->options['passwordcol'] = 'password';
        $this->options['dsn']         = '';
        $this->options['db_fields']   = '';
        $this->options['cryptType']   = 'md5';
    }
468116
public function setup_users() {
        global $SESSION, $DB;

        $this->userwheresql = "";
        $this->userwheresql_params = array();
        if (isset($SESSION->gradereport['filterfirstname']) && !empty($SESSION->gradereport['filterfirstname'])) {
            $this->userwheresql .= ' AND '.$DB->sql_like('u.firstname', ':firstname', false, false);
            $this->userwheresql_params['firstname'] = $SESSION->gradereport['filterfirstname'].'%';
        }
        if (isset($SESSION->gradereport['filtersurname']) && !empty($SESSION->gradereport['filtersurname'])) {
            $this->userwheresql .= ' AND '.$DB->sql_like('u.lastname', ':lastname', false, false);
            $this->userwheresql_params['lastname'] = $SESSION->gradereport['filtersurname'].'%';
        }
    }
317502
def process_user_record(cls, info):
        """"""
        keys = list(info.keys())
        # Value conversion
        for k in keys:
            v = info[k]
            if v in ('N/A', 'no_information'):
                info[k] = None
            elif v == 'false':
                info[k] = False
            elif v == 'true':
                info[k] = True
        # Object conversion
        for p, t in cls.list_sub_objects:
            obj = dict([(k[len(p):], info.pop(k))
                        for k in keys if k.startswith(p)])
            if obj.get('active', False):
                info.setdefault(t, []).append(obj)
        return info
1273597
def editpermissions_anonymous_user_view(self, request, forum_id=None):
        
        forum = get_object_or_404(Forum, pk=forum_id) if forum_id else None

        # Set up the context
        context = self.get_forum_perms_base_context(request, forum)
        context['forum'] = forum
        context['title'] = '{} - {}'.format(_('Forum permissions'), _('Anonymous user'))
        context['form'] = self._get_permissions_form(
            request, UserForumPermission, {'forum': forum, 'anonymous_user': True},
        )

        return render(request, self.editpermissions_anonymous_user_view_template_name, context)
902019
def default_fields
        @default_fields ||= {
          id:              SecureRandom.uuid.gsub('-', ''),
          group_id:        nil,
          icon:            1,
          name:            nil,
          url:             nil,
          username:        nil,
          password:        nil,
          notes:           nil,
          creation_time:   Time.now,
          last_mod_time:   Time.now,
          last_acc_time:   Time.now,
          expiration_time: Time.local(2999, 12, 28, 23, 59, 59),
          binary_desc:     nil,
          binary_data:     nil,
          terminator:      nil,
        }
      end
1253458
def accounting(dbfile,config):
    ''' 
    '''
    try:
        nas_id = config.get('DEFAULT', 'nas_id')
        nas_addr = config.get('DEFAULT', 'nas_addr')
        secret = config.get('DEFAULT', 'radius_secret')
        radius_addr = config.get('DEFAULT', 'radius_addr')
        radius_acct_port = config.getint('DEFAULT', 'radius_acct_port')
        radius_timeout = config.getint('DEFAULT', 'radius_timeout')
        status_dbfile = config.get('DEFAULT', 'statusdb')

        clients = statusdb.query_client(status_dbfile)

        ctime = int(time.time())
        for cli in clients:
            if (ctime - int(cli['uptime'])) < int(cli['acct_interval']):
                continue

            session_id = cli['session_id']
            req = {'User-Name':cli['username']}
            req['Acct-Status-Type'] = ACCT_UPDATE
            req['Acct-Session-Id'] = session_id
            req["Acct-Output-Octets"]  =  int(cli['outbytes'])
            req["Acct-Input-Octets"]  =  int(cli['inbytes'])
            req['Acct-Session-Time'] = (ctime - int(cli['ctime']))
            req["NAS-IP-Address"]     = nas_addr
            req["NAS-Port-Id"]     = '0/0/0:0.0'
            req["NAS-Port"]           = 0
            req["Service-Type"]       = "Login-User"
            req["NAS-Identifier"]     = nas_id
            req["Called-Station-Id"]  = '00:00:00:00:00:00'
            req["Calling-Station-Id"] = '00:00:00:00:00:00'
            req["Framed-IP-Address"]  = cli['userip']

            def update_uptime(radresp):
                statusdb.update_client_uptime(status_dbfile,session_id)
                log.msg('online<%s> client accounting update'%session_id)

            def onresp(r):
                try:
                    update_uptime(r)
                except Exception as e:
                    log.err('online update uptime error')
                    log.err(e)

            d = client.send_acct(str(secret), get_dictionary(), radius_addr, 
                acctport=radius_acct_port, debug=True,**req)
            d.addCallbacks(onresp,log.err)

    except Exception, e:
        log.err('accounting error')
        log.err(e)
570944
def default_log_template(self, record):
    

    reset = Style.RESET_ALL
    levelname = [
        LEVEL_COLORS.get(record.levelname),
        Style.BRIGHT,
        '(%(levelname)s)',
        Style.RESET_ALL,
        ' ',
    ]
    asctime = [
        '[',
        Fore.BLACK,
        Style.DIM,
        Style.BRIGHT,
        '%(asctime)s',
        Fore.RESET,
        Style.RESET_ALL,
        ']',
    ]
    name = [
        ' ',
        Fore.WHITE,
        Style.DIM,
        Style.BRIGHT,
        '%(name)s',
        Fore.RESET,
        Style.RESET_ALL,
        ' ',
    ]

    tpl = "".join(reset + levelname + asctime + name + reset)

    return tpl
1130162
public function index()
    {
        if (!userHasPermission('admin:blog:settings:\d+:update')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Load models
        $this->load->model('blog/blog_model');
        $oSkinModel = Factory::model('Skin', 'nails/module-blog');

        // --------------------------------------------------------------------------

        $this->data['blogs'] = $this->blog_model->getAllFlat();

        if (empty($this->data['blogs'])) {

            if (userHasPermission('admin:blog:blog:create')) {

                $status   = 'message';
                $message  = '<strong>You don\'t have a blog!</strong> Create a new blog ';
                $message .= 'in order to configure blog settings.';
                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData($status, $message);
                redirect('admin/blog/blog/create');

            } else {

                show404();
            }
        }

        if (count($this->data['blogs']) == 1) {

            reset($this->data['blogs']);
            $this->data['selectedBlogId'] = key($this->data['blogs']);

        } elseif ($this->input->get('blog_id')) {

            if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

                $this->data['selectedBlogId'] = $this->input->get('blog_id');
            }

            if (empty($this->data['selectedBlogId'])) {

                $this->data['error'] = 'There is no blog by that ID.';
            }
        }

        //  Check user has permission
        if (!empty($this->data['selectedBlogId'])) {

            if (!userHasPermission('admin:blog:settings:' . $this->data['selectedBlogId'] . ':update')) {

                unauthorised();
            }
        }

        //  Set up the skin model for this blog
        //  @todo; work out a cleaner way of handling this
        $oSkinModel->init($this->data['selectedBlogId']);

        // --------------------------------------------------------------------------

        //  Process POST
        if ($this->input->post()) {

            //  Prepare update
            $settings                       = array();
            $settings['name']               = $this->input->post('name');
            $settings['url']                = $this->input->post('url');
            $settings['postName']           = strtolower($this->input->post('postName'));
            $settings['postNamePlural']     = strtolower($this->input->post('postNamePlural'));
            $settings['use_excerpts']       = (bool) $this->input->post('use_excerpts');
            $settings['gallery_enabled']    = (bool) $this->input->post('gallery_enabled');
            $settings['categories_enabled'] = (bool) $this->input->post('categories_enabled');
            $settings['tags_enabled']       = (bool) $this->input->post('tags_enabled');
            $settings['rss_enabled']        = (bool) $this->input->post('rss_enabled');

            //  Skin settings
            $settings['skin'] = $this->input->post('skin');

            //  Commenting settings
            $settings['comments_enabled']          = $this->input->post('comments_enabled');
            $settings['comments_engine']           = $this->input->post('comments_engine');
            $settings['comments_disqus_shortname'] = $this->input->post('comments_disqus_shortname');

            //  Social settings
            $settings['social_facebook_enabled']   = (bool) $this->input->post('social_facebook_enabled');
            $settings['social_twitter_enabled']    = (bool) $this->input->post('social_twitter_enabled');
            $settings['social_twitter_via']        = $this->input->post('social_twitter_via');
            $settings['social_googleplus_enabled'] = (bool) $this->input->post('social_googleplus_enabled');
            $settings['social_pinterest_enabled']  = (bool) $this->input->post('social_pinterest_enabled');
            $settings['social_skin']               = $this->input->post('social_skin');
            $settings['social_layout']             = $this->input->post('social_layout');
            $settings['social_layout_single_text'] = $this->input->post('social_layout_single_text');
            $settings['social_counters']           = (bool) $this->input->post('social_counters');

            //  If any of the above are enabled, then social is enabled.
            $settings['social_enabled'] = $settings['social_facebook_enabled'] || $settings['social_twitter_enabled'] || $settings['social_googleplus_enabled'] || $settings['social_pinterest_enabled'];

            //  Sidebar
            $settings['sidebar_latest_posts']  = (bool) $this->input->post('sidebar_latest_posts');
            $settings['sidebar_categories']    = (bool) $this->input->post('sidebar_categories');
            $settings['sidebar_tags']          = (bool) $this->input->post('sidebar_tags');
            $settings['sidebar_popular_posts'] = (bool) $this->input->post('sidebar_popular_posts');

            //  @todo: Associations

            // --------------------------------------------------------------------------

            //  Sanitize blog url
            $settings['url'] .= substr($settings['url'], -1) != '/' ? '/' : '';

            // --------------------------------------------------------------------------

            //  Save
            $oAppSettingService = Factory::service('AppSetting');

            if ($oAppSettingService->set($settings, 'blog-' . $this->input->get('blog_id'))) {

                $this->data['success'] = 'Blog settings have been saved.';

                $oRoutesService = Factory::service('Routes');

                if (!$oRoutesService->update()) {

                    $this->data['warning']  = '<strong>Warning:</strong> while the blog settings were updated, the ';
                    $this->data['warning'] .= 'routes file could not be updated. The blog may not behave as expected,';
                }

            } else {

                $this->data['error'] = 'There was a problem saving settings.';
            }
        }

        // --------------------------------------------------------------------------

        //  Get data
        $this->data['skins']        = $oSkinModel->getAll();
        $this->data['skinSelected'] = $oSkinModel->getEnabled();

        if (!empty($this->data['selectedBlogId'])) {

            $this->data['settings'] = appSetting(null, 'blog-' . $this->data['selectedBlogId'], true);
        }

        // --------------------------------------------------------------------------

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->load('admin.settings.min.js', 'nails/module-blog');

        // --------------------------------------------------------------------------

        //  Set page title
        $this->data['page']->title = 'Settings &rsaquo; Blog';

        if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

            $this->data['page']->title .= ' &rsaquo; ' . $this->data['blogs'][$this->input->get('blog_id')];
        }

        // --------------------------------------------------------------------------

        //  Add a header button
        if (userHasPermission('admin:blog:blog:manage')) {
            Helper::addHeaderButton(
                'admin/blog/blog/index',
                'Manage Blogs'
            );
        }

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }
1041567
public function requireDefaultRecords()
    {
        $records = (array) Config::inst()->get(get_class($this), 'default_records');
        foreach ($records as $name) {
            $type = TaxonomyType::get()->filter('Name', $name)->first();
            if (!$type) {
                $type = TaxonomyType::create(array('Name' => $name));
                $type->write();
            }
        }
    }
956358
function set_data($default_values) {
        if (!is_object($default_values)) {
            // we need object for file_prepare_standard_editor
            $default_values = (object)$default_values;
        }
        $editoroptions = $this->_customdata['editoroptions'];
        $default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions,
                $editoroptions['context'], 'course', 'section', $default_values->id);
        if (strval($default_values->name) === '') {
            $default_values->name = false;
        }
        parent::set_data($default_values);
    }
1301804
public function onAdminInit()
    {
        if (!in_array($this->App->Config->§specs['§type'], ['theme', 'plugin'], true)) {
            return; // Not applicable; themes/plugins only.
        } // e.g., We don't collect stats for a simple MU plugin.

        if (!$this->c::appCore()->s::applyFilters('app_stats_enable', true)) {
            return; // Stats disabled via filter.
        }
        $last_posted = $this->lastPosted();

        if ($last_posted['time'] > $this->outdated_stats_time) {
            return; // Not time to post stats again yet.
        } // Must be 1+ week apart (enforced by remote API).

        $anonymous_stats = [
            'os'            => PHP_OS,
            'php_version'   => PHP_VERSION,
            'mysql_version' => $this->s::wpDb()->db_version(),

            'wp_version'      => WP_VERSION,
            'product_version' => $this->App::VERSION,
            'product'         => $this->App->Config->©brand['§product_slug'],
        ];
        wp_remote_post($this->s::coreBrandStatsUrl('/log'), [
                'blocking'  => false,
                'sslverify' => false,
                'body'      => $anonymous_stats,
        ]);
        $this->lastPosted(['time' => time()]); // Record last time.
    }