Webocreation

Wednesday, February 3, 2010

Calender Code

<?php
include('databaseConnection.php');

$action = $_POST['action'];

switch($action) {
case 'login':
// Login.
$username = stripslashes(trim($_POST['username']));
$password = sha1(stripslashes(trim($_POST['password'])));

if(empty($username) || empty($password)) {
// Stop, someone tried entering nothing into here.
// Show an error.
$loginMsg = 'You must enter a username and password';
} else {
// The input seems to be ok, check it against the database.
$checkDetails = mysql_query("SELECT id FROM user WHERE username='$username' AND password='$password' LIMIT 1", $conn);
if($checkDetails) {
if(mysql_num_rows($checkDetails) > 0) {
setcookie('nodstrumCalendarV2', '1', time()+3600); // Cookie will expire in 1 hour.
// $loginMsg = '<span style="color: green">You are logged in<i>!</i></span>';
} else {
$loginMsg = 'Your username or password was incorrect';
}
} else {
$loginMsg = 'There was an error logging you in';
}
}
break;
case 'logout':
setcookie('nodstrumCalendarV2', '0', time()-3600000);
header('location: index.php');
break;
case 'updatePassword':
$pass1 = sha1($_POST['password1']);
$pass2 = sha1($_POST['password2']);

if($pass1 == $pass2) {
$updatePassword = mysql_query("UPDATE user SET password='$pass1' WHERE username='admin' LIMIT 1", $conn);
if($updatePassword) {
$loginMsg = '<span style="color: green">Your password has been changed :)</span>';
} else {
$loginMsg = 'There was an error updating your password.';
}
} else {
$loginMsg = 'Your passwords did not match, please try again.';
}

break;
case 'updateColours':
$dc = $_POST['dayColor'];
$wc = $_POST['weekendColor'];
$tc = $_POST['todayColor'];
$ec = $_POST['eventColor'];
$ic1 = $_POST['iteratorColor1'];
$ic2 = $_POST['iteratorColor2'];

$updateColours = mysql_query("UPDATE settings SET dayColor='$dc', weekendColor='$wc', todayColor='$tc', eventColor='$ec', iteratorColor1='$ic1', iteratorColor2='$ic2' WHERE id='1' LIMIT 1", $conn);

if($updateColours) {
$loginMsg = '<span style="color: green">Your colours have been updated :)</span>';
} else {
$loginMsg = 'There was a problem updating the colours';
}

break;
}

include('settings.php');
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MySQL Calendar System - Easily using PHP & Script.aculo.us</title>

<script src="js/lib/prototype.js" type="text/javascript"></script>
<script src="js/src/scriptaculous.js" type="text/javascript"></script>

<style>
body {
font-family: Tahoma;
font-size: 12px;
}

.calendarBox {
position: relative;
top: 30px;
margin: 0 auto;
padding: 5px;
width: 254px;
border: 1px solid #000;
}

.calendarFloat {
float: left;
width: 31px;
height: 25px;
margin: 1px 0px 0px 1px;
padding: 1px;
border: 1px solid #000;
}
</style>

<script type="text/javascript">
function highlightCalendarCell(element) {
$(element).style.border = '1px solid #999999';//cellpadding color
}

function resetCalendarCell(element) {
$(element).style.border = '1px solid #000000';
}

function startCalendar(month, year) {
new Ajax.Updater('calendarInternal', 'rpc.php', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+''});
}

function showEventForm(day) {
$('evtDay').value = day;
$('evtMonth').value = $F('ccMonth');
$('evtYear').value = $F('ccYear');

displayEvents(day, $F('ccMonth'), $F('ccYear'));

if(Element.visible('addEventForm')) {
// do nothing.
} else {
Element.show('addEventForm');
}
}

function displayEvents(day, month, year) {
new Ajax.Updater('eventList', 'rpc.php', {method: 'post', postBody: 'action=listEvents&&d='+day+'&m='+month+'&y='+year+''});
if(Element.visible('eventList')) {
// do nothing, its already visble.
} else {
setTimeout("Element.show('eventList')", 30);
}
}

