Example #1
0
 /**
  * Overwrite the abstract method defined in Control, see parent comment
  * 
  * @return string
  */
 public function getLabel() : string
 {
     if (key_exists($this->getValue(), $this->getChoices())) {
         return (string) $this->getChoices()[$this->getValue()];
     }
     return $this->getValue();
 }
Example #2
0
 /**
  * Возвращает массив в виде дерева (многомерной иерархии)
  * Позаимствовано с http://stackoverflow.com/questions/841014/nested-sets-php-array-and-transformation
  *
  * @param array  $array Плоский массив
  * @param string $depth Ключ массива в котором лежит номер уровня
  * @param string $children Ключ массива в котором будут лежать дети
  * @return array
  */
 public function filter($array = array(), $depth = 'clevel', $children = 'children')
 {
     // Trees mapped
     $trees = array();
     $l = 0;
     if (count($array) > 0) {
         // Node Stack. Used to help building the hierarchy
         $stack = array();
         foreach ($array as $node) {
             $item = $node;
             //$item[$children] = array();
             // Number of stack items
             $l = count($stack);
             // Check if we're dealing with different levels
             while ($l > 0 && $stack[$l - 1][$depth] >= $item[$depth]) {
                 array_pop($stack);
                 $l--;
             }
             // Stack is empty (we are inspecting the root)
             if ($l == 0) {
                 // Assigning the root node
                 $i = count($trees);
                 $trees[$i] = $item;
                 $stack[] =& $trees[$i];
             } else {
                 // Add node to parent
                 $i = key_exists($children, $stack[$l - 1]) ? count($stack[$l - 1][$children]) : 0;
                 $stack[$l - 1][$children][$i] = $item;
                 $stack[] =& $stack[$l - 1][$children][$i];
             }
         }
     }
     return $trees;
 }
