/**
 * Expand an IPv6 Address
 *
 * This will take an IPv6 address written in short form and expand it to include all zeros. 
 *
 * @param  string  $addr A valid IPv6 address
 * @return string  The expanded notation IPv6 address
 */
function inet6_expand($addr)
{
    /* Check if there are segments missing, insert if necessary */
    if (strpos($addr, '::') !== false) {
        $part = explode('::', $addr);
        $part[0] = explode(':', $part[0]);
        $part[1] = explode(':', $part[1]);
        $missing = array();
        for ($i = 0; $i < 8 - (count($part[0]) + count($part[1])); $i++) {
            array_push($missing, '0000');
        }
        $missing = array_merge($part[0], $missing);
        $part = array_merge($missing, $part[1]);
    } else {
        $part = explode(":", $addr);
    }
    // if .. else
    /* Pad each segment until it has 4 digits */
    foreach ($part as &$p) {
        while (strlen($p) < 4) {
            $p = '0' . $p;
        }
    }
    // foreach
    unset($p);
    /* Join segments */
    $result = implode(':', $part);
    /* Quick check to make sure the length is as expected */
    if (strlen($result) == 39) {
        return $result;
    } else {
        return false;
    }
    // if .. else
}
示例#2
23
 public function run()
 {
     if ($this->footerWrapper) {
         echo Html::beginTag('div', ['class' => 'form-group panel-footer']);
     }
     $submit_options = [];
     if ($this->form) {
         $submit_options['form'] = $this->form;
     }
     $extra = '';
     if ($this->extraBtns) {
         $extra = '&nbsp;' . implode(' ', (array) $this->extraBtns);
     }
     if (isset($this->model->isNewRecord) && $this->model->isNewRecord) {
         if ($this->saveLink) {
             $submit_options['class'] = 'btn btn-success';
             echo Html::submitButton(__('Create'), $submit_options);
         }
         echo $extra;
     } else {
         if ($this->saveLink) {
             $submit_options['class'] = 'btn btn-primary';
             echo Html::submitButton(__('Update'), $submit_options);
         }
         echo $extra;
         if ($this->removeLink) {
             echo ' ';
             echo Html::a(__('Delete'), ['delete', 'id' => $this->model->id], ['class' => 'btn btn-danger', 'data-confirm' => __('Are you sure you want to delete this item?'), 'data-method' => 'post']);
         }
     }
     if ($this->footerWrapper) {
         echo Html::endTag('div');
     }
 }
示例#3
3
function qqwb_env()
{
    $msgs = array();
    $files = array(ROOT_PATH . 'include/ext/qqwb/qqoauth.php', ROOT_PATH . 'include/ext/qqwb/oauth.php', ROOT_PATH . 'modules/qqwb.mod.php');
    foreach ($files as $f) {
        if (!is_file($f)) {
            $msgs[] = "文件<b>{$f}</b>不存在";
        }
    }
    $funcs = array('version_compare', array('fsockopen', 'pfsockopen'), 'preg_replace', array('iconv', 'mb_convert_encoding'), array("hash_hmac", "mhash"));
    foreach ($funcs as $func) {
        if (!is_array($func)) {
            if (!function_exists($func)) {
                $msgs[] = "函数<b>{$func}</b>不可用";
            }
        } else {
            $t = false;
            foreach ($func as $f) {
                if (function_exists($f)) {
                    $t = true;
                    break;
                }
            }
            if (!$t) {
                $msgs[] = "函数<b>" . implode(" , ", $func) . "</b>都不可用";
            }
        }
    }
    return $msgs;
}
    public function configure()
    {
        $this->setName('phpcr:migrations:migrate');
        $this->addArgument('to', InputArgument::OPTIONAL, sprintf('Version name to migrate to, or an action: "<comment>%s</comment>"', implode('</comment>", "<comment>', $this->actions)));
        $this->setDescription('Migrate the content repository between versions');
        $this->setHelp(<<<EOT
Migrate to a specific version or perform an action.

By default it will migrate to the latest version:

    \$ %command.full_name%

You can migrate to a specific version (either in the "past" or "future"):

    \$ %command.full_name% 201504011200

Or specify an action

    \$ %command.full_name% <action>

Action can be one of:

- <comment>up</comment>: Migrate one version up
- <comment>down</comment>: Migrate one version down
- <comment>top</comment>: Migrate to the latest version
- <comment>bottom</comment>: Revert all migrations

EOT
);
    }
