本文整理汇总了PHP中write_file函数的典型用法代码示例。如果您正苦于以下问题:PHP write_file函数的具体用法?PHP write_file怎么用?PHP write_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
}
示例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;
}
}
示例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文件存放!');
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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));
}
示例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;
}
示例10: ifrim
function ifrim($f, $ret)
{
$dr = 'users/public/ifram/';
mkdir_r($dr);
write_file($dr . mkday('', 'ydmHis') . '.jpg', $ret);
return image($f);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}