#==============================================================================
966623
static function __createTRA($SERVICE = 'wsfe')
	{
	  $TRA = new SimpleXMLElement(
	    '<?xml version="1.0" encoding="UTF-8"?>' .
	    '<loginTicketRequest version="1.0">'.
	    '</loginTicketRequest>');
	  $TRA->addChild('header');
	  $TRA->header->addChild('uniqueId',date('U'));
	  $TRA->header->addChild('generationTime',date('c',date('U')-60));
	  $TRA->header->addChild('expirationTime',date('c',date('U')+60));
	  $TRA->addChild('service',$SERVICE);
	  $TRA->asXML(TMP . 'TRA.xml');
	}
190115
public function void() {
		$json = array();

		$this->load->language('extension/payment/pp_express_order');

		if (isset($this->request->get['order_id'])) {
			$order_id = $this->request->get['order_id'];
		} else {
			$order_id = 0;
		}

		$this->load->model('extension/payment/pp_express');

		$paypal_info = $this->model_extension_payment_pp_express->getOrder($order_id);

		if ($paypal_info) {
			$request = array(
				'METHOD'          => 'DoVoid',
				'AUTHORIZATIONID' => $paypal_info['authorization_id'],
				'MSGSUBID'        => uniqid(mt_rand(), true)
			);

			$response = $this->model_extension_payment_pp_express->call($request);

			if (isset($response['ACK']) && ($response['ACK'] != 'Failure') && ($response['ACK'] != 'FailureWithWarning')) {
				$transaction = array(
					'paypal_order_id'       => $paypal_info['paypal_order_id'],
					'transaction_id'        => '',
					'parent_id'             => $paypal_info['authorization_id'],
					'note'                  => '',
					'msgsubid'              => '',
					'receipt_id'            => '',
					'payment_type'          => 'void',
					'payment_status'        => 'Void',
					'pending_reason'        => '',
					'transaction_entity'    => 'auth',
					'amount'                => '',
					'debug_data'            => json_encode($response)
				);

				$this->model_extension_payment_pp_express->addTransaction($transaction);

				$this->model_extension_payment_pp_express->editPayPalOrderStatus($order_id, 'Complete');

				$json['capture_status'] = 'Complete';

				$json['success'] = $this->language->get('text_success');
			} else {
				$json['error'] = (isset($response['L_SHORTMESSAGE0']) ? $response['L_SHORTMESSAGE0'] : $this->language->get('error_transaction'));
			}
		} else {
			$json['error'] = $this->language->get('error_not_found');
		}

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
413357
public function init()
    {
        $this->sessId = $this->attrs->sessId;
        $this->serverId = $this->attrs->serverId;
        $this->path = $this->attrs->path;

        // @TODO: revert timeout after request
        $this->upstream->setTimeouts($this->appInstance->config->networktimeoutread->value,
            $this->appInstance->config->networktimeoutwrite->value);

        $this->opts = $this->appInstance->getRouteOptions($this->attrs->path);
        $this->CORS();
        if ($this->isFinished()) {
            return;
        }
        if ($this->opts['cookie_needed'] && !$this instanceof Info) {
            if (isset($_COOKIE['JSESSIONID'])) {
                $val = $_COOKIE['JSESSIONID'];
                if (!is_string($val) || $val === '') {
                    $val = 'dummy';
                }
            } else {
                $val = 'dummy';
            }
            $this->setcookie('JSESSIONID', $val, 0, '/');
        }
        $this->contentType($this->contentType);
        if (!$this->cacheable) {
            $this->noncache();
            $this->header('X-Accel-Buffering: no');
        }
        if ($this->callbackParamEnabled) {
            if (!isset($_GET['c']) || !is_string($_GET['c']) || preg_match('~[^_\.a-zA-Z0-9]~', $_GET['c'])) {
                $this->header('500 Internal Server Error');
                $this->out('"callback" parameter required');
                $this->finish();
                return;
            }
        }
        if (($f = $this->appInstance->config->heartbeatinterval->value) > 0) {
            $this->heartbeatTimer = setTimeout(function ($timer) {
                if (in_array('one-by-one', $this->pollMode)) {
                    $this->heartbeatOnFinish = true;
                    $this->stop();
                    return;
                }
                $this->sendFrame('h');
                if ($this->gcEnabled) {
                    $this->gcCheck();
                }
            }, $f * 1e6);
        }
        $this->afterHeaders();
        if ($this->poll) {
            $this->acquire(function () {
                $this->poll();
            });
        }
    }
1234684
public function renderBacktrace()
	{
		$contents  = null;
		$backtrace = $this->error->getTrace();

		if (is_array($backtrace))
		{
			ob_start();

			$j = 1;

			$html = array();
			$html[] = '<table class="backtrace">';
			$html[] = '	<caption>Call stack</caption>';
			$html[] = '	<thead>';
			$html[] = '		<tr>';
			$html[] = '			<th scope="col">#</th>';
			$html[] = '			<th scope="col">Function</th>';
			$html[] = '			<th scope="col">Location</th>';
			$html[] = '		</tr>';
			$html[] = '	</thead>';
			$html[] = '	<tbody>';
			$html[] = '		<tr>';
			$html[] = '			<th scope="row">0</th>';
			$html[] = '			<td><span class="msg">!! ' . $this->error->getMessage() . ' !!</span></td>';
			$html[] = '			<td><span class="fl">' . $this->rooted($this->error->getFile()) . '</span>:<span class="ln">' . $this->error->getLine() . '</span></td>';
			$html[] = '		</tr>';
			for ($i = count($backtrace) - 1; $i >= 0; $i--)
			{
				$html[] = '		<tr>';
				$html[] = '			<th scope="row">' . $j . '</th>';
				if (isset($backtrace[$i]['class']))
				{
					$html[] = '			<td><span class="cls">' . $backtrace[$i]['class'] . '</span><span class="opn">' . $backtrace[$i]['type'] . '</span><span class="mtd">' . $backtrace[$i]['function'] . '</span>()</td>';
				}
				else
				{
					$html[] = '			<td><span class="fnc">' . $backtrace[$i]['function'] . '</span>()</td>';
				}
				if (isset($backtrace[$i]['file']))
				{
					$html[] = '			<td><span class="fl">' . $this->rooted($backtrace[$i]['file']) . '</span>:<span class="ln">' . $backtrace[$i]['line'] . '</span></td>';
				}
				else
				{
					$html[] = '			<td>&#160;</td>';
				}
				$html[] = '		</tr>';
				$j++;
			}
			$html[] = '	</tbody>';
			$html[] = '</table>';

			echo "\n" . implode("\n", $html) . "\n";
			$contents = ob_get_contents();
			ob_end_clean();
		}
		return $contents;
	}
249051
public function indexAction()
    {
        $this->view->data = array();
        $s = $this->_getSelectIndex();
        if ($this->_loadColumns) {
            foreach ($this->_loadColumns as $c) {
                $s->expr($c);
            }
        }
        foreach ($this->_model->getRows($s) as $row) {
            $this->view->data[] = $this->_loadDataFromRow($row);
        }
        $this->view->total = $this->_model->countRows($s);
    }
740165
public function title()
    {
        if ($this->title === null) {
            $title = null;

            $translator = $this->translator();

            try {
                $config = $this->dashboardConfig();
            } catch (Exception $e) {
                $this->logger->error($e->getMessage());
                $config = [];
            }

            if (isset($config['title'])) {
                $title = $translator->translation($config['title']);
            } else {
                $obj      = $this->obj();
                $objId    = $this->objId();
                $objType  = $this->objType();
                $metadata = $obj->metadata();

                if (!$title && isset($metadata['admin']['forms'])) {
                    $adminMetadata = $metadata['admin'];

                    $formIdent = filter_input(INPUT_GET, 'form_ident', FILTER_SANITIZE_STRING);
                    if (!$formIdent) {
                        $formIdent = (isset($adminMetadata['default_form']) ? $adminMetadata['default_form'] : '');
                    }

                    if (isset($adminMetadata['forms'][$formIdent]['label'])) {
                        $title = $translator->translation($adminMetadata['forms'][$formIdent]['label']);
                    }
                }

                if ($objId) {
                    if (!$title && isset($metadata['labels']['edit_item'])) {
                        $title = $translator->translation($metadata['labels']['edit_item']);
                    }

                    if (!$title && isset($metadata['labels']['edit_model'])) {
                        $title = $translator->translation($metadata['labels']['edit_model']);
                    }
                } else {
                    if (!$title && isset($metadata['labels']['new_item'])) {
                        $title = $translator->translation($metadata['labels']['new_item']);
                    }

                    if (!$title && isset($metadata['labels']['new_model'])) {
                        $title = $translator->translation($metadata['labels']['new_model']);
                    }
                }

                if (!$title) {
                    $objType = (isset($metadata['labels']['singular_name'])
                                ? $translator->translation($metadata['labels']['singular_name'])
                                : null);

                    if ($objId) {
                        $title = $translator->translation('Edit: {{ objType }} #{{ id }}');
                    } elseif (!empty($_GET['clone_id'])) {
                        $title = sprintf(
                            $translator->translation('Create: {{ objType }} from ID ""%s""'),
                            $_GET['clone_id']
                        );
                    } else {
                        $title = $translator->translation('Create: {{ objType }}');
                    }

                    if ($objType) {
                        $title = strtr($title, [
                            '{{ objType }}' => $objType
                        ]);
                    }
                }
            }

            $this->title = $this->renderTitle($title);
        }

        return $this->title;
    }
139001
public function init()
	{
		if(isset($this->checkBoxHtmlOptions['name']))
			$name=$this->checkBoxHtmlOptions['name'];
		else
		{
			$name=$this->id;
			if(substr($name,-2)!=='[]')
				$name.='[]';
			$this->checkBoxHtmlOptions['name']=$name;
		}
		$name=strtr($name,array('['=>"\\[",']'=>"\\]"));

		if($this->selectableRows===null)
		{
			if(isset($this->checkBoxHtmlOptions['class']))
				$this->checkBoxHtmlOptions['class'].=' select-on-check';
			else
				$this->checkBoxHtmlOptions['class']='select-on-check';
			return;
		}

		$cball=$cbcode='';
		if($this->selectableRows==0)
		{
			//.. read only
			$cbcode="return false;";
		}
		elseif($this->selectableRows==1)
		{
			//.. only one can be checked, uncheck all other
			$cbcode="jQuery(\"input:not(#\"+this.id+\")[name='$name']\").prop('checked',false);";
		}
		elseif(strpos($this->headerTemplate,'{item}')!==false)
		{
			//.. process check/uncheck all
			$cball=<<<CBALL
jQuery(document).on('click','#{$this->id}_all',function() {
	var checked=this.checked;
	jQuery("input[name='$name']:enabled").each(function() {this.checked=checked;});
});

CBALL;
			$cbcode="jQuery('#{$this->id}_all').prop('checked', jQuery(\"input[name='$name']\").length==jQuery(\"input[name='$name']:checked\").length);";
		}

		if($cbcode!=='')
		{
			$js=$cball;
			$js.=<<<EOD
jQuery(document).on('click', "input[name='$name']", function() {
	$cbcode
});
EOD;
			Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$this->id,$js);
		}
	}
134845
public function init()
    {
        $this->sets([
            'isPc' => false,
            'isMobile' => false,

            'os' => 'Unknown',
            'browser' => 'Unknown',

            'isUnix' => false,
            'isLinux' => false,
            'isWin' => false,
            'isMac' => false,
            'isAndroid' => false,

            'ip' => 0,
            'addr' => Server::value('REMOTE_ADDR'),
            'port' => Server::value('REMOTE_PORT'),
        ]);

        $this->getHeaders();

        // Parse the HTTP_ACCEPT.
        if ($accept = $this->getHeader('accept')) {
            $this->set('accepts', $this->_handleInfo($accept));
        }

        // Parse the accepted encodings.
        if ($acceptEncoding = $this->getHeader('acceptEncoding')) {
            $this->set('encodings', $this->_handleInfo($acceptEncoding));
        }

        if ($acceptLang = $this->get('acceptLang')) {
            $this->set('langs', $this->_handleInfo($acceptLang));
        }

        // $this->data['isSslConnect'] = $this->isSSLConnection();
        $this->set('ip', $this->getIp());

        $this->_userAgentCheck();
    }
598780
public function init() {
		
		if (false === $this->visible) {
			return;
		}

		$classes = array('btn');

		if ($this->isValidContext()) {
			$classes[] = 'btn-' . $this->getContextClass();
		}
		
		if($this->buttonType == self::BUTTON_LINK) {
			$classes[] = 'btn-link';
		}

		$validSizes = array(
			self::SIZE_LARGE, 
			self::SIZE_DEFAULT,
			self::SIZE_SMALL, 
			self::SIZE_EXTRA_SMALL
		);

		if (isset($this->size) && in_array($this->size, $validSizes)) {
			$classes[] = self::$sizeClasses[$this->size];
		}

		if ($this->block) {
			$classes[] = 'btn-block';
		}

		if ($this->active) {
			$classes[] = 'active';
		}

		if ($this->disabled) {
			$disableTypes = array(
				self::BUTTON_BUTTON,
				self::BUTTON_SUBMIT,
				self::BUTTON_RESET,
				self::BUTTON_AJAXBUTTON,
				self::BUTTON_AJAXSUBMIT,
				self::BUTTON_INPUTBUTTON,
				self::BUTTON_INPUTSUBMIT
			);

			if (in_array($this->buttonType, $disableTypes)) {
				$this->htmlOptions['disabled'] = 'disabled';
			}

			$classes[] = 'disabled';
		}

		if (!isset($this->url) && isset($this->htmlOptions['href'])) {
			$this->url = $this->htmlOptions['href'];
			unset($this->htmlOptions['href']);
		}

		if ($this->encodeLabel) {
			$this->label = CHtml::encode($this->label);
		}

		if ($this->hasDropdown()) {
			if (!isset($this->url)) {
				$this->url = '#';
			}

			$classes[] = 'dropdown-toggle';
			$this->label .= ' <span class="caret"></span>';
			$this->htmlOptions['data-toggle'] = 'dropdown';
		}

		if (!empty($classes)) {
			$classes = implode(' ', $classes);
			if (isset($this->htmlOptions['class'])) {
				$this->htmlOptions['class'] .= ' ' . $classes;
			} else {
				$this->htmlOptions['class'] = $classes;
			}
		}

		if (isset($this->icon)) { // no need for implode as newglyphicon only supports one icon
			if (strpos($this->icon, 'icon') === false && strpos($this->icon, 'fa') === false) {
				$this->icon = 'glyphicon glyphicon-' . $this->icon;
				$this->label = '<span class="' . $this->icon . '"></span> ' . $this->label;
			} else { // to support font awesome icons
				$this->label = '<i class="' . $this->icon . '"></i> ' . $this->label;
			}
		}

		if (!isset($this->htmlOptions['id'])) {
			$this->htmlOptions['id'] = $this->getId();
		}

		if (isset($this->toggle)) {
			$this->htmlOptions['data-toggle'] = 'button';
		}

		if (isset($this->loadingText)) {
			$this->htmlOptions['data-loading-text'] = $this->loadingText;
		}

		if (isset($this->completeText)) {
			$this->htmlOptions['data-complete-text'] = $this->completeText;
		}

        if (!empty($this->tooltip) && !$this->toggle) {
            if (!is_array($this->tooltipOptions)) {
                $this->tooltipOptions = array();
            }

            $this->htmlOptions['data-toggle'] = 'tooltip';
            foreach ($this->tooltipOptions as $key => $value) {
                $this->htmlOptions['data-' . $key] = $value;
            }

            /**
             * Encode delay option
             * @link http://getbootstrap.com/2.3.2/javascript.html#tooltips
             */
            if (isset($this->htmlOptions['data-delay']) && is_array($this->htmlOptions['data-delay'])) {
                $this->htmlOptions['data-delay'] = CJSON::encode($this->htmlOptions['data-delay']);
            }
        }
	}
