Esempio n. 1
0
 /**
  * Converts an XML url or string to a PHP array format
  *
  * @static
  * @access public
  * @param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which.
  * @return array Parsed XML
  * @throws BadEntryError
  * @throws DependencyError
  * @throws HookError
  * @throws XMLError
  */
 public static function load($data)
 {
     $http = HTTP::getDefaultInstance();
     if (!function_exists('simplexml_load_string')) {
         throw new DependencyError("SimpleXML", "http://us.php.net/manual/en/book.simplexml.php");
     }
     libxml_use_internal_errors(true);
     if (in_string("<?xml", $data)) {
         $xmlout = $data;
     } else {
         $xmlout = $http->get($data);
     }
     Hooks::runHook('PreSimpleXMLLoad', array(&$xmlout));
     $xml = simplexml_load_string($xmlout);
     Hooks::runHook('PostSimpleXMLLoad', array(&$xml));
     if (!$xml) {
         foreach (libxml_get_errors() as $error) {
             throw new XMLError($error);
         }
     }
     $outArr = array();
     $namespaces = $xml->getNamespaces(true);
     $namespaces['default'] = '';
     self::recurse($xml, $outArr, $namespaces);
     libxml_clear_errors();
     return $outArr;
 }
Esempio n. 2
0
 public static function getBlameResult($wiki, $article, $nofollowredir, $text)
 {
     try {
         $site = Peachy::newWiki(null, null, null, 'http://' . $wiki . '/w/api.php');
     } catch (Exception $e) {
         return null;
     }
     $pageClass = $site->initPage($article, null, !$nofollowredir);
     $title = $pageClass->get_title();
     $history = $pageClass->history(null, 'older', true);
     $revs = array();
     foreach ($history as $id => $rev) {
         if ($id + 1 == count($history)) {
             if (in_string($text, $rev['*'], true)) {
                 $revs[] = self::parseRev($rev, $wiki, $title);
             }
         } else {
             if (in_string($text, $rev['*'], true) && !in_string($text, $history[$id + 1]['*'], true)) {
                 $revs[] = self::parseRev(${$rev}, $wiki, $title);
             }
         }
         unset($rev);
         //Saves memory
     }
     return $revs;
 }
Esempio n. 3
0
function p11n($locale)
{
    $args = func_get_args();
    $locale = array_shift($args);
    $num_args = count($args);
    if ($num_args == 0) {
        return $locale;
    }
    if (in_string('|', $locale)) {
        $n = NULL;
        $locale = explode('|', $locale);
        $count = count($locale);
        foreach ($locale as $i => &$l) {
            if (preg_match('/^\\{(\\d+?)\\}|\\[(\\d+?),(\\d+?|Inf)\\]/', $l, $match)) {
                $n = end($match);
                if ($n == 'Inf') {
                    break;
                }
            } else {
                if (is_null($n)) {
                    $l = '[0,1]' . $l;
                    $n = 1;
                } else {
                    if ($i == $count - 1) {
                        $l = '[' . ++$n . ',Inf]' . $l;
                    } else {
                        $l = '{' . ++$n . '}' . $l;
                    }
                }
            }
        }
        unset($l);
        foreach ($locale as $l) {
            if (preg_match('/^\\{(\\d+?)\\}(.*)/', $l, $match) && $args[0] == $match[1]) {
                $locale = $match[2];
                unset($args[0]);
                break;
            } else {
                if (preg_match('/^\\[(\\d+?),(\\d+?|Inf)\\](.*)/', $l, $match) && $args[0] >= $match[1] && ($match[2] == 'Inf' || $args[0] <= $match[2])) {
                    $locale = $match[3];
                    unset($args[0]);
                    break;
                }
            }
        }
        if (is_array($locale)) {
            return FALSE;
        }
    }
    array_unshift($args, $locale);
    return call_user_func_array('sprintf', $args);
}
Esempio n. 4
0
	public static function callFunction( $name, $args, $context, $line ) {
		if( !in_string( '_', $name ) ) {
			$context->error( 'unknownfunction', $line, array( $name ) );
		}

		list( $prefix, $realName ) = explode( '_', $name, 2 );
		$module = self::getModule( $prefix );
		if( !$module || !in_array( $realName, $module->getFunctionList() ) ) {
			$context->error( 'unknownfunction', $line, array( $name ) );
		}

		return $module->callFunction( $realName, $args, $context, $line );
	}
Esempio n. 5
0
 /**
  * Search for hook functions and run them if defined
  *
  * @param string $hook_name Name of hook to search for
  * @param array $args Arguments to pass to the hook function
  * @throws HookError
  * @throws BadEntryError
  * @return mixed Output of hook function
  */
 public static function runHook($hook_name, $args = array())
 {
     global $pgHooks;
     if (!isset($pgHooks[$hook_name])) {
         return null;
     }
     if (!is_array($pgHooks[$hook_name])) {
         throw new HookError("Hook assignment for event `{$hook_name}` is not an array. Syntax is " . '$pgHooks[\'hookname\'][] = "hook_function";');
     }
     $method = null;
     foreach ($pgHooks[$hook_name] as $function) {
         if (is_array($function)) {
             if (count($function) < 2) {
                 throw new HookError("Not enough parameters in array specified for `{$hook_name}` hook");
             } elseif (is_object($function[0])) {
                 $object = $function[0];
                 $method = $function[1];
                 if (count($function) > 2) {
                     $data = $function[2];
                 }
             } elseif (is_string($function[0])) {
                 $method = $function[0];
                 if (count($function) > 1) {
                     $data = $function[1];
                 }
             }
         } elseif (is_string($function)) {
             $method = $function;
         }
         if (isset($data)) {
             $args = array_merge(array($data), $args);
         }
         if (isset($object)) {
             $fncarr = array($object, $method);
         } elseif (is_string($method) && in_string("::", $method)) {
             $fncarr = explode("::", $method);
         } else {
             $fncarr = $method;
         }
         //is_callable( $fncarr ); //Apparently this is a bug. Thanks, MW!
         if (!is_callable($fncarr)) {
             throw new BadEntryError("MissingFunction", "Hook function {$fncarr} was not defined");
         }
         $hookRet = call_user_func_array($fncarr, $args);
         if (!is_null($hookRet)) {
             return $hookRet;
         }
     }
 }
