Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
 public function getRemoteTypeGroups()
 {
     if (!$this->useCache || !isset($this->data['settings']['remote']['typeGroups'])) {
         $localPath = \CTempFile::GetDirectoryName(100);
         static::downloadFile(self::REMOTE_TYPE_GROUP_FILE, self::LOCAL_TYPE_GROUP_FILE, false, $localPath);
         $csv = new CSVReader();
         $res = $csv->ReadBlock($localPath . self::LOCAL_TYPE_GROUP_FILE);
         $result = array();
         foreach ($res as $line) {
             $result[$line['CODE']] = explode(':', $line['TYPES']);
         }
         $this->data['settings']['remote']['typeGroups'] = $result;
         if (\Bitrix\Main\IO\File::isFileExists($localPath . self::LOCAL_TYPE_GROUP_FILE)) {
             try {
                 \Bitrix\Main\IO\File::deleteFile($localPath . self::LOCAL_TYPE_GROUP_FILE);
                 \Bitrix\Main\IO\Directory::deleteDirectory($localPath);
             } catch (\Exception $e) {
             }
         }
     }
     return $this->data['settings']['remote']['typeGroups'];
 }
Ejemplo n.º 3
0
 protected function packData($xmlFile)
 {
     $tmpDir = $this->path . "/tmp";
     $archiveName = $tmpDir . "/" . $this->feedType . "_" . $this->fileNameSalt . ".zip";
     $oArchiver = \CBXArchive::GetArchive($archiveName, "ZIP");
     $oArchiver->SetOptions(array("REMOVE_PATH" => $this->path . "/xml", "ADD_PATH" => $this->feedType));
     if ($oArchiver->Pack($xmlFile)) {
         \Bitrix\Main\IO\File::deleteFile($xmlFile);
     }
     return $archiveName;
 }
Ejemplo n.º 4
0
 /**
  * @return bool
  */
 function UnInstallFiles()
 {
     \Bitrix\Main\IO\Directory::deleteDirectory($_SERVER["DOCUMENT_ROOT"] . '/bitrix/components/adelshin/');
     if (\Bitrix\Main\IO\Directory::isDirectoryExists($path = $this->GetPath() . '/admin')) {
         // удаляем административные файлы
         DeleteDirFiles($_SERVER["DOCUMENT_ROOT"] . $this->GetPath() . '/install/admin/', $_SERVER["DOCUMENT_ROOT"] . '/bitrix/admin');
         if ($dir = opendir($path)) {
             while (false !== ($item = readdir($dir))) {
                 if (in_array($item, $this->exclusionAdminFiles)) {
                     continue;
                 }
                 \Bitrix\Main\IO\File::deleteFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin/' . $this->MODULE_ID . '_' . $item);
             }
             closedir($dir);
         }
     }
     return true;
 }