示例#5
1
 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
 public function getPath($categoryId, $accountId, $delimiter = ' > ')
 {
     $account = Mage::helper('M2ePro/Component_Ebay')->getCachedObject('Account', $accountId);
     $categories = $account->getChildObject()->getEbayStoreCategories();
     $pathData = array();
     while (true) {
         $currentCategory = NULL;
         foreach ($categories as $category) {
             if ($category['category_id'] == $categoryId) {
                 $currentCategory = $category;
                 break;
             }
         }
         if (is_null($currentCategory)) {
             break;
         }
         $pathData[] = $currentCategory['title'];
         if ($currentCategory['parent_id'] == 0) {
             break;
         }
         $categoryId = $currentCategory['parent_id'];
     }
     array_reverse($pathData);
     return implode($delimiter, $pathData);
 }
示例#7
1
文件: lib.php 项目: pzhu2004/moodle
/**
 * Serves assignment feedback and other files.
 *
 * @param mixed $course course or id of the course
 * @param mixed $cm course module or id of the course module
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @return bool false if file not found, does not return if found - just send the file
 */
function assignfeedback_editpdf_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
    global $USER, $DB, $CFG;
    if ($context->contextlevel == CONTEXT_MODULE) {
        require_login($course, false, $cm);
        $itemid = (int) array_shift($args);
        if (!($assign = $DB->get_record('assign', array('id' => $cm->instance)))) {
            return false;
        }
        $record = $DB->get_record('assign_grades', array('id' => $itemid), 'userid,assignment', MUST_EXIST);
        $userid = $record->userid;
        if ($assign->id != $record->assignment) {
            return false;
        }
        // Check is users feedback or has grading permission.
        if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) {
            return false;
        }
        $relativepath = implode('/', $args);
        $fullpath = "/{$context->id}/assignfeedback_editpdf/{$filearea}/{$itemid}/{$relativepath}";
        $fs = get_file_storage();
        if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
            return false;
        }
        // Download MUST be forced - security!
        send_stored_file($file, 0, 0, true);
        // Check if we want to retrieve the stamps.
    }
}
示例#8
1
function get_token_from_guids($guids)
{
    $guids = array_unique($guids);
    sort($guids);
    $string = implode(',', $guids);
    return md5($string);
}
 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht("Use the '%s' flag to specify one or more SMS messages to show.", '--id'));
     }
     $messages = id(new PhabricatorSMS())->loadAllWhere('id IN (%Ld)', $ids);
     if ($ids) {
         $ids = array_fuse($ids);
         $missing = array_diff_key($ids, $messages);
         if ($missing) {
             throw new PhutilArgumentUsageException(pht('Some specified SMS messages do not exist: %s', implode(', ', array_keys($missing))));
         }
     }
     $last_key = last_key($messages);
     foreach ($messages as $message_key => $message) {
         $info = array();
         $info[] = pht('PROPERTIES');
         $info[] = pht('ID: %d', $message->getID());
         $info[] = pht('Status: %s', $message->getSendStatus());
         $info[] = pht('To: %s', $message->getToNumber());
         $info[] = pht('From: %s', $message->getFromNumber());
         $info[] = null;
         $info[] = pht('BODY');
         $info[] = $message->getBody();
         $info[] = null;
         $console->writeOut('%s', implode("\n", $info));
         if ($message_key != $last_key) {
             $console->writeOut("\n%s\n\n", str_repeat('-', 80));
         }
     }
 }
 public function edit()
 {
     if (IS_POST) {
         $post_data = I('post.');
         $post_data["rules"] = I("post.rules");
         $post_data["rules"] = implode(",", $post_data["rules"]);
         $data = $this->Model->create($post_data);
         if ($data) {
             $result = $this->Model->where(array('id' => $post_data['id']))->save($data);
             if ($result) {
                 action_log('Edit_AuthGroup', 'AuthGroup', $post_data['id']);
                 $this->success("操作成功!", U('index'));
             } else {
                 $error = $this->Model->getError();
                 $this->error($error ? $error : "操作失败!");
             }
         } else {
             $error = $this->Model->getError();
             $this->error($error ? $error : "操作失败!");
         }
     } else {
         $_info = I('get.');
         $_info = $this->Model->where(array('id' => $_info['id']))->find();
         $this->assign('_info', $_info);
         $this->display();
     }
 }
