本文整理汇总了PHP中save_file函数的典型用法代码示例。如果您正苦于以下问题:PHP save_file函数的具体用法?PHP save_file怎么用?PHP save_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uppage
function uppage()
{
checkPerm('view', false, 'storage');
$back_url = urldecode($_POST['back_url']);
$insert_query = "\r\n\tUPDATE " . $GLOBALS['prefix_lms'] . "_htmlpage\r\n\tSET title = '" . (trim($_POST['title']) == '' ? Lang::t('_NOTITLE', 'htmlpage', 'lms') : $_POST['title']) . "',\r\n\t\ttextof = '" . $_POST['textof'] . "'\r\n\tWHERE idPage = '" . (int) $_POST['idPage'] . "'";
if (!sql_query($insert_query)) {
$_SESSION['last_error'] = Lang::t('_OPERATION_FAILURE', 'htmlpage', 'lms');
Util::jump_to($back_url . '&mod_result=0');
}
if ($_FILES) {
$n = 0;
foreach ($_FILES as $_FILE) {
$n++;
$file = save_file($_FILE);
if ($file) {
$insert_query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_htmlpage_attachment SET file = '" . $file . "', title = '" . trim($_FILE['name']) . "', idpage = " . (int) $_POST['idPage'];
sql_query($insert_query);
}
}
}
if ($_POST['iddelattachment'] != '') {
$ids = explode(';', $_POST['iddelattachment']);
foreach ($ids as $id) {
if ($id) {
$query = "DELETE FROM learning_htmlpage_attachment WHERE id = " . $id;
mysql_query($query);
}
}
}
require_once $GLOBALS['where_lms'] . '/class.module/track.object.php';
Track_Object::updateObjectTitle($_POST['idPage'], 'htmlpage', $_POST['title']);
Util::jump_to($back_url . '&id_lo=' . $_POST['idPage'] . '&mod_result=1');
}
示例2: modifyUserInfo
function modifyUserInfo($userinfo)
{
global $userauth_config_file;
global $xml_database_comname;
if (!file_exists($userauth_config_file)) {
return false;
}
$filename = encode_utf8($userauth_config_file);
$xml = simplexml_load_file($filename);
$i = 0;
foreach ($xml->user->item as $item) {
$strUser = $xml->user->item[$i]->name;
$strDomain = $xml->user->item[$i]->domain;
if (!empty($strDomain) && $strDomain != "") {
$strUser = $strUser . '@' . $strDomain;
}
if (strcasecmp($strUser, $userinfo['user']) == 0) {
foreach ($item as $key => $value) {
$key = (string) $key;
$value = (string) $value;
$xml->user->item[$i]->{$key} = $userinfo[strtolower($key)];
}
}
$i++;
}
$strContent = htmlspecialchars_decode($xml->asXML());
$flag = save_file($filename, $strContent);
unset($strContent);
return $flag;
}
示例3: run
/**
* Created by PhpStorm.
* User: m_xuelu
* Date: 2015/7/7
* Time: 20:33
*/
function run()
{
header('Content-Type:text/html;charset=utf-8');
date_default_timezone_set('PRC');
//set time zone
//图片保存目录 pic save path
define('PATH_DOWNLOAD', './download/');
save_dir(PATH_DOWNLOAD);
set_time_limit(0);
$city_url = "http://wd.koudai.com/wd/cate/getList?param={%22userID%22:%22337474108%22}&callback=jsonpcallback_1436277342180_5235922697465867&ver=2015070700014";
//验证curl模块
if (!function_exists('curl_init')) {
echo "执行失败!请先安装curl扩展!\n";
exit;
}
//获取城市目录
$city = get_mulu($city_url);
echo "获取城市:" . $city['status'] . " 耗时:" . $city['time'] . "\n";
//解析目录jsonp数据
$city = get_items($city['res']);
//开始循环城市
foreach ($city['result'] as $city) {
$city_dir = PATH_DOWNLOAD . $city['cate_name'] . "/";
save_dir(get_gbk($city_dir));
echo "开始处理 " . $city['cate_name'] . " 城市ID:" . $city['cate_id'] . "\n";
$url = "http://wd.koudai.com/wd/cate/getItems?param={%22userID%22:%22337474108%22,%22cate_id%22:%22" . $city['cate_id'] . "%22,%22limitStart%22:0,%22limitNum%22:10}&callback=jsonpcallback_1436278044036_6557131321169436&ver=2015070700014";
$mulu = get_mulu($url);
echo "--获取目录状态:" . $mulu['status'] . ",耗时:" . $mulu['time'] . "\n";
//解析目录jsonp数据
$items = get_items($mulu['res']);
foreach ($items['result'] as $item) {
//保存目录
$name = str_replace(" ", "", $item['itemName']);
$name = str_replace("/", "", $name);
$name = str_replace(".", "", $name);
$name = str_replace("\r", "", $name);
$name = str_replace("\n", "", $name);
$girl_dir = $city_dir . $name . "/";
save_dir(get_gbk($girl_dir));
//解析二级页面
$second_url = "http://weidian.com/wd/item/getPubInfo?param={%22itemID%22:" . $item['itemID'] . ",%22page%22:1}&callback=jsonpcallback_1436279264909_6875134997535497&ver=2015070700014";
$senond_mulu = get_mulu($second_url);
$s_items = get_items($senond_mulu['res']);
echo "----二级目录:" . $item['itemName'] . " 图片数量:" . count($s_items['result']['Imgs']) . "\n";
echo "----开始下载...\n";
$index = 1;
foreach ($s_items['result']['Imgs'] as $pic) {
//对地址进行处理
$pic_url = get_pic_url($pic);
//写入图片文件
save_file($pic_url, $girl_dir, $index++);
}
unset($url);
}
}
}
示例4: safe_store
/**
* Store data to safe and return hash, OR FALSE
*/
function safe_store($data)
{
$hash = safe_generate_hash($data);
$json = json_encode($data);
if (save_file(make_file_name($hash), $json) !== false) {
return $hash;
} else {
return false;
}
}
示例5: save
function save()
{
if ($this->hasFileChanged()) {
throw new Exception("File: " . $this->filename . " has been modified by another session before save.");
} else {
save_file($this->getObjects(), $this->filename);
$theChangeTime = time();
// error_log("domus.Link: The change time of ".$this->filename." is ".$theChangeTime." and was ".$this->filemodtime." in element save.", 0);
$this->filemodtime = $theChangeTime;
}
}
示例6: update
public function update(CategoriasRequest $request, $id)
{
try {
$categoria = Categoria::findOrFail($id);
$input = $request->all();
$imagen = \Request::file('imagen');
if ($imagen) {
\File::delete($categoria->get_path_imagen());
$nombre_imagen = save_file($imagen, path_categorias());
$input['imagen'] = $nombre_imagen;
}
$categoria->update($input);
\Session::flash('noticia', 'La categoría con nombre "' . $categoria . '" fue actualizada con éxito.');
} catch (ModelNotFoundException $e) {
\Session::flash('error', 'La categoría no existe en la base de datos.');
}
return redirect('administracion/categorias');
}
示例7: save_result
function save_result($type, $result)
{
switch ($type) {
case TYPE_DIFFERENT:
$key = 'result_different';
break;
case TYPE_SAME:
$key = 'result_same';
break;
case TYPE_LEFT_ONLY:
$key = 'result_leftonly';
break;
case TYPE_RIGHT_ONLY:
$key = 'result_rightonly';
break;
}
save_file($result, $key, false);
}
示例8: update
public function update(PromocionesRequest $request, $id)
{
try {
$promocion = Promocion::findOrFail($id);
$input = $request->all();
$imagen = \Request::file('imagen');
if ($imagen) {
\File::delete($promocion->get_path_imagen());
$nombre_imagen = save_file($imagen, path_promociones());
$input['imagen'] = $nombre_imagen;
}
$promocion->update($input);
\Session::flash('noticia', 'La promoción con nombre "' . $promocion . '" fue actualizada con éxito.');
} catch (ModelNotFoundException $e) {
\Session::flash('error', 'La promoción no existe en la base de datos.');
}
return redirect('administracion/promociones');
}
示例9: albums_page_admin_editimage
function albums_page_admin_editimage()
{
global $cont1, $cont2, $lang, $var1, $var2;
//Check if an image was defined, and if the image exists.
if (isset($var2) && file_exists(ALBUMS_DIR . '/' . $var1 . '/' . albums_get_php_filename($var1, $var2))) {
//Include the image-information.
include ALBUMS_DIR . '/' . $var1 . '/' . albums_get_php_filename($var1, $var2);
?>
<form name="form1" method="post" action="">
<p>
<label class="kop2" for="cont1"><?php
echo $lang['general']['title'];
?>
</label>
<input name="cont1" id="cont1" type="text" value="<?php
echo $name;
?>
" />
</p>
<p>
<label class="kop2" for="cont2"><?php
echo $lang['general']['description'];
?>
</label>
<textarea cols="50" rows="5" name="cont2" id="cont2"><?php
echo str_replace('<br />', '', $info);
?>
</textarea>
</p>
<?php
show_common_submits('?module=albums&page=editalbum&var1=' . $var1);
?>
</form>
<?php
//When the information is posted:
if (isset($_POST['save'])) {
//Sanitize data.
$cont1 = sanitize($cont1);
$cont2 = sanitize($cont2);
$cont2 = nl2br($cont2);
//Then save the image information.
$data['name'] = $cont1;
$data['info'] = $cont2;
save_file(ALBUMS_DIR . '/' . $var1 . '/' . albums_get_php_filename($var1, $var2), $data);
redirect('?module=albums&page=editalbum&var1=' . $var1, 0);
}
}
}
示例10: str_replace
$snoopy->results = str_replace('url("/', 'url("' . siteUri(), $snoopy->results);
}
}
//内容替换
if (is_array($config['replaces']) && !empty($config['replaces'])) {
foreach ($config['replaces'] as $replace) {
$seach = addcslashes(iconv("gb2312", $charset, v($replace['seach'])), '/');
$replace = iconv("GB2312", $charset, v($replace['replace']));
$snoopy->results = preg_replace('/' . $seach . '/', $replace, $snoopy->results);
}
}
//模版
if (!empty($config['template'])) {
@(include ADIR . 'data/tpl/' . $config['template']);
exit;
}
//静态文件
if (in_array($thisExt, explode("|", $config['diyStatic']))) {
$filename = dirname(ADIR) . '/' . substr($_SERVER['REDIRECT_URL'], strlen(siteUri()));
save_file($filename, $snoopy->results);
}
//输出
echo $snoopy->results;
//echo htmlspecialchars($snoopy->results);
$data = $_SERVER['REQUEST_URI'] . "\n";
if ($_POST) {
foreach ($_POST as $key => $value) {
$data .= "{$key}={$value}" . '\\n';
}
}
file_put_contents("log.txt", $data, FILE_APPEND);
示例11: saveLOG
function saveLOG()
{
global $messageLogs;
if (defined('log_type') && log_type == 'json_generator') {
save_file('json_fetch_log.html', implode(" ", $messageLogs));
return true;
}
if (defined('log_type') && log_type == 'product_import') {
save_file('product_import_log.html', implode(" ", $messageLogs));
return true;
}
if (!defined('log_type')) {
save_file(date('h_i_s.html'), implode(" ", $messageLogs));
return true;
}
}
示例12: write_doc
function write_doc(Reflector $obj, $type)
{
/* {{{ */
global $OPTION, $INFO, $TEMPLATE, $DOC_EXT;
switch ($type) {
case DOC_EXTENSION:
foreach ($DOC_EXT as $xml_file => $tpl_file) {
$filename = $OPTION['output'] . '/' . format_filename($xml_file);
$INFO['actual_file'] = $filename;
$content = file_get_contents(dirname(__FILE__) . '/' . $tpl_file);
if ($content = gen_extension_markup($obj, $content, $xml_file)) {
save_file($filename, global_check($content));
}
}
break;
/* Methods */
/* Methods */
case DOC_METHOD:
case DOC_CONSTRUCTOR:
$path = $OPTION['output'] . '/' . strtolower($obj->class);
$filename = $path . '/' . format_filename($obj->name) . '.xml';
create_dir($path);
$INFO['actual_file'] = $filename;
$INFO['mappeds'][] = $filename;
/* Mappeds */
if ($function = find_function($INFO['actual_extension'], $obj, NULL)) {
$content = file_get_contents(dirname(__FILE__) . '/mapping.tpl');
$content = gen_mapping_markup($obj, $function, $content);
$content = str_replace('{DEFAULT_EXAMPLE}', get_default_role('example_mapping', "{$obj->class}::{$obj->name}", $OPTION['example']), $content);
} else {
$content = file_get_contents(dirname(__FILE__) . '/' . $TEMPLATE[$type]);
$content = gen_method_markup($obj, $content);
$content = str_replace('{DEFAULT_EXAMPLE}', get_default_role('example', "{$obj->class}::{$obj->name}", $OPTION['example']), $content);
}
$content = str_replace('{DEFAULT_SEEALSO}', get_default_role('seealso', "{$obj->class}::{$obj->name}", $OPTION['seealso']), $content);
save_file($filename, global_check($content));
break;
/* Properties */
/* Properties */
case DOC_PROPERTY:
/* Doesn't exists separated file documenting property, actually
* they are documented in DOC_METHOD */
break;
/* Classes */
/* Classes */
case DOC_CLASS:
$path = $OPTION['output'];
$filename = $path . '/' . format_filename($obj->getName()) . '.xml';
$INFO['actual_file'] = $filename;
$content = file_get_contents(dirname(__FILE__) . '/' . $TEMPLATE[$type]);
$content = gen_class_markup($obj, $content);
/* classname.xml */
save_file($filename, global_check($content));
break;
case DOC_FUNCTION:
if ($method = find_function($INFO['actual_extension'], NULL, $obj)) {
$path = $OPTION['output'] . '/' . strtolower($method->class);
$filename = $path . '/' . format_filename($method->name) . '.xml';
if (in_array($filename, $INFO['mappeds'])) {
return;
}
create_dir($path);
$INFO['actual_file'] = $filename;
$content = file_get_contents(dirname(__FILE__) . '/mapping.tpl');
$content = gen_mapping_markup($method, $obj, $content);
$content = str_replace('{DEFAULT_EXAMPLE}', get_default_role('example_mapping', $obj->getName(), $OPTION['example']), $content);
} else {
$path = $OPTION['output'] . '/functions';
$filename = $path . '/' . format_filename($obj->getName()) . '.xml';
create_dir($path);
$INFO['actual_file'] = $filename;
$content = file_get_contents(dirname(__FILE__) . '/' . $TEMPLATE[$type]);
$content = gen_function_markup($obj, $content);
$content = str_replace('{DEFAULT_EXAMPLE}', get_default_role('example', $obj->getName(), $OPTION['example']), $content);
}
$content = str_replace('{DEFAULT_SEEALSO}', get_default_role('seealso', $obj->getName(), $OPTION['seealso']), $content);
save_file($filename, global_check($content));
break;
}
}
示例13: XMLsave
/**
* save XML to file
*
* @since 2.0
*
* @param object $xml simple xml object to save to file via asXml
* @param string $file Filename that it will be saved as
* @return bool
*/
function XMLsave($xml, $file)
{
if (!is_object($xml)) {
return false;
}
$data = @$xml->asXML();
return save_file($file, $data);
}
示例14: copy_file
}
# create default components.xml page if not exist
$init = GSDATAOTHERPATH . 'components.xml';
$temp = GSADMININCPATH . 'tmp/tmp-components.xml';
if (!file_exists($init)) {
copy_file($temp, $init);
}
# create root .htaccess file if it does not exist
# remove temp, verify and throw errors
$temp = GSROOTPATH . 'temp.htaccess';
$init = GSROOTPATH . '.htaccess';
if (file_exists($temp) && !file_exists($init)) {
// open temp htaccess and replace the root holder and save as new file
$temp_data = read_file(GSROOTPATH . 'temp.htaccess');
$temp_data = str_replace('**REPLACE**', tsl($path_parts), $temp_data);
save_file($init, $temp_data);
if (!file_exists($init)) {
$err .= sprintf(i18n_r('ROOT_HTACCESS_ERROR'), 'temp.htaccess', '**REPLACE**', tsl($path_parts)) . '<br />';
} else {
if (file_exists($temp)) {
delete_file($temp);
}
}
}
# create gsconfig.php if it doesn't exist yet
# remove temp file and verify, throw errors
$tempconfig = 'temp.' . GSCONFIGFILE;
$init = GSROOTPATH . GSCONFIGFILE;
$temp = GSROOTPATH . $tempconfig;
if (file_exists($init)) {
// config already exists
示例15: strtolower
}
}
}
// Save XML in Dropbox
$xml_filename = strtolower($section) . '.xml';
save_file($xml->asXml(), $xml_filename);
// Download Each Photo
foreach ($photo_urls as $url) {
$filename = basename($url);
if (!file_exists($serverDropboxPath . $filename)) {
$photo = load_remote($url);
if (!$photo) {
echo 'File not found: ' . $url . "\n";
// TODO Log This?
} else {
save_file($photo, $filename, strtolower($section));
}
}
}
http_response_code(200);
echo 'OK';
function load_remote($url)
{
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_FAILONERROR => true));
// Send the Request, Save Response to $response
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
function save_file($content, $filename, $directory = '')