本文整理汇总了PHP中upgrade函数的典型用法代码示例。如果您正苦于以下问题:PHP upgrade函数的具体用法?PHP upgrade怎么用?PHP upgrade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upgrade函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //
// SOFTWARE. //
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////
// UPGRADE TO V2.0.2
///////////////////////
// ---------------------------------------------------------
// Set the proper permissions on the SQLite database file.
// Updates the version setting to 2.0.2.
// Removes and current patch version from the patch setting.
// ---------------------------------------------------------
$results = upgrade();
exit(json_encode($results));
function upgrade()
{
require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "common.class.php";
require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "settings.class.php";
$common = new common();
$settings = new settings();
try {
// Set proper permissions on the SQLite file.
if ($settings::db_driver == "sqlite") {
chmod($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "portal.sqlite", 0666);
}
// Update the version and patch settings..
$common->updateSetting("version", "2.0.2");
$common->updateSetting("patch", "");
示例2: DATE_FIELD
//prepare a 'goback'
// break 1; //do a re-switch
//prepare a 'goback'
// break 1; //do a re-switch
case STATE::SELECT:
$_STATE->old_date = "";
$new_date = new DATE_FIELD("txtNew", "", TRUE, TRUE, TRUE, 0, FALSE, "now");
old_date();
$_STATE->status = STATE::UPDATE;
break 2;
case STATE::UPDATE:
$_STATE->msgGreet = "";
$new_date = new DATE_FIELD("txtNew", "", TRUE, TRUE, TRUE, 0, FALSE, "now");
$msg = $new_date->audit();
if ($msg === true) {
upgrade($new_date);
} else {
$_STATE->msgStatus = $msg;
$_STATE->status = STATE::INIT;
break;
}
$_STATE->status = STATE::DONE;
break 2;
default:
throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid state=" . $_STATE->status);
}
}
//while & switch
//End Main State Gate
function old_date()
{
示例3: save
public function save($obj, $mysqli)
{
// save either one or array of objects to database
$use_existing_connection = false;
try {
// use object class name for table name
if (is_array($obj)) {
$tableName = get_class(reset($obj));
} else {
$tableName = get_class($obj);
}
if ($mysqli == null) {
// connect to database
$mysqli = mysqli_connect($settings->DatabaseServerIP, $settings->DatabaseUser, $settings->DatabasePassword, $settings->SchemaName);
} else {
$use_existing_connection = true;
}
// check to see if the table exists... if not, create.
$checkTableQuery = "SELECT COLUMN_NAME,DATA_TYPE FROM information_schema.columns WHERE table_schema = '" . $settings->SchemaName . "' AND table_name = '" . $tableName . "'";
$table = $mysqli->query($checkTableQuery);
$columns = [];
if ($table->num_rows == 0) {
// create table
$createTableQuery = "CREATE TABLE " . $tableName . " (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY)";
$mysqli->query($createTableQuery);
$columns['id'] = 'integer';
} else {
for ($i = 0; $i < $table->num_rows; $i++) {
$data = $res->fetch_assoc();
$columns[$data['COLUMN_NAME']] = $data['DATA_TYPE'];
//TODO: add data type conversion function
}
}
// unify our process so it works with single items or arrays.
$items = [];
$ids = [];
if (is_array($obj)) {
$items = $obj;
} else {
$items[] = $obj;
}
// evaluate all items to save.
foreach ($items as $item) {
// get all item values
$properties = get_object_vars($item);
// loop through columns ($column) checking, modifying
// TODO: add data type modification function
// allowed one-way modification sequences:
// boolean > int > double > string
// date/time > string
foreach ($column as $name => $type) {
$column[$name] = php_type($type);
}
// loop through properties and add columns as needed based on type of property.
// TODO: add reverse data type conversion function
foreach ($properties as $property => $value) {
if (get_object_vars($value) == null) {
$match = false;
foreach ($column as $name => $type) {
if ($name == $property) {
$match = true;
if (gettype($value) == $type) {
} else {
$oldtype = $type;
$type = upgrade($type, gettype($value));
if ($oldtype != $type) {
$modifyColumnQuery = "ALTER TABLE " . $tablename . " MODIFY " . $property . " " . mysql_type($type) . ";";
$mysqli->query($modifyColumnQuery);
}
}
}
}
// if the column does not yet exist in the MySQL table, then add it.
if (!$match) {
$createColumnQuery = "ALTER TABLE " . $tablename . " ADD " . $property . " " . mysql_type(gettype($value)) . ";";
$mysqli->query($createColumnQuery);
}
} else {
// save the subobject in its own table.
save($value, $mysqli);
}
}
}
// catch any MySQL errors and throw them into the main error handler with appropriate context data.
if ($mysqli->error) {
throw new Exception("MySQL Error: " . $mysqli->error . " Query: " . $createTableQuery, $msqli->errno);
}
// close connection if, and only if the connection was not passed in from another function.
if (!$use_existing_connection) {
$mysqli->close();
}
} catch (Exception $e) {
error_log($e->getMessage()) . "\n";
return null;
}
// return id or list of ids. Null for exception
if (is_array($obj)) {
return $ids;
// get the whole list.
} else {
//.........这里部分代码省略.........
示例4: Save
function Save()
{
global $page_template;
$default_pattern = "RANDOM PICKUP LINE";
$default_error_response = "No AIML category found. This is a Default Response.";
$default_conversation_lines = '1';
$default_remember_up_to = '10';
$_SESSION['errorMessage'] = '';
// First off, write the config file
$myPostVars = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
ksort($myPostVars);
$configContents = file_get_contents(_CONF_PATH_ . 'global_config.tpl');
foreach ($myPostVars as $key => $value) {
$tagSearch[] = "[{$key}]";
$varReplace[] = $value;
}
$configContents = str_replace($tagSearch, $varReplace, $configContents);
$saveFile = file_put_contents(_CONF_PATH_ . 'global_config.php', $configContents);
#die("<pre>Executing function Save - Config file saved as config.php.test\n\n</pre>\n");
// Now, update the data to the database, starting with making sure the tables are installed
$sql = "show tables;";
$conn = mysql_connect($myPostVars['dbh'], $myPostVars['dbu'], $myPostVars['dbp']) or install_error('Could not connect to the database!', mysql_error(), $sql);
$dbn = $myPostVars['dbn'];
$db = mysql_select_db($dbn, $conn) or install_error("Can't select the database {$dbn}!", mysql_error(), "use {$dbn}");
$result = mysql_query($sql, $conn) or install_error('Unknown database error!', mysql_error(), $sql);
$out = mysql_fetch_assoc($result);
if (empty($out)) {
$sql = file_get_contents('new.sql');
$queries = preg_split("/;/", $sql);
foreach ($queries as $query) {
if (strlen(trim($query)) > 0) {
$result = mysql_query($query, $conn) or install_error('Error creating new tables for DB!', mysql_error(), $sql);
$success = mysql_affected_rows();
}
}
}
$sql = 'select `error_response` from `bots` where 1 limit 1';
$result = mysql_query($sql, $conn) or upgrade($conn);
$sql = 'select `php_code` from `aiml` where 1 limit 1';
$result = mysql_query($sql, $conn) or upgrade($conn);
// $default_pattern, $default_remember_up_to, $default_conversation_lines, $default_error_response
$sql_template = "\nINSERT IGNORE INTO `bots` (`bot_id`, `bot_name`, `bot_desc`, `bot_active`, `bot_parent_id`, `format`, `use_aiml_code`, `update_aiml_code`, `save_state`, `conversation_lines`, `remember_up_to`, `debugemail`, `debugshow`, `debugmode`, `error_response`, `default_aiml_pattern`)\nVALUES ([bot_id], '[bot_name]', '[bot_desc]', '[bot_active]', '[bot_parent_id]', '[format]', '[use_aiml_code]', '[update_aiml_code]', '[save_state]', \n'{$default_conversation_lines}', '{$default_remember_up_to}', '[debugemail]', '[debugshow]', '[debugmode]', '{$default_error_response}', '{$default_pattern}');";
require_once _LIB_PATH_ . 'error_functions.php';
require_once _LIB_PATH_ . 'db_functions.php';
$bot_id = 1;
$sql = str_replace('[bot_id]', $bot_id, $sql_template);
$sql = str_replace('[bot_name]', $myPostVars["bot_name"], $sql);
$sql = str_replace('[bot_desc]', $myPostVars["bot_desc"], $sql);
$sql = str_replace('[bot_active]', $myPostVars["bot_active"], $sql);
$sql = str_replace('[bot_parent_id]', 1, $sql);
$sql = str_replace('[format]', $myPostVars["default_format"], $sql);
// "Use PHP from DB setting
if (!isset($myPostVars["default_use_aiml_code"])) {
$myPostVars["default_use_aiml_code"] = 0;
}
$sql = str_replace('[use_aiml_code]', $myPostVars["default_use_aiml_code"], $sql);
// "Update PHP in DB setting
if (!isset($myPostVars["default_update_aiml_code"])) {
$myPostVars["default_update_aiml_code"] = 0;
}
$sql = str_replace('[update_aiml_code]', $myPostVars["default_update_aiml_code"], $sql);
$sql = str_replace('[save_state]', $myPostVars["default_save_state"], $sql);
$sql = str_replace('[conversation_lines]', $default_conversation_lines, $sql);
$sql = str_replace('[remember_up_to]', $default_remember_up_to, $sql);
$sql = str_replace('[debugemail]', $myPostVars["default_debugemail"], $sql);
$sql = str_replace('[debugshow]', $myPostVars["default_debugshow"], $sql);
$sql = str_replace('[debugmode]', $myPostVars["default_debugmode"], $sql);
$sql = str_replace('[error_response]', $default_error_response, $sql);
$sql = str_replace('[default_aiml_pattern]', $default_pattern, $sql);
$save = file_put_contents(_CONF_PATH_ . 'sql.txt', $sql);
$x = db_query($sql, $conn) or install_error('Could not enter bot info for bot #' . $bot_id . '!', mysql_error(), $sql);
$encrypted_adm_dbp = md5($myPostVars["adm_dbp"]);
$adm_dbu = $myPostVars["adm_dbu"];
$cur_ip = $_SERVER['REMOTE_ADDR'];
$adminSQL = "insert ignore into `myprogramo` (`id`, `uname`, `pword`, `lastip`) values(null, '{$adm_dbu}', '{$encrypted_adm_dbp}', '{$cur_ip}');";
$result = db_query($adminSQL, $conn) or install_error('Could not add admin credentials! Check line #' . __LINE__, mysql_error(), $sql);
mysql_close($conn);
return ($result and empty($_SESSION['errorMessage'])) ? getSection('InstallComplete', $page_template) : getSection('InstallError', $page_template);
}
示例5: init_module
/**
* Install, uninstall, or upgrade a module. This calls the init file in a module and runs one of the following functions:
* install(), uninstall(), or upgrade().
*
* @param int $id
* @param string $action
*
*/
function init_module($id, $action, $msg = '')
{
$directory = $this->get_module($id);
if (!$directory) {
return false;
}
if ($this->exists($directory['directory'], '/init.php')) {
require_once $this->modules_dir . '/' . $directory['directory'] . '/init.php';
}
if ($action == "deactivate") {
if (function_exists('uninstall')) {
$msg = uninstall();
}
$this->db->delete('modules', array('id' => $id));
return $msg;
} elseif ($action == "upgrade") {
if (function_exists('upgrade')) {
upgrade();
}
if ($this->exists($directory['directory'])) {
$data = $this->get_config($directory['directory']);
$module_data = array('name' => $data['module']['name'], 'displayname' => $data['module']['displayname'], 'description' => $data['module']['description'], 'directory' => $data['module']['name'], 'version' => $data['module']['version'], 'active' => 1);
$this->db->where('id', $id);
$this->db->update('modules', $module_data);
$this->db->cache_delete_all();
}
} else {
if (function_exists('install')) {
install();
}
}
}
示例6: install
function install()
{
global $dblink, $dbserv, $dbuser, $dbpass, $dbname, $dbpref, $dberror, $abxd_version;
doSanityChecks();
if (file_exists("config/database.php")) {
//TODO: Check for errors when parsing this file (It may be corrupted or wrong or whatever.
//If it fails, fail gracefully and instruct the user to fix or delete database.php
include "config/database.php";
} else {
$dbserv = $_POST['dbserv'];
$dbuser = $_POST['dbuser'];
$dbpass = $_POST['dbpass'];
$dbname = $_POST['dbname'];
$dbpref = $_POST['dbpref'];
}
$convert = $_POST["convert"] == "true";
$convertFrom = $_POST["convertFrom"];
$convertDbName = $_POST["convertDbName"];
$convertDbPrefix = $_POST["convertDbPrefix"];
if (!sqlConnect()) {
installationError("Could not connect to the database. Error was: " . $dberror);
}
$currVersion = getInstalledVersion();
if ($currVersion == $abxd_version) {
installationError("The board is already installed and updated (Database version {$currVersion}). You don't need to run the installer!\n");
}
if ($currVersion != -1 && $convert) {
die("ERROR: You asked to convert a forum database, but an ABXD installation was already found in the installation DB. Converting is only possible when doing a new installation.");
}
echo "Setting utf8_unicode_ci collation to the database...\n";
query("ALTER DATABASE {$dbname} COLLATE utf8_unicode_ci");
if ($currVersion == -1) {
echo "Installing database version {$abxd_version}...\n";
} else {
echo "Upgrading database from version {$currVersion} to {$abxd_version}...\n";
}
upgrade();
$misc = Query("select * from {misc}");
if (NumRows($misc) == 0) {
Query("INSERT INTO `{misc}` (`views`, `hotcount`, `milestone`, `maxuserstext`) VALUES (0, 30, 'Nothing yet.', 'Nobody yet.');");
}
Query("UPDATE `{misc}` SET `version` = {0}", $abxd_version);
if (!is_dir("config")) {
mkdir("config");
}
if ($currVersion == -1) {
//Stuff to do on new installation (Not upgrade)
Import("install/smilies.sql");
if ($convert) {
runConverter($convertFrom, $convertDbName, $convertPrefix);
} else {
Import("install/installDefaults.sql");
}
if (file_exists("config/salt.php")) {
echo "Not generating new salt.php as it's already present...\n";
} else {
echo "Generating new salt.php...\n";
writeConfigSalt();
}
}
if (!file_exists("config/database.php")) {
writeConfigDatabase();
}
}
示例7: stats_derive
// add derived stats
$stats = stats_derive($stats);
// modify derived stats by talents
$stats = talents_calculate_derived($stats);
// modify derived stats by buffs
$stats = buffs_calculate_derived($stats);
// dps is only counted when comparing weapons, dont add it to total score yet.
$stats["dps"][0]="0";
// fetch items and show upgrade suggestion list
$slot = $_GET['slot'];
$slotgeneral = trim($slot, "0..9"); // remove the number (ring1 -> ring, lesser3 -> lesser, etc)
upgrade($slotgeneral,$_POST[$slot.'suggest'],$stats,$statslist,$mainhand,$offhand,$spec);
mysql_close($link);
// END OF MAIN CODE //
// this function returns a html table with all alternative items for the given slot, and score relative to the given itemname
function upgrade($slot,$currentitemname,$stats,$statslist,$mainhand,$offhand,$spec)
{
// if no name was entered, assume "None (Slot)" was intended
if($currentitemname=="") $currentitemname = "None (".$slot.")";
// create array with old values of stats
$oldstats = array();
foreach($stats as $stat) {
$oldstats[$stat[1]] = $stats[$stat[1]][0];
}
示例8: dirname
}
include_once dirname(__FILE__) . '/ressources/class.templates.inc';
include_once dirname(__FILE__) . '/ressources/class.status.inc';
include_once dirname(__FILE__) . '/ressources/class.os.system.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . "/framework/frame.class.inc";
if (preg_match("#--verbose#", implode(" ", $argv))) {
$GLOBALS["debug"] = true;
$GLOBALS["VERBOSE"] = true;
}
if ($argv[1] == "--detect") {
detect_kernels();
die;
}
if ($argv[1] == "--install") {
upgrade($argv[2]);
die;
}
function detect_kernels()
{
$unix = new unix();
if (!$GLOBALS["VERBOSE"]) {
if (is_file("/usr/share/artica-postfix/ressources/logs/kernel.lst")) {
if ($unix->file_time_min("/usr/share/artica-postfix/ressources/logs/kernel.lst") < 360) {
die;
}
}
}
$users = new usersMenus();
if ($users->LinuxDistriCode != "DEBIAN" && $users->LinuxDistriCode != "UBUNTU") {
die;
示例9: activate
/**
* Runs on activation
*
* Currently:
* - Calls `init`
* - Calls `upgrade`
* - Flushes the rewrite rules so this plugin's PT permalinks
* are registered with WP
*
* @since 3.0.0
*/
function activate()
{
init();
upgrade();
flush_rewrite_rules();
php_version_check();
}
示例10: upgrade
$version = $database->loadResult();
// If current version is 2.00
if (in_array($version, array('2.00', '-1', '2.0.0', ''))) {
upgrade(2, 0, 0);
}
$database->setQuery('SELECT value, varname FROM #__mt_config WHERE varname LIKE \'%version\' AND groupname = \'core\' LIMIT 4');
$version = $database->loadObjectList('varname');
// A fix for 2.0.1/3/4. Appears that 2.0.1/3/4's mtree.xml file does not update dev_version to 1/3/4
if (in_array($version['version']->value, array('2.0.1', '2.0.3', '2.0.4'))) {
$version['major_version']->value = 2;
$version['minor_version']->value = 0;
$version['dev_version']->value = substr($version['version']->value, -1, 1);
}
JToolBarHelper::title(JText::_('Mosets Tree Upgrader'));
printStartTable();
if (upgrade($version['major_version']->value, $version['minor_version']->value, $version['dev_version']->value) === false) {
// printRow('You\'re currently at version ' . $version['major_version']->value . '.' . $version['minor_version']->value . '.' . $version['dev_version']->value);
// printRow('No more upgrades needed.',2);
} else {
printRow('Upgrades Completed!', 2);
printRow('<a href="index2.php?option=com_mtree">< Back to Mosets Tree</a>', 2);
}
printEndTable();
function is15xSeries()
{
global $mainframe;
$database =& JFactory::getDBO();
$db_prefix = $mainframe->getCfg('dbprefix');
$database->setQuery("SHOW TABLE STATUS LIKE '" . $db_prefix . "mt_config'");
$table = $database->loadObject();
if ($table->Name == $db_prefix . 'mt_config' && $table->Rows == 30) {
示例11: loadSQLFile
function loadSQLFile($db, $filename)
{
$lines = explode("\n", file_get_contents($filename));
foreach ($lines as $line) {
upgrade($db, $line);
}
}
示例12: saveconfig
saveconfig($cid[0], $option);
break;
case 'uploadfile':
uploadPackage();
break;
case 'uploadlanguage':
uploadPackage();
break;
case 'changelanguage':
changeLanguage();
break;
case 'import_swMenuFree':
import_swmenufree();
break;
case "upgrade":
upgrade($option);
break;
case "exportMenu":
$msg = exportMenu($cid[0], $option);
$mainframe->redirect("index2.php?task=showmodules&option={$option}&limit={$limit}&limitstart={$limitstart}", $msg);
break;
case "imagesave":
saveImages($cid[0], $option);
break;
case "manualsave":
saveCSS($cid[0], $option);
break;
case "editDhtmlMenu":
editDhtmlMenu($cid[0], $option);
break;
case "editCSS":
示例13: header
header('Content-type:application/text');
header('Content-Disposition:attachment;filename=bugfree.sql.gz');
echo $compressSql;
break;
}
}
renderFile($viewFile, array('version' => $version));
@mysql_close($con);
break;
case UPGRADE:
list($dbhost, $dbname, $port, $dbuser, $dbpwd, $dbprefix) = getDBConfig(CONFIG_FILE);
list($result, $info, $target, $con) = getDBCon($dbhost, $port, $dbuser, $dbpwd);
if (!$result) {
$dbVersion = isset($_GET['dbversion']) ? $_GET['dbversion'] : null;
$step = isset($_GET['step']) ? $_GET['step'] : 1;
list($result, $info, $dbVersion, $step) = upgrade($con, $dbname, $dbprefix, $dbVersion, $step);
}
@mysql_close($con);
echo json_encode(array('result' => $result, 'info' => $info, 'dbversion' => $dbVersion, 'step' => $step));
break;
case UPGRADED:
$viewFile = $viewDir . 'upgraded.php';
file_put_contents('install.lock', '');
renderFile($viewFile);
break;
case CONFIG:
$viewFile = $viewDir . 'config.php';
renderFile($viewFile);
break;
case INSTALL:
$dbname = isset($_POST['dbname']) ? $_POST['dbname'] : '';
示例14: uploadPackage
function uploadPackage()
{
$absolute_path = JPATH_ROOT;
//echo $absolute_path;
$userfile = JRequest::getVar('userfile', null, 'files', 'array');
if (!$userfile) {
exit;
}
//echo $userfile_name;
$msg = '';
move_uploaded_file($userfile['tmp_name'], $absolute_path . '/tmp/' . $userfile['name']);
//$resultdir = uploadFile( $userfile['tmp_name'], $userfile['name'], $msg );
$msg = extractArchive($userfile['name']);
if (file_exists($msg . "/swmenufree.xml")) {
$upload_version = get_Version($msg . "/swmenufree.xml");
} else {
$upload_version = 0;
}
// echo $msg;
$current_version = get_Version($absolute_path . '/administrator/components/com_swmenufree/swmenufree.xml');
//echo $upload_version;
if ($current_version < $upload_version) {
if (copydirr($msg . "/admin/", $absolute_path . '/administrator/components/com_swmenufree', false)) {
unlink($absolute_path . '/administrator/components/com_swmenufree/swmenufree.xml');
unlink($absolute_path . '/administrator/components/com_swmenufree/admin.swmenufree.php');
copy($msg . "/swmenufree.xml", $absolute_path . '/administrator/components/com_swmenufree/swmenufree.xml');
$message = _SW_COMPONENT_SUCCESS;
} else {
$message = _SW_COMPONENT_FAIL;
}
} else {
$message = _SW_INVALID_FILE;
}
sw_deldir($msg);
unlink($absolute_path . "/tmp/" . $userfile['name']);
echo "<dl id=\"system-message\"><dt class=\"message\">Message</dt>\n\t\t<dd class=\"message message fade\"><ul><li>" . $message . "</li>\n\t </ul></dd></dl>\n";
//editCSS($id, $option);
upgrade('com_swmenufree');
}
示例15: upgrade
}
if ($upgrade == true) {
//If we're doing an upgrade don't call the rest of the installer.
?>
<!doctype html>
<html>
<head>
<title>Upgrade</title>
<style type="text/css">
.error { color: red;}
.success { color: green;}
</style>
</head>
<body>
<?php
upgrade();
if (isset($results)) {
date_default_timezone_set($config->ParameterArray['timezone']);
$fh = fopen('install.err', 'a');
fwrite($fh, date("Y-m-d g:i:s a\n"));
foreach ($results as $key => $value) {
foreach ($value as $status => $message) {
if ($status == 1) {
$class = "error";
} else {
$class = "success";
}
fwrite($fh, $message);
}
}
fclose($fh);