本文整理汇总了PHP中write_file函数的典型用法代码示例。如果您正苦于以下问题:PHP write_file函数的具体用法?PHP write_file怎么用?PHP write_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: pdf_create
function pdf_create($html, $filename = '', $stream = TRUE, $invoice_id, $type)
{
require_once "dompdf/dompdf_config.inc.php";
if (get_magic_quotes_gpc()) {
$html = stripslashes($html);
}
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper("a4", "portrait");
$dompdf->render();
$timestamp = date('YmdGis') . $invoice_id;
$filename = $timestamp . '.pdf';
if ($stream) {
$dompdf->stream($filename);
} else {
if ($type == 'invoice') {
$CI =& get_instance();
$CI->load->helper('file');
write_file("invoice/" . $filename, $dompdf->output());
return $filename;
} else {
if ($type == 'salary') {
$CI =& get_instance();
$CI->load->helper('file');
write_file("salary_slip/" . $filename, $dompdf->output());
return $filename;
}
}
}
}
开发者ID:haseeb736,项目名称:test,代码行数:30,代码来源:dompdf_helper.php
示例2: index
public function index()
{
$cnt_backups = 14;
$path = "../backups";
$date = mktime(date("H") - CORRECTION_DATE, date("i"), date("s"), date("m"), date("d"), date("Y"));
$dump_name2 = date("__Y-m-d__H-i-s__", $date) . "dump.sql";
//имя файла
$dump_name = "{$path}/{$dump_name2}.zip";
//имя архива
$prefs = array('tables' => array(), 'ignore' => array(), 'format' => 'zip', 'filename' => $dump_name2, 'add_drop' => TRUE, 'add_insert' => TRUE, 'newline' => "\n");
// Загружаем класс DB utility
$this->load->dbutil();
// Создаем бэкап текущей бд и ассоциируем его с переменной
$backup =& $this->dbutil->backup($prefs);
// Загружаем хелпер file и записываем бэкап в файл
$this->load->helper('file');
write_file($dump_name, $backup);
echo "Backup \"{$dump_name}\" created<br>";
// Загружаем хелпер download и отправляем бэкап пользователю
//$this->load->helper('download');
//force_download("$dump_name", $backup);
//удаляем старые бэкапы
$count = count(scandir($path)) - 2;
//количество бэкапов
while ($count > $cnt_backups) {
$arr = scandir($path);
$name = "{$path}/{$arr['2']}";
echo "Backup \"{$name}\" removed<br>";
$b = unlink($path . "/" . $arr[2]);
$count = count(scandir($path)) - 2;
}
}
开发者ID:TomNovok,项目名称:ListToDo,代码行数:32,代码来源:backup.php
示例3: insertsql
public function insertsql()
{
if (empty($_POST['ids'])) {
$this->error('请选择需要备份的数据库表!');
}
$filesize = intval($_POST['filesize']);
if ($filesize < 1) {
$this->error('出错了,请为分卷大小设置一个整数值!');
}
$file = RUNTIME_PATH . 'DataBack/';
$random = mt_rand(1000, 9999);
$sql = '';
$p = 1;
foreach ($_POST['ids'] as $table) {
$rs = D('Admin.' . str_replace(C('db_prefix'), '', $table));
$array = $rs->select();
$sql .= "TRUNCATE TABLE `{$table}`;\n";
foreach ($array as $value) {
$sql .= $this->getinsertsql($table, $value);
if (strlen($sql) >= $filesize * 1000) {
$filename = $file . date('Ymd') . '_' . $random . '_' . $p . '.sql';
write_file($filename, $sql);
$p++;
$sql = '';
}
}
}
if (!empty($sql)) {
$filename = $file . date('Ymd') . '_' . $random . '_' . $p . '.sql';
write_file($filename, $sql);
}
$this->assign("jumpUrl", C('cms_admin') . '?s=Admin/Data/Showback');
$this->success('数据库分卷备份已完成,共分成' . $p . '个sql文件存放!');
}
开发者ID:skygunner,项目名称:ekucms,代码行数:34,代码来源:DataAction.class.php
示例4: modify_theme
function modify_theme()
{
$subfolder = rtrim(dirname(dirname($_SERVER['PHP_SELF'])), '/\\') . '/';
$this->load->helper('file');
$theme = $this->input->post('theme');
$output = array('success' => true, 'messgae' => '', 'data' => '');
$gocartconfig = $_SERVER['DOCUMENT_ROOT'] . $subfolder . 'gocart/config/gocart.php';
$gocartconfigbak = $_SERVER['DOCUMENT_ROOT'] . $subfolder . 'gocart/config/gocart.bak.php';
if (file_exists($gocartconfigbak)) {
unlink($gocartconfigbak);
}
if (file_exists($gocartconfig)) {
copy($gocartconfig, $gocartconfigbak);
$content = file_get_contents($gocartconfig);
$content = preg_replace('/\\$config\\[[\'|\\"]theme[\'|\\"]\\].*;/', '$config["theme"] = "' . $theme . '";', $content);
try {
unlink($gocartconfig);
write_file($gocartconfig, $content);
$output['data'] = $theme;
echo json_encode($output);
} catch (Exception $e) {
$output['sucess'] = false;
$output['messgae'] = $e->getMessage();
echo json_encode($output);
}
}
}
开发者ID:Joncg,项目名称:eelly_cps_fx,代码行数:27,代码来源:theme.php
示例5: index
public function index()
{
$sql = "SELECT\n\t\tdistinct role_name, role_code,role_url\n\t\tFROM user_role_master rm";
$data = $this->usermenumodel->common_index($sql);
$menus = $this->rolemastermodel->menu_category();
foreach ($menus as $key => $value) {
$menus[$key]['submenu'] = $this->rolemastermodel->menu_sub_category($value['menu_id']);
}
$data['menus'] = $menus;
$file_data = json_encode($this->role_list());
write_file('./IncludeViews/data.json', $file_data);
foreach ($menus as $keys => $values) {
//echo '<pre>'.print_r($values['submenu'],true);
foreach ($values['submenu'] as $key => $value) {
$menu_id = $value['menu_id'];
$url[$menu_id]['text'] = $value['menu_text'];
$url[$menu_id]['url'] = $value['menu_navigate_url'];
}
}
$data['columns_header'] = array('Role code', 'Role name', 'Role url');
$data['url'] = $url;
//echo '<pre>'.print_r($data,true);
$this->load->view('admin/rolemaster', $data);
$this->load->view('footer-links-role', $data);
}
开发者ID:aakash5792,项目名称:sample,代码行数:25,代码来源:rolemaster.php
示例6: pad_write
function pad_write($p, $o, $res)
{
$pad = 'pad' . ses('USE') . date('ymd');
$f = 'plug/_data/' . $pad . '.txt';
write_file($f, ajxg($res));
return lkt('popbt', root() . $f, $pad);
}
开发者ID:philum,项目名称:cms,代码行数:7,代码来源:pad.php
示例7: index
public function index()
{
$args = array_slice($this->uri->rsegment_array(), 2);
foreach ($this->items as $item) {
$name = isset($item['name']) ? (string) $item['name'] : null;
if (!empty($args)) {
if (!in_array($name, $args)) {
continue;
}
}
$source = isset($item['source']) ? (string) $item['source'] : '';
$destination = isset($item['destination']) ? (string) $item['destination'] : '';
$compress = !empty($item['compress']);
if ($source == '' || $destination == '') {
continue;
}
$dir = pathinfo($destination, PATHINFO_DIRNAME);
file_exists($dir) or mkdir($dir, 0755, TRUE);
try {
write_file($destination, $this->less->parse($source, null, true, array('full_path' => true, 'compress' => $compress)));
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
}
}
开发者ID:Balamir,项目名称:starter-public-edition-3,代码行数:25,代码来源:Compile_controller.php
示例8: save_data
public function save_data($data)
{
if (isset($data['area']) && !empty($data['area'])) {
$this->widget_area = $data['area'];
}
return write_file($this->widget_data_location, json_encode($data, JSON_PRETTY_PRINT));
}
开发者ID:srifqi,项目名称:pusakacms,代码行数:7,代码来源:Widget.php
示例9: Retrieve
private function Retrieve($link)
{
global $options;
$page = $this->GetPage($link);
is_present($page, "Link was removed due to violation of our TOS", "Link is not invalid");
$Cookies = GetCookies($page);
$random_num = cut_str($page, 'id="random_num" value="', '"');
$passport_num = cut_str($page, 'id="passport_num" value="', '"');
preg_match('#http://[a-z]{7}\\d+.megashares.com/[^"]+#', $page, $dlink);
$img = "http://d01.megashares.com/index.php?secgfx=gfx&random_num={$random_num}";
$page = $this->GetPage($img, $Cookies, 0, $link);
$headerend = strpos($page, "\r\n\r\n");
$pass_img = substr($page, $headerend + 4);
if (preg_match("#\\w{4}\r\n#", $pass_img)) {
$t = strpos($pass_img, "P");
$pass_img = ltrim(substr($pass_img, $t - 2), "\r\n");
}
write_file($options['download_dir'] . "megashares_captcha.png", $pass_img);
$data = array();
$data['step'] = "1";
$data['Cookies'] = $Cookies;
$data['link'] = $link;
$data['random_num'] = $random_num;
$data['passport_num'] = $passport_num;
$data['dlink'] = $dlink[0];
$this->EnterCaptcha($options['download_dir'] . "megashares_captcha.png", $data, "7");
exit;
}
开发者ID:SheppeR,项目名称:rapidleech,代码行数:28,代码来源:megashares_com.php
示例10: ifrim
function ifrim($f, $ret)
{
$dr = 'users/public/ifram/';
mkdir_r($dr);
write_file($dr . mkday('', 'ydmHis') . '.jpg', $ret);
return image($f);
}
开发者ID:philum,项目名称:cms,代码行数:7,代码来源:ifr.php
示例11: write
public static function write($var, $LOG_TYPE = self::LOG_DEFAULT)
{
$MY =& MY_Controller::get_instance();
$folder = '';
if ($LOG_TYPE == self::LOG_DEFAULT) {
}
if ($LOG_TYPE == self::LOG_APP) {
$folder = 'app';
}
if ($LOG_TYPE == self::LOG_DB) {
$folder = 'db';
}
if ($LOG_TYPE == self::LOG_PROCESS) {
$folder = 'process';
}
if ($LOG_TYPE == self::LOG_PUBLIC) {
$folder = 'public';
}
$path = BASEPATH . "../application/logs" . (empty($folder) ? '' : "/{$folder}") . "/";
if (!file_exists($path)) {
mkdir($path, 0777);
}
if (is_array($var) || is_object($var)) {
$var = print_r($var, TRUE);
}
$path .= date('Y') . '/' . date('m') . '/' . date('d');
if (!file_exists($path)) {
mkdir($path, 0777, TRUE);
}
$file = $path . "/" . date("H.i.s") . '.txt';
$template = "========================" . date("Y-m-d H:i:s") . "========================\n\n" . $var . "\n\n" . "Desde la IP: " . $MY->input->ip_address() . "\n\n" . "=======================================================================\n\n";
write_file($file, $template, FOPEN_READ_WRITE_CREATE);
chmod($file, 0777);
}
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:34,代码来源:log_helper.php
示例12: save_default_db
public function save_default_db()
{
$this->load->dbutil();
$this->load->helper('file');
$prefs = array('format' => 'txt');
// Ion Auth
$prefs['tables'] = array('groups', 'login_attempts', 'users', 'users_groups');
$backup = $this->dbutil->backup($prefs);
$file_path = FCPATH . 'sql/core/ion_auth.sql';
write_file($file_path, $backup);
echo 'Database saved to: ' . $file_path . PHP_EOL;
// Ion Auth (for Admin Panel)
$prefs['tables'] = array('admin_groups', 'admin_login_attempts', 'admin_users', 'admin_users_groups');
$backup = $this->dbutil->backup($prefs);
$file_path = FCPATH . 'sql/core/ion_auth_admin.sql';
write_file($file_path, $backup);
echo 'Database saved to: ' . $file_path . PHP_EOL;
// Demo - Cover Photos
$prefs['tables'] = array('demo_cover_photos');
$backup = $this->dbutil->backup($prefs);
$file_path = FCPATH . 'sql/demo/cover_photos.sql';
write_file($file_path, $backup);
echo 'Database saved to: ' . $file_path . PHP_EOL;
// Demo - Blog
$prefs['tables'] = array('demo_blog_posts', 'demo_blog_categories', 'demo_blog_tags', 'demo_blog_posts_tags');
$backup = $this->dbutil->backup($prefs);
$file_path = FCPATH . 'sql/demo/blog.sql';
write_file($file_path, $backup);
echo 'Database saved to: ' . $file_path . PHP_EOL;
}
开发者ID:Steadroy,项目名称:ci_bootstrap_3,代码行数:30,代码来源:Cli.php
示例13: saveModule
public function saveModule($data)
{
$this->load->helper('file');
$docNameNew = uniqid('', true);
$docName = $docNameNew . '.php';
$category = $data['category'];
if (!write_file($this->config->item('moduleDir') . $category . '/files/' . $docName, $data['html'])) {
$msg = array('status' => 'error', 'msg' => 'There was an error writing the new module to a file.');
echo json_encode($msg);
exit;
} else {
$image = new Image($this->config->item('image_binary'));
$options = array('format' => 'jpg', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip');
$newImage = $this->config->item('moduleDir') . $category . '/files/thumbnails/' . $docNameNew . '.jpg';
$image->generateFromHtml($data['html'], $newImage, $options, true);
$config['source_image'] = $newImage;
$config['maintain_ratio'] = true;
$config['height'] = 200;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$module = array('category' => $category, 'owner' => $this->session->id, 'description' => $data['description'], 'created' => date('Y-m-d H:i:s'), 'publishable' => 1, 'location' => $docName);
$this->db->insert('modules', $module);
$msg = array('status' => 'success', 'msg' => 'We successfully created the new module, and inserted the data into the database.');
echo json_encode($msg);
}
}
开发者ID:brandon-bailey,项目名称:osdms,代码行数:26,代码来源:Builder_model.php
示例14: macro
/** */
function macro($_macro_name, $_wait = TRUE)
{
$_macro_response = '/var/www/temp/' . $_macro_name . '_' . time() . '.log';
$_macro_trace = '/var/www/temp/' . $_macro_name . '_' . time() . '.trace';
write_file($_macro_trace, '', 'w');
chmod($_macro_trace, 0777);
write_file($_macro_response, '', 'w');
chmod($_macro_response, 0777);
$_no_wait = '';
if (!$_wait) {
$_no_wait = ' > /dev/null';
}
$_command_macro = 'sudo python /var/www/fabui/python/gmacro.py ' . $_macro_name . ' ' . $_macro_trace . ' ' . $_macro_response . ' ' . $_no_wait . ' & echo $!';
$_output_macro = shell_exec($_command_macro);
$_pid_macro = trim(str_replace('\\n', '', $_output_macro));
if (!$_wait) {
return true;
}
/** WAIT MACRO TO FINISH */
while (str_replace(PHP_EOL, '', file_get_contents($_macro_response)) == '') {
sleep(0.5);
}
$_return_array['trace'] = file_get_contents($_macro_trace, FILE_USE_INCLUDE_PATH);
$_return_array['response'] = file_get_contents($_macro_response, FILE_USE_INCLUDE_PATH);
unlink($_macro_trace);
unlink($_macro_response);
return $_return_array;
}
开发者ID:tjankovic,项目名称:FAB-UI,代码行数:29,代码来源:utilities.php
示例15: index
function index()
{
$this->load->helper('file');
$tmpdir = '../../tmp';
echo 'upload dir:' . $this->config->item('upload_directory') . '<br />';
echo octal_permissions(fileperms($this->config->item('upload_directory'))) . '<br />';
echo 'tmp dir:' . $tmpdir . '<br />';
echo octal_permissions(fileperms($tmpdir)) . '<br />';
if (opendir($this->config->item('upload_directory'))) {
echo 'sucessfully opened upload dir<br />';
} else {
echo 'failed to open upload dir<br />';
}
if (write_file($this->config->item('upload_directory') . '/test.txt', 'success')) {
echo 'successfully wrote to upload dir';
}
if (opendir($tmpdir)) {
echo 'sucessfully opened tmp dir<br />';
} else {
echo 'failed to open upload dir<br />';
}
if (write_file($this->config->item('../../tmp') . '/test.txt', 'success')) {
echo 'successfully wrote to tmp dir';
}
phpinfo();
}
开发者ID:cybercog,项目名称:exambuff,代码行数:26,代码来源:permcheck.php
示例16: md5_change_go
function md5_change_go()
{
global $list, $PHP_SELF;
if (isset($_POST['yes'])) {
foreach ($_POST['files'] as $k => $v) {
$name = $list[$v]['name'];
$html_name = htmlentities(basename($name));
if (file_exists($name)) {
if (@write_file($name, chr(0), 0)) {
clearstatcache();
printf(lang(381), $html_name);
unset($list[$v]);
$time = filemtime($name);
while (isset($list[$time])) {
$time++;
}
$list[$time] = array('name' => $name, "size" => bytesToKbOrMbOrGb(filesize($name)), "date" => $time);
} else {
printf(lang(382), $html_name);
}
} else {
printf(lang(145), $html_name);
}
echo '<br />';
}
if (!updateListInFile($list)) {
echo lang(146) . "<br /><br />";
}
} else {
echo '<script type="text/javascript">location.href="' . $PHP_SELF . '?act=files";</script>';
}
}
开发者ID:SheppeR,项目名称:rapidleech,代码行数:32,代码来源:md5change.php
示例17: dobackup
public function dobackup()
{
if (empty($_POST['ids'])) {
alert('请选择需要备份的数据库表!', 1);
}
$filesize = intval($_POST['filesize']);
if ($filesize < 512) {
alert('出错了,请为分卷大小设置一个大于512的整数值!', 1);
}
$file = './Public/Backup/';
$random = mt_rand(1000, 9999);
$sql = '';
$p = 1;
foreach ($_POST['ids'] as $table) {
$rs = D(str_replace(C('db_prefix'), '', $table));
$array = $rs->select();
$sql .= "TRUNCATE TABLE `{$table}`;\n";
foreach ($array as $value) {
$sql .= $this->insertsql($table, $value);
if (strlen($sql) >= $filesize * 1000) {
$filename = $file . date('Ymd') . '_' . $random . '_' . $p . '.sql';
write_file($filename, $sql);
$p++;
$sql = '';
}
}
}
if (!empty($sql)) {
$filename = $file . date('Ymd') . '_' . $random . '_' . $p . '.sql';
write_file($filename, $sql);
}
alert('数据库分卷备份已完成,共分成' . $p . '个sql文件存放!', U("Backup/restore"));
}
开发者ID:yunsite,项目名称:waikucms,代码行数:33,代码来源:BackupAction.class.php
示例18: send_sms
function send_sms($mobile, $verify_code, $func = 'register', $debug = true)
{
if ($debug || ENVIRONMENT == "development") {
/**
* 调试环境 查看验证码 tail -f application/logs/verify.php
*/
$CI =& get_instance();
$CI->load->helper('file');
write_file('./application/logs/verify.php', $verify_code . "\n");
return true;
}
$message = array('register' => '注册验证码:' . $verify_code . ',如非本人操作,请忽略本条短信。【】', 'get_pass' => '找回密码验证码:' . $verify_code . ',如非本人操作,请忽略本条短信。【】');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sms-api.luosimao.com/v1/send.json");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:key-b87f2819ac9a8-------');
//关于key暂时先存放此处,以后将存放到config中
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('mobile' => $mobile, 'message' => $message[$func]));
$res = curl_exec($ch);
curl_close($ch);
$res = json_decode($res, true);
if ($res['error'] != 0) {
return false;
} else {
return true;
}
}
开发者ID:lwl1989,项目名称:CI3HMVC,代码行数:35,代码来源:sms_helper.php
示例19: plug_sendmail
function plug_sendmail()
{
$ret .= lkc("", "sendmail.php", "index") . br();
$ip = hostname();
$arr = array("from" => "text", "dest" => "text", "suj" => "text", "msg" => "textarea", "ok" => "submit");
if ($_POST["submit"] == "ok") {
foreach ($arr as $k => $v) {
${$k} = $_POST[$k];
$ret .= $k . ': ' . ${$k} . "\n";
}
if ($ip == $myip) {
$ret .= nl2br($ret);
mail($dest, $suj, $msg, 'From: ' . $from . "\n", "");
} else {
$ret .= "_specify_your_ip_in_source" . br();
}
}
$f = "data/sendmail.txt";
//$ret.=lkc("",$f,"txt").br();
$t .= date("ymd.Hi", time()) . "\n" . $ip . "\n" . $ret . "---\n";
$t .= read_file($f);
write_file($f, $t . "\n");
//write_file($f,$t,"a+");
$ret .= make_form_b($arr, "");
return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:26,代码来源:sendmail.php
示例20: save
/**
* Saves Fancyupoad settings in /modules/Fancyupoad/config/config.php file
*
*/
function save()
{
$this->load->helper('file');
// Settings to save
$keys = array('fancyupload_active', 'fancyupload_max_upload', 'fancyupload_type', 'fancyupload_folder', 'fancyupload_file_prefix', 'fancyupload_send_alert', 'fancyupload_send_confirmation', 'fancyupload_email', 'fancyupload_group');
$settings = array_fill_keys($keys, '');
// Feed array with Post data
foreach ($_POST as $key => $val) {
if (isset($settings[$key])) {
$settings[$key] = $val;
}
}
if ($settings['fancyupload_max_upload'] == '') {
$settings['fancyupload_max_upload'] = 0;
}
/*
* Saving the file
*/
$conf = "<?php \n\n";
foreach ($settings as $key => $val) {
$conf .= "\$config['" . $key . "'] = '" . $val . "';\n";
}
// files end
$conf .= "\n\n";
$conf .= '/* End of file config.php */' . "\n";
$conf .= '/* Auto generated by FancyUpload Administration on : ' . date('Y.m.d H:i:s') . ' */' . "\n";
$conf .= '/* Location: ' . MODPATH . 'Fancyupload/config/config.php */' . "\n";
// Writing problem
if (!write_file(MODPATH . 'Fancyupload/config/config.php', $conf)) {
$this->error(lang('ionize_message_error_writing_file'));
} else {
$this->success(lang('module_fancyupload_message_options_save'));
}
}
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:38,代码来源:fancyupload.php
注:本文中的write_file函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论