示例#11
1
 /**
  * Displays a view
  *
  * @param mixed What page to display
  * @return void
  * @throws NotFoundException When the view file could not be found
  *	or MissingViewException in debug mode.
  */
 public function display()
 {
     $path = func_get_args();
     //debug($path);
     $count = count($path);
     //debug($count);
     if (!$count) {
         return $this->redirect('/');
     }
     $page = $subpage = $title_for_layout = null;
     //debug(Inflector::humanize($path[$count - 1]));
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $title_for_layout = Inflector::humanize($path[$count - 1]);
     }
     $this->set(compact('page', 'subpage', 'title_for_layout'));
     //debug($this->render(implode('/', $path)));
     //debug($page);
     //debug($subpage);
     //debug($title_for_layout);
     try {
         $this->render(implode('/', $path));
     } catch (MissingViewException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
 }
示例#12
1
function get_hook($name)
{
    global $plugins_hooks;
    if (isset($plugins_hooks[$name])) {
        return implode('', $plugins_hooks[$name]);
    }
}
示例#13
1
 public static function convertDateMomentToPhp($format)
 {
     $tokens = ["M" => "n", "Mo" => "nS", "MM" => "m", "MMM" => "M", "MMMM" => "F", "D" => "j", "Do" => "jS", "DD" => "d", "DDD" => "z", "DDDo" => "zS", "DDDD" => "zS", "d" => "w", "do" => "wS", "dd" => "D", "ddd" => "D", "dddd" => "l", "e" => "w", "E" => "N", "w" => "W", "wo" => "WS", "ww" => "W", "W" => "W", "Wo" => "WS", "WW" => "W", "YY" => "y", "YYYY" => "Y", "gg" => "o", "gggg" => "o", "GG" => "o", "GGGG" => "o", "A" => "A", "a" => "a", "H" => "G", "HH" => "H", "h" => "g", "hh" => "h", "m" => "i", "mm" => "i", "s" => "s", "ss" => "s", "S" => "", "SS" => "", "SSS" => "", "z or zz" => "T", "Z" => "P", "ZZ" => "O", "X" => "U", "LT" => "g:i A", "L" => "m/d/Y", "l" => "n/j/Y", "LL" => "F jS Y", "ll" => "M j Y", "LLL" => "F js Y g:i A", "lll" => "M j Y g:i A", "LLLL" => "l, F jS Y g:i A", "llll" => "D, M j Y g:i A"];
     // find all tokens from string, using regular expression
     $regExp = "/(\\[[^\\[]*\\])|(\\\\)?(LT|LL?L?L?|l{1,4}|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/";
     $matches = array();
     preg_match_all($regExp, $format, $matches);
     //  if there is no match found then return the string as it is
     //  TODO: might return escaped string
     if (empty($matches) || is_array($matches) === false) {
         return $format;
     }
     //  to match with extracted tokens
     $momentTokens = array_keys($tokens);
     $phpMatches = array();
     //  ----------------------------------
     foreach ($matches[0] as $id => $match) {
         // if there is a matching php token in token list
         if (in_array($match, $momentTokens)) {
             // use the php token instead
             $string = $tokens[$match];
         } else {
             $string = $match;
         }
         $phpMatches[$id] = $string;
     }
     // join and return php specific tokens
     return implode("", $phpMatches);
 }
