Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. error_reporting(E_ALL);
  4.  
  5. require_once($_SERVER [ 'DOCUMENT_ROOT' ].'/bitrix/modules/main/include/prolog_before.php');
  6. CModule::IncludeModule('iblock');
  7.  
  8. $path_dir = "old_kulichi/vopros";
  9. function getArrayFiles($path_dir) {
  10.     $array_path = array();
  11.     $dir = new RecursiveDirectoryIterator($path_dir);
  12.     foreach(new RecursiveIteratorIterator($dir) as $val) {
  13.         if($val->isFile() && $val->getExtension() == 'htm') {
  14.             $array_path[$val->getPathname()] = $val->getBasename('.htm');
  15.         }
  16.     }
  17.     return $array_path;
  18. }
  19.  
  20. foreach (getArrayFiles($path_dir) as $pathname => $filename) {
  21.  
  22.     $name = basename($filename, ".htm");
  23.     //$find = "1";
  24.     //$pos = strpos($name,$find, 2);
  25.         $text = file_get_contents($pathname);
  26.         $text = iconv("cp1251", "utf-8", $text);
  27.         $text = strip_tags($text, '<br>');
  28.  
  29.        if (is_readable($name."1"))
  30.        {
  31.            $otvet = file_get_contents($pathname);
  32.            $otvet = iconv("cp1251", "utf-8", $otvet);
  33.            $otvet = strip_tags($otvet, '<br>');
  34.            $PROP = array();
  35.            $PROP[29] = array("VALUE" => array("TEXT" => $text, "TYPE" => "text"));
  36.            $PROP[30] = array("VALUE" => array("TEXT" => $otvet, "TYPE" => "text"));
  37.  
  38.        }
  39.  
  40.  
  41.         $el = new CIBlockElement;
  42.  
  43.         $arLoadProductArray = Array(
  44.             "MODIFIED_BY" => 1,
  45.             "IBLOCK_SECTION_ID" => false,
  46.             "IBLOCK_ID" => 10,
  47.             "PROPERTY_VALUES" => $PROP,
  48.             "NAME" => $name,
  49.             "CODE" => $name,
  50.             "ACTIVE" => "Y",
  51.         );
  52.  
  53.         if ($PRODUCT_ID = $el->Add($arLoadProductArray))
  54.             echo "New ID: " . $PRODUCT_ID;
  55.         else
  56.             echo "Error: " . $el->LAST_ERROR;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement