function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $output .= $indent . '<li id="shopkeeper-menu-item-' . $item->ID . '"' . $value . $class_names . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $prepend = '';
     $append = '';
     //$description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
     if ($depth != 0) {
         $description = $append = $prepend = "";
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . $prepend . apply_filters('the_title', $item->title, $item->ID) . $append;
     //$item_output .= $description.$args->link_after;
     //$item_output .= ' '.$item->background_url.'</a>';
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
     apply_filters('walker_nav_menu_start_lvl', $item_output, $depth, $args->background_url = $item->background_url);
 }
 function _insert()
 {
     $data['content'] = $_POST['content'];
     $data['add_file'] = $_POST['add_file'];
     $data['sender_id'] = get_user_id();
     $data['sender_name'] = get_user_name();
     $data['create_time'] = time();
     $model = D('Message');
     $arr_recever = array_filter(explode(";", $_POST['to']));
     foreach ($arr_recever as $val) {
         $tmp = explode("|", $val);
         $data['receiver_id'] = $tmp[1];
         $data['receiver_name'] = $tmp[0];
         $data['user_id'] = get_user_id();
         $list = $model->add($data);
         $data['user_id'] = $tmp[1];
         $list = $model->add($data);
     }
     //保存当前数据对象
     if ($list !== false) {
         //保存成功
         $this->assign('jumpUrl', get_return_url());
         $this->success('发送成功!');
     } else {
         //失败提示
         $this->error('发送失败!');
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function getExportFields()
 {
     // avoid security field to be exported
     return array_filter(parent::getExportFields(), function ($v) {
         return !in_array($v, array('password', 'salt'));
     });
 }
Example #4
0
 /**
  * Takes a source path (ie. an image src from an html page), and an
  * associated URL (ie. the page that the image appears on), and returns the
  * absolute source (including url & protocol) path.
  * @param string $SrcPath The source path to make absolute (if not absolute already).
  * @param string $Url The full url to the page containing the src reference.
  * @return string Absolute source path.
  */
 function AbsoluteSource($SrcPath, $Url)
 {
     // If there is a scheme in the srcpath already, just return it.
     if (!is_null(parse_url($SrcPath, PHP_URL_SCHEME))) {
         return $SrcPath;
     }
     // Does SrcPath assume root?
     if (in_array(substr($SrcPath, 0, 1), array('/', '\\'))) {
         return parse_url($Url, PHP_URL_SCHEME) . '://' . parse_url($Url, PHP_URL_HOST) . $SrcPath;
     }
     // Work with the path in the url & the provided src path to backtrace if necessary
     $UrlPathParts = explode('/', str_replace('\\', '/', parse_url($Url, PHP_URL_PATH)));
     $SrcParts = explode('/', str_replace('\\', '/', $SrcPath));
     $Result = array();
     foreach ($SrcParts as $Part) {
         if (!$Part || $Part == '.') {
             continue;
         }
         if ($Part == '..') {
             array_pop($UrlPathParts);
         } else {
             $Result[] = $Part;
         }
     }
     // Put it all together & return
     return parse_url($Url, PHP_URL_SCHEME) . '://' . parse_url($Url, PHP_URL_HOST) . '/' . implode('/', array_filter(array_merge($UrlPathParts, $Result)));
 }
Example #5
0
 /**
  * Get Global Application CMS accessibility scope.
  *
  * @access public
  * @static
  * @uses   Core\Config()
  *
  * @return array
  */
 public static function getAccessibilityScope()
 {
     $scope = glob(Core\Config()->paths('mode') . 'controllers' . DIRECTORY_SEPARATOR . '*.php');
     $builtin_scope = array('CMS\\Controllers\\CMS');
     $builtin_actions = array();
     $accessibility_scope = array();
     foreach ($builtin_scope as $resource) {
         $builtin_actions = array_merge($builtin_actions, get_class_methods($resource));
     }
     $builtin_actions = array_filter($builtin_actions, function ($action) {
         return !in_array($action, array('create', 'show', 'edit', 'delete', 'export'), true);
     });
     foreach ($scope as $resource) {
         $resource = basename(str_replace('.php', '', $resource));
         if ($resource !== 'cms') {
             $controller_name = '\\CMS\\Controllers\\' . $resource;
             $controller_class = new \ReflectionClass($controller_name);
             if (!$controller_class->isInstantiable()) {
                 continue;
             }
             /* Create instance only if the controller class is instantiable */
             $controller_object = new $controller_name();
             if ($controller_object instanceof CMS\Controllers\CMS) {
                 $accessibility_scope[$resource] = array_diff(get_class_methods($controller_name), $builtin_actions);
                 array_push($accessibility_scope[$resource], 'index');
                 foreach ($accessibility_scope[$resource] as $key => $action_with_acl) {
                     if (in_array($action_with_acl, $controller_object->skipAclFor, true)) {
                         unset($accessibility_scope[$resource][$key]);
                     }
                 }
             }
         }
     }
     return $accessibility_scope;
 }
 public function processRequest()
 {
     // No CSRF for SendGrid.
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     $request = $this->getRequest();
     $user = $request->getUser();
     $raw_headers = $request->getStr('headers');
     $raw_headers = explode("\n", rtrim($raw_headers));
     $raw_dict = array();
     foreach (array_filter($raw_headers) as $header) {
         list($name, $value) = explode(':', $header, 2);
         $raw_dict[$name] = ltrim($value);
     }
     $headers = array('to' => $request->getStr('to'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict;
     $received = new PhabricatorMetaMTAReceivedMail();
     $received->setHeaders($headers);
     $received->setBodies(array('text' => $request->getStr('text'), 'html' => $request->getStr('from')));
     $file_phids = array();
     foreach ($_FILES as $file_raw) {
         try {
             $file = PhabricatorFile::newFromPHPUpload($file_raw, array('authorPHID' => $user->getPHID()));
             $file_phids[] = $file->getPHID();
         } catch (Exception $ex) {
             phlog($ex);
         }
     }
     $received->setAttachments($file_phids);
     $received->save();
     $received->processReceivedMail();
     $response = new AphrontWebpageResponse();
     $response->setContent("Got it! Thanks, SendGrid!\n");
     return $response;
 }
Example #7
0
 /**
  * Updates a team resource
  * 
  * @param \Badgeville\Api\Cairo\Sites\Teams $obj
  * @return \Badgeville\Api\Cairo\Sites\Teams
  */
 public function update($obj = null)
 {
     $useSelf = false;
     if ($obj instanceof $this) {
         $objData = $obj->toArray();
     } else {
         $useSelf = true;
         $objData = $this->data;
     }
     $properties = ['display_name' => FILTER_SANITIZE_STRING, 'name' => FILTER_SANITIZE_STRING, 'active' => ['filter' => FILTER_VALIDATE_BOOLEAN, 'flags' => FILTER_NULL_ON_FAILURE], 'display_priority' => FILTER_SANITIZE_NUMBER_INT];
     // need to remove null values
     $data = array_filter($objData, function ($value) {
         return is_null($value) ? false : true;
     });
     // clean params up
     $data = filter_var_array($data, $properties, false);
     $params = ['do' => 'update', 'data' => json_encode($data, JSON_UNESCAPED_SLASHES)];
     $response = $this->getSite()->getRequest($this->uriBuilder() . '/' . $this->id, $params);
     if ($useSelf) {
         return $this->setData($response[$this->getResourceName()][0]);
     }
     $player = clone $this;
     $player->setData();
     return $player;
 }
Example #8
0
 /**
  * {@inheritDoc}
  */
 protected function parse($path)
 {
     $matches = array();
     $parts = array_filter(explode($this->structureDelimiter, $path));
     // Set controller
     $matches = array_merge($this->defaults, $matches);
     if (isset($parts[0]) && in_array($parts[0], $this->controllerList)) {
         $matches['controller'] = $this->decode($parts[0]);
     }
     // Make Match
     if (isset($matches['controller'])) {
         switch ($matches['controller']) {
             case 'ticket':
                 if (isset($parts[1]) && is_numeric($parts[1])) {
                     $matches['id'] = intval($parts[1]);
                 }
                 break;
         }
     }
     /* echo '<pre>';
        print_r($parts);
        print_r($matches);
        echo '</pre>'; */
     return $matches;
 }
 /**
  * {@inheritdoc}
  */
 public function process($text, $langcode)
 {
     $allowed_tags = array_filter($this->settings['restrictions']['allowed'], function ($value) {
         return is_array($value) || (bool) $value !== FALSE;
     });
     return new FilterProcessResult(Xss::filter($text, array_keys($allowed_tags)));
 }
Example #10
0
 /**
  * @return Response
  */
 public function index(Container $p_dependencies)
 {
     $request = RequestWrapper::$request;
     $session = SessionFactory::getSession();
     $options = ['blaze' => (bool) $request->get('blaze'), 'deflect' => (bool) $request->get('deflect'), 'duel' => (bool) $request->get('duel'), 'evade' => (bool) $request->get('evasion'), 'attack' => !(bool) $request->get('duel')];
     $target = Player::find($request->get('target'));
     $attacker = Player::find($session->get('player_id'));
     $skillListObj = new Skill();
     $ignores_stealth = false;
     $required_turns = 0;
     foreach (array_filter($options) as $type => $value) {
         $ignores_stealth = $ignores_stealth || $skillListObj->getIgnoreStealth($type);
         $required_turns += $skillListObj->getTurnCost($type);
     }
     $params = ['required_turns' => $required_turns, 'ignores_stealth' => $ignores_stealth];
     try {
         $rules = new AttackLegal($attacker, $target, $params);
         $attack_is_legal = $rules->check();
         $error = $rules->getError();
     } catch (\InvalidArgumentException $e) {
         $attack_is_legal = false;
         $error = 'Could not determine valid target';
     }
     if (!$attack_is_legal) {
         // Take away at least one turn even on attacks that fail.
         $attacker->turns = $attacker->turns - 1;
         $attacker->save();
         $parts = ['target' => $target, 'attacker' => $attacker, 'error' => $error];
         return new StreamedViewResponse('Battle Status', 'attack_mod.tpl', $parts, ['quickstat' => 'player']);
     } else {
         return $this->combat($attacker, $target, $required_turns, $options);
     }
 }
Example #11
0
 function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0)
 {
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     if ($args->has_children) {
         $classes[] = 'dropdown';
     }
     $icon_html = '';
     if (isset($item->custom_icon) && !empty($item->custom_icon)) {
         $icon_html = '<i class="' . $item->custom_icon . '"></i><span>&nbsp;&nbsp;</span>';
     }
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $value . $class_names . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . $icon_html . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
 public function parse(\Twig_Token $token)
 {
     $inputs = array();
     $attrs = array('filters' => array());
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             $inputs[] = $stream->next()->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'filter')) {
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attrs['filters'] = array_merge($attrs['filters'], array_filter(array_map('trim', explode(',', $stream->expect(\Twig_Token::STRING_TYPE)->getValue()))));
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'output')) {
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes['output'] = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $content = $this->parser->subparse(array($this, 'testEndTag'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $this->manager->load($inputs, $attrs, $this->getTag());
     $params['assets'] = $this->manager->getAssetsPath();
     return new TlAssetsNode(array('content' => $content), $params, $token->getLine(), $this->getTag());
 }
 /**
  * {@inheritdoc}
  */
 public function filter(RouteCollection $collection, Request $request)
 {
     // The Content-type header does not make sense on GET requests, because GET
     // requests do not carry any content. Nothing to filter in this case.
     if ($request->isMethod('GET')) {
         return $collection;
     }
     $format = $request->getContentType();
     foreach ($collection as $name => $route) {
         $supported_formats = array_filter(explode('|', $route->getRequirement('_content_type_format')));
         if (empty($supported_formats)) {
             // No restriction on the route, so we move the route to the end of the
             // collection by re-adding it. That way generic routes sink down in the
             // list and exact matching routes stay on top.
             $collection->add($name, $route);
         } elseif (!in_array($format, $supported_formats)) {
             $collection->remove($name);
         }
     }
     if (count($collection)) {
         return $collection;
     }
     // We do not throw a
     // \Symfony\Component\Routing\Exception\ResourceNotFoundException here
     // because we don't want to return a 404 status code, but rather a 415.
     throw new UnsupportedMediaTypeHttpException('No route found that matches "Content-Type: ' . $request->headers->get('Content-Type') . '"');
 }
Example #14
0
 /**
  * Checks the queue for matches to this request.
  * If a group can be formed, returns an array with the sessions that will form this group.
  * Otherwise, returns FALSE.
  *
  * @param GroupRequest $request
  * @return array<Session> if a group can be formed, FALSE otherwise
  */
 public function newRequest(GroupRequest $request)
 {
     // filter all requests that match this one
     $matches = array_filter($this->requests, function ($potential_match) use($request) {
         return !$potential_match->expired() && $request->match($potential_match);
     });
     if (count($matches) + 1 >= $request->size()) {
         // we have enough people to form a group!
         // get as many of the matches as we need for the group
         $selected_requests = array_slice($matches, 0, $request->size() - 1);
         // remove the fulfilled grouprequests from the queue
         $this->removeRequests($selected_requests);
         // get the sessions that will make up this group
         $sessions = array_map(function ($selected_request) {
             return $selected_request->session;
         }, $selected_requests);
         $sessions[] = $request->session;
         // don't forget the new request
         return $sessions;
     } else {
         // not enough requests matching this one
         // add this request to the queue
         $this->addRequest($request);
         return FALSE;
     }
 }
 /**
  * Batch has been successfully imported.
  *
  * @param Batch $batch
  */
 public function imported(Batch $batch)
 {
     $links = array();
     $output = '';
     $types = array('page', 'post');
     // Only keep published posts of type $types.
     $posts = array_filter($batch->get_posts(), function (Post $post) use($types) {
         return $post->get_post_status() == 'publish' && in_array($post->get_type(), $types);
     });
     // Create links for each of the posts.
     foreach ($posts as $post) {
         $post_id = $this->post_dao->get_id_by_guid($post->get_guid());
         $links[] = array('link' => get_permalink($post_id), 'title' => $post->get_title());
     }
     $links = apply_filters('sme_imported_post_links', $links);
     foreach ($links as $link) {
         $output .= '<li><a href="' . $link['link'] . '" target="_blank">' . $link['title'] . '</a></li>';
     }
     if ($output !== '') {
         $output = '<ul>' . $output . '</ul>';
         $message = '<h3>Posts deployed to ' . get_bloginfo('name') . ':</h3>' . $output;
         $this->api->add_deploy_message($batch->get_id(), $message, 'info', 102);
     }
     $this->api->add_deploy_message($batch->get_id(), 'Batch has been successfully imported!', 'success', 101);
 }
Example #16
0
 public function request($type, $url, array $params = array(), array $properties = array())
 {
     $params = array_filter($params);
     $ch = curl_init();
     switch (strtolower($type)) {
         case 'post':
             curl_setopt($ch, CURLOPT_POST, true);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
             break;
         case 'get':
             $url = $this->buildQueryString($url, $params);
             break;
         case 'delete':
             $url = $this->buildQueryString($url, $params);
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
         case 'update':
         case 'put':
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
             break;
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_URL, $url);
     foreach ($properties as $propertyKey => $propertyValue) {
         curl_setopt($ch, $propertyKey, $propertyValue);
     }
     $response = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     return new Response($info, $response);
 }
Example #17
0
 /**
  * Sends a request to the REST API service and does initial processing
  * on the response.
  *
  * @param  string $op    Name of the operation for the request
  * @param  array  $query Query data for the request (optional)
  * @throws Zend_Service_Exception
  * @return DOMDocument Parsed XML response
  */
 protected function _makeRequest($op, $query = null)
 {
     if ($query != null) {
         $query = array_diff($query, array_filter($query, 'is_null'));
         $query = '?' . http_build_query($query);
     }
     $this->_http->setUri($this->_baseUri . $op . '.do' . $query);
     $response = $this->_http->request('GET');
     if ($response->isSuccessful()) {
         $doc = new DOMDocument();
         $doc->loadXML($response->getBody());
         $xpath = new DOMXPath($doc);
         $list = $xpath->query('/status/code');
         if ($list->length > 0) {
             $code = $list->item(0)->nodeValue;
             if ($code != 0) {
                 $list = $xpath->query('/status/message');
                 $message = $list->item(0)->nodeValue;
                 /**
                  * @see Zend_Service_Exception
                  */
                 require_once 'Zend/Service/Exception.php';
                 throw new Zend_Service_Exception($message, $code);
             }
         }
         return $doc;
     }
     /**
      * @see Zend_Service_Exception
      */
     require_once 'Zend/Service/Exception.php';
     throw new Zend_Service_Exception($response->getMessage(), $response->getStatus());
 }
Example #18
0
 protected function getFilteredEventsWithObserversCount()
 {
     $eventsWithObservers = array_filter($this->getFilteredEvents(), function ($item) {
         return count($item['observers']) > 0;
     });
     return count($eventsWithObservers);
 }
 /**
  * Handle pre save event
  *
  * @param LifecycleEventArgs $args Event arguments
  */
 protected function preSave(LifecycleEventArgs $args)
 {
     $annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
     if (0 === count($annotations)) {
         return;
     }
     foreach ($annotations as $field => $annotation) {
         $config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
         if (!(isset($config['use_orphanage']) && $config['use_orphanage'])) {
             continue;
         }
         $value = (array) PropertyAccess::createPropertyAccessor()->getValue($args->getEntity(), $field);
         $value = array_filter($value, 'strlen');
         $value = array_map(function ($file) {
             return pathinfo($file, PATHINFO_BASENAME);
         }, $value);
         if (empty($value)) {
             continue;
         }
         $orphanageStorage = $this->container->get('oneup_uploader.orphanage.' . $annotation->endpoint);
         $files = [];
         foreach ($orphanageStorage->getFiles() as $file) {
             if (in_array($file->getBasename(), $value, true)) {
                 $files[] = $file;
             }
         }
         $orphanageStorage->uploadFiles($files);
     }
 }
 protected function addressFromIP($ip)
 {
     $geocoder = AddressGeocoding::get_geocoder();
     $geodata = array();
     try {
         if ($ip) {
             $geodata = $geocoder->geocode($ip)->toArray();
         }
     } catch (Exception $e) {
         SS_Log::log($e, SS_Log::ERR);
     }
     $geodata = array_filter($geodata);
     $datamap = array('Country' => 'countryCode', 'County' => 'county', 'State' => 'region', 'PostalCode' => 'zipcode', 'Latitude' => 'latitude', 'Longitude' => 'longitude');
     $mappeddata = array();
     foreach ($datamap as $addressfield => $geofield) {
         if (is_array($geofield)) {
             if ($data = implode(" ", array_intersect_key($geodata, array_combine($geofield, $geofield)))) {
                 $mappeddata[$addressfield] = $data;
             }
         } elseif (isset($geodata[$geofield])) {
             $mappeddata[$addressfield] = $geodata[$geofield];
         }
     }
     return $mappeddata;
 }
Example #21
0
 /**
  * Create a new SetCookie object from a string
  *
  * @param string $cookie Set-Cookie header string
  *
  * @return self
  */
 public static function fromString($cookie)
 {
     // Create the default return array
     $data = self::$defaults;
     // Explode the cookie string using a series of semicolons
     $pieces = array_filter(array_map('trim', explode(';', $cookie)));
     // The name of the cookie (first kvp) must include an equal sign.
     if (empty($pieces) || !strpos($pieces[0], '=')) {
         return new self($data);
     }
     // Add the cookie pieces into the parsed data array
     foreach ($pieces as $part) {
         $cookieParts = explode('=', $part, 2);
         $key = trim($cookieParts[0]);
         $value = isset($cookieParts[1]) ? trim($cookieParts[1], " \n\r\t\v\"") : true;
         // Only check for non-cookies when cookies have been found
         if (empty($data['Name'])) {
             $data['Name'] = $key;
             $data['Value'] = $value;
         } else {
             foreach (array_keys(self::$defaults) as $search) {
                 if (!strcasecmp($search, $key)) {
                     $data[$search] = $value;
                     continue 2;
                 }
             }
             $data[$key] = $value;
         }
     }
     return new self($data);
 }
function mm_ux_log($args = array())
{
    $url = "https://ssl.google-analytics.com/collect";
    global $title;
    if (empty($_SERVER['REQUEST_URI'])) {
        return;
    }
    $path = explode('wp-admin', $_SERVER['REQUEST_URI']);
    if (empty($path) || empty($path[1])) {
        $path = array("", " ");
    }
    $defaults = array('v' => '1', 'tid' => 'UA-39246514-3', 't' => 'pageview', 'cid' => md5(get_option('siteurl')), 'uid' => md5(get_option('siteurl') . get_current_user_id()), 'cn' => 'mojo_wp_plugin', 'cs' => 'mojo_wp_plugin', 'cm' => 'plugin_admin', 'ul' => get_locale(), 'dp' => $path[1], 'sc' => '', 'ua' => @$_SERVER['HTTP_USER_AGENT'], 'dl' => $path[1], 'dh' => get_option('siteurl'), 'dt' => $title, 'ec' => '', 'ea' => '', 'el' => '', 'ev' => '');
    if (isset($_SERVER['REMOTE_ADDR'])) {
        $defaults['uip'] = $_SERVER['REMOTE_ADDR'];
    }
    $params = wp_parse_args($args, $defaults);
    $test = get_transient('mm_test', '');
    if (isset($test['key']) && isset($test['name'])) {
        $params['cm'] = $params['cm'] . "_" . $test['name'] . "_" . $test['key'];
    }
    //use test account for testing
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $params['tid'] = 'UA-19617272-27';
    }
    $z = wp_rand(0, 1000000000);
    $query = http_build_query(array_filter($params));
    $args = array('body' => $query, 'method' => 'POST', 'blocking' => false);
    $url = add_query_arg(array('z' => $z), $url);
    wp_remote_post($url, $args);
}
Example #23
0
 public function sql_split($sql)
 {
     $db_charset = C('DB_CHARSET') ? C('DB_CHARSET') : 'utf8';
     $sql = preg_replace("/TYPE=(InnoDB|MyISAM|MEMORY)( DEFAULT CHARSET=[^; ]+)?/", "ENGINE=\\1 DEFAULT CHARSET=" . $db_charset, $sql);
     if (C('DB_PREFIX') != "tb_") {
         $sql = str_replace("tb_", C('DB_PREFIX'), $sql);
     }
     $sql = str_replace("\r", "\n", $sql);
     $ret = array();
     $num = 0;
     $queriesarray = explode(";\n", trim($sql));
     unset($sql);
     foreach ($queriesarray as $query) {
         $ret[$num] = '';
         $queries = explode("\n", trim($query));
         $queries = array_filter($queries);
         foreach ($queries as $query) {
             $str1 = substr($query, 0, 1);
             if ($str1 != '#' && $str1 != '-') {
                 $ret[$num] .= $query;
             }
         }
         $num++;
     }
     return $ret;
 }
Example #24
0
 public function addCommandsFromClass($className, $passThrough = null)
 {
     $roboTasks = new $className();
     $commandNames = array_filter(get_class_methods($className), function ($m) {
         return !in_array($m, ['__construct']);
     });
     foreach ($commandNames as $commandName) {
         $command = $this->createCommand(new TaskInfo($className, $commandName));
         $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
             // get passthru args
             $args = $input->getArguments();
             array_shift($args);
             if ($passThrough) {
                 $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
             }
             $args[] = $input->getOptions();
             $res = call_user_func_array([$roboTasks, $commandName], $args);
             if (is_int($res)) {
                 exit($res);
             }
             if (is_bool($res)) {
                 exit($res ? 0 : 1);
             }
             if ($res instanceof Result) {
                 exit($res->getExitCode());
             }
         });
         $this->add($command);
     }
 }
Example #25
0
 /**
  * Search authitem
  * @param array $params
  * @return \yii\data\ActiveDataProvider|\yii\data\ArrayDataProvider
  */
 public function search($params)
 {
     /* @var \yii\rbac\Manager $authManager */
     $authManager = Yii::$app->authManager;
     if ($this->type == Item::TYPE_ROLE) {
         $items = $authManager->getRoles();
     } else {
         $items = [];
         if ($this->type == Item::TYPE_PERMISSION) {
             foreach ($authManager->getPermissions() as $name => $item) {
                 if ($name[0] !== '/') {
                     $items[$name] = $item;
                 }
             }
         } else {
             foreach ($authManager->getPermissions() as $name => $item) {
                 if ($name[0] === '/') {
                     $items[$name] = $item;
                 }
             }
         }
     }
     if ($this->load($params) && $this->validate() && (trim($this->name) !== '' || trim($this->description) !== '')) {
         $search = strtolower(trim($this->name));
         $desc = strtolower(trim($this->description));
         $items = array_filter($items, function ($item) use($search, $desc) {
             return (empty($search) || strpos(strtolower($item->name), $search) !== false) && (empty($desc) || strpos(strtolower($item->description), $desc) !== false);
         });
     }
     return new ArrayDataProvider(['allModels' => $items]);
 }
Example #26
0
 public function __construct($api_key, $secret, $generate_session_secret = false)
 {
     $this->api_key = $api_key;
     $this->secret = $secret;
     $this->generate_session_secret = $generate_session_secret;
     $this->api_client = new FacebookRestClient($api_key, $secret, null);
     $this->validate_fb_params();
     // Set the default user id for methods that allow the caller to
     // pass an explicit uid instead of using a session key.
     $defaultUser = null;
     if ($this->user) {
         $defaultUser = $this->user;
     } else {
         if ($this->profile_user) {
             $defaultUser = $this->profile_user;
         } else {
             if ($this->canvas_user) {
                 $defaultUser = $this->canvas_user;
             }
         }
     }
     $this->api_client->set_user($defaultUser);
     if (isset($this->fb_params['friends'])) {
         $this->api_client->friends_list = array_filter(explode(',', $this->fb_params['friends']));
     }
     if (isset($this->fb_params['added'])) {
         $this->api_client->added = $this->fb_params['added'];
     }
     if (isset($this->fb_params['canvas_user'])) {
         $this->api_client->canvas_user = $this->fb_params['canvas_user'];
     }
 }
 /**
  * Returns an array of public variable names (instead of properties names of parent class)
  *
  * @return array
  */
 public function getPublicProperties()
 {
     // return $this->table->getPublicProperties();
     return array_filter(array_keys(get_object_vars($this)), function ($k) {
         return substr($k, 0, 1) != '_';
     });
 }
 /**
  * start_el function.
  * 
  * @access public
  * @param mixed &$output
  * @param mixed $item
  * @param int $depth (default: 0)
  * @param array $args (default: array())
  * @param int $id (default: 0)
  * @return void
  */
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $li_attributes = '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = $args->has_children ? 'dropdown' : '';
     $classes[] = $item->current || $item->current_item_ancestor ? 'active' : '';
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $attributes .= $args->has_children ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= $args->has_children ? ' <b class="caret"></b></a>' : '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
Example #29
0
    public function callbackColumnCategories($value, $row, $column, $isExport)
    {
        $groupId = (int) $row->getData('id');
        $categories = array_filter(explode(',', $row->getData('categories')));
        $count = count($categories);
        if ($count == 0 || $count > 3) {
            $total = Mage::helper('M2ePro')->__('Total');
            $html = "<strong>{$total}:&nbsp;</strong>&nbsp;{$count}";
            if (count($categories) > 3) {
                $details = Mage::helper('M2ePro')->__('details');
                $html .= <<<HTML
&nbsp;
[<a href="javascript: void(0);" onclick="ListingAutoActionHandlerObj.categoryStepOne({$groupId});">{$details}</a>]
HTML;
            }
            return $html;
        }
        $html = '';
        foreach ($categories as $categoryId) {
            $path = Mage::helper('M2ePro/Magento_Category')->getPath($categoryId);
            if (empty($path)) {
                continue;
            }
            if ($html != '') {
                $html .= '<br/>';
            }
            $path = implode(' > ', $path);
            $html .= '<span style="font-style: italic;">' . Mage::helper('M2ePro')->escapeHtml($path) . '</span>';
        }
        return $html;
    }
Example #30
-7
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth));
     /**
      * Change WP's default classes to match Foundation's required classes
      */
     $class_names = str_replace(array('menu-item-has-children'), array('has-submenu'), $class_names);
     // ==========================
     $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
     $id = $id ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $class_names . '>';
     $atts = array();
     $atts['title'] = !empty($item->attr_title) ? $item->attr_title : '';
     $atts['target'] = !empty($item->target) ? $item->target : '';
     $atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
     $atts['href'] = !empty($item->url) ? $item->url : '';
     $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }