Ejemplo n.º 1
2
function getLocation($str)
{
    $array_size = intval(substr($str, 0, 1));
    // 拆成的行数
    $code = substr($str, 1);
    // 加密后的串
    $len = strlen($code);
    $subline_size = $len % $array_size;
    // 满字符的行数
    $result = array();
    $deurl = "";
    for ($i = 0; $i < $array_size; $i += 1) {
        if ($i < $subline_size) {
            array_push($result, substr($code, 0, ceil($len / $array_size)));
            $code = substr($code, ceil($len / $array_size));
        } else {
            array_push($result, substr($code, 0, ceil($len / $array_size) - 1));
            $code = substr($code, ceil($len / $array_size) - 1);
        }
    }
    for ($i = 0; $i < ceil($len / $array_size); $i += 1) {
        for ($j = 0; $j < count($result); $j += 1) {
            $deurl = $deurl . "" . substr($result[$j], $i, 1);
        }
    }
    return str_replace("^", "0", urldecode($deurl));
}
/**	
 * Performs payment module specific configuration validation
 * 
 * @param string &$errorMessage			- error message when return result is not true
 * 
 * @return bool 						- true if configuration is valid, false otherwise
 * 
 * 
 */
function moduleValidateConfiguration(&$errorMessage)
{
    global $providerConf;
    $commomResult = commonValidateConfiguration($errorMessage);
    if (!$commomResult) {
        return false;
    }
    if (strlen(trim($providerConf['Param_sid'])) == 0) {
        $errorMessage = '\'Account number\' field is empty';
        return false;
    }
    if (!in_array($providerConf['Param_pay_method'], array('CC', 'CK'))) {
        $errorMessage = '\'Pay method\' field has incorrect value';
        return false;
    }
    if (strlen(trim($providerConf['Param_secret_word'])) == 0) {
        $errorMessage = '\'Secret word\' field is empty';
        return false;
    }
    if (strlen(trim($providerConf['Param_secret_word'])) > 16 || strpos($providerConf['Param_secret_word'], ' ') !== false) {
        $errorMessage = '\'Secret word\' field has incorrect value';
        return false;
    }
    return true;
}
Ejemplo n.º 3
1
 function action()
 {
     if (isset($_POST['action']['save'])) {
         $fields = $_POST['fields'];
         $permissions = $fields['permissions'];
         $name = trim($fields['name']);
         $page_access = $fields['page_access'];
         if (strlen($name) == 0) {
             $this->_errors['name'] = 'This is a required field';
             return;
         } elseif ($this->_driver->roleExists($name)) {
             $this->_errors['name'] = 'A role with the name <code>' . $name . '</code> already exists.';
             return;
         }
         $sql = "INSERT INTO `tbl_members_roles` VALUES (NULL, \n\t\t\t\t\t\t\t\t\t\t\t\t'{$name}', \n\t\t\t\t\t\t\t\t\t\t\t\t" . (strlen(trim($fields['email_subject'])) > 0 ? "'" . addslashes($fields['email_subject']) . "'" : 'NULL') . ", \n\t\t\t\t\t\t\t\t\t\t\t\t" . (strlen(trim($fields['email_body'])) > 0 ? "'" . addslashes($fields['email_body']) . "'" : 'NULL') . ")";
         $this->_Parent->Database->query($sql);
         $role_id = $this->_Parent->Database->getInsertID();
         if (is_array($page_access) && !empty($page_access)) {
             foreach ($page_access as $page_id) {
                 $this->_Parent->Database->query("INSERT INTO `tbl_members_roles_page_permissions` VALUES (NULL, {$role_id}, {$page_id}, 'yes')");
             }
         }
         if (is_array($permissions) && !empty($permissions)) {
             $sql = "INSERT INTO `tbl_members_roles_event_permissions` VALUES ";
             foreach ($permissions as $event_handle => $p) {
                 foreach ($p as $action => $allow) {
                     $sql .= "(NULL,  {$role_id}, '{$event_handle}', '{$action}', '{$allow}'),";
                 }
             }
             $this->_Parent->Database->query(trim($sql, ','));
         }
         redirect(extension_members::baseURL() . 'edit/' . $role_id . '/created/');
     }
 }
 public function submitInfo()
 {
     $this->load->model("settings_model");
     // Gather the values
     $values = array('nickname' => htmlspecialchars($this->input->post("nickname")), 'location' => htmlspecialchars($this->input->post("location")));
     // Change language
     if ($this->config->item('show_language_chooser')) {
         $values['language'] = $this->input->post("language");
         if (!is_dir("application/language/" . $values['language'])) {
             die("3");
         } else {
             $this->user->setLanguage($values['language']);
             $this->plugins->onSetLanguage($this->user->getId(), $values['language']);
         }
     }
     // Remove the nickname field if it wasn't changed
     if ($values['nickname'] == $this->user->getNickname()) {
         $values = array('location' => $this->input->post("location"));
     } elseif (strlen($values['nickname']) < 4 || strlen($values['nickname']) > 14 || !preg_match("/[A-Za-z0-9]*/", $values['nickname'])) {
         die(lang("nickname_error", "ucp"));
     } elseif ($this->internal_user_model->nicknameExists($values['nickname'])) {
         die("2");
     }
     if (strlen($values['location']) > 32 && !ctype_alpha($values['location'])) {
         die(lang("location_error", "ucp"));
     }
     $this->settings_model->saveSettings($values);
     $this->plugins->onSaveSettings($this->user->getId(), $values);
     die("1");
 }