Example #3
0
 protected function _setEventStatus($status)
 {
     $this->requireAuthentication();
     $app = App::i();
     if (!key_exists('id', $this->urlData)) {
         $app->pass();
     }
     $entity = $this->getRequestedEntity();
     if (!$entity) {
         $app->pass();
     }
     $entity->checkPermission('@control');
     if (isset($this->data['ids']) && $this->data['ids']) {
         $ids = is_array($this->data['ids']) ? $this->data['ids'] : explode(',', $this->data['ids']);
         $events = $app->repo('Event')->findBy(['id' => $ids]);
     }
     foreach ($events as $event) {
         if (\MapasCulturais\Entities\Event::STATUS_ENABLED === $status) {
             $event->publish();
         } elseif (\MapasCulturais\Entities\Event::STATUS_DRAFT === $status) {
             $event->unpublish();
         }
     }
     $app->em->flush();
     $this->json(true);
 }
 public function index(){
     $days = 7;
     $this -> assign('days', $days);
     $where = array('token' => $this -> token);
     $where['time'] = array('gt', time() - $days * 24 * 3600);
     $where['module'] = array('neq', '');
     $db = M('Share');
     $items = $db -> where($where) -> select();
     $datas = array();
     if ($items){
         foreach ($items as $item){
             if (trim($item['module'])){
                 if (!key_exists($item['module'], $datas)){
                     $datas[$item['module']] = array('module' => $item['module'], 'count' => 1, 'moduleName' => funcDict :: moduleName($item['module']));
                 }else{
                     $datas[$item['module']]['count']++;
                 }
             }
         }
     }
     $xml = '<chart borderThickness="0" caption="' . $days . '日内分享统计" baseFontColor="666666" baseFont="宋体" baseFontSize="14" bgColor="FFFFFF" bgAlpha="0" showBorder="0" bgAngle="360" pieYScale="90"  pieSliceDepth="5" smartLineColor="666666">';
     if ($datas){
         foreach ($datas as $item){
             $xml .= '<set label="' . $item['moduleName'] . '" value="' . $item['count'] . '"/>';
         }
     }
     $xml .= '</chart>';
     $this -> assign('items', $items);
     $this -> assign('xml', $xml);
     $this -> assign('list', $datas);
     $this -> assign('listinfo', 1);
     $this -> assign('tab', 'stastic');
     $this -> display();
 }
 /**
  * 指定店铺的 商品分类 树
  * @param number $sid		店铺ID
  * @param string $status	状态
  */
 public function tree($sid, $status = null)
 {
     $status_view = array('default' => '所有', 'del' => '已删除', 'forbid' => '禁用', 'allow' => '正常');
     //默认是 所有 未删除
     //店铺id必须有
     $map['store_id'] = (int) $sid;
     if ($map['store_id'] <= 0) {
         $this->error('参数非法');
     }
     $store_M = new Model('Store');
     $store_info = $store_M->find($map['store_id']);
     if (empty($store_info)) {
         $this->error('店铺不存在');
     }
     $this->assign('store_info', $store_info);
     $now_status = $status_view['default'];
     if (isset($status) && key_exists($status, CategoryModel::$mystat)) {
         //指定查询状态
         $map['status'] = CategoryModel::$mystat[$status];
         $now_status = $status_view[$status];
     } else {
         $map['status'] = array('EGT', 0);
         //默认查询状态为未删除的数据
     }
     $model = new CategoryModel();
     $cate_tree = $model->ztreeArr($map);
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //ztree json
     $this->assign('now_status', $now_status);
     //当前页面筛选的状态
     // 记录当前列表页的cookie
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
Example #6
0
function startthelog($logname, $quick = FALSE)
{
    logit($logname, '-----------------------------------------------------------');
    $line = '';
    //logit($logname, $_SERVER['HTTP_REFERER']);
    if (!$quick) {
        // doing the dns lookup takes some extra time so use $quick to speed things up a bid
        $line = gethostbyaddr($_SERVER["REMOTE_HOST"]);
        if ($line == $_SERVER["REMOTE_ADDR"]) {
            $line = '** No DNS entry found for calling IP';
        }
        $line = ' - ' . $line;
    }
    logit($logname, $_SERVER["REMOTE_ADDR"] . $line);
    if (key_exists('HTTP_USER_AGENT', $_SERVER)) {
        logit($logname, $_SERVER['HTTP_USER_AGENT'] . $line);
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (substr(str_replace(chr(10), '', print_r($_POST, true)), 10) == '') {
            logit($logname, 'Called as a POST, but NO values were passed in');
        } else {
            logit($logname, 'POST values: ' . substr(str_replace(chr(10), '', print_r($_POST, true)), 10));
        }
    }
    if ($_SERVER["QUERY_STRING"] != '') {
        logit($logname, 'GET param string: ' . $_SERVER["QUERY_STRING"]);
    }
}
Example #7
0
 /**
  * Return all navigation collection
  * 
  * @param type $name
  * @return array
  */
 public function getNavigation($name)
 {
     if (!key_exists($name, $this->_navigations)) {
         return null;
     }
     return $this->_navigations[$name];
 }
 public function AddPreLoadedImage($strLoc)
 {
     if (!key_exists(MJaxTouchConfig::preloadImages, $this->arrConfig)) {
         $this->arrConfig[MJaxTouchConfig::preloadImages] = array();
     }
     $this->arrConfig[MJaxTouchConfig::preloadImages][] = $strLoc;
 }
Example #9
0
 public function save()
 {
     $name = basename($this->project->compiledFile, '.chm');
     $dir = dirname($this->project->compiledFile);
     if (!is_dir($dir)) {
         throw new CException(Yii::t('yiiext', 'Directory "{directory} not available.".', array('{directory}' => $dir)));
     }
     if ($this->project->contentsFile === NULL) {
         $this->project->contentsFile = $dir . '/' . $name . '.hhc';
     }
     if ($this->project->indexFile === NULL) {
         $this->project->indexFile = $dir . '/' . $name . '.hhk';
     }
     if ($this->project->path === NULL) {
         $this->project->path = $dir . '/' . $name . '.hhp';
     }
     $windows = $this->project->getWindows();
     if ($this->project->defaultWindow === NULL || !key_exists($this->project->defaultWindow, $windows)) {
         reset($windows);
         $this->project->defaultWindow = current($windows)->id;
     }
     $this->toc->save($this->project->contentsFile);
     $this->index->save($this->project->indexFile);
     $this->project->save($this->project->path);
     // generate project
     $exeFile = dirname(__FILE__) . '/vendors/hhc.exe';
     exec('"' . $exeFile . '" "' . $this->project->path . '"', $output, $return_var);
     if (!file_exists($this->project->compiledFile)) {
         throw new CException(Yii::t('yiiext', 'Cannot save .chm file "{file}".' . "\nReturn: {$return_var}\nOutput:\n" . implode("\n", $output), array('{file}' => $this->project->compiledFile)));
     }
     return $this->project->compiledFile;
 }
 /**
  * Sets the value of the location property.
  *
  * You can set the value of this property using a GeoPoint object or using an array,
  *
  * <code>
  * // example with GeoPoint
  * $entity->location = new GeoPoint(-45.123, -23.345);
  *
  * // example with arrays
  * $entity->location = [-45.123, -23.345];
  * $entity->location = ['x' => -45.123, 'y' => -23.345];
  * $entity->location = ['longitude' => -45.123, 'latitude' => -23.345];
  *
  * </code>
  *
  * This method sets the value of the property _geoLocation with a PostGIS ST_Geography type.
  *
  * @param \MapasCulturais\Types\GeoPoint|array $location
  */
 function setLocation($location)
 {
     $x = $y = null;
     if (!$location instanceof GeoPoint) {
         if (is_array($location) && key_exists('x', $location) && key_exists('y', $location)) {
             $x = $location['x'];
             $y = $location['y'];
         } elseif (is_array($location) && key_exists('longitude', $location) && key_exists('latitude', $location)) {
             $x = $location['longitude'];
             $y = $location['latitude'];
         } elseif (is_array($location) && count($location) === 2 && is_numeric($location[0]) && is_numeric($location[1])) {
             $x = $location[0];
             $y = $location[1];
         } else {
             throw new \Exception(App::txt('The location must be an instance of \\MapasCulturais\\Types\\GeoPoint or an array with two numeric values'));
         }
         $location = new GeoPoint($x, $y);
     }
     if (is_numeric($x) && is_numeric($y)) {
         $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
         $sql = "SELECT ST_GeographyFromText('POINT({$location->longitude} {$location->latitude})') AS geo";
         $rsm->addScalarResult('geo', 'geo');
         $query = App::i()->em->createNativeQuery($sql, $rsm);
         $this->_geoLocation = $query->getSingleScalarResult();
     }
     $this->location = $location;
 }
Example #11
0
 public static function render($params = [])
 {
     $html = '';
     /** Rendering breadcrumb show */
     if (!empty($params)) {
         foreach ($params as $j => $i) {
             /** Prepping data */
             $r = explode(':', $i);
             /** Rendering breadcrumb list */
             if (!empty(self::$array)) {
                 foreach (self::$array as $k => $v) {
                     if ($k == $r[0]) {
                         if ($j == count($params) - 1) {
                             $html .= '<li><a class="acitve-pages" >' . $v['title'] . '</a></li>';
                         } else {
                             if (key_exists(1, $r)) {
                                 $html .= '<li><a href="' . $v['url'] . '/' . $r[1] . '" >' . $v['title'] . '</a></li>';
                             } else {
                                 $html .= '<li><a href="' . $v['url'] . '" >' . $v['title'] . '</a></li>';
                             }
                         }
                     }
                 }
             }
         }
     }
     $html .= '';
     return $html;
 }
Example #12
0
 /**
  * Sets options for dbd.h
  * @param string $define name of contstant to modify
  * @param mixed $value value to set constant to
  * @return boolean
  */
 public function setDefine($define, $value)
 {
     if (key_exists($define, $this->dbdDefines)) {
         /**@TODO: add sanitiy checking for define values */
         switch ($define) {
             /**
              * String values need to be quoted
              */
             case 'HOST':
             case 'BINDHOST':
             case 'EXECPROC_NULL':
             case 'SHARED_SECRET':
             case 'HIGHLIGHT_PREFIX':
             case 'HIGHLIGHT_SUFFIX':
             case 'SEPARATOR_BETWEEN_PREFIX_AND_DATA':
             case 'INSTANCE_SEMAPHORE':
                 $value = "'" . $value . "'";
                 break;
             default:
                 break;
         }
         $this->dbdDefines["{$define}"] = $value;
         return true;
     }
     return false;
 }
 public function run()
 {
     $message = '';
     $projectlist = new ProjectListModel();
     $projectlist->read();
     $projectIds = array_map(function ($e) {
         return $e['id'];
     }, $projectlist->entries);
     $emptyQuestionTitles = 0;
     foreach ($projectIds as $projectId) {
         $project = new ProjectModel($projectId);
         $activityEntries = ActivityListDto::getActivityForProject($project);
         foreach ($activityEntries as $activity) {
             if (key_exists('questionRef', $activity) && key_exists('question', $activity['content'])) {
                 $questionId = $activity['questionRef'];
                 $questionTitle = $activity['content']['question'];
                 if ($questionTitle == '') {
                     $emptyQuestionTitles++;
                     $questionModel = new QuestionModel($project, $questionId);
                     $activityModel = new ActivityModel($project, $activity['id']);
                     $newTitle = $questionModel->getTitleForDisplay();
                     $activityModel->actionContent['question'] = $newTitle;
                     $message .= "Fixing activity " . $activity['action'] . " with title '" . $newTitle . "'\n";
                     $activityModel->write();
                 }
             }
         }
     }
     if ($emptyQuestionTitles > 0) {
         $message .= "\n\nFixed up {$emptyQuestionTitles} empty question titles in the activity log\n\n";
     } else {
         $message .= "\n\nNo empty question titles were found in the activity log \n\n";
     }
     return $message;
 }
Example #14
0
 function stream_read($count)
 {
     if (key_exists($this->s++, $this->lines)) {
         return $this->lines[$this->s - 1];
     }
     return "";
 }
 protected function weekbyhours()
 {
     $this->matrix = array();
     foreach ($this->events as $event) {
         $recur = new Recurrences($event);
         foreach ($recur->recurrences as $recurrence) {
             /* @var $recurrence When */
             if ($recurrence->getFequency() == 'WEEKLY') {
                 foreach ($recurrence->getByDay() as $day) {
                     if ($day[0] == '+') {
                         $weekday = substr($day, 2);
                         $start = new \DateTime($event->getStart()->dateTime);
                         $time = $start->format('H:i');
                         if (!key_exists($time, $this->matrix)) {
                             $this->matrix[$time] = array();
                         }
                         $this->matrix[$time][$weekday][] = $event;
                     }
                 }
             }
         }
     }
     ksort($this->matrix);
     return $this->matrix;
 }
Example #16
0
 public function action_rid()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in to see this.', array('problem' => 'auth'));
     }
     $user = user::get();
     $langs = array(1 => 'english', 17 => 'french', 19 => 'german', 22 => 'hungarian', 34 => 'portugese');
     $userlang = $user->option('language');
     if (!key_exists($userlang, $langs)) {
         ajax::error('We currently only have RID data available for English, French, German, Hungarian and Portugese.', array('problem' => 'data'));
     }
     $page = ORM::factory('Page', arr::get($_POST, 'id', ''));
     if (!$page->loaded() || !$page->user_id == $user->id) {
         ajax::error('That page wasn\'t found!');
     }
     if ($page->rid == '') {
         require Kohana::find_file('vendor/rid', 'rid');
         $rid = new RID();
         $rid->load_dictionary(Kohana::find_file('vendor/rid', $langs[$userlang], 'cat'));
         $data = $rid->analyze($page->content());
         $vals = array();
         $colors = array('#B0BF1A', '#7CB9E8', '#C9FFE5', '#B284BE', '#5D8AA8', '#00308F', '#00308F', '#AF002A', '#F0F8FF', '#E32636', '#C46210', '#EFDECD', '#E52B50', '#AB274F', '#F19CBB', '#3B7A57', '#FFBF00', '#FF7E00', '#FF033E', '#9966CC', '#A4C639', '#CD9575', '#665D1E', '#915C83', '#841B2D', '#FAEBD7', '#008000', '#8DB600', '#FBCEB1', '#00FFFF', '#7FFFD4', '#4B5320', '#3B444B', '#8F9779', '#E9D66B', '#B2BEB5', '#87A96B', '#FF9966', '#A52A2A', '#FDEE00', '#6E7F80', '#568203', '#007FFF');
         $i = 0;
         foreach ($data->category_percentage as $key => $val) {
             $vals[] = array('value' => $val, 'label' => $key, 'color' => $colors[$i]);
             $i++;
         }
         $page->rid = serialize($vals);
         $page->save();
     }
     ajax::success('ok', array('data' => unserialize($page->rid)));
 }
