예제 #1
0
 public function run($isTab = false)
 {
     /** @var TourBuilderForm $tourForm */
     $tourForm = Yii::app()->user->getState('tourForm');
     $eventId = $tourForm->eventId;
     $startCities = Yii::app()->user->getState('startCities');
     $currentStartCityIndex = Yii::app()->user->getState('startCitiesIndex') - 1;
     $currentStartCity = City::model()->findByPk($startCities[$currentStartCityIndex]->id);
     $startCityId = $currentStartCity->id;
     $event = Event::model()->findByPk($eventId);
     $tripStorage = new TripStorage();
     $order = $tripStorage->saveOrder($event, $startCityId, 'Тур для события "' . $event->title . '" из ' . $currentStartCity->caseGen);
     $eventOrder = new EventOrder();
     $eventOrder->startCityId = $startCityId;
     $eventOrder->orderId = $order->id;
     $eventOrder->eventId = $event->id;
     $eventOrder->save();
     $eventPrice = EventPrice::model()->findByAttributes(array('eventId' => $eventId, 'cityId' => $startCityId));
     if (!$eventPrice) {
         $eventPrice = new EventPrice();
     }
     $eventPrice->eventId = $event->id;
     $eventPrice->cityId = $startCityId;
     $eventPrice->bestPrice = $tripStorage->getPrice();
     if (!$eventPrice->save()) {
         throw new CHttpException('Could not save price for event - city.' . CVarDumper::dumpAsString($eventPrice));
     }
     $this->controller->redirect($this->controller->createUrl('showEventTrip'));
 }
예제 #2
0
파일: Dump.php 프로젝트: wuhailin/composer
 public static function dump()
 {
     echo '<pre>';
     CVarDumper::dump(func_get_args());
     echo '<pre>';
     exit;
 }
예제 #3
0
 public function registerScript($id, $script, $position = null, array $htmlOptions = array())
 {
     // assumed config includes the required path aliases to use
     // EScriptBoost
     $debug = YII_DEBUG;
     // Check if this script is in the exceptions - if so, skip caching.
     foreach ($this->skipList as $s) {
         $skip |= strpos($id, $s) === 0;
         if ($skip) {
             break;
         }
     }
     $compressed = !$debug ? false : Yii::app()->cache->get($id);
     if ($skip) {
         // Skipping scripts that should not be cached.
         $compressed = EScriptBoost::minifyJs($script);
     } elseif ($debug && $compressed !== false) {
         // During debug check that the newly minified script is not different from the cached one.
         // If so, log the difference so that it can be fixed.
         $c = EScriptBoost::minifyJs($script);
         if ($c !== $compressed) {
             Yii::log("Issue with caching of compressed script '{$id}'\n" . CVarDumper::dumpAsString($c) . "\nXXX\n" . CVarDumper::dumpAsString($compressed), CLogger::LEVEL_ERROR);
         }
     } elseif ($compressed === false) {
         $compressed = EScriptBoost::minifyJs($script);
         Yii::app()->cache->set($id, $compressed, $this->cacheDuration);
     }
     parent::registerScript($id, $compressed, $position, $htmlOptions);
 }
예제 #4
0
파일: dump.php 프로젝트: xexys/xca-backend
/**
 * Функция для отладки, печатает переменную с подсветкой синтаксиса
 * @param mixed
 */
function d()
{
    foreach (func_get_args() as $arg) {
        CVarDumper::dump($arg, 10, true);
        echo '<hr>';
    }
}
 public function actionAdd()
 {
     $model = new Umbrella();
     if (isset($_POST['Umbrella'])) {
         $model->attributes = $_POST;
         $model->umbrellaid = uniqid('', true);
         $model->attributes = $_POST['Umbrella'];
         $model->create_userid = $this->user_id;
         $model->now_userid = $this->user_id;
         $model->create_at = $this->getTime();
         if (SERVER_TEST) {
             $model->img = "http://umbrella.b0.upaiyun.com/991c/991c1b1f34d6d076bcf7e01925af1e43/7GTMyFS_QW00m6fdAzzdphLPJtGAvlF9Gd4ivkWNQ9-olR2mFgn6NBn8JW8e78H2.jpg";
         }
         // 			$model->status=UMBRELLASTATUS::IDLE;
         if ($model->validate()) {
             $model->img = $this->updateWxImage($model->img);
             if (!$model->save()) {
                 Yii::log(CVarDumper::dumpAsString($user->errors), 'error', "Add umbrella save error");
             }
             $this->actionInfo($model->umbrellaid);
             return;
         }
     }
     $this->render('add', array('model' => $model, 'status' => 'new'));
 }
