From: dinesh Date: Mon, 11 Aug 2008 03:55:49 +0000 (+0530) Subject: commiting ccan web pages X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=d2c982b37f3c4373e99e7c60c19d048de02b5919 commiting ccan web pages --- diff --git a/web/approval.php b/web/approval.php new file mode 100644 index 00000000..dc99ca7d --- /dev/null +++ b/web/approval.php @@ -0,0 +1,134 @@ +You donot have a rite to approve users"; + exit(); + } + + //extracting user information + $query = "SELECT * FROM users where username=\"$accountid\""; + $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle)); + if (($row = sqlite3_fetch_array($result)) == '') { + echo "
Not a valid account id
"; + exit(); + } + + $name = $row["name"]; + $email = $row["email"]; + $website = $row["website"]; + $desc = $row["description"]; + + if($row["approved"] == "true") { + $query = "SELECT * FROM approval where approved=\"$accountid\""; + $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle)); + $row = sqlite3_fetch_array($result); + echo "
Already $accountid is approved by ".$row["approvedby"]."...
"; + exit(); + } +?> +

Approval

+
+ + + + + + + + + + + + + + + + + + + + + + + +

Full name:

Account id:

Email:

+

Description:

Web Site:

Admin rites (check this if you want this user to be admin)
+

+ + + Successfully approved $accountid..."; +} + +//if approval is canceled +else if (isset($_POST['cancel'])) { +//delete user +$handle = sqlite3_open($db) or die("Could not open database"); +$query = "delete from users where username=\"$accountid\""; +$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle)); +echo "
Successfully cancelled $accountid...
"; +} + +function generate_passwd($length = 16) { + static $chars = '!@#$%^&*abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789'; + $chars_len = strlen($chars); + for ($i = 0; $i < $length; $i++) + $password .= $chars[mt_rand(0, $chars_len - 1)]; + return $password; +} +?> \ No newline at end of file diff --git a/web/ccan.jpg b/web/ccan.jpg new file mode 100644 index 00000000..babddac9 Binary files /dev/null and b/web/ccan.jpg differ diff --git a/web/changedetail.php b/web/changedetail.php new file mode 100644 index 00000000..0915d26d --- /dev/null +++ b/web/changedetail.php @@ -0,0 +1,107 @@ + 16) + $errmsg = 'Password should have length between 6 and 16'; + if($password != $repassword) + $errmsg = 'Password and retype password not match'; + } +} + +if(trim($errmsg) != '' || !isset($_POST['submit'])) { +?> +

Change CCAN account

+
+
Note: Please leave password fields blank if you donot want to change
+
+ + + + + + + + + + + + + + + + + + +

Full name:

Email:

New Password:

Retype Password:


+

Web Site[Optional]:


+
+
+
+ + + Sucessfully changed ".$ispass."... "; +} + +function isEmail($email) +{ + return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i" + ,$email)); +} +?> diff --git a/web/configuration b/web/configuration new file mode 100644 index 00000000..80c6b889 --- /dev/null +++ b/web/configuration @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/web/db/ccan b/web/db/ccan new file mode 100755 index 00000000..09af3764 Binary files /dev/null and b/web/db/ccan differ diff --git a/web/db/ccan.db b/web/db/ccan.db new file mode 100755 index 00000000..30078430 Binary files /dev/null and b/web/db/ccan.db differ diff --git a/web/dbfunc b/web/dbfunc new file mode 100644 index 00000000..99b33ea6 --- /dev/null +++ b/web/dbfunc @@ -0,0 +1,11 @@ + diff --git a/web/del.php b/web/del.php new file mode 100644 index 00000000..f494f223 --- /dev/null +++ b/web/del.php @@ -0,0 +1,43 @@ + diff --git a/web/dispmoduleinfo.php b/web/dispmoduleinfo.php new file mode 100644 index 00000000..b6f08172 --- /dev/null +++ b/web/dispmoduleinfo.php @@ -0,0 +1,48 @@ + + + + + + +
/.tar>Download/_dep.tar>Download Dependencies
+ + + + + + + + + + + + + + + + +

Module:

Title:

 

Author:

>

Description:


diff --git a/web/functions.php b/web/functions.php new file mode 100644 index 00000000..4228c3ae --- /dev/null +++ b/web/functions.php @@ -0,0 +1,42 @@ +read()) { + // Skip pointers + if ($entry == '.' || $entry == '..') { + continue; + } + + // Recurse + rmdirr($dirname . DIRECTORY_SEPARATOR . $entry); + } + + // Clean up + $dir->close(); + return rmdir($dirname); +} + +function getccanadmin($db) +{ + //forming admin mail addresses from data base + $handle = sqlite3_open($db) or die("Could not open database"); + $query = "SELECT email FROM users where admin=\"true\""; + $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle)); + + while ($row = sqlite3_fetch_array($result)) + $admin = $admin.$row[0].","; + return $admin; +} +?> \ No newline at end of file diff --git a/web/index.html b/web/index.html new file mode 100644 index 00000000..b3e3c954 --- /dev/null +++ b/web/index.html @@ -0,0 +1,10 @@ + + +ccan + + + + + + diff --git a/web/login.php b/web/login.php new file mode 100644 index 00000000..90488f91 --- /dev/null +++ b/web/login.php @@ -0,0 +1,105 @@ +
Already logged in as ".$_SESSION['susername']."...
"; + exit(); +} + +if(!isset($_POST['submit'])) { + include('logo.html'); + include('menulist.html'); + loginhtml("Members only. Please login to access."); + exit(); +} + +// get username and password +$username = $_POST['username']; +$password = $_POST['password']; + +// register username and logged as session variables. +session_register("susername"); +session_register("slogged"); + +//set session variables +$_SESSION["susername"] = $username; +$_SESSION["slogged"] = false; + +// open database file +$handle = sqlite3_open($db) or die("Could not open database"); +// query string +$query = "SELECT * FROM login where username=\"$username\""; +// execute query +$result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle)); +// if rows exist +if (($row = sqlite3_fetch_array($result)) != '') { + if(md5($password) == $row["password"]) + $valid_user = 1; +} +else { +$valid_user = 0; +} + +//if not valid user +if (!($valid_user)) { + // Unset session variables. + session_unset(); + include('logo.html'); + include('menulist.html'); + loginhtml("Incorrect login information, please try again. You must login to access."); + exit(); +} + +//if valid user +else { + $referer = $_GET['referer']; + $_SESSION["slogged"] = true; + if($referer != '') { + header('Location: '.$referer); + exit(); + } + include('logo.html'); + include('menulist.html'); + echo "
Logged in sucessfully..."; +} + + + +function loginhtml($info) +{ +?> +
" method="POST"> +

+ + + + + + + + + + + + +
+Username: + + +
+Password: + + +
+ + +

+ + + + diff --git a/web/logo.html b/web/logo.html new file mode 100644 index 00000000..7239556c --- /dev/null +++ b/web/logo.html @@ -0,0 +1,15 @@ + + +ccan + + + + + + + +
+ + +

Comprehensive C Archieve Network

+

\ No newline at end of file diff --git a/web/logout.php b/web/logout.php new file mode 100644 index 00000000..ef6a9d7f --- /dev/null +++ b/web/logout.php @@ -0,0 +1,13 @@ +
Logged out Successfully...
"; +else + echo "
Please login...
"; + +session_destroy(); +?> \ No newline at end of file diff --git a/web/menulist.html b/web/menulist.html new file mode 100644 index 00000000..6e7e63b0 --- /dev/null +++ b/web/menulist.html @@ -0,0 +1,30 @@ + + + + + + + + + +
Welcome ! + Login + + + Request CCAN account + + + Change CCAN account detail + + + Upload Code + + + Search CCAN + + + Logout +
+
\ No newline at end of file diff --git a/web/reponse.html b/web/reponse.html new file mode 100644 index 00000000..0299cf14 --- /dev/null +++ b/web/reponse.html @@ -0,0 +1,7 @@ + + +CCAN Request Account + + + Thank you for registering with CCAN. You will get the password to your after approval. + diff --git a/web/requestid.php b/web/requestid.php new file mode 100644 index 00000000..eedada53 --- /dev/null +++ b/web/requestid.php @@ -0,0 +1,94 @@ + 16) { + $errmsg = 'account id should have length between 4 and 16'; + } + else if(trim($accountid) != '') { + $handle = sqlite3_open($db) or die("Could not open database"); + $query = "SELECT * FROM users where username=\"$accountid\""; + $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle)); + + if (($row = sqlite3_fetch_array($result)) != '') { + $errmsg = 'Desired id already exist. Please enter different Desired id.'; + } + } + else if(trim($description) == '') { + $errmsg = 'Please enter your description'; + } + else if(strlen($description) < 20) { + $errmsg = 'Description should atleast be 20 characters'; + } +} + +if(trim($errmsg) != '' || !isset($_POST['submit'])) { +?> +

Request CCAN account

+
+
+ + + + + + + + + + + + + + + + + + + +

Full name:

Email:


Desired ID:


Web Site[Optional]:


A short description of what you are planning to contribute:

+

+
+

+ +
Thank you for registering with CCAN. You will get the password to your mail after approval.
+ diff --git a/web/search.html b/web/search.html new file mode 100644 index 00000000..3a497b9f --- /dev/null +++ b/web/search.html @@ -0,0 +1,27 @@ +
+ + + + + + + + + + + +
+ Search ccan repository: + +

+
+

+

+
+ + Display all
+
diff --git a/web/search.php b/web/search.php new file mode 100644 index 00000000..d0c55330 --- /dev/null +++ b/web/search.php @@ -0,0 +1,40 @@ +Please enter some keyword to search
'; + exit(); + } +} +else if($_GET['author'] != '') { + $searchtext = $_GET['author']; + $in = "author"; +} +else if ($_GET['disp'] == 'all') { + $searchtext = ""; + $in = "module"; +} +else + exit(); + +$result = searchdb($searchtext, $in, $db); +echo ''; +if($row = sqlite3_fetch_array($result)) + echo ""; +else + echo '
No results found
'; +while($row = sqlite3_fetch_array($result)) { + echo ""; +} +echo '
".$row["module"]."
". + "".$row["author"]." : ". $row["title"]."

".$row["module"]."
". + "".$row["author"]." : ". $row["title"]."

'; +?> diff --git a/web/searchengine.php b/web/searchengine.php new file mode 100644 index 00000000..6117f38b --- /dev/null +++ b/web/searchengine.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/web/tools/ccanlint b/web/tools/ccanlint new file mode 100755 index 00000000..f8706246 Binary files /dev/null and b/web/tools/ccanlint differ diff --git a/web/tools/create_dep_tar b/web/tools/create_dep_tar new file mode 100755 index 00000000..50234d80 Binary files /dev/null and b/web/tools/create_dep_tar differ diff --git a/web/tools/infotojson b/web/tools/infotojson new file mode 100755 index 00000000..9ceaa2fa Binary files /dev/null and b/web/tools/infotojson differ diff --git a/web/upload.php b/web/upload.php new file mode 100644 index 00000000..1a83d958 --- /dev/null +++ b/web/upload.php @@ -0,0 +1,31 @@ + + +

Upload Code

+ + +
+

+

+ + + + + + + + +
+ + Choose a file to upload: + +
+
+
+
+ diff --git a/web/uploader.php b/web/uploader.php new file mode 100644 index 00000000..467c51c0 --- /dev/null +++ b/web/uploader.php @@ -0,0 +1,133 @@ + 0) { + echo "Error: " . $_FILES["uploadedfile"]["error"] . "
"; + exit(); +} + +//list of file types supported +if($_FILES["uploadedfile"]["type"] == "application/x-gzip" + || $_FILES["uploadedfile"]["type"] == "application/x-tar" + || $_FILES["uploadedfile"]["type"] == "application/x-bzip" + || $_FILES["uploadedfile"]["type"] == "application/zip") { + + $folder = substr($_FILES["uploadedfile"]["name"], 0, strpos($_FILES["uploadedfile"]["name"],'.')); + move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], + $tempfolder . $_FILES["uploadedfile"]["name"]); + + //extracting code + if($_FILES["uploadedfile"]["type"] == "application/zip") { + exec('unzip '.$tempfolder.$_FILES["uploadedfile"]["name"].' -d '.$tempfolder, $op, $status); + } + else { + exec('tar -xf '.$tempfolder.$_FILES["uploadedfile"]["name"].' -C '.$tempfolder, $op, $status); + } + checkerror($status[0],"Error: cannot extract(tar error)."); + + //chmod + exec('chmod -R 0777 '. $tempfolder.$folder, $status); + checkerror($status[0],"Error: chmod execution error."); + + //running ccanlint + exec($ccanlint.$tempfolder.$folder, $score, $status); + //checkerror($status,"Error: ccanlint execution error."); + + //if user not logged in + if($_SESSION["slogged"] == false) { + //move to temp folder + if (file_exists($temprepo . $folder)) + rmdirr($temprepo.$folder); + rename($tempfolder.$folder, $temprepo.$folder); + + //send mail for review to admins + $subject = "Review: code upload at temporary repository"; + $message = "Some developer has uploaded code who has not logged in.\n\nModule is stored in ".$temprepo.$folder.".\n\nOutput of ccanlint: \n"; + foreach($score as $disp) + $message = $message.$disp."\n"; + + $toaddress = getccanadmin($db); + mail($toaddress, $subject, $message, "From: $frommail"); + echo "
Stored to temporary repository. Mail will be send to admin to get verification of the code."; + unlink($tempfolder.$_FILES["uploadedfile"]["name"]); + exit(); + } + + //if not junk code + if($status == 0) { + $rename = $folder; + //if module already exist + if (file_exists($repopath.$ccan_home_dir . $folder)) { + // if owner is not same + if(!(getowner($repopath.$ccan_home_dir.$folder, $db) == $_SESSION['susername'])) { + if(!file_exists($repopath . $ccan_home_dir. $folder.'-'.$_SESSION['susername'])) + echo "
".$repopath . $ccan_home_dir. $folder . " already exists. Renaming to ". $folder."-".$_SESSION['susername']."
"; + else + echo "
".$repopath . $ccan_home_dir. $folder."-".$_SESSION['susername'] . " already exists. Overwriting ". $folder."-".$_SESSION['susername']."
"; + $rename = $folder."-".$_SESSION['susername']; + } + else + echo "
".$repopath. $ccan_home_dir. $folder. " already exists(uploaded by you). Overwriting ". $repopath. $folder."
"; + } + //module not exist. store author to db + else { + storefileowner($repopath . $ccan_home_dir. $folder, $_SESSION['susername'], $db); + } + rmdirr($repopath. $ccan_home_dir. $rename); + rename($tempfolder.$folder, $repopath. $ccan_home_dir. $rename); + echo "
Stored to ".$repopath . $ccan_home_dir. $rename . "
"; + + exec($infotojson . $repopath. $ccan_home_dir. $rename."/_info.c ". $repopath. $ccan_home_dir. $rename."/json_".$rename. " ". $_SESSION['susername']." ".$db, $status); + checkerror($status[0],"Error: In infotojson."); + //createsearchindex($rename, $repopath.$rename, $infofile, $db, $_SESSION['susername']); + } + + //if junk code (no _info.c etc) + else { + rmdirr($junkcode.$folder.'-'.$_SESSION['susername']); + rename($tempfolder.$folder, $junkcode.$folder.'-'.$_SESSION['susername']); + if($score == '') + $msg = 'Below is details for test.'; + echo "
Score for code is low. Cannot copy to repository. Moving to ". $junkcode.$folder.'-'.$_SESSION['susername']."...

". $msg ."

"; + foreach($score as $disp) + echo "$disp
"; + echo "
"; + } + unlink($tempfolder.$_FILES["uploadedfile"]["name"]); +} +else { + echo "
File type not supported
"; + exit(); +} + +function checkerror($status, $msg) +{ + if($status != 0) { + echo "
" . $msg . "Contact ccan admin.
"; + exit(); + } +} + +function getowner($filename, $db) +{ + //getting owner of a file stored at db + $handle = sqlite3_open($db) or die("Could not open database"); + $query = "SELECT owner FROM fileowner users where filename=\"$filename\""; + $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle)); + $row = sqlite3_fetch_array($result); + return $row["owner"]; +} + +function storefileowner($filename, $owner, $db) +{ + //storing owner of a file stored at db + $handle = sqlite3_open($db) or die("Could not open database"); + $query = "insert into fileowner values(\"$filename\", \"$owner\")"; + $result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle)); +} +?> \ No newline at end of file