Example #17
0
 public function handle()
 {
     $token = Seat::get('slack_token');
     if ($token == null) {
         throw new SlackSettingException("missing slack_token in settings");
     }
     // get members list from slack team
     $api = new SlackApi($token);
     $members = $api->members();
     // iterate over each member, check if the user mail match with a seat account and update the relation table
     foreach ($members as $m) {
         if ($m['id'] != 'USLACKBOT' && $m['deleted'] == false && $m['is_bot'] == false && !key_exists('api_app_id', $m['profile'])) {
             $user = User::where('email', '=', $m['profile']['email'])->first();
             if ($user != null) {
                 $slackUser = SlackUser::find($user->id);
                 if ($slackUser == null) {
                     $slackUser = new SlackUser();
                     $slackUser->user_id = $user->id;
                     $slackUser->invited = true;
                 }
                 $slackUser->slack_id = $m['id'];
                 $slackUser->save();
             }
         }
     }
 }
Example #18
0
 /**
  * 
  * @param string $name
  * @throws Exception
  * @return Channel
  */
 public function getChannel($name)
 {
     if (!key_exists($name, $this->channels)) {
         throw new Exception(sprintf('No channel with name "%s" exists', $name));
     }
     return $this->channels[$name];
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /* @var $em \Doctrine\ORM\EntityManager */
     $em = $this->getContainer()->get('doctrine')->getManager();
     /* @var $repo \AppBundle\Entity\ReviewRepository */
     $repo = $em->getRepository('AppBundle:Card');
     $setid = $input->getArgument('setid');
     $xmlstr = file_get_contents("https://raw.githubusercontent.com/TassLehoff/AGoTv2-OCTGN/master/GameDatabase/30c200c9-6c98-49a4-a293-106c06295c05/sets/{$setid}/set.xml");
     $set = new \SimpleXMLElement($xmlstr);
     $cards = $set->cards[0];
     $guids = [];
     foreach ($cards->children() as $card) {
         $attributes = $card->attributes();
         $name = (string) $attributes->name;
         $guid = (string) $attributes->id;
         $name = str_replace('’', '\'', $name);
         $guids[$name] = $guid;
     }
     $cards = $repo->findBy(['octgnId' => null], ['code' => 'ASC']);
     foreach ($cards as $card) {
         $name = $card->getName();
         if (key_exists($name, $guids)) {
             $card->setOctgnId($guids[$name]);
             unset($guids[$name]);
             $output->writeln("<info>Updating octgn id for {$name}</info>");
         } else {
             $output->writeln("<error>Cannot find {$name}</error>");
         }
     }
     $em->flush();
 }