예제 #6
0
 /**
  * Displays a variable.
  * This method achieves the similar functionality as var_dump and print_r
  * but is more robust when handling complex objects such as Yii controllers.
  * @param mixed $var variable to be dumped
  */
 public static function dump()
 {
     $args = func_get_args();
     if (php_sapi_name() == "cli") {
         foreach ($args as $k => $var) {
             var_dump($var);
             echo "\n";
         }
         return;
     } else {
         if (empty($_SERVER['SERVER_ADDR']) || empty($_SERVER['REMOTE_ADDR']) || $_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR']) {
             return;
         }
     }
     $backTrace = debug_backtrace();
     $backTrace = array_shift($backTrace);
     echo '<div style="margin: 10px;border: 1px solid red;padding: 10px; background: #fff;">';
     if (is_array($backTrace) && isset($backTrace['file']) && isset($backTrace['function']) && $backTrace['function'] === __FUNCTION__) {
         echo "<b>{$backTrace['file']}</b> in line <b>{$backTrace['line']}</b> <br />";
         echo '<div style="border-bottom:1px solid #006699;margin: 5px 0;"></div>';
     }
     foreach ($args as $k => $var) {
         echo CVarDumper::dump($var, 10, true), '<br />';
     }
     echo "</div>";
 }
예제 #7
0
 public function actionChangeState($hotelBookerId = 0, $newState = '')
 {
     if ($hotelBookerId) {
         /** @var HotelBookerComponent $hotelBookerComponent  */
         $hotelBookerComponent = new HotelBookerComponent();
         $hotelBookerComponent->setHotelBookerFromId($hotelBookerId);
         echo "HotelBookerId " . $hotelBookerComponent->getHotelBookerId() . PHP_EOL;
         echo "Current status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . PHP_EOL;
         echo "Next possible status are " . $hotelBookerComponent->getCurrent()->swGetNextStatus() . PHP_EOL;
         echo "Trying to change status to {$newState}" . PHP_EOL;
         if ($newState) {
             $res = $hotelBookerComponent->status($newState);
             if (!$res) {
                 CVarDumper::dump($hotelBookerComponent->getCurrent()->getErrors());
                 CVarDumper::dump($hotelBookerComponent->getCurrent()->getAttributes());
                 echo PHP_EOL;
             } else {
                 $hotelBookerComponent->getCurrent()->onlySave();
             }
             echo "Status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . "\n";
         }
     } else {
         $helpText = $this->getHelp();
         $helpText = str_replace('command', 'ChangeState', $helpText);
         echo $helpText;
     }
 }
예제 #8
0
 public static function injectForBe($flightVoyages, $injectSearchParams = false)
 {
     $newFlights = array();
     try {
         if (!is_iterable($flightVoyages)) {
             throw new CException('Flight Voyages are not iterable.');
         }
         foreach ($flightVoyages as $key => $flight) {
             $newFlight = $flight;
             if ($injectSearchParams) {
                 $newFlight['serviceClass'] = $injectSearchParams['serviceClass'];
                 $newFlight['freeWeight'] = $newFlight['serviceClass'] == 'E' ? $flight['economFreeWeight'] : $flight['businessFreeWeight'];
                 $newFlight['freeWeightDescription'] = $newFlight['serviceClass'] == 'E' ? $flight['economDescription'] : $flight['businessDescription'];
                 unset($newFlight['economFreeWeight']);
                 unset($newFlight['businessFreeWeight']);
                 unset($newFlight['economDescription']);
                 unset($newFlight['businessDescription']);
             }
             $newFlights[] = $newFlight;
         }
         return $newFlights;
     } catch (Exception $e) {
         $newException = new Exception("Error: " . $e->getMessage() . " Data: " . CVarDumper::dumpAsString($flightVoyages));
         Yii::app()->RSentryException->logException($newException);
         return $newFlights;
     }
 }