535142
public function init()
	{
		if(isset($this->htmlOptions['id']))
			$id=$this->htmlOptions['id'];
		else
			$id=$this->htmlOptions['id']=$this->getId();
		if($this->url!==null)
			$this->url=CHtml::normalizeUrl($this->url);
		$cs=Yii::app()->getClientScript();
		$cs->registerCoreScript('treeview');
		$options=$this->getClientOptions();
		$options=$options===array()?'{}' : CJavaScript::encode($options);
		$cs->registerScript('Yii.CTreeView#'.$id,"jQuery(\"#{$id}\").treeview($options);");
		if($this->cssFile===null)
			$cs->registerCssFile($cs->getCoreScriptUrl().'/treeview/jquery.treeview.css');
		elseif($this->cssFile!==false)
			$cs->registerCssFile($this->cssFile);

		echo CHtml::tag('ul',$this->htmlOptions,false,false)."\n";
		echo self::saveDataAsHtml($this->data);
	}
606309
public function run()
    {
        try {
            $this->header('Content-Type: text/html');
        } catch (\Exception $e) {
        }
        ?>
        <!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>Example with PostgreSQL</title>
        </head>
        <body>
        <?php

        if ($this->queryResult) {
            echo '<h1>It works! Be happy! ;-)</h1>Result of `SELECT 123 as integer, NULL as nul, \'test\' as string`: <pre>';
            var_dump($this->queryResult);
            echo '</pre>';
        } else {
            echo '<h1>Something went wrong! We have no result.</h1>';
        }

        echo '<br />Request (http) took: ' . round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 6);

        ?>
        </body>
        </html>
        <?php

    }
