<?php //require(str_repeat('../', substr_count($_SERVER['SCRIPT_NAME'], "/")) . 'includes/functions.php'); // Added 08/01/2010 when getting PHP warnings date_default_timezone_set("Europe/London"); $d_date1 = date('l jS F, Y', h99()); // Friday 26th December, 2003 $d_date5 = date('Y-m-d'); // 2003-12-26 # mysql_style date $d_date6 = date('Y-m-d H:i:s', h99()); // 2003-12-26 21:06:19 # mysql-style date time $d_date10 = date('H:i:s', h99()); // 21:06:19 $d_date11 = date('H:i', h99()); // 21:06 // Configuration $textarea_rows = 15; $textarea_cols = 105; $textarea_rows2 = 10; $textarea_cols2 = 125; // Define our preferred colours //define('TODAY_COL', '#609'); define('SEL_COL', '#c00'); define('THREE_COL', '#f60'); define('FOUR_COL', '#c90'); define('TOOLS_SCRIPT', 'inc/tools2.php'); // Script that handles all AJAX server output define('SECSINADAY', 86400); // Number of seconds in one day (60*60*24) $arr_d = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); // 009966
function upd($link) { $row_imp = @$_POST['row_imp']; //echo $row_imp; //$info = magicquotes_check($_POST['info'], 1); // addslashes $info = $_POST['info']; $pst_dt = $_POST['dt']; if (!isset($info) or !isset($pst_dt)) { exit; } $dt_pst_dt = formatmydate($pst_dt, 1); $r_dateinfo = $link->prepare("SELECT id FROM diary_main WHERE d=?"); $r_dateinfo->execute(array((string) $pst_dt)); $dy1 = date("D", strtotime($pst_dt)); $iscurwk = isCurWk($pst_dt); //$nm_dateinfo = $r_dateinfo->rowCount(); $str = ''; // Check if entry exists for date if ($r_dateinfo->rowCount() == 0) { // Entry for date does not exist $ins_date = date('Y-m-d H:i:s', h99()); // Date does not exist in database - create a row for it $r_ins = $link->prepare("INSERT INTO diary_main (d, info, ins_date) VALUES (?, '', ?)"); $r_ins->execute(array((string) $pst_dt, (string) $ins_date)); // Keep a text record of diary entries $file_path2 = "../temp/{$pst_dt}" . '_' . time() . '.php'; $fp2 = fopen($file_path2, 'w'); $write_file2 = fwrite($fp2, ''); fclose($fp2); if (!$r_ins->rowCount()) { $str .= '<span class="updfail">The entry for ' . "{$dt_pst_dt} could not be CREATED at {$ins_date} </span>"; exit; //} else { } } // End if. // Update existing row $ch_date = date('Y-m-d H:i:s', h99()); // Get the number of edits: $r_nme = $link->prepare("SELECT numedit FROM diary_main WHERE d=?"); $r_nme->execute(array((string) $pst_dt)); $rw = $r_nme->fetch(PDO::FETCH_NUM); $nme = $rw[0] + 1; $r_upd = $link->prepare("UPDATE diary_main SET info=?, important=?, ch_date=?, numedit=? where d=?"); $r_upd->execute(array((string) $info, (int) $row_imp, (string) $ch_date, (int) $nme, (string) $pst_dt)); // Keep a text 'snapshot' record of updated diary entries list($uy, $um, $ud) = explode('-', $pst_dt); $uym = "{$uy}-{$um}"; if (!is_dir("../temp/{$uym}")) { mkdir("../temp/{$uym}"); } if (!is_dir("../temp/{$uym}/{$ud}")) { mkdir("../temp/{$uym}/{$ud}"); } $file_path2 = "../temp/{$uym}/{$ud}/" . time() . '.txt'; $fp2 = fopen($file_path2, 'w'); $write_file2 = fwrite($fp2, stripslashes($info)); fclose($fp2); if ($r_upd->rowCount() == 1) { // Record updated if (isset($r_ins)) { // New record created echo "<span class=\"updsuccess\">The entry for {$dt_pst_dt} was CREATED at " . formatmydate($ins_date, 0) . "</span>|{$ins_date}|None"; } else { $str .= "<span class=\"updsuccess\">The entry for {$dt_pst_dt} was UPDATED at " . formatmydate($ch_date, 0) . "</span>|{$ch_date}"; } // End if. } else { $str .= '<span class="updfail">RECORD WAS NOT UPDATED</span>'; } // End if. $str .= "|{$pst_dt}|{$dy1}|{$iscurwk}"; echo $str; }