} #----------------------------------------------------------------------------- $Public = SPrintF('%s/public', $Tmp); #----------------------------------------------------------------------------- if (File_Exists($Public)) { #--------------------------------------------------------------------------- $Contents = IO_Scan($Public); if (Is_Error($Contents)) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- foreach ($Contents as $Content) { #------------------------------------------------------------------------- if (Preg_Match('/^statistics/', $Content)) { #----------------------------------------------------------------------- if (Is_Error(IO_RmDir(SPrintF('%s///%s', $Public, $Content)))) { return ERROR | @Trigger_Error(500); } } } } #----------------------------------------------------------------------------- $UniqID = UniqID('statistics'); #----------------------------------------------------------------------------- $Folder = SPrintF('%s/%s', $Public, $UniqID); #----------------------------------------------------------------------------- if (!File_Exists($Folder)) { #--------------------------------------------------------------------------- if (!@MkDir($Folder, 0777, TRUE)) { return ERROR | @Trigger_Error(500); }
function IO_RmDir($Folder) { #------------------------------------------------------------------------------- $Folder = Preg_Replace('/\\/{2,}/', '/', rTrim($Folder, '/')); #------------------------------------------------------------------------------- if (StrPos(SPrintF('/%s/', $Folder), SYSTEM_PATH) === FALSE) { return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка безопасности при удалении (%s)', $Folder)); } #------------------------------------------------------------------------------- $Entities = IO_Scan($Folder, FALSE); if (Is_Error($Entities)) { return ERROR | @Trigger_Error('[IO_RmDir]: не удалось получить содержимое папки'); } #------------------------------------------------------------------------------- if (Count($Entities)) { #------------------------------------------------------------------------------- foreach ($Entities as $Entity) { #------------------------------------------------------------------------------- $Entity = SPrintF('%s/%s', $Folder, $Entity); #------------------------------------------------------------------------------- if (Is_Dir($Entity)) { #------------------------------------------------------------------------------- if (Is_Error(IO_RmDir($Entity))) { return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка рекурсивного вызова при удалении (%s)', $Entity)); } #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- if (!UnLink($Entity)) { return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка при удалении файла (%s)', $Entity)); } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- if (!@RmDir($Folder)) { return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка при удалении директории (%s)', $Folder)); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- return TRUE; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- }
#------------------------------------------------------------------------------- echo "\n\n"; #------------------------------------------------------------------------------- if (File_Exists(SPrintF('%s/template_c', $Tmp))) { #------------------------------------------------------------------------------- if (Is_Error(IO_RmDir(SPrintF('%s///template_c', $Tmp)))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- echo SPrintF("Очистка временной директории компилированных шаблонов\n"); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- if (File_Exists(SPrintF('%s/WhatsApp', $Tmp))) { #------------------------------------------------------------------------------- if (Is_Error(IO_RmDir(SPrintF('%s///WhatsApp', $Tmp)))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- echo SPrintF("Очистка временной директории WhatsApp\n"); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- if (File_Exists($MyCnf)) { UnLink($MyCnf); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $IsUpdate = DB_Update('Config', array('Value' => 'TRUE'), array('Where' => "`Param` = 'IsInitDB'")); if (Is_Error($IsUpdate)) {
} #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Tmp = System_Element('tmp'); if (Is_Error($Tmp)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- # кастыли, поскольку класс хочет директорию для базы внутри своей директории $waPath = SPrintF('%s/hosts/billing/system/classes/WhatsApp', SYSTEM_PATH); #------------------------------------------------------------------------------- $wadata = SPrintF('%s/wadata', $waPath); #------------------------------------------------------------------------------- if (!Is_Link($wadata) && Is_Dir($wadata)) { #------------------------------------------------------------------------------- if (Is_Error(IO_RmDir(SPrintF('%s///wadata', $waPath)))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- $DataFolder = SPrintF('%s/WhatsApp', $Tmp); #------------------------------------------------------------------------------- $LogFile = SPrintF('%s/WhatsApp.%s.log', $DataFolder, Date('Y-m-d')); #------------------------------------------------------------------------------- if (!Is_Dir(SPrintF('%s/logs', $DataFolder))) { if (!MkDir(SPrintF('%s/logs', $DataFolder), 0750, true)) { return ERROR | @Trigger_Error(500); } } #-------------------------------------------------------------------------------