Ejemplo n.º 1
0
function insertIntoRestaurant($name1, $street, $city, $state, $zip, $long, $lat, $conn, $cities)
{
    $sql = "insert into " . userAccount . ".restaurant values('" . db2_escape_string($name1) . "', NULL, '" . db2_escape_string($street) . "', '" . db2_escape_string($city) . "', '" . db2_escape_string($state) . "', '" . db2_escape_string($zip) . "', '" . COUNTY . "', " . $long . ", " . $lat . ", db2gse.ST_Point(" . $long . ", " . $lat . ", 1))";
    if (array_key_exists($city, $GLOBALS['cities'])) {
        //Hashmap lookup to filter unwanted cities, O(1)
        /*
        		$result = db2_exec( $GLOBALS['conn'] , $sql );
        		if(!$result){
        			//log failure
        			//$sql .= "\r\n";
        			saveToFile(errorFile, $sql."\r\n");
                }*/
        try {
            $result = db2_exec($GLOBALS['conn'], $sql);
            //saveToFile(errorFile1, $sql."\r\n");
        } catch (Exception $e) {
            //log failure
            //$sql .= "\r\n";
            saveToFile(errorFile1, $sql . "\r\n");
            echo "Query Failed<br>";
            echo "Exception: " . $e->getMessage() . "<br>";
            echo db2_conn_error() . "<br>";
            echo db2_conn_errormsg() . "<br>";
        }
    } else {
        //log rejected city
        //$sql .= "\r\n";
        saveToFile(errorFile2, $sql . "\r\n");
    }
}
<?php

/* This file stores the specified RDF content temporarily
   on the server, to be served to the browser, and is then
   immediately removed from the server. Typical usage: "Download my RDF file" button */