function apply_labels($dbh, $id, $user)
{
    $labels = null;
    $label_data = $dbh->prepare("SELECT * FROM cm_messages WHERE id = '{$id}'");
    $label_data->execute();
    $ld = $label_data->fetch(PDO::FETCH_ASSOC);
    if (in_string($user, $ld['archive'])) {
        $labels .= '<span class="label_archive">Archive</span>';
    } else {
        $labels .= '<span class="label_inbox">Inbox</span>';
    }
    if ($ld['from'] == $user) {
        $labels .= '<span class="label_sent">Sent</span>';
    }
    return $labels;
}
 public function jsonSerialize()
 {
     $fields = [];
     $reflection = new \ReflectionClass($this);
     foreach ($reflection->getMethods() as $method) {
         if (substr($method->getName(), 0, 3) !== 'get') {
             continue;
         }
         if (in_string("@JsonIgnore", $method->getDocComment())) {
             continue;
         }
         $underscore = preg_replace('/([a-z])([A-Z])/', '$1_$2', substr($method->getName(), 3));
         $fields[strtolower($underscore)] = $method->invoke($this);
     }
     return $fields;
 }
Esempio n. 8
0
 public function getQuotesFromSearch($search, $regex = false)
 {
     $retArr = array();
     foreach ($this->quotes as $id => $quote) {
         if ($regex) {
             if (preg_match($search, html_entity_decode($quote))) {
                 $retArr[$id + 1] = $quote;
             }
         } else {
             if (in_string($search, $quote, false) === true) {
                 $retArr[$id + 1] = $quote;
             }
         }
     }
     return $retArr;
 }
Esempio n. 9
0
 public function __construct()
 {
     parent::__construct();
     $this->_configs['base_url'] = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
     $this->_configs['request_url'] = $_SERVER['REQUEST_URI'] != $this->_configs['base_url'] ? substr($_SERVER['REQUEST_URI'], strlen($this->_configs['base_url'])) : 'index.html';
     $this->_configs['extension_url'] = extension($this->_configs['request_url'], $this->_configs['request_url']);
     $this->_configs['ajax_header'] = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
     $ext = extension($url = !empty($_GET['request_url']) ? $_GET['request_url'] : $this->_configs['request_url'], $url);
     $this->_configs['segments_url'] = explode('/', rtrim(substr($url, 0, -strlen($ext)), '.'));
     if ($this->_configs['segments_url'][0] == 'admin') {
         $this->_configs['admin_url'] = TRUE;
     }
     if (empty($this->_configs['admin_url']) && $this->_configs['segments_url'][0] == 'ajax' || !empty($this->_configs['admin_url']) && isset($this->_configs['segments_url'][1]) && $this->_configs['segments_url'][1] == 'ajax') {
         $this->_configs['ajax_url'] = TRUE;
     }
     if (is_null($configs = NeoFrag::loader()->db->select('site, lang, name, value, type')->from('nf_settings')->get())) {
         exit('Database is empty');
     }
     foreach ($configs as $setting) {
         if ($setting['type'] == 'array') {
             $value = unserialize(utf8_html_entity_decode($setting['value']));
         } else {
             if ($setting['type'] == 'list') {
                 $value = explode('|', $setting['value']);
             } else {
                 if ($setting['type'] == 'bool') {
                     $value = (bool) $setting['value'];
                 } else {
                     if ($setting['type'] == 'int') {
                         $value = (int) $setting['value'];
                     } else {
                         $value = $setting['value'];
                     }
                 }
             }
         }
         $this->_settings[$setting['site']][$setting['lang']][$setting['name']] = $value;
         if (empty($site) && $setting['name'] == 'nf_domains' && in_string($_SERVER['HTTP_HOST'], $setting['value'])) {
             $site = $value;
         }
     }
     $this->update('');
     $this->update('default');
     if (!empty($site)) {
         $this->update('default');
     }
 }
Esempio n. 10
0
 public function parse($content, $data = array(), $loader = NULL, $parse_php = TRUE)
 {
     if (!$loader) {
         $loader = $this->load;
     }
     if ($parse_php && is_callable($content)) {
         $content = call_user_func($content, $data, $loader);
     } else {
         if (in_string('<?php', $content) && in_string('?>', $content)) {
             $NeoFrag = $this->load;
             $paths = $loader->paths;
             $GLOBALS['loader'] = $loader;
             //Récupèration du contenu du template avec exécution du code PHP
             $content = eval('ob_start(); ?>' . preg_replace('/;*\\s*\\?>/', '; ?>', str_replace('<?=', '<?php echo ', $content)) . '<?php return ob_get_clean();');
         }
     }
     return $content;
 }
Esempio n. 11
0
    public static function display($disposition_id, $disposition, $page, $zone_id)
    {
        global $NeoFrag;
        $output = display($disposition, NeoFrag::live_editor() ? $zone_id : NULL);
        if (!NeoFrag::live_editor() && in_string('<div class="module', $output)) {
            $output .= $NeoFrag->profiler->output();
        }
        if (NeoFrag::live_editor()) {
            if (NeoFrag::live_editor() & NeoFrag::ZONES) {
                $output = '	<div class="pull-right">
								' . ($page == '*' ? '<button type="button" class="btn btn-link live-editor-fork" data-enable="0">' . icon('fa-toggle-off') . ' ' . $NeoFrag->lang('common_layout') . '</button>' : '<button type="button" class="btn btn-link live-editor-fork" data-enable="1">' . icon('fa-toggle-on') . ' ' . $NeoFrag->lang('custom_layout') . '</button>') . '
							</div>
							<h3>' . (!empty($NeoFrag->load->theme->zones[$zone_id]) ? $NeoFrag->load->theme->load->lang($NeoFrag->load->theme->zones[$zone_id], NULL) : $NeoFrag->lang('zone', $zone_id)) . ' <div class="btn-group"><button type="button" class="btn btn-xs btn-success live-editor-add-row" data-toggle="tooltip" data-container="body" title="' . $NeoFrag->lang('new_row') . '">' . icon('fa-plus') . '</button></div></h3>' . $output;
            }
            $output = '<div' . (NeoFrag::live_editor() & NeoFrag::ZONES ? ' class="live-editor-zone"' : '') . ' data-disposition-id="' . $disposition_id . '">' . $output . '</div>';
        }
        return $output;
    }
Esempio n. 12
0
 public static function delete($track_id)
 {
     if (empty($track_id)) {
         throw new ControllerException("At lease one track id must be specified");
     }
     $track_ids = in_string(",", $track_id) ? explode(",", $track_id) : array($track_id);
     self::validateListOfTrackIds($track_ids);
     $track_objects = self::getTracksListById($track_ids);
     $isTrackBelongsToUser = function ($track) {
         return $track[TSongs::USER_ID] == self::$me->getId();
     };
     if (!$track_objects->all($isTrackBelongsToUser)) {
         throw new ControllerException("One or more selected tracks is not belongs to you");
     }
     foreach ($track_objects as $track) {
         Logger::printf("Removing track %s", $track[TSongs::ID]);
         self::removeFilesUsedByTrack($track);
     }
     self::deleteTracksById($track_ids);
 }
