Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- error_reporting(E_ALL);
- require_once($_SERVER [ 'DOCUMENT_ROOT' ].'/bitrix/modules/main/include/prolog_before.php');
- CModule::IncludeModule('iblock');
- $path_dir = "old_kulichi/vopros";
- function getArrayFiles($path_dir) {
- $array_path = array();
- $dir = new RecursiveDirectoryIterator($path_dir);
- foreach(new RecursiveIteratorIterator($dir) as $val) {
- if($val->isFile() && $val->getExtension() == 'htm') {
- $array_path[$val->getPathname()] = $val->getBasename('.htm');
- }
- }
- return $array_path;
- }
- foreach (getArrayFiles($path_dir) as $pathname => $filename) {
- $name = basename($filename, ".htm");
- //$find = "1";
- //$pos = strpos($name,$find, 2);
- $text = file_get_contents($pathname);
- $text = iconv("cp1251", "utf-8", $text);
- $text = strip_tags($text, '<br>');
- if (is_readable($name."1"))
- {
- $otvet = file_get_contents($pathname);
- $otvet = iconv("cp1251", "utf-8", $otvet);
- $otvet = strip_tags($otvet, '<br>');
- $PROP = array();
- $PROP[29] = array("VALUE" => array("TEXT" => $text, "TYPE" => "text"));
- $PROP[30] = array("VALUE" => array("TEXT" => $otvet, "TYPE" => "text"));
- }
- $el = new CIBlockElement;
- $arLoadProductArray = Array(
- "MODIFIED_BY" => 1,
- "IBLOCK_SECTION_ID" => false,
- "IBLOCK_ID" => 10,
- "PROPERTY_VALUES" => $PROP,
- "NAME" => $name,
- "CODE" => $name,
- "ACTIVE" => "Y",
- );
- if ($PRODUCT_ID = $el->Add($arLoadProductArray))
- echo "New ID: " . $PRODUCT_ID;
- else
- echo "Error: " . $el->LAST_ERROR;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement