Beispiel #1
0
 /**
  * 设置某cookie变量的值
  *
  * @access public
  *
  * @param string $name cookie的变量名
  * @param mixed $value cookie值
  * @param integer $expire cookie的生存周期
  * @param string $path cookie所存放的目录
  * @param string $domain cookie所支持的域名
  *
  * @return boolean
  */
 public static function set($name, $value, $expire = null, $path = null, $domain = null)
 {
     //参数分析
     if (!$name) {
         return false;
     }
     //获取cookie的配置信息
     if (is_null($expire)) {
         $configExpire = Configure::get('cookie.expire');
         $expire = !$configExpire ? self::$_defaultConfig['expire'] : $configExpire;
     }
     if (is_null($path)) {
         $configPath = Configure::get('cookie.path');
         $configPath = !$configPath ? $configPath : rtrim($configPath, '/') . '/';
         $path = !$configPath ? self::$_defaultConfig['path'] : $configPath;
     }
     if (is_null($domain)) {
         $configDomain = Configure::get('cookie.domain');
         $domain = !$configDomain ? self::$_defaultConfig['domain'] : $configDomain;
     }
     $expire = time() + $expire;
     setcookie($name, $value, $expire, $path, $domain);
     $_COOKIE[$name] = $value;
     return true;
 }
Beispiel #2
0
 /**
  * 构造方法
  *
  * 用于初始化运行环境,或对基本变量进行赋值
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($params = array())
 {
     if (!extension_loaded('mongo')) {
         Controller::halt('The mongo extension to be loaded!');
     }
     //参数分析
     if (!$params || !is_array($params)) {
         //加载数据库配置文件.
         $params = Configure::get('mongo');
     }
     $params = is_array($params) ? $params + $this->_defaultConfig : $this->_defaultConfig;
     if (!isset($params['dbname']) || !$params['dbname']) {
         Controller::halt('The file of MongoDB config is error, dbname is not found!');
     }
     try {
         //实例化mongo
         $this->_mongo = new Mongo($params['dsn'], $params['option']);
         //连接mongo数据库
         $this->_dbLink = $this->_mongo->selectDB($params['dbname']);
         //用户登录
         if (isset($params['username']) && isset($params['password'])) {
             $this->_dbLink->authenticate($params['username'], $params['password']);
         }
         return true;
     } catch (Exception $exception) {
         //抛出异常信息
         throw new DoitException('MongoDb connect error!<br/>' . $exception->getMessage(), $exception->getCode());
     }
 }
Beispiel #3
0
 public function __construct($options)
 {
     $this->options = array_merge($this->options, $options);
     $this->Session = Session::getInstance();
     $this->db = Orm::loadModel('Users');
     $this->options['salt'] = Configure::get('globals.salt');
 }
 /**
  * Initialize
  */
 public function __construct()
 {
     parent::__construct();
     // Set the company ID
     $this->company_id = Configure::get("Blesta.company_id");
     $this->dir = PLUGINDIR . "css_javascript_toolbox/includes/" . $this->company_id . "/";
     Language::loadLang("model", null, PLUGINDIR . "css_javascript_toolbox" . DS . "language" . DS);
 }