Esempio n. 13
0
function getBlameResult(&$pageClass, $text)
{
    $history = $pageClass->history(null, 'older', true);
    $list = '';
    $anz = count($history);
    foreach ($history as $id => $rev) {
        if (in_string($text, $rev['*'], true) && ($id + 1 == $anz || !in_string($text, $history[$id + 1]['*'], true))) {
            $date = date('Y-m-d, H:i ', strtotime($rev['timestamp']));
            $year = date('Y', strtotime($rev['timestamp']));
            $month = date('m', strtotime($rev['timestamp']));
            $minor = $row['rev_minor_edit'] == '1' ? '<span class="minor" >m</span>' : '';
            $list .= '
				<tr>
				<td style="font-size:95%; white-space:nowrap;">' . $date . ' &middot; </td>
				<td>(<a href="//{$domain}/w/index.php?title={$urlencodedpage}&amp;diff=prev&amp;oldid=' . $rev['revid'] . '" title="' . $title . '">diff</a>)</td>
				<td>(<a href="//{$domain}/w/index.php?title={$urlencodedpage}&amp;action=history&amp;year=' . $year . '&amp;month=' . $month . ' " title="' . $title . '">hist</a>)</td>
				<td><a href="//{$domain}/wiki/User:'******'user'] . '" title="User:'******'user'] . '">' . $rev['user'] . '</a> </td>
				<td style="font-size:85%" > &middot; ' . htmlspecialchars($rev['comment']) . '</td>
				</tr>
			';
        }
    }
    return $list;
}
Esempio n. 14
0
 /**
  * Determine whether a page would be suitable for being counted as an
  * article in the site_stats table based on the title & its content
  *
  * @param $text String: text to analyze
  * @return bool
  */
 public function isCountable($text)
 {
     global $wgUseCommaCount;
     $token = $wgUseCommaCount ? ',' : '[[';
     return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token, $text);
 }
Esempio n. 15
0
 /**
  * @dataProvider provide_in_string
  * @covers ::in_string
  * @param $needle
  * @param $haystack
  * @param $insensitive
  * @param $expected
  */
 public function test_in_string($needle, $haystack, $insensitive, $expected)
 {
     $this->assertEquals($expected, in_string($needle, $haystack, $insensitive));
 }
Esempio n. 16
0
 /**
  * Determine whether a page  would be suitable for being counted as an
  * article in the site_stats table based on the title & its content
  *
  * @param $text String: text to analyze
  * @return bool
  */
 function isCountable($text)
 {
     global $wgUseCommaCount, $wgContentNamespaces;
     $token = $wgUseCommaCount ? ',' : '[[';
     return array_search($this->mTitle->getNamespace(), $wgContentNamespaces) !== false && !$this->isRedirect($text) && in_string($token, $text);
 }
Esempio n. 17
0
 /**
  * @dataProvider inStringProvider
  * @param $haystack
  * @param $needle
  * @param $result
  */
 public function testInString($haystack, $needle, $caseInsensitive, $result)
 {
     $this->assertEquals($result, in_string($haystack, $needle, $caseInsensitive));
 }
Esempio n. 18
0
 /**
  * Return the text of a template, after recursively
  * replacing any variables or templates within the template.
  *
  * @param array $piece The parts of the template
  *  $piece['text']: matched text
  *  $piece['title']: the title, i.e. the part before the |
  *  $piece['parts']: the parameter array
  * @return string the text of the template
  * @private
  */
 function braceSubstitution($piece)
 {
     global $wgContLang, $wgLang, $wgAllowDisplayTitle, $wgNonincludableNamespaces;
     $fname = __METHOD__;
     wfProfileIn($fname);
     wfProfileIn(__METHOD__ . '-setup');
     # Flags
     $found = false;
     # $text has been filled
     $nowiki = false;
     # wiki markup in $text should be escaped
     $noparse = false;
     # Unsafe HTML tags should not be stripped, etc.
     $noargs = false;
     # Don't replace triple-brace arguments in $text
     $replaceHeadings = false;
     # Make the edit section links go to the template not the article
     $headingOffset = 0;
     # Skip headings when number, to account for those that weren't transcluded.
     $isHTML = false;
     # $text is HTML, armour it against wikitext transformation
     $forceRawInterwiki = false;
     # Force interwiki transclusion to be done in raw mode not rendered
     # Title object, where $text came from
     $title = NULL;
     $linestart = '';
     # $part1 is the bit before the first |, and must contain only title characters
     # $args is a list of arguments, starting from index 0, not including $part1
     $titleText = $part1 = $piece['title'];
     # If the third subpattern matched anything, it will start with |
     if (null == $piece['parts']) {
         $replaceWith = $this->variableSubstitution(array($piece['text'], $piece['title']));
         if ($replaceWith != $piece['text']) {
             $text = $replaceWith;
             $found = true;
             $noparse = true;
             $noargs = true;
         }
     }
     $args = null == $piece['parts'] ? array() : $piece['parts'];
     wfProfileOut(__METHOD__ . '-setup');
     # SUBST
     wfProfileIn(__METHOD__ . '-modifiers');
     if (!$found) {
         $mwSubst =& MagicWord::get('subst');
         if ($mwSubst->matchStartAndRemove($part1) xor $this->ot['wiki']) {
             # One of two possibilities is true:
             # 1) Found SUBST but not in the PST phase
             # 2) Didn't find SUBST and in the PST phase
             # In either case, return without further processing
             $text = $piece['text'];
             $found = true;
             $noparse = true;
             $noargs = true;
         }
     }
     # MSG, MSGNW and RAW
     if (!$found) {
         # Check for MSGNW:
         $mwMsgnw =& MagicWord::get('msgnw');
         if ($mwMsgnw->matchStartAndRemove($part1)) {
             $nowiki = true;
         } else {
             # Remove obsolete MSG:
             $mwMsg =& MagicWord::get('msg');
             $mwMsg->matchStartAndRemove($part1);
         }
         # Check for RAW:
         $mwRaw =& MagicWord::get('raw');
         if ($mwRaw->matchStartAndRemove($part1)) {
             $forceRawInterwiki = true;
         }
     }
     wfProfileOut(__METHOD__ . '-modifiers');
     //save path level before recursing into functions & templates.
     $lastPathLevel = $this->mTemplatePath;
     # Parser functions
     if (!$found) {
         wfProfileIn(__METHOD__ . '-pfunc');
         $colonPos = strpos($part1, ':');
         if ($colonPos !== false) {
             # Case sensitive functions
             $function = substr($part1, 0, $colonPos);
             if (isset($this->mFunctionSynonyms[1][$function])) {
                 $function = $this->mFunctionSynonyms[1][$function];
             } else {
                 # Case insensitive functions
                 $function = strtolower($function);
                 if (isset($this->mFunctionSynonyms[0][$function])) {
                     $function = $this->mFunctionSynonyms[0][$function];
                 } else {
                     $function = false;
                 }
             }
             if ($function) {
                 $funcArgs = array_map('trim', $args);
                 $funcArgs = array_merge(array(&$this, trim(substr($part1, $colonPos + 1))), $funcArgs);
                 $result = call_user_func_array($this->mFunctionHooks[$function], $funcArgs);
                 $found = true;
                 // The text is usually already parsed, doesn't need triple-brace tags expanded, etc.
                 //$noargs = true;
                 //$noparse = true;
                 if (is_array($result)) {
                     if (isset($result[0])) {
                         $text = $linestart . $result[0];
                         unset($result[0]);
                     }
                     // Extract flags into the local scope
                     // This allows callers to set flags such as nowiki, noparse, found, etc.
                     extract($result);
                 } else {
                     $text = $linestart . $result;
                 }
             }
         }
         wfProfileOut(__METHOD__ . '-pfunc');
     }
     # Template table test
     # Did we encounter this template already? If yes, it is in the cache
     # and we need to check for loops.
     if (!$found && isset($this->mTemplates[$piece['title']])) {
         $found = true;
         # Infinite loop test
         if (isset($this->mTemplatePath[$part1])) {
             $noparse = true;
             $noargs = true;
             $found = true;
             $text = $linestart . "[[{$part1}]]<!-- WARNING: template loop detected -->";
             wfDebug(__METHOD__ . ": template loop broken at '{$part1}'\n");
         } else {
             # set $text to cached message.
             $text = $linestart . $this->mTemplates[$piece['title']];
             #treat title for cached page the same as others
             $ns = NS_TEMPLATE;
             $subpage = '';
             $part1 = $this->maybeDoSubpageLink($part1, $subpage);
             if ($subpage !== '') {
                 $ns = $this->mTitle->getNamespace();
             }
             $title = Title::newFromText($part1, $ns);
             //used by include size checking
             $titleText = $title->getPrefixedText();
             //used by edit section links
             $replaceHeadings = true;
         }
     }
     # Load from database
     if (!$found) {
         wfProfileIn(__METHOD__ . '-loadtpl');
         $ns = NS_TEMPLATE;
         # declaring $subpage directly in the function call
         # does not work correctly with references and breaks
         # {{/subpage}}-style inclusions
         $subpage = '';
         $part1 = $this->maybeDoSubpageLink($part1, $subpage);
         if ($subpage !== '') {
             $ns = $this->mTitle->getNamespace();
         }
         $title = Title::newFromText($part1, $ns);
         if (!is_null($title)) {
             $titleText = $title->getPrefixedText();
             # Check for language variants if the template is not found
             if ($wgContLang->hasVariants() && $title->getArticleID() == 0) {
                 $wgContLang->findVariantLink($part1, $title);
             }
             if (!$title->isExternal()) {
                 if ($title->getNamespace() == NS_SPECIAL && $this->mOptions->getAllowSpecialInclusion() && $this->ot['html']) {
                     $text = SpecialPage::capturePath($title);
                     if (is_string($text)) {
                         $found = true;
                         $noparse = true;
                         $noargs = true;
                         $isHTML = true;
                         $this->disableCache();
                     }
                 } else {
                     if ($wgNonincludableNamespaces && in_array($title->getNamespace(), $wgNonincludableNamespaces)) {
                         $found = false;
                         //access denied
                         wfDebug("{$fname}: template inclusion denied for " . $title->getPrefixedDBkey());
                     } else {
                         list($articleContent, $title) = $this->fetchTemplateAndtitle($title);
                         if ($articleContent !== false) {
                             $found = true;
                             $text = $articleContent;
                             $replaceHeadings = true;
                         }
                     }
                 }
                 # If the title is valid but undisplayable, make a link to it
                 if (!$found && ($this->ot['html'] || $this->ot['pre'])) {
                     $text = "[[:{$titleText}]]";
                     $found = true;
                 }
             } elseif ($title->isTrans()) {
                 // Interwiki transclusion
                 if ($this->ot['html'] && !$forceRawInterwiki) {
                     $text = $this->interwikiTransclude($title, 'render');
                     $isHTML = true;
                     $noparse = true;
                 } else {
                     $text = $this->interwikiTransclude($title, 'raw');
                     $replaceHeadings = true;
                 }
                 $found = true;
             }
             # Template cache array insertion
             # Use the original $piece['title'] not the mangled $part1, so that
             # modifiers such as RAW: produce separate cache entries
             if ($found) {
                 if ($isHTML) {
                     // A special page; don't store it in the template cache.
                 } else {
                     $this->mTemplates[$piece['title']] = $text;
                 }
                 $text = $linestart . $text;
             }
         }
         wfProfileOut(__METHOD__ . '-loadtpl');
     }
     if ($found && !$this->incrementIncludeSize('pre-expand', strlen($text))) {
         # Error, oversize inclusion
         $text = $linestart . "[[{$titleText}]]<!-- WARNING: template omitted, pre-expand include size too large -->";
         $noparse = true;
         $noargs = true;
     }
     # Recursive parsing, escaping and link table handling
     # Only for HTML output
     if ($nowiki && $found && ($this->ot['html'] || $this->ot['pre'])) {
         $text = wfEscapeWikiText($text);
     } elseif (!$this->ot['msg'] && $found) {
         if ($noargs) {
             $assocArgs = array();
         } else {
             # Clean up argument array
             $assocArgs = self::createAssocArgs($args);
             # Add a new element to the templace recursion path
             $this->mTemplatePath[$part1] = 1;
         }
         if (!$noparse) {
             # If there are any <onlyinclude> tags, only include them
             if (in_string('<onlyinclude>', $text) && in_string('</onlyinclude>', $text)) {
                 $replacer = new OnlyIncludeReplacer();
                 StringUtils::delimiterReplaceCallback('<onlyinclude>', '</onlyinclude>', array(&$replacer, 'replace'), $text);
                 $text = $replacer->output;
             }
             # Remove <noinclude> sections and <includeonly> tags
             $text = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $text);
             $text = strtr($text, array('<includeonly>' => '', '</includeonly>' => ''));
             if ($this->ot['html'] || $this->ot['pre']) {
                 # Strip <nowiki>, <pre>, etc.
                 $text = $this->strip($text, $this->mStripState);
                 if ($this->ot['html']) {
                     $text = Sanitizer::removeHTMLtags($text, array(&$this, 'replaceVariables'), $assocArgs);
                 } elseif ($this->ot['pre'] && $this->mOptions->getRemoveComments()) {
                     $text = Sanitizer::removeHTMLcomments($text);
                 }
             }
             $text = $this->replaceVariables($text, $assocArgs);
             # If the template begins with a table or block-level
             # element, it should be treated as beginning a new line.
             if (!$piece['lineStart'] && preg_match('/^(?:{\\||:|;|#|\\*)/', $text)) {
                 $text = "\n" . $text;
             }
         } elseif (!$noargs) {
             # $noparse and !$noargs
             # Just replace the arguments, not any double-brace items
             # This is used for rendered interwiki transclusion
             $text = $this->replaceVariables($text, $assocArgs, true);
         }
     }
     # Prune lower levels off the recursion check path
     $this->mTemplatePath = $lastPathLevel;
     if ($found && !$this->incrementIncludeSize('post-expand', strlen($text))) {
         # Error, oversize inclusion
         $text = $linestart . "[[{$titleText}]]<!-- WARNING: template omitted, post-expand include size too large -->";
         $noparse = true;
         $noargs = true;
     }
     if (!$found) {
         wfProfileOut($fname);
         return $piece['text'];
     } else {
         wfProfileIn(__METHOD__ . '-placeholders');
         if ($isHTML) {
             # Replace raw HTML by a placeholder
             # Add a blank line preceding, to prevent it from mucking up
             # immediately preceding headings
             $text = "\n\n" . $this->insertStripItem($text, $this->mStripState);
         } else {
             # replace ==section headers==
             # XXX this needs to go away once we have a better parser.
             if (!$this->ot['wiki'] && !$this->ot['pre'] && $replaceHeadings) {
                 if (!is_null($title)) {
                     $encodedname = base64_encode($title->getPrefixedDBkey());
                 } else {
                     $encodedname = base64_encode("");
                 }
                 $m = preg_split('/(^={1,6}.*?={1,6}\\s*?$)/m', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
                 $text = '';
                 $nsec = $headingOffset;
                 for ($i = 0; $i < count($m); $i += 2) {
                     $text .= $m[$i];
                     if (!isset($m[$i + 1]) || $m[$i + 1] == "") {
                         continue;
                     }
                     $hl = $m[$i + 1];
                     if (strstr($hl, "<!--MWTEMPLATESECTION")) {
                         $text .= $hl;
                         continue;
                     }
                     $m2 = array();
                     preg_match('/^(={1,6})(.*?)(={1,6}\\s*?)$/m', $hl, $m2);
                     $text .= $m2[1] . $m2[2] . "<!--MWTEMPLATESECTION=" . $encodedname . "&" . base64_encode("{$nsec}") . "-->" . $m2[3];
                     $nsec++;
                 }
             }
         }
         wfProfileOut(__METHOD__ . '-placeholders');
     }
     # Prune lower levels off the recursion check path
     $this->mTemplatePath = $lastPathLevel;
     if (!$found) {
         wfProfileOut($fname);
         return $piece['text'];
     } else {
         wfProfileOut($fname);
         return $text;
     }
 }
