## --------------------------------------------------------
978723
public function gd_filter_vintage()
	{
		if ($this->imageResized)
		{
			$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 45);
			imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 20);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -35);
			imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, -10, 35);
			imagefilter($this->imageResized, IMG_FILTER_SMOOTH, 7);
			$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'scratch', 10);
		}
	}
1038254
public function supportAction()
    {
        $this->initHtml();

        $this->html->h3($this->_('Support'));
        $this->html->pInfo()->sprintf(
                $this->_('There is more than one way to get support for %s.'),
                $this->project->getName()
                );

        if ($url = $this->project->getDocumentationUrl()) {
            $this->html->h4($this->_('Documentation'));

            $this->html->pInfo()->sprintf($this->_('All available documentation is gathered at: %s'))
                    ->a($url, array('rel' => 'external', 'target' => 'documentation'));
        }

        if ($url = $this->project->getManualUrl()) {
            $this->html->h4($this->_('Manual'));

            $this->html->pInfo()->sprintf($this->_('The manual is available here: %s'))
                    ->a($url, array('rel' => 'external', 'target' => 'manual'));
        }

        if ($url = $this->project->getForumUrl()) {
            $this->html->h4($this->_('The forum'));

            $this->html->pInfo()->sprintf($this->_(
                    'You will find questions asked by other users and ask new questions at our forum site: %s'
                    ))->a($url, array('rel' => 'external', 'target' => 'forum'));
        }

        if ($url = $this->project->getSupportUrl()) {
            $this->html->h4($this->_('Support site'));

            $this->html->pInfo()->sprintf($this->_('Check our support site at %s.'))
                    ->a($url, array('rel' => 'external', 'target' => 'support'));
        }

        $this->html->h4($this->_('Or contact'));
        $this->html->append($this->_getOrganizationsList());
    }
491783
public function index()
    {
        $this->requireAdmin();

        $this->layout->title = Lang::get('settings');

        $this->view->settings = $this->settings;

        $basicSettings = array();
        if (isset($this->settings['phpci']['basic'])) {
            $basicSettings = $this->settings['phpci']['basic'];
        }

        $buildSettings = array();
        if (isset($this->settings['phpci']['build'])) {
            $buildSettings = $this->settings['phpci']['build'];
        }

        $latestBuildsSettings = array();
        if (isset($this->settings['phpci']['latest_builds'])) {
            $latestBuildsSettings = $this->settings['phpci']['latest_builds'];
        }

        $emailSettings = array();
        if (isset($this->settings['phpci']['email_settings'])) {
            $emailSettings = $this->settings['phpci']['email_settings'];
        }

        $authSettings = array();
        if (isset($this->settings['phpci']['authentication_settings'])) {
            $authSettings = $this->settings['phpci']['authentication_settings'];
        }

        $this->view->configFile = PHPCI_CONFIG_FILE;
        $this->view->basicSettings = $this->getBasicForm($basicSettings);
        $this->view->latestBuildsSettings = $this->getLatestBuildsForm($latestBuildsSettings);
        $this->view->buildSettings = $this->getBuildForm($buildSettings);
        $this->view->github = $this->getGithubForm();
        $this->view->emailSettings = $this->getEmailForm($emailSettings);
        $this->view->authenticationSettings = $this->getAuthenticationForm($authSettings);
        $this->view->isWriteable = $this->canWriteConfig();

        if (!empty($this->settings['phpci']['github']['token'])) {
            $this->view->githubUser = $this->getGithubUser($this->settings['phpci']['github']['token']);
        }

        return $this->view->render();
    }
1189330
public function render(): void
	{
		$page = $this->paginator->page;
		if ($this->paginator->pageCount < 2) {
			$steps = [$page];
			$viewed = false;
		} else {
			$viewed = true;

			$f = $first = $page - $this->pageAround;
			$l = $last = $page + $this->pageAround;
			if ($f < $this->paginator->firstPage) {
				$last += ($this->paginator->firstPage - $f);
			}
			if ($l > $this->paginator->lastPage) {
				$first -= ($l - $this->paginator->lastPage);
			}
			$arr = range(max($this->paginator->firstPage, $first), min($this->paginator->lastPage, $last));

			if ($this->othersPage > 0) {
				$count = $this->othersPage * 2;
				$quotient = ($this->paginator->pageCount - 1) / $count;
				for ($i = 0; $i <= $count; $i++) {
					$arr[] = round($quotient * $i) + $this->paginator->firstPage;
				}
				sort($arr);
				$steps = array_values(array_unique($arr));
			} else {
				$steps = $arr;
			}
		}

		$this->template->viewed = $viewed;
		$this->template->steps = $steps;
		$this->template->paginator = $this->paginator;
		$this->template->isAjax = $this->isAjax;
		$this->template->noHistory = $this->noHistory;
		$this->template->prev = $this->prev;
		$this->template->next = $this->next;
		$this->template->other = $this->other;
		if (count($this->onClick ?? []) > 0) {
			$this->template->handle = 'click!';
		} else {
			$this->template->handle = 'this';
		}

		$this->template->setFile($this->templateFile);
		$this->template->render();
	}