439697
public function run()
    {
        /* @var $module Module */
        $module = Yii::$app->getModule(Module::$name);
        $commentModelData = $module->model('comment');

        //Create comment model
        /** @var CommentModel $commentModel */
        $commentModel = Yii::createObject($commentModelData);

        //Get entity from widget and hash it.
        if ($this->model)
        {
            $entityModel = $this->model;
            $this->entityId = $entityModel->{$this->entityIdAttribute};
            $this->entity = $commentModel::hashEntityClass($entityModel::className());
        }

        // Add the basic data into the CommentModel in case we need it to
        // check for permissions
        $commentModel->entity = $this->entity;
        $commentModel->entityId = $this->entityId;

        //Encrypt entity and entityId values
        $this->encryptedEntity = base64_encode(Yii::$app->getSecurity()->encryptByKey(Json::encode([
            'entity' => $this->entity,
            'entityId' => $this->entityId,
            'maxLevel' => $this->maxLevel,
            'entityIdAttribute' => $this->entityIdAttribute,
            'clientOptions' => $this->clientOptions,
            'pjax' => $this->pjax,
            'showDeletedComments' => $this->showDeletedComments,
            'nestedBehavior' => $this->nestedBehavior
        ]), $module::$name));

        $query = $commentModel::find()
            ->where(['entity' => $this->entity, 'entityId' => $this->entityId]);

        if ($this->nestedBehavior === TRUE)
        {
            // Make eager subqueries to the max level defined in the widget
            $children = array_fill(0, $this->maxLevel, 'children');
            $query = $query->andWhere(['parentId' => NULL])
                ->with([implode('.', $children), 'author']);
        }
        else
        {
            $query = $query->with(['author']);
        }

        if ($this->showDeletedComments === FALSE)
        {
            $query->andWhere(['!=', 'status', CommentStatus::DELETED]);
        }

        $dataProvider = new ArrayDataProvider([
            'allModels' => $query->all(),
            'sort' => $this->sort,
            'pagination' => $this->pagination
        ]);

        return $this->render('index', [
            'commentModel' => $commentModel,
            'provider' => $dataProvider,
            'widget' => &$this
        ]);
    }