Esempio n. 19
0
function in_string($needle, $haystack)
{
    if (is_array($needle)) {
        $result = true;
        foreach ($needle as $sub_needle) {
            $result = in_string($sub_needle, $haystack) && $result;
        }
    } else {
        $result = stripos($haystack, $needle) !== false;
    }
    return $result;
}
Esempio n. 20
0
$q = $dbh->prepare($sql);
$q->execute();
$error = $q->errorInfo();
while ($result = $q->fetch(PDO::FETCH_ASSOC)) {
    $rows = array();
    //Add user picture
    $pic = "<img class='thumbnail-mask' src='" . return_thumbnail($dbh, $result['username']) . "' border='0'>";
    $rows[] = $pic;
    //Format data
    $result['username'] = username_to_fullname($dbh, $result['username']);
    $result['date_added'] = extract_date_time_sortable($result['date_added']);
    //Check to see if this user has read or archived this journal
    if (in_string($user, $result['read'])) {
        $result['read'] = 'yes';
    } else {
        $result['read'] = '';
    }
    if (in_string($user, $result['archived'])) {
        $result['archived'] = 'yes';
    } else {
        $result['archived'] = '';
    }
    foreach ($cols as $col) {
        $rows[] = $result[$col];
    }
    $output['aaData'][] = $rows;
}
if ($q->rowCount() < 1) {
    $output['aaData'] = array();
}
echo json_encode($output);
Esempio n. 21
0
 public function get_method(&$args, $ignore_ajax = FALSE)
 {
     $url = '';
     if ($this->config->admin_url) {
         $url .= 'admin';
     }
     if ($this->config->ajax_url && !$ignore_ajax) {
         $url .= '/ajax';
     }
     $url = ltrim($url, '/');
     if ($url) {
         foreach (array_keys($this->routes) as $route) {
             if (!preg_match('#^' . $url . '#', $route)) {
                 unset($this->routes[$route]);
             }
         }
         $url .= '/';
     }
     $url .= implode('/', $args);
     $method = NULL;
     foreach ($this->routes as $route => $function) {
         if (preg_match('#^' . str_replace(array_map(function ($a) {
             return '{' . $a . '}';
         }, array_keys(self::$patterns)) + array('#'), array_values(self::$patterns) + array('\\#'), $route) . '$#', $url, $matches)) {
             $args = array();
             if (in_string('{url_title*}', $route)) {
                 foreach (array_offset_left($matches) as $arg) {
                     $args = array_merge($args, explode('/', $arg));
                 }
             } else {
                 $args = array_offset_left($matches);
             }
             $args = array_map(function ($a) {
                 return trim($a, '/');
             }, $args);
             $method = $function;
             break;
         }
     }
     return $method;
 }
function forum_is_mod($fid, $gid, $uid)
{
    global $conf, $grouplist, $forumlist;
    if ($gid == 1 || $gid == 2) {
        return TRUE;
    }
    // 管理员有所有权限
    if ($gid == 3 || $gid == 4) {
        if ($fid == 0) {
            return TRUE;
        }
        // 此处不严谨!
        $group = $grouplist[$gid];
        $forum = $forumlist[$fid];
        return in_string($uid, $forum['moduids']);
    }
    return FALSE;
}
Esempio n. 23
0
<?php

