コード例 #1
0
ファイル: vcardreader.php プロジェクト: DarneoStudio/bitrix
 /**
  * @return bool
  */
 public function readElementContent()
 {
     if ($this->elementContent !== null) {
         $this->elementContent = null;
     }
     if (!$this->readToBufferIfEmpty()) {
         return false;
     }
     do {
         $pos = stripos($this->buffer, 'BEGIN:VCARD', 0);
     } while ($pos === false && $this->readToBuffer());
     if ($pos === false) {
         return false;
     }
     $beginPos = $pos;
     do {
         $pos = stripos($this->buffer, 'END:VCARD', $beginPos + 11);
         // 11 is strlen('BEGIN:VCARD')
     } while ($pos === false && $this->readToBuffer());
     if ($pos === false) {
         return false;
     }
     $endPos = $pos;
     $borderPos = $endPos + 9;
     // 9 is strlen('END:VCARD')
     $this->elementContent = substr($this->buffer, $beginPos, $borderPos - $beginPos);
     $this->buffer = substr($this->buffer, $borderPos);
     $this->elementBorderPosition = $this->filePosition - Main\Text\String::getBinaryLength($this->buffer);
     return $this->elementContent !== '';
 }
コード例 #2
0
 /**
  * Set new secret
  *
  * @param string $secret Secret (binary).
  * @return $this
  */
 public function setSecret($secret)
 {
     $this->secret = $secret;
     // Backward compatibility. Use sha256 for eToken with 256bits key
     if (\Bitrix\Main\Text\String::getBinaryLength($this->secret) > 25) {
         $this->digest = 'sha256';
     }
     return $this;
 }
コード例 #3
0
ファイル: path.php プロジェクト: DarneoStudio/bitrix
 public static function getName($path)
 {
     //$path = self::normalize($path);
     $p = Text\String::strrpos($path, self::DIRECTORY_SEPARATOR);
     if ($p !== false) {
         return substr($path, $p + 1);
     }
     return $path;
 }
コード例 #4
0
ファイル: basevalues.php プロジェクト: spas-viktor/books
 public function getValue($propertyCode)
 {
     if ($this->values === false) {
         $this->values = $this->queryValues();
     }
     if (isset($this->values[$propertyCode])) {
         return \Bitrix\Main\Text\String::htmlEncode($this->values[$propertyCode]["VALUE"]);
     } else {
         return "";
     }
 }
コード例 #5
0
ファイル: random.php プロジェクト: rasuldev/torino
 /**
  * Returns pseudo random block
  *
  * @return string
  */
 protected function getPseudoRandomBlock()
 {
     global $APPLICATION;
     if (function_exists('openssl_random_pseudo_bytes')) {
         $bytes = openssl_random_pseudo_bytes(64);
         if ($bytes && String::getBinaryLength($bytes) >= 64) {
             return String::getBinarySubstring($bytes, 0, 64);
         }
     }
     $bytes = '';
     for ($i = 0; $i < 64; $i++) {
         $bytes .= pack('S', mt_rand(0, 0xffff));
     }
     $bytes .= $APPLICATION->getServerUniqID();
     return hash('sha512', $bytes, true);
 }
コード例 #6
0
ファイル: random.php プロジェクト: ASDAFF/1C_Bitrix_info_site
 /**
  * Returns pseudo random block
  *
  * @return string
  */
 protected function getPseudoRandomBlock()
 {
     global $APPLICATION;
     if (static::isOpensslSkipped()) {
         $bytes = openssl_random_pseudo_bytes(static::RANDOM_BLOCK_LENGTH);
         if ($bytes && String::getBinaryLength($bytes) >= static::RANDOM_BLOCK_LENGTH) {
             return String::getBinarySubstring($bytes, 0, static::RANDOM_BLOCK_LENGTH);
         }
     }
     $bytes = '';
     for ($i = 0; $i < static::RANDOM_BLOCK_LENGTH; $i++) {
         $bytes .= pack('S', mt_rand(0, 0xffff));
     }
     $bytes .= $APPLICATION->getServerUniqID();
     return hash('sha512', $bytes, true);
 }