845733
public function indexAction()
    {
        $user = $this->userService->getCurrentUser();
        $workspacesArray = [];
        /** @var Workspace $workspace */
        foreach ($this->workspaceRepository->findAll() as $workspace) {

            // FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
            if ($workspace->getOwner() !== null && $workspace->getOwner() !== $user) {
                continue;
            }

            $workspaceArray = [
                'name' => $workspace->getName(),
                'title' => $workspace->getTitle(),
                'description' => $workspace->getDescription(),
                'baseWorkspace' => $workspace->getBaseWorkspace()
            ];
            if ($user !== null) {
                $workspaceArray['readonly'] = !$this->userService->currentUserCanPublishToWorkspace($workspace);
            }
            $workspacesArray[] = $workspaceArray;
        }

        $this->view->assign('workspaces', $workspacesArray);
    }
905149
public function validate()
    {
        $preFunctions = $this->getPreFunctions();
        $postFunctions = $this->getPostFunctions();
        $validators = $this->getValidators();

        ValidationHelper::validate($preFunctions);
        ValidationHelper::validate($postFunctions);
        ValidationHelper::validate($validators);

        $split = $this->getSplit();
        $join = $this->getJoin();

        $parent = $this->getParent();
        if ((null === $split) && (null === $join) && !($parent instanceof ActionDescriptor && ($parent->isFinish()))) {
            $errMsg = '';
            $id = (integer)$this->getId();
            if (is_numeric($id)) {
                $errMsg .= sprintf('#%s:', $id);
            }
            $errMsg .= 'Если не указано значение атрибутов split или join, необходимо указать';

            if (!$this->hasStep) {
                $errMsg .= ' id следующего шага';
                throw new InvalidWorkflowDescriptorException($errMsg);
            }

            $status = $this->getStatus();
            if (!$status) {
                $errMsg .= ' статус';
                throw new InvalidWorkflowDescriptorException($errMsg);
            }
        }
    }
841278
public function parse()
    {
        $args = $this->formatInputArguments();

        foreach ($args as $key => $value) {
            if ('--' === substr($value, 0, 2)) {
                $this->parseOption(substr($value, 2));
            } else if ('-' === substr($value, 0, 1)) {
                $this->parseOption(substr($value, 1));
            } else {
                $this->parseArgument($value);
            }
        }
    }
214326
public function run()
    {
        if (!is_array($rules = $this->getRules())) {
            $rules = $this->convertToArray($rules);
        }

        if (!is_array($datas = $this->getDatas())) {
            $datas = $this->convertToArray($datas);
        }

        foreach ($rules as $key => $rule) {
            $parsedRules = explode("|", $rule);

            foreach ($parsedRules as $parsedRule) {
                $required = $this->handleRule($parsedRule, $key, $datas);

                if ($required !== null && $required === false) {
                    break;
                }
            }
        }
    }
233719
public function run()
    {
        DB::table('groups')->delete();

        // users
        $permissions = array('user' => 1, 'edit' => 0, 'blog' => 0, 'mod' => 0, 'admin' => 0);
        $group = array('name' => 'Users', 'permissions' => $permissions);
        Credentials::getGroupProvider()->create($group);

        // editors
        $permissions = array('user' => 1, 'edit' => 1, 'blog' => 0, 'mod' => 0, 'admin' => 0);
        $group = array('name' => 'Editors', 'permissions' => $permissions);
        Credentials::getGroupProvider()->create($group);

        // bloggers
        $permissions = array('user' => 1, 'edit' => 0, 'blog' => 1, 'mod' => 0, 'admin' => 0);
        $group = array('name' => 'Bloggers', 'permissions' => $permissions);
        Credentials::getGroupProvider()->create($group);

        // moderators
        $permissions = array('user' => 1, 'edit' => 0, 'blog' => 0, 'mod' => 1, 'admin' => 0);
        $group = array('name' => 'Moderators', 'permissions' => $permissions);
        Credentials::getGroupProvider()->create($group);

        // admins
        $permissions = array('user' => 1, 'edit' => 1, 'blog' => 1, 'mod' => 1, 'admin' => 1);
        $group = array('name' => 'Admins', 'permissions' => $permissions);
        Credentials::getGroupProvider()->create($group);
    }
100910
public function info()
    {
        $data = [
            'name' => $this->name,
            'type' => $this->type
        ];
        if ($this->value !== null) {
            $data['value'] = $this->value;
        }
        if ($this->varTableIndex !== null) {
            $data['varTableIndex'] = $this->varTableIndex;
        }
        if ($this->members) {
            $data['members'] = array_map(function ($v) {
                return $v->info();
            }, $this->members);
        }
        if ($this->status) {
            $data['status'] = $this->status->info();
        }
        return $data;
    }
306610
public function populate($data = array())
    {
        $this->title = (isset($data['title'])) ? $data['title'] : null;
        if (isset($data['is_active']) && $data['is_active'] != null) {
            $this->is_active = $data['is_active'];
        }
        if (isset($data['content']) && $data['content'] != null) {
            $this->content = $data['content'];
        }
        $this->identifier = (isset($data['identifier'])) ? $data['identifier'] : null;
    }
1353361
public function run()
    {
        $stime = microtime(true);
        $this->header('Content-Type: text/html; charset=utf-8');
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>Server status.</title>
        </head>
        <body>
        <br/>Uptime: <b><?php echo DateTime::diffAsText(Daemon::$startTime, time());
            ?></b>
        <br/><br/><b>State of workers:</b><?php $stat = Daemon::getStateOfWorkers();
        ?>
        <br/>Idle: <?php echo $stat['idle'];
        ?>
        <br/>Busy: <?php echo $stat['busy'];
        ?>
        <br/>Total alive: <?php echo $stat['alive'];
        ?>
        <br/>Shutdown: <?php echo $stat['shutdown'];
        ?>
        <br/>Pre-init: <?php echo $stat['preinit'];
        ?>
        <br/>Wait-init: <?php echo $stat['waitinit'];
        ?>
        <br/>Init: <?php echo $stat['init'];
        ?>
        <br/>
        <br/>Request took: <?php printf('%f', round(microtime(true) - $stime, 6));
        ?>
        </body>
        </html>
        <?php
    }
564148
public function run() {
		
		$id = $this->htmlOptions['id'];

		echo CHtml::openTag('div', $this->htmlOptions);

		foreach ($this->alerts as $type => $alert) {

			if (is_string($alert)) {
				$type = $alert;
				$alert = array();
			}

			if (isset($alert['visible']) && $alert['visible'] === false) {
				continue;
			}

			/** @var CWebUser $userComponent */
			$userComponent = Yii::app()->getComponent($this->userComponentId);
			if (!$userComponent->hasFlash($type))
				continue;

			$alertText = $userComponent->getFlash($type);
            if (empty($alertText)) { // null, ''
                continue;
            }

			$this->renderSingleAlert($alert, $type, $alertText);
		}

		echo CHtml::closeTag('div');

		$id .= '_' . self::$_containerId++;
		$selector = "#{$id} .alert";

		/** @var CClientScript $cs */
		$cs = Yii::app()->getClientScript();
		$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('{$selector}').alert();");

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			$cs->registerScript(
				__CLASS__ . '#' . $id . '_' . $name,
				"jQuery('{$selector}').on('{$name}', {$handler});"
			);
		}
	}
970680
public function init()
    {
        if ($this->countRows < 1) {
            $this->totalPages = 0;
            $this->currentPage = 0;

            return;
        }

        if ($this->limit < 10) {
            $this->limit = 10;
        }

        $this->totalPages = (int)($this->countRows / $this->limit);

        if ($this->countRows % $this->limit) {
            $this->totalPages++;
        }

        if ($this->totalPages === 0) {
            $this->totalPages = 1;
        }

        if ($this->currentPage < 0) {
            $this->currentPage = 0;
        }

        if ($this->currentPage > $this->totalPages) {
            $this->currentPage = $this->totalPages;
        }
    }
