Ejemplo n.º 1
0
function getOurHostID()
{
    $db = gs_db_slave_connect();
    $rs = $db->execute('SELECT `id`, `host` FROM `hosts`');
    $hosts = array();
    while ($r = $rs->fetchRow()) {
        $hosts[] = $r;
    }
    $ips = array();
    foreach ($hosts as $h) {
        $h['host'] = trim(normalizeIPs($h['host']));
        if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $h['host'])) {
            $ips[$h['host']] = $h['id'];
        } else {
            $tmp = getHostByNameL($h['host']);
            if (is_array($tmp)) {
                foreach ($tmp as $ip) {
                    $ips[normalizeIPs($ip)] = $h['id'];
                }
            }
        }
    }
    unset($hosts);
    $ifconfig = normalizeIPs(trim(@shell_exec('ifconfig 2>>/dev/null')));
    foreach ($ips as $ip => $hostid) {
        if (strPos($ifconfig, $ip) !== false) {
            return $hostid;
        }
    }
    return false;
}
    /**
     * Helper for subclasses' rewrite() methods. This checks if the call can
     * be rewritten at all and leaves a FIXME if it can't. If the variable's
     * key is not a string starting with MODULE_, the call will not be
     * considered rewritable.
     *
     * @return boolean
     */
    protected function tryRewrite(FunctionCallNode $call, TargetInterface $target)
    {
        $statement = $call->getStatement();
        $arguments = $call->getArguments();
        if ($arguments[0] instanceof StringNode) {
            $key = $arguments[0]->toValue();
            if (strPos($key, $target->id() . '_') === 0) {
                return TRUE;
            } else {
                $comment = <<<END
This looks like another module's variable. You'll need to rewrite this call
to ensure that it uses the correct configuration object.
END;
                $this->buildFixMe($comment)->prependTo($statement);
                return FALSE;
            }
        } else {
            $comment = <<<END
The correct configuration object could not be determined. You'll need to
rewrite this call manually.
END;
            $this->buildFixMe($comment)->prependTo($statement);
            return FALSE;
        }
    }
Ejemplo n.º 3
0
	/**
	 * 
	 * @param string $type
	 * @return Dkplus_Model_Interface
	 */
	public static function get($type){
		$args = func_get_args();
		unset($args[0]);
		$args = array_values($args);
		foreach($args AS $arg){
			if(
				!is_int($arg)
				&& !is_string($arg)
				&& !is_bool($arg)
				&& !is_null($arg)
			){
				throw new Dkplus_Model_Exception('Arguments can be only strings, ints, booleans or NULL.');
			}
		}
		
		$type = (string) $type;
		$blnPrefixNotNeeded = false;
		foreach(self::$_prefix AS $prefix){
			if(
				strPos($type, $prefix) === 0
				AND @class_exists($type)
			){
				$blnPrefixNotNeeded = true;
			}			
		}
		
		if(
			$blnPrefixNotNeeded
		){			
			return self::_getObject($type, $args);
		}
		else{
			return self::_loadClass($type, $args);
		}
	}