Beispiel #5
0
 /**
  * Sets the meta data to use for this invoice. This method is invoked after
  * __construct() but before makeDocument()
  *
  * @param array $meta An array of meta data including:
  * 	-background The absolute path to the background graphic
  * 	-logo The absolute path to the logo graphic
  * 	-company_name The name of the company
  * 	-company_address The address of the company
  * 	-terms The terms to display on this invoice
  * 	-paper_size The size of paper to use (e.g. "A4" or "Letter")
  * 	-tax An array of tax info including:
  * 		-tax_id The Tax ID/VATIN of this company
  * 		-cascade_tax Whether or not taxes are cascading
  */
 public function setMeta($meta)
 {
     $this->meta = $meta;
     $font = isset($this->meta['settings']['inv_font_' . Configure::get("Blesta.language")]) ? $this->meta['settings']['inv_font_' . Configure::get("Blesta.language")] : null;
     $this->pdf = new HtmlInvoicePdf("P", "px", $this->meta['paper_size'], true, 'UTF-8', false, $font);
     $this->html = new HtmlInvoiceHtm("P", "px", $this->meta['paper_size'], true, 'UTF-8', false, $font);
     // Set the meta data to use for this invoice
     $this->pdf->meta = $this->meta;
     $this->html->meta = $this->meta;
 }
 public static function init()
 {
     $databaseConfigure = Configure::get('database');
     if ($databaseConfigure['type'] == 'mysql') {
         self::setup('mysql:host=' . $databaseConfigure['host'] . ';dbname=' . $databaseConfigure['databasename'], $databaseConfigure['account'], $databaseConfigure['password']);
         //for both mysql or mariaDB
     } else {
         self::setup();
     }
 }
 public function __construct()
 {
     Language::loadLang("admin", null, dirname(__FILE__) . DS . "language" . DS);
     // Load components required by this plugin
     Loader::loadComponents($this, array("Input", "Record"));
     // Load modules for this plugun
     Loader::loadModels($this, array("ModuleManager"));
     $this->loadConfig(dirname(__FILE__) . DS . "config.json");
     $this->upload_path = PLUGINDIR . "css_javascript_toolbox/includes/" . Configure::get("Blesta.company_id") . DS;
 }
 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8')
 {
     Language::loadLang("html_invoice", null, dirname(__FILE__) . DS . "language" . DS);
     Loader::loadModels($this, array("Companies", "Transactions"));
     $company_id = Configure::get("Blesta.company_id");
     $this->company = $this->Companies->get($company_id);
     $this->Html = new Html();
     $buffer = '';
     $this->rtl = '';
 }
 /**
  * Performs necessary initialization
  */
 private function init()
 {
     // Require login
     $this->parent->requireLogin();
     // Set the company ID
     $this->company_id = Configure::get("Blesta.company_id");
     $this->uses(array("CssJavascriptToolbox.Toolbox"));
     $this->Date = $this->parent->Date;
     // Set the plugin ID
     $this->plugin_id = isset($this->get[0]) ? $this->get[0] : null;
     $this->dir = PLUGINDIR . "css_javascript_toolbox/includes/" . $this->company_id . "/";
     // Set the page title
     $this->parent->structure->set("page_title", Language::_("CssJavascriptToolboxPlugin." . Loader::fromCamelCase($this->action ? $this->action : "index") . ".page_title", true));
     // Set the view to render for all actions under this controller
     $this->view->setView(null, "CssJavascriptToolbox.default");
     // $directory = CONTROLLERDIR ;
 }
Beispiel #10
0
 /**
  * 构造函数
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($options = null)
 {
     if (!extension_loaded('redis')) {
         Controller::halt('The redis extension to be loaded!');
     }
     //当参数为空时,程序则自动加载配置文件中数据库连接参数
     if (!$options || !is_array($options)) {
         $options = Configure::get('redis');
         if (!$options) {
             $options = array();
         }
     }
     $options += $this->_defaultServer;
     //连接数据库
     $this->_dbLink = new Redis();
     $this->_dbLink->connect($options['host'], $options['port']);
     return true;
 }
Beispiel #11
0
 /**
  * 构造方法
  *
  * 用于初始化本类的运行环境,或对基本变量进行赋值
  *
  * @access public
  * @return boolean
  */
 public function __construct()
 {
     //时区设置,默认为中国(北京时区)
     date_default_timezone_set(Configure::get('application.defaultTimeZone'));
     //设置异常处理
     set_exception_handler(array($this, '_exception'));
     //关闭魔术变量,提高PHP运行效率
     if (get_magic_quotes_runtime()) {
         @set_magic_quotes_runtime(0);
     }
     //将全局变量进行魔术变量处理,过滤掉系统自动加上的'\'.
     if (get_magic_quotes_gpc()) {
         $_POST = $_POST ? $this->_stripSlashes($_POST) : array();
         $_GET = $_GET ? $this->_stripSlashes($_GET) : array();
         $_SESSION = $_SESSION ? $this->_stripSlashes($_SESSION) : array();
         $_COOKIE = $_COOKIE ? $this->_stripSlashes($_COOKIE) : array();
     }
     //实例化视图对象
     self::$_viewObject = $this->initView();
     //回调函数,实例化控制器(Controller)时,执行所要补充的程序
     $this->init();
     return true;
 }
