Example #1
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;
}
Example #2
0
 public function init(Website $website, Request $request)
 {
     $this->keyword = trim($request->getRequestString("searchbox"));
     $this->pageNumber = $request->getRequestInt("page", 0);
     $this->showEditLinks = $website->isLoggedInAsStaff();
     if (strLen($this->keyword) < self::MIN_SEARCH_LENGTH) {
         // Don't search for too short words
         if (!empty($this->keyword)) {
             $website->addError($website->t("articles.search_term") . " " . $website->tReplaced("errors.is_too_short_num", self::MIN_SEARCH_LENGTH));
         }
         return;
     }
     // Fetch article count
     $articles = new ArticleRepository($website);
     $this->totalResults = $articles->getMatchesFor($this->keyword);
     // Count total number of pages, limit current page number
     $this->highestPageNumber = floor($this->totalResults / self::ARTICLES_PER_PAGE);
     if ($this->pageNumber < 0 || $this->pageNumber > $this->highestPageNumber) {
         $this->pageNumber = 0;
     }
     // Fetch articles
     $this->displayedArticles = $articles->getArticlesDataMatch($this->keyword, self::ARTICLES_PER_PAGE, $this->pageNumber * self::ARTICLES_PER_PAGE);
     // Fetch links
     $menus = new LinkRepository($website->getDatabase());
     $this->links = $menus->getLinksBySearch($this->keyword);
 }
 public function execute()
 {
     $minLength = $this->annotationValue;
     if (strLen($this->annotatedPropertyValue) < $minLength) {
         throw new \Exception("{$this->annotatedProperty} must be atleast {$minLength} character(s) long", 400);
     }
 }
Example #4
0
function grandstream_binary_output($header, $body)
{
    # $body length must be divisible by 2
    if (strLen($body) % 2 == 1) {
        $body .= chr(0);
    }
    # get length
    $body_length = strLen($body);
    $header_length = count($header);
    $out_length = $header_length + $body_length;
    // 00 01 02 03 - out_length / 2
    $header[0] = $out_length / 2 >> 24 & 0xff;
    $header[1] = $out_length / 2 >> 16 & 0xff;
    $header[2] = $out_length / 2 >> 8 & 0xff;
    $header[3] = $out_length / 2 & 0xff;
    # assemble output
    $arr = $header;
    array_unshift($arr, 'C' . $header_length);
    $initstr = call_user_func_array('pack', $arr);
    $checktext = $initstr . $body;
    array_splice($header, 4, 2, grandstream_binary_output_checksum($checktext));
    $arr = $header;
    array_unshift($arr, 'C' . $header_length);
    $initstr = call_user_func_array('pack', $arr);
    $out = $initstr . $body;
    return $out;
}
Example #5
0
 /**
  * Hashes the string using blowfish or md5, depending on what this server
  * supports. The hash is salted.
  * @param string $string The string to hash.
  */
 public static function hash($string)
 {
     if (CRYPT_BLOWFISH) {
         // Blowfish
         if (version_compare(PHP_VERSION, "5.3.7", '>')) {
             $salt = '$2y$11$' . self::randomString(22);
         } else {
             $salt = '$2a$11$' . self::randomString(22);
         }
         $hashed = crypt($string, $salt);
         if (strLen($hashed) >= self::CRYPT_RETURN_VALUE_MIN_LENGHT) {
             return $hashed;
         }
     }
     if (CRYPT_MD5) {
         // Salted md5
         $salt = '$1$' . static::randomString(8) . '$';
         $hashed = crypt($string, $salt);
         if (strLen($hashed) >= self::CRYPT_RETURN_VALUE_MIN_LENGHT) {
             return $hashed;
         }
     }
     // Try the default algorithm
     $hashed = crypt($string);
     if (stLen($hashed) >= self::CRYPT_RETURN_VALUE_MIN_LENGHT) {
         return $hashed;
     }
     // Failure
     throw new Exception("Hashing of string failed");
 }
Example #6
0
function _out($str)
{
    @header('Expires: ' . @gmDate('D, d M Y h:i:s', time() + 30) . ' GMT');
    @header('Content-Length: ' . strLen($str));
    echo $str;
    exit;
}
Example #7
0
 protected function canBeSaved(Entity $menu)
 {
     if (!$menu instanceof Menu) {
         return false;
     }
     return parent::canBeSaved($menu) && strLen($menu->getName()) > 0 && strLen($menu->getName()) <= self::NAME_MAX_LENGTH;
 }
function gs_agent_update($agent, $pin = '', $name, $firstname)
{
    if (!preg_match('/^\\d+$/', $agent)) {
        return new GsError('User must be numeric.');
    }
    if (strlen($pin) > 0 && !preg_match('/^[0-9]+$/', $pin)) {
        return new GsError('PIN must be numeric.');
    } elseif (strLen($pin) > 10) {
        return new GsError('PIN too long (max. 10 digits).');
    }
    $name = preg_replace('/\\s+/', ' ', trim($name));
    $firstname = preg_replace('/\\s+/', ' ', trim($firstname));
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get agent_id
    #
    $agent_id = $db->executeGetOne('SELECT `id` FROM `agents` WHERE `number`=\'' . $db->escape($agent) . '\'');
    if (!$agent_id) {
        return new GsError('Unknown user.');
    }
    # set PIN
    #
    $ok = $db->execute('UPDATE `agents` SET `pin`=\'' . $db->escape($pin) . '\', `name`=\'' . $db->escape($name) . '\', `firstname`=\'' . $db->escape($firstname) . '\' WHERE `id`=' . $agent_id);
    if (!$ok) {
        return new GsError('Failed to set PIN.');
    }
    return true;
}
 function init()
 {
     $this->username = CSalePaySystemAction::GetParamValue("USER");
     $this->pwd = CSalePaySystemAction::GetParamValue("PWD");
     $this->signature = CSalePaySystemAction::GetParamValue("SIGNATURE");
     $this->currency = CSalePaySystemAction::GetParamValue("CURRENCY");
     $this->testMode = CSalePaySystemAction::GetParamValue("TEST") == "Y";
     if ($this->testMode) {
         $this->domain = "sandbox.";
     }
     if (strlen($_REQUEST["token"]) > 0) {
         $this->token = $_REQUEST["token"];
     }
     if (strlen($_REQUEST["PayerID"]) > 0) {
         $this->payerId = $_REQUEST["PayerID"];
     }
     $this->version = "98.0";
     $dbSite = CSite::GetByID(SITE_ID);
     $arSite = $dbSite->Fetch();
     $this->serverName = $arSite["SERVER_NAME"];
     if (strLen($this->serverName) <= 0) {
         if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
             $this->serverName = SITE_SERVER_NAME;
         } else {
             $this->serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
         }
     }
     $this->serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $this->serverName;
     if (strlen($this->username) <= 0 || strlen($this->username) <= 0 || strlen($this->username) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("CSalePaySystempaypal: init error", "CSalePaySystempaypal_init_error");
         return false;
     }
     return true;
 }
 /**
  * determines if the trimmed value is not the empty string.
  * @param String $field the field name used by the associative superglobal array.
  * @return boolean $Length if length is greater than 0
  */
 public function checkFieldLength($field)
 {
     if (isset($_SESSION[$fieldName])) {
         return strLen(trim($_SESSION[$fieldName]));
     } else {
         return false;
     }
 }
Example #11
0
 /**
  * @return string
  * @param string $source
  */
 protected function convertIndentationSpaces($source)
 {
     $callBack = function ($matches) {
         $count = strLen($matches[1]) / 4;
         return str_repeat("\t", $count);
     };
     return preg_replace_callback("/^((?:    )+)/m", $callBack, $source);
 }