コード例 #7
0
 public static function format(\Exception $exception, $htmlMode = false, $level = 0)
 {
     $result = '[' . get_class($exception) . '] ';
     if ($exception instanceof \ErrorException) {
         $result .= static::severityToString($exception->getSeverity());
     }
     $result .= "\n" . static::getMessage($exception) . "\n";
     if ($exception instanceof Main\DB\SqlQueryException) {
         $result .= $exception->getQuery() . "\n";
     }
     $fileLink = static::getFileLink($exception->getFile(), $exception->getLine());
     $result .= $fileLink . (empty($fileLink) ? "" : "\n");
     if ($htmlMode) {
         $result = Main\Text\String::htmlEncode($result);
     }
     $prevArg = null;
     $trace = static::getTrace($exception);
     foreach ($trace as $traceNum => $traceInfo) {
         $traceLine = '#' . $traceNum . ': ';
         if (array_key_exists('class', $traceInfo)) {
             $traceLine .= $traceInfo['class'] . $traceInfo['type'];
         }
         if (array_key_exists('function', $traceInfo)) {
             $traceLine .= $traceInfo['function'];
             $traceLine .= static::getArguments($traceInfo['args'], $level);
         }
         if ($htmlMode) {
             $traceLine = Main\Text\String::htmlEncode($traceLine);
         }
         if (array_key_exists('file', $traceInfo)) {
             $traceLine .= "\n\t" . static::getFileLink($traceInfo['file'], $traceInfo['line']);
         } else {
             $traceLine .= "\n\t" . static::getFileLink(null, null);
         }
         $result .= $traceLine . "\n";
     }
     if ($htmlMode) {
         $result = '<pre>' . $result . '</pre>';
     } else {
         $result .= static::DELIMITER;
     }
     return $result;
 }
コード例 #8
0
ファイル: options.php プロジェクト: romzes5000/bex.d7dull
echo bitrix_sessid_post();
$tabControl->beginNextTab();
?>
    <tr>
        <td width="40%">
            <label for="max_image_size"><?php 
echo Loc::getMessage("REFERENCES_MAX_IMAGE_SIZE");
?>
:</label>
        <td width="60%">
            <input type="text"
                   size="50"
                   maxlength="5"
                   name="max_image_size"
                   value="<?php 
echo String::htmlEncode(Option::get(ADMIN_MODULE_NAME, "max_image_size", 500));
?>
"
                   />
        </td>
    </tr>

    <?php 
$tabControl->buttons();
?>
    <input type="submit"
           name="save"
           value="<?php 
echo Loc::getMessage("MAIN_SAVE");
?>
"
コード例 #9
0
ファイル: lang_edit.php プロジェクト: DarneoStudio/bitrix
BX.ready(BXSetCulture);
</script>
			<select name="CULTURE_ID" onchange="BXSetCulture()" id="bx_culture_select">
<?php 
foreach ($cultures as $cult) {
    ?>
				<option value="<?php 
    echo $cult["ID"];
    ?>
"<?php 
    if ($cult["ID"] == $language["CULTURE_ID"]) {
        echo " selected";
    }
    ?>
><?php 
    echo String::htmlEncode($cult["NAME"]);
    ?>
</option>
<?php 
}
?>
			</select>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><a href="culture_edit.php?lang=<?php 
echo LANGUAGE_ID;
?>
" id="bx_culture_link"><?php 
echo Loc::getMessage("lang_edit_culture_edit");
コード例 #10
0
ファイル: httpclient.php プロジェクト: mrdeadmouse/u136006
 protected function decompress()
 {
     if (is_resource($this->outputStream)) {
         $compressed = stream_get_contents($this->outputStream, -1, 10);
         $compressed = String::getBinarySubstring($compressed, 0, -8);
         if ($compressed != '') {
             $uncompressed = gzinflate($compressed);
             rewind($this->outputStream);
             $len = fwrite($this->outputStream, $uncompressed);
             ftruncate($this->outputStream, $len);
         }
     } else {
         $compressed = String::getBinarySubstring($this->result, 10, -8);
         if ($compressed != '') {
             $this->result = gzinflate($compressed);
         }
     }
 }