Ejemplo n.º 4
0
function siemens_push_str($phone_ip, $postdata)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    $data = "POST /server_push.html/ServerPush HTTP/1.1\r\n";
    $data .= "User-Agent: Gemeinschaft\r\n";
    $data .= "Host: {$phone_ip}:8085\r\n";
    $data .= "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
    $data .= "Connection: keep-alive\r\n";
    $data .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $data .= "Content-Length: " . strLen($postdata) . "\r\n\r\n";
    $data .= $postdata;
    $socket = @fSockOpen($phone_ip, 8085, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Siemens: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Siemens: Failed to push to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Siemens: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
Ejemplo n.º 5
0
 public function uri($uriTemplate)
 {
     $this->uriTemplate = $uriTemplate;
     if (strPos($uriTemplate, ':') === false) {
         $this->routeType = self::TYPE_STATIC;
     } else {
         $this->routeType = self::TYPE_PATTERN;
     }
     return $this;
 }
Ejemplo n.º 6
0
function verifyLCCN()
{
    ## remove "-" and fill with "0" to make 8 char long
    $pos = strPos($lookupVal, "-");
    if ($pos > 0) {
        $lccnLeft = subStr($lookupVal, 0, $pos);
        $lccnRight = subStr($lookupVal, $pos + 1, 6);
        $lccnRight = str_pad($lccnRight, 6, "0", STR_PAD_LEFT);
        $lookupVal = $lccnLeft . $lccnRight;
    }
    return $lookupVal;
}
Ejemplo n.º 7
0
 public function __construct($date, $workoutName)
 {
     $this->date = $date;
     $this->workoutName = $workoutName;
     if (strPos($workoutName, 'r') > 0) {
         $this->type = self::INTERVAL;
     } else {
         if (strPos($workoutName, 'm')) {
             $this->type = self::DISTANCE;
         } else {
             $this->type = self::TIME;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * @return void
  * @param string $url
  */
 public static function run($url = null)
 {
     self::instance();
     include SETTINGS . DS . 'routes.php';
     if (null === $url) {
         $url = $_SERVER['REQUEST_URI'];
         if (false !== strPos($url, '?')) {
             $url = subStr($url, 0, strPos($url, '?'));
         }
         if (self::config('web')->url && 0 === strPos($url, self::config('web')->url)) {
             $url = subStr($url, strLen(self::config('web')->url));
         }
         if (self::config('web')->index) {
             $url = preg_replace('/' . preg_quote(self::config('web')->index) . '$/', '', $url);
         }
     }
     echo self::instance()->dispatcher->dispatch(self::instance()->routes, $url);
 }
/**
 * Send & request to VIES site and interprets results
 *
 * @access public
 * @param string
 * @return boolean
 */
function oos_validate_is_vatid($sVatno)
{
    $sVatno = trim($sVatno);
    $sVatno = strtoupper($sVatno);
    $aRemove = array(' ', '-', '/', '.', ':', ',', ';', '#');
    for ($i = 0, $n = count($aRemove); $i < $n; $i++) {
        $sVatno = str_replace($aRemove[$i], '', $sVatno);
    }
    $sViesMS = substr($sVatno, 0, 2);
    $sVatno = substr($sVatno, 2);
    $urlVies = 'http://ec.europa.eu/taxation_customs/vies/cgi-bin/viesquer/?VAT=' . $sVatno . '&MS=' . $sViesMS . '&Lang=EN';
    $DataHTML = load_data($urlVies);
    if (!$DataHTML) {
        return false;
    }
    $ViesOk = 'YES, VALID VAT NUMBER';
    $ViesEr = 'NO, INVALID VAT NUMBER';
    $DataHTML = '#' . strtoupper($DataHTML);
    return strPos($DataHTML, $ViesOk) > 0 ? true : false;
}
Ejemplo n.º 10
0
 /**
  * Разбирает файл или массив строк методом parse_ini_file;
  *
  * Проверряет существование файла, парстит его методом parse_ini и нормализует
  * имена сеций([ myConfig: base] => [myConfig])
  *
  * Если в качестве аргумента передан масси, то он сохранятся во временный файл.
  * 
  * TODO PHP5.3 parse_ini_string
  *
  * @param iFile | arrray
  * @return array
  */
 function getPattern($file)
 {
     if ($file instanceof iFile && !$file->exists()) {
         throw new ConfigTaskException('File ' . $file . ' not found');
     } elseif (is_array($file)) {
         $tFile = new TempFile();
         file_put_contents($tFile, implode('', $file));
         $file = $tFile;
     }
     @($arr = parse_ini_file($file, true));
     if ($arr === false) {
         throw new Exception('Error while parsing ini-file ' . $file);
     }
     foreach ($arr as $sect => $c) {
         if (($p = strPos($sect, Config::getInstance()->getInheritSeparator())) !== false) {
             $sect2 = trim(substr($sect, 0, $p));
         }
         $pattern[isset($sect2) ? $sect2 : $sect] = $c;
     }
     return $pattern;
 }
Ejemplo n.º 11
0
function WDAddPageParams($page_url = "", $params = array(), $htmlSpecialChars = true)
{
    $strUrl = "";
    $strParams = "";
    $arParams = array();
    $param = "";
    // Attention: $page_url already is safe.
    if (is_array($params) && count($params) > 0) {
        foreach ($params as $key => $val) {
            if (is_array($val) && count($val) > 0 || strLen($val) > 0 && $val != "0" || intVal($val) > 0) {
                if (is_array($val)) {
                    $param = implode(",", $val);
                } else {
                    $param = $val;
                }
                if (strLen($param) > 0) {
                    if (strPos($page_url, $key) !== false) {
                        $page_url = preg_replace("/" . $key . "\\=[^\\&]*((\\&amp\\;)|(\\&)*)/", "", $page_url);
                    }
                    $arParams[] = $key . "=" . $param;
                }
            }
        }
        if (count($arParams) > 0) {
            if (strPos($page_url, "?") === false) {
                $strParams = "?";
            } elseif (substr($page_url, -5, 5) != "&amp;" && substr($page_url, -1, 1) != "&" && substr($page_url, -1, 1) != "?") {
                $strParams = "&";
            }
            $strParams .= implode("&", $arParams);
            if ($htmlSpecialChars) {
                $page_url .= htmlspecialcharsbx($strParams);
            } else {
                $page_url .= $strParams;
            }
        }
    }
    return $page_url;
}
Ejemplo n.º 12
0
function aastra_push_str($phone_ip, $xml)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    //FIXME - call wget or something. this function should not block
    // for so long!
    // see _gs_prov_phone_checkcfg_by_ip_do_aastra() in
    // opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php
    //$xml = utf8_decode($xml);
    if (subStr($xml, 0, 5) !== '<' . '?xml') {
        $xmlpi = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
    } else {
        $xmlpi = '';
    }
    $data = "POST / HTTP/1.1\r\n";
    $data .= "Host: {$phone_ip}\r\n";
    $data .= "Referer: {$prov_host}\r\n";
    $data .= "Connection: Close\r\n";
    $data .= "Content-Type: text/xml; charset=utf-8\r\n";
    $data .= "Content-Length: " . (strLen('xml=') + strLen($xmlpi) + strLen($xml)) . "\r\n";
    $data .= "\r\n";
    $data .= 'xml=' . $xmlpi . $xml;
    $socket = @fSockOpen($phone_ip, 80, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Aastra: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Aastra: Failed to push XML to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Aastra: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
Ejemplo n.º 13
0
 function getNewPlayer($player, $rank)
 {
     $race_tmp = $this->_players_array[$player]->find('td[class=race] img');
     $race_src = $race_tmp[0]->src;
     $race = $this->_races[substr($race_src, strpos($race_src, "race/") + 5, strPos($race_src, "-") - (strpos($race_src, "race/") + 5))];
     $sex = substr($race_src, strpos($race_src, "-") + 1, 1);
     $class_tmp = $this->_players_array[$player]->find('td[class=cls] img');
     $class_src = $class_tmp[0]->src;
     $start = strpos($class_src, "class/") + 6;
     $end = strpos($class_src, ".gif");
     $diff = $end - $start;
     $class = $this->_classes[substr($class_src, $start, $diff)];
     //echo $player.": ".$race.": ".$sex.": ".$class."<br>";
     //echo $race;
     $newPlayer["Name"] = $player;
     $newPlayer["Race"] = $race;
     $newPlayer["Class"] = $class;
     $newPlayer["Sex"] = $sex;
     $newPlayer["Rank"] = $rank;
     $newPlayer["Spec"] = "";
     $newPlayer["New"] = true;
     return $newPlayer;
 }
Ejemplo n.º 14
0
 /**
  * This method will try to compare specific to a non-string type
  * of one of the values.
  * If one of the values is an object and it has method 'equals' that 
  * method is used. 
  * If both are objects or arrays and the output of print_r contains *RECURSION*
  * the outputs of print_r are compared to prevent Fatal error:  Nesting level too deep.
  * This is a compromise as the order of keys matters and 
  * print_r prints 0 different from false or null.
  * If both are numeric and at least one is float, they are compared with PRECISION
  * In all other cases comparision is done through == 
  * @param mixed $a if called by Action::check, reference (the result of parsing the string from the test)
  * @param mixed $b if called by Action::check, actual (the value from the method)
  * @result boolean wheather the supplied values seem to be equal
  */
 public function equals($a, $b)
 {
     if (is_object($a) && method_exists($a, 'equals')) {
         return $a->equals($b);
     }
     if (is_object($b) && method_exists($b, 'equals')) {
         return $b->equals($a);
     }
     if (is_object($a) && is_object($b) || is_array($a) && is_array($b)) {
         //prevent PHP Fatal error:  Nesting level too deep
         $aPrintR = print_r($a, true);
         $bPrintR = print_r($b, true);
         if (strPos($aPrintR, '*RECURSION*') !== false || strPos($bPrintR, '*RECURSION*') !== false) {
             return $aPrintR == $bPrintR;
         }
     }
     if (is_object($b) || is_array($b)) {
         return $this->valueToString($a) == $b;
     }
     if (is_numeric($a) && is_numeric($b) && (is_float($a) || is_float($b))) {
         return abs($b - $a) < $this->precision;
     }
     return $a == $b;
 }
Ejemplo n.º 15
0
function psetting($sectionname, $val = '')
{
    global $settings;
    if (strPos($sectionname, '|')) {
        list($section, $name) = explode('|', $sectionname);
        if ($section !== '' && $name !== '') {
            if (!array_key_exists($section, $settings) || !is_array($settings[$section])) {
                $settings[$section] = array();
            }
            $settings[$section][$name] = $val;
        }
    }
}
Ejemplo n.º 16
0
 public function start()
 {
     $urlPrefix = $this->config->get('web')->url;
     $url = $_SERVER['REQUEST_URI'];
     if (false !== strPos($url, '?')) {
         $url = subStr($url, 0, strPos($url, '?'));
     }
     if ($urlPrefix && 0 === strPos($url, $urlPrefix)) {
         $url = subStr($url, strLen($urlPrefix));
     }
     if ($this->config->get('web')->index) {
         $url = preg_replace('/' . preg_quote($this->config->get('web')->index) . '$/', '', $url);
     }
     $url = trim(rawUrlDecode($url), '/');
     $this->dispatcher->dispatch($this->config->routes(), $url);
 }
Ejemplo n.º 17
0
<?php

// this is an example server-side proxy to load feeds
$feed = $_REQUEST['feed'];
if (!empty($feed) && preg_match('#((https?)://(\\S*?\\.\\S*?))([\\s)\\[\\]{},;"\':<]|\\.\\s|$)#i', $feed)) {
    header('Content-Type: text/xml');
    $xml = file_get_contents($feed);
    // Clean up our own RSS feeds
    if (strPos($feed, 'feeds.feedburner.com/extblog') || strPos($feed, 'sencha.com/forum')) {
        // Cut out extraneous whitespace to aid in checking for existing CDATA tags below
        $xml = preg_replace('/[\\n\\r]/', '', $xml);
        $xml = preg_replace('/>\\s+</', '><', $xml);
        // Make textual items XML safe by enclosing them with CDATA sections unless it's already been done
        $xml = preg_replace('/<title>(?!<\\!\\[CDATA\\[)/', '<title><![CDATA[', $xml);
        $xml = preg_replace('/([^\\]][^\\]][^>])<\\/title>/', '$1]]></title>', $xml);
        $xml = preg_replace('/<author>(?!<\\!\\[CDATA\\[)/', '<author><![CDATA[', $xml);
        $xml = preg_replace('/([^\\]][^\\]][^>])<\\/author>/', '$1]]></author>', $xml);
        $xml = preg_replace('/<description>(?!<\\!\\[CDATA\\[)/', '<description><![CDATA[', $xml);
        $xml = preg_replace('/([^\\]][^\\]][^>])<\\/description>/', '$1]]></description>', $xml);
        $xml = preg_replace('/<link>(?!<\\!\\[CDATA\\[)/', '<link><![CDATA[', $xml);
        $xml = preg_replace('/([^\\]][^\\]][^>])<\\/link>/', '$1]]></link>', $xml);
    }
    $xml = str_replace('<content:encoded>', '<content>', $xml);
    $xml = str_replace('</content:encoded>', '</content>', $xml);
    $xml = str_replace('</dc:creator>', '</author>', $xml);
    echo str_replace('<dc:creator', '<author', $xml);
    return;
}
Ejemplo n.º 18
0
    }
}
if (empty($arResult["VARIABLES"]["GALLERY"])) {
    if (!($arParams["PERMISSION"] >= "W" && $user_alias == "NEW_ALIAS" && ($object == "group" || $object == "user" && $arResult["VARIABLES"]["user_id"] == $USER->GetID()))) {
        $arParams["NOTE_MESSAGE"] = GetMessage("SONET_GALLERY_NOT_FOUND");
        return 0;
    }
}
/********************************************************************
				/Default params
********************************************************************/
/********************************************************************
				Path
********************************************************************/
foreach ($arDefaultUrlTemplates404 as $url => $value) {
    if (strPos($url, "user_photo") === false && strPos($url, "group_photo") === false) {
        continue;
    }
    $arResult["~PATH_TO_" . strToUpper($url)] = str_replace(array("#user_id#", "#group_id#", "#user_alias#", "#path#", "#section_id#", "#element_id#", "#element_name#", "#action#"), array($arResult["VARIABLES"]["user_id"], $arResult["VARIABLES"]["group_id"], "#USER_ALIAS#", "#PATH#", "#SECTION_ID#", "#ELEMENT_ID#", "#ELEMENT_NAME#", "#ACTION#"), $arResult["PATH_TO_" . strToUpper($url)]);
}
$arResult["~PATH_TO_USER_PHOTO"] = $arResult["~PATH_TO_USER_PHOTO_GALLERY"];
$arResult["~PATH_TO_USER"] = str_replace("#user_id#", "#USER_ID#", empty($arResult["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : $arResult["PATH_TO_USER"]);
$arResult["VARIABLES"]["SECTION_ID"] = $arResult["VARIABLES"]["section_id"];
$arResult["VARIABLES"]["ELEMENT_ID"] = $arResult["VARIABLES"]["element_id"];
$arResult["VARIABLES"]["ACTION"] = $arResult["VARIABLES"]["action"];
$arResult["VARIABLES"]["PERMISSION"] = $arParams["PERMISSION"];
if ($componentPage == "user_photo_gallery") {
    $componentPage = "user_photo";
} elseif ($componentPage == "group_photo_gallery") {
    $componentPage = "group_photo";
}
		</th>
		<th style="width:217px;" colspan="2">
			<?php 
        echo __('Anlage');
        ?>
		</th>
		<th style="width:50px;">
			&nbsp;
		</th>
	</tr>
</thead>
<tbody>
<?php 
        $i = 0;
        foreach ($boi_perms as $p) {
            if (strPos($p['roles'], 'l') === false) {
                continue;
            }
            echo '<tr class="', $i % 2 === 0 ? 'odd' : 'even', '">', "\n";
            echo "<td>&nbsp;</td>\n";
            echo '<td>', htmlEnt($p['comment']), '</td>', "\n";
            echo '<td>', htmlEnt($p['host']), '</td>', "\n";
            echo "<td>\n";
            echo '<a href="', gs_url($SECTION, $MODULE, null, 'bp_del_h=' . $p['host_id'] . '&amp;edit=' . rawUrlEncode($edit_user) . '&amp;action=edit' . '&amp;name=' . rawUrlEncode($name) . '&amp;number=' . rawUrlEncode($number) . '&amp;page=' . $page . '&amp;sort=' . $sort . '&amp;sortorder=' . $sortorder), '" title="', __('entfernen'), '"><img alt="', __('entfernen'), '" src="', GS_URL_PATH, 'crystal-svg/16/act/editdelete.png" /></a>';
            echo "</td>\n";
            echo "</tr>\n";
            ++$i;
        }
        echo '<tr class="', $i % 2 === 0 ? 'odd' : 'even', '">', "\n";
        echo "<td>&nbsp;</td>\n";
        echo '<td colspan="2">', "\n";
    }
    unset($dispatcher_errors_html);
    if (!@array_key_exists('boi_url', @$MODULES[$SECTION]['sub'][$MODULE])) {
        echo 'Error.';
    } else {
        echo '<iframe id="boi-content" src="';
        echo $reverse_proxy;
        unset($reverse_proxy);
        /*
        include_once( GS_DIR .'inc/boi-soap/boi-soap.php' );
        echo _gs_boi_ssl_is_possible($_SESSION['sudo_user']['boi_host']) ? 'https':'http';
        */
        echo 'http';
        echo '/', $_SESSION['sudo_user']['boi_host'];
        echo htmlEnt($MODULES[$SECTION]['sub'][$MODULE]['boi_url']);
        echo strPos($MODULES[$SECTION]['sub'][$MODULE]['boi_url'], '?') === false ? '?' : '&amp;';
        echo 'SESSID=', htmlEnt(@$_SESSION['sudo_user']['boi_session']);
        echo '"></iframe>', "\n";
    }
    echo '</div>', "\n";
    echo '<script type="text/javascript">try {gs_sandbox_iframe("boi-content");} catch(e){}</script>', "\n";
}
?>

</div>

<div class="nofloat"></div>
<div id="copyright"><a target="_blank" href="http://www.amooma.de/gemeinschaft/">www.amooma.de/gemeinschaft</a><br />
<a target="_blank" href="http://www.amooma.de/"><img alt="&copy; amooma" src="<?php 
echo GS_URL_PATH;
?>
Ejemplo n.º 21
0
/**
 * Returns, if $str contains $needle.
 *
 * @param  string  $str      The string to check.
 * @param  string  $needle   he string, where $str must contains
 * @param  boolean $caseless Ignore the case? (defaults to FALSE)
 * @param  string  $charset  Encoding of the string (defaults to 'UTF-8')
 * @return boolean Returns TRUE on success, FALSE otherwise.
 * @uses   Multibyte extension The function requires that PHP have the Multibyte extension mb_string enabled.
 * @uses   \Beluga\strPos
 * @since  v0.1
 */
function strContains(string $str, string $needle, bool $caseless = false, string $charset = 'UTF-8') : bool
{
    return false !== strPos($str, $needle, $caseless, $charset);
}
Ejemplo n.º 22
0
    call_user_func(array(&$ob, $fn));
    die;
} else {
    CHTTP::SetStatus('405 Method not allowed');
    header('Allow: ' . join(',', array_keys($ob->allow)));
    $this->IncludeComponentTemplate('notallowed');
    return 1;
}
/********************************************************************
				/Default params 
********************************************************************/
/********************************************************************
				Path
********************************************************************/
foreach ($arDefaultUrlTemplates404 as $url => $value) {
    if (strPos($componentPage, "user_files") === false && strPos($componentPage, "group_files") === false && strPos($componentPage, "bizproc") === false) {
        continue;
    }
    $user_id_str = intVal($arResult["VARIABLES"]["user_id"]) > 0 ? $arResult["VARIABLES"]["user_id"] : $GLOBALS["USER"]->GetId();
    $arResult["~PATH_TO_" . strToUpper($url)] = str_replace(array("#user_id#", "#group_id#", "#path#", "#section_id#", "#element_id#", "#element_name#", "#action#", "#id#", "#task_id#"), array($user_id_str, $arResult["VARIABLES"]["group_id"], "#PATH#", "#SECTION_ID#", "#ELEMENT_ID#", "#ELEMENT_NAME#", "#ACTION#", "#ID#", "#ID#"), $arResult["PATH_TO_" . strToUpper($url)]);
}
if ($ob->workflow == 'bizproc' || $ob->workflow == 'bizproc_limited') {
    $arResult["~PATH_TO_GROUP_FILES_ELEMENT_HISTORY"] = $arResult["~PATH_TO_GROUP_FILES_WEBDAV_BIZPROC_HISTORY"];
    $arResult["~PATH_TO_USER_FILES_ELEMENT_HISTORY"] = $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_HISTORY"];
}
$arResult["~PATH_TO_USER"] = str_replace("#user_id#", "#USER_ID#", empty($arResult["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : $arResult["PATH_TO_USER"]);
$arResult["VARIABLES"]["ROOT_SECTION_ID"] = $arParams["ROOT_SECTION_ID"];
if (empty($arResult["VARIABLES"]["SECTION_ID"])) {
    $arResult["VARIABLES"]["SECTION_ID"] = $arResult["VARIABLES"]["section_id"];
}
$arResult["VARIABLES"]["ELEMENT_ID"] = $arResult["VARIABLES"]["element_id"];
Ejemplo n.º 23
0
        }
    }
    if (empty($aMsg)) {
        $redirectTo = $ob->_get_path($ob->GetMetaID("TRASH"));
        $redirectHilight = 'all_restored';
    }
}
WDClearComponentCache(array("webdav.element.edit", "webdav.element.hist", "webdav.element.upload", "webdav.element.view", "webdav.menu", "webdav.section.edit", "webdav.section.list"));
if (!empty($aMsg)) {
    $e = new CAdminException($aMsg);
    $GLOBALS["APPLICATION"]->ThrowException($e);
    return false;
} else {
    $arParams["CONVERT"] = strPos($arParams["~SECTIONS_URL"], "?") === false ? true : false;
    if (!$arParams["CONVERT"]) {
        $arParams["CONVERT"] = strPos($arParams["~SECTIONS_URL"], "?") > strPos($arParams["~SECTIONS_URL"], "#PATH#");
    }
    if (empty($redirectTo)) {
        $url = CComponentEngine::MakePathFromTemplate($arParams["~SECTIONS_URL"], array("PATH" => implode("/", $arParams["CONVERT"] ? $arResult["NAV_CHAIN_UTF8"] : $arResult["NAV_CHAIN"])));
    } else {
        $url = WDAddPageParams(str_replace(array("//", "%23"), array("/", "#"), CComponentEngine::MakePathFromTemplate($arParams["~SECTIONS_URL"], array("PATH" => $redirectTo))), array('result' => $redirectHilight));
    }
    if (isset($_REQUEST["AJAX"])) {
        if (!(isset($_REQUEST['redirect']) && $_REQUEST['redirect'] == 'N')) {
            $APPLICATION->RestartBuffer();
            echo "<script>window.location = \"" . CUtil::JSEscape($url) . "\";</script>";
            die;
        }
    } else {
        LocalRedirect($url);
    }
Ejemplo n.º 24
0
 public static function fetchAutoWidgetCode($widget, $paramsArray, $width, $height, $bgcolor = "#FFFFFF")
 {
     global $CFG;
     $ret = "";
     //determine if this is mobile or not
     if (self::isMobile($CFG->filter_poodll_html5widgets)) {
         $pos = strPos($widget, ".lzx.");
         if ($pos > 0) {
             $basestring = substr($widget, 0, $pos + 4);
             $widget = $basestring . ".js";
             $ret = self::fetchJSWidgetiFrame($widget, $paramsArray, $width, $height, $bgcolor = "#FFFFFF");
         }
     } else {
         //$ret=$browser->getPlatform();
         $ret = self::fetchSWFWidgetCode($widget, $paramsArray, $width, $height, $bgcolor = "#FFFFFF");
     }
     return $ret;
 }
Ejemplo n.º 25
0
    if (count($arCalendarIBlockID) > 0) {
        $rsCalendarSection = CIBlockSection::GetList(array("timestamp_x" => "desc"), array("IBLOCK_ID" => $arCalendarIBlockID, "SOCNET_GROUP_ID" => $arResult["VARIABLES"]["group_id"]));
        if ($arCalendarSection = $rsCalendarSection->Fetch()) {
            $arParams["CALENDAR_GROUP_IBLOCK_ID"] = $arCalendarSection["IBLOCK_ID"];
        }
    }
} elseif (strPos($componentPage, "user_forum") !== false || strPos($componentPage, "group_forum") !== false || $componentPage == "user" || $componentPage == "group" || $componentPage == "index") {
    $path = str_replace(array("\\", "//"), "/", dirname(__FILE__) . "/include/forum.php");
    if (!file_exists($path)) {
        $arParams["ERROR_MESSAGE"] = "Forum file is not exist.";
        $res = 0;
    } else {
        $res = (include_once $path);
    }
    $arParams["FATAL_ERROR"] = $res <= 0 ? "Y" : "N";
} elseif (strPos($componentPage, "user_content_search") !== false || strPos($componentPage, "group_content_search") !== false) {
    $path = str_replace(array("\\", "//"), "/", dirname(__FILE__) . "/include/search.php");
    if (!file_exists($path)) {
        $arParams["ERROR_MESSAGE"] = "Content search file is not exist.";
        $res = 0;
    } else {
        $res = (include_once $path);
    }
    $arParams["FATAL_ERROR"] = $res <= 0 ? "Y" : "N";
}
/********************************************************************
				/Content search
********************************************************************/
CUtil::InitJSCore(array("window", "ajax"));
$this->IncludeComponentTemplate($componentPage, array_key_exists($componentPage, $arCustomPagesPath) ? $arCustomPagesPath[$componentPage] : "");
//top panel button to reindex
Ejemplo n.º 26
0
function uploadfile($filedata, $fileextension, $mediatype, $actionid, $contextid, $comp, $farea, $itemid)
{
    global $CFG, $USER;
    //setup our return object
    $return = fetchReturnArray(true);
    //make sure nobodyapassed in a bogey file extension
    switch ($fileextension) {
        case "mp3":
        case "flv":
        case "jpg":
        case "png":
        case "xml":
        case "mov":
        case "wav":
        case "mp4":
        case "3gpp":
        case "3gp":
        case "3g2":
        case "aac":
        case "wma":
        case "wmv":
        case "smf":
        case "amr":
        case "ogg":
            break;
        case "":
        default:
            //if we are set to FFMPEG convert,lets  not muddle with the file extension
            if ($CFG->filter_poodll_ffmpeg && $mediatype == 'audio' && $CFG->filter_poodll_audiotranscode) {
                //do nothing
            } elseif ($CFG->filter_poodll_ffmpeg && $mediatype == 'video' && $CFG->filter_poodll_videotranscode) {
                //do nothing
            } else {
                if ($mediatype == 'video') {
                    $fileextension = "mp4";
                } elseif ($mediatype == 'image') {
                    $fileextension = "jpg";
                } else {
                    $fileextension = "mp3";
                }
            }
    }
    //init our fs object
    $fs = get_file_storage();
    //assume a root level filepath
    $filepath = "/";
    //make our filerecord
    $record = new stdClass();
    $record->filearea = $farea;
    $record->component = $comp;
    $record->filepath = $filepath;
    $record->itemid = $itemid;
    $record->license = $CFG->sitedefaultlicense;
    $record->author = 'Moodle User';
    $record->contextid = $contextid;
    $record->userid = $USER->id;
    $record->source = '';
    //make filename and set it
    //we are trying to remove useless junk in the draft area here
    //when we know its stable, we will do the same for non images too
    if ($mediatype == 'image') {
        $filenamebase = "upfile_" . $actionid;
    } else {
        $filenamebase = "upfile_" . rand(100, 32767) . rand(100, 32767);
    }
    $fileextension = "." . $fileextension;
    $filename = $filenamebase . $fileextension;
    $record->filename = $filename;
    //in most cases we will be storing files in a draft area and lettign Moodle do the rest
    //previously we only allowed one file in draft, but we removed that limit
    /*
    if($farea=='draft'){
        $fs->delete_area_files($contextid,$comp,$farea,$itemid);
    }
    */
    //if file already exists, raise an error
    if ($fs->file_exists($contextid, $comp, $farea, $itemid, $filepath, $filename)) {
        if ($mediatype == 'image') {
            //delete any existing draft files.
            $file = $fs->get_file($contextid, $comp, $farea, $itemid, $filepath, $filename);
            $file->delete();
            //check there is no metadata prefixed to the base 64. From OL widgets, none, from JS yes
            $metapos = strPos($filedata, ",");
            if ($metapos > 10 && $metapos < 30) {
                $filedata = substr($filedata, $metapos + 1);
            }
            //decode the data and store it
            $xfiledata = base64_decode($filedata);
            //create the file
            $stored_file = $fs->create_file_from_string($record, $xfiledata);
        } else {
            $stored_file = false;
            $return['success'] = false;
            array_push($return['messages'], "Already exists, file with filename:" . $filename);
        }
    } else {
        //check there is no metadata prefixed to the base 64. From OL widgets, none, from JS yes
        //if so it will look like this: data:image/png;base64,iVBORw0K
        //we remove it, there must be a better way of course ...
        //$metapos = strPos($filedata,";base64,");
        $metapos = strPos($filedata, ",");
        if ($metapos > 10 && $metapos < 30) {
            //$trunced = substr($filedata,0,$metapos+8);
            $filedata = substr($filedata, $metapos + 1);
        }
        //decode the data and store it in memory
        $xfiledata = base64_decode($filedata);
        //Determine if we need to convert and what format the conversions should take
        if ($CFG->filter_poodll_ffmpeg && $CFG->filter_poodll_audiotranscode && $fileextension != ".mp3" && $mediatype == "audio") {
            $convext = ".mp3";
        } else {
            if ($CFG->filter_poodll_ffmpeg && $CFG->filter_poodll_videotranscode && $fileextension != ".mp4" && $mediatype == "video") {
                $convext = ".mp4";
            } else {
                $convext = false;
            }
        }
        //if we need to convert with ffmpeg, get on with it
        if ($convext) {
            //determine the temp directory
            if (isset($CFG->tempdir)) {
                $tempdir = $CFG->tempdir . "/";
            } else {
                //moodle 2.1 users have no $CFG->tempdir
                $tempdir = $CFG->dataroot . "/temp/";
            }
            //actually make the file on disk so FFMPEG can get it
            $ret = file_put_contents($tempdir . $filename, $xfiledata);
            //if successfully saved to disk, convert
            if ($ret) {
                $do_bg_encoding = $CFG->filter_poodll_bgtranscode_audio && $convext == ".mp3" || $CFG->filter_poodll_bgtranscode_video && $convext == ".mp4";
                if ($do_bg_encoding && $CFG->version >= 2014051200) {
                    $stored_file = convert_with_ffmpeg_bg($record, $tempdir, $filename, $filenamebase, $convext);
                } else {
                    $stored_file = convert_with_ffmpeg($record, $tempdir, $filename, $filenamebase, $convext);
                }
                if ($stored_file) {
                    $filename = $stored_file->get_filename();
                    //if failed, default to using the original uploaded data
                    //and delete the temp file we made
                } else {
                    $stored_file = $fs->create_file_from_string($record, $xfiledata);
                    if (is_readable(realpath($tempdir . $filename))) {
                        unlink(realpath($tempdir . $filename));
                    }
                }
                //if couldn't create on disk fall back to the original data
            } else {
                $stored_file = $fs->create_file_from_string($record, $xfiledata);
            }
            //if we are not converting, then just create our moodle file entry with original file data
        } else {
            $stored_file = $fs->create_file_from_string($record, $xfiledata);
        }
    }
    //if successful return filename
    if ($stored_file) {
        array_push($return['messages'], $filename);
        //if unsuccessful, return error
    } else {
        $return['success'] = false;
        array_push($return['messages'], "unable to save file with filename:" . $filename);
    }
    //we process the result for return to browser
    $xml_output = prepareXMLReturn($return, $actionid);
    //we return to widget/client the result of our file operation
    return $xml_output;
}
Ejemplo n.º 27
0
/**
 * check gs version is Beta
 *
 * @since  3.3.0
 * @return boolean true if beta release
 */
function isBeta()
{
    return strPos(get_site_version(false), "b");
}
Ejemplo n.º 28
0
function uploadfile($filedata, $fileextension, $actionid, $contextid, $comp, $farea, $itemid)
{
    global $CFG, $USER;
    //setup our return object
    $return = fetchReturnArray(true);
    //make sure nobodyapassed in a bogey file extension
    switch ($fileextension) {
        case "mp3":
        case "flv":
        case "jpg":
        case "png":
        case "xml":
        case "mov":
        case "mp4":
            break;
        default:
            $fileextension = "";
    }
    //init our fs object
    $fs = get_file_storage();
    //assume a root level filepath
    $filepath = "/";
    //make our filerecord
    $record = new stdClass();
    $record->filearea = $farea;
    $record->component = $comp;
    $record->filepath = $filepath;
    $record->itemid = $itemid;
    $record->license = $CFG->sitedefaultlicense;
    $record->author = 'Moodle User';
    $record->contextid = $contextid;
    $record->userid = $USER->id;
    $record->source = '';
    //make filename and set it
    $filename = "upfile_" . rand(100, 32767) . rand(100, 32767) . "." . $fileextension;
    $record->filename = $filename;
    //in most cases we will be storing files in a draft area and lettign Moodle do the rest
    //one condition of using this function is that only one file can be here,
    //attachment limits in question. could be bypassed if reason enough
    if ($farea == 'draft') {
        $fs->delete_area_files($contextid, $comp, $farea, $itemid);
    }
    //if file already exists, raise an error
    if ($fs->file_exists($contextid, $comp, $farea, $itemid, $filepath, $filename)) {
        $return['success'] = false;
        array_push($return['messages'], "Already exists, file with filename:" . $filename);
    } else {
        //check there is no metadata prefixed to the base 64. From OL widgets, none, from JS yes
        //if so it will look like this: data:image/png;base64,iVBORw0K
        //we remove it, there must be a better way of course ...
        //$metapos = strPos($filedata,";base64,");
        $metapos = strPos($filedata, ",");
        if ($metapos > 10 && $metapos < 30) {
            //$trunced = substr($filedata,0,$metapos+8);
            $filedata = substr($filedata, $metapos + 1);
        }
        //actually make the file
        $xfiledata = base64_decode($filedata);
        $stored_file = $fs->create_file_from_string($record, $xfiledata);
        //if successful return filename
        if ($stored_file) {
            array_push($return['messages'], $filename);
            //array_push($return['messages'],$filedata );
            //array_push($return['messages'],$stored_file->get_itemid() );
            //if unsuccessful, return error
        } else {
            $return['success'] = false;
            array_push($return['messages'], "unable to save file with filename:" . $filename);
        }
    }
    //we process the result for return to browser
    $xml_output = prepareXMLReturn($return, $actionid);
    //we return to widget/client the result of our file operation
    return $xml_output;
}
Ejemplo n.º 29
0
    $access->check_authenticity();
    $calendarlib->drop_calendar($_REQUEST['calendarId']);
    $_REQUEST["calendarId"] = 0;
}
if (isset($_REQUEST["save"])) {
    check_ticket('admin-calendars');
    $customflags["customlanguages"] = $_REQUEST["customlanguages"];
    $customflags["customlocations"] = $_REQUEST["customlocations"];
    $customflags["customparticipants"] = $_REQUEST["customparticipants"];
    $customflags["customcategories"] = $_REQUEST["customcategories"];
    $customflags["custompriorities"] = $_REQUEST["custompriorities"];
    $customflags["customsubscription"] = isset($_REQUEST["customsubscription"]) ? $_REQUEST["customsubscription"] : 'n';
    $customflags["personal"] = $_REQUEST["personal"];
    $customflags['customstatus'] = isset($_REQUEST['customstatus']) ? $_REQUEST['customstatus'] : 'y';
    $options = $_REQUEST['options'];
    if (array_key_exists('customcolors', $options) && strPos($options['customcolors'], '-') > 0) {
        $customColors = explode('-', $options['customcolors']);
        if (!preg_match('/^[0-9a-fA-F]{3,6}$/', $customColors[0])) {
            $options['customfgcolor'] = '000000';
        } else {
            $options['customfgcolor'] = $customColors[0];
        }
        if (!preg_match('/^[0-9a-fA-F]{3,6}$/', $customColors[1])) {
            $options['custombgcolor'] = 'ffffff';
        } else {
            $options['custombgcolor'] = $customColors[1];
        }
    }
    if (!preg_match('/^[0-9a-fA-F]{3,6}$/', $options['customfgcolor'])) {
        $options['customfgcolor'] = '';
    }
Ejemplo n.º 30
0
 /**
  * Gets the user with the given username or email
  * @param string $usernameOrEmail Either a username or an email.
  * @return User The user.
  * @throws NotFoundException If no user exists with that username or email.
  */
 public function getByNameOrEmail($usernameOrEmail)
 {
     if (strPos($usernameOrEmail, '@') === false) {
         return $this->getByName($usernameOrEmail);
     } else {
         return $this->getByEmail($usernameOrEmail);
     }
 }