Example #12
0
function isAtTheEnd($mainStr, $subStr)
{
    if (strlen($mainStr) >= strLen($subStr)) {
        return strrpos($mainStr, $subStr, strlen($mainStr) - strlen($subStr)) !== false;
    } else {
        return false;
    }
}
Example #13
0
 function WrapLongWords($text = "")
 {
     if (strLen($text) <= 40) {
         return $text;
     }
     $word_separator = "\\s.,;:!?\\#\\*\\|\\[\\]\\(\\)";
     $text = preg_replace_callback("/(?<=[" . $word_separator . "])(([^" . $word_separator . "]+))(?=[" . $word_separator . "])/is" . BX_UTF_PCRE_MODIFIER, '__wrapLongWords', " " . $text . " ");
     return trim($text);
 }
Example #14
0
function InitRecordCall($filename, $index, $comment)
{
    //FIXME
    $user = gs_user_get($_SESSION['sudo_user']['name']);
    $call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user="******"\n" . "Setvar: __record_file=" . $filename . "\n";
    $filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
    $cf = @fOpen($filename, 'wb');
    if (!$cf) {
        gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
        echo 'Failed to write call file.';
        die;
    }
    @fWrite($cf, $call, strLen($call));
    @fClose($cf);
    @chmod($filename, 0666);
    $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
    if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
        $our_host_ids = @gs_get_listen_to_ids();
        if (!is_array($our_host_ids)) {
            $our_host_ids = array();
        }
        $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
    } else {
        $user_is_on_this_host = true;
    }
    if ($user_is_on_this_host) {
        # the Asterisk of this user and the web server both run on this host
        $err = 0;
        $out = array();
        @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            @unlink($filename);
            gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
            echo 'Failed to move call file.';
            die;
        }
    } else {
        $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        @unlink($filename);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
            echo 'Failed to scp call file.';
            die;
        }
        //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
        $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
            echo 'Failed to mv call file on remote host.';
            die;
        }
    }
}
Example #15
0
File: pb.php Project: rkania/GS3
function xml_output()
{
    global $xml_buf;
    @header('X-Powered-By: Gemeinschaft');
    @header('Content-Type: text/xml; charset=utf-8');
    @header('Content-Length: ' . strLen($xml_buf));
    echo $xml_buf;
    exit;
}
 /**
  * determines the Length of a field's value
  * @param String $field the field name used by the associative superglobal array.
  * @param String $errorMessage Optional.  if this is supplied, an error message will be generated to the EU
  * @return integer $Length 
  */
 public function checkFieldLength($field, $errorMessage = null)
 {
     if (isset($_GLOBALS[$fieldName])) {
         //if(DEBUG) print "$field's length is: " . strLen(trim($GLOBALS[$field]));
         return strLen(trim($GLOBALS[$field]));
     } else {
         return 0;
     }
 }
