コード例 #1
0
<!--Código PHP-->
<?php 
echo "</br>";
$quebra_linha = "\r\n";
$i = 1;
//salvar em TXT
if (isset($_POST["botao"])) {
    @($arquivoDeTexto = "chamada.txt");
    if ($_POST["nome"] == null) {
        $_POST["nome"] = "Não Informado";
    }
    if ($_POST["data"] == null) {
        $_POST["data"] = "Não Informado";
    }
    @($formulario = " |Cliente: " . $_POST["nome"] . " |Data: " . $_POST["data"] . " |Origem: " . $_POST["pesquisaOrigem"] . " |Destino: " . $_POST["pesquisaDestino"] . " |Tempo: " . $_POST["tempo"] . " |Valor: " . $_POST["preco"] . $quebra_linha);
    @($ponteiro = Fopen($arquivoDeTexto, "a+"));
    fwrite($ponteiro, $formulario);
    fclose($ponteiro);
    if ($arquivoDeTexto) {
        @($arquivo = fopen($arquivoDeTexto, "r")) or die("Erro!");
        while (!feof($arquivo)) {
            @($buffer = fgets($arquivo));
            $saltodelinha = nl2br($buffer);
            echo "Corrida " . $i . " - " . $saltodelinha;
            $i++;
        }
        fclose($arquivo);
    }
}
?>
	</body>
コード例 #2
0
ファイル: IO.php プロジェクト: carriercomm/jbs
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;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}