本文整理汇总了PHP中file_write_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP file_write_contents函数的具体用法?PHP file_write_contents怎么用?PHP file_write_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_write_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multinet_rebuild_globalconf
function multinet_rebuild_globalconf()
{
global $ubillingConfig;
$altCfg = $ubillingConfig->getAlter();
$global_template = file_get_contents("config/dhcp/global.template");
$subnets_template = file_get_contents("config/dhcp/subnets.template");
$alldhcpsubnets_q = "SELECT `id`,`netid` from `dhcp` ORDER BY `id` ASC";
$alldhcpsubnets = simple_queryall($alldhcpsubnets_q);
$allMembers_q = "SELECT `ip` from `nethosts` WHERE `option` != 'NULL'";
$allMembers = simple_queryall($allMembers_q);
$membersMacroContent = '';
$vlanMembersMacroContent = '';
$onuMembersMacroContent = '';
if (!empty($allMembers)) {
foreach ($allMembers as $ix => $eachMember) {
$memberClass = 'm' . str_replace('.', 'x', $eachMember['ip']);
$membersMacroContent .= 'deny members of "' . $memberClass . '";' . "\n";
}
}
if (isset($altCfg['VLANGEN_SUPPORT'])) {
if ($altCfg['VLANGEN_SUPPORT']) {
$vlanMembers_q = "SELECT `ip` FROM `users` WHERE `login` IN(SELECT `login` FROM `vlanhosts`);";
$allVlanMembers = simple_queryall($vlanMembers_q);
if (!empty($allVlanMembers)) {
foreach ($allVlanMembers as $ivl => $eachVlanMember) {
$memberVlanClass = 'm' . str_replace('.', 'x', $eachVlanMember['ip']);
$vlanMembersMacroContent .= 'deny members of "' . $memberVlanClass . '";' . "\n";
}
}
}
}
$onuMembers_q = "SELECT `ip` FROM `nethosts` WHERE `netid` IN (SELECT `id` FROM `networks` WHERE `nettype` = 'dhcp82_bdcom' or `nettype` = 'dhcp82_zte');";
$allOnuMembers = simple_queryall($onuMembers_q);
if (!empty($allOnuMembers)) {
foreach ($allOnuMembers as $index => $eachOnuMember) {
$memberOnuClass = 'm' . str_replace('.', 'x', $eachOnuMember['ip']);
$onuMembersMacroContent .= 'deny members of "' . $memberOnuClass . '";' . "\n";
}
}
$subnets = '';
if (!empty($alldhcpsubnets)) {
foreach ($alldhcpsubnets as $io => $eachnet) {
$netdata = multinet_get_network_params($eachnet['netid']);
$templatedata['{STARTIP}'] = $netdata['startip'];
$templatedata['{ENDIP}'] = $netdata['endip'];
$templatedata['{CIDR}'] = explode('/', $netdata['desc']);
$templatedata['{NETWORK}'] = $templatedata['{CIDR}'][0];
$templatedata['{CIDR}'] = $templatedata['{CIDR}'][1];
$templatedata['{ROUTERS}'] = int2ip(ip2int($templatedata['{STARTIP}']) + 1);
$templatedata['{MASK}'] = multinet_cidr2mask($templatedata['{CIDR}']);
$dhcpdata = dhcp_get_data_by_netid($eachnet['netid']);
if (isset($dhcpdata['confname'])) {
$templatedata['{HOSTS}'] = $dhcpdata['confname'];
// check if override?
if (!empty($dhcpdata['dhcpconfig'])) {
$currentsubtpl = $dhcpdata['dhcpconfig'];
} else {
$currentsubtpl = $subnets_template;
}
$subnets .= multinet_ParseTemplate($currentsubtpl, $templatedata) . "\n";
}
}
}
$globdata['{SUBNETS}'] = $subnets;
$globdata['{DENYMEMBERS}'] = $membersMacroContent;
$globdata['{DENYVLANGENMEMBERS}'] = $vlanMembersMacroContent;
$globdata['{DENYONUMEMBERS}'] = $onuMembersMacroContent;
$globconf = multinet_ParseTemplate($global_template, $globdata);
file_write_contents("multinet/dhcpd.conf", $globconf);
}
示例2: output
function output($title, $content, $disposition = 'browser')
{
$_SERVER['PLANOWNER_DISPLAY_NAME'] = str_replace("'", "", $_SERVER['PLANOWNER_DISPLAY_NAME']);
$_SERVER['STOPWATCH']['content_end'] = array_sum(explode(' ', microtime()));
$_SERVER['STOPWATCH']['output_begin'] = array_sum(explode(' ', microtime()));
// if there is no cookie, user is 'guest'
if (!$_SERVER['USER']) {
$_SERVER['USER'] = 'guest';
}
if ($_SERVER['OUTPUT_MODE'] == 'HTML') {
Header("Content-type: text/html; charset=UTF-8");
$page = output_html($title, $content);
}
if ($_SERVER['OUTPUT_MODE'] == 'IPHONE') {
Header("Content-type: text/html; charset=UTF-8");
$page = output_iphone($title, $content);
}
if ($_SERVER['OUTPUT_MODE'] == 'RSS' || strstr($_SERVER['OUTPUT_MODE'], 'ATOM')) {
Header("Content-type: text/xml; charset=UTF-8");
$page = output_feed($title, $content);
}
if ($_SERVER['OUTPUT_MODE'] == 'AJAX') {
Header("Content-type: text/html; charset=UTF-8");
$page = output_ajax($title, $content);
}
if ($disposition == 'return') {
return $page;
}
if (strstr($disposition, $_SERVER['DOCUMENT_ROOT'])) {
file_write_contents($disposition, $page);
return $page;
}
echo $page;
exit;
}
示例3: save_cache
function save_cache()
{
$this->CONTENT = ob_get_contents();
//Записываем буфер в переменную
rcms_delete_files($this->dir_cache . "/" . $this->hash_code);
file_write_contents($this->dir_cache . "/" . $this->hash_code, $this->CONTENT);
}
示例4: guestbook_remove_post
function guestbook_remove_post($file, $num, $config = false)
{
if ($data = @file_get_contents($file)) {
$data = unserialize($data);
}
unset($data[$num]);
file_write_contents($file, serialize($data));
return true;
}
示例5: write_rate
function write_rate($for, $val, $ip)
{
global $write;
if (!$write) {
$arr = array();
if (file_exists(RATE_PATH . $for)) {
$arr = unserialize(file_get_contents(RATE_PATH . $for));
}
$arr[$ip] = $val;
file_write_contents(RATE_PATH . $for, serialize($arr));
}
}
示例6: gallery_delete_comment
function gallery_delete_comment($id, $cid)
{
$images = rcms_scandir(GALLERY_PATH);
if ($data = @file_get_contents(GALLERY_PATH . $images[$id] . '.cm')) {
$data = unserialize($data);
} else {
return false;
}
if (isset($data[$cid])) {
unset($data[$cid]);
file_write_contents(GALLERY_PATH . $images[$id] . '.cm', serialize($data));
}
return true;
}
示例7: ucm_delete
function ucm_delete($id)
{
$filename = basename($id) . '.ucm';
if (!is_file(DF_PATH . $filename)) {
return false;
}
if (rcms_delete_files(DF_PATH . $filename)) {
$config = file_get_contents(CONFIG_PATH . 'menus.ini');
$config = preg_replace('/[0-9]* = "ucm:' . $id . '"\\s/i', '', $config);
file_write_contents(CONFIG_PATH . 'menus.ini', $config);
return true;
} else {
return false;
}
}
示例8: ucm_delete
function ucm_delete($id, $dir = MENU_MODULES_PATH)
{
$id = basename($id);
$workdir = $dir . 'ucm.' . $id;
if (is_dir($workdir)) {
if (rcms_delete_files($workdir, true)) {
$config = file_get_contents(CONFIG_PATH . 'menus.ini');
$config = preg_replace('/[0-9]* = "ucm.' . $id . '"\\s/i', '', $config);
if (!file_write_contents(CONFIG_PATH . 'menus.ini', $config)) {
return 6;
}
return 0;
} else {
return 4;
}
} else {
return 4;
}
}
示例9: download_save_data_file
function download_save_data_file($file, $cont)
{
if (!is_writeable($file) && is_file($file)) {
return false;
}
$res = array();
foreach ($cont as $key => $value) {
if ($value !== false) {
$res[$key] = $value;
}
}
if (!($data = serialize($res))) {
return false;
}
if (!file_write_contents($file, $data)) {
return false;
}
return true;
}
示例10: close
function close($uc = true, $uo = true)
{
if ($uc) {
if (!$this->copened) {
$this->openCurrentPolls();
}
$a = file_write_contents($this->polls_file, serialize($this->current));
}
if ($uo) {
if (!$this->oopened) {
$this->openArchivedPolls();
}
$b = file_write_contents($this->old_polls_file, serialize($this->old));
}
if ($uc && $uo) {
return $a && $b;
} elseif ($uo) {
return $b;
} elseif ($uc) {
return $a;
} else {
return true;
}
}
示例11: page_change
function page_change($id, $newid, $title, $text, $description, $keywords, $mode = 'html', $date)
{
global $system;
$id = basename($id);
$newid = basename($newid);
if (preg_replace("/[a-z0-9\\-\\_]*/i", '', $id) != '' || empty($id)) {
return false;
}
if (preg_replace("/[a-z0-9\\-\\_]*/i", '', $newid) != '' || empty($newid)) {
return false;
}
if (!is_file(PAGES_PATH . $id)) {
return false;
}
if ($id != $newid && is_file(PAGES_PATH . $newid)) {
return false;
}
$page = array('title' => $title, 'text' => $text, 'description' => $description, 'keywords' => $keywords, 'mode' => $mode, 'author_nick' => $system->user['nickname'], 'author_name' => $system->user['username'], 'date' => sql_to_unix_time($date));
if (!file_write_contents(PAGES_PATH . $id, serialize($page))) {
return false;
}
rcms_rename_file(PAGES_PATH . $id, PAGES_PATH . $newid);
return true;
}
示例12: rcms_parse_ini_file
$alter_conf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
if ($alter_conf['EXPORT_ENABLED']) {
$export_filepath = 'exports/';
$export_fileext = '.export';
if (wf_CheckGet(array('dlexf'))) {
zb_DownloadFile($export_filepath . vf($_GET['dlexf'], 3) . $export_fileext, 'default');
}
show_window(__('Export payments data'), zb_ExportForm());
if (isset($_POST['fromdate']) and isset($_POST['todate'])) {
$from_date = $_POST['fromdate'];
$to_date = $_POST['todate'];
//export types
//xml
if ($alter_conf['EXPORT_FORMAT'] == 'xml') {
$export_result = zb_ExportPayments($from_date, $to_date);
}
//dbf
if ($alter_conf['EXPORT_FORMAT'] == 'dbf') {
//need to be written
}
$export_filename = time();
$exported_link = wf_Link('?module=payexport&dlexf=' . $export_filename, wf_img('skins/icon_download.png') . ' ' . __('Exported data download'), false, 'ubButton');
file_write_contents($export_filepath . $export_filename . $export_fileext, $export_result);
show_window('', $exported_link);
}
} else {
show_error(__('Payments export not enabled'));
}
} else {
show_error(__('You cant control this module'));
}
示例13: __
$prio = $_POST['priority'][$module];
include_once 'sitemap/' . $module . '.php';
}
}
$sitemap->sitemapFileName = $_POST['filename'];
$result = $sitemap->sitemapFileName . ' ' . __('added successfully') . '<br/>';
if (!empty($_POST['gz'])) {
$sitemap->createGZipFile = true;
$result .= $_POST['filename'] . '.gz ' . __('added successfully') . '<br/>';
}
$sitemap->createSitemap();
// create sitemap in memory
$sitemap->writeSitemap();
// write sitemap as file
if (isset($_POST['robots_txt'])) {
file_write_contents(RCMS_ROOT_PATH . 'robots.txt', $_POST['robots_txt']);
}
//save robots.txt
if (!empty($_POST['robots'])) {
//build new robots.txt
rcms_delete_files(RCMS_ROOT_PATH . 'robots.txt');
$sitemap->updateRobots();
$result .= 'robots.txt ' . __('added successfully') . '<br/>';
}
if (!empty($_POST['engines'])) {
// submit sitemaps to search engines
$result .= "<pre>";
$result .= $sitemap->submitSitemap('');
$result .= "</pre>";
}
$result .= __('Memory peak usage: ') . number_format(memory_get_peak_usage() / (1024 * 1024), 2) . "MB";
示例14: saveIndexFiles
function saveIndexFiles()
{
global $system;
if ($system->checkForRight('GALLERY')) {
file_write_contents(GALLERY_INDEXES_DIR . 'main.dat', serialize($this->indexes['main']));
file_write_contents(GALLERY_INDEXES_DIR . 'filename.dat', serialize($this->indexes['filename']));
file_write_contents(GALLERY_INDEXES_DIR . 'title.dat', serialize($this->indexes['title']));
file_write_contents(GALLERY_INDEXES_DIR . 'size.dat', serialize($this->indexes['size']));
file_write_contents(GALLERY_INDEXES_DIR . 'type.dat', serialize($this->indexes['type']));
file_write_contents(GALLERY_INDEXES_DIR . 'keywords.dat', serialize($this->indexes['keywords']));
}
return true;
}
示例15: mkdir
if (!is_dir(DATA_PATH . 'help/')) {
mkdir(DATA_PATH . 'help/', 0777);
}
if (!is_dir($help_dir)) {
mkdir($help_dir, 0777);
}
if (!empty($_GET['delete'])) {
$dfile = $help_dir . '/' . get('delete');
if (rcms_delete_files($dfile)) {
show_window(__('Result'), __('File removed'));
} else {
show_window(__('Result'), __('Error occurred') . ':' . $dfile);
}
}
if (!empty($_POST['save']) && !empty($module)) {
file_write_contents($file, $_POST['help_edit']);
show_window(__('Result'), __('File updated') . '. ' . __('Show') . ' — ' . show_help($module));
}
if (!empty($module)) {
$result = file_exists($file) ? file_get_contents($file) : '';
$frm = new InputForm('', 'post', __('Submit'));
$frm->hidden('save', '1');
$frm->addrow('', $frm->textarea('help_edit', $result, 55, 15) . tinymce_selector('help_edit'), 'top');
$result = $frm->show(true);
show_window(__('Help') . ' ' . __('for the module') . ' ' . get('edit') . ': ' . __('Edit'), $result, 'center');
} else {
$files = rcms_scandir($help_dir);
if (!empty($files)) {
$result = '<table width="100%">';
foreach ($files as $helpfile) {
$admin_link = '