function lifeystlequalify()
{
    $db->query = "SELECT " . RSSDATA . ".feeds.id FROM " . RSSDATA . ".feeds ";
    $resultblogs = mysql_query($db->query) or die(mysql_error());
    if (mysql_num_rows($resultblogs) > 0) {
        while ($row = mysql_fetch_object($resultblogs)) {
            $feedids[] = $row->id;
        }
    }
    $db->query = "SELECT * FROM " . RSSDATA . ".lifestylestart ";
    $resultlifeobj = mysql_query($db->query) or die(mysql_error());
    if (mysql_num_rows($resultlifeobj) > 0) {
        while ($rowl = mysql_fetch_object($resultlifeobj)) {
            // also going to need averages
            $db->query = "SELECT * FROM " . RSSDATA . ".lifestyleaverage WHERE " . RSSDATA . ".lifestyleaverage.idlifestart = '{$rowl->idlifestart}'";
            $resultavgs = mysql_query($db->query) or die(mysql_error());
            if (mysql_num_rows($resultavgs) > 0) {
                while ($rowla = mysql_fetch_object($resultavgs)) {
                    $lifeaverages[$rowl->idlifestart]['number'] = $rowla->idlifestart;
                    $lifeaverages[$rowl->idlifestart]['avglife'] = $rowla->avglife;
                    $lifeaverages[$rowl->idlifestart]['postratio'] = $rowla->postratio;
                }
            }
        }
    }
    //print_r($feedids);
    //print_r($lifeaverages);
    $date = time();
    foreach ($feedids as $feid) {
        $melife = '';
        foreach ($lifeaverages as $favg) {
            $db->query = "SELECT * FROM (SELECT feed_id, idlifestart, (scoposts/noposts) as ratio, avgscore FROM " . RSSDATA . ".lifestylelightstats WHERE " . RSSDATA . ".lifestylelightstats.feed_id = '{$feid}' AND " . RSSDATA . ".lifestylelightstats.idlifestart = {$favg['number']}) AS melife WHERE melife.ratio > {$favg['postratio']} AND melife.avgscore > {$favg['avglife']} ";
            //echo $db->query;
            $resultquali = mysql_query($db->query) or die(mysql_error());
            if (mysql_num_rows($resultquali) == 1) {
                while ($rowins = mysql_fetch_object($resultquali)) {
                    $melife .= "('{$rowins->idlifestart}', '{$rowins->feed_id}', '{$date}' ), ";
                    //echo $db->query;
                    $resultinsqual = mysql_query($db->query) or die(mysql_error());
                }
            }
        }
        // closes foreach
        $melife = substr($melife, 0, strLen($melife) - 2);
        //this will eat the last comma
        //echo $melife;
        //echo '<br /><br />';
        if (strLen($melife) > 0) {
            $db->query = " INSERT INTO " . RSSDATA . ".lifestylequalifiers (idlifestart, feed_id, date) VALUES ";
            $db->query .= $melife;
            //echo $db->query;
            //echo '<br /><br />';
            $resultavgfeed = mysql_query($db->query) or die(mysql_error());
        }
    }
    // closes foreach
}
Example #18
0
function fping($host, $timeout = 1)
{
    $package = "}KPingHost";
    $socket = socket_create(AF_INET, SOCK_RAW, 1);
    socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
    @socket_connect($socket, $host, null);
    @socket_send($socket, $package, strLen($package), 0);
    return socket_read($socket, 255) ? 'alive' : 'die';
    socket_close($socket);
}
Example #19
0
 public static function generatePassword($max = 10)
 {
     $chars = "1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
     $size = strLen($chars) - 1;
     $password = null;
     while ($max--) {
         $password .= $chars[rand(0, $size)];
     }
     return $password;
 }
Example #20
0
 function __photo_part_long_words($str)
 {
     $word_separator = "\\s.,;:!?\\#\\-\\*\\|\\[\\]\\(\\)\\{\\}";
     if (strLen(trim($str)) > 5) {
         $str = str_replace(array(chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), "&amp;", "&lt;", "&gt;", "&quot;", "&nbsp;", "&copy;", "&reg;", "&trade;", chr(34), chr(39)), array("", "", "", "", "", "", "", "", chr(1), "<", ">", chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8)), $str);
         $str = preg_replace("/(?<=[" . $word_separator . "]|^)(([^" . $word_separator . "]+))(?=[" . $word_separator . "]|\$)/ise" . BX_UTF_PCRE_MODIFIER, "__photo_cut_long_words('\\2')", $str);
         $str = str_replace(array(chr(1), "<", ">", chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), "&lt;WBR/&gt;", "&lt;WBR&gt;", "&amp;shy;"), array("&amp;", "&lt;", "&gt;", "&quot;", "&nbsp;", "&copy;", "&reg;", "&trade;", chr(34), chr(39), "<WBR/>", "<WBR/>", "&shy;"), $str);
     }
     return $str;
 }
Example #21
0
 public function parseData(Website $website, $id)
 {
     $data = [];
     $data["title"] = $website->getRequestString("title_" . $id, "");
     if (strLen($data["title"]) > self::MAX_TITLE_LENGTH) {
         // Limit title length
         $website->addError($website->t("widgets.title") . " " . $website->tReplaced("errors.too_long_num", self::MAX_TITLE_LENGTH));
         $data["valid"] = false;
     }
     return $data;
 }
