/**
 * 保存用户头像
 * @param $uid int 用户UID
 * @param $picData object 头像数据流
 * @return string 生成后的头像地址
 */
function setAvatar($uid, $picData, $sync = false)
{
    $fpath = avatarFile($uid, 132);
    if ($uid && $picData) {
        saveFile($fpath, $picData, true, $sync);
    }
    return getImgUrl($fpath);
}
function openFile($url, $size)
{
    if (file_exists($url)) {
        $file = $url;
        $dataToReturn = file_get_contents($file);
    } else {
        saveFile($url, "");
        $dataToReturn = "";
    }
    return $dataToReturn;
}
示例#3
0
 public function index()
 {
     // get all images
     $images = $this->vk->getImages();
     // update last date in db
     $this->parser->update_last_date('jokes', array('last_update' => date("Y-m-d H:i:s")));
     // save all images in folder
     $path = 'assets/images/';
     foreach ($images as $key => $value) {
         $expansion = new SplFileInfo($value->url);
         $fileName = uniqid('post_', true) . '.' . $expansion->getExtension();
         $result = saveFile($value->url, $path . $fileName);
         if ($result == 200) {
             $this->image->setImages(array('title' => $value->text, 'image' => $fileName));
         }
     }
     $this->output->set_status_header(200)->set_output('Success');
 }
示例#4
0
 public function index()
 {
     //logutils::log_obj($_FILES['upload_img']);
     if (isset($_FILES['upload_img'])) {
         $filename = ROOT_PATH . strim($GLOBALS['request']['filename']);
         //logutils::log_str($filename);
         $dir = dirname($filename);
         if (!is_dir($dir)) {
             mkpathA($dir);
         }
         if (saveFile($_FILES['upload_img']['tmp_name'], $filename)) {
             $root['status'] = 1;
         } else {
             $root['status'] = 0;
         }
     } else {
         $root['status'] = 0;
     }
     //logutils::log_obj($root);
     output($root);
 }
示例#5
0
function read($n)
{
    loadNames();
    global $sData;
    $start = false;
    $fd = fopen($n, "r");
    while (!feof($fd)) {
        $buffer = fgets($fd);
        $line = trim($buffer);
        if ($start) {
            parseLine($line);
        }
        if (substr($line, 0, 34) == "do_system_check_initialisation() {") {
            $start = true;
        }
        if (trim(substr($line, 0, 14)) == "# Evil strings") {
            $start = false;
        }
    }
    fclose($fd);
    saveFile('out.txt', $sData);
}
示例#6
0
文件: main.php 项目: koala87/backup
function saveSqlLog($sqlTimeStart, $sql)
{
    if (SAVE_LOG) {
        $t = microtime(true) - $sqlTimeStart;
        $str = date("Y-m-d H:i:s") . ' ' . sprintf('%01.17f', $t) . ' -> ' . $sql . PHP_EOL;
        saveFile($str);
    }
}
示例#7
0
 function saveDoc($testId)
 {
     if (!$this->safety->allowByControllerName('testing/edit')) {
         return errorForbidden();
     }
     $this->deleteDoc($testId);
     $result = saveFile(config_item('testDoc'));
     if ($result['code'] != true) {
         return loadViewAjax(false, $result['result']);
     }
     $this->Testing_Model->saveDoc($testId, $result['fileId']);
     $data = $this->Testing_Model->get($testId, true);
     return loadViewAjax(true, $data['testDoc']);
 }
示例#8
0
      </Constraint>
   </csw:Query>
</GetRecords>';
/**
 * Send a post $request at $url
 * 
 * If headers is set to false, do not force headers
 * during POST request
 */
if (isset($_REQUEST["headers"]) && $_REQUEST["headers"] == "false") {
    $theData = postRemoteData($url, $request, false);
} else {
    $theData = postRemoteData($url, $request, true);
}
/**
 * Store request and response
 */