예제 #9
0
 public static function createOrUpdate($id, $title, $address, $latitude, $longitude, $type = 'create')
 {
     $querystring_arrays = array();
     $uri = '';
     if ($type == 'create') {
         //这里是创建
         $uri = '/geodata/v3/poi/create';
         $querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK);
     } else {
         //这里是更新
         $uri = '/geodata/v3/poi/update';
         $querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK);
     }
     $sn = BDLbs::caculateAKSN($uri, $querystring_arrays, "POST");
     $querystring_arrays['sn'] = $sn;
     Yii::trace(CVarDumper::dumpAsString($querystring_arrays), 'create or update baidu poi post');
     $ret = Yii::app()->curl->post(Yii::app()->params['baiduapi'] . $uri, $querystring_arrays);
     $ret = json_decode($ret, true);
     Yii::trace(CVarDumper::dumpAsString($ret), 'create or update baidu poi');
     if ($ret['status'] == 0) {
         return $ret['id'];
     } else {
         Yii::log(CVarDumper::dumpAsString($ret), 'error', 'create or update baidu poi ERROR');
         return -1;
     }
 }
예제 #10
0
 /**
  * @param array $options options for tree searching. Valid options are:
  * exclude: array list of children exclusions
  * level: integer, recursion depth, default=-1
  * Level -1 means searching for all children under root;
  * Level 0 means searching for only the child DIRECTLY under the root;
  * level N means searching for those children that are within N levels.
  */
 public function findTree($options = array())
 {
     $exclude = array();
     $level = -1;
     extract($options);
     $cache = $this->getCache();
     $cacheKey = get_class($this->getOwner()) . '-' . $this->getOwner()->{$this->primaryKey} . '-' . $this->className . '-' . $this->primaryKey . '-' . $this->attributeName . '-' . CVarDumper::dumpAsString($this->attributes) . '-' . CVarDumper::dumpAsString($this->criteria) . '-' . CVarDumper::dumpAsString($exclude) . '-' . CVarDumper::dumpAsString($level);
     $cacheKey = md5($cacheKey);
     if (isset($cache) && ($data = $cache->get($cacheKey)) !== false) {
         Yii::trace('Find tree from cache:' . $cacheKey, 'Xpress.extensions.web.behaviors');
         return $data;
     }
     $event = new NestedEvent($this);
     $event->params = array('exclude' => $exclude, 'level' => $level);
     if ($this->hasEventHandler('onBeforeFindTree')) {
         $this->onBeforeFindTree($event);
     }
     $tree = $this->findTreeRecursive($exclude, 0, NULL, $level);
     $event->data =& $tree;
     if ($this->hasEventHandler('onAfterFindTree')) {
         $this->onAfterFindTree($event);
     }
     if (isset($cache)) {
         $cache->set($cacheKey, $tree);
     }
     Yii::trace('Find tree from database', 'Xpress.extensions.web.behaviors');
     return $tree;
 }
예제 #11
0
 public function bookAndReturnTripElementWorkflowItem($index)
 {
     try {
         $bookedTripElementWorkflow = array();
         $item = $this->itemsOnePerGroup[$index];
         if ($this->isDoubleRequest($item)) {
             throw new CHttpException(400, 'Double request');
         }
         $tripElementWorkflow = $item->createTripElementWorkflow();
         $tripElementWorkflow->bookItem();
         $this->markItemGroupAsBooked($tripElementWorkflow->getItem());
         $tripElementWorkflow->runWorkflowAndSetFinalStatus();
         $this->saveWorkflowState($tripElementWorkflow->finalStatus);
         $tripElementWorkflow->updateBookingId();
         Yii::app()->shoppingCart->update($item, 1);
         $bookedTripElementWorkflow[] = $tripElementWorkflow;
         if ($this->areAllStatusesCorrect()) {
             Yii::app()->user->setState('blockedToBook', null);
             return $bookedTripElementWorkflow;
         } else {
             throw new CHttpException(500, 'At least one of workflow status at step 1 is incorrect:' . CVarDumper::dumpAsString($this->finalWorkflowStatuses));
         }
     } catch (Exception $e) {
         throw new CHttpException(500, 'We can not book ' . $index . '-th item: ' . $e->getMessage());
     }
 }