コード例 #11
0
 /**
  * Writes cache into the file.
  *
  * @param mixed $arAllVars Cached result.
  * @param string $baseDir Base cache directory (usually /bitrix/cache).
  * @param string $initDir Directory within base.
  * @param string $filename File name.
  * @param integer $TTL Expiration period in seconds.
  *
  * @return void
  */
 public function write($arAllVars, $baseDir, $initDir, $filename, $TTL)
 {
     static $search = array("\\", "'", "");
     static $replace = array("\\\\", "\\'", "'.chr(0).'");
     $documentRoot = Main\Loader::getDocumentRoot();
     $folder = $documentRoot . "/" . ltrim($baseDir . $initDir, "/");
     $fn = $folder . $filename;
     $fnTmp = $folder . md5(mt_rand()) . ".tmp";
     if (!CheckDirPath($fn)) {
         return;
     }
     if ($handle = fopen($fnTmp, "wb+")) {
         if (is_array($arAllVars)) {
             $contents = "<?";
             $contents .= "\nif(\$INCLUDE_FROM_CACHE!='Y')return false;";
             $contents .= "\n\$datecreate = '" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . "';";
             $contents .= "\n\$dateexpire = '" . str_pad(mktime() + intval($TTL), 12, "0", STR_PAD_LEFT) . "';";
             $contents .= "\n\$ser_content = '" . str_replace($search, $replace, serialize($arAllVars)) . "';";
             $contents .= "\nreturn true;";
             $contents .= "\n?>";
         } else {
             $contents = "BX" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . str_pad(mktime() + intval($this->TTL), 12, "0", STR_PAD_LEFT);
             $contents .= $arAllVars;
         }
         $this->written = fwrite($handle, $contents);
         $this->path = $fn;
         $len = Main\Text\String::getBinaryLength($contents);
         fclose($handle);
         static::unlink($fn);
         if ($this->written === $len) {
             rename($fnTmp, $fn);
         }
         static::unlink($fnTmp);
     }
 }
コード例 #12
0
ファイル: asset.php プロジェクト: ASDAFF/1C_Bitrix_info_site
 /**
  * Write optimized css, js files or info file
  *
  * @param string $filePath - Path for optimized css, js or info file
  * @param string $content - File contents
  * @param bool $gzip - For disabled gzip
  * @return bool - TRUE or FALSE result
  */
 function write($filePath, $content, $gzip = true)
 {
     $result = false;
     $fnTmp = $filePath . '.tmp';
     if (!CheckDirPath($filePath) || !($fh = fopen($fnTmp, "wb"))) {
         return $result;
     }
     $written = fwrite($fh, $content);
     $len = Main\Text\String::getBinaryLength($content);
     fclose($fh);
     self::unlink($filePath);
     if ($written === $len) {
         $result = true;
         rename($fnTmp, $filePath);
         if ($gzip && self::gzipEnabled()) {
             $fnTmpGz = $filePath . '.tmp.gz';
             $fnGz = $filePath . '.gz';
             if ($gz = gzopen($fnTmpGz, 'wb9f')) {
                 $writtenGz = @gzwrite($gz, $content);
                 gzclose($gz);
                 self::unlink($fnGz);
                 if ($writtenGz === $len) {
                     rename($fnTmpGz, $fnGz);
                 }
                 self::unlink($fnTmpGz);
             }
         }
     }
     self::unlink($fnTmp);
     return $result;
 }
コード例 #13
0
ファイル: csv_data.php プロジェクト: rasuldev/torino
 public function SetPos($iCurPos = 0)
 {
     $iCurPos = intval($iCurPos);
     if ($iCurPos <= $this->iFileLength) {
         $this->iCurPos = $iCurPos;
     } else {
         $this->iCurPos = $this->iFileLength;
     }
     $pos = $this->iCurPos;
     if ($this->__hasBOM) {
         $pos += 3;
     }
     fseek($this->__file, $pos);
     if (feof($this->__file)) {
         $this->__buffer = "";
     } else {
         $this->__buffer = fread($this->__file, 1024 * 1024);
     }
     $this->__buffer_size = String::getBinaryLength($this->__buffer);
     $this->__buffer_pos = 0;
 }
コード例 #14
0
ファイル: class.php プロジェクト: akniyev/arteva.ru
 /**
  * Sets measure for all viewed products.
  * @return void
  */
 protected function setItemsMeasure()
 {
     if (!count($this->productIdsMap)) {
         return;
     }
     $measures = $this->data['MEASURE'];
     foreach ($this->items as &$item) {
         if (array_key_exists($item['CATALOG_MEASURE'], $measures)) {
             $measure = $measures[$item['CATALOG_MEASURE']];
             $item['~CATALOG_MEASURE_NAME'] = LANGUAGE_ID == "ru" ? $measure["SYMBOL_RUS"] : $measure["SYMBOL_INTL"];
             $item['CATALOG_MEASURE_NAME'] = String::htmlEncode($item['~CATALOG_MEASURE_NAME']);
         }
     }
     // Ratios
     $ratioIterator = CCatalogMeasureRatio::getList(array(), array('@PRODUCT_ID' => array_values($this->productIdsMap)), false, false, array('PRODUCT_ID', 'RATIO'));
     while ($ratio = $ratioIterator->fetch()) {
         if (isset($this->items[$ratio['PRODUCT_ID']])) {
             $intRatio = intval($ratio['RATIO']);
             $dblRatio = doubleval($ratio['RATIO']);
             $mxRatio = $dblRatio > $intRatio ? $dblRatio : $intRatio;
             if (CATALOG_VALUE_EPSILON > abs($mxRatio)) {
                 $mxRatio = 1;
             } elseif (0 > $mxRatio) {
                 $mxRatio = 1;
             }
             $this->items[$ratio['PRODUCT_ID']]['CATALOG_MEASURE_RATIO'] = $mxRatio;
         }
     }
 }