Beispiel #12
0
 /**
  * 构造方法
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($options = null)
 {
     //分析memcache扩展模块的加载
     if (!extension_loaded('memcache')) {
         Controller::halt('The memcache extension to be loaded before use!');
     }
     //获取Memcache服务器连接参数
     if (!$options || !is_array($options)) {
         $options = Configure::get('memcache');
     }
     if (is_array($options) && $options) {
         $this->_defaultOptions = $options + $this->_defaultOptions;
     }
     if (!$this->_defaultOptions['servers']) {
         $this->_defaultOptions['servers'][] = $this->_defaultServer;
     }
     $this->_dbLink = new Memcache();
     foreach ($this->_defaultOptions['servers'] as $server) {
         $server += array('host' => '127.0.0.1', 'port' => 11211, 'persistent' => true);
         $this->_dbLink->addServer($server['host'], $server['port'], $this->_defaultOptions['persistent']);
     }
     return true;
 }
Beispiel #13
0
    public function FinalTemplate($Header = null, $HtmlDir = null, $HtmlTitle = null, $RtlCss = null, $drawBackground = null, $drawLogo = null, $drawPaidWatermark = null, $drawInvoiceType = null, $drawInvoiceInfo = null, $drawReturnAddress = null, $drawAddress = null, $drawLineHeader = null, $drawInvoice = null, $SubTotals = null, $Taxes = array(), $Totals = null, $PublicNotes = null, $drawPayments = null, $drawTerms = null, $Footer = null, $PrintBtn = null, $DownloadBtn = null, $PaymentBtn = null, $EditBtn = null)
    {
        /*
        *
        NOTE , The $Header include all the header 
        *
        */
        // print_r($drawInvoiceInfo['invoice_view']);
        if (strpos($_SERVER['REQUEST_URI'], Configure::get("Route.admin"))) {
            $return_rl = WEBDIR . Configure::get("Route.admin") . "/clients/view/" . $drawInvoiceInfo['client_view'] . "/";
            $payment_btn = '
				<div class="btn-group">
					<button type="button" class="btn btn-warning btn-lg dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
						<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.add_payment", true) . ' <span class="caret"></span>
					</button>
					<ul class="dropdown-menu" role="menu">
						<li><a href="' . WEBDIR . Configure::get("Route.admin") . '/clients/makepayment/' . $drawInvoiceInfo['client_view'] . '/' . $drawInvoiceInfo['invoice_view'] . '"><span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.pay_invoice", true) . '</a></li>
						<li class="divider"></li>
						<li><a href="' . WEBDIR . Configure::get("Route.admin") . '/clients/recordpayment/' . $drawInvoiceInfo['client_view'] . '/' . $drawInvoiceInfo['invoice_view'] . '"><span class="glyphicon glyphicon-usd" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.record_invoice", true) . '</a></li>							
					</ul>
				</div>';
            $edit_btn = '
				<button type="button" class="btn btn-info btn-lg " onclick="window.location.href=\'' . WEBDIR . Configure::get("Route.admin") . '/clients/editinvoice/' . $drawInvoiceInfo['client_view'] . '/' . $drawInvoiceInfo['invoice_view'] . '\'"> 
					<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.edit_invoice", true) . '
				</button>';
        } else {
            $return_rl = WEBDIR . Configure::get("Route.client") . "/";
            $payment_btn = '
				<button type="button" class="btn btn-warning btn-lg" onclick="window.location.href=\'' . WEBDIR . Configure::get("Route.client") . '/pay/method/' . $drawInvoiceInfo['invoice_view'] . '/\'">
				  <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.pay_invoice", true) . '
				</button>';
            $edit_btn = '';
        }
        $paid_watermark = '
				<button type="button" class="btn btn-success btn-lg active" >
					<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.watermark_paid", true) . '
				</button>';
        $unpaid_watermark = '
				<button type="button" class="btn btn-danger btn-lg active" >
					<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.watermark_unpaid", true) . '
				</button>';
        $download_btn = '
				<button type="button" class="btn btn-primary btn-lg " onclick="window.location.href=\'' . $_SERVER['REQUEST_URI'] . '/pdf/\'"> 
					<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.download_invoice", true) . '
				</button>';
        $print_btn = '
				<button type="button" class="btn btn-primary btn-lg" onclick="javascript:window.print();" >
				  <span class="glyphicon glyphicon-print" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.print_invoice", true) . '
				</button>';
        $draw_terms = '
				<div class="row">
					<div class="col-xs-12">
						<h3><span class="label label-default">' . Language::_("HtmlInvoice.terms_heading", true) . '</span></h3>
						
						<div class="well well-sm">' . nl2br($drawTerms) . '</div>						
					</div>
				</div>';
        $taxe_line = "";
        foreach ($Taxes as $Taxe) {
            $taxe_line .= '
				<tr>
					<th colspan="2" class="warning text-right"><h4>' . $Taxe['label'] . '</h4></th>
					<th class="warning text-right"><h4>' . $Taxe['value'] . '</h4></th>
				</tr>';
        }
        $content = '
		<!doctype html>
		<html dir="' . $HtmlDir . '">
			<head>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<meta name="viewport" content="width=device-width, initial-scale=1.0">	
				<title>' . $HtmlTitle . ' </title>				
				<!-- Latest compiled and minified CSS -->
				<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
				<!-- Optional theme -->
				<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">		
				' . (Language::_("AppController.lang.dir", true) == "rtl" ? '<link rel="stylesheet" href="//cdn.rawgit.com/morteza/bootstrap-rtl/master/dist/cdnjs/3.3.1/css/bootstrap-rtl.min.css">' : '') . '
				<style>
					' . $drawBackground . '
					' . $RtlCss . '
					header {margin-top: 70px;}
				</style>				
			</head>
			<body>
				<div class="container">				
					<header class="header">
						<div class="row">
							<div class="col-md-5 col-xs-12 ">
								<div class="thumbnail">
									<div class=" text-left">' . $drawLogo . '</div>
								</div>
							</div>
							<div class="col-md-5 col-xs-12 col-md-offset-2 text-right flip ">
								<h1>' . $drawInvoiceType . '</h1>
								<div class="row">
									<div class="col-md-8 col-md-offset-4 col-xs-12">
										<dl class="dl-horizontal">
											<dt>' . $drawInvoiceType . Language::_("HtmlInvoice.invoice_id_code", true) . '</dt>
											<dd>' . $drawInvoiceInfo['invoice_id'] . '</dd>
											<dt>' . Language::_("HtmlInvoice.client_id_code", true) . '</dt>
											<dd>' . $drawInvoiceInfo['client_id'] . '</dd>
											<dt>' . Language::_("HtmlInvoice.date_billed", true) . '</dt>
											<dd>' . $drawInvoiceInfo['date_billed'] . '</dd>
											<dt>' . Language::_("HtmlInvoice.date_due", true) . '</dt>
											<dd>' . $drawInvoiceInfo['date_due'] . '</dd>									
										</dl>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-5 col-xs-12 ">
								' . $drawReturnAddress . ' 
							</div>
							<div class="col-md-5 col-xs-12  col-md-offset-2 text-right">
								' . $drawAddress . '
							</div>
						</div>
						<!-- / end client details section -->
						<div class="row">
								<div class="col-xs-12 ">									
									' . ($PaymentBtn ? $payment_btn : "") . '
									' . ($EditBtn ? $edit_btn : "") . '
									' . ($PrintBtn ? $print_btn : "") . '
									' . ($DownloadBtn ? $download_btn : "") . '
									<p class="pull-right flip">							
										' . ($drawPaidWatermark ? $paid_watermark : $unpaid_watermark) . '									
									</p>									
								</div>
						</div>
						
					</header>
					<div class="content">						
						<table class="table table-hover table-bordered">
							<thead>
								<tr class="active">' . $drawLineHeader . '</tr>
							</thead>
							<tbody>
								' . $drawInvoice . '
							</tbody>
							<tfoot>
								<tr>
									<th rowspan="6" ></th>
									<th colspan="2" class="active text-right"><h4>' . Language::_("HtmlInvoice.subtotal_heading", true) . '</h4></th>
									<th class="active text-right"><h4>' . $SubTotals . '</h4></th>
								</tr>
								' . $taxe_line . '
								<tr>
									<th colspan="2" class="info text-right"><h4>' . Language::_("HtmlInvoice.total_heading", true) . '</h4></th>
									<th class="info text-right"><h4>' . $Totals . '</h4></th>
								</tr>							
							</tfoot>							
							
							
						</table>
						
						<div class="row">
							<div class="col-md-5 col-xs-12">
								' . $PublicNotes . '
							</div>
							<div class="col-md-7 col-xs-12">
								' . $drawPayments . '	
							</div>
						</div>
						
					</div>
					<footer class="footer">		
						' . ($drawTerms ? $draw_terms : "") . '
						' . $Footer . '
					</footer>
					<nav>
						<ul class="pager">
							<li><a href="' . $return_rl . '"><span aria-hidden="true">&larr;</span> ' . Language::_("HtmlInvoice.back", true) . '</a></li>
							<li><a href="' . $_SERVER['REQUEST_URI'] . '/pdf/">' . Language::_("HtmlInvoice.download_invoice", true) . '</a></li>
							<li><a href="#">' . Language::_("HtmlInvoice.close", true) . '</a></li>
						</ul>
					</nav>					
				</div>
				<!-- jQuery -->
				<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>				
				<!-- Latest compiled and minified JavaScript -->
				<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>						
			</body>
		</html>';
        return $content;
    }