Ejemplo n.º 5
1
		/**
		 * Constructor
		 *
		 * @param string $name
		 * @param string $rname
		 * @param integer $ttl
		 * @param string $class
		 */
		function __construct($name, $value, $ttl = false, $class = "IN")
		{
			parent::__construct();
			
			$this->Type = "TXT";
			
			// Name
			if (($this->Validator->MatchesPattern($name, self::PAT_NON_FDQN) || 
				$name == "@" || 
				$name === "" || 
				$this->Validator->IsDomain($name)) && !$this->Validator->IsIPAddress(rtrim($name, "."))
			   )
				$this->Name = $name;
			else 
			{
				self::RaiseWarning("'{$name}' is not a valid name for TXT record");
				$this->Error = true;
			}
				
				
			if (strlen($value) > 255)
			{
                self::RaiseWarning("TXT record value cannot be longer than 65536 bytes");
                $this->Error = true;
			}
			else 
                $this->Value = $value;
				
			$this->TTL = $ttl;
			
			$this->Class = $class;
		}
 /**
  * 
  * get array of slide classes, between two sections.
  */
 public function getArrClasses($startText = "", $endText = "", $explodeonspace = false)
 {
     $content = $this->cssContent;
     //trim from top
     if (!empty($startText)) {
         $posStart = strpos($content, $startText);
         if ($posStart !== false) {
             $content = substr($content, $posStart, strlen($content) - $posStart);
         }
     }
     //trim from bottom
     if (!empty($endText)) {
         $posEnd = strpos($content, $endText);
         if ($posEnd !== false) {
             $content = substr($content, 0, $posEnd);
         }
     }
     //get styles
     $lines = explode("\n", $content);
     $arrClasses = array();
     foreach ($lines as $key => $line) {
         $line = trim($line);
         if (strpos($line, "{") === false) {
             continue;
         }
         //skip unnessasary links
         if (strpos($line, ".caption a") !== false) {
             continue;
         }
         if (strpos($line, ".tp-caption a") !== false) {
             continue;
         }
         //get style out of the line
         $class = str_replace("{", "", $line);
         $class = trim($class);
         //skip captions like this: .tp-caption.imageclass img
         if (strpos($class, " ") !== false) {
             if (!$explodeonspace) {
                 continue;
             } else {
                 $class = explode(',', $class);
                 $class = $class[0];
             }
         }
         //skip captions like this: .tp-caption.imageclass:hover, :before, :after
         if (strpos($class, ":") !== false) {
             continue;
         }
         $class = str_replace(".caption.", ".", $class);
         $class = str_replace(".tp-caption.", ".", $class);
         $class = str_replace(".", "", $class);
         $class = trim($class);
         $arrWords = explode(" ", $class);
         $class = $arrWords[count($arrWords) - 1];
         $class = trim($class);
         $arrClasses[] = $class;
     }
     sort($arrClasses);
     return $arrClasses;
 }
Ejemplo n.º 7
1
 public function afterExample(ExampleEvent $event)
 {
     $total = $this->stats->getEventsCount();
     $counts = $this->stats->getCountsHash();
     $percents = array_map(function ($count) use($total) {
         return round($count / ($total / 100), 0);
     }, $counts);
     $lengths = array_map(function ($percent) {
         return round($percent / 2, 0);
     }, $percents);
     $size = 50;
     asort($lengths);
     $progress = array();
     foreach ($lengths as $status => $length) {
         $text = $percents[$status] . '%';
         $length = $size - $length >= 0 ? $length : $size;
         $size = $size - $length;
         if ($length > strlen($text) + 2) {
             $text = str_pad($text, $length, ' ', STR_PAD_BOTH);
         } else {
             $text = str_pad('', $length, ' ');
         }
         $progress[$status] = sprintf("<{$status}-bg>%s</{$status}-bg>", $text);
     }
     krsort($progress);
     $this->printException($event, 2);
     $this->io->writeTemp(implode('', $progress) . ' ' . $total);
 }