コード例 #15
0
ファイル: importer.php プロジェクト: DarneoStudio/bitrix
 /**
  * @param string $iblockType This variable is the id iblockType.
  * @param string $datum This variable is the encrypted string.
  * @param null $siteId This variable is the id current site.
  * @throws Main\ArgumentNullException
  */
 public static function import($iblockType, $datum, $siteId = null)
 {
     if (empty($datum)) {
         throw new Main\ArgumentNullException("datum");
     }
     if (substr($datum, 0, 10) === "compressed") {
         $datum = gzuncompress(Main\Text\String::getBinarySubstring($datum, 10));
     }
     $len = intval(Main\Text\String::getBinarySubstring($datum, 0, 10));
     $iblockSerialized = Main\Text\String::getBinarySubstring($datum, 10, $len);
     $datum = Main\Text\String::getBinarySubstring($datum, $len + 10);
     $marker = Main\Text\String::getBinarySubstring($datum, 0, 1);
     $picture = null;
     $pictureType = null;
     if ($marker == "P") {
         $len = intval(Main\Text\String::getBinarySubstring($datum, 1, 10));
         $pictureType = Main\Text\String::getBinarySubstring($datum, 11, $len);
         $datum = Main\Text\String::getBinarySubstring($datum, $len + 11);
         $len = intval(Main\Text\String::getBinarySubstring($datum, 0, 10));
         $picture = Main\Text\String::getBinarySubstring($datum, 10, $len);
         $datum = Main\Text\String::getBinarySubstring($datum, $len + 10);
         $marker = Main\Text\String::getBinarySubstring($datum, 0, 1);
     }
     $iblock = CheckSerializedData($iblockSerialized) ? unserialize($iblockSerialized) : array();
     $iblock = Main\Text\Encoding::convertEncodingArray($iblock, "UTF-8", LANG_CHARSET);
     $iblockId = static::createIBlock($iblockType, $iblock, $pictureType, $picture, $siteId);
     if ($iblockId > 0) {
         $documentType = self::getDocumentType($iblockType, $iblockId);
         while (!empty($datum)) {
             if ($marker == "B") {
                 $len = intval(Main\Text\String::getBinarySubstring($datum, 1, 10));
                 $bpDescr = Main\Text\String::getBinarySubstring($datum, 11, $len);
                 $datum = Main\Text\String::getBinarySubstring($datum, $len + 11);
                 $bpDescr = CheckSerializedData($bpDescr) ? unserialize($bpDescr) : array();
                 $bpDescr = Main\Text\Encoding::convertEncodingArray($bpDescr, "UTF-8", LANG_CHARSET);
                 $len = intval(Main\Text\String::getBinarySubstring($datum, 0, 10));
                 $bp = Main\Text\String::getBinarySubstring($datum, 10, $len);
                 $datum = Main\Text\String::getBinarySubstring($datum, $len + 10);
                 static::importTemplate($documentType, $bpDescr, $bp);
             } else {
             }
             if (empty($datum)) {
                 break;
             }
             $marker = Main\Text\String::getBinarySubstring($datum, 0, 1);
         }
     }
 }
コード例 #16
0
ファイル: template.php プロジェクト: ASDAFF/entask.ru
														<?foreach($app["OPTIONS"] as $opt):?>
														<option value="<?php 
echo String::htmlEncode($opt);
?>
"><?php 
echo String::htmlEncode($opt);
?>
</option>
														<?endforeach?>
														<option value="<?echo GetMessage("main_app_pass_other")?>"><?echo GetMessage("main_app_pass_other")?></option>
													<?else:?>
														<option value="<?php 