Beispiel #14
0
 public static function init()
 {
     $routeType = Configure::get('route.type');
     if ($routeType == 'custom') {
         self::custom();
     } else {
         self::pathInfo();
     }
 }
Beispiel #15
0
 /**
  * 获取当前日志文件名
  *
  * @example
  *
  * $this->__getLogFilePath('sql');
  * 或
  * $this->__getLogFilePath('2012-11.2012-11-23');
  * 或
  * $this->__getLogFilePath('2012-11/2012-11-23');
  *
  * @access private
  *
  * @param $logFileName 日志文件名
  *
  * @return string
  */
 private static function _getLogFilePath($logFileName = null)
 {
     //参数分析
     if ($logFileName && strpos($logFileName, '.') !== false) {
         $logFileName = str_replace('.', '/', $logFileName);
     }
     //组装日志文件路径
     $logFilePath = rtrim(Configure::get('application.logPath'), '/') . DIRECTORY_SEPARATOR;
     if (!$logFileName) {
         $logFilePath .= date('Y-m') . '/' . date('Y-m-d');
     } else {
         if (strpos($logFileName, '/') !== false) {
             $logFilePath .= $logFileName;
         } else {
             $logFilePath .= date('Y-m') . '/' . $logFileName;
         }
     }
     $logFilePath .= '.log';
     return $logFilePath;
 }