if (MSP_DEBUG) {
    $tmp = createPassword(10);
    saveFile($request, MSP_UPLOAD_DIR . "csw_" . $tmp . "_request.xml");
    $resultFileURI = saveFile($theData, MSP_UPLOAD_DIR . "csw_" . $tmp . "_response.xml");
}
/**
 *  Check if a SOAP Fault occured
 */
$error = OWSExceptionToJSON($theData);
if ($error) {
    echo $error;
} else {
    echo outputToGeoJSON($theData);
}
示例#9
0
 $input = $_REQUEST["vmlCode"];
 $language = $_REQUEST["language"];
 $filename = saveFile($input);
 $outputFilename = "{$filename}.output";
 $command = "java -jar vml.jar {$outputFilename} {$filename}";
 exec($command);
 $genericCode = readTemporaryFile($outputFilename);
 if ($language == "Generic") {
     $sourceCode = $genericCode;
 } else {
     $secondOutFilename = "{$filename}.{$language}.output";
     if (in_array($language, array("Php", "Java", "Ruby", "Alloy", "NuSMV"))) {
         saveFile("generate {$language};\n" . $genericCode, $outputFilename);
         $command = "java -jar umplesync.jar -source {$outputFilename} > {$secondOutFilename}";
     } else {
         saveFile($genericCode, $outputFilename);
         $command = "java -jar umplesync.jar -generate {$language} {$outputFilename}  > {$secondOutFilename}";
     }
     exec($command);
     $sourceCode = readTemporaryFile($secondOutFilename);
     $sourceCode = str_replace("<?php", "", $sourceCode);
     $sourceCode = str_replace("?>", "", $sourceCode);
     if ($sourceCode == "") {
         $sourceCode = "//Generated code did not compile in Umple, please review the Umple code below and then fix your VML code\n\n";
         $sourceCode .= $genericCode;
     }
 }
 if ($language != "Json") {
     $sourceCode = htmlspecialchars($sourceCode);
 }
 if ($sourceCode == "") {
示例#10
0
function makeWeather($saveFilePath = 'api', $openFile = '/weather.txt')
{
    //读取文件并过滤重复
    $handle = fopen($saveFilePath . $openFile, "r");
    if (!$handle) {
        exit('文件不存在。');
    }
    $temp_arr = array();
    do {
        $file = fgets($handle, 1024);
        $temp_arr[] = $file;
    } while (!feof($handle));
    fclose($handle);
    //遍历数组,取相同组,创建新数组,最后得到没有重复的数组,筛选完成
    $newArr = array();
    foreach ($temp_arr as $key => $value) {
        if (in_array($value, $arr)) {
            unset($newArr[$key]);
        } else {
            $newArr[] = $value;
        }
    }
    //去掉文件中空值,同时去掉最后一个空值被取到数组
    $cot = count($newArr);
    unset($newArr[$cot - 1]);
    //获取要采集的文件
    foreach ($newArr as $key => $value) {
        flush();
        $urlFile = str_replace(PHP_EOL, '', $value);
        //PHP自带过滤换行
        $urlFile = parse_url($urlFile, PHP_URL_PATH);
        $urlFile = $saveFilePath . $urlFile;
        $value = str_replace(PHP_EOL, '', $value);
        //PHP自带过滤换行
        //未成功写入则跳过
        if (saveFile($urlFile, curl_file($value))) {
            echo '<font color="#66CC00">写入成功</font> ' . $urlFile . '<br>';
            ob_flush();
        } else {
            continue;
        }
    }
    exit($openFile . '中文件采集执行完毕。');
}
示例#11
0
/**
 ** takes a page test, and runs it and tests it for problems in the output.
 **        Returns: False on finding a problem, or True on no problems being found.
 */
function runWikiTest(pageTest $test, &$testname, $can_overwrite = false)
{
    // by default don't overwrite a previous test of the same name.
    while (!$can_overwrite && file_exists(DIRECTORY . "/" . $testname . DATA_FILE)) {
        $testname .= "-" . mt_rand(0, 9);
    }
    $filename = DIRECTORY . "/" . $testname . DATA_FILE;
    // Store the time before and after, to find slow pages.
    $before = microtime(true);
    // Get MediaWiki to give us the output of this test.
    $wiki_preview = wikiTestOutput($test);
    $after = microtime(true);
    // if we received no response, then that's interesting.
    if ($wiki_preview == "") {
        print "\nNo response received for: {$filename}";
        return false;
    }
    // save output HTML to file.
    $html_file = DIRECTORY . "/" . $testname . HTML_FILE;
    saveFile($wiki_preview, $html_file);
    // if there were PHP errors in the output, then that's interesting too.
    if (strpos($wiki_preview, "<b>Warning</b>: ") !== false || strpos($wiki_preview, "<b>Fatal error</b>: ") !== false || strpos($wiki_preview, "<b>Notice</b>: ") !== false || strpos($wiki_preview, "<b>Error</b>: ") !== false || strpos($wiki_preview, "<b>Strict Standards:</b>") !== false) {
        $error = substr($wiki_preview, strpos($wiki_preview, "</b>:") + 7, 50);
        // Avoid probable PHP bug with bad session ids; http://bugs.php.net/bug.php?id=38224
        if ($error != "Unknown: The session id contains illegal character") {
            print "\nPHP error/warning/notice in HTML output: {$html_file} ; {$error}";
            return false;
        }
    }
    // if there was a MediaWiki Backtrace message in the output, then that's also interesting.
    if (strpos($wiki_preview, "Backtrace:") !== false) {
        print "\nInternal MediaWiki error in HTML output: {$html_file}";
        return false;
    }
    // if there was a Parser error comment in the output, then that's potentially interesting.
    if (strpos($wiki_preview, "!-- ERR") !== false) {
        print "\nParser Error comment in HTML output: {$html_file}";
        return false;
    }
    // if a database error was logged, then that's definitely interesting.
    if (dbErrorLogged()) {
        print "\nDatabase Error logged for: {$filename}";
        return false;
    }
    // validate result
    $valid = true;
    if (VALIDATE_ON_WEB) {
        list($valid, $validator_output) = validateHTML($wiki_preview);
        if (!$valid) {
            print "\nW3C web validation failed - view details with: html2text " . DIRECTORY . "/" . $testname . ".validator_output.html";
        }
    }
    // Get tidy to check the page, unless we already know it produces non-XHTML output.
    if ($test->tidyValidate()) {
        $valid = tidyCheckFile($testname . HTML_FILE) && $valid;
    }
    // if it took more than 2 seconds to render, then it may be interesting too. (Possible DoS attack?)
    if ($after - $before >= 2) {
        print "\nParticularly slow to render (" . round($after - $before, 2) . " seconds): {$filename}";
        return false;
    }
    if ($valid) {
        // Remove temp HTML file if test was valid:
        unlink($html_file);
    } elseif (VALIDATE_ON_WEB) {
        saveFile($validator_output, DIRECTORY . "/" . $testname . ".validator_output.html");
    }
    return $valid;
}
<?php

$n = 0;
$thisScript = $argv[$n++];
$sourceRuleFile = $argv[$n++];
$targetRuleFile = $argv[$n++];
require_once '../../configs/main.config.local.php';
echo "Using megalib from " . ABSPATH_MEGALIB . "\n";
require_once ABSPATH_MEGALIB . 'CSV.php';
require_once ABSPATH_MEGALIB . 'Files.php';
echo "loading source rule file from {$sourceRuleFile}\n";
$csv = new CSVFile();
if (!$csv->load($sourceRuleFile)) {
    die("File {$sourceRuleFile} not found\n");
}
echo "saving the rule file to {$targetRuleFile}\n";
if (!saveFile($targetRuleFile, $csv->getJSON())) {
    die('Cannot save file ' . $targetRuleFile . "\n");
}
echo "done";
示例#13
0
文件: compiler.php 项目: umple/umple
 }
 if ($toRemove) {
     exec($rmcommand);
 }
 // The following is a hack. The arguments to umplesync need fixing
 if (!$stateDiagram && !$classDiagram && !$entityRelationshipDiagram && !$yumlDiagram) {
     $command = "java -jar umplesync.jar -source {$filename} 1> {$outputFilename} 2> {$errorFilename}";
 } else {
     // The following is used for outputting diagrams only
     $thedir = dirname($outputFilename);
     exec("rm -rf " . $thedir . "/modelcd.gv " . $thedir . "/model.gv " . $thedir . "modelcdt.gv " . $thedir . "/modelerd.gv");
     $command = "java -jar umplesync.jar -generate " . $language . " {$filename} " . $suboptions . " 1> {$outputFilename} 2> {$errorFilename}";
 }
 exec("( ulimit -t 10; " . $command . ")");
 // Restore file so it doesn't have the 'generate' command in front
 saveFile($input);
 $sourceCode = readTemporaryFile($outputFilename);
 $sourceCode = str_replace("<?php", "", $sourceCode);
 $sourceCode = str_replace("?>", "", $sourceCode);
 $sourceCode = htmlspecialchars($sourceCode);
 $errhtml = getErrorHtml($errorFilename);
 if ($sourceCode == "") {
     if ($input == "//\$?[End_of_model]\$?") {
         $html = "\n        Please create an Umple model textually (on the left side of the screen)\n        or visually (on the right side of the screen),\n        and then choose Generate Code again.";
     } else {
         $html = "\n        An error occurred interpreting your Umple code, please review it and try again.\n        If the problem persists, please email the Umple code to\n        the umple-help google group: umple-help@googlegroups.com";
     }
     echo $errhtml . "<p>URL_SPLIT" . $html;
 } else {
     if ($javadoc) {
         $thedir = dirname($outputFilename);
示例#14
0
<?php

require_once 'lib.php';
require_once 'data.php';
error_reporting(E_ERROR | E_NOTICE | E_PARSE | E_WARNING);
ini_set('display_errors', 1);
$data = file_exists('ads.txt') ? readFromFile('ads.txt') : '';
if (!empty($_POST)) {
    $id = isset($_POST['id']) ? $_POST['id'] : '';
    if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($data[$id])) {
        $data[$id] = $_POST;
    } else {
        $data[] = $_POST;
    }
} elseif (isset($_GET['del'])) {
    unset($data[$_GET['del']]);
} elseif (isset($_GET['edit']) && !isset($_GET['action'])) {
    $id = $_GET['edit'];
    $formParam = prepareAd($data[$id]);
}
if (!isset($formParam)) {
    $formParam = prepareAd();
}
require_once 'form.php';
saveFile('ads.txt', $data);
示例#15
0
        if (is_uploaded_file($_FILES[$str]['tmp_name'])) {
            $return = saveFile($table[0], $str, "StudentDocuments/");
            if ($return == 1) {
                $table[$count] = $table[0] . ".zip";
            } else {
                $table[$count] = "";
            }
        } else {
            $table[$count] = "";
        }
    } else {
        if ($tableName == "Tschedule") {
            $str = $str . $count;
            $pKey = $table[0] . "-" . $table[1] . "-" . $table[2] . "-" . $table[3];
            if (is_uploaded_file($_FILES[$str]['tmp_name'])) {
                $return = saveFile($pKey, $str, "ScheduleDocuments/");
                if ($return == 1) {
                    $table[$count] = $pKey . ".zip";
                } else {
                    $table[$count] = "";
                }
            } else {
                $table[$count] = "";
            }
        }
    }
}
//echo "<script type='text/javascript'>alert(".$fileName.");</script>";
function saveFile($pKey, $str, $dir)
{
    $target_dir = $dir;
示例#16
0
function saveJSON($file, $data)
{
    $data = "<?php/*|" . json_encode($data) . "|*/?>";
    saveFile($file, $data);
}
示例#17
0
  *          top:
  *          left:
  *          right:
  *      }
  *  }
  */
 foreach ($json->tiles as $row) {
     foreach ($row as $tile) {
         $arr = explode('/', $tile->url);
         $arr = explode('\\.', $arr[count($arr) - 1]);
         $name = $arr[0];
         /*
          * If file exists, no need to upload it again !
          */
         if (!file_exists(MSP_UPLOAD_DIR . $name . ".tif")) {
             saveFile(getRemoteData($tile->url, null, false), MSP_UPLOAD_DIR . $name . ".jpeg");
             exec(MSP_GDAL_TRANSLATE_PATH . ' -of GTiff -a_srs ' . $tile->srs . ' -a_ullr ' . $tile->bounds->left . ' ' . $tile->bounds->top . ' ' . $tile->bounds->right . ' ' . $tile->bounds->bottom . ' ' . MSP_UPLOAD_DIR . $name . '.jpeg ' . MSP_UPLOAD_DIR . $name . '.tif');
         }
         $unique .= $name;
         $inputs .= " " . MSP_UPLOAD_DIR . $name . ".tif";
     }
 }
 /*
  * Generate the mosaic if it not already exists
  */
 $unique = md5($unique) . ".tif";
 if (!file_exists(MSP_UPLOAD_DIR . $unique)) {
     exec(MSP_GDAL_MERGE_PATH . ' -o ' . MSP_UPLOAD_DIR . $unique . $inputs);
 }
 $json = array('success' => true, 'url' => MSP_GETFILE_URL . $unique . "&stream=true");
 echo json_encode($json);
示例#18
0
function saveAllUsers($users, $fileUsersPath)
{
    saveFile($fileUsersPath, json_encode($users));
}
 $local_img_url = './images/' . $save_img_dir . '/' . basename($pic_main);
 //保存产品主图
 createDirIfNotExists($local_img_url);
 saveFile($remote_img_url, $local_img_url);
 $insert_product['products_image'] = '/images/' . $save_img_dir . '/' . basename($pic_main);
 //产品主图----end
 //产品详情图----begin
 $preg = '~<img src="([^"]+)" width="769" height="307" />~';
 preg_match($preg, $content, $arr);
 //print_r($arr);
 $pic_desp = $arr[1];
 $remote_img_url = $remote_host . '/' . $pic_desp;
 $local_img_url = './images/' . $save_img_dir . '/' . basename($pic_desp);
 //保存产品详情图
 createDirIfNotExists($local_img_url);
 saveFile($remote_img_url, $local_img_url);
 //产品详情图----end
 //产品详情1
 $preg = '~<td class="news3">&nbsp;Product Specifications</td>(?:\\s|.)+?<td height="165" valign="top" style="color:#333333;">((?:\\s|.)+?)</td>~';
 preg_match($preg, $content, $arr);
 $pro_desp = $arr[1];
 //print_r($arr);
 //产品详情2
 $preg = '~<td class="news3">&nbsp;User Guide</td>(?:\\s|.)+?<td height="165" valign="top" style="color:#333333;">((?:\\s|.)+?)</td>~';
 preg_match($preg, $content, $arr);
 $pro_desp2 = $arr[1];
 //print_r($arr);
 $insert_product_desp['products_description'] = $pro_desp . $pro_desp2 . '<img src="/images/' . $save_img_dir . '/' . basename($pic_desp);
 //添加记录
 addProductBackEver(array('products' => $insert_product, 'products_description' => $insert_product_desp, 'categories_id' => $products_cat));
 $msg = '添加产品成功。';
示例#20
0
 * Geonames rssToGeoRSS service
 */
$rssToGeoRSS = 'http://ws.geonames.net/rssToGeoRSS?username=jrom&feedUrl=';
/*
 * Process only valid requests
 */
if (abcCheck($_REQUEST)) {
    $fileName = MSP_UPLOAD_DIR . createPassword(8) . '.rss';
    /*
     * First get RSS stream
     */
    if (saveFile(getRemoteData($_REQUEST["url"], null, false), $fileName)) {
        /*
         * If input RSS is true GeoRSS, then it should contain
         * a xmlns:georss attribute with value = "http://www.georss.org/georss"
         *
         */
        $doc = new DOMDocument();
        $doc->load($fileName);
        if ($doc->documentElement->getAttribute("xmlns:georss") != "http://www.georss.org/georss") {
            unlink($fileName);
            saveFile(getRemoteData($rssToGeoRSS . rawurlencode($_REQUEST["url"]), null, false), $fileName);
        }
        header("Pragma: no-cache");
        header("Expires: 0");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Content-type: text/xml");
        echo file_get_contents($fileName);
    }
}
示例#21
0
             }
         } else {
             echo json_encode(array('id' => 'error_create_pro', "ID_USER" => $id_user, "SQL" => $conn->error));
         }
     } else {
         echo json_encode(array('id' => 'error_invalid_user'));
     }
 } else {
     if (strcmp('update-user-with-image', $_POST['method']) == 0) {
         // SEND
         list($idUser, $email, $ext, $name) = explode(";", $_POST['data']);
         $fileString = $_POST['data2'];
         $now = date("D M j G:i:s T Y");
         $filename = md5($email . $now);
         $filename = $filename . "." . $ext;
         $returnFileSave = saveFile($fileString, $filename);
         $sql = "UPDATE USER SET PICTURE_PROFILE = '{$filename}', NAME = '{$name}'  WHERE ID={$idUser}";
         if ($conn->query($sql) === TRUE) {
             echo json_encode(array('id' => 'update-user-sucess', 'filename' => $filename));
         } else {
             echo json_encode(array('id' => 'update-user-error', 'filename' => $filename));
             //erro de cadastro
         }
     } else {
         if (strcmp('update-user-without-image', $_POST['method']) == 0) {
             // SEND
             list($idUser, $name) = explode(";", $_POST['data']);
             $sql = "UPDATE USER SET NAME = '{$name}'  WHERE ID={$idUser}";
             if ($conn->query($sql) === TRUE) {
                 echo json_encode(array('id' => 'update-user-without-image-sucess', 'filename' => ""));
             } else {
示例#22
0
// 参数为要打印标签的包裹处理号列表
$packageSns = array('CET141010TST000087', 'CET141010TST000088', 'CET141010TST000087', 'CET141010TST000088');
$dispatcher = array('category' => 'direct-express', 'handler' => 'package', 'action' => 'print-label');
$request_data = array('token' => getToken(), 'user_key' => getUserKey(), 'format' => 'classic_a4');
$api_address = $api_base . join("/", $dispatcher);
$api_address .= "?" . http_build_query($request_data);
$api_address .= get_repeat_string_params_string($packageSns, 'package_sn');
echo $api_address;
try {
    $response = rest_helper($api_address, null, 'GET', 'binary');
    $r = json_decode($response);
    if ($r === null) {
        //throw new Exception("failed to decode $res as json");
        //if not json return, save file
        $file = "label/label-mutiply-packageSns.pdf";
        saveFile($file, $response);
        echo "<br />";
        echo "save ok " . $file;
    } else {
        echo "<pre>";
        print_r($r);
        echo "</pre>";
    }
} catch (exception $e) {
    echo $e;
}
function saveFile($filename, $response)
{
    $fd = fopen($filename, 'wb');
    fwrite($fd, $response);
    fclose($fd);
//define('IC_APIPASSWORD', ''); //Your password
/* txt file setting */
define('FL_MAIL', 'emails.txt');
/* File error log */
define('ERROR_LOG', 'error-log.txt');
/* Install headers */
header('Expires: 0');
header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
header('Content-Type: application/json; charset=utf-8');
/* AJAX check */
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    extract($_POST);
    try {
        if (isset($subscribe) && validateMail($subscribe)) {
            saveFile($subscribe);
            sendMailChimp($subscribe);
            sendGetResponse($subscribe);
            sendAWeber($subscribe);
            sendCompaingMonitor($subscribe);
            sendiContact($subscribe);
        } else {
            throw new Exception("Email not valid", 1);
        }
    } catch (Exception $e) {
        $code = $e->getCode();
    }
    echo $code ? $code : 0;
} else {
    echo 'Only Ajax request';
}
示例#24
0
文件: ifm.php 项目: httvncoder/ifm
         echo json_encode(array("realpath" => ""));
     }
 } elseif ($_POST["api"] == "getFiles") {
     if (isset($_POST["dir"]) && isPathValid($_POST["dir"])) {
         getFiles($_POST["dir"]);
     } else {
         getFiles("");
     }
 } else {
     if (isset($_POST["dir"]) && isPathValid($_POST["dir"])) {
         switch ($_POST["api"]) {
             case "createDir":
                 createDir($_POST["dir"], $_POST["dirname"]);
                 break;
             case "saveFile":
                 saveFile($_POST);
                 break;
             case "getContent":
                 getContent($_POST);
                 break;
             case "deleteFile":
                 deleteFile($_POST);
                 break;
             case "renameFile":
                 renameFile($_POST);
                 break;
             case "downloadFile":
                 downloadFile($_POST);
                 break;
             case "extractFile":
                 extractFile($_POST);
/**
 * XML post recieve page
 * @package TestUtils
 * @author Elfar Torarinsson <*****@*****.**>
 */
$config = (require 'config.php');
//Connect to the database
require_once "db.class.php";
$db = new db_mysql($config);
$msg = "";
$msgcode = "";
//Receive the posted XML data
if (isset($_FILES["xml"])) {
    $tmp_file = $_FILES['xml']['tmp_name'];
    if (saveFile($tmp_file)) {
        //Save xml file
        $msgcode = "XML_RECEIVED_OK";
        $msg = "Save OK\n";
    } else {
        $msgcode = "XML_RECEIVED_FAIL";
        $msg = "Save file failed\n";
    }
} else {
    $msgcode = "XML_RECEIVED_FAIL";
    $msg = "No xml file\n";
}
$logattrs = array();
$logattrs["msgcode"] = $msgcode;
writeLog($logattrs, $msg);
echo $msgcode;
示例#26
0
        //read a file and send
        readfile($tempZipFile);
    }
    exit;
}
if (isset($_POST['action'])) {
    if (!isUserLogged()) {
        exit;
    }
    $_POST['action'] = sanitizeString($_POST['action']);
    switch ($_POST['action']) {
        case "getFile":
            getFile();
            break;
        case "saveFile":
            saveFile();
            break;
        case "createNewFile":
            createNewFile();
            break;
        case "createDir":
            createDir();
            break;
        case "renameFile":
            renameFile();
            break;
        case "removeFile":
            removeFile();
            break;
        case "duplicateFile":
            duplicateFile();
示例#27
0
function createDemoContent()
{
    if (!file_exists("style1.css")) {
        $style1 = "body {margin:0;padding:0;}div.outer_div {-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:#EEEEEE none repeat scroll 0 0;border:1px solid #CCCCCC;margin:4px;padding:2px;}div.inner_div {-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:#F2F2F2 none repeat scroll 0 0;border:1px solid #CCCCCC;margin:2px;padding:4px;}";
        saveFile("style1.css", $style1, true);
    }
    if (!file_exists("style2.css")) {
        $style2 = "div.header_div {border-bottom:1px dotted #CCCCCC;color:#444444;font-size:12px;font-weight:bold;padding:2px 4px 0;}div.content_div {-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:#F6F6F6 none repeat scroll 0 0;font-size:11px;padding:4px;text-align:center;}div.footer_div {border-top:1px dotted #CCCCCC;color:#CCCCCC;font-size:12px;padding:4px 4px 0;text-align:right;}";
        saveFile("style2.css", $style2, true);
    }
}
示例#28
0
/**
 * 远程抓取图片,保存到本地服务器
 * @param  $content  需要转换的内容
 * @return 返回图片替换后的数据
 */
function getContent($Content)
{
    $Content = stripslashes($Content);
    //  echo $Content;
    //获取图片路径
    //  preg_match_all( " <img[^>]*src=[\"|']?(^>+)[\"|']?[^>]*>", $Content, $temp );
    //  preg_match_all( "/src=(\"|')(.*?)(\"|')/i", DeCodeStr($Content), $temp );
    preg_match_all("/src=(\"|')(.*?)(\"|')/i", $Content, $temp);
    $imageList = $temp[2];
    //  echo '<hr>'. print_r($imageList) . '<hr>';
    //*/
    $ImagePath = date("ym", time()) . '/' . date("d", time());
    createFolder(IMAGEPATH, $ImagePath);
    //网页上面的路径
    $ImageUrl = IMAGEURL . $ImagePath;
    for ($i = 0; $i < count($imageList); $i++) {
        $fName = saveFile($imageList[$i], $ImagePath, $ImageUrl);
        if (!empty($fName)) {
            $filename[$i] = $fName;
        }
    }
    for ($i = 0; $i < count($imageList); $i++) {
        $Content = str_replace($imageList[$i], $ImageUrl . $filename[$i], $Content);
    }
    /*
       echo '<hr>';
       echo $Content;
       echo '<hr>';
       exit();
       //*/
    /*
    //去掉无用的页面脚本
    //去掉js
    $cp = preg_replace( "@\<script(.*?)\</script\>@is", "", $cp );
    
    //去掉HTML
    //去Table
    $cp = preg_replace( "@\<table(.*?)\</table\>@is", "", $cp );
    //去Tr
    $cp = preg_replace( "@\<tr(.*?)\</tr\>@is", "", $cp );
    //去Td
    $cp = preg_replace( "@\<td(.*?)\</td\>@is", "", $cp );
    //去div
    $cp = preg_replace( "@\<div(.*?)\</div\>@is", "", $cp );
    
    //去iframe
    $cp = preg_replace( "@\<iframe(.*?)\</iframe\>@is", "", $cp );
    
    //去掉css
    //$cp = preg_replace( "@\<style(.*?)\</style\>@is", "", $cp );
    */
    //去掉超连接
    $Content = preg_replace(EnCodeStr("@\\<a(.*?)\\>@is"), "", $Content);
    //去<!-- -->
    $Content = preg_replace(EnCodeStr("@\\<!--(.*?)\\--\\>@is"), "", $Content);
    return $Content;
}
示例#29
0
function handleUmpleTextChange()
{
    $action = $_REQUEST["action"];
    $input = $_REQUEST["umpleCode"];
    //Windows versus Linux PHP issues
    $actionCode = $GLOBALS["OS"] == "Windows" ? json_encode($_REQUEST["actionCode"]) : "\"" . $_REQUEST["actionCode"] . "\"";
    $actionCode = str_replace("<", "\\<", $actionCode);
    $actionCode = str_replace(">", "\\>", $actionCode);
    if (!is_null($actionCode)) {
        //Escape all the double quotes
        $actionCode = str_replace("\"", "\\\"", $actionCode);
        //Trim for any un-standard characters
        $actionCode = trim($actionCode);
        //Trim for escaped doubles quotes in the beginning and end of the actionCode string
        $actionCode = trim($actionCode, "\\\"");
    }
    $filename = saveFile($input);
    $umpleOutput = executeCommand("java -jar umplesync.jar -{$action} \"{$actionCode}\" {$filename}");
    saveFile($umpleOutput, $filename);
    echo $umpleOutput;
    return;
}
示例#30
0
/**
 * This script returns GeoJSON
 */
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/json; charset=utf-8");
/**
 * TODO : allow only ws.geonames.net to idenfied user ?
 * $url = 'http://ws.geonames.org/wikipediaSearch?';
 */
$url = 'http://ws.geonames.net/wikipediaSearch?username=jrom&';
/*
 * Search terms
 */
$q = isset($_REQUEST["q"]) ? $_REQUEST["q"] : "";
/*
 * Lang
 */
$lang = isset($_REQUEST["lang"]) ? $_REQUEST["lang"] : "en";
/*
 * Number of results
 */
$maxRows = isset($_REQUEST["maxRows"]) ? $_REQUEST["maxRows"] : MSP_RESULTS_PER_PAGE;
/**
 * NB: tags are comma separated
 */
$url = $url . "q=" . $q . "&maxRows=" . $maxRows . "&lang=" . $lang;
echo toGeoJSON(saveFile(getRemoteData($url, null, false), MSP_UPLOAD_DIR . "wikipedia_" . createPassword(10) . ".xml"));