Ejemplo n.º 8
1
function search_ac_init(&$a)
{
    if (!local_channel()) {
        killme();
    }
    $start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
    $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
    $search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
    if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
        $search = $_REQUEST['query'];
    }
    // Priority to people searches
    if ($search) {
        $people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
        $tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
    }
    $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
    $results = array();
    if ($r) {
        foreach ($r as $g) {
            $results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
        }
    }
    $r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
    if (count($r)) {
        foreach ($r as $g) {
            $results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
        }
    }
    header("content-type: application/json");
    $o = array('start' => $start, 'count' => $count, 'items' => $results);
    echo json_encode($o);
    logger('search_ac: ' . print_r($x, true));
    killme();
}
function buildjs()
{
    $t = $_GET["t"];
    $time = time();
    $MEPOST = 0;
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $page = CurrentPageName();
    $array = unserialize(@file_get_contents($GLOBALS["CACHEFILE"]));
    $prc = intval($array["POURC"]);
    $title = $tpl->javascript_parse_text($array["TEXT"]);
    $md5file = trim(md5_file($GLOBALS["LOGSFILES"]));
    echo "// CACHE FILE: {$GLOBALS["CACHEFILE"]} {$prc}%\n";
    echo "// LOGS FILE: {$GLOBALS["LOGSFILES"]} - {$md5file} " . strlen($md5file) . "\n";
    if ($prc == 0) {
        if (strlen($md5file) < 32) {
            echo "\n\t// PRC = {$prc} ; md5file={$md5file}\n\tfunction Start{$time}(){\n\t\t\tif(!RTMMailOpen()){return;}\n\t\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
            return;
        }
    }
    if ($md5file != $_GET["md5file"]) {
        echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    if ($prc > 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    if ($prc == 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\t\$('#SQUID_ARTICA_QUOTA_RULES').flexReload();\n\t\tRTMMailHide();\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
}
Ejemplo n.º 10
1
 /**
  * Generates a 'List' element.
  *
  * @param array   $items   Array with the elements of the list
  * @param boolean $ordered Specifies ordered/unordered list; default unordered
  * @param array   $attribs Attributes for the ol/ul tag.
  * @return string The list XHTML.
  */
 public function htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
 {
     if (!is_array($items)) {
         #require_once 'Zend/View/Exception.php';
         $e = new Zend_View_Exception('First param must be an array');
         $e->setView($this->view);
         throw $e;
     }
     $list = '';
     foreach ($items as $item) {
         if (!is_array($item)) {
             if ($escape) {
                 $item = $this->view->escape($item);
             }
             $list .= '<li>' . $item . '</li>' . self::EOL;
         } else {
             if (6 < strlen($list)) {
                 $list = substr($list, 0, strlen($list) - 6) . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
             } else {
                 $list .= '<li>' . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
             }
         }
     }
     if ($attribs) {
         $attribs = $this->_htmlAttribs($attribs);
     } else {
         $attribs = '';
     }
     $tag = 'ul';
     if ($ordered) {
         $tag = 'ol';
     }
     return '<' . $tag . $attribs . '>' . self::EOL . $list . '</' . $tag . '>' . self::EOL;
 }
Ejemplo n.º 11
1
 /**
  * Retrieve filter array
  *
  * @param Enterprise_Search_Model_Resource_Collection $collection
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string|array $value
  * @return array
  */
 protected function _getSearchParam($collection, $attribute, $value)
 {
     if (!is_string($value) && empty($value) || is_string($value) && strlen(trim($value)) == 0 || is_array($value) && isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
         return array();
     }
     if (!is_array($value)) {
         $value = array($value);
     }
     $field = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute, 'nav');
     if ($attribute->getBackendType() == 'datetime') {
         $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
         foreach ($value as &$val) {
             if (!is_empty_date($val)) {
                 $date = new Zend_Date($val, $format);
                 $val = $date->toString(Zend_Date::ISO_8601) . 'Z';
             }
         }
         unset($val);
     }
     if (empty($value)) {
         return array();
     } else {
         return array($field => $value);
     }
 }
Ejemplo n.º 12
1
 function Create($proto)
 {
     if ($this->debug) {
         e("SAMConnection.Create(proto={$proto})");
     }
     $rc = false;
     /* search the PHP config for a factory to use...    */
     $x = get_cfg_var('sam.factory.' . $proto);
     if ($this->debug) {
         t('SAMConnection.Create() get_cfg_var() "' . $x . '"');
     }
     /* If there is no configuration (php.ini) entry for this protocol, default it.  */
     if (strlen($x) == 0) {
         /* for every protocol other than MQTT assume we will use XMS    */
         if ($proto != 'mqtt') {
             $x = 'xms';
         } else {
             $x = 'mqtt';
         }
     }
     /* Invoke the chosen factory to create a real connection object...   */
     $x = 'sam_factory_' . $x . '.php';
     if ($this->debug) {
         t("SAMConnection.Create() calling factory - {$x}");
     }
     $rc = (include $x);
     if ($this->debug && $rc) {
         t('SAMConnection.Create() rc = ' . get_class($rc));
     }
     if ($this->debug) {
         x('SAMConnection.Create()');
     }
     return $rc;
 }
 public static function validatePassword(User $user, $value)
 {
     $length = strlen($value);
     $config = $user->getMain()->getConfig();
     $minLength = $config->getNested("Registration.MinLength", 4);
     if ($length < $minLength) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordUnderflow", "too short"));
         return false;
     }
     $maxLength = $config->getNested("Registration.MaxLength", -1);
     if ($maxLength !== -1 and $length > $maxLength) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordOverflow", "too long"));
         return false;
     }
     if ($config->getNested("Registration.BanPureLetters", false) and preg_match('/^[a-z]+$/i', $value)) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordPureLetters", "only letters"));
         return false;
     }
     if ($config->getNested("Registration.BanPureNumbers", false) and preg_match('/^[0-9]+$/', $value)) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordPureNumbers", "only numbers"));
         return false;
     }
     if ($config->getNested("Registration.DisallowSlashes", true) and $value[0] === "/") {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordSlashes", "do not start with slashes"));
         return false;
     }
     return true;
 }
Ejemplo n.º 14
1
 /**
  * displays the topics on a forums
  * @return [type] [description]
  */
 public function action_list()
 {
     //in case performing a search
     if (strlen($search = core::get('search')) >= 3) {
         return $this->action_search($search);
     }
     $this->template->styles = array('css/forums.css' => 'screen');
     $this->template->scripts['footer'][] = 'js/forums.js';
     $forum = new Model_Forum();
     $forum->where('seoname', '=', $this->request->param('forum', NULL))->cached()->limit(1)->find();
     if ($forum->loaded()) {
         //template header
         $this->template->title = $forum->name . ' - ' . __('Forum');
         $this->template->meta_description = $forum->description;
         Breadcrumbs::add(Breadcrumb::factory()->set_title($forum->name));
         //count all topics
         $count = DB::select(array(DB::expr('COUNT("id_post")'), 'count'))->from(array('posts', 'p'))->where('id_post_parent', 'IS', NULL)->where('id_forum', '=', $forum->id_forum)->cached()->execute();
         $count = array_keys($count->as_array('count'));
         $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => isset($count[0]) ? $count[0] : 0))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'forum' => $this->request->param('forum')));
         $pagination->title($this->template->title);
         //getting all the topic for the forum
         $topics = DB::select('p.*')->select(array(DB::select(DB::expr('COUNT("id_post")'))->from(array('posts', 'pc'))->where('pc.id_post_parent', '=', DB::expr(Database::instance('default')->table_prefix() . 'p.id_post'))->where('pc.id_forum', '=', $forum->id_forum)->where('pc.status', '=', Model_Post::STATUS_ACTIVE)->group_by('pc.id_post_parent'), 'count_replies'))->select(array(DB::select('ps.created')->from(array('posts', 'ps'))->where('ps.id_post', '=', DB::expr(Database::instance('default')->table_prefix() . 'p.id_post'))->or_where('ps.id_post_parent', '=', DB::expr(Database::instance('default')->table_prefix() . 'p.id_post'))->where('ps.id_forum', '=', $forum->id_forum)->where('ps.status', '=', Model_Post::STATUS_ACTIVE)->order_by('ps.created', 'DESC')->limit(1), 'last_message'))->from(array('posts', 'p'))->where('id_post_parent', 'IS', NULL)->where('id_forum', '=', $forum->id_forum)->where('status', '=', Model_Post::STATUS_ACTIVE)->order_by('last_message', 'DESC')->limit($pagination->items_per_page)->offset($pagination->offset)->as_object()->execute();
         $pagination = $pagination->render();
         $this->template->bind('content', $content);
         $this->template->content = View::factory('pages/forum/list', array('topics' => $topics, 'forum' => $forum, 'pagination' => $pagination));
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
Ejemplo n.º 15
0
    /**
     * A generic find function for schedules. As parameters, do:
     * 
     * $params = array( 's.depicao' => 'value',
     *					's.arricao' => array ('multiple', 'values'),
     *	);
     * 
     * Syntax is ('s.columnname' => 'value'), where value can be
     *	an array is multiple values, or with a SQL wildcard (%) 
     *  if that's what is desired.
     * 
     * Columns from the schedules table should be prefixed by 's.',
     * the aircraft table as 'a.'
     * 
     * You can also pass offsets ($start and $count) in order to 
     * facilitate pagination
     * 
     * @tutorial http://docs.phpvms.net/media/development/searching_and_retriving_schedules
     */
    public static function findSchedules($params, $count = '', $start = '')
    {
        $sql = 'SELECT s.*, 
					a.id as aircraftid, a.name as aircraft, a.registration,
					a.minrank as aircraft_minrank, a.ranklevel as aircraftlevel,
					dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,
					arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng
				FROM ' . TABLE_PREFIX . 'schedules AS s
				LEFT JOIN ' . TABLE_PREFIX . 'airports AS dep ON dep.icao = s.depicao
				LEFT JOIN ' . TABLE_PREFIX . 'airports AS arr ON arr.icao = s.arricao
				LEFT JOIN ' . TABLE_PREFIX . 'aircraft AS a ON a.id = s.aircraft ';
        /* Build the select "WHERE" based on the columns passed, this is a generic function */
        $sql .= DB::build_where($params);
        // Order matters
        if (Config::Get('SCHEDULES_ORDER_BY') != '') {
            $sql .= ' ORDER BY ' . Config::Get('SCHEDULES_ORDER_BY');
        }
        if (strlen($count) != 0) {
            $sql .= ' LIMIT ' . $count;
        }
        if (strlen($start) != 0) {
            $sql .= ' OFFSET ' . $start;
        }
        $ret = DB::get_results($sql);
        return $ret;
    }
function F10984563791DEB243A5DC2A8AC17FB84($RD7A9632D7A0B3B4AC99AAFB2107A2613)
{
    if (F12DE84D0D1210BE74C53778CF385AA4D($RD7A9632D7A0B3B4AC99AAFB2107A2613)) {
        return true;
    }
    $RD7A9632D7A0B3B4AC99AAFB2107A2613 = FC718EAC1D5F164063CBA5FB022329FC7($RD7A9632D7A0B3B4AC99AAFB2107A2613);
    $RB5719367F67DC84F064575F4E19A2606 = getLicense();
    $RFDFD105B00999E2642068D5711B49D5D = substr($RD7A9632D7A0B3B4AC99AAFB2107A2613, 0, 3);
    $RA6CC906CDD1BAB99B7EB044E98D68FAE = substr($RD7A9632D7A0B3B4AC99AAFB2107A2613, -3, 3);
    $R8439A88C56A38281A17AE2CE034DB5B7 = substr($RB5719367F67DC84F064575F4E19A2606, 0, 3);
    $R254A597F43FF6E1BE7E3C0395E9409D4 = substr($RB5719367F67DC84F064575F4E19A2606, 3, 3);
    $RDE2A352768EABA0E164B92F7ACA37DEE = substr($RB5719367F67DC84F064575F4E19A2606, -3, 3);
    $R254A597F43FF6E1BE7E3C0395E9409D4 = FCE67EB692054EBB3F415F8AF07562D82($R254A597F43FF6E1BE7E3C0395E9409D4, 3);
    $RDE2A352768EABA0E164B92F7ACA37DEE = FCE67EB692054EBB3F415F8AF07562D82($RDE2A352768EABA0E164B92F7ACA37DEE, 3);
    $R705EE0B4D45EEB1BC55516EB53DF7BCE = array('A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13, 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, '0' => 0);
    $RA7B9A383688A89B5498FC84118153069 = strlen($RD7A9632D7A0B3B4AC99AAFB2107A2613);
    $RA5694D3559F011A29A639C0B10305B51 = 0;
    for ($RA09FE38AF36F6839F4A75051DC7CEA25 = 0; $RA09FE38AF36F6839F4A75051DC7CEA25 < $RA7B9A383688A89B5498FC84118153069; $RA09FE38AF36F6839F4A75051DC7CEA25++) {
        $RF5687F6BBE9EC10202A32FA6C037D42B = substr($RD7A9632D7A0B3B4AC99AAFB2107A2613, $RA09FE38AF36F6839F4A75051DC7CEA25, 1);
        $RA5694D3559F011A29A639C0B10305B51 = $RA5694D3559F011A29A639C0B10305B51 + $R705EE0B4D45EEB1BC55516EB53DF7BCE[$RF5687F6BBE9EC10202A32FA6C037D42B];
    }
    if ($RA5694D3559F011A29A639C0B10305B51 != $R8439A88C56A38281A17AE2CE034DB5B7 - 25) {
        return false;
    } else {
        if (strcmp($RFDFD105B00999E2642068D5711B49D5D, $R254A597F43FF6E1BE7E3C0395E9409D4) != 0) {
            return false;
        } else {
            if (strcmp($RA6CC906CDD1BAB99B7EB044E98D68FAE, $RDE2A352768EABA0E164B92F7ACA37DEE) != 0) {
                return false;
            } else {
                return true;
            }
        }
    }
}
Ejemplo n.º 17
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $linked_page_is_set = 0 < strlen($instance['url_to_page']);
     $linked_page_id_is_set = 0 < (int) $instance['sc_id_for_url'];
     $shortcode = '[event-list show_nav=false';
     $shortcode .= ' num_events="' . $instance['num_events'] . '"';
     $shortcode .= ' title_length=' . $instance['title_length'];
     $shortcode .= ' show_starttime=' . $instance['show_starttime'];
     $shortcode .= ' show_location=' . $instance['show_location'];
     $shortcode .= ' location_length=' . $instance['location_length'];
     $shortcode .= ' show_details=' . $instance['show_details'];
     $shortcode .= ' details_length=' . $instance['details_length'];
     if ($linked_page_is_set && $linked_page_id_is_set) {
         $shortcode .= ' link_to_event=' . $instance['link_to_event'];
         $shortcode .= ' url_to_page="' . $instance['url_to_page'] . '"';
         $shortcode .= ' sc_id_for_url=' . $instance['sc_id_for_url'];
     } else {
         $shortcode .= ' link_to_event=false';
     }
     $shortcode .= ' cat_filter="' . $instance['category'] . '"';
     $shortcode .= ']';
     echo do_shortcode($shortcode);
     if ('true' === $instance['link_to_page'] && $linked_page_is_set) {
         echo '<div style="clear:both"><a title="' . $instance['link_to_page_caption'] . '" href="' . $instance['url_to_page'] . '">' . $instance['link_to_page_caption'] . '</a></div>';
     }
     echo $after_widget;
 }
 /**
  * {@inheritdoc}
  */
 public function extract($command)
 {
     $className = substr(strrchr(get_class($command), '\\'), 1);
     return preg_replace_callback('/(^|[a-z])([A-Z])/', function ($s) {
         return strtolower(strlen($s[1]) ? "{$s['1']}_{$s['2']}" : "{$s['2']}");
     }, $className);
 }
Ejemplo n.º 19
0
 private function formatPath($path)
 {
     $root = realpath(__DIR__ . '/../../../');
     $path = realpath($path);
     $relative = substr($path, strlen($root) + 1);
     return preg_replace('~/([a-z0-9-]+)(\\.[a-z0-9]+)?$~ims', '/<fg=blue>$1</fg=blue>$2', $relative);
 }
Ejemplo n.º 20
0
 /**
  * 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;
 }
Ejemplo n.º 21
0
 /**
  * Compute string length of only visible characters
  *
  * @param $string
  *
  * @return int
  */
 public static function getVisibleStringLength($string)
 {
     // remove escape characters
     $pattern = '#' . static::ESCAPE_CHARACTER_REGEX . '#';
     $cleanString = preg_replace($pattern, '', $string);
     return strlen($cleanString);
 }
Ejemplo n.º 22
0
 /**
  * Cria a imagem apartir dos dados do Sprite.
  */
 public function createImage()
 {
     $img = imagecreatetruecolor($this->width, $this->height);
     //http://in.php.net/manual/en/function.imagecreatetruecolor.php
     imagecolortransparent($img, imagecolorallocatealpha($img, $this->palette[0]['red'], $this->palette[0]['green'], $this->palette[0]['blue'], $this->palette[0]['alpha']));
     $i = 0;
     $p = 0;
     while ($i < strlen($this->data)) {
         $b = ord($this->data[$i]);
         //http://in.php.net/manual/en/function.ord.php
         if ($b == 0) {
             $i++;
             $dest = $p + ord($this->data[$i]);
             $color = imagecolorallocatealpha($img, $this->palette[0]['red'], $this->palette[0]['green'], $this->palette[0]['blue'], $this->palette[0]['alpha']);
             //http://in.php.net/manual/en/function.imagecolorallocatealpha.php
             for ($p; $p < $dest; $p++) {
                 imagesetpixel($img, $p % $this->width, $p / $this->width, $color);
             }
         } else {
             $color = imagecolorallocatealpha($img, $this->palette[$b]['red'], $this->palette[$b]['green'], $this->palette[$b]['blue'], $this->palette[$b]['alpha']);
             imagesetpixel($img, $p % $this->width, $p / $this->width, $color);
             //http://in.php.net/manual/en/function.imagesetpixel.php
             $p++;
         }
         $i++;
     }
     return $img;
 }