Beispiel #16
0
 public function configure()
 {
     echo Configure::get('hello');
 }
Beispiel #17
0
 /**
  * 设置session最大存活时间.
  *
  * @access protected
  * @return boolean
  */
 protected static function _setTimeout()
 {
     //获取session的系统配置信息
     $configExpire = Configure::get('session.expire');
     if (!$configExpire) {
         return false;
     }
     return ini_set('session.gc_maxlifetime', $configExpire);
 }
Beispiel #18
0
 /**
  * 加载自定义配置文件所引导的文件
  *
  * @access private
  *
  * @param string $className 所需要加载的类的名称,注:不含后缀名
  *
  * @return void
  */
 private static function _loadImportConfigFile($className)
 {
     //定义自动加载状态。(true:已加载/false:未加载)
     $atuoLoadStatus = false;
     //分析配置文件import引导信息
     $importRules = Configure::get('import');
     //当配置文件引导信息合法时
     if ($importRules && is_array($importRules)) {
         foreach ($importRules as $rules) {
             if (!$rules) {
                 continue;
             }
             //当配置文件引导信息中含有*'时,将设置的规则中的*替换为所要加载的文件类名
             if (strpos($rules, '*') !== false) {
                 $filePath = str_replace('*', $className, $rules);
             } else {
                 $filePath = self::_parseFilePath($rules, $className);
             }
             //当自定义自动加载的文件存在时
             if (is_file($filePath)) {
                 //加载文件
                 Doit::loadFile($filePath);
                 $atuoLoadStatus = true;
                 break;
             }
         }
     }
     return $atuoLoadStatus;
 }
Beispiel #19
0
 /**
  * ...
  *
  * @param string $tag
  * The tag name of an element.
  *
  * @return string|bool
  * Returns the path of the definition file ...
  * Returns `false` ...
  *
  * @since 2.0.0 `definitionFilePath` is renamed `definitionFile`.
  * @since 0.0.0
  *
  * @see https://github.com/Odepax/pasap/wiki/Namespaces#how-elements-are-resolved-and-rendered
  */
 public static function definitionFile(string $tag)
 {
     $tagParts = explode(':', $tag);
     $rootNs = array_shift($tagParts);
     if (!array_key_exists($rootNs, Configure::get('namespaceSource'))) {
         return null;
     }
     $definitionFile = Configure::get('namespaceSource')[$rootNs] . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $tagParts) . '.php';
     if (is_file($definitionFile)) {
         return $definitionFile;
     } else {
         return null;
     }
 }
Beispiel #20
0
 /**
  * Returns all HTML markup required to render an authorization and capture payment form
  *
  * @param array $contact_info An array of contact info including:
  *    - id The contact ID
  *    - client_id The ID of the client this contact belongs to
  *    - user_id The user ID this contact belongs to (if any)
  *    - contact_type The type of contact
  *    - contact_type_id The ID of the contact type
  *    - first_name The first name on the contact
  *    - last_name The last name on the contact
  *    - title The title of the contact
  *    - company The company name of the contact
  *    - address1 The address 1 line of the contact
  *    - address2 The address 2 line of the contact
  *    - city The city of the contact
  *    - state An array of state info including:
  *        - code The 2 or 3-character state code
  *        - name The local name of the country
  *    - country An array of country info including:
  *        - alpha2 The 2-character country code
  *        - alpha3 The 3-character country code
  *        - name The english name of the country
  *        - alt_name The local name of the country
  *    - zip The zip/postal code of the contact
  * @param float $amount The amount to charge this contact
  * @param array $invoice_amounts An array of invoices, each containing:
  *    - id The ID of the invoice being processed
  *    - amount The amount being processed for this invoice (which is included in $amount)
  * @param array $options An array of options including:
  *    - description The Description of the charge
  *    - return_url The URL to redirect users to after a successful payment
  *    - recur An array of recurring info including:
  *        - amount The amount to recur
  *        - term The term to recur
  *        - period The recurring period (day, week, month, year, onetime) used in conjunction with term in order to determine the next recurring payment
  * @return string HTML markup required to render an authorization and capture payment form
  */
 public function buildProcess(array $contact_info, $amount, array $invoice_amounts = null, array $options = null)
 {
     $this->initPaymentwallConfigs();
     $post_to = Configure::get("Blesta.gw_callback_url") . Configure::get("Blesta.company_id") . "/brick/";
     $fields = array();
     $contact = false;
     // Set contact email address and phone number
     if ($this->ifSet($contact_info['id'], false)) {
         Loader::loadModels($this, array("Contacts"));
         $contact = $this->Contacts->get($contact_info['id']);
     } else {
         return "Contact information invalid!";
     }
     $data = array('public_key' => Paymentwall_Config::getInstance()->getPublicKey(), 'amount' => $amount, 'merchant' => $this->ifSet($this->meta['merchant_name'], 'Blesta'), 'product_name' => $options['description'], 'currency' => $this->currency);
     $post_to .= "?data=" . $this->encodeData(array('client_id' => $contact->client_id, 'amount' => $amount, 'currency' => $this->currency, 'invoices' => $invoice_amounts, 'email' => $contact->email, 'description' => $options['description']));
     $this->view = $this->makeView("process", "default", str_replace(ROOTWEBDIR, "", dirname(__FILE__) . DS));
     $this->view->set("data", $data);
     $this->view->set("post_to", $post_to);
     $this->view->set("fields", $fields);
     return $this->view->fetch();
 }
