Esempio n. 1
0
function SaveUploadedFile($Table, $ID, $File)
{
    #-------------------------------------------------------------------------------
    $FilePaths = GetFilePath($Table, $ID);
    #-------------------------------------------------------------------------------
    # создаём директорию
    if (!File_Exists($FilePaths['FileDir'])) {
        if (!MkDir($FilePaths['FileDir'], 0700, true)) {
            return new gException('CANNOT_CREATE_DIRECTORY', 'Не удалось создать директорию для сохранения файла');
        }
    }
    #-------------------------------------------------------------------------------
    # сохраняем файл
    $fp = FOpen($FilePaths['FilePath'], 'w');
    FWrite($fp, $File);
    FClose($fp);
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
}
Esempio n. 2
0
         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);
     }
 }
 #-----------------------------------------------------------------------------
 $HostsIDs = Array_Reverse($GLOBALS['HOST_CONF']['HostsIDs']);
 #-----------------------------------------------------------------------------
 foreach ($HostsIDs as $HostID) {
     #---------------------------------------------------------------------------
     $Path = SPrintF('%s/hosts/%s/comp/Statistics', SYSTEM_PATH, $HostID);
     #---------------------------------------------------------------------------
     if (!File_Exists($Path)) {
         continue;
     }
     #---------------------------------------------------------------------------
     $Files = IO_Scan($Path);
Esempio n. 3
0
function setBackup()
{
    global $dbname, $dbh;
    global $PARAM, $SUBS, $MSG, $MONTHS;
    if (!is_dir(getAdmSetting('BACKUP_DIR'))) {
        MkDir(getAdmSetting('BACKUP_DIR'), 0777);
    }
    if ($PARAM['upload'] == 1) {
        global $bckFile, $bckFile_name;
        if ($bckFile_name == '') {
            $SUBS['ERROR'] = $MSG[20108];
            $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt');
        } else {
            if (!($UPLOAD = @file($bckFile))) {
                setLogAndStatus("Reading", $bckFile, 0, "setBackup()", 'READ_UPLOAD');
            }
            $file = date('d F Y H_i_s');
            $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql";
            $upload = '## ' . $MSG[20109] . date(' d F Y H:i:s') . "\n";
            $upload .= "## {$MSG['20110']} {$bckFile_name}\n";
            $upload .= join('', $UPLOAD);
            if (!($fp = fopen($filename, 'w'))) {
                setLogAndStatus("Opening", $filename, 0, "setBackup()", 'OPEN_FILE');
            }
            fwrite($fp, $upload);
            fclose($fp);
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20050";
            printPage('_admin_done.htmlt');
            return;
        }
    }
    //export database backup
    if ($PARAM['export'] == 1) {
        $file = date('d F Y H_i_s');
        $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql";
        if (!($fp = fopen($filename, 'w'))) {
            setLogAndStatus("Opening", 0, $filename, "setBackup()", 'OPEN_FILE');
        }
        //write comments if any
        if ($PARAM['bckComments'] != '') {
            $comments = '##' . ereg_replace("\n", "\n##", $PARAM['bckComments']) . "\n";
            fwrite($fp, $comments);
        }
        if (!($res = db_list_tables($dbname, $dbh))) {
            setLogAndStatus("db_list_tables()", 0, $dbname, "setBackup()", 'LIST_TABLES');
        }
        $num_tables = db_num_rows($res);
        $i = 0;
        while ($i < $num_tables) {
            $table = db_tablename($res, $i);
            $fields = db_list_fields($dbname, $table, $dbh);
            $columns = db_num_fields($fields);
            $tablelist = '';
            for ($j = 0; $j < $columns; $j++) {
                if ($columns - $j == 1) {
                    $tablelist .= db_field_name($fields, $j);
                } else {
                    $tablelist .= db_field_name($fields, $j) . ',';
                }
            }
            $schema = "REPLACE INTO {$table} ({$tablelist}) VALUES (";
            $query = "SELECT * FROM {$dbname}.{$table}";
            $result = runQuery($query, 'setBackup()', 'SELECT_TABLES');
            while ($row = db_fetch_row($result)) {
                $schema_insert = '';
                for ($j = 0; $j < $columns; $j++) {
                    if (!isset($row[$j])) {
                        $schema_insert .= ' NULL,';
                    } else {
                        $schema_insert .= ' ' . dbQuote($row[$j]) . ',';
                    }
                }
                $schema_insert = $schema . ereg_replace(',$', '', $schema_insert);
                $schema_insert .= ");\r\n";
                fwrite($fp, $schema_insert);
            }
            $i++;
        }
        fclose($fp);
        // the ZIP thing --------------------
        $fp = fopen($filename, "rb");
        $data = fread($fp, filesize($filename));
        fclose($fp);
        $name = array(baseName($filename));
        $data = array($data);
        $content = makezip($name, $data);
        $fp = fopen('./zip/' . basename($filename) . '.ZIP', "wb");
        fputs($fp, $content);
        fclose($fp);
        // the ZIP thing --------------------
        $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20052";
        printPage('_admin_done.htmlt');
        return;
    }
    //prepare for import or delete
    $backups = opendir(getAdmSetting('BACKUP_DIR'));
    while (($file = readdir($backups)) != false) {
        if (!is_dir($file)) {
            $BCKUPS[eregi_replace('[^a-z0-9]', '_', $file)] = getAdmSetting('BACKUP_DIR') . "/{$file}";
        }
    }
    closedir($backups);
    reset($PARAM);
    while (list($k, $v) = each($PARAM)) {
        if (ereg('^bck_(.*)$', $k, $R)) {
            $BACKUPS[] = $R[1];
        }
    }
    reset($PARAM);
    //delete backups
    if ($PARAM['delete'] == 1) {
        if (count($BACKUPS) == 0) {
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008";
            printPage('_admin_done.htmlt');
            return;
        }
        for ($i = 0; $i < count($BACKUPS); $i++) {
            if (!@unlink($BCKUPS[$BACKUPS[$i]])) {
                setLogAndStatus("Deleting", $BCKUPS[$BACKUPS[$i]], "setBackup()", 'DEL_BACKUP');
            }
        }
        $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20054";
        printPage('_admin_done.htmlt');
        return;
    }
    //import database backup
    if ($PARAM['import'] == 1) {
        if (count($BACKUPS) > 1) {
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20053";
            printPage('_admin_done.htmlt');
            return;
        }
        if (count($BACKUPS) == 0) {
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008";
            printPage('_admin_done.htmlt');
            return;
        }
        //get backup file
        $file = fread(fopen($BCKUPS[$BACKUPS[0]], 'r'), filesize($BCKUPS[$BACKUPS[0]]));
        ////---- [Mrasnika's] Edition 21.03.2002
        split_sql_file($BACKUP, $file);
        //reset tables
        if (!($res = db_list_tables($dbname, $dbh))) {
            setLogAndStatus("db_list_tables()", 1, $dbname, "databaseBackup()", 'LIST_TABLES_2');
        }
        $num_tables = db_num_rows($res);
        $i = 0;
        while ($i < $num_tables) {
            $table = db_tablename($res, $i);
            $query = "DELETE FROM {$dbname}.{$table}";
            $result = runQuery($query, 'setBackup()', 'RESET_TABLES');
            $i++;
        }
        //fill tables
        while (list($k, $query) = each($BACKUP)) {
            if (!ereg('^#', $query)) {
                if (!($result = db_query($query, $dbh))) {
                    setLogAndStatus($query, db_errno($dbh), db_error($dbh), "databaseBackup()", 'RESTORE_DB');
                    $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20055";
                    printPage('_admin_done.htmlt');
                    return;
                }
            }
        }
        $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20056";
        printPage('_admin_done.htmlt');
        return;
    }
    $backups = opendir(getAdmSetting('BACKUP_DIR'));
    $last = 0;
    while (($file = readdir($backups)) != false) {
        if (!is_dir($file)) {
            $date = stat(getAdmSetting('BACKUP_DIR') . "/{$file}");
            if ($last < $date[9]) {
                $month = intval(date('m'));
                $SUBS['LAST'] = $MSG[20051] . date(' d ', $date[9]) . $MONTHS[$month] . date(' Y H.i.s', $date[9]);
            }
            $SUBS['SIZE'] = sprintf('%0.2f KB', $date[7] / 1024);
            $SUBS['NAME'] = eregi_replace('_', ':', $file);
            $SUBS['CHECK'] = eregi_replace('[^a-z0-9]', '_', $file);
            //checkbox name
            $SUBS['WHERE'] = getAdmSetting('BACKUP_DIR') . "/{$file}";
            if (!($BACKUP = @file(getAdmSetting('BACKUP_DIR') . "/{$file}"))) {
                setLogAndStatus("Reading", 0, getAdmSetting('BACKUP_DIR') . "/{$file}", "setBackup()", 'READ_FILE');
            }
            $comments = '';
            //get comments from the beginning of the file
            for ($i = 0; $i < count($BACKUP); $i++) {
                if (eregi('^##(.*)$', $BACKUP[$i], $R)) {
                    $comments .= $R[1];
                }
            }
            if ($comments != '') {
                $SUBS['COMMENTS'] = ' &nbsp; ' . ereg_replace("\n", '<BR> &nbsp; ', htmlEncode($comments));
                $SUBS['COMMENTS'] = ereg_replace('<BR> &nbsp; $', '', $SUBS['COMMENTS']);
            } else {
                $SUBS['COMMENTS'] = '';
            }
            $SUBS['BACKUPS'] .= fileParse('_admin_backup_row.htmlt');
        }
    }
    closedir($backups);
    if ($PARAM['err'] != '') {
        $SUBS['ERROR'] = $MSG[$PARAM['err']];
        $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt');
    }
    printPage('_admin_backup.htmlt');
}
Esempio n. 4
0
function HTMLDoc_CreatePDF($ModeID, $HTML, $Prefix = '/')
{
    /****************************************************************************/
    $__args_types = array('string', 'string,object', 'string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    if (Is_Object($HTML)) {
        #---------------------------------------------------------------------------
        $Tables = $HTML->GetByTagName('TABLE');
        #---------------------------------------------------------------------------
        for ($i = 0; $i < Count($Tables); $i++) {
            #-------------------------------------------------------------------------
            $Table =& $Tables[$i];
            #-------------------------------------------------------------------------
            switch (@$Table->Attribs['class']) {
                case 'Standard':
                    $Table->AddAttribs(array('border' => 2, 'cellspacing' => 0, 'cellpadding' => 5), TRUE);
                    break;
                default:
                    # No more...
            }
        }
        #---------------------------------------------------------------------------
        $Tds = $HTML->GetByTagName('TD');
        #---------------------------------------------------------------------------
        for ($i = 0; $i < Count($Tds); $i++) {
            #-------------------------------------------------------------------------
            $Td =& $Tds[$i];
            #-------------------------------------------------------------------------
            switch (@$Td->Attribs['class']) {
                case 'Head':
                    $Td->AddAttribs(array('bgcolor' => '#ADC1F0'), TRUE);
                    break;
                case 'Separator':
                    $Td->AddAttribs(array('bgcolor' => '#EAEAEA'), TRUE);
                    break;
                default:
                    # No more...
            }
        }
        #---------------------------------------------------------------------------
        $Imgs = $HTML->GetByTagName('IMG');
        #---------------------------------------------------------------------------
        for ($i = 0; $i < Count($Imgs); $i++) {
            #-------------------------------------------------------------------------
            $Img =& $Imgs[$i];
            #-------------------------------------------------------------------------
            $Img->AddAttribs(array('src' => SPrintF('%s/%s', $Prefix, $Img->Attribs['src'])), TRUE);
        }
        #---------------------------------------------------------------------------
        $HTML = $HTML->Build();
    }
    #-----------------------------------------------------------------------------
    $Config = Config();
    #-----------------------------------------------------------------------------
    $Settings = $Config['HTMLDOC'];
    #-----------------------------------------------------------------------------
    $Modes = $Settings['Modes'];
    #-----------------------------------------------------------------------------
    $Mode = isset($Modes[$ModeID]) ? $Modes[$ModeID] : $ModeID;
    #-----------------------------------------------------------------------------
    $Tmp = System_Element('tmp');
    if (Is_Error($Tmp)) {
        return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: временная папка не найдена');
    }
    #-----------------------------------------------------------------------------
    $Logs = SPrintF('%s/logs', $Tmp);
    #-----------------------------------------------------------------------------
    if (!File_Exists($Logs)) {
        #---------------------------------------------------------------------------
        if (!@MkDir($Logs, 0777, TRUE)) {
            return ERROR | @Trigger_Error(500);
        }
    }
    #-----------------------------------------------------------------------------
    $HTML = @Mb_Convert_Encoding($HTML, $Settings['ConvertToCharset']);
    if (!$HTML) {
        return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось преобразовать кодировку');
    }
    #-----------------------------------------------------------------------------
    $UniqID = UniqID('HTMLDOC');
    #-----------------------------------------------------------------------------
    $File = IO_Write($Path = SPrintF('%s/%s', $Tmp, $UniqID), $HTML);
    Debug($File);
    if (Is_Error($File)) {
        return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось создать временный файл');
    }
    #-----------------------------------------------------------------------------
    $Command = SPrintF('htmldoc %s %s', $Mode, $Path);
    #-----------------------------------------------------------------------------
    Debug($Command);
    #-----------------------------------------------------------------------------
    if (!PutENV('HTMLDOC_NOCGI=1')) {
        return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось установить переменную окружения HTMLDOC_NOCGI');
    }
    #-----------------------------------------------------------------------------
    $HTMLDOC = @Proc_Open($Command, array(array('pipe', 'r'), array('pipe', 'w'), array('file', $Log = SPrintF('%s/HTMLDOC.log', $Logs), 'a')), $Pipes);
    if (!Is_Resource($HTMLDOC)) {
        return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось открыть процесс');
    }
    #-----------------------------------------------------------------------------
    $StdOut =& $Pipes[1];
    #-----------------------------------------------------------------------------
    $Result = '';
    #-----------------------------------------------------------------------------
    while (!Feof($StdOut)) {
        $Result .= FRead($StdOut, 1024);
    }
    #-----------------------------------------------------------------------------
    Proc_Close($HTMLDOC);
    #-----------------------------------------------------------------------------
    if (!UnLink($Path)) {
        return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось удалить временный файл');
    }
    #-----------------------------------------------------------------------------
    if (!$Result) {
        return ERROR | @Trigger_Error(SPrintF('[HTMLDoc_CreatePDF]: ошибка формирования PDF, смотрите (%s)', $Log));
    }
    #-----------------------------------------------------------------------------
    return $Result;
}
Esempio n. 5
0
$us = $_SESSION['u_id'];
mysql_connect($h, $u, $psw) or die("Can't connect to database.");
mysql_select_db("dobro_db1") or die("Could not select database");
session_start();
$file_n = $HTTP_POST_FILES['filebag']['name'];
$type_n = $HTTP_POST_FILES['filebag']['type'];
$size_n = $HTTP_POST_FILES['filebag']['size'];
$temp_n = $HTTP_POST_FILES['filebag']['tmp_name'];
$size_limit = get_option("upload_max_size");
$allowed_types = array("text/plain", "text/html", "application/x-zip-compressed");
if ($file_n) {
    $filesdir = get_option("upload_tmp_dir");
    $cp = date("h1i2s3_m4y5d");
    $tmpdir = $filesdir . $cp . "/";
    $sizekb = number_format($size_n / 1024, 2);
    MkDir($tmpdir, 0777) or die("Не удалось1");
    copy($temp_n, $tmpdir . $file_n) or die("Не удалось");
    $cnvlist = file($tmpdir . $file_n);
    echo $cnvlist[1];
}
if (!isset($del)) {
    $del = 0;
}
echo "<input type='hidden' name='del' id='del' value='" . $del . "'>";
if (!isset($client)) {
    $client = -1;
}
echo "<input type='hidden' name='client' id='client' value='" . $client . "'>";
if (!isset($backtr)) {
    $backtr = 0;
}
Esempio n. 6
0
function lock_dir($name = "")
{
    //ディレクトリロック
    if ($name == "") {
        $name = "lock";
    }
    // 3分以上前のディレクトリなら解除失敗とみなして削除
    if (file_exists($name) && filemtime($name) < time() - 180) {
        @RmDir($name);
    }
    do {
        if (@MkDir($name, 0777)) {
            return 1;
        }
        sleep(1);
        // 一秒待って再トライ
        $i++;
    } while ($i < 5);
    return 0;
}
Esempio n. 7
0
  {	
	$fileName = $HTTP_POST_FILES['filedata']['name'];
    $tmpName  = $HTTP_POST_FILES['filedata']['tmp_name'];
    $fileSize = $HTTP_POST_FILES['filedata']['size'];
    $fileType = $HTTP_POST_FILES['filedata']['type'];
    $fp      = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);
    $user_id=$_POST['user_id'];
	
	
	$filesdir=get_option("upload_tmp_dir");
    $cp=date("h1i2s3_m4y5d");
    $tmpdir=$filesdir.$cp."/";
    MkDir($tmpdir, 0777);
    copy($tmpName, $tmpdir.$fileName);
    $command = "/usr/local/bin/unzip ".$tmpdir.$fileName." -d ".$tmpdir;
    exec($command);
	
	$transport = array(
	    0 => "�אלמכוע",
		1 => "�ארטםא",
		2 => "�מםעויםונ",
		3 => "��"
	);
   
   $query = "select div_id, parentdiv_id, divname, dl_id, stock_id from `div` where dl_id in (6,2) and stock_id is not null order by dl_id, div_id";
   $res = mysql_query($query) or die(mysql_error());
	while ($row=mysql_fetch_array($res)){
	  $store[$row['stock_id']]=$row['div_id'];
Esempio n. 8
0
function IO_Write($Path, $Data, $IsRewrite = FALSE, $Wait = 3)
{
    /******************************************************************************/
    $__args_types = array('string', 'string', 'boolean', 'integer');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    Debug(SPrintF('[IO_Write]: запись в файл (%s)', $Path));
    #-------------------------------------------------------------------------------
    if (File_Exists($Path)) {
        #-------------------------------------------------------------------------------
        $Start = Time() + $Wait;
        #-------------------------------------------------------------------------------
        do {
        } while (!Is_Writable($Path) && Time() < $Start);
        #-------------------------------------------------------------------------------
    } else {
        #-------------------------------------------------------------------------------
        $Folder = DirName($Path);
        #-------------------------------------------------------------------------------
        if (!File_Exists($Folder)) {
            #-------------------------------------------------------------------------------
            Debug(SPrintF('[IO_Write]: создание директории (%s)', $Folder));
            #-------------------------------------------------------------------------------
            if (!@MkDir($Folder, 0777, TRUE)) {
                return ERROR | @Trigger_Error(SPrintF('[IO_Write]: не возможно создать директорию (%s)', $Folder));
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    $File = @Fopen($Path, $IsRewrite ? 'w' : 'a');
    if (!$File) {
        return ERROR | @Trigger_Error('[IO_Write]: ошибка открытия файла');
    }
    #-------------------------------------------------------------------------------
    if (!@Fwrite($File, $Data)) {
        return ERROR | @Trigger_Error('[IO_Write]: ошибка записи в файл');
    }
    #-------------------------------------------------------------------------------
    if (!@Fclose($File)) {
        return ERROR | @Trigger_Error('[IO_Write]: ошибка закрытия файла');
    }
    #-------------------------------------------------------------------------------
    # почему закомменчено - не знаю. так было.
    #if(Preg_Match('/\/tmp\//',$Path))
    #	if(!@ChMod($Path,0666))
    #		@Trigger_Error('[IO_Write]: ошибка установки прав на файл');
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Esempio n. 9
0
 public function Install_Template()
 {
     # Was this a Post request with data enctype?
     if (!Is_Array($_FILES) || empty($_FILES)) {
         return False;
     }
     # Check the files
     foreach ($_FILES as $field_name => $arr_file) {
         if (!Is_File($arr_file['tmp_name'])) {
             unset($_FILES[$field_name]);
         }
     }
     # Check if there are uploaded files
     if (empty($_FILES)) {
         return False;
     }
     # Create template dir
     if (!Is_Dir($this->template_dir)) {
         MkDir($this->template_dir);
         ChMod($this->template_dir, 0755);
     }
     # Copy the template file
     if (isset($_FILES['template_zip'])) {
         # Install the ZIP Template
         $zip_file = $_FILES['template_zip']['tmp_name'];
         require_once 'includes/file.php';
         WP_Filesystem();
         return UnZip_File($zip_file, $this->template_dir);
     } elseif (isset($_FILES['template_php']) && $this->Get_Template_Properties($_FILES['template_php']['tmp_name'])) {
         # Install the PHP Template
         $php_file = $_FILES['template_php']['tmp_name'];
         $template_name = BaseName($_FILES['template_php']['name'], '.php');
         # Create dir and copy file
         if (!Is_Dir($this->template_dir . '/' . $template_name)) {
             MkDir($this->template_dir . '/' . $template_name);
             ChMod($this->template_dir . '/' . $template_name, 0755);
         }
         Copy($php_file, $this->template_dir . '/' . $template_name . '/' . $template_name . '.php');
         ChMod($this->template_dir . '/' . $template_name . '/' . $template_name . '.php', 0755);
     } else {
         return False;
     }
     # Template installed
     return True;
 }
Esempio n. 10
0
 #-------------------------------------------------------------------------------
 if (!File_Exists($File)) {
     #-------------------------------------------------------------------------------
     Array_UnShift($HostsIDs, HOST_ID);
     #-------------------------------------------------------------------------------
     if (!File_Put_Contents($File, SPrintF("HostsIDs=%s\nmemcached.port=11211", Implode(',', $HostsIDs)))) {
         Error(SPrintF('Ошибка записи файла (%s)', $File));
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 $Link = SPrintF('%s/hosts/%s/tmp/public', SYSTEM_PATH, HOST_ID);
 #-------------------------------------------------------------------------------
 if (!File_Exists($Link)) {
     #-------------------------------------------------------------------------------
     if (!@MkDir($Link, 0755, TRUE)) {
         Error(SPrintF('Не возможно создать директорию (%s)', $Link));
     }
     #-------------------------------------------------------------------------------
     if (!@SymLink(SPrintF('./hosts/%s/tmp/public', HOST_ID), './public')) {
         Error(SPrintF('Не возможно создать символическую ссылку (%s)', $Link));
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 if (File_Exists(SETTINGS_FILE)) {
     if (!@UnLink(SETTINGS_FILE)) {
         Error(SPrintF('Не возможно удалить файл (%s)', SETTINGS_FILE));
     }
 }
 #-------------------------------------------------------------------------------
Esempio n. 11
0
    return new gException('FILE_TOO_BIG', SPrintF('Файл превышает максимально допустимый размер (%uMb > %uMb)', $File['size'] / (1024 * 1024), $Settings['MaxFileSize']));
}
#-------------------------------------------------------------------------------
$Tmp = System_Element('tmp');
if (Is_Error($Tmp)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Path = $File['tmp_name'];
#-------------------------------------------------------------------------------
$Hash = Md5(Time() + Rand(100, 999));
#-------------------------------------------------------------------------------
$Uploads = SPrintF('%s/uploads', $Tmp);
#-------------------------------------------------------------------------------
if (!File_Exists($Uploads)) {
    if (!@MkDir(SPrintF('%s/uploads', $Tmp), 0777, TRUE)) {
        return ERROR | @Trigger_Error(500);
    }
}
#-------------------------------------------------------------------------------
if (!Copy($Path, SPrintF('%s/%s', $Uploads, $Hash))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Name = $File['name'];
#-------------------------------------------------------------------------------
$NamesPath = SPrintF('%s/names.txt', $Uploads);
#-------------------------------------------------------------------------------
$Names = Is_Error($Names = IO_Read($NamesPath)) ? array() : JSON_Decode($Names, true);
#-------------------------------------------------------------------------------
$Names[$Hash] = $Name;
Esempio n. 12
0
    #-------------------------------------------------------------------------------
    Debug('[comp/Tasks/CheckEmail]: сообщения не обработаны, т.к. пользователь "Гость", идентификатор 10 не найден');
    #-------------------------------------------------------------------------------
    $GLOBALS['TaskReturnInfo'][] = "no message processing, because user 'Guest', ID=10 does not exists";
    #-------------------------------------------------------------------------------
    return $ExecuteTime;
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Server = SPrintF("{%s/%s/%s}INBOX", $ServerSettings['Address'], $ServerSettings['Params']['Method'], $ServerSettings['Protocol'] == 'ssl' ? 'ssl/novalidate-cert' : 'notls');
#-------------------------------------------------------------------------------
$attachmentsDir = SPrintF('%s/hosts/%s/tmp/imap', SYSTEM_PATH, HOST_ID);
#-------------------------------------------------------------------------------
if (!File_Exists($attachmentsDir)) {
    MkDir($attachmentsDir, 0700, true);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
try {
    #-------------------------------------------------------------------------------
    $mailbox = new ImapMailbox($Server, $ServerSettings['Login'], $ServerSettings['Password'], $attachmentsDir);
    #-------------------------------------------------------------------------------
} catch (Exception $e) {
    #-------------------------------------------------------------------------------
    Debug(SPrintF('[comp/Tasks/CheckEmail]: Exception = %s', $e->getMessage()));
    return 3600;
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
Esempio n. 13
0
$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);
    }
}
#-------------------------------------------------------------------------------
if (!Is_Link($wadata)) {
    if (!SymLink($DataFolder, $wadata)) {
        return ERROR | @Trigger_Error(500);
    }
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$WhatsAppClient = new WhatsProt($Settings['Login'], $Settings['Params']['Sender'], FALSE, TRUE, $DataFolder);
if (Is_Error($WhatsAppClient)) {
    return ERROR | @Trigger_Error(500);
}
Esempio n. 14
0
 function prepare_cache_file()
 {
     // Prepare Cache file
     if (!Is_Dir($this->cache_dir_path) && !Is_File($this->cache_dir_path) && Is_Writable(DirName($this->cache_dir_path))) {
         MkDir($this->cache_dir_path);
         ChMod($this->cache_dir_path, 0755);
     }
     if (Is_Dir($this->cache_dir_path) && Is_Writable($this->cache_dir_path)) {
         Touch($this->cache_file_path);
     }
 }