Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit 37f6050

Browse files
committed
Documented the code
1 parent cd8aa23 commit 37f6050

31 files changed

+326
-25
lines changed

about.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
<!DOCTYPE html>
1+
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* About page
8+
*/
9+
?><!DOCTYPE html>
210
<html lang="en"><head>
311
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
412
<meta charset="utf-8">

account.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Account Settings page
8+
*/
29
require_once('functions.php');
310
if(!loggedin())
411
header("Location: login.php");

admin/footer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Footer for all pages
8+
*/
9+
?>
110
<hr/>
211
<div class="footer">Powered by <a href="../about.php">Codejudge</a>.</div>
312
<!-- Le javascript

admin/header.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Common header for most files
8+
*/
9+
?>
110
<!DOCTYPE html>
211
<html lang="en"><head>
312
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

admin/index.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Codjudge admin panel
8+
*/
29
require_once('../functions.php');
310
if(!loggedin())
411
header("Location: login.php");

admin/login.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Codejudge Admin Login page
8+
*/
29
require_once('../functions.php');
310
if(loggedin() and $_SESSION['username'] == 'admin')
411
header("Location: index.php");
512
else if(isset($_POST['password'])) {
613
if(trim($_POST['password']) == "")
7-
header("Location: login.php?derror=1");
14+
header("Location: login.php?derror=1"); // empty entry
815
else {
16+
// code to login the user and start a session
917
connectdb();
1018
$query = "SELECT salt,hash FROM users WHERE username='admin'";
1119
$result = mysql_query($query);

admin/logout.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Logout Script
8+
*/
29
session_start();
310
$_SESSION=array();
411
if(isset($_COOKIE[session_name()])) {

admin/preview.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* PHP script that returns for AJAX requests
8+
*/
29
if($_POST['action'] == 'preview') {
10+
// preview for the markdown problem statement
311
if($_POST['title']=="" and $_POST['text']=="")
412
echo("<div class=\"alert alert-error\">You have not entered either the title or the problem text!</div>");
513
else {
@@ -9,6 +17,7 @@
917
echo($out);
1018
}
1119
} else if($_POST['action'] == 'code' and is_numeric($_POST['id'])) {
20+
// formatting for codes
1221
include('../functions.php');
1322
connectdb();
1423
echo("<hr/><h1><small>".$_POST['name']."</small></h1>\n");

admin/problems.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Problems adding or editing page
8+
*/
29
require_once('../functions.php');
310
if(!loggedin())
411
header("Location: login.php");
@@ -38,6 +45,7 @@
3845
<ul class="nav nav-list">
3946
<li class="nav-header">ADDED PROBLEMS</li>
4047
<?php
48+
// list all the problems
4149
$query = "SELECT * FROM problems";
4250
$result = mysql_query($query);
4351
if(mysql_num_rows($result)==0)
@@ -63,6 +71,7 @@
6371
<hr/>
6472
<?php
6573
if(isset($_GET['action']) and $_GET['action']=='edit') {
74+
// edit a selected problem
6675
?>
6776
<h1><small>Edit a Problem</small></h1>
6877
<form method="post" action="update.php">
@@ -91,7 +100,8 @@
91100
<input class="btn btn-danger btn-large" type="button" value="Delete Problem" onclick="window.location='update.php?action=delete&id='+$('#id').val();"/>
92101
</form>
93102
<div id="preview"></div>
94-
<?php }else {?>
103+
<?php }else { // add a problem
104+
?>
95105
<h1><small>Add a Problem</small></h1>
96106
<form method="post" action="update.php">
97107
<input type="hidden" name="action" value="addproblem"/>

admin/profile.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
/*
3+
* Codejudge
4+
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
5+
* Licensed under MIT License.
6+
*
7+
* Profileof the users
8+
*/
29
require_once('../functions.php');
310
if(!loggedin())
411
header("Location: login.php");
@@ -19,6 +26,7 @@
1926

2027
<div class="container">
2128
<?php
29+
// get the name, email and status
2230
$query = "SELECT email, status FROM users WHERE username='".$_GET['uname']."'";
2331
$result = mysql_query($query);
2432
$row = mysql_fetch_array($result);
@@ -35,6 +43,7 @@
3543
</tr></thead>
3644
<tbody>
3745
<?php
46+
// list all the problems attempted or solved
3847
$query = "SELECT problem_id, status, attempts FROM solve WHERE username='".$_GET['uname']."'";
3948
$result = mysql_query($query);
4049
while($row = mysql_fetch_array($result)) {

0 commit comments

Comments
 (0)