Beispiel #21
0
 /**
  * Tab Tasks
  *
  * /DONE/
  */
 public function tabTasks($package, $service, array $get = null, array $post = null, $client = false)
 {
     $template = $client ? "tab_client_tasks" : "tab_tasks";
     $this->view = new View($template, "default");
     $this->view->base_uri = $this->base_uri;
     // Load the helpers required for this view
     Loader::loadHelpers($this, array("Form", "Html", "Date", "WidgetClient"));
     // Get the service fields
     $service_fields = $this->serviceFieldsToObject($service->fields);
     $module_row = $this->getModuleRow($package->module_row);
     $tasks = $this->Tasks($module_row, $service_fields->options['node'], $service_fields->vmid, $count = null, $get, $client);
     sleep(1);
     $tasksall = $this->Tasks($module_row, $service_fields->options['node'], $service_fields->vmid, $count = true);
     $client_pagination = $this->base_uri . "services/manage/" . $this->Html->ifSet($service->id) . "/tabClientTasks/[p]/";
     $admin_pagination = $this->base_uri . "clients/servicetab/" . $this->Html->ifSet($service->client_id) . "/" . $this->Html->ifSet($service->id) . "/tabTasks/[p]/";
     $pagin_admin = Configure::get("Blesta.pagination");
     $pagin_client = Configure::get("Blesta.pagination_client");
     $settings = array_merge($client ? $pagin_client : $pagin_admin, array('total_results' => count($tasksall), 'uri' => $client ? $client_pagination : $admin_pagination, 'params' => array()));
     Loader::loadHelpers($this, array("Pagination" => array($get, $settings)));
     $client ? "" : $this->Pagination->setSettings(Configure::get("Blesta.pagination_ajax"));
     $this->view->set("tasks", $tasks);
     $this->view->set("client_id", $service->client_id);
     $this->view->set("service_id", $service->id);
     $this->view->set("view", $this->view->view);
     $this->view->setDefaultView("components" . DS . "modules" . DS . "proxmoxv2" . DS);
     return $this->view->fetch();
 }
Beispiel #22
0
 /**
  * 初始化常用的全局常量
  *
  * 定义常用的全局常量:重写模式、路由分割符、伪静态网址的后缀、基本网址
  *
  * @access private
  *
  * @param string $filePath 配置文件的路径
  *
  * @return boolean
  */
 private static function _init($filePath = null)
 {
     //加载对配置文件管理的类文件
     self::loadFile(DOIT_ROOT . 'core/Configure.class.php');
     //加载路由网址分析的类文件
     self::loadFile(DOIT_ROOT . 'core/Router.class.php');
     //加载Controller基类
     self::loadFile(DOIT_ROOT . 'core/Controller.class.php');
     //加载并分析项目的主配置文件
     Configure::loadConfig($filePath);
     //定义是否开启调试模式。开启后,程序运行出现错误时,显示错误信息,便于程序调试。
     if (!defined('DOIT_DEBUG')) {
         define('DOIT_DEBUG', Configure::get('application.debug'));
     }
     //定义URL的Rewrite功能是否开启。如开启后,需WEB服务器软件如:apache或nginx等,要开启Rewrite功能。
     if (!defined('DOIT_REWRITE')) {
         define('DOIT_REWRITE', Configure::get('application.rewrite'));
     }
     //定义项目应用目录(application)的基本路径
     if (!defined('BASE_PATH')) {
         define('BASE_PATH', rtrim(Configure::get('application.basePath'), '/') . DIRECTORY_SEPARATOR);
     }
     //定义项目缓存目录(cache)的基本路径
     if (!defined('CACHE_PATH')) {
         define('CACHE_PATH', rtrim(Configure::get('application.cachePath'), '/') . DIRECTORY_SEPARATOR);
     }
     //定义项目入口文件的名称
     if (!defined('ENTRY_SCRIPT_NAME')) {
         define('ENTRY_SCRIPT_NAME', basename($_SERVER['SCRIPT_NAME']));
     }
     //定义网址路由的分割符。注:分割符不要与其它网址参数等数据相冲突
     if (!defined('URL_SEGEMENTATION')) {
         define('URL_SEGEMENTATION', Configure::get('application.urlSegmentation'));
     }
     //定义路由网址的伪静态网址的后缀。注:不要忘记了.(点)
     if (!defined('URL_SUFFIX')) {
         define('URL_SUFFIX', Configure::get('application.urlSuffix'));
     }
     //定义路由网址的格式。注:get/path
     if (!defined('URL_FORMAT')) {
         define('URL_FORMAT', Configure::get('application.urlFormat'));
     }
     //定义视图文件格式
     if (!defined('VIEW_EXT')) {
         define('VIEW_EXT', Configure::get('application.viewExt'));
     }
     //定义默认的Module名称。注:名称要全部使用小写字母
     if (!defined('DEFAULT_MODULE')) {
         define('DEFAULT_MODULE', Configure::get('application.defaultModule'));
     }
     //定义默认的Controller名称。注:为提高不同系统平台的兼容性,名称首字母要大写,其余小写
     if (!defined('DEFAULT_CONTROLLER')) {
         define('DEFAULT_CONTROLLER', Configure::get('application.defaultController'));
     }
     //定义默认的Action名称。注:名称要全部使用小写字母
     if (!defined('DEFAULT_ACTION')) {
         define('DEFAULT_ACTION', Configure::get('application.defaultAction'));
     }
     return true;
 }