예제 #12
0
function e($msg, $exit = true, $depth = 10)
{
    CVarDumper::dump($msg, $depth, true);
    if ($exit) {
        exit;
    }
}
 public function actionReadTopic($id)
 {
     $thread = Thread::model()->getThreadInfoById($id);
     $this->areaLarge = $thread['program_name'];
     $this->areaSmall = $thread['semester_name'];
     $reply = new Reply();
     $complaint = new Complaint('postComplaint');
     if (isset($_POST['Reply'])) {
         $reply->attributes = $_POST['Reply'];
         $reply->post_item_id = $id;
         if ($reply->save()) {
             Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
             $reply->unsetAttributes();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
         }
     }
     if (isset($_POST['Complaint'])) {
         $complaint->attributes = $_POST['Complaint'];
         if ($complaint->save()) {
             if ($complaint->post_item_id == $id) {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             } else {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             }
             $complaint->unsetAttributes();
         } else {
             Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
         }
     }
     $dataProvider = Thread::model()->getPostsDataInThread($id);
     Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
     $this->render('application.modules.community.views.front.post.view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = new WorkshopForm('view', $id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['WorkshopForm'])) {
         $model->attributes = $_POST['WorkshopForm'];
         $model->postItem->attributes = $_POST['PostItem'];
         $model->workshop->attributes = $_POST['Workshop'];
         $model->workshopFile = CUploadedFile::getInstance($model, 'workshopFile');
         Yii::log(CVarDumper::dumpAsString($model->workshopFile));
         if ($model->validate()) {
             $fileUpload = $model->workshopFile;
             if ($fileUpload !== null) {
                 $model->workshop->removeFile();
                 $model->workshop->workshop_file = $fileUpload;
                 $fileName = $fileUpload->name;
             }
             if ($model->save()) {
                 if ($model->workshop->workshop_file !== null) {
                     $userFilePath = FileHelper::getFilePath(Yii::getPathOfAlias('site.files') . '/workshops/' . $model->postItem->primaryKey . '/');
                     $model->workshopFile->saveAs($userFilePath . $fileName);
                 }
                 $this->redirect(array('view', 'id' => $model->workshop->post_item_id));
             }
         }
     }
     $this->render('update', array('model' => $model));
 }
예제 #15
0
 public function run()
 {
     $nav = $content = '';
     $first = true;
     $type = rtrim($this->type, 's');
     foreach ($this->items as $id => $item) {
         if (is_array($item['content'])) {
             $id = "{$this->id}-{$id}";
             $opts = $first ? array('class' => 'active') : array();
             $opts['class'] = isset($opts['class']) ? $opts['class'] . ' dropdown' : 'dropdown';
             $dropdown = array();
             foreach ($item['content'] as $subId => $subTab) {
                 Yii::trace(CVarDumper::dumpAsString($subTab));
                 $subOpts = array();
                 $subOpts['id'] = "{$id}-{$subId}";
                 $subOpts['class'] = 'tab-pane';
                 $content .= CHtml::tag('div', $subOpts, $subTab['content']);
                 $dropdown[$subTab['title']] = '#' . $subOpts['id'];
             }
             Yii::trace(CVarDumper::dumpAsString($dropdown));
             $nav .= CHtml::tag('li', $opts, BHtml::dropdownToggle($item['title']) . BHtml::dropdownMenu($dropdown, array('linkOptions' => array('data-toggle' => 'tab'))));
         } else {
             $id = "{$this->id}-{$id}";
             $opts = $first ? array('class' => 'active') : array();
             $nav .= CHtml::tag('li', $opts, CHtml::link($item['title'], "#{$id}", array('data-toggle' => $type)));
             $opts['id'] = $id;
             $opts['class'] = isset($opts['class']) ? $opts['class'] . ' tab-pane' : 'tab-pane';
             $content .= CHtml::tag('div', $opts, $item['content']);
         }
         $first = false;
     }
     echo CHtml::tag('div', $this->htmlOptions, CHtml::tag('ul', $this->navOptions, $nav) . CHtml::tag('div', array('class' => 'tab-content'), $content));
     BHtml::registerBootstrapJs();
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     /* @param Slide $model*/
     $model = $this->loadModel($id);
     $maxPositions = Slide::model()->count();
     Yii::log("PrevImage: " . $model->slide_image, 'log');
     if (isset($_POST['Slide'])) {
         $model->oldPosition = $model->position;
         $model->attributes = $_POST['Slide'];
         Yii::log("CurrImage: " . $model->slide_image, 'log');
         $fileUpload = CUploadedFile::getInstance($model, 'slide_image');
         Yii::log("FileUpload: " . CVarDumper::dumpAsString($fileUpload), 'log');
         if ($fileUpload !== null) {
             $model->removeImage();
             $model->slide_image = $fileUpload;
         }
         if ($model->validate() && $model->save()) {
             if ($fileUpload !== null) {
                 $model->slide_image->saveAs(Yii::app()->basePath . '/../files/images/slides/' . $model->slide_image . "_" . $model->getPrimaryKey());
             }
             $this->redirect(array('view', 'id' => $model->slide_id));
         }
     }
     $viewablePositions = array();
     foreach (range(0, $maxPositions - 1) as $position) {
         $viewablePositions[$position] = Formatter::formatOrdinal($position + 1);
     }
     $this->positions = $viewablePositions;
     $this->render('update', array('model' => $model));
 }
예제 #17
0
 public function filterLogRequest($filterChain)
 {
     if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
         Yii::log(CVarDumper::dumpAsString($GLOBALS["HTTP_RAW_POST_DATA"]), 'trace', 'WX_RAW_REQUEST_DATA');
     }
     Yii::log(CVarDumper::dumpAsString($_REQUEST), 'trace', 'WX_RAW_REQUEST');
     $filterChain->run();
 }
예제 #18
0
 public function renderCoreScripts()
 {
     $folder = 'frontend.tmp';
     $path = Yii::getPathOfAlias($folder);
     $filePath = $path . '/core.txt';
     file_put_contents($filePath, CVarDumper::dumpAsString($this->coreScripts));
     parent::renderCoreScripts();
 }
예제 #19
0
function dump($var, $depth = 10, $highlight = true)
{
    if (class_exists('CVarDumper')) {
        CVarDumper::dump($var, $depth, $highlight);
    } else {
        var_dump($var);
    }
}
예제 #20
0
 public function getPageResults()
 {
     Console::writeLine('fetching');
     $this->fetch();
     file_put_contents(Yii::app()->basePath . '/reports/pagehtml.html', $this->pageHtml);
     CVarDumper::dump($this->response, 10, false);
     die('Debug Point');
 }
예제 #21
0
 /**
  * Dumps a variable or the object itself in terms of a string.
  *
  * @param mixed variable to be dumped
  */
 protected function dump($var = 'dump-the-object', $highlight = true)
 {
     if ($var === 'dump-the-object') {
         return CVarDumper::dumpAsString($this, $depth = 15, $highlight);
     } else {
         return CVarDumper::dumpAsString($var, $depth = 15, $highlight);
     }
 }
예제 #22
0
 /**
  * Generates the required HTML and Javascript
  */
 public function run()
 {
     //echo 'Chức năng upload file tạm thời Off để bảo trì, liên hệ trangptk@vega.com.vn';
     list($name, $id) = $this->resolveNameID();
     $model = $this->model;
     if (!isset($this->options['uploadTable'])) {
         $uploadTable = "files";
         $this->options['uploadTable'] = "#files";
     } else {
         $uploadTable = $this->options['uploadTable'];
         $this->options['uploadTable'] = "#{$uploadTable}";
     }
     if (!isset($this->options['downloadTable'])) {
         $downloadTable = "files";
         $this->options['downloadTable'] = "#files";
     } else {
         $downloadTable = $this->options['downloadTable'];
         $this->options['downloadTable'] = "#{$downloadTable}";
     }
     if (!isset($this->options['buildUploadRow'])) {
         $this->options['buildUploadRow'] = $this->_getBuildUploadRow();
     }
     if (!isset($this->options['buildDownloadRow'])) {
         $this->options['buildDownloadRow'] = $this->_getBuildDownloadRow();
     }
     if (!isset($this->htmlOptions['enctype'])) {
         $this->htmlOptions['enctype'] = 'multipart/form-data';
     }
     if (!isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = 'xupload-form file_upload';
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = get_class($model) . "_form";
     }
     $options = CJavaScript::encode($this->options);
     CVarDumper::dumpAsString($options, 10, true);
     Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->htmlOptions['id'], "jQuery('#{$this->htmlOptions['id']}').fileUploadUI({$options});", CClientScript::POS_READY);
     //echo "<pre>";print_r($options);exit();
     echo CHtml::beginForm($this->url, 'post', $this->htmlOptions);
     $htmlOptions = array();
     if ($this->multiple) {
         $htmlOptions["multiple"] = true;
     }
     if ($this->hasModel()) {
         echo CHtml::activeFileField($this->model, $this->attribute, $htmlOptions);
     } else {
         echo CHtml::fileField($name, $this->value, $htmlOptions);
     }
     echo CHtml::tag("button", array(), "Upload", true);
     echo CHtml::tag("div", array(), $this->text, true);
     echo CHtml::endForm();
     if ($uploadTable == $downloadTable) {
         echo CHtml::tag("table", array("id" => $uploadTable), "", true);
     } else {
         echo CHtml::tag("table", array("id" => $uploadTable), "", true);
         echo CHtml::tag("table", array("id" => $downloadTable), "", true);
     }
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/studentIndex.php'
     // using the default layout 'protected/views/layouts/main.php'
     $articleData = Article::model()->getBriefArticlesData(self::homePageArticleLimit);
     $slideItems = Slide::getSliderItems();
     Yii::log(CVarDumper::dumpAsString($slideItems));
     $this->render('index', array('articleData' => $articleData, 'slideItems' => $slideItems));
 }