echo String::htmlEncode($app["NAME"]);
?>
"><?php 
echo String::htmlEncode($app["NAME"]);
?>
</option>
													<?endif?>
													</select>
												</td>
												<td class="tal" style="padding: 0;">
													<input type="text" name="COMMENT" class="bx-otp-slt medium m0" placeholder="<?echo GetMessage("main_app_pass_comment_ph")?>">
												</td>
											</tr>
										</tbody>
									</table>
									<input type="hidden" name="APPLICATION_ID" value="<?php 
echo $app_id;
?>
">
コード例 #17
0
        if (is_array($_POST["IBLOCK_SECTION"])) {
            $section_id = min(array_filter($_POST["IBLOCK_SECTION"], "strlen"));
        } else {
            $section_id = 0;
        }
        $arFields = array("IBLOCK_ID" => $_REQUEST["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $section_id, "NAME" => $_POST["NAME"], "CODE" => $_POST["CODE"], "PREVIEW_TEXT" => $_POST["PREVIEW_TEXT"], "DETAIL_TEXT" => $_POST["DETAIL_TEXT"]);
    } else {
        $ipropTemplates = null;
        $arFields = array();
    }
    if ($ipropTemplates) {
        $values = $ipropTemplates->getValuesEntity();
        $entity = $values->createTemplateEntity();
        $entity->setFields($arFields);
        $templates = $ipropTemplates->findTemplates();
        if (is_array($_POST["IPROPERTY_TEMPLATES"])) {
            foreach ($_POST["IPROPERTY_TEMPLATES"] as $TEMPLATE_NAME => $TEMPLATE_VALUE) {
                $templates[$TEMPLATE_NAME] = array("TEMPLATE" => \Bitrix\Iblock\Template\Helper::convertArrayToModifiers($TEMPLATE_VALUE));
            }
        }
        $result = array();
        foreach ($templates as $TEMPLATE_NAME => $templateInfo) {
            $result[] = array("id" => $TEMPLATE_NAME, "value" => \Bitrix\Main\Text\String::htmlEncode(\Bitrix\Iblock\Template\Engine::process($entity, $templateInfo["TEMPLATE"])));
        }
        echo CUtil::PhpToJSObject($result);
        //$entity = $values->createTemplateEntity();
        //$entity->setFields($arFields);
        //$templates = $values->getTemplateEntity();
    }
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
コード例 #18
0
 public function write($arAllVars, $baseDir, $initDir, $filename, $TTL)
 {
     $documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     $fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
     $file = new IO\File($fn);
     $fnTmp = IO\Path::combine($documentRoot, $baseDir, $initDir, md5(mt_rand()) . ".tmp");
     $fileTmp = new IO\File($fnTmp);
     $dir = $file->getDirectory();
     if (!$dir->isExists()) {
         $dir->create();
     }
     if (is_array($arAllVars)) {
         $contents = "<?";
         $contents .= "\nif(\$INCLUDE_FROM_CACHE!='Y')return false;";
         $contents .= "\n\$datecreate = '" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . "';";
         $contents .= "\n\$dateexpire = '" . str_pad(mktime() + IntVal($TTL), 12, "0", STR_PAD_LEFT) . "';";
         $v = serialize($arAllVars);
         if (static::checkZeroDanger()) {
             $v = str_replace("*", "", $v);
             $contents .= "\n\$zeroDanger = true;";
         }
         $contents .= "\n\$ser_content = '" . str_replace("'", "\\'", str_replace("\\", "\\\\", $v)) . "';";
         $contents .= "\nreturn true;";
         $contents .= "\n?>";
     } else {
         $contents = "BX" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . str_pad(mktime() + IntVal($this->TTL), 12, "0", STR_PAD_LEFT);
         $contents .= $arAllVars;
     }
     $this->written = $fileTmp->putContents($contents);
     $len = \Bitrix\Main\Text\String::strlenBytes($contents);
     //This checks for Zend Server CE in order to supress warnings
     if (function_exists('accelerator_reset')) {
         try {
             $file->delete();
         } catch (\Exception $ex) {
         }
     } elseif ($file->isExists()) {
         $file->delete();
     }
     if ($this->written === $len) {
         $fileTmp->rename($fn);
     }
     //This checks for Zend Server CE in order to supress warnings
     if (function_exists('accelerator_reset')) {
         try {
             IO\File::deleteFile($fnTmp);
         } catch (\Exception $ex) {
         }
     } elseif (IO\File::isFileExists($fnTmp)) {
         IO\File::deleteFile($fnTmp);
     }
 }