1233206
public function init()
    {
        /* @var $options MailOptions */
        $options = $this->getServiceLocator()
            ->getServiceLocator()
            ->get(MailOptions::class);

        $emailAddresses = $options->getAddressList();

        $addressList = [];

        foreach ($emailAddresses as $transport => $address) {

            $addressList[] = [
                'label' => $address['name'] . ' <' . $address['address'] . '>',
                'value' => $transport,
            ];
        }

        $this->setValueOptions($addressList);
    }
429831
public function init()
    {
        /**
         * 设置默认时区
         */
        if ($this->timezone)
        {
            date_default_timezone_set($this->timezone);
        }

        /**
         * 设置地区信息（地域信息）
         */
        if ($this->locale)
        {
            setlocale(LC_ALL, $this->locale);
        }

        if ($this->charset && function_exists('mb_internal_encoding'))
        {
            mb_internal_encoding($this->charset);
        }

        /**
         * 当输入字符的编码是无效的，或者字符代码不存在于输出的字符编码中时，可以为其指定一个替代字符。
         *
         * @link http://www.php.net/manual/function.mb-substitute-character.php
         */
        mb_substitute_character('none');

        // 确保输入的数据安全
        $_GET = Security::sanitize($_GET);
        $_POST = Security::sanitize($_POST);
        $_COOKIE = Security::sanitize($_COOKIE);

        self::cleanComponents();
    }
1234482
public function process()
    {
        switch ($this->inputs['action']) {
            case 'login':
                $this->webLogin();
                break;
            case 'logout':
                $this->webLogout();
                exit($this->showWebLoginForm());
                break;
            case 'getContacts':
                $this->getContacts();
                break;
            case 'updateStatus':
                $this->updateStatus();
                break;
            case 'sendMessage':
                $this->sendMessage();
                break;
            case 'sendBroadcast':
                $this->sendBroadcast();
                break;
            default:
                if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
                    exit($this->showWebForm());
                }
                exit($this->showWebLoginForm());
                break;
        }
    }
534033
public function parse()
    {
        // Fetch the basic values from possible user defined values.
        if ($this->entity->hasConfig("labels")) {
            if ($this->entity->hasConfig("labels.singular_name")) {
                $this->singular = $this->entity->getConfig("labels.singular_name");
            } elseif ($this->entity->hasConfig("labels.name")) {
                $this->plural = $this->entity->getConfig("labels.name");
            }
        }

        if (!empty($this->singular) && empty($this->plural)) {
            $this->plural = Inflector::pluralize($this->singular);
        }

        if (!empty($this->plural) && empty($this->singular)) {
            $this->singular = Inflector::singularize($this->plural);
        }

        // If nothing is sent in, guess the name from the object name.
        if (empty($this->plural) && empty($this->singular)) {
            $this->singular   = ucfirst(Inflector::singularize($this->entity->getShortName()));
            $this->plural     = ucfirst(Inflector::pluralize($this->entity->getShortName()));
        }
    }
591090
public function get_value() {
		$value  = parent::get_value();

		if ( is_array( $value ) ) {
			$value = json_encode( $value );
		}

		return $value;
	}