require_once getenv('MW_INSTALL_PATH') !== false ? getenv('MW_INSTALL_PATH') . "/maintenance/commandLine.inc" : dirname(__FILE__) . '/../../maintenance/commandLine.inc';
require 'Expr.php';
$tests = file('exprTests.txt');
$pass = $fail = 0;
// Each test is on one line. The test must always evaluate to '1'.
$parser = new ExprParser();
foreach ($tests as $test) {
    $test = trim($test);
    if (in_string(';', $test)) {
        list($input, $expected) = explode(';', $test);
    } else {
        $input = $test;
        $expected = 1;
    }
    $expected = trim($expected);
    $input = trim($input);
    $result = $parser->doExpression($input);
    if ($result != $expected) {
        print "FAILING test -- {$input}\n gave a final result of {$result}, instead of {$expected}.\n";
        $fail++;
    } else {
        print "PASSED test {$test}\n";
        $pass++;
    }
}
print "Passed {$pass} tests, failed {$fail} tests, out of a total of " . ($pass + $fail) . "\n";
Esempio n. 24
0
    public function display()
    {
        NeoFrag::loader()->css('neofrag.table')->js('neofrag.table');
        $output = '';
        $search = trim(post('search'));
        if (post('table_id')) {
            if (post('table_id') == $this->id) {
                $this->config->ajax_url = TRUE;
                $this->_ajax = TRUE;
            } else {
                $this->reset();
                return;
            }
        }
        if (!is_null($session_sort = $this->session('table', $this->id, 'sort'))) {
            foreach ($session_sort as $session) {
                list($column_id, $order) = $session;
                $this->sort_by($column_id, $order);
            }
        }
        if ($this->_pagination && !empty($this->pagination) && !is_null($items_per_page = $this->session('table', $this->id, 'items_per_page'))) {
            $this->pagination->set_items_per_page($items_per_page);
        }
        if (!is_null($sort = post('sort')) && $this->_ajax) {
            list($column_id, $order) = json_decode($sort);
            if (in_array($order, array('asc', 'desc', 'none'))) {
                if ($order == 'asc') {
                    $order = SORT_ASC;
                } else {
                    if ($order == 'desc') {
                        $order = SORT_DESC;
                    } else {
                        if ($order == 'none') {
                            $order = -1;
                        }
                    }
                }
                $added = FALSE;
                if (!is_null($session_sort = $this->session('table', $this->id, 'sort'))) {
                    foreach ($session_sort as $i => $session) {
                        if ($column_id == $session[0]) {
                            $added = TRUE;
                            if ($order != -1 || isset($this->_sortings[$column_id])) {
                                $this->session->set('table', $this->id, 'sort', $i, array($column_id, $order));
                            } else {
                                $this->session->destroy('table', $this->id, 'sort', $i);
                            }
                        }
                    }
                }
                if (!$added) {
                    $this->session->add('table', $this->id, 'sort', array($column_id, $order));
                }
                $this->sort_by($column_id, $order);
            }
            $search = $this->session('table', $this->id, 'search');
        }
        $count_results = $this->_pagination && !empty($this->pagination) ? $this->pagination->count() : count($this->_data);
        if ($this->_is_searchable() && $search && $this->_pagination && !empty($this->pagination)) {
            $this->_data = $this->pagination->display_all();
        } else {
            if (!empty($this->_sortings) && $this->_pagination && !empty($this->pagination) && (!isset($search) || !$search)) {
                $this->_data = $this->pagination->get_data();
            }
        }
        $this->_preprocessing();
        //Gestion des recherches
        if ($this->_is_searchable()) {
            if ($search) {
                $results = array();
                $words = explode(' ', trim($search));
                foreach ($this->_data as $data_id => $data) {
                    $found = 0;
                    $data = array_merge(array('data_id' => $data_id), $data);
                    foreach ($this->_columns as $value) {
                        if (!isset($value['search']) || is_null($value['search'])) {
                            continue;
                        }
                        $value = $this->template->parse($value['search'], $data, $this->load);
                        foreach ($words as $word) {
                            if (in_string($word, $value, FALSE)) {
                                $found++;
                            }
                        }
                        if ($found == count($words)) {
                            break;
                        }
                    }
                    if ($found == count($words)) {
                        $results[] = $data;
                    }
                }
                $this->session->set('table', $this->id, 'search', $search);
                $this->_data = $results;
                $this->_no_data = NeoFrag::loader()->lang('no_result');
            } else {
                $this->session->destroy('table', $this->id, 'search');
            }
            $words = array();
            foreach ($this->_data as $data_id => $data) {
                $data = array_merge(array('data_id' => $data_id), $data);
                foreach ($this->_columns as $value) {
                    if (!isset($value['search']) || is_null($value['search'])) {
                        continue;
                    }
                    $this->_words[] = $value = $this->template->parse($value['search'], $data, $this->load);
                    $words[] = '"' . $value . '"';
                }
            }
        }
        if (empty($this->_data)) {
            $output = '<div class="clearfix"></div>' . ($this->_no_data ?: NeoFrag::loader()->lang('no_data'));
        } else {
            if (!$this->_ajax && $this->_is_searchable()) {
                $search_input = '	<div class="table-search pull-left">
										<div class="form-group has-feedback">
											<input class="form-control" data-provide="typeahead" data-items="5" data-source="' . utf8_htmlentities('[' . trim_word(implode(', ', array_unique($words)), ', ') . ']') . '" type="text"' . (isset($search) ? ' value="' . $search . '"' : '') . ' placeholder="' . NeoFrag::loader()->lang('search') . '" autocomplete="off" />
										</div>
									</div>';
            }
            //Gestion des tris
            if (!empty($this->_sortings)) {
                $sortings = array();
                foreach ($this->_sortings as $column => $order) {
                    if (!isset($this->_columns[$column]) || !isset($this->_columns[$column]['sort']) || $order[0] == -1) {
                        continue;
                    }
                    $tmp = array();
                    foreach ($this->_data as $data_id => $data) {
                        $data = array_merge(array('data_id' => $data_id), $data);
                        $tmp[] = $this->template->parse($this->_columns[$column]['sort'], $data, $this->load);
                    }
                    $sortings[] = array_map('strtolower', $tmp);
                    $sortings = array_merge($sortings, $order);
                }
                $data = array();
                foreach ($this->_data as $key => $value) {
                    $data[$key . ' '] = $value;
                }
                $sortings[] =& $data;
                call_user_func_array('array_multisort', $sortings);
                $this->_data = array();
                foreach ($data as $key => $value) {
                    $this->_data[trim($key)] = $value;
                }
                if ($this->_pagination && !empty($this->pagination) && ($items_per_page = $this->pagination->get_items_per_page()) > 0) {
                    $this->_data = array_slice($this->_data, ($this->pagination->get_page() - 1) * $items_per_page, $items_per_page);
                }
            }
            if ($this->_pagination && !empty($this->pagination) && $this->pagination->count() > 10) {
                $output .= '<div class="form-group pull-left">
								<select class="form-control" style="width: auto;" onchange="window.location=\'' . $this->pagination->get_url() . '/\'+$(this).find(\'option:selected\').data(\'url\')+\'.html\'" autocomplete="off">
									<option value="10"' . ($this->pagination->get_items_per_page() == 10 ? ' selected="selected"' : '') . ' data-url="page/1/10">' . NeoFrag::loader()->lang('results', 10, 10) . '</option>
									<option value="25"' . ($this->pagination->get_items_per_page() == 25 ? ' selected="selected"' : '') . ' data-url="page/1/25">' . NeoFrag::loader()->lang('results', 25, 25) . '</option>
									<option value="50"' . ($this->pagination->get_items_per_page() == 50 ? ' selected="selected"' : '') . ' data-url="page/1/50">' . NeoFrag::loader()->lang('results', 50, 50) . '</option>
									<option value="100"' . ($this->pagination->get_items_per_page() == 100 ? ' selected="selected"' : '') . ' data-url="page/1/100">' . NeoFrag::loader()->lang('results', 100, 100) . '</option>
									<option value="all"' . ($this->pagination->get_items_per_page() == 0 ? ' selected="selected"' : '') . ' data-url="all">' . NeoFrag::loader()->lang('show_all') . '</option>
								</select>
							</div>';
            }
            if ($this->_pagination && !empty($this->pagination) && ($pagination = $this->pagination->get_pagination()) != '') {
                $output .= '<div class="form-group pull-right">' . $pagination . '</div>';
            }
            $count = count($this->_data);
            $output .= '<div class="table-responsive"><table class="table table-hover table-striped">';
            if ($this->_display_header()) {
                $output .= '<thead>';
                $header = '			<tr class="navbar-inner">';
                $i = 0;
                foreach ($this->_columns as $th) {
                    $width = isset($th['size']) ? $th['size'] : FALSE;
                    $class = array();
                    $sort = '';
                    if ($width === TRUE) {
                        $class[] = 'action';
                    }
                    if (!empty($this->_data) && isset($th['sort'])) {
                        $class[] = 'sort';
                        $sort = ' data-column="' . ($i + 1) . '"';
                        if (isset($this->_sortings[$i]) && $this->_sortings[$i][0] == SORT_ASC) {
                            $class[] = 'sorting_asc';
                            $sort .= ' data-order-by="desc"';
                        } else {
                            if (isset($this->_sortings[$i]) && $this->_sortings[$i][0] == SORT_DESC) {
                                $class[] = 'sorting_desc';
                                $sort .= ' data-order-by="none"';
                            } else {
                                $class[] = 'sorting';
                                $sort .= ' data-order-by="asc"';
                            }
                        }
                    }
                    $header .= '		<th' . (!empty($class) ? ' class="' . implode(' ', $class) . '"' : '') . (!is_bool($width) ? ' style="width: ' . $width . ';"' : '') . (!empty($sort) ? $sort : '') . '>' . (!empty($th['title']) ? $th['title'] : '') . '</th>';
                    $i++;
                }
                $header .= '		</tr>';
                $output .= $header . '
								</thead>';
            }
            $output .= '	<tbody>';
            foreach ($this->_data as $data_id => $data) {
                $data = array_merge(array('data_id' => $data_id), $data);
                $output .= '<tr>';
                foreach ($this->_columns as $value) {
                    if (is_array($value['content'])) {
                        $actions = array();
                        foreach ($value['content'] as $val) {
                            $actions[] = $this->template->parse($val, $data, $this->load);
                        }
                        $output .= '<td class="action">' . implode('&nbsp;', array_filter($actions)) . '</td>';
                    } else {
                        $content = $this->template->parse($value['content'], $data, $this->load);
                        if (!isset($value['td']) || $value['td']) {
                            $classes = array();
                            if (isset($value['size']) && $value['size'] === TRUE) {
                                $classes[] = 'action';
                            }
                            if (!empty($value['class'])) {
                                $classes[] = $value['class'];
                            }
                            if (!empty($value['align']) && in_array($value['align'], array('left', 'center', 'right'))) {
                                $classes[] = 'text-' . $value['align'];
                            }
                            $content = '<td' . (!empty($classes) ? ' class="' . implode(' ', $classes) . '"' : '') . '>' . $content . '</td>';
                        }
                        $output .= $content;
                    }
                }
                $output .= '</tr>';
            }
            $output .= '	</tbody>';
            if ($this->_pagination && !empty($this->pagination) && $this->pagination->get_items_per_page() >= 50 && $count >= 50) {
                $output .= '<tfoot>' . $header . '</tfoot>';
            }
            $output .= '</table></div>';
            if (!empty($pagination)) {
                $output .= '<div class="pull-right">' . $pagination . '</div>';
            }
            $output .= '<i>' . NeoFrag::loader()->lang('results', $count, $count) . ($count < $count_results ? NeoFrag::loader()->lang('results_total', $count_results) : '') . '</i>';
            if (!$this->_ajax) {
                $output = '<div class="table-area" data-table-id="' . $this->id . '"' . ($this->config->ajax_url ? ' data-ajax-url="' . url($this->config->request_url) . '"  data-ajax-post="' . http_build_query(post()) . '"' : '') . '>' . (isset($search_input) ? $search_input : '') . '<div class="table-content">' . $output . '</div></div>';
            }
        }
        $this->reset();
        if ($this->_ajax) {
            $this->session->save();
            echo $output;
            return '';
        } else {
            return $output;
        }
    }
