PageRenderTime 57ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/middCalendar/eventsunmerged.txt

https://github.com/gkipkorir/public_html
Plain Text | 488 lines | 392 code | 96 blank | 0 comment | 0 complexity | 64b6dd46111d6cddb8d595ec21a35567 MD5 | raw file
  1. <?php
  2. <<<<<<< HEAD
  3. //start session
  4. //must happen before anything else on the page
  5. //print_r($_SESSION);
  6. //set up the connection to the database
  7. define('DB_SERVER','panther.cs.middlebury.edu');
  8. define('DB_USERNAME','wschaaf');
  9. define('DB_PASSWORD','wschaaf');
  10. define('DB_DATABASE','wschaaf_Calendar');
  11. $con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die("Could not connect");
  12. //get todays date in form (y-m-d)
  13. $date = getdate();
  14. $today = $date['year']."-".$date['mon']."-".$date['mday'];
  15. $date1 = date_create("$today");
  16. //make array of week
  17. $t = date_create("$today");
  18. $byDate[date_format($t,"Y-m-d")][]=' ';
  19. for ($x=1; $x<=6; $x++)
  20. {
  21. date_add($t,date_interval_create_from_date_string("1 days"));
  22. $byDate[date_format($t,"Y-m-d")][]=' ';
  23. }
  24. //get date 6 days from today (to create a week, including today)
  25. $date=date_create("$today");
  26. date_add($date,date_interval_create_from_date_string("6 days"));
  27. //echo "Seven days from now is: ".date_format($date,"Y-m-d")."</br>";
  28. //sql query selects all events between today's date and 6 days from now
  29. $sql="SELECT * FROM Events WHERE date BETWEEN '".date_format($date1,"Y-m-d")."' AND '".date_format($date,"Y-m-d")."' AND approved=1";
  30. if (!mysqli_query($con,$sql))
  31. {
  32. die('Error: ' . mysqli_error());
  33. }
  34. else
  35. {
  36. //execute the SQL query
  37. $result = mysqli_query($con,$sql);
  38. }
  39. //$byDate needs to be initialized first so that days with no events still show up...
  40. function sortFunction( $a, $b ) {
  41. return strtotime($a['date']) - strtotime($b["date"]);
  42. }
  43. while ($row = mysqli_fetch_array($result)) {
  44. $result1[] = $row;
  45. }
  46. usort($result1, "sortFunction");
  47. //while ($row = mysqli_fetch_array($result)) {
  48. //for each event, display its name as a link to detailed event info, with eid in the url
  49. // echo "<a href='./eventInfo.php?eid=".$row['eid']."'>".$row['name']."</a><br>";
  50. foreach($result1 as $row){
  51. $byDate[$row['date']][]=$row;
  52. }
  53. //}
  54. //print_r($byDate);
  55. echo "<div id='links'>";
  56. echo "</br>";
  57. //if session user is set (from logging in), show link to create event and log out
  58. if(isset($_SESSION['User'])){
  59. echo "Welcome ".$_SESSION['User']."</br>";
  60. echo "<a href='./CreateEvent.php'>Create Event</a></br>";
  61. echo "<a href='./CreateOrganization.php'>Create Organization</a></br>";
  62. echo "<a href='./addMembers.php'>Add Members to Org</a></br>";
  63. $sql2="SELECT supervisor FROM Users WHERE uid = '$_SESSION[uid]'";
  64. if (!mysqli_query($con,$sql2))
  65. {
  66. die('Error: ' . mysqli_error());
  67. }
  68. else
  69. {
  70. //execute the SQL query
  71. $result2 = mysqli_query($con,$sql2);
  72. }
  73. $row = mysqli_fetch_array($result2);
  74. if($row['supervisor']==1){
  75. echo "<a href='./approveEvents.php'>Approve Events</a></br>";
  76. }
  77. echo "<a href='./logout.php'>Don't forget to logout</a><br>";
  78. }
  79. else{ //if session user is not set, show link to log in and to create user
  80. $_SESSION['User'] = null;
  81. echo "<a href='./login.php'>Log In</a></br>";
  82. echo "<a href='./CreateUser.php'>Create User</a></br>";
  83. }
  84. //link to search page
  85. ?>
  86. <html>
  87. =======
  88. //start session
  89. //must happen before anything else on the page
  90. session_start();
  91. //set up the connection to the database
  92. define('DB_SERVER','panther.cs.middlebury.edu');
  93. define('DB_USERNAME','wschaaf');
  94. define('DB_PASSWORD','wschaaf');
  95. define('DB_DATABASE','wschaaf_Calendar');
  96. $con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die("Could not connect");
  97. //get todays date in form (y-m-d)
  98. $date = getdate();
  99. $today = $date['year']."-".$date['mon']."-".$date['mday'];
  100. $date1 = date_create("$today");
  101. //make array of week
  102. $t = date_create("$today");
  103. $byDate[date_format($t,"Y-m-d")][]=' ';
  104. for ($x=1; $x<=6; $x++) {
  105. date_add($t,date_interval_create_from_date_string("1 days"));
  106. $byDate[date_format($t,"Y-m-d")][]=' ';
  107. }
  108. //get date 6 days from today (to create a week, including today)
  109. $date=date_create("$today");
  110. date_add($date,date_interval_create_from_date_string("6 days"));
  111. //echo "Seven days from now is: ".date_format($date,"Y-m-d")."</br>";
  112. //sql query selects all events between today's date and 6 days from now
  113. $sql="SELECT * FROM Events WHERE date BETWEEN '".date_format($date1,"Y-m-d")."' AND '".date_format($date,"Y-m-d")."' AND approved=1";
  114. if (!mysqli_query($con,$sql))
  115. {
  116. die('Error: ' . mysqli_error());
  117. }
  118. else
  119. {
  120. //execute the SQL query
  121. $result = mysqli_query($con,$sql);
  122. }
  123. //$byDate needs to be initialized first so that days with no events still show up...
  124. echo "</br>Events in the Next 7 days: </br>";
  125. while ($row = mysqli_fetch_array($result)) {
  126. //for each event, display its name as a link to detailed event info, with eid in the url
  127. // echo "<a href='./eventInfo.php?eid=".$row['eid']."'>".$row['name']."</a><br>";
  128. $byDate[$row['date']][]=$row;
  129. }
  130. //print_r($byDate);
  131. echo "<div id='links'>";
  132. echo "</br>";
  133. //if session user is set (from logging in), show link to create event and log out
  134. if(isset($_SESSION['User'])){
  135. echo "Welcome ".$_SESSION['User']."</br>";
  136. echo "<a href='./CreateEvent.php'>Create Event</a></br>";
  137. echo "<a href='./CreateOrganization.php'>Create Organization</a></br>";
  138. echo "<a href='./addMembers.php'>Add Members to Org</a></br>";
  139. $sql2="SELECT supervisor FROM Users WHERE uid = '$_SESSION[uid]'";
  140. if (!mysqli_query($con,$sql2)) {
  141. die('Error: ' . mysqli_error());
  142. }
  143. else {
  144. //execute the SQL query
  145. $result2 = mysqli_query($con,$sql2);
  146. }
  147. $row = mysqli_fetch_array($result2);
  148. if($row['supervisor']==1) {
  149. echo "<a href='./approveEvents.php'>Approve Events</a></br>";
  150. }
  151. echo "<a href='./logout.php'>Don't forget to logout</a><br>";
  152. }
  153. else {
  154. //if session user is not set, show link to log in and to create user
  155. $_SESSION['User'] = null;
  156. echo "<a href='./login.php'>Log In</a></br>";
  157. echo "<a href='./CreateUser.php'>Create User</a></br>";
  158. }
  159. ?>
  160. <html>
  161. <head>
  162. <title>Midd Events</title>
  163. <style>
  164. a:visited, a:link {
  165. color:#0066CC;
  166. }
  167. a{
  168. font-size:20;
  169. }
  170. #links {
  171. float:left;
  172. width: 200px ;
  173. }
  174. #content {
  175. float:left;
  176. }
  177. #table1 {
  178. width: 1100px ;
  179. margin-left: auto ;
  180. margin-right: auto ;
  181. }
  182. div.date a:link,div.date a:visited {
  183. text-transform:uppercase;
  184. font-weight:bold;
  185. color:#0066CC;
  186. }
  187. table, th, td {
  188. border: 1px solid black;
  189. text-align:center;
  190. }
  191. td {
  192. vertical-align:top;
  193. width:200;
  194. }
  195. </style>
  196. </head>
  197. >>>>>>> 281b898698e544d13df1aee64b15ad2291e648e6
  198. <body>
  199. <SCRIPT LANGUAGE="javascript">
  200. function validate() {
  201. fm = document.thisForm
  202. //use validation here to make sure the user entered
  203. //the information correctly
  204. fm.submit()
  205. }
  206. </SCRIPT>
  207. <form action="insert1.php" method="post">
  208. <label for="midd_search_query">Search</label>
  209. <input type="search" id="midd_search_query" class="search_query x-webkit-speech" name="Search" placeholder="Search Calendar" x-webkit-speech required>
  210. <input type="submit" value="Go">
  211. <!--<input type="hidden" id="midd_ajax_search_url" value="/go/search">-->
  212. </form>
  213. <!--This creates the insert boxes
  214. <form action="insert1.php" method="post">
  215. <<<<<<< HEAD
  216. <label for="midd_search_query">Search</label>
  217. <input type="search" id="midd_search_query" class="search_query x-webkit-speech" name="Search" placeholder="Search Calendar" x-webkit-speech required>
  218. <input type="submit" value="Go">
  219. <!--<input type="hidden" id="midd_ajax_search_url" value="/go/search">-->
  220. </form>
  221. <!--This creates the insert boxes
  222. <form action="insert1.php" method="post">
  223. Search: <input type="text" name="Search" /> <br> <br>
  224. <input type="submit" value="Search"/> <br> <br>
  225. </form>-->
  226. <!--This creates the drop down list-->
  227. <form name="thisForm" method="POST" action="eventsByGenre.php">
  228. <p>Select Genre: <select size="1" name="genre">
  229. <option value="Dance"> Dance </option>
  230. <option value="Party"> Party </option>
  231. <option value="Clam Bake"> Clam Bake </option>
  232. <option value="Pineapple"> Pineapple </option>
  233. <option value="drinking"> drinking </option>
  234. <option value="sports"> sports </option>
  235. <input type="button" value="Go" name="btm_submit" onclick="validate()">
  236. </select></p>
  237. <p>
  238. </p>
  239. </form>
  240. </body>
  241. </html>
  242. <?php
  243. echo "</div>";
  244. $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday', 'Saturday');
  245. $months = array('01'=>'January', 'February', 'March', 'April','May','June', 'July', 'August', 'September', 'October', 'November', 'December');
  246. echo "</br>";
  247. echo "<div id='content'>";
  248. echo "<div id='table1'>";
  249. echo "<table>";
  250. echo "<tr>";
  251. foreach($byDate as $key => $value)
  252. {
  253. echo "<td>";
  254. echo "<div class = 'date'>";
  255. echo "<a href='./date.php?date=".$key."' >";
  256. echo $days[date( "w", strtotime($key))]."</br>";
  257. echo $months[date( "m", strtotime($key))]." ".date( "d", strtotime($key))."</br></br>";
  258. echo "</a></div>";
  259. //array shift removes first value of array, which kept being current time for some reason.
  260. array_shift($value);
  261. //print out each event that occurs on day, as a link to more details
  262. foreach($value as $event){
  263. echo "<a href='./eventInfo.php?eid=".$event['eid']."'>".$event['name']."</a> </br>".date('g:i A',strtotime($event['time']))."<br>";
  264. //echo "<a href='./eventInfo.php?eid=".$event['eid']."'>".$event['name']."</a> ".date("l jS \of F Y h:i:s A",strtotime($event['time']))."<br>";
  265. echo "<div class = 'description'>".substr($event['description'],0,15)."...</div></br>";
  266. }
  267. echo "</td>";
  268. }
  269. echo "</tr>";
  270. echo "</table>";
  271. echo "</div>";
  272. echo "</div>";
  273. //Display events
  274. //echo "</br>Events in the Next 7 days: </br>";
  275. //while ($row = mysqli_fetch_array($result)) {
  276. //for each event, display its name as a link to detailed event info, with eid in the url
  277. // echo "<a href='./eventInfo.php?eid=".$row['eid']."'>".$row['name']."</a><br>";
  278. //}
  279. //view session data:
  280. //print_r($_SESSION);
  281. //close connection
  282. mysql_close($con)
  283. ?>
  284. <style>
  285. html{
  286. background: #737373;
  287. background-image:url('./1003background1.png');
  288. }
  289. a:visited, a:link{
  290. color:#0066CC;
  291. }
  292. #links{
  293. float:left;
  294. width: 200px ;
  295. background: white;
  296. opacity:0.9;
  297. }
  298. #content{
  299. float:left;
  300. }
  301. #table1{
  302. background: white;
  303. opacity:0.9;
  304. width: 1100px ;
  305. margin-left: auto ;
  306. margin-right: auto ;
  307. }
  308. div.date a:link,div.date a:visited{
  309. text-transform:uppercase;
  310. font-weight:bold;
  311. color:#0066CC;
  312. }
  313. .description{
  314. color: #585858;
  315. font-size:16;
  316. }
  317. table, th, td
  318. {
  319. font-size:20;
  320. border: 1px solid black;
  321. text-align:center;
  322. }
  323. td{
  324. vertical-align:top;
  325. width:200;
  326. }
  327. </style>
  328. <!DOCTYPE HTML>
  329. <html>
  330. <title> Midd Events </title>
  331. <body>
  332. </body>
  333. </html>
  334. =======
  335. Search: <input type="text" name="Search" /> <br> <br>
  336. <input type="submit" value="Search"/> <br> <br>
  337. </form>-->
  338. <!--This creates the drop down list-->
  339. <form name="thisForm" method="POST" action="query.php">
  340. <p>Select Genre: <select size="1" name="my_dropdown">
  341. <option value="Dance"> Dance </option>
  342. <option value="Party"> Party </option>
  343. <option value="Clam Bake"> Clam Bake </option>
  344. <option value="Pineapple"> Pineapple </option>
  345. <option value="drinking"> drinking </option>
  346. <option value="sports"> sports </option>
  347. <input type="button" value="Go" name="btm_submit" onclick="validate()">
  348. </select></p>
  349. <p>
  350. </p>
  351. </form>
  352. <?php
  353. echo "</div>";
  354. $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday', 'Saturday');
  355. $months = array('01'=>'January', 'February', 'March', 'April','May','June', 'July', 'August', 'September', 'October', 'November', 'December');
  356. echo "</br>";
  357. echo "<div id='content'>";
  358. echo "<div id='table1'>";
  359. echo "<table>";
  360. echo "<tr>";
  361. foreach($byDate as $key => $value) {
  362. echo "<td>";
  363. echo "<div class = 'date'>";
  364. echo "<a href='./date.php?date=".$key."' >";
  365. echo $days[date( "w", strtotime($key))]."</br>";
  366. echo $months[date( "m", strtotime($key))]." ".date( "d", strtotime($key))."</br></br>";
  367. echo "</a></div>";
  368. //array shift removes first value of array, which kept being current time for some reason.
  369. array_shift($value);
  370. //print out each event that occurs on day, as a link to more details
  371. foreach($value as $event){
  372. echo "<a href='./eventInfo.php?eid=".$event['eid']."'>".$event['name']."</a> ".date('g:i',strtotime($event['time']))."<br>";
  373. }
  374. echo "</td>";
  375. }
  376. echo "</tr>";
  377. echo "</table>";
  378. echo "</div>";
  379. echo "</div>";
  380. //Display events
  381. //echo "</br>Events in the Next 7 days: </br>";
  382. //while ($row = mysqli_fetch_array($result)) {
  383. //for each event, display its name as a link to detailed event info, with eid in the url
  384. // echo "<a href='./eventInfo.php?eid=".$row['eid']."'>".$row['name']."</a><br>";
  385. //}
  386. //view session data:
  387. //print_r($_SESSION);
  388. //close connection
  389. mysql_close($con);
  390. ?>
  391. </body>
  392. </html>