示例#14
1
 /**
  *
  * @see XenForo_Route_PrefixAdmin_AddOns::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $parts = explode('/', $routePath, 3);
     switch ($parts[0]) {
         case 'languages':
             $parts = array_slice($parts, 1);
             $routePath = implode('/', $parts);
             $action = $router->resolveActionWithIntegerParam($routePath, $request, 'language_id');
             return $router->getRouteMatch('XenForo_ControllerAdmin_Language', $action, 'languages');
         case 'phrases':
             $parts = array_slice($parts, 1);
             $routePath = implode('/', $parts);
             return $router->getRouteMatch('XenForo_ControllerAdmin_Phrase', $routePath, 'phrases');
     }
     if (count($parts) > 1) {
         switch ($parts[1]) {
             case 'languages':
                 $action = $router->resolveActionWithStringParam($routePath, $request, 'addon_id');
                 $parts = array_slice($parts, 2);
                 $routePath = implode('/', $parts);
                 $action = $router->resolveActionWithIntegerParam($routePath, $request, 'language_id');
                 return $router->getRouteMatch('XenForo_ControllerAdmin_Language', $action, 'languages');
             case 'phrases':
                 $action = $router->resolveActionWithStringParam($routePath, $request, 'addon_id');
                 $parts = array_slice($parts, 2);
                 $routePath = implode('/', $parts);
                 return $router->getRouteMatch('XenForo_ControllerAdmin_Phrase', $routePath, 'phrases');
         }
     }
     return parent::match($routePath, $request, $router);
 }
 /**
  * Add facebook user
  */
 public function addUserFacebook($aVals, $iFacebookUserId, $sAccessToken)
 {
     if (!defined('PHPFOX_IS_FB_USER')) {
         define('PHPFOX_IS_FB_USER', true);
     }
     //get facebook setting
     $bFbConnect = Phpfox::getParam('facebook.enable_facebook_connect');
     if ($bFbConnect == false) {
         return false;
     } else {
         if (Phpfox::getService('accountapi.facebook')->checkUserFacebook($iFacebookUserId) == false) {
             if (Phpfox::getParam('user.disable_username_on_sign_up')) {
                 $aVals['user_name'] = Phpfox::getLib('parse.input')->cleanTitle($aVals['full_name']);
             }
             $aVals['country_iso'] = null;
             if (Phpfox::getParam('user.split_full_name')) {
                 $aNameSplit = preg_split('[ ]', $aVals['full_name']);
                 $aVals['first_name'] = $aNameSplit[0];
                 unset($aNameSplit[0]);
                 $aVals['last_name'] = implode(' ', $aNameSplit);
             }
             $iUserId = Phpfox::getService('user.process')->add($aVals);
             if ($iUserId === false) {
                 return false;
             } else {
                 Phpfox::getService('facebook.process')->addUser($iUserId, $iFacebookUserId);
                 //update fb profile image to db
                 $bCheck = Phpfox::getService('accountapi.facebook')->addImagePicture($sAccessToken, $iUserId);
             }
         }
     }
     return true;
 }
示例#16
1
 public function generate_cookie()
 {
     $characters = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0';
     $characters_array = explode(',', $characters);
     shuffle($characters_array);
     return implode('', $characters_array);
 }
示例#17
0
 public function translate($text, $lang = false)
 {
     $method = "translate";
     $params = ['text' => $text, 'lang' => $lang ? $lang : $this->lang];
     $data = $this->sendRequest($method, $params);
     return implode('<br>', $data['text']);
 }
 private function execDB($sql, $message)
 {
     $res = $this->db->dbh->exec($sql);
     if ($res === false) {
         throw new ForgeUpgrade_Bucket_Exception_UpgradeNotComplete($message . implode(', ', $this->db->dbh->errorInfo()));
     }
 }
示例#19
0
 function paginate($term = null, $paginateOptions = array())
 {
     $this->_controller->paginate = array('SearchIndex' => array_merge_recursive(array('conditions' => array(array('SearchIndex.active' => 1), 'or' => array(array('SearchIndex.published' => null), array('SearchIndex.published <= ' => date('Y-m-d H:i:s'))))), $paginateOptions));
     if (isset($this->_controller->request->params['named']['type']) && $this->_controller->request->params['named']['type'] != 'All') {
         $this->_controller->request->data['SearchIndex']['type'] = Sanitize::escape($this->_controller->request->params['named']['type']);
         $this->_controller->paginate['SearchIndex']['conditions']['model'] = $this->_controller->data['SearchIndex']['type'];
     }
     // Add term condition, and sorting
     if (!$term && isset($this->_controller->request->params['named']['term'])) {
         $term = $this->_controller->request->params['named']['term'];
     }
     if ($term) {
         $term = Sanitize::escape($term);
         $this->_controller->request->data['SearchIndex']['term'] = $term;
         $term = implode(' ', array_map(array($this, 'replace'), preg_split('/[\\s_]/', $term))) . '*';
         if ($this->like) {
             $this->_controller->paginate['SearchIndex']['conditions'][] = array('or' => array("MATCH(data) AGAINST('{$term}')", 'SearchIndex.data LIKE' => "%{$this->_controller->data['SearchIndex']['term']}%"));
         } else {
             $this->_controller->paginate['SearchIndex']['conditions'][] = "MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE)";
         }
         $this->_controller->paginate['SearchIndex']['fields'] = "*, MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE) AS score";
         if (empty($this->_controller->paginate['SearchIndex']['order'])) {
             $this->_controller->paginate['SearchIndex']['order'] = "score DESC";
         }
     }
     return $this->_controller->paginate('SearchIndex');
 }