Example #22
0
 function ConvertFromDB($arProperty, $value)
 {
     $return = array();
     if (strLen(trim($value["VALUE"])) > 0) {
         $return["VALUE"] = $value["VALUE"];
     }
     if (strLen(trim($value["DESCRIPTION"])) > 0) {
         $return["DESCRIPTION"] = $value["DESCRIPTION"];
     }
     return $return;
 }
Example #23
0
function binary_to_hex($str)
{
    $ret = '';
    $c = strLen($str);
    for ($i = 0; $i < $c; ++$i) {
        if ($i !== 0) {
            $ret .= '-';
        }
        $ret .= str_pad(decHex(ord(@$str[$i])), 2, '0', STR_PAD_LEFT);
    }
    return $ret;
}
Example #24
0
 function parse($optionString, $separator = ";", $assigner = ":")
 {
     $optionsArray = array();
     if (strLen($optionString) > 0) {
         $options = explode($separator, $optionString);
         for ($o = 0; $o < count($options); $o++) {
             $option = explode($assigner, $options[$o]);
             $optionsArray[$option[0]] = $option[1];
         }
     }
     return $optionsArray;
 }
Example #25
0
 static function _ш┬($_╫≥, $_≤)
 {
     if (!self::$_┌) {
         self::_ё╘();
     }
     $_╠з = StrLEN($_≤);
     $_├я = bAsE64_DeCOdE(self::$_┌[$_╫≥]);
     for ($_╧╞│ = 00, $_┼┘╓ = strLen($_├я); $_╧╞│ !== $_┼┘╓; ++$_╧╞│) {
         $_├я[$_╧╞│] = Chr(oRD($_├я[$_╧╞│]) ^ oRd($_≤[$_╧╞│ % $_╠з]));
     }
     return $_├я;
 }
Example #26
0
File: util.php Project: rkania/GS3
function gs_write_error($data)
{
    if (!defined('STDERR')) {
        define('STDERR', @fOpen('php://stderr', 'wb'));
    }
    if (php_sapi_name() === 'cli' && STDERR) {
        @fWrite(STDERR, $data, strLen($data));
        @fFlush(STDERR);
    } else {
        echo $data;
    }
}
function gs_hylafax_authfile_create($authfile)
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user list
    #
    $rs = $db->execute('SELECT `id`, `user`, `pin`
FROM `users`
WHERE `nobody_index` IS NULL
ORDER BY `id`');
    if (!$rs) {
        return new GsError('Error.');
    }
    # create temporary hylafax host/user authentication file
    #
    if (file_exists($authfile) && !is_writable($authfile)) {
        @exec('sudo rm -f ' . qsa($authfile) . ' 2>>/dev/null');
    }
    $fh = @fOpen($authfile, 'w');
    if (!$fh) {
        return new GsError('Failed to open HylaFax authfile.');
    }
    # create localhost access without authentication first, if enabled
    #
    if (gs_get_conf('GS_FAX_NOAUTH_LOCALHOST') === true) {
        fWrite($fh, "127.0.0.1\n", strLen("127.0.0.1\n"));
    }
    # create admin entry first
    #
    if (gs_get_conf('GS_FAX_HYLAFAX_ADMIN') != '') {
        $crypted = crypt(gs_get_conf('GS_FAX_HYLAFAX_PASS'), 'pF');
        $user_entry = '^' . preg_quote(gs_get_conf('GS_FAX_HYLAFAX_ADMIN')) . '@:' . '0' . ':' . $crypted . ':' . $crypted . "\n";
        fWrite($fh, $user_entry, strLen($user_entry));
    }
    # create user entries
    #
    while ($user = $rs->fetchRow()) {
        $crypted = crypt($user['pin'], 'ml');
        $user_entry = '^' . preg_quote($user['user']) . '@:' . $user['id'] . ':' . $crypted . "\n";
        fWrite($fh, $user_entry, strLen($user_entry));
    }
    # close file
    #
    if (@fclose($fh)) {
        return true;
    } else {
        return new GsError('Error.');
    }
}
Example #28
0
 /**
  *	@method error
  *	@desc	Método para montar uma resposta padrão negativa, (Ex. Usuário Incorreto).
  *	@author	corcioli;
  *	@param	${Integer}$errorCode:	Código do erro.
  *	@param	${String}$errorMessage:	Mensaggem do erro (opcional).
  *	@return	types				  :	array
  */
 public function error($errorCode, $errorMessage = "")
 {
     if (array_key_exists($errorCode, $this->_errorCodes)) {
         if (strLen($errorMessage) > 0) {
             return array("StatusCode" => $errorCode, "StatusMessage" => $this->_errorCodes[$errorCode] . " | " . $errorMessage);
         } else {
             return array("StatusCode" => $errorCode, "StatusMessage" => $this->_errorCodes[$errorCode]);
         }
     } else {
         return array("StatusCode" => $errorCode, "StatusMessage" => $errorMessage);
     }
 }
