Scripts.FranciscoCharrua.com
HotScripts.com - Over 10 web rings.
more links...
user name
password
don't keep me logged
keep me logged for a month
keep me logged for 6 months
keep me logged for a year
Index
News
Samples
E-Mail me
Forums
Sign Up
AGENDA-CALENDAR.PHP
This abstract class contains the methods required to save and get saved agenda calendar entries for all the days of the year. Bellow, you will find the PHP source code for save-entry.ajax.php, and get-entry.ajax.php.
include('agenda-calendar.class.php'); $date = isset($_POST['date']) ? $_POST['date'] : ''; $entry = agendaCalendar::getEntry($date); ?> = $entry ?>
//* : delete this line, it's here to keep my DB from being spammed. include('agenda-calendar.class.php'); include('../../forum/php/guest.class.php'); //* $guestObj = new Guest(DB_NAME, DB_USER, DB_PASS); //* $isLogged = $guestObj->isLogged(); //* $date = isset($_POST['date']) ? $_POST['date'] : ''; $entry = isset($_POST['entry']) ? stripslashes($_POST['entry']) : ''; if($isLogged) //* $id = agendaCalendar::saveEntry($date, $entry); ?> if(!$isLogged) { ?>You must log in in order to post entries in my agenda calendar. } ?>
agenda-calendar.html
agenda-calendar.js
agenda-calendar.php
//Developed by Francisco Charrua //on April 2011 include('db.inc.php'); abstract class agendaCalendar { public function createTables() { $connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); $sql = 'create table if not exists ac_entries (' . 'id int primary key auto_increment, ' . '`date` date, ' . 'entry text' . ')'; $connection->query($sql); $connection->close(); } public function saveEntry($date, $entry) { $entry = self::sanitize($entry); $connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); $sql = 'select id from ac_entries where ac_entries.date = ?'; $statement = $connection->prepare($sql); $statement->bind_param('s', $date); $statement->bind_result($id); $statement->execute(); if($statement->fetch()) { $statement->close(); $sql = 'update ac_entries set entry = ? where id = ?'; $statement = $connection->prepare($sql); $statement->bind_param('si', $entry, $id); $statement->execute(); } else { $statement->close(); $sql = 'insert into ac_entries (ac_entries.date, entry) values (?, ?)'; $statement = $connection->prepare($sql); $statement->bind_param('ss', $date, $entry); $statement->execute(); $id = $statement->insert_id; } $statement->close(); $connection->close(); return($id); } public function getEntry($date) { $connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); $sql = 'select entry from ac_entries where ac_entries.date = ?'; $statement = $connection->prepare($sql); $statement->bind_param('s', $date); $statement->bind_result($entry); $statement->execute(); if(!$statement->fetch()) $entry = ''; $statement->close(); $connection->close(); return($entry); } private function sanitize($text) { $text = trim($text); $text = str_replace("<", "<", $text); $text = str_replace(">", ">", $text); return($text); } } ?>