Example #20
0
 function setParent($parent)
 {
     //Added this case to remove parent from the entity
     if ($parent === null) {
         $this->parent = null;
         return;
     } elseif (!is_object($parent)) {
         return;
     }
     $parent->checkPermission('createChild');
     $error1 = App::txt('O pai não pode ser o filho.');
     $error2 = App::txt('O pai deve ser do mesmo tipo que o filho.');
     if (!key_exists('parent', $this->_validationErrors)) {
         $this->_validationErrors['parent'] = array();
     }
     if ($parent && $parent->id === $this->id) {
         $this->_validationErrors['parent'][] = $error1;
     } elseif (key_exists('parent', $this->_validationErrors) && in_array($error1, $this->_validationErrors['parent'])) {
         $key = array_search($error, $this->_validationErrors['parent']);
         unset($this->_validationErrors['parent'][$key]);
     }
     if ($parent && $parent->className !== $this->className) {
         $this->_validationErrors['parent'][] = $error2;
     } elseif (key_exists('parent', $this->_validationErrors) && in_array($error2, $this->_validationErrors['parent'])) {
         $key = array_search($error, $this->_validationErrors['parent']);
         unset($this->_validationErrors['parent'][$key]);
     }
     if (!$this->_validationErrors['parent']) {
         unset($this->_validationErrors['parent']);
     }
     $this->parent = $parent;
 }