Example #29
0
 function __CopyForumFiles($source_abs, $target_abs, $bReWriteAdditionalFiles = true, $arParams = array())
 {
     $source_base = dirname(__FILE__);
     $source_base = str_replace(array("\\", "//"), "/", $source_base . "/");
     $source_abs = str_replace(array("\\", "//"), "/", $source_abs . "/");
     $target_abs = str_replace(array("\\", "//"), "/", $target_abs . "/");
     $source = substr($source_abs, strLen($source_base));
     $source = str_replace("//", "/", "/" . $source . "/");
     $arParams = is_array($arParams) ? $arParams : array();
     if (file_exists($source_abs)) {
         //Create target directory
         CheckDirPath($target_abs);
         $dh = opendir($source_abs);
         //Read the source
         while ($file = readdir($dh)) {
             if ($file == "." || $file == "..") {
                 continue;
             }
             if (is_dir($source_abs . $file)) {
                 __CopyForumFiles($source_abs . $file, $target_abs . $file, $bReWriteAdditionalFiles);
             } else {
                 $target_file = $target_abs . $file;
                 if ($bReWriteAdditionalFiles || !file_exists($target_file)) {
                     //Here we will write public data
                     $source_file = $source_abs . $file;
                     $fh = fopen($source_file, "rb");
                     $php_source = fread($fh, filesize($source_file));
                     fclose($fh);
                     $arParamsForReplace = array();
                     foreach ($arParams as $key => $val) {
                         $arParamsForReplace["#" . $key . "#"] = $val;
                     }
                     $php_source = str_replace(array_keys($arParamsForReplace), $arParamsForReplace, $php_source);
                     //Parse localization
                     if (preg_match_all('/GetMessage\\("(.*?)"\\)/', $php_source, $matches)) {
                         //Include LANGUAGE_ID file
                         $path = $source_base . "lang/" . LANGUAGE_ID . $source . $file;
                         __IncludeLang($path);
                         //Substite the stuff
                         foreach ($matches[0] as $i => $text) {
                             $php_source = str_replace($text, '"' . GetMessage($matches[1][$i]) . '"', $php_source);
                         }
                     }
                     //Write to the destination directory
                     $fh = fopen($target_file, "wb");
                     fwrite($fh, $php_source);
                     fclose($fh);
                     @chmod($target_file, BX_FILE_PERMISSIONS);
                 }
             }
         }
     }
 }
 protected function setUp()
 {
     $this->headers = "Date: Fri, 22 Jan 2016 04:05:30 GMT\r\n";
     $this->headers .= "X-RateLimit-Limit: 10\r\n";
     $this->headers .= "X-RateLimit-Remaining: 10\r\n";
     $this->headers .= "X-RateLimit-Reset: 1453435538946\r\n";
     $this->headers_exceeded = "Date: Fri, 22 Jan 2016 04:05:30 GMT\r\n";
     $this->headers_exceeded .= "X-RateLimit-Limit: 10\r\n";
     $this->headers_exceeded .= "X-RateLimit-Remaining: 0\r\n";
     $this->headers_exceeded .= "X-RateLimit-Reset: 1453435538946\r\n";
     $this->headers_length = strLen($this->headers) - 1;
     $this->headers_length_exceeded = strLen($this->headers_exceeded) - 1;
 }