error_reporting(E_ALL);
ini_set('display_errors', '1');
include "downloadFile.php";
include "include/Serializer.php";
define("RDFAPI_INCLUDE_DIR", "include/rdfapi-php/api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
include RDFAPI_INCLUDE_DIR . "syntax/RdfSerializer.php";
include RDFAPI_INCLUDE_DIR . 'vocabulary/RDFS_C.php';
include RDFAPI_INCLUDE_DIR . 'vocabulary/DC_C.php';
include RDFAPI_INCLUDE_DIR . 'vocabulary/FOAF_C.php';
header("Content-Type: application/rdf+xml");
header("Content-Disposition: attachment; filename=" . $_POST['fileName']);
saveToFile($_POST['rawRDF'], $_POST['fileName']);
readfile($_POST['fileLoc']);
unlink("rdf/" . $_POST['fileName']);
Ejemplo n.º 3
0
function getListURL($url, $keywords, $keywordsPlural, $keywordsName, $fileName, $filePath)
{
    if (!($result = getURL($url))) {
        return array('status' => 'warning', 'message' => "Получена пустая страница по адресу <b>{$url}</b>");
    }
    /* fix bag */
    saveToFile($filePath, "tmp_{$_REQUEST['keywords']}.data", str_replace('www.', '', $url), true);
    $arKeywordsCurRequest = getKeywordsFromURL($url);
    $patternfromLinks = "/href=\"(.*\\?{$keywordsName}=.*)\"/iUs";
    if (!preg_match_all($patternfromLinks, $result, $matches)) {
        return array('status' => 'warning', 'message' => "Не найдено ни одного ключевого слова по адресу <b>{$url}</b>");
    }
    $listURL = $matches[1];
    $validListURL = array();
    $keywordsCount = 0;
    foreach ($listURL as $url) {
        $arKeywords = getKeywordsFromURL($url);
        $keywordsFound = $arKeywords['keywords'];
        if (!isValidKeywords($keywords, $keywordsPlural, $keywordsFound)) {
            continue;
        }
        if (notInFile($filePath, "tmp_{$_REQUEST['keywords']}.data", $url)) {
            $validListURL[] = $url;
        }
        if (notInFile($filePath, $fileName, $keywordsFound)) {
            $keywordsCount++;
            saveToFile($filePath, $fileName, $keywordsFound, true);
        }
    }
    if (count($validListURL)) {
        return array('listurl' => $validListURL, 'log' => array('keywords' => $arKeywordsCurRequest['keywords'], 'keywordscount' => $keywordsCount));
    } else {
        return array('status' => 'warning', 'message' => "Все ключевые слова по адресу <b>{$url}</b> уже были сохранены или не подходят по начальному слову");
    }
}
Ejemplo n.º 4
0
    $awards = getFile();
    //KIEM TRA CO GIA THUONG NAO DA HET HAY CON
    $awards_rand = $awards;
    foreach ($awards_rand as $key => $award) {
        if ($award <= 0) {
            unset($awards_rand[$key]);
        }
    }
    //LAY NGAY NHIEN TRONG NHUNG GIAI THUONG CON
    $aw = array_rand($awards_rand);
    //TRU GIAI THUONG DUOC CHON DI 1 GIAI THUONG
    if ($aw != "") {
        $awards[$aw]--;
    }
    //LUU LAI GAI THUONG VAO FILE
    saveToFile($awards);
    $aw = $aw == 'award_a' ? "A" : $aw;
    $aw = $aw == 'award_b' ? "B" : $aw;
    $aw = $aw == 'award_c' ? "C" : $aw;
    $data['awards'] = $aw;
    echo json_encode($data);
}
function saveToFile($data = null)
{
    if ($data == null) {
        return;
    }
    $file_path = 'save.txt';
    $file = fopen($file_path, "w") or die("can't open file");
    foreach ($data as $key => $value) {
        $value = trim($value);
Ejemplo n.º 5
0
    //$requestHeader[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    //$requestHeader[] = "Accept-Language: en-us,en;q=0.5";
    //$requestHeader[] = "Pragma: "; // browsers keep this blank.
    curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeader);
    $response = curl_exec($ch);
    //store the content in variable
    if (!curl_errno($ch)) {
        //send out headers and output
        header("Content-type: " . curl_getinfo($ch, CURLINFO_CONTENT_TYPE) . "");
        header("Content-Length: " . curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD) . "");
        //printAutoNewline($response);
    } else {
        printAutoNewline('Curl error: ' . curl_error($ch));
    }
    curl_close($ch);
    //close curl handle
    return $response;
}
printAutoNewline("DIRECTORY_SEPARATOR=" . DIRECTORY_SEPARATOR);
$yellEntryUrl = "http://www.yell.com/";
$yesllRespHtml = getUrlRespHtml($yellEntryUrl);
//printAutoNewline("yesllRespHtml=".$yesllRespHtml);
$outputFilename = "respHtml.html";
saveToFile($yesllRespHtml, $outputFilename);
$keywords = "plumbers";
$yellSearchUrl = "http://www.yell.com/ucs/UcsSearchAction.do?keywords=" . $keywords . "&location=&scrambleSeed=30792452&searchType=&M=&bandedclarifyResults=&ssm=1";
$searchRespHtml = getUrlRespHtml($yellSearchUrl);
saveToFile($yesllRespHtml, "searchResult.html");
// $outestDivPattern = '#<div class="\S+" name="\S+">(.+)</div>#is';
// preg_match($outestDivPattern, $testStr, $matches);
// print_r($matches); #注意,通过网页方式查看打印出来的字符,是看不到div的,需要查看网页源代码,就可以看出来对应的div了
Ejemplo n.º 6
0
function exec_FOP($files, $mode = '-q', $asynch = false)
{
    $config_file = $files['config_file'];
    $fo_file = $files['fo_file'];
    $xml_file = $files['xml_file'];
    $xsl_file = $files['xsl_file'];
    $pdf_file = $files['pdf_file'];
    $log_file = $files['log_file'];
    $config_file_ok = !empty($config_file) && file_exists($config_file);
    $fo_file_ok = !empty($fo_file) && file_exists($fo_file);
    $xml_file_ok = !empty($xml_file) && file_exists($xml_file);
    $xsl_file_ok = !empty($xsl_file) && file_exists($xsl_file);
    $pdf_file_ok = !empty($pdf_file);
    $log_file_ok = !empty($log_file);
    $input_ok = $fo_file_ok || $xml_file_ok && $xsl_file_ok;
    if (!($config_file_ok && $input_ok && $pdf_file_ok)) {
        echo "error_fop: {$config_file_ok} && ({$fo_file_ok} || ( {$xml_file_ok} && {$xsl_file_ok} )) && {$pdf_file_ok}\n";
        print_r($files);
        exit;
    }
    $config_file_param = $config_file_ok ? ' -c ' . $config_file : '';
    $fo_file_param = $fo_file_ok ? ' -fo ' . $fo_file : '';
    $xml_file_param = $xml_file_ok ? ' -xml ' . $xml_file : '';
    $xsl_file_param = $xsl_file_ok ? ' -xsl ' . $xsl_file : '';
    $pdf_file_param = $pdf_file_ok ? ' -pdf ' . $pdf_file : '';
    if ($asynch) {
        $command = "nice " . CONFIG::get('app_FOPBIN') . " -r {$mode}";
    } else {
        $command = CONFIG::get('app_FOPBIN') . " -r {$mode}";
    }
    $command .= $config_file_param . ($fo_file_ok ? $fo_file_param : $xml_file_param . $xsl_file_param) . $pdf_file_param;
    $log_tmp = 'makePrintPdfs.txt';
    saveToFile($command, $log_tmp);
    $pre_fop = "export JAVACMD=" . CONFIG::get('app_JAVAPATH') . "java ; ";
    if ($asynch) {
        saveToFile('1:' . $pre_fop . escapeshellcmd($command) . ($log_file_ok ? " > {$log_file} 2>&1" : '') . ' &', $log_tmp);
        exec($pre_fop . escapeshellcmd($command) . ($log_file_ok ? " > {$log_file} 2>&1" : '') . ' &');
    } else {
        saveToFile('2:' . $pre_fop . escapeshellcmd($command) . ($log_file_ok ? " > {$log_file} 2>&1" : ''), $log_tmp);
        exec($pre_fop . escapeshellcmd($command) . ($log_file_ok ? " > {$log_file} 2>&1" : ''));
    }
}
Ejemplo n.º 7
0
function makeFont($fontfile, $afmfile, $enc = 'cp1252', $patch = array(), $type = 'TrueType')
{
    //Generate a font definition file
    if (get_magic_quotes_runtime()) {
        @set_magic_quotes_runtime(0);
    }
    ini_set('auto_detect_line_endings', '1');
    if ($enc) {
        $map = readMap($enc);
        foreach ($patch as $cc => $gn) {
            $map[$cc] = $gn;
        }
    } else {
        $map = array();
    }
    if (!file_exists($afmfile)) {
        die('<b>Error:</b> AFM file not found: ' . $afmfile);
    }
    $fm = readAFM($afmfile, $map);
    if ($enc) {
        $diff = makeFontEncoding($map);
    } else {
        $diff = '';
    }
    $fd = makeFontDescriptor($fm, empty($map));
    //Find font type
    if ($fontfile) {
        $ext = strtolower(substr($fontfile, -3));
        if ($ext == 'ttf') {
            $type = 'TrueType';
        } elseif ($ext == 'pfb') {
            $type = 'Type1';
        } else {
            die('<b>Error:</b> unrecognized font file extension: ' . $ext);
        }
    } else {
        if ($type != 'TrueType' && $type != 'Type1') {
            die('<b>Error:</b> incorrect font type: ' . $type);
        }
    }
    //Start generation
    $s = '<?php' . "\n";
    $s .= '$type=\'' . $type . "';\n";
    $s .= '$name=\'' . $fm['FontName'] . "';\n";
    $s .= '$desc=' . $fd . ";\n";
    if (!isset($fm['UnderlinePosition'])) {
        $fm['UnderlinePosition'] = -100;
    }
    if (!isset($fm['UnderlineThickness'])) {
        $fm['UnderlineThickness'] = 50;
    }
    $s .= '$up=' . $fm['UnderlinePosition'] . ";\n";
    $s .= '$ut=' . $fm['UnderlineThickness'] . ";\n";
    $w = makeWidthArray($fm);
    $s .= '$cw=' . $w . ";\n";
    $s .= '$enc=\'' . $enc . "';\n";
    $s .= '$diff=\'' . $diff . "';\n";
    $basename = substr(basename($afmfile), 0, -4);
    if ($fontfile) {
        //Embedded font
        if (!file_exists($fontfile)) {
            die('<b>Error:</b> font file not found: ' . $fontfile);
        }
        if ($type == 'TrueType') {
            checkTTF($fontfile);
        }
        $f = fopen($fontfile, 'rb');
        if (!$f) {
            die('<b>Error:</b> Can\'t open ' . $fontfile);
        }
        $file = fread($f, filesize($fontfile));
        fclose($f);
        if ($type == 'Type1') {
            //Find first two sections and discard third one
            $header = ord($file[0]) == 128;
            if ($header) {
                //Strip first binary header
                $file = substr($file, 6);
            }
            $pos = strpos($file, 'eexec');
            if (!$pos) {
                die('<b>Error:</b> font file does not seem to be valid Type1');
            }
            $size1 = $pos + 6;
            if ($header && ord($file[$size1]) == 128) {
                //Strip second binary header
                $file = substr($file, 0, $size1) . substr($file, $size1 + 6);
            }
            $pos = strpos($file, '00000000');
            if (!$pos) {
                die('<b>Error:</b> font file does not seem to be valid Type1');
            }
            $size2 = $pos - $size1;
            $file = substr($file, 0, $size1 + $size2);
        }
        if (function_exists('gzcompress')) {
            $cmp = $basename . '.z';
            saveToFile($cmp, gzcompress($file), 'b');
            $s .= '$file=\'' . $cmp . "';\n";
            echo 'Font file compressed (' . $cmp . ')<br>';
        } else {
            $s .= '$file=\'' . basename($fontfile) . "';\n";
            echo '<b>Notice:</b> font file could not be compressed (zlib extension not available)<br>';
        }
        if ($type == 'Type1') {
            $s .= '$size1=' . $size1 . ";\n";
            $s .= '$size2=' . $size2 . ";\n";
        } else {
            $s .= '$originalsize=' . filesize($fontfile) . ";\n";
        }
    } else {
        //Not embedded font
        $s .= '$file=' . "'';\n";
    }
    $s .= "?>\n";
    saveToFile($basename . '.php', $s, 't');
    echo 'Font definition file generated (' . $basename . '.php' . ')<br>';
}