Esempio n. 25
0
function is_mobile()
{
    //Get the current user agent
    $ua = $_SERVER["HTTP_USER_AGENT"];
    //If it contains any of the following browsers...
    if (in_string($ua, "Windows CE") || in_string($ua, "AvantGo") || in_string($ua, "Mazingo") || in_string($ua, "Mobile") || in_string($ua, "T68") || in_string($ua, "Syncalot") || in_string($ua, "Blazer")) {
        $DEVICE_TYPE = "MOBILE";
        //Set the device type to 'mobile'
    }
    //Return whether the device type is mobile
    return isset($DEVICE_TYPE) && $DEVICE_TYPE == "MOBILE";
}
Esempio n. 26
0
	public static function keywordIn( $a, $b ) {
		if( $b->isArray() ) {
			foreach( $b->data as $elem ) {
				if( self::equals( $elem, $a ) )
					return new WSData( self::DBool, true );
			}
			return new WSData( self::DBool, false );
		} else {
			$a = $a->toString();
			$b = $b->toString();
			
			if( $a == '' || $b == '' ) {
				return new WSData( self::DBool, false );
			}
			
			return new WSData( self::DBool, in_string( $a, $b ) );
		}
	}
Esempio n. 27
0
function run_sql_script($filename)
{
    global $db_path;
    $sql_file = $db_path . $filename;
    $file = @fopen($sql_file, 'rb');
    if (!$file) {
        return false;
    }
    $content = fread($file, filesize($sql_file));
    fclose($file);
    $content = preg_replace("/--(.*)/", '', $content);
    $parts = explode(';', $content);
    $queries = array();
    $query_temp = '';
    $is_function = false;
    $is_copy_stdin = false;
    for ($i = 0; $i < count($parts); $i++) {
        $q = $parts[$i];
        // Check if it's a function
        if ((in_string($q, 'create function') || in_string($q, 'create or replace function') || in_string($q, 'replace function')) && !in_string($q, 'language plpgsql') && !in_string($q, 'language \'plpgsql\'') && !in_string($q, 'language \'c\'') && !in_string($q, 'language c')) {
            while (!in_string($q, 'language plpgsql') && !in_string($q, 'language \'plpgsql\'')) {
                $i++;
                $q = $q . ';' . $parts[$i];
            }
            $queries[] = trim($q);
            // Check if it is a COPY FROM stdin
        } else {
            if (in_string($q, 'copy') && in_string($q, 'from stdin')) {
                while (!in_string($q, '\\.')) {
                    $i++;
                    $q = $q . ';' . $parts[$i];
                }
                $aux = explode('\\.', $q, 2);
                $queries[] = ltrim($aux[0] . "\\.\n");
                if (trim($aux[1]) != '') {
                    $queries[] = trim($aux[1]);
                }
                // Else, we just add it up
            } else {
                if (trim($q) != '') {
                    $queries[] = trim($q);
                }
            }
        }
    }
    $i = 0;
    //db_begin();
    foreach ($queries as $query) {
        // Check if it is a DROP TABLE
        if (in_string($query, 'drop table')) {
            $aux = explode(' ', trim($query));
            if (count($aux) == 3 || count($aux) == 4) {
                // PERFECT!
                drop_table_if_exists($aux[2]);
            } else {
                print_r($aux);
            }
            // Check if it is a DROP SEQUENCE
        } else {
            if (in_string($query, 'drop sequence')) {
                $aux = explode(' ', trim($query));
                if (count($aux) == 3) {
                    // PERFECT!
                    drop_seq_if_exists($aux[2]);
                } else {
                    print_r($aux);
                }
                // Check if it is a DROP TRIGGER
            } else {
                if (in_string($query, 'drop trigger')) {
                    $aux = explode(' ', trim($query));
                    if (count($aux) == 5 || count($aux) == 6) {
                        // PERFECT!
                        drop_trigger_if_exists($aux[2], $aux[4]);
                    } else {
                        print_r($aux);
                    }
                    // Check if it is a DROP VIEW
                } else {
                    if (in_string($query, 'drop view')) {
                        $aux = explode(' ', trim($query));
                        if (count($aux) == 3 || count($aux) == 4) {
                            // PERFECT!
                            drop_view_if_exists($aux[2]);
                        } else {
                            print_r($aux);
                        }
                    } else {
                        $res = db_query($query);
                        if (!$res) {
                            show(db_error() . "\n");
                            show("QUERY: {$query}\n");
                            show("Continue executing ([Y]es/[N]o)?\n");
                            // Read the input
                            $answer = strtolower(trim(fgets(STDIN)));
                            if ($answer != 'y' && $anser != 'yes') {
                                //db_rollback();
                                return false;
                            } else {
                                //db_commit();
                                //db_begin();
                            }
                        }
                    }
                }
            }
        }
    }
    // Patch for somre 3.0preX versions
    if ($filename == '20021216.sql') {
        db_query("SELECT setval('themes_theme_id_key', (SELECT MAX(theme_id) FROM themes), true)");
        show("Applying fix for some 3.0preX versions\n");
    }
    db_commit();
    return true;
}
Esempio n. 28
0
}
unset($tool, $surl);
require_once '/data/project/xtools/public_html/phptemp/PHPtemp.php';
require_once '/data/project/xtools/public_html/phptemp/Language.php';
require_once '/data/project/xtools/public_html/sitenotice.php';
$langs = glob("/data/project/xtools/public_html/pcount/configs/*.conf");
foreach ($langs as $k => $newlang) {
    $langs[$k] = str_replace(array('/data/project/xtools/public_html/pcount/configs/', '.conf'), '', $newlang);
    if ($langs[$k] == "qqq") {
        unset($langs[$k]);
    }
}
$language = new Language($langs);
$lang = $language->getLang();
$phptemp = new PHPtemp('/data/project/xtools/public_html/templates/main.tpl');
if (in_string('iPhone', $_SERVER['HTTP_USER_AGENT']) && $lang == "en" && !isset($_GET['nophone'])) {
    define('IPHONE', true);
    $phptemp = new PHPtemp('/data/project/xtools/public_html/templates/iphone.tpl');
    $content = new PHPtemp('/data/project/xtools/public_html/pcount/templates/iphone.tpl');
} else {
    define('IPHONE', false);
    $phptemp = new PHPtemp('/data/project/xtools/public_html/templates/main.tpl');
    $content = new PHPtemp('/data/project/xtools/public_html/pcount/templates/pcount.tpl');
}
$langlinks = $language->generateLangLinks();
if (is_file('/data/project/xtools/public_html/configs/' . $lang . '.conf')) {
    $phptemp->load_config('/data/project/xtools/public_html/configs/' . $lang . '.conf', 'main');
    $content->load_config('/data/project/xtools/public_html/configs/' . $lang . '.conf', 'main');
} else {
    $phptemp->load_config('/data/project/xtools/public_html/configs/en.conf', 'main');
    $content->load_config('/data/project/xtools/public_html/configs/en.conf', 'main');
Esempio n. 29
0
 protected function funcContainsAny($args)
 {
     if (count($args) < 2) {
         throw new AFPUserVisibleException('notenoughargs', $this->mCur->pos, array('contains_any', 2, count($args)));
     }
     $s = array_shift($args);
     $s = $s->toString();
     $searchStrings = array();
     foreach ($args as $arg) {
         $searchStrings[] = $arg->toString();
     }
     if (function_exists('fss_prep_search')) {
         $fss = fss_prep_search($searchStrings);
         $result = fss_exec_search($fss, $s);
         $ok = is_array($result);
     } else {
         $ok = false;
         foreach ($searchStrings as $needle) {
             if (in_string($needle, $s)) {
                 $ok = true;
                 break;
             }
         }
     }
     return new AFPData(AFPData::DBool, $ok);
 }
Esempio n. 30
0
 public function controller($controller)
 {
     if (in_array($controller, array_keys($this->controllers))) {
         $this->profiler->log('Contrôleur ' . $controller . ' déjà chargé', Profiler::INFO);
         return $this->controllers[$controller];
     }
     reset($this->paths['controllers']);
     while (list(, $path) = each($this->paths['controllers'])) {
         if (!file_exists($controller_path = $path . '/' . $controller . '.php')) {
             continue;
         }
         $this->profiler->log('Contrôleur ' . $controller . ' chargé : ' . $path, Profiler::INFO);
         $controller_name = get_class($this->object) . '_c_' . $controller;
         if (in_string('/overrides/', $controller_path)) {
             while (list(, $path) = each($this->paths['controllers'])) {
                 if (!file_exists($o_controller_path = $path . '/' . $controller . '.php')) {
                     continue;
                 }
                 include_once $o_controller_path;
                 break;
             }
             $controller_name = 'o_' . $controller_name;
         }
         include_once $controller_path;
         if (!class_exists($controller_name)) {
             $controller_name = preg_replace('/^((o_)?)w_(.+?)$/', '\\1m_\\3', $controller_name);
         }
         if (class_exists($controller_name)) {
             $controller_instance = new $controller_name($this->object);
             $this->controllers[$controller] =& $controller_instance;
             return $controller_instance;
         } else {
             break;
         }
     }
     $this->profiler->log('Contrôleur ' . $controller . ' inexistant : ' . $path, Profiler::ERROR);
     return NULL;
 }