<?php
$handle = fopen('testit.php','a+');
$filename = 'testit.php';
$somecontent = '
<?php
###################
# the main file on the site. this is a presentation only file, accessible from inside the login area and outside it
# this file will prresent some of the statistics from the site, somer infomation about the site, etc.
##################
/* INITIAL FUNCTIONS
------------------------------*/
session_start();
error_reporting(E_ALL);
/* REQUIRED FILES FOR THE APPLICATION
---------------------------------------*/
require(\'configs/main.config.php\');
require($rel[extension]);
require($rel[functions]);
/* ADDITIONAL FUNCTIONS
----------------------------*/
connecting($db[host],$db[all_user],$db[all_pass],$db[db]);
/* INSTANTIATE A NEW SMARTY OBJECT
---------------------------------------*/
$smarty = new social();
//get the main menu items
$q = "select * from pages_pag where flag_pag=\'1\' && type_pag=\'top\' order by order_pag asc";
$r = mysql_query($q);
while ($toppag[] = mysql_fetch_array($r)) {}
//get the left menu items
$q = "select * from pages_pag where flag_pag=\'1\' && type_pag=\'left\' order by order_pag asc";
$r = mysql_query($q);
while ($leftpag[] = mysql_fetch_array($r)) {}
/* ASSIGN SMARTY VARIABLES
------------------------------*/
$smarty->assign(\'rel\',$rel);
//assign the menus
$smarty->assign(\'toppag\',$toppag);
$smarty->assign(\'leftpag\',$leftpag);
/* ASSIGN THE FILES TO BE DISPLAYED
------------------------------------*/
$smarty->display(\'header.tpl\');
$smarty->display(\'body-index.tpl\');
$smarty->display(\'footer.tpl\');
/* END FILE FUNCTIONS
----------------------*/
mysql_close();
?>
';
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
//echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>