Ejemplo n.º 23
0
function mytabs_blockShow($pageid, $tabid, $placement = '', $remove = '')
{
    $block = array();
    $visblocks = array();
    $blocks_handler = xoops_getmodulehandler('pageblock', 'mytabs');
    $blocks = $blocks_handler->getBlocks($pageid, $tabid, $placement, $remove);
    $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
    foreach (array_keys($blocks) as $key) {
        foreach ($blocks[$key] as $thisblock) {
            if ($thisblock->isVisible() && array_intersect($thisblock->getVar('groups'), $groups)) {
                $visblocks[] = $thisblock;
            }
        }
    }
    $count = count($visblocks);
    for ($i = 0; $i < $count; $i++) {
        $logger_name = $visblocks[$i]->getVar('title') . "(" . $visblocks[$i]->getVar('pageblockid') . ")";
        $GLOBALS['xoopsLogger']->startTime($logger_name);
        $thisblock = $visblocks[$i]->render($GLOBALS['xoopsTpl'], $tabid . '_' . $visblocks[$i]->getVar('pageblockid'));
        if ($thisblock != false) {
            if (strlen($thisblock['title']) > 0) {
                if ($thisblock['title'][0] == '-') {
                    $thisblock['title'] = '';
                }
            }
            $block[] = $thisblock;
        }
        $GLOBALS['xoopsLogger']->stopTime($logger_name);
    }
    return $block;
}
 /**
  * <code>inputs</code> should consist of two (three) elements, the
  * original name of the database element and the method for
  * generating the name.
  * The optional third element may contain a prefix that will be
  * stript from name prior to generate the resulting name.
  * There are currently three methods:
  * <code>CONV_METHOD_NOCHANGE</code> - xml names are converted
  * directly to php names without modification.
  * <code>CONV_METHOD_UNDERSCORE</code> will capitalize the first
  * letter, remove underscores, and capitalize each letter before
  * an underscore.  All other letters are lowercased. "phpname"
  * works the same as the <code>CONV_METHOD_PHPNAME</code> method
  * but will not lowercase any characters.
  *
  * @param      inputs list expected to contain two (optional: three) parameters,
  * element 0 contains name to convert, element 1 contains method for conversion,
  * optional element 2 contains prefix to be striped from name
  * @return The generated name.
  * @see        NameGenerator
  */
 public function generateName($inputs)
 {
     $schemaName = $inputs[0];
     $method = $inputs[1];
     if (count($inputs) > 2) {
         $prefix = $inputs[2];
         if ($prefix != '' && substr($schemaName, 0, strlen($prefix)) == $prefix) {
             $schemaName = substr($schemaName, strlen($prefix));
         }
     }
     $phpName = null;
     switch ($method) {
         case self::CONV_METHOD_CLEAN:
             $phpName = $this->cleanMethod($schemaName);
             break;
         case self::CONV_METHOD_PHPNAME:
             $phpName = $this->phpnameMethod($schemaName);
             break;
         case self::CONV_METHOD_NOCHANGE:
             $phpName = $this->nochangeMethod($schemaName);
             break;
         case self::CONV_METHOD_UNDERSCORE:
         default:
             $phpName = $this->underscoreMethod($schemaName);
     }
     return $phpName;
 }
Ejemplo n.º 25
0
 function autocode_on_history()
 {
     $kode = "";
     $query = "SELECT MAX(`id`) FROM `khusus_kas_bank` WHERE DATE(`tgl_input`) = '" . date("Y-m-d") . "';";
     if ($result = $this->runQuery($query)) {
         $rs = $result->fetch_array();
         if ($rs[0] == null) {
             $kode = "KKB" . date("ymd") . "0001";
         } else {
             $lastCode = substr($rs[0], 9, 4);
             $newCode = $lastCode + 1;
             switch (strlen($newCode)) {
                 case 1:
                     $kode = "KKB" . date("ymd") . "000" . $newCode;
                     break;
                 case 2:
                     $kode = "KKB" . date("ymd") . "00" . $newCode;
                     break;
                 case 3:
                     $kode = "KKB" . date("ymd") . "0" . $newCode;
                     break;
                 case 4:
                     $kode = "KKB" . date("ymd") . $newCode;
                     break;
             }
         }
     }
     return $kode;
 }
 /**
  * Render the information header for the view
  * 
  * @param string $title
  * @param string $title
  */
 public function writeInfo($title, $subtitle, $description = false)
 {
     echo wordwrap(strtoupper($title), 100) . "\n";
     echo wordwrap($subtitle, 100) . "\n";
     echo str_repeat('-', min(100, max(strlen($title), strlen($subtitle)))) . "\n";
     echo wordwrap($description, 100) . "\n\n";
 }
 /**
  * Test that the daemon is correctly handling requests and PSR-7 and
  * HttpFoundation responses with large param records and message bodies.
  */
 public function testHandler()
 {
     $testData = $this->createTestData();
     // Create test environment
     $callbackGenerator = function ($response) use($testData) {
         return function (RequestInterface $request) use($response, $testData) {
             $this->assertEquals($testData['requestParams'], $request->getParams());
             $this->assertEquals($testData['requestBody'], stream_get_contents($request->getStdin()));
             return $response;
         };
     };
     $scenarios = [['responseKey' => 'symfonyResponse', 'rawResponseKey' => 'rawSymfonyResponse'], ['responseKey' => 'psr7Response', 'rawResponseKey' => 'rawPsr7Response']];
     foreach ($scenarios as $scenario) {
         $callback = $callbackGenerator($testData[$scenario['responseKey']]);
         $context = $this->createTestingContext($callback);
         $requestId = 1;
         $context['clientWrapper']->writeRequest($requestId, $testData['requestParams'], $testData['requestBody']);
         do {
             $context['handler']->ready();
         } while (!$context['connection']->isClosed());
         $rawResponse = $context['clientWrapper']->readResponse($this, $requestId);
         $expectedRawResponse = $testData[$scenario['rawResponseKey']];
         // Check response
         $this->assertEquals(strlen($expectedRawResponse), strlen($rawResponse));
         $this->assertEquals($expectedRawResponse, $rawResponse);
         // Clean up
         fclose($context['sockets'][0]);
     }
 }
Ejemplo n.º 28
0
function quick_dump($string)
{
    $result = '';
    $exa = '';
    $cont = 0;
    for ($i = 0; $i <= strlen($string) - 1; $i++) {
        if (ord($string[$i]) <= 32 | ord($string[$i]) > 126) {
            $result .= "  .";
        } else {
            $result .= "  " . $string[$i];
        }
        if (strlen(dechex(ord($string[$i]))) == 2) {
            $exa .= " " . dechex(ord($string[$i]));
        } else {
            $exa .= " 0" . dechex(ord($string[$i]));
        }
        $cont++;
        if ($cont == 15) {
            $cont = 0;
            $result .= "\r\n";
            $exa .= "\r\n";
        }
    }
    return $exa . "\r\n" . $result;
}
 protected function renderConfigurationSecret($value)
 {
     if (strlen($value)) {
         return str_repeat('*', strlen($value));
     }
     return '';
 }
Ejemplo n.º 30
-6
 function procesar()
 {
     toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
     toba::logger_ws()->set_checkpoint();
     set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
     $this->validar_componente();
     //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
     $clave = array();
     $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
     $clave['componente'] = $this->info['objetos'][0]['objeto'];
     list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
     agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
     $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
     $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
     $sufijo = 'op__';
     $metodos = array();
     $reflexion = new ReflectionClass($clase);
     foreach ($reflexion->getMethods() as $metodo) {
         if (strpos($metodo->name, $sufijo) === 0) {
             $servicio = substr($metodo->name, strlen($sufijo));
             $prefijo = $wsdl ? '' : '_';
             $metodos[$servicio] = $prefijo . $metodo->name;
         }
     }
     $opciones = array();
     $opciones['serviceName'] = $this->info['basica']['item'];
     $opciones['classes'][$clase]['operations'] = $metodos;
     $opciones = array_merge($opciones, $opciones_extension);
     $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
     $opciones['classes'][$clase]['args'] = array($datos);
     toba::logger_ws()->set_checkpoint();
     $service = new WSService($opciones);
     $service->reply();
     $this->log->debug("Fin de servicio web", 'toba');
 }