Beispiel #23
0
 * @package       minPHP
 * @version       $Revision: 52 $
 * @modifiedby    $LastChangedBy: cody $
 * @lastmodified  $Date: 2010-10-01 12:50:08 -0800 (Fri, 01 Oct 2010) $
 */
$start = microtime(true);
try {
    include dirname(__FILE__) . "/lib/init.php";
    // Dispatch the Web request
    if (!empty($_SERVER['REQUEST_URI'])) {
        Dispatcher::dispatch($_SERVER['REQUEST_URI']);
    } else {
        Dispatcher::dispatchCli($argv);
    }
} catch (Exception $e) {
    try {
        // Attempt to raise any error, gracefully
        Dispatcher::raiseError($e);
    } catch (Exception $e) {
        if (Configure::get("System.debug")) {
            echo $e->getMessage() . " on line <strong>" . $e->getLine() . "</strong> in <strong>" . $e->getFile() . "</strong>\n" . "<br />Printing Stack Trace:<br />" . nl2br($e->getTraceAsString());
        } else {
            echo $e->getMessage();
        }
    }
}
$end = microtime(true);
// Display rendering time if benchmarking is enabled
if (Configure::get("System.benchmark")) {
    echo "execution time: " . ($end - $start) . " seconds";
}
Beispiel #24
0
 /**
  * 回调类方法:自定义当前模型(Model)的数据库连接参数
  *
  * @access protected
  * @return array
  */
 protected function setConfig()
 {
     return Configure::get('db');
 }
 /**
  * @param $response
  */
 private function processTransaction($response)
 {
     $transaction_id = '';
     // If a response was given, record the transaction
     if (is_array($response)) {
         Loader::loadModels($this, array('Transactions', 'Clients', 'Companies', 'Emails'));
         Loader::loadHelpers($this, array('Date', 'CurrencyFormat'));
         $trans_data = array('client_id' => $response['client_id'], 'amount' => $response['amount'], 'currency' => $response['currency'], 'type' => "other", 'gateway_id' => $response['gateway_id'], 'transaction_id' => isset($response['transaction_id']) ? $response['transaction_id'] : null, 'reference_id' => isset($response['reference_id']) ? $response['reference_id'] : null, 'parent_transaction_id' => isset($response['parent_transaction_id']) ? $response['parent_transaction_id'] : null, 'status' => $response['status']);
         // If the transaction exists, update it
         if ($trans_data['transaction_id'] && ($transaction = $this->Transactions->getByTransactionId($trans_data['transaction_id'], null, $response['gateway_id']))) {
             // Don't update client_id to prevent transaction from being reassigned
             unset($trans_data['client_id']);
             $this->Transactions->edit($transaction->id, $trans_data);
             $transaction_id = $transaction->id;
         } else {
             $transaction_id = $this->Transactions->add($trans_data);
         }
     } elseif ($errors = $this->errors()) {
         $this->Input->setErrors($errors);
         die('Transaction invalid!');
     }
     // Set any errors with adding the transaction
     if ($errors = $this->Transactions->errors()) {
         $this->Input->setErrors($errors);
         die('Cannot process transaction #' . $transaction_id);
     } else {
         // Apply the transaction to the invoices given (if any)
         if (isset($response['invoices']) && is_array($response['invoices'])) {
             // Format invoices into something suitable for Transactions::apply()
             foreach ($response['invoices'] as &$invoice) {
                 $invoice['invoice_id'] = $invoice['id'];
                 unset($invoice['id']);
             }
             if (!empty($response['invoices']) && $response['status'] == "approved") {
                 $this->Transactions->apply($transaction_id, array('amounts' => $response['invoices']));
             }
         }
         $transaction = $this->Transactions->get($transaction_id);
         // Send an email regarding the non-merchant payment received
         if (isset($response['status']) && isset($response['client_id']) && $response['status'] == "approved" && $transaction && ($client = $this->Clients->get($response['client_id']))) {
             // Set date helper info
             $this->Date->setTimezone("UTC", Configure::get("Blesta.company_timezone"));
             $this->Date->setFormats(array('date_time' => $this->Companies->getSetting($response['company_id'], "datetime_format")->value));
             $amount = $this->CurrencyFormat->format($transaction->amount, $transaction->currency);
             $tags = array('contact' => $client, 'transaction' => $transaction, 'date_added' => $this->Date->cast($transaction->date_added, "date_time"));
             $this->Emails->send("payment_nonmerchant_approved", $response['company_id'], $client->settings['language'], $client->email, $tags, null, null, null, array('to_client_id' => $client->id));
         }
         die('OK');
     }
 }
Beispiel #26
0
 /** @inheritDoc */
 public function is(string $tag) : bool
 {
     switch ($tag) {
         case '#text':
         case '#comment':
             return $tag === $this->rawFullTag();
         case '#native':
             return array_key_exists($this->rawRootNs(), Configure::get('nativeNamespace'));
         case '#self-closing':
             return $this->is('#native') && in_array($this->rawFullTag(), Configure::get('nativeNamespace')[$this->rootNs()]);
         case '#process':
             return $this->source instanceof \DOMProcessingInstruction;
         case '#element':
             return $this->source instanceof \DOMElement;
         case '#pasap':
             return $this->rawRootNs() === 'pasap' || $this->endTag() === 'pasap';
         case '#resolved':
             return !is_null($this->resolvedTag());
         case '#cdata':
             return $this->rawFullTag() === '#cdata-section';
         default:
             return $tag === $this->tag();
     }
 }
Beispiel #27
0
 /**
  * 网址分析,获取路由网址有效的URI
  *
  * @access private
  * @return string
  */
 private static function _parseUri()
 {
     //初始化$uri
     $uri = $_SERVER['REQUEST_URI'];
     if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) {
         $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
     } else {
         //网址中省略引导文件名时
         $scriptBaseUrl = dirname($_SERVER['SCRIPT_NAME']);
         if (strpos($uri, $scriptBaseUrl) === 0) {
             $uri = substr($uri, strlen($scriptBaseUrl));
         }
     }
     $uri = ltrim($uri, '/');
     //当uri的内容极为简单,没有包含任何路由信息时
     if (!$uri) {
         return URL_SEGEMENTATION;
     }
     //当开启Rewrite设置时,去掉网址后缀
     if (DOIT_REWRITE === true) {
         $suffixLength = strlen(URL_SUFFIX);
         if (strlen($uri) > $suffixLength && substr($uri, -$suffixLength) == URL_SUFFIX) {
             $uri = substr($uri, 0, -$suffixLength);
         }
     }
     //如网址(URL)含有'?'(问号),则过滤掉问号(?)及其后面的所有字符串
     $pos = strpos($uri, '?');
     if ($pos !== false) {
         $uri = substr($uri, 0, $pos);
     }
     //当自定义URL路由功能开启时
     if ($uri && Configure::get('application.customUrlRouter') === true) {
         $ruleArray = Configure::get('router');
         if (is_array($ruleArray) && $ruleArray) {
             //利用正则表达式将自定义的网址替换掉,替换为真实的网址
             foreach ($ruleArray as $routerKey => $routerValue) {
                 $routerKey = str_replace(array(':any', ':num'), array('.+?', '[0-9]+'), $routerKey);
                 if (preg_match('#' . $routerKey . '#', $uri)) {
                     $uri = preg_replace('#' . $routerKey . '#', $routerValue, $uri);
                     break;
                 }
             }
         }
     }
     //当uri的内容极为简单,没有包含任何路由信息时
     if (!$uri || $uri == '/') {
         return URL_SEGEMENTATION;
     }
     return trim($uri, URL_SEGEMENTATION);
 }
Beispiel #28
0
 /**
  * Retrieves a list of webserver types from the config file
  *
  * @param stdClass $package The package
  * @return array A list of products
  */
 public function getWebserverTypes($cert_type = 1)
 {
     //webserver types
     return Configure::get("gogetsslv2.web_server_types.{$cert_type}");
 }