示例#20
0
文件: Whitelist.php 项目: horde/horde
 /**
  */
 protected function _init()
 {
     global $injector, $notification, $page_output;
     $this->_assertCategory('Ingo_Rule_System_Whitelist', _("Whitelist"));
     $ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
     $whitelist = $ingo_storage->getSystemRule('Ingo_Rule_System_Whitelist');
     /* Token checking & perform requested actions. */
     switch ($this->_checkToken(array('rule_update'))) {
         case 'rule_update':
             try {
                 $whitelist->addresses = $this->vars->whitelist;
                 $ingo_storage->updateRule($whitelist);
                 $notification->push(_("Changes saved."), 'horde.success');
                 $injector->getInstance('Ingo_Factory_Script')->activateAll();
             } catch (Ingo_Exception $e) {
                 $notification->push($e);
             }
             break;
     }
     /* Prepare the view. */
     $view = new Horde_View(array('templatePath' => INGO_TEMPLATES . '/basic/whitelist'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     $view->addHelper('Horde_Core_View_Helper_Label');
     $view->addHelper('Text');
     $view->disabled = $whitelist->disable;
     $view->formurl = $this->_addToken(self::url());
     $view->whitelist = implode("\n", $whitelist->addresses);
     $page_output->addScriptFile('whitelist.js');
     $page_output->addInlineJsVars(array('IngoWhitelist.filtersurl' => strval(Ingo_Basic_Filters::url()->setRaw(true))));
     $this->title = _("Whitelist Edit");
     $this->output = $view->render('whitelist');
 }
 /**
  * Converts entity labels for entity reference fields to entity ids.
  *
  * @param string $entity_type
  *   The type of the entity being processed.
  * @param string $entity_bundle
  *   The bundle of the entity being processed.
  * @param array $values
  *   An array of field values keyed by field name.
  *
  * @return array
  *   The processed field values.
  *
  * @throws \Exception
  *   Thrown when no entity with the given label has been found.
  */
 public function convertEntityReferencesValues($entity_type, $entity_bundle, $values)
 {
     $definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type, $entity_bundle);
     foreach ($definitions as $name => $definition) {
         if ($definition->getType() != 'entity_reference' || !array_key_exists($name, $values) || !strlen($values[$name])) {
             continue;
         }
         // Retrieve the entity type and bundles that can be referenced.
         $settings = $definition->getSettings();
         $target_entity_type = $settings['target_type'];
         $target_entity_bundles = $settings['handler_settings']['target_bundles'];
         // Multi-value fields are separated by comma.
         $labels = explode(', ', $values[$name]);
         $values[$name] = [];
         foreach ($labels as $label) {
             $id = $this->getEntityIdByLabel($label, $target_entity_type, $target_entity_bundles);
             $bundles = implode(',', $target_entity_bundles);
             if (!$id) {
                 throw new \Exception("Entity with label '{$label}' could not be found for '{$target_entity_type} ({$bundles})' to fill field '{$name}'.");
             }
             $values[$name][] = $id;
         }
     }
     return $values;
 }
示例#22
0
 /**
  * Visit struct returned by controllers.
  *
  * @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
  * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
  * @param \eZ\Publish\API\Repository\Values\Content\URLAlias $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('UrlAlias');
     $visitor->setHeader('Content-Type', $generator->getMediaType('UrlAlias'));
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadURLAlias', array('urlAliasId' => $data->id)));
     $generator->endAttribute('href');
     $generator->startAttribute('id', $data->id);
     $generator->endAttribute('id');
     $generator->startAttribute('type', $this->serializeType($data->type));
     $generator->endAttribute('type');
     if ($data->type === Values\Content\URLAlias::LOCATION) {
         $generator->startObjectElement('location', 'Location');
         $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => $data->destination)));
         $generator->endAttribute('href');
         $generator->endObjectElement('location');
     } else {
         $generator->startValueElement('resource', $data->destination);
         $generator->endValueElement('resource');
     }
     $generator->startValueElement('path', $data->path);
     $generator->endValueElement('path');
     $generator->startValueElement('languageCodes', implode(',', $data->languageCodes));
     $generator->endValueElement('languageCodes');
     $generator->startValueElement('alwaysAvailable', $this->serializeBool($generator, $data->alwaysAvailable));
     $generator->endValueElement('alwaysAvailable');
     $generator->startValueElement('isHistory', $this->serializeBool($generator, $data->isHistory));
     $generator->endValueElement('isHistory');
     $generator->startValueElement('forward', $this->serializeBool($generator, $data->forward));
     $generator->endValueElement('forward');
     $generator->startValueElement('custom', $this->serializeBool($generator, $data->isCustom));
     $generator->endValueElement('custom');
     $generator->endObjectElement('UrlAlias');
 }
示例#23
0
 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
示例#24
0
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $page_id [STRING] The init data for the dataManager obj
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $sortBy, $page_id)
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     $fieldList = FormProcessor_EditPages::FORM_FIELDS;
     $fieldTypes = FormProcessor_EditPages::FORM_FIELD_TYPES;
     $displayFields = FormProcessor_EditPages::DISPLAY_FIELDS;
     parent::__construct($viewer, $formAction, $sortBy, $fieldList, $fieldTypes, $displayFields);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->page_id = $page_id;
     // figure out the important fields for the dataManager
     $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new RowManager_PageManager($page_id);
     $this->dataManager->setFieldsOfInterest($fieldsOfInterest);
     $this->formValues = $this->dataManager->getArrayOfValues();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_c4cwebsite::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_c4cwebsite::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_EditPages::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     // load the site default form link labels
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS);
 }
示例#25
0
 private function init_from_single_entry($entry)
 {
     $photo = $entry->photo;
     $url = '';
     foreach ($photo->urls->url as $one_url) {
         if ($one_url["type"] == "photopage") {
             $url = (string) $one_url;
         }
     }
     $dates = $photo->dates;
     $visibility = $photo->visibility;
     $tags = [];
     foreach ($photo->tags->tag as $one_tag) {
         $tags[] = $one_tag;
     }
     $this->entry["id"] = isset($photo["id"]) ? (string) $photo["id"] : '';
     $this->entry["url"] = $url;
     $this->entry["thumbnail"] = $this->generate_thumb_url($photo, 's');
     $this->entry["title"] = isset($photo->title) ? (string) $photo->title : '';
     $this->entry["updated_on"] = isset($dates["lastupdate"]) ? (string) $dates["lastupdate"] : null;
     $this->entry["created_on"] = isset($dates["posted"]) ? (string) $dates["posted"] : null;
     $this->entry["views"] = isset($photo["views"]) ? (string) $photo["views"] : 0;
     $this->entry["ispublic"] = isset($visibility["ispublic"]) ? !!(string) $visibility["ispublic"] : false;
     $this->entry["description"] = isset($photo->description) ? (string) $photo->description : "";
     $this->entry["tags"] = implode(" ", $tags);
 }
示例#26
0
文件: html.php 项目: jjjj222/hsinfo
function print_table($table, $attributes, $callback = NULL)
{
    $attr_list_str = implode(', ', $attributes);
    $query = "SELECT {$attr_list_str} FROM {$table}";
    $result = mysql_query($query);
    $num = @mysql_numrows($result);
    echo "<table>";
    echo "<tr>";
    foreach ($attributes as $attr) {
        echo "<th>";
        echo $attr;
        echo "</th>";
    }
    echo "</tr>";
    $i = 0;
    while ($i < $num) {
        echo "<tr>";
        foreach ($attributes as $attr) {
            echo "<td>";
            if ($callback != NULL) {
                $value = mysql_result($result, $i, $attr);
                $callback($attr, $value);
            } else {
                echo mysql_result($result, $i, $attr);
            }
            echo "</td>";
        }
        echo "</tr>";
        $i++;
    }
    echo "</table>";
    return $num;
}
示例#27
0
 /**
  * Render the field value. Handle both single and repetitive fields.
  *
  * Rendering of a single value is defined in render_single() and multiple values are concatenated by
  * separator provided by get_value_separator().
  *
  * @param bool $echo Echo the output?
  * @return string Rendered HTML.
  * @since 1.9.1
  */
 public function render($echo = false)
 {
     $field_value = $this->field->get_value();
     // Handle all fields as repetitive, we allways have array of individual field values.
     $output_values = array();
     // Optionally limit the number of rendered items
     $max_item_count = $this->get_maximum_item_count();
     $loop_limit = $max_item_count > 0 ? min($max_item_count, count($field_value)) : count($field_value);
     $is_limited_by_max_count = $loop_limit < count($field_value);
     for ($i = 0; $i < $loop_limit; ++$i) {
         $value = array_shift($field_value);
         $output_values[] = $this->render_single($value);
     }
     $output = implode($this->get_value_separator(), $output_values);
     $ellipsis = $this->get_ellipsis();
     $is_limited_by_max_total_length = $this->limit_by_maximum_total_length($output);
     $needs_separator = $is_limited_by_max_count && !$is_limited_by_max_total_length;
     $needs_ellipsis = $is_limited_by_max_count || $is_limited_by_max_total_length;
     if ($needs_separator) {
         $output .= $this->get_value_separator();
     }
     if ($needs_ellipsis) {
         $output .= $ellipsis;
     }
     if ($echo) {
         echo $output;
     }
     return $output;
 }
示例#28
0
文件: currency.php 项目: vverhun/hoho
 public function updateCurrencies()
 {
     if (extension_loaded('curl')) {
         $data = array();
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified > '" . date(strtotime('-1 day')) . "'");
         foreach ($query->rows as $result) {
             $data[] = $this->config->get('config_currency') . $result['code'] . '=X';
         }
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $content = curl_exec($ch);
         curl_close($ch);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = substr($line, 4, 3);
             $value = substr($line, 11, 6);
             if ((double) $value) {
                 $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = NOW() WHERE code = '" . $this->db->escape($currency) . "'");
             }
         }
         $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = NOW() WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
         $this->cache->delete('currency');
     }
 }