예제 #24
0
 public function beforeSave()
 {
     parent::beforeSave();
     $dumper = new FlightCacheDumper();
     $dumper->model = $this;
     $dumper->save();
     Yii::log("FLIGHT CACHE DUMPER = \n" . CVarDumper::dumpAsString($dumper->model->attributes));
     return false;
 }
예제 #25
0
 private function saveItemsOfOrder()
 {
     foreach ($this->itemsOnePerGroup as $item) {
         if (!$item->saveToOrderDb()) {
             $errMsg = "Could not save order's item" . PHP_EOL . CVarDumper::dumpAsString($item);
             $this->logAndThrowException($errMsg, 'TripStorage.saveItemsOfOrder');
         }
         $item->saveReference($this->order);
     }
 }
예제 #26
0
/**
 * If debug = 2 in application/config.php this will produce output in the console / firebug
 * similar to var_dump. It will also include the filename and line that called this method.
 *
 * @param mixed $variable The variable to be dumped
 * @param int $depth Maximum depth to go into the variable, default is 10
 */
function traceVar($variable, $depth = 10)
{
    $msg = CVarDumper::dumpAsString($variable, $depth, false);
    $fullTrace = debug_backtrace();
    $trace = array_shift($fullTrace);
    if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII_PATH) !== 0) {
        $msg = $trace['file'] . ' (' . $trace['line'] . "):\n" . $msg;
    }
    Yii::trace($msg, 'vardump');
}
예제 #27
0
 private function doRequest($postData)
 {
     $curl = curl_init();
     $curlOptions = array(CURLOPT_URL => 'http://atompark.com/members/sms/xml.php', CURLOPT_FOLLOWLOCATION => false, CURLOPT_POST => true, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 100, CURLOPT_POSTFIELDS => array('XML' => $postData));
     curl_setopt_array($curl, $curlOptions);
     if (false === ($response = curl_exec($curl))) {
         throw new Exception('Http request failed with code ' . CVarDumper::dumpAsString($response));
     }
     curl_close($curl);
     return $response;
 }
 /**
  * Dumps a variable in terms of a string.
  * This method achieves the similar functionality as var_dump and print_r
  * but is more robust when handling complex objects such as Yii controllers.
  * @param mixed $var variable to be dumped
  * @param integer $depth maximum depth that the dumper should go into the variable. Defaults to 10.
  * @param boolean $highlight whether the result should be syntax-highlighted
  * @return string the string representation of the variable
  */
 public static function dumpAsString($var, $depth = 10, $highlight = false)
 {
     self::$_output = '';
     self::$_objects = array();
     self::$_depth = $depth;
     self::dumpInternal($var, 0);
     if ($highlight) {
         $result = highlight_string("<?php\n" . self::$_output, true);
         self::$_output = preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
     }
     return self::$_output;
 }
 private function doRequest($url, $args)
 {
     $argsJson = CJSON::encode($args);
     $curl = curl_init();
     $curlOptions = array(CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => false, CURLOPT_POST => true, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 100, CURLOPT_POSTFIELDS => $argsJson);
     curl_setopt_array($curl, $curlOptions);
     if (false === ($response = curl_exec($curl))) {
         throw new Exception('Http request failed with code ' . CVarDumper::dumpAsString($response));
     }
     curl_close($curl);
     return CJSON::decode($response);
 }
예제 #30
0
 private function getDumpForDb($db)
 {
     echo date('H:i:s Y-m-d') . ' Start backup ' . $db . PHP_EOL;
     $file = $this->file . '_' . $db . '.sql';
     $command = 'mysqldump -uoleg -pq1w2e3r4 ' . $db . ' > ' . $file;
     $results = array();
     exec($command, $results);
     if (!empty($results)) {
         CVarDumper::dump($results);
     }
     echo date('H:i:s Y-m-d') . ' End backup ' . $db . PHP_EOL;
 }