555642
public function process()
    {
        parent::process();

        if (!$this->isVisible()) {
            return;
        }

        $hour = 0;
        $minute = 0;
        $second = 0;

        $all_empty = true;
        $any_empty = false;

        if ($this->display_parts & self::HOUR) {
            $hour_flydown = $this->getCompositeWidget('hour_flydown');
            $hour = $hour_flydown->value;
            if ($hour === null) {
                if ($this->required_parts & self::HOUR) {
                    $any_empty = true;
                } else {
                    $hour = 0;
                }
            } else {
                $all_empty = false;
            }

            if ($this->twelve_hour) {
                $am_pm_flydown = $this->getCompositeWidget('am_pm_flydown');
                $am_pm = $am_pm_flydown->value;
                if ($am_pm === null) {
                    if ($this->required_parts & self::HOUR) {
                        $any_empty = true;
                    } else {
                        $am_pm = 'am';
                    }
                } else {
                    $all_empty = false;
                }

                // convert 12-hour display to 24-hour value
                if ($hour !== null && $am_pm == 'pm' && $hour != 12) {
                    $hour += 12;
                }
                if ($hour == 12 && $am_pm == 'am') {
                    $hour = 0;
                }
            }
        }

        if ($this->display_parts & self::MINUTE) {
            $minute_flydown = $this->getCompositeWidget('minute_flydown');
            $minute = $minute_flydown->value;
            if ($minute === null) {
                if ($this->required_parts & self::MINUTE) {
                    $any_empty = true;
                } else {
                    $minute = 0;
                }
            } else {
                $all_empty = false;
            }
        }

        if ($this->display_parts & self::SECOND) {
            $second_flydown = $this->getCompositeWidget('second_flydown');
            $second = $second_flydown->value;
            if ($second === null) {
                if ($this->required_parts & self::SECOND) {
                    $any_empty = true;
                } else {
                    $second = 0;
                }
            } else {
                $all_empty = false;
            }
        }

        if ($all_empty) {
            if ($this->required && $this->isSensitive()) {
                if ($this->show_field_title_in_messages) {
                    $message = Swat::_('%s is required.');
                } else {
                    $message = Swat::_('This field is required.');
                }
                $this->addMessage(new SwatMessage($message, 'error'));
            }
            $this->value = null;
        } elseif ($any_empty) {
            if ($this->show_field_title_in_messages) {
                $message = Swat::_('%s is not a valid time.');
            } else {
                $message = Swat::_('This is not a valid time.');
            }
            $this->addMessage(new SwatMessage($message, 'error'));
            $this->value = null;
        } else {
            try {
                $date = new SwatDate();
                if (
                    $date->setDate(
                        self::$date_year,
                        self::$date_month,
                        self::$date_day
                    ) === false
                ) {
                    throw new SwatException('Invalid date.');
                }

                if ($date->setTime($hour, $minute, $second) === false) {
                    throw new SwatException('Invalid date.');
                }

                $date->setTZById('UTC');

                $this->value = $date;
                $this->validateRanges();
            } catch (SwatException $e) {
                if ($this->show_field_title_in_messages) {
                    $message = Swat::_('%s is not a valid time.');
                } else {
                    $message = Swat::_('This is not a valid time.');
                }
                $this->addMessage(new SwatMessage($message, 'error'));
                $this->value = null;
            }
        }
    }
434308
public function total($count)
    {
        if ($this->get) {
            $this->total = ($count > $this->limit) ? ceil($count / $this->limit) : 1;
        }
    }
460690
public function run()
    {
        $groups = config('defaultusergroups');
        $insertGroups = [];

        /**
         * @var string $name
         * @var \Laranix\Auth\Group\Settings $group
         */
        foreach ($groups as $name => $group) {
            $settings = new Settings($group);

            if ($settings->hasRequiredSettings()) {
                $insertGroups[] = [
                    'name'      => $settings->name,
                    'color'     => $settings->color,
                    'icon'      => $settings->icon,
                    'level'     => $settings->level,
                    'flags'     => $settings->flags !== null ? implode(',', $settings->flags) : null,
                    'hidden'    => $settings->hidden,
                ];
            }
        }

        app('db')->table(config('laranixauth.group.table'))->insert($insertGroups);
    }