예제 #1
0
 }
 if (!in_array($site, $arSites)) {
     $error = getMessage('ABTEST_AJAX_ERROR');
 }
 if ($error === false) {
     $source = Bitrix\Main\Text\Encoding::convertEncodingToCurrent($source);
     $source = Bitrix\ABTest\AdminHelper::getRealPath($site, $source);
     if (empty($source)) {
         $error = getMessage('ABTEST_UNKNOWN_PAGE');
     }
     if ($error === false) {
         $docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/');
         $source = new Bitrix\Main\IO\File($docRoot . $source);
         $k = 0;
         do {
             $targetPath = BX_ROOT . '/abtest/' . date('Ymd') . '/' . sprintf('%u', crc32(rand() . time())) . $source->getName();
             $target = new Bitrix\Main\IO\File($docRoot . $targetPath);
         } while ($target->isExists() && $k++ < 10);
         if ($target->isExists()) {
             $error = getMessage('ABTEST_AJAX_ERROR');
         } else {
             $success = copyDirFiles($source->getPath(), $target->getPath(), false, false, false);
             if ($success) {
                 $result = $targetPath;
             } else {
                 $error = getMessage('ABTEST_AJAX_ERROR');
             }
         }
     }
 }
 break;