Example #21
0
 protected function processRules()
 {
     $rules = array();
     $method = strtolower(Yii::app()->getRequest()->getRequestType());
     //transform method's rules keys to lowercase
     $this->rules = array_combine(array_map(array($this, '__atToLowerCase'), array_keys($this->rules)), array_values($this->rules));
     //check if it has an index the same as the request type and if it does add its rules
     if (key_exists("@{$method}", $this->rules)) {
         $rules = $this->rules["@{$method}"];
     }
     //add the default rules
     if (is_array($rules)) {
         foreach ($this->rules as $k => $rule) {
             if (substr($k, 0, 1) !== '@') {
                 $rules[$k] = $rule;
             }
         }
     } elseif (is_string($rules)) {
         $rules = array("." => $rules);
     }
     //override the existing rules with only those that matche with the request type
     $this->rules = $rules;
     //disable cache that causes it to load wrong rules
     //cant use it as its defined as a constant and not able to change to use method's specific cache
     $this->cacheID = false;
     parent::processRules();
 }
Example #22
0
 public function init()
 {
     $config = $this->getEngine()->getConfig();
     $job = $this->getEngine()->getJob();
     $segment = $this->getSegment();
     $values = $segment->getValues();
     foreach ($values as $key => $entry) {
         foreach ($entry as $lineValue) {
             $value = $lineValue['value'];
             $lineNum = $lineValue['line'];
             if (!key_exists($key, $this->regexValidators)) {
                 $job->addLogEntry("Variable in hostgroup object file not supported: " . $key . " on line " . $lineNum);
                 if (!$config->getVar('continue_error')) {
                     return false;
                 }
             } else {
                 // Key exists, let's check the regexp
                 if ($this->regexValidators[$key] != '' && !preg_match($this->regexValidators[$key], $value)) {
                     // Failed the regular expression match (which was provided)!!!
                     $job->addLogEntry("Variable '" . $key . "' failed the regular expression sanity check of: " . $this->regexValidators[$key] . " on line " . $linenum);
                     if (!$config->getVar('continue_error')) {
                         return false;
                     }
                 }
             }
         }
     }
     $job->addNotice("NagiosHostGroupImporter finished initializing.");
     return true;
 }
Example #23
0
 public function get($key)
 {
     if (key_exists($key, $this->config)) {
         return $this->config[$key];
     }
     die('Index is out of range');
 }
Example #24
0
 /**
  * Хук. Вызывается после завершения openId-регистрации
  * для каких-либо доп. действий. Переопределяется в наследниках
  */
 public function onRegister()
 {
     $openidData = $this->_broker->getUserData();
     if (key_exists('profile', $openidData) && key_exists('photo', $openidData['profile'])) {
         $this->_copyAvatar($openidData['profile']['photo']);
     }
 }
 public function _unit_test_create_user()
 {
     $Members_Info["username"] = "******";
     $Members_Info["email"] = "*****@*****.**";
     $Members_Info["password"] = "******";
     $Members_Info["phone"] = "(+60)0177002928";
     $Members_Info["email_activation"] = $email_activation = $this->config->item('email_activation', 'tank_auth');
     $val_return = $this->SendReceive_Service("CB_Member:create_member", json_encode($Members_Info));
     //Expected output
     $return_data = json_decode($val_return, TRUE);
     $data["user_id"] = "";
     if (!is_null($return_data["data"]["result"]) && key_exists("user_id", $return_data["data"]["result"])) {
         $data["user_id"] = $return_data["data"]["result"]["user_id"];
         if (!is_null($data["user_id"])) {
             $data["email"] = "*****@*****.**";
             $data["phone"] = "(+60)0177002928";
             $data["username"] = "";
         } else {
             $data["error"] = $return_data["data"]["result"]["error"];
         }
     }
     $golden_data["result"] = $data;
     $golden["service"] = "CB_Member:create_member";
     $golden["status"] = "Complete";
     $golden["status_information"] = "Info: Complete CB_Member:create member";
     $golden["data"] = $golden_data;
     $val_golden = json_encode($golden);
     $note = "Return value -- " . $val_return . "<br>";
     $note = $note . "Golden value -- {$val_golden}";
     $this->unit->run($val_return, $val_golden, "Test CB_Property AUTH Send Recieved gateway", $note);
 }
 public static function getTemplateByName($name)
 {
     if (!key_exists($name, NagiosHostExtInfoImporter::$templates)) {
         return false;
     }
     return NagiosHostExtInfoImporter::$templates[$name];
 }
 public function __get($namespace)
 {
     if (!key_exists($namespace, $this->_clients)) {
         $this->_clients[$namespace] = new XmlRpcClient($this->_url, strlen($this->_namespace) > 0 ? "{$this->_namespace}.{$namespace}" : $namespace);
     }
     return $this->_clients[$namespace];
 }
Example #28
0
 public function saveArray()
 {
     if ($_COOKIE['question']) {
         $cookie = json_decode($_COOKIE['question'], 1);
     }
     $cookie[$this->para['id']] = $this->para['val'];
     setcookie('question', json_encode($cookie), time() + 7200, '/');
     $this->model = D('Question_attr');
     $arr = array();
     foreach ($cookie as $k => $v) {
         $attr = $this->model->where(array('id' => $k))->getField('attr');
         if (key_exists($attr, $arr)) {
             array_push($arr[$attr], $v);
             $arr[$attr] = array_unique($arr[$attr]);
         } else {
             $arr[$attr] = array($v);
         }
     }
     if (!empty($this->oUser)) {
         if ($this->oUser['type'] == 1) {
             $this->model = D('User_owner');
             $this->model->where(array('uid' => $this->oUser['id']))->data(array('attr' => json_encode($arr)))->save();
         }
     }
     echo '1';
     exit;
 }
Example #29
0
 /**
  * Manage instance usage of this class
  */
 public static function &getInstance($type = 'base')
 {
     if (key_exists($type, self::$dbCache)) {
         $db = self::$dbCache[$type];
         vglobal('adb', $db);
         return $db;
     } else {
         if (key_exists('base', self::$dbCache)) {
             $db = self::$dbCache['base'];
             vglobal('adb', $db);
             return $db;
         }
     }
     $config = self::getDBConfig($type);
     $db = new self($config['db_type'], $config['db_server'], $config['db_name'], $config['db_username'], $config['db_password'], $config['db_port']);
     if ($db->database == NULL) {
         $db->log('Database getInstance: Error connecting to the database', 'error');
         $db->checkError('Error connecting to the database');
         return false;
     } else {
         self::$dbCache[$type] = $db;
         vglobal('adb', $db);
     }
     return $db;
 }
 protected function cachable($method_name, $params, $function)
 {
     if (!key_exists($method_name, $this->cached_results)) {
         $this->cached_results[$method_name] = call_user_func($function, $params);
     }
     return $this->cached_results[$method_name];
 }