function addEvent(day, month, year, body) {
if(day && month && year && body) {
// alert('Add Event\nDay: '+day+'\nMonth: '+month+'\nYear: '+year+'\nBody: '+body);
new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=addEvent&d='+day+'&m='+month+'&y='+year+'&body='+body+'', onSuccess: highlightEvent(day)});
$('evtBody').value = '';
} else {
alert('There was an unexpected script error.\nPlease ensure that you have not altered parts of it.');
}

// highlightEvent(day);
} // addEvent.

function highlightEvent(day) {
Element.hide('addEventForm');
$('calendarDay_'+day+'').style.background = '#<?= $eventColor ?>';
}

function showLoginBox() {
Element.show('loginBox');
}

function showCP() {
Element.show('cpBox');
}

function deleteEvent(eid) {
confirmation = confirm('Are you sure you wish to delete this event?\n\nOnce the event is deleted, it is gone forever!');
if(confirmation == true) {
new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=deleteEvent&eid='+eid+'', onSuccess: Element.hide('event_'+eid+'')});
} else {
// Do not delete it!.
}
}
</script>


</head>
<body>
<p><?php<br>
include('databaseConnection.php');<br>
<br>
$action = $_POST['action'];<br>
<br>
switch($action) {<br>
case 'login':<br>
// Login.<br>
$username = stripslashes(trim($_POST['username']));<br>
$password = sha1(stripslashes(trim($_POST['password'])));<br>
<br>
if(empty($username) || empty($password)) {<br>
// Stop, someone tried entering nothing into here.<br>
// Show an error.<br>
$loginMsg = 'You must enter a username and password';<br>
} else {<br>
// The input seems to be ok, check it against the database.<br>
$checkDetails = mysql_query("SELECT id FROM user WHERE username='$username' AND password='$password' LIMIT 1", $conn);<br>
if($checkDetails) {<br>
if(mysql_num_rows($checkDetails) > 0) {<br>
setcookie('nodstrumCalendarV2', '1', time()+3600); // Cookie will expire in 1 hour.<br>
// $loginMsg = '<span style="color: green">You are logged in<i>!</i></span>';<br>
} else {<br>
$loginMsg = 'Your username or password was incorrect';<br>
}<br>
} else {<br>
$loginMsg = 'There was an error logging you in';<br>
}<br>
}<br>
break;<br>
case 'logout':<br>
setcookie('nodstrumCalendarV2', '0', time()-3600000);<br>
header('location: index.php');<br>
break;<br>
case 'updatePassword':<br>
$pass1 = sha1($_POST['password1']);<br>
$pass2 = sha1($_POST['password2']);<br>
<br>
if($pass1 == $pass2) {<br>
$updatePassword = mysql_query("UPDATE user SET password='$pass1' WHERE username='admin' LIMIT 1", $conn);<br>
if($updatePassword) {<br>
$loginMsg = '<span style="color: green">Your password has been changed :)</span>';<br>
} else {<br>
$loginMsg = 'There was an error updating your password.';<br>
}<br>
} else {<br>
$loginMsg = 'Your passwords did not match, please try again.';<br>
}<br>
<br>
break;<br>
case 'updateColours':<br>
$dc = $_POST['dayColor'];<br>
$wc = $_POST['weekendColor'];<br>
$tc = $_POST['todayColor'];<br>
$ec = $_POST['eventColor'];<br>
$ic1 = $_POST['iteratorColor1'];<br>
$ic2 = $_POST['iteratorColor2'];<br>
<br>
$updateColours = mysql_query("UPDATE settings SET dayColor='$dc', weekendColor='$wc', todayColor='$tc', eventColor='$ec', iteratorColor1='$ic1', iteratorColor2='$ic2' WHERE id='1' LIMIT 1", $conn);<br>
<br>
if($updateColours) {<br>
$loginMsg = '<span style="color: green">Your colours have been updated :)</span>';<br>
} else {<br>
$loginMsg = 'There was a problem updating the colours';<br>
}<br>
<br>
break;<br>
}<br>
<br>
include('settings.php');<br>
?></p>
<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br>
<html><br>
<head><br>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><br>
<title>MySQL Calendar System - Easily using PHP &amp; Script.aculo.us</title></p>
<p><script src="js/lib/prototype.js" type="text/javascript"></script><br>
<script src="js/src/scriptaculous.js" type="text/javascript"></script></p>
<p><style><br>
body {<br>
font-family: Tahoma;<br>
font-size: 12px;<br>
}<br>
<br>
.calendarBox {<br>
position: relative;<br>
top: 30px;<br>
margin: 0 auto;<br>
padding: 5px;<br>
width: 254px;<br>
border: 1px solid #000;<br>
}</p>
<p> .calendarFloat {<br>
float: left;<br>
width: 31px;<br>
height: 25px;<br>
margin: 1px 0px 0px 1px;<br>
padding: 1px;<br>
border: 1px solid #000;<br>
}<br>
</style></p>
<p><script type="text/javascript"><br>
function highlightCalendarCell(element) {<br>
$(element).style.border = '1px solid #999999';//cellpadding color<br>
}</p>
<p> function resetCalendarCell(element) {<br>
$(element).style.border = '1px solid #000000';<br>
}<br>
<br>
function startCalendar(month, year) {<br>
new Ajax.Updater('calendarInternal', 'rpc.php', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+''});<br>
}<br>
<br>
function showEventForm(day) {<br>
$('evtDay').value = day;<br>
$('evtMonth').value = $F('ccMonth');<br>
$('evtYear').value = $F('ccYear');<br>
<br>
displayEvents(day, $F('ccMonth'), $F('ccYear'));<br>
<br>
if(Element.visible('addEventForm')) {<br>
// do nothing.<br>
} else {<br>
Element.show('addEventForm');<br>
}<br>
}<br>
<br>
function displayEvents(day, month, year) {<br>
new Ajax.Updater('eventList', 'rpc.php', {method: 'post', postBody: 'action=listEvents&&d='+day+'&m='+month+'&y='+year+''});<br>
if(Element.visible('eventList')) {<br>
// do nothing, its already visble.<br>
} else {<br>
setTimeout("Element.show('eventList')", 30);<br>
}<br>
}<br>
<br>
function addEvent(day, month, year, body) {<br>
if(day && month && year && body) {<br>
// alert('Add Event\nDay: '+day+'\nMonth: '+month+'\nYear: '+year+'\nBody: '+body);<br>
new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=addEvent&d='+day+'&m='+month+'&y='+year+'&body='+body+'', onSuccess: highlightEvent(day)});<br>
$('evtBody').value = '';<br>
} else {<br>
alert('There was an unexpected script error.\nPlease ensure that you have not altered parts of it.');<br>
}<br>
<br>
// highlightEvent(day);<br>
} // addEvent.<br>
<br>
function highlightEvent(day) {<br>
Element.hide('addEventForm');<br>
$('calendarDay_'+day+'').style.background = '#<?= $eventColor ?>';<br>
}<br>
<br>
function showLoginBox() {<br>
Element.show('loginBox');<br>
}<br>
<br>
function showCP() {<br>
Element.show('cpBox');<br>
}<br>
<br>
function deleteEvent(eid) {<br>
confirmation = confirm('Are you sure you wish to delete this event?\n\nOnce the event is deleted, it is gone forever!');<br>
if(confirmation == true) {<br>
new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=deleteEvent&eid='+eid+'', onSuccess: Element.hide('event_'+eid+'')});<br>
} else {<br>
// Do not delete it!.<br>
}<br>
}<br>
</script><br>
</p>
<p></head><br>
<body></p>
<p> <div id="calendar" class="calendarBox"><br>
<div id="calendarInternal"><br>
&nbsp;<br>
</div><br>
<br style="clear: both;"><br>
<span id="LoginMessageBox" style="color: red; margin-top: 10px;"><?= $loginMsg; ?></span><br>
<div id="eventList" style="display: none;"></div><br>
<div style="display: none; margin-top: 10px;" id="addEventForm"><br>
<b>Add Event</b><br>
<br><br>
Date: <input type="text" size="2" id="evtDay" disabled> <input type="text" size="2" id="evtMonth" disabled> <input type="text" size="4" id="evtYear" disabled><br>
<br><br>
<textarea id="evtBody" cols="32" rows="5"></textarea><br>
<br><br>
<input type="button" value="Add Event" onClick="addEvent($F('evtDay'), $F('evtMonth'), $F('evtYear'), $F('evtBody'));"><br>
<a href="#" onClick="Element.hide('addEventForm');">Close</a><br>
</div><br>
<br>
<div style="display: none; margin-top: 10px;" id="loginBox"><br>
<b>Login</b><br>
<br><br>
<form action="index.php" method="post"><br>
Username: <input type="text" name="username" size="20"><br>
<br><br>
Password: <input type="password" name="password" size="20"><br>
<br><br>
<input type="hidden" name="action" value="login"><br>
<input type="submit" value="Login"><br>
<a href="#" onClick="Element.hide('loginBox');">Close</a><br>
</form><br>
</div><br>
<br>
<div style="display: none; margin-top: 10px;" id="cpBox"><br>
<b>Control Panel</b> <a href="#" onClick="Element.hide('cpBox');">Close</a><br>
<br><br><br>
<b>Change the colours</b><br>
<br><br>
<form action="index.php" method="post"><br>
Day Colour: <input type="text" name="dayColor" size="6" maxlength="6" value="<?= $dayColor; ?>"><br>
<br><br>
Weekend Colour: <input type="text" name="weekendColor" size="6" maxlength="6" value="<?= $weekendColor; ?>"><br>
<br><br>
Today Colour: <input type="text" name="todayColor" size="6" maxlength="6" value="<?= $todayColor; ?>"><br>
<br><br>
Event Colour: <input type="text" name="eventColor" size="6" maxlength="6" value="<?= $eventColor; ?>"><br>
<br><br>
Iterator 1 Colour: <input type="text" name="iteratorColor1" size="6" maxlength="6" value="<?= $iteratorColor2; ?>"><br>
<br><br>
Iterator 2 Colour: <input type="text" name="iteratorColor2" size="6" maxlength="6" value="<?= $iteratorColor1; ?>"><br>
<br><br>
<input type="hidden" name="action" value="updateColours"><br>
<input type="submit" value="Update Colours"><br>
</form><br>
<br>
<br><br>
<form action="index.php" method="post"><br>
<input type="hidden" name="action" value="updatePassword"><br>
<b>Change your password</b><br>
<br><br>
New Password: <input type="password" name="password1" size="20"><br>
<br><br>
Confirm it: <input type="password" name="password2" size="20"><br>
<br><br>
<input type="submit" value="Update Password"><br>
</form><br>
<br>
<br><br><br>
<b>Logout</b><br>
<form action="index.php" method="post"><br>
<input type="hidden" name="action" value="logout"><br>
<input type="submit" value="logout"><br>
</form><br>
</div><br>
<br>
</div> <!-- FINAL DIV DO NOT REMOVE --><br>
<br>
<script type="text/javascript"><br>
startCalendar(0,0);<br>
</script></p>
<p></body><br>
</html></p>
</body>
</html>
free php code, bootstrap php code, php code, extjs php mysql tutorial example code, php code employment application form, how to send and receive sms using php code, how to send receive sms using php code, php login code, php source code, creating a php chatroom source code, php code attach document and email, php code digital filing, php code snippet textbox scroll require, php credit card verification code validation, php employment application form code, php form code, database code generator php, how to php code in csv, php code for moneris payment modules, php code nakupenda, php codes, php database code, pre code php, code + connect + vb6 to php + with odbc, code snippets php, default apache php code to display file list, embed asp code into php, how to php code a list from a csv file, insert php code into html, meta search engine source code in php, meta search source code in php, peripheral devices php connect code scanner, peripheral devices php connect code scanner network, php code filling pdf, php code for dashboard to display tables, php code to open a url in new window, php fullscreen f11 code, php page code, php script to crypt php code, php source code for dating website, sample project using php code igniter, view msg files using php code, web macro php source code, why does my php code display chinese instead of english, you may post php code, ascii code php, code lobster php edition serial number, code site download php mysql reports, code todisplay records in multiple pages in php, convert c++ code to php, date code combobox php, date code jan 1 combobox php, excel ascii codes with php, how php code to show only new records in a csv file, how to download server side php code, how to php code csv, how to php code in a csv file, how to php code in csv file, how to php code in img, how to run java menu in php code, how to use java script in php code, learning php code, line break in php code, new line in php code, php code checker, php code debug tool, php code for social network system, php code is not null, php code not interpreted, php code online text file editor, php code to display shoretel data, php code to open a new window, php code to replace mod_autoindex, php contact form code, php credit card verification code, php database select code, php generat code, php image resize code, php run java code, php sample code, php torrent source code, php treeview code, php using old code deprecated, planet source code php, roshan's ajax dropdown code with php, simple crypt php code, simple free php code, what is a php code, wordpress page php code

No comments:

Post a Comment