本文整理汇总了PHP中saveFile函数的典型用法代码示例。如果您正苦于以下问题:PHP saveFile函数的具体用法?PHP saveFile怎么用?PHP saveFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了saveFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAvatar
/**
* 保存用户头像
* @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);
}
示例2: openFile
function openFile($url, $size)
{
if (file_exists($url)) {
$file = $url;
$dataToReturn = file_get_contents($file);
} else {
saveFile($url, "");
$dataToReturn = "";
}
return $dataToReturn;
}
示例3: index
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: index
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: read
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: saveSqlLog
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: saveDoc
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: postRemoteData
</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: saveFile
$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: makeWeather
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: runWikiTest
/**
** 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;
}
示例12: CSVFile
<?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: exec
}
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: error_reporting
<?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: saveFile
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;