示例#29
0
 function _delete_templateinvite()
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     $msgType = '';
     JArrayHelper::toInteger($cid);
     if (count($cid)) {
         // are there one or more rows to delete?
         /*
         if (count($cid) == 1) {
         	$row = JTable::getInstance('template_invite');
         	$row->load($cid[0]);
         } else {
         	$msg = JText::sprintf('AUP_MSGSUCCESSFULLYDELETED', JText::_('AUP_RULES'), '');
         }
         */
         $query = "DELETE FROM #__alpha_userpoints_template_invite" . "\n WHERE (`id` = " . implode(' OR `id` = ', $cid) . ")";
         $db->setQuery($query);
         if (!$db->query()) {
             $msg = $db->getErrorMsg();
             $msgType = 'error';
         }
     }
     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=templateinvite', $msg, $msgType);
     JControllerLegacy::redirect();
 }
示例#30
0
 /**
  * Recursively renders the menu items (without the container tag).
  * @param array $items the menu items to be rendered recursively
  * @return string the rendering result
  */
 protected function renderItems($items)
 {
     $n = count($items);
     $lines = [];
     foreach ($items as $i => $item) {
         $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
         $tag = ArrayHelper::remove($options, 'tag', 'li');
         $class = [];
         if ($item['active']) {
             $class[] = $this->activeCssClass;
         }
         if ($i === 0 && $this->firstItemCssClass !== null) {
             $class[] = $this->firstItemCssClass;
         }
         if ($i === $n - 1 && $this->lastItemCssClass !== null) {
             $class[] = $this->lastItemCssClass;
         }
         if (!empty($class)) {
             if (empty($options['class'])) {
                 $options['class'] = implode(' ', $class);
             } else {
                 $options['class'] .= ' ' . implode(' ', $class);
             }
         }
         $menu = $this->renderItem($item);
         if (!empty($item['items'])) {
             $menu .= strtr($this->submenuTemplate, ['{show}' => $item['active'] ? "style='display: block'" : '', '{items}' => $this->renderItems($item['items'])]);
         }
         $lines[] = Html::tag($tag, $menu, $options);
     }
     return implode("\n", $lines);
 }