本文整理汇总了PHP中DBG::msg方法的典型用法代码示例。如果您正苦于以下问题:PHP DBG::msg方法的具体用法?PHP DBG::msg怎么用?PHP DBG::msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBG
的用法示例。
在下文中一共展示了DBG::msg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEvent
/**
* Event handler to add logs
*
* We need to do this with an event handler so there's no dependency to this component
* @param string $eventName Name of triggered event, should always be static::EVENT_NAME
* @param array $eventArgs Supplied arguments, should be an array (see DBG message below)
*/
public function onEvent($eventName, array $eventArgs)
{
if ($eventName != static::EVENT_NAME) {
return;
}
if (empty($eventArgs['severity']) || empty($eventArgs['message']) || empty($eventArgs['data'])) {
\DBG::msg('Triggered event "SysLog/Add" with wrong arguments. I need an array with non-empty values for the keys "severity", "message" and "data"');
return;
}
$this->addSysLog(new \Cx\Core_Modules\SysLog\Model\Entity\Log($eventArgs['severity'], $eventArgs['message'], $eventArgs['data']));
}
示例2: convertIdnToUtf8Format
/**
* Convert idn to utf8 format
*
* @param string $name
*
* @return string
*/
public static function convertIdnToUtf8Format($name)
{
if (empty($name)) {
return;
}
if (!function_exists('idn_to_utf8')) {
\DBG::msg('Idn is not supported in this system.');
} else {
$name = idn_to_utf8($name);
}
return $name;
}
示例3: set
public static function set($prop, &$val)
{
switch ($prop) {
case 'cx':
// set is only used for installerCx. Normal cx class will load with \Env::get('cx')
self::$props[$prop] = $val;
\DBG::msg(__METHOD__ . ": Setting '{$prop}' is deprecated. Use only for installer, otherwise use \\Env::('{$prop}')");
\DBG::stack();
break;
case 'em':
self::$props[$prop] = $val;
\DBG::msg(__METHOD__ . ": Setting '{$prop}' is deprecated. Env::get({$prop}) always returns the active/preferred instance of {$prop}.");
\DBG::stack();
break;
default:
self::$props[$prop] = $val;
break;
}
}
示例4: makeWritable
public static function makeWritable($path)
{
try {
$objFile = new \Cx\Lib\FileSystem\File($path);
$objFile->makeWritable();
return true;
} catch (FileSystemException $e) {
\DBG::msg($e->getMessage());
}
return false;
}
示例5: editMedia
/**
* Shows the image manipulation component.
*
* @global array $_ARRAYLANG
* @return string Parsed content.
*/
function editMedia()
{
global $_ARRAYLANG;
$this->_objTpl->loadTemplateFile('module_media_edit.html', true, true);
$this->pageTitle = $_ARRAYLANG['TXT_MEDIA_EDIT_FILE'];
if (isset($_GET['saveError']) && $_GET['saveError'] === 'true') {
$this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_ERROR_MESSAGE' => $_ARRAYLANG['TXT_MEDIA_CANNOT_SAVE_IMAGE']));
$this->_objTpl->parse('mediaErrorFile');
return;
}
// Activate cx
\JS::activate('cx');
// Activate jQuery and imgAreaSelect
\JS::activate('jquery');
\JS::activate('jquery-imgareaselect');
try {
// Get quality options from the settings
$arrImageSettings = $this->getImageSettings();
} catch (\Exception $e) {
\DBG::msg('Could not query image settings: ' . $e->getMessage());
}
$check = true;
empty($this->getFile) ? $check = false : '';
empty($this->getPath) ? $check = false : '';
!file_exists($this->path . $this->getFile) ? $check = false : '';
if ($check) {
// File exists
$this->_objTpl->setVariable(array('TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_SAVE_AS' => $_ARRAYLANG['TXT_MEDIA_SAVE_AS'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET'], 'TXT_MEDIA_PREVIEW' => $_ARRAYLANG['TXT_PREVIEW'], 'MEDIA_EDIT_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=editImage&path=' . $this->webPath, 'MEDIA_DIR' => $this->webPath, 'MEDIA_FILE' => $this->getFile));
$icon = $this->_getIcon($this->path . $this->getFile);
$info = pathinfo($this->getFile);
$fileExt = $info['extension'];
$ext = !empty($fileExt) ? '.' . $fileExt : '';
$fileName = substr($this->getFile, 0, strlen($this->getFile) - strlen($ext));
// Icon, file & extension name
$this->_objTpl->setVariable(array('MEDIA_FILE_ICON' => self::_getIconWebPath() . $icon . '.png', 'MEDIA_FILE_DIR' => $this->webPath, 'MEDIA_FILE_NAME' => $fileName, 'MEDIA_FILE_EXT' => $fileExt));
// Edit image
$imageSize = @getimagesize($this->path . $this->getFile);
$this->_objTpl->setVariable(array('TXT_MEDIA_IMAGE_MANIPULATION' => $_ARRAYLANG['TXT_MEDIA_IMAGE_MANIPULATION'], 'TXT_MEDIA_WIDTH' => $_ARRAYLANG['TXT_MEDIA_WIDTH'], 'TXT_MEDIA_HEIGHT' => $_ARRAYLANG['TXT_MEDIA_HEIGHT'], 'TXT_MEDIA_BALANCE' => $_ARRAYLANG['TXT_MEDIA_BALANCE'], 'TXT_MEDIA_QUALITY' => $_ARRAYLANG['TXT_MEDIA_QUALITY'], 'TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET'], 'TXT_MEDIA_SET_IMAGE_NAME' => $_ARRAYLANG['TXT_MEDIA_SET_IMAGE_NAME'], 'TXT_MEDIA_CONFIRM_REPLACE_IMAGE' => $_ARRAYLANG['TXT_MEDIA_CONFIRM_REPLACE_IMAGE'], 'TXT_MEDIA_REPLACE' => $_ARRAYLANG['TXT_MEDIA_REPLACE'], 'TXT_MEDIA_OR' => $_ARRAYLANG['TXT_MEDIA_OR'], 'TXT_MEDIA_SAVE_NEW_COPY' => $_ARRAYLANG['TXT_MEDIA_SAVE_NEW_COPY'], 'TXT_MEDIA_CROP' => $_ARRAYLANG['TXT_MEDIA_CROP'], 'TXT_MEDIA_CROP_INFO' => $_ARRAYLANG['TXT_MEDIA_CROP_INFO'], 'TXT_MEDIA_CANCEL' => $_ARRAYLANG['TXT_MEDIA_CANCEL'], 'TXT_MEDIA_ROTATE' => $_ARRAYLANG['TXT_MEDIA_ROTATE'], 'TXT_MEDIA_ROTATE_INFO' => $_ARRAYLANG['TXT_MEDIA_ROTATE_INFO'], 'TXT_MEDIA_SCALE_COMPRESS' => $_ARRAYLANG['TXT_MEDIA_SCALE_COMPRESS'], 'TXT_MEDIA_SCALE_INFO' => $_ARRAYLANG['TXT_MEDIA_SCALE_INFO'], 'TXT_MEDIA_PREVIEW' => $_ARRAYLANG['TXT_MEDIA_PREVIEW'], 'MEDIA_IMG_WIDTH' => $imageSize[0], 'MEDIA_IMG_HEIGHT' => $imageSize[1]));
foreach ($this->arrImageQualityValues as $value) {
$this->_objTpl->setVariable(array('IMAGE_QUALITY_VALUE' => $value, 'IMAGE_QUALITY_OPTION_CHECKED' => $value == $arrImageSettings['image_compression'] ? 'selected="selected"' : ''));
$this->_objTpl->parse('mediaEditImageQualityOptions');
}
$this->_objTpl->parse('mediaEditImage');
} else {
// File doesn't exist
$this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_ERROR_MESSAGE' => $_ARRAYLANG['TXT_MEDIA_FILE_DONT_EXISTS']));
$this->_objTpl->parse('mediaErrorFile');
}
// Variables
$this->_objTpl->setVariable(array('CSRF' => \Cx\Core\Csrf\Controller\Csrf::param(), 'MEDIA_EDIT_AJAX_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=editImage&path=' . $this->webPath, 'MEDIA_EDIT_REDIRECT' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath, 'MEDIA_BACK_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath, 'MEDIA_FILE_IMAGE_SRC' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=getImage&path=' . $this->webPath . '&file=' . $this->getFile . '&' . \Cx\Core\Csrf\Controller\Csrf::param(), 'MEDIA_IMAGE_WIDTH' => !empty($imageSize) ? intval($imageSize[0]) : 0, 'MEDIA_IMAGE_HEIGHT' => !empty($imageSize) ? intval($imageSize[1]) : 0, 'MEDIA_IMAGE_CROP_WIDTH' => $arrImageSettings['image_cut_width'], 'MEDIA_IMAGE_CROP_HEIGHT' => $arrImageSettings['image_cut_height'], 'MEDIA_IMAGE_RESIZE_QUALITY' => $arrImageSettings['image_compression']));
}
示例6: saveEntry
//.........这里部分代码省略.........
$associatedEntityClassMetadata = $em->getClassMetadata($value["targetEntity"]);
foreach ($_POST[$relatedClassInputFieldName] as $relatedPostData) {
$entityData = array();
parse_str($relatedPostData, $entityData);
// if we have already an entry (on update) we take the existing one and update it.
// Otherwise we create a new one
if (isset($entityData['id']) && $entityData['id'] != 0) {
// update/edit case
$associatedClassRepo = $em->getRepository($value["targetEntity"]);
$associatedEntity = $associatedClassRepo->find($entityData['id']);
} else {
// add case
$associatedEntity = $associatedEntityClassMetadata->newInstance();
}
// if there are any entries which the user wants to delete, we delete them here
if (isset($entityData['delete']) && $entityData['delete'] == 1) {
$em->remove($associatedEntity);
}
// save the "n" associated class data to its class
$this->savePropertiesToClass($associatedEntity, $associatedEntityClassMetadata, $entityData, $entityWithNS);
// Linking 1: link the associated entity to the main entity for doctrine
$methodName = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
if (!in_array($methodName, $classMethods)) {
\Message::add(sprintf($_ARRAYLANG['TXT_CORE_RECORD_FUNCTION_NOT_FOUND'], $name, $methodName), \Message::CLASS_ERROR);
continue;
}
$entity->{$methodName}($associatedEntity);
// Linking 2: link the main entity to its associated entity. This should normally be done by
// 'Linking 1' but because not all components have implemented this, we do it here by ourselves
$method = 'set' . ucfirst($value["mappedBy"]);
if (method_exists($associatedEntity, $method)) {
$associatedEntity->{$method}($entity);
}
// buffer entity, so we can persist it later
$associatedEntityToPersist[] = $associatedEntity;
}
}
}
if ($entityId != 0) {
// edit case
// update the main entry in doctrine so we can store it over doctrine to database later
$this->savePropertiesToClass($entity, $entityClassMetadata);
$param = 'editid';
$successMessage = $_ARRAYLANG['TXT_CORE_RECORD_UPDATED_SUCCESSFUL'];
} else {
// add case
// save main formular class data to its class over $_POST
$this->savePropertiesToClass($entity, $entityClassMetadata);
$param = 'add';
$successMessage = $_ARRAYLANG['TXT_CORE_RECORD_ADDED_SUCCESSFUL'];
}
$showSuccessMessage = false;
if ($entity instanceof \Cx\Core\Model\Model\Entity\YamlEntity) {
// Save the yaml entities
$entityRepository = $em->getRepository($entityWithNS);
if (!$entityRepository->isManaged($entity)) {
$entityRepository->add($entity);
}
$entityRepository->flush();
$showSuccessMessage = true;
} else {
if ($entity instanceof \Cx\Model\Base\EntityBase) {
/* We try to store the prepared em. This may fail if (for example) we have a one to many association which
can not be null but was not set in the post request. This cases should be caught here. */
try {
// persist main entity. This must be done first, otherwise saving oneToManyAssociated entities won't work
$em->persist($entity);
// now we can persist the associated entities. We need to do this, because otherwise it will fail,
// if yaml does not contain a cascade option
foreach ($associatedEntityToPersist as $associatedEntity) {
$em->persist($associatedEntity);
}
$em->flush();
$showSuccessMessage = true;
} catch (\Cx\Core\Error\Model\Entity\ShinyException $e) {
/* Display the message from the exception. If this message is empty, we output a general message,
so the user knows what to do in every case */
if ($e->getMessage() != "") {
\Message::add($e->getMessage(), \Message::CLASS_ERROR);
} else {
\Message::add($_ARRAYLANG['TXT_CORE_RECORD_UNKNOWN_ERROR'], \Message::CLASS_ERROR);
}
return;
} catch (\Exception $e) {
echo $e->getMessage();
die;
}
} else {
\Message::add($_ARRAYLANG['TXT_CORE_RECORD_VALIDATION_FAILED'], \Message::CLASS_ERROR);
\DBG::msg('Unkown entity model ' . get_class($entity) . '! Trying to persist using entity manager...');
}
}
if ($showSuccessMessage) {
\Message::add($successMessage);
}
// get the proper action url and redirect the user
$actionUrl = clone $cx->getRequest()->getUrl();
$actionUrl->setParam($param, null);
\Cx\Core\Csrf\Controller\Csrf::redirect($actionUrl);
}
示例7: getJson
/**
* Fetches a json response via HTTP request
* @todo Support cookies (to allow login and similiar features)
* @param string $url URL to get json from
* @param array $data (optional) HTTP post data
* @param boolean $secure (optional) Wheter to verify peer using SSL or not, default false
* @param string $certificateFile (optional) Local certificate file for non public SSL certificates
* @param array Set an optional HTTP Authentication method and supply its login credentials.
* The supplied array must comply with the following structure:
* <pre class="brush: php">
* $httpAuth = array(
* 'httpAuthMethod' => 'none|basic|disgest',
* 'httpAuthUsername' => '<username>',
* 'httpAuthPassword' => '<password>',
* );
* </pre>
* @return mixed Decoded JSON on success, false otherwise
*/
public function getJson($url, $data = array(), $secure = false, $certificateFile = '', $httpAuth = array(), $files = array())
{
$request = new \HTTP_Request2($url, \HTTP_Request2::METHOD_POST);
if (!empty($httpAuth)) {
switch ($httpAuth['httpAuthMethod']) {
case 'basic':
$request->setAuth($httpAuth['httpAuthUsername'], $httpAuth['httpAuthPassword'], \HTTP_Request2::AUTH_BASIC);
break;
case 'disgest':
$request->setAuth($httpAuth['httpAuthUsername'], $httpAuth['httpAuthPassword'], \HTTP_Request2::AUTH_DIGEST);
break;
case 'none':
default:
break;
}
}
foreach ($data as $name => $value) {
$request->addPostParameter($name, $value);
}
if (!empty($files)) {
foreach ($files as $fieldId => $file) {
$request->addUpload($fieldId, $file);
}
}
if ($this->sessionId !== null) {
$request->addCookie(session_name(), $this->sessionId);
}
$request->setConfig(array('ssl_verify_host' => false, 'ssl_verify_peer' => false, 'follow_redirects' => true, 'strict_redirects' => true));
$response = $request->send();
//echo '<pre>';var_dump($response->getBody());echo '<br /><br />';
$cookies = $response->getCookies();
foreach ($cookies as &$cookie) {
if ($cookie['name'] === session_name()) {
$this->sessionId = $cookie['value'];
break;
}
}
if ($response->getStatus() != 200) {
\DBG::msg(__METHOD__ . ' Request failed! Status: ' . $response->getStatus());
\DBG::msg('URL: ' . $url);
\DBG::dump($data);
return false;
}
$body = json_decode($response->getBody());
if ($body === NULL) {
\DBG::msg(__METHOD__ . ' failed!');
\DBG::dump($response->getBody());
}
return $body;
}
示例8: createOrder
/**
* Create a new Order
*
* @param integer $productId productId
* @param object $objUser \User object
* @param string $transactionReference transactionReference
* @param array $subscriptionOptions subscriptionOptions
*
* @return boolean
* @throws OrderRepositoryException
*/
public function createOrder($productId, \Cx\Modules\Crm\Model\Entity\Currency $currency, \User $objUser, $transactionReference, $subscriptionOptions = array())
{
if (\FWValidator::isEmpty($productId) || \FWValidator::isEmpty($subscriptionOptions) || \FWValidator::isEmpty($transactionReference) || \FWValidator::isEmpty($currency)) {
return;
}
$contactId = $objUser->getCrmUserId();
if (\FWValidator::isEmpty($contactId)) {
return;
}
try {
$order = new \Cx\Modules\Order\Model\Entity\Order();
$order->setContactId($contactId);
$order->setCurrency($currency);
$productRepository = \Env::get('em')->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Product');
$product = $productRepository->findOneBy(array('id' => $productId));
//create subscription
$subscription = $order->createSubscription($product, $subscriptionOptions);
// set discount price for first payment period of subscription
if (!empty($subscriptionOptions['oneTimeSalePrice'])) {
$subscription->setPaymentAmount($subscriptionOptions['oneTimeSalePrice']);
}
$order->billSubscriptions();
$invoices = $order->getInvoices();
if (!empty($invoices)) {
\DBG::msg(__METHOD__ . ": order has invoices");
$paymentRepo = \Env::get('em')->getRepository('\\Cx\\Modules\\Order\\Model\\Entity\\Payment');
foreach ($invoices as $invoice) {
if (!$invoice->getPaid()) {
\DBG::msg(__METHOD__ . ": lookup payment with transaction-reference {$transactionReference} and amount " . $invoice->getAmount());
$payment = $paymentRepo->findOneByCriteria(array('amount' => $invoice->getAmount(), 'transactionReference' => $transactionReference, 'invoice' => null));
if ($payment) {
\DBG::msg(__METHOD__ . ": payment found");
//set subscription-id to Subscription::$externalSubscriptionId
if ($subscription) {
\DBG::msg(__METHOD__ . ": trying to link to new subscription to the external subscription ID");
$referenceArry = explode('|', $payment->getTransactionReference());
if (isset($referenceArry[4]) && !empty($referenceArry[4])) {
$subscription->setExternalSubscriptionId($referenceArry[4]);
}
}
$transactionData = $payment->getTransactionData();
if (!\FWValidator::isEmpty($transactionData) && isset($transactionData['contact']) && isset($transactionData['contact']['id'])) {
\DBG::msg(__METHOD__ . ": set externalPaymentCustomerIdProfileAttributeId of user to " . $transactionData['contact']['id']);
$objUser->setProfile(array(\Cx\Core\Setting\Controller\Setting::getValue('externalPaymentCustomerIdProfileAttributeId', 'MultiSite') => array(0 => $transactionData['contact']['id'])), true);
if (!$objUser->store()) {
\DBG::msg('Order::createOrder() Updating user failed: ' . $objUser->getErrorMsg());
}
}
$invoice->addPayment($payment);
$payment->setInvoice($invoice);
\Env::get('em')->persist($invoice);
\Env::get('em')->persist($payment);
break;
}
}
}
}
\Env::get('em')->persist($order);
\Env::get('em')->flush();
return $order;
} catch (\Exception $e) {
throw new OrderRepositoryException($e->getMessage());
}
}
示例9: getUploaderCode
/**
* Get uploader code
*
* @param string $fieldKey uploadFieldKey
* @param string $fieldName uploadFieldName
* @param string $uploadCallBack upload callback function
* @param boolean $allowImageOnly allow only images files
*
* @return string uploaderCode
* @throws \Exception
*/
protected function getUploaderCode($fieldKey, $fieldName, $uploadCallBack = "uploadFinished", $allowImageOnly = true)
{
\cmsSession::getInstance();
$cx = \Cx\Core\Core\Controller\Cx::instanciate();
try {
$uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
$uploaderId = $uploader->getId();
$uploadOptions = array('id' => 'calendarUploader_' . $uploaderId, 'style' => 'display: none');
if ($allowImageOnly) {
$uploadOptions['allowed-extensions'] = array('gif', 'jpg', 'png', 'jpeg');
}
$uploader->setCallback($fieldName . 'JsCallback');
$uploader->setUploadLimit(1);
$uploader->setOptions($uploadOptions);
$uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Calendar/Controller/Calendar.class.php', '\\Cx\\Modules\\Calendar\\Controller\\Calendar', $uploadCallBack));
$folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploaderId);
$this->_objTpl->setVariable(array(strtoupper($fieldName) . '_WIDGET_CODE' => $folderWidget->getXHtml(), "{$this->moduleLangVar}_" . strtoupper($fieldKey) => $uploaderId));
$strJs = <<<JAVASCRIPT
{$uploader->getXHtml()}
<script type="text/javascript">
cx.ready(function() {
//called if user clicks on the field
jQuery('#{$fieldName}').bind('click', function() {
jQuery('#calendarUploader_{$uploaderId}').trigger('click');
return false;
});
});
//uploader javascript callback function
function {$fieldName}JsCallback(callback) {
angular.element('#mediaBrowserfolderWidget_{$folderWidget->getId()}').scope().refreshBrowser();
}
</script>
JAVASCRIPT;
return $strJs;
} catch (\Exception $e) {
\DBG::msg('<!-- failed initializing uploader -->');
throw new \Exception("failed initializing uploader");
}
}
示例10: check
/**
* checks whether the entered string matches the captcha.
* if the check is already done the result will be returned.
*
* @return boolean
*/
public function check()
{
if (empty($this->securityCheck)) {
if ($this->isValidCode()) {
$this->securityCheck = true;
} else {
$this->securityCheck = false;
if (!empty($_POST['coreCaptchaCode'])) {
\DBG::msg('Captcha: The entered security code was incorrect.');
}
}
}
return $this->securityCheck;
}
示例11: __construct
/**
* Handles a list
* @param mixed $entities Entity class name as string or callback function
* @param array $crit (optional) Doctrine style criteria array to use
* @param array $options (Unused)
*/
public function __construct($entities, $crit = array(), $options = array())
{
if (isset($options['paging'])) {
$this->paging = $options['paging'];
}
if (isset($options['order'])) {
$this->order = $options['order'];
}
// init handlers (filtering, paging and sorting)
$this->handlers[] = new FilteringController();
if (!empty($options['sorting'])) {
$this->handlers[] = new SortingController();
}
$this->handlers[] = new PagingController();
if (is_callable($entities)) {
\DBG::msg('Init ListingController using callback function');
$this->callback = $entities;
} else {
if ($entities instanceof \Cx\Core_Modules\Listing\Model\Entity\DataSet) {
\DBG::msg('Init ListingController using DataSet');
$this->entityClass = $entities;
} else {
\DBG::msg('Init ListingController using entity class');
$this->entityClass = $entities;
}
}
$this->criteria = $crit;
// todo: allow multiple listing controllers per page request
$this->args = contrexx_input2raw($_GET);
}
示例12: _writeNewConfigurationFile
function _writeNewConfigurationFile()
{
global $_CORELANG, $_ARRAYLANG, $_DBCONFIG, $_PATHCONFIG, $_FTPCONFIG, $_CONFIGURATION, $_CONFIG;
$ftpStatus = $_FTPCONFIG['is_activated'] ? 'true' : 'false';
$charset = 'UTF-8';
$dbCharset = 'utf8';
$_FTPCONFIG['port'] = intval($_FTPCONFIG['port']);
$configurationTpl = <<<CONFIG_TPL
<?php
global \$_DBCONFIG, \$_PATHCONFIG, \$_FTPCONFIG, \$_CONFIG;
/**
* @exclude
*
* Cloudrexx CMS Web Installer
* Please use the Cloudrexx CMS installer to configure this file
* or edit this file and configure the parameters for your site and
* database manually.
*/
/**
* -------------------------------------------------------------------------
* Set installation status
* -------------------------------------------------------------------------
*/
define('CONTREXX_INSTALLED', true);
/**
* -------------------------------------------------------------------------
* Database configuration section
* -------------------------------------------------------------------------
*/
\$_DBCONFIG['host'] = '{$_DBCONFIG['host']}'; // This is normally set to localhost
\$_DBCONFIG['database'] = '{$_DBCONFIG['database']}'; // Database name
\$_DBCONFIG['tablePrefix'] = '{$_DBCONFIG['tablePrefix']}'; // Database table prefix
\$_DBCONFIG['user'] = '{$_DBCONFIG['user']}'; // Database username
\$_DBCONFIG['password'] = '{$_DBCONFIG['password']}'; // Database password
\$_DBCONFIG['dbType'] = '{$_DBCONFIG['dbType']}'; // Database type (e.g. mysql,postgres ..)
\$_DBCONFIG['charset'] = '{$dbCharset}'; // Charset (default, latin1, utf8, ..)
\$_DBCONFIG['timezone'] = '{$_CONFIG['timezone']}'; // Controller's timezone for model
\$_DBCONFIG['collation'] = '{$_DBCONFIG['collation']}';
/**
* -------------------------------------------------------------------------
* Site path specific configuration
* -------------------------------------------------------------------------
*/
\$_PATHCONFIG['ascms_root'] = '';
\$_PATHCONFIG['ascms_root_offset'] = ''; // example: '/cms';
\$_PATHCONFIG['ascms_installation_root'] = \$_PATHCONFIG['ascms_root'];
\$_PATHCONFIG['ascms_installation_offset'] = \$_PATHCONFIG['ascms_root_offset']; // example: '/cms';
/**
* -------------------------------------------------------------------------
* Ftp specific configuration
* -------------------------------------------------------------------------
*/
\$_FTPCONFIG['is_activated'] = {$ftpStatus}; // Ftp support true or false
\$_FTPCONFIG['host'] = '{$_FTPCONFIG['host']}';// This is normally set to localhost
\$_FTPCONFIG['port'] = {$_FTPCONFIG['port']}; // Ftp remote port
\$_FTPCONFIG['username'] = '{$_FTPCONFIG['username']}'; // Ftp login username
\$_FTPCONFIG['password'] = '{$_FTPCONFIG['password']}'; // Ftp login password
\$_FTPCONFIG['path'] = '{$_FTPCONFIG['path']}'; // Ftp path to cms (must not include ascms_root_offset)
/**
* -------------------------------------------------------------------------
* Base setup (altering might break the system!)
* -------------------------------------------------------------------------
*/
// Set character encoding
\$_CONFIG['coreCharacterEncoding'] = 'UTF-8'; // example 'UTF-8'
CONFIG_TPL;
// write settings
try {
$objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/configuration.php');
$objFile->makeWritable();
$objFile->write($configurationTpl);
} catch (\Cx\Lib\FileSystem\FileSystemException $e) {
\DBG::msg($e->getMessage());
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php'));
setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
return false;
}
return true;
}
示例13: makeWritable
public function makeWritable()
{
// abort process in case the file is already writable
if (is_writable($this->filePath)) {
return true;
}
$parentDirectory = dirname($this->filePath);
if (!is_writable($parentDirectory)) {
if (strpos($parentDirectory, \Env::get('cx')->getWebsiteDocumentRootPath()) === 0) {
// parent directory lies within the Contrexx installation directory,
// therefore, we shall try to make it writable
\Cx\Lib\FileSystem\FileSystem::makeWritable($parentDirectory);
} else {
throw new FileSystemFileException('Parent directory ' . $parentDirectory . ' lies outside of Contrexx installation and can therefore not be made writable!');
}
}
// fetch current permissions on loaded file
$filePerms = $this->getFilePermissions();
// set write access to file owner
$filePerms |= \Cx\Lib\FileSystem\FileSystem::CHMOD_USER_WRITE;
// log file permissions into the humand readable chmod() format
\DBG::msg('CHMOD: ' . substr(sprintf('%o', $filePerms), -4));
if (!@chmod($this->filePath, $filePerms)) {
throw new FileSystemFileException('Unable to set write access to file ' . $this->filePath . '!');
}
}
示例14: AddAttachment
/**
* Adds an attachment from a path on the filesystem.
* Returns false if the file could not be found
* or accessed.
* @param string $path Path to the attachment.
* @param string $name Overrides the attachment name.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File extension (MIME) type.
* @return bool
*/
public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream')
{
try {
if (!@is_file($path)) {
throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
$this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => 'attachment', 7 => 0);
} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
DBG::msg($e->getMessage());
if ($e->getCode() == self::STOP_CRITICAL) {
return false;
}
}
return true;
}
示例15: _createSettingsFile
/**
* Write all settings into the config-file
*
*/
function _createSettingsFile()
{
global $_ARRLANG;
$objDb = $this->_getDbObject($statusMsg);
if ($objDb === false) {
return $statusMsg;
} else {
$strSettingsFile = $_SESSION['installer']['config']['documentRoot'] . $_SESSION['installer']['config']['offsetPath'] . '/config/settings.php';
if (!\Cx\Lib\FileSystem\FileSystem::touch($strSettingsFile) || !\Cx\Lib\FileSystem\FileSystem::makeWritable($strSettingsFile)) {
return sprintf($_ARRLANG['TXT_SETTINGS_ERROR_WRITABLE'], $strSettingsFile);
}
//Header & Footer
$strHeader = "<?php\n";
$strHeader .= "/**\n";
$strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
$strHeader .= "* Do not try to edit it manually!\n";
$strHeader .= "*/\n\n";
$strFooter = "\n";
//Get module-names
$objResult = $objDb->Execute("SELECT id, name FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "modules`");
if ($objResult->RecordCount() > 0) {
while (!$objResult->EOF) {
$arrModules[$objResult->fields['id']] = $objResult->fields['name'];
$objResult->MoveNext();
}
}
//Get values
$objResult = $objDb->Execute("SELECT setname, setmodule, setvalue FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "settings` ORDER BY setmodule ASC, setname ASC");
$intMaxLen = 0;
if ($objResult->RecordCount() > 0) {
while (!$objResult->EOF) {
$intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen;
$arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue'];
$objResult->MoveNext();
}
}
$intMaxLen += strlen('$_CONFIG[\'\']') + 1;
//needed for formatted output
//Write values
$data = $strHeader;
$strBody = '';
foreach ($arrValues as $intModule => $arrInner) {
$strBody .= "/**\n";
$strBody .= "* -------------------------------------------------------------------------\n";
$strBody .= "* " . ucfirst(isset($arrModules[$intModule]) ? $arrModules[$intModule] : '') . "\n";
$strBody .= "* -------------------------------------------------------------------------\n";
$strBody .= "*/\n";
foreach ($arrInner as $strName => $strValue) {
$strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']');
$strBody .= "= ";
$strBody .= (is_numeric($strValue) ? $strValue : '"' . str_replace('"', '\\"', $strValue) . '"') . ";\n";
}
$strBody .= "\n";
}
$data .= $strBody;
$data .= $strFooter;
try {
$objFile = new \Cx\Lib\FileSystem\File($strSettingsFile);
$objFile->write($data);
return true;
} catch (\Cx\Lib\FileSystem\FileSystemException $e) {
DBG::msg($e->getMessage());
}
return false;
}
}