commiting ccan web pages
authordinesh <dinesh@dinesh-laptop>
Mon, 11 Aug 2008 03:55:49 +0000 (09:25 +0530)
committerdinesh <dinesh@dinesh-laptop>
Mon, 11 Aug 2008 03:55:49 +0000 (09:25 +0530)
25 files changed:
web/approval.php [new file with mode: 0644]
web/ccan.jpg [new file with mode: 0644]
web/changedetail.php [new file with mode: 0644]
web/configuration [new file with mode: 0644]
web/db/ccan [new file with mode: 0755]
web/db/ccan.db [new file with mode: 0755]
web/dbfunc [new file with mode: 0644]
web/del.php [new file with mode: 0644]
web/dispmoduleinfo.php [new file with mode: 0644]
web/functions.php [new file with mode: 0644]
web/index.html [new file with mode: 0644]
web/login.php [new file with mode: 0644]
web/logo.html [new file with mode: 0644]
web/logout.php [new file with mode: 0644]
web/menulist.html [new file with mode: 0644]
web/reponse.html [new file with mode: 0644]
web/requestid.php [new file with mode: 0644]
web/search.html [new file with mode: 0644]
web/search.php [new file with mode: 0644]
web/searchengine.php [new file with mode: 0644]
web/tools/ccanlint [new file with mode: 0755]
web/tools/create_dep_tar [new file with mode: 0755]
web/tools/infotojson [new file with mode: 0755]
web/upload.php [new file with mode: 0644]
web/uploader.php [new file with mode: 0644]

diff --git a/web/approval.php b/web/approval.php
new file mode 100644 (file)
index 0000000..dc99ca7
--- /dev/null
@@ -0,0 +1,134 @@
+<?php
+session_start();
+if($_SESSION["slogged"] == false) {
+       header('Location: login.php?referer=approval.php?accountid='.$_GET['accountid']);
+       exit();
+}
+
+include('logo.html');
+include('menulist.html');
+include('configuration');
+$accountid = $_GET['accountid'];
+$username = $_SESSION['susername'];
+
+if(!isset($_POST['submit']) && !isset($_POST['cancel']))
+{
+       //checking for admin rites
+       $handle =       sqlite3_open($db) or die("Could not open database");
+       $query = "SELECT * FROM users where username=\"$username\"";
+       $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+       $row = sqlite3_fetch_array($result);
+       if ($row["admin"] == "false") { 
+       echo "<div align=\"center\">You donot have a rite to approve users</div>";
+       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 "<div align=\"center\">Not a valid account id</div>";
+       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 "<div align=\"center\"> Already <b>$accountid</b> is approved by <b>".$row["approvedby"]."</b>...</div>";
+               exit();
+       }
+?>
+       <h3 class="firstheader" align="center">Approval</h3>
+       <form method="post" action="approval.php?accountid=<?=$accountid?>" >
+       <table align="center" border="0" cellpadding="10" bgcolor="gray">
+                       <tr align="left" bgcolor="lightgray">
+                       <td>    <p>Full name: </td><td><?=$name;?></p></td>
+       </tr>
+       <tr align="left" bgcolor="silver">
+                       <td>    <p>Account id: </td><td><?=$accountid;?></p></td>
+       </tr>
+                       <tr align="left" bgcolor="lightgray">
+                       <td> <p>Email: </td><td><?=$email;?></p>
+       </td>
+       </tr>
+                       <tr align="left" bgcolor="silver">
+                       <td> <p>Description: </td><td><?=$desc;?></p> </td>
+       </tr>
+                       <tr align="left" bgcolor="lightgray">
+                       <td> <p>Web Site: </td><td><?=$website;?></p> </td>
+       </tr>
+       <tr align="left" bgcolor="lightgray">
+                       <td>Admin rites</td><td><input type="checkbox" name="isadmin"> (check this if you want this user to be admin) </td>
+       </tr>
+                       <tr align="center">
+                       <td> <input type="submit" name="submit" value="Approve"/></td>
+                       <td><input type="submit" name="cancel" value="Cancel Approval"/></td>
+       </tr>
+       </table>
+       </form><hr>
+       </body>
+       </html>
+<?php
+}
+
+//if approved 
+else if (isset($_POST['submit'])) {
+//set approval=true
+$handle = sqlite3_open($db) or die("Could not open database");
+$query = "update users set approved=\"true\" where username=\"$accountid\"";
+$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+
+//where whether user is given admin permission 
+if($_POST['isadmin']) {
+$query = "update users set admin=\"true\" where username=\"$accountid\"";
+$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+}
+
+//inserting to db 
+$query = "insert into approval values(\"$accountid\",\"$username\")";
+$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+
+//get email id
+$query = "SELECT * FROM users where username=\"$accountid\"";
+$result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+$row = sqlite3_fetch_array($result);
+$email = $row["email"];
+
+//generate password and send mail
+$password = generate_passwd(8);
+$subject = "Approval of ccan account";
+$message = "Your request for ccan account id is being approved.\n\n Please use the following password to login\n Password: ".$password;
+$password = md5($password);
+
+//insert password 
+$query = "insert into login (username,password) values(\"$accountid\",\"$password\")";
+$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+
+//sendmail 
+mail($email, $subject, $message, "From: $frommail");
+echo "<div align=center> Successfully approved <b>$accountid</b>...</div>";
+}
+
+//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 "<div align=center> Successfully cancelled <b>$accountid</b>...</div>";
+}
+
+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 (file)
index 0000000..babddac
Binary files /dev/null and b/web/ccan.jpg differ
diff --git a/web/changedetail.php b/web/changedetail.php
new file mode 100644 (file)
index 0000000..0915d26
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+session_start(); // start session.
+if($_SESSION["slogged"] == false) {
+       header('Location: login.php?referer=changedetail.php');
+       exit();
+}
+
+else {
+include('logo.html');
+include('menulist.html');
+include('configuration');
+
+//get account data 
+$handle = sqlite3_open($db) or die("Could not open database");
+$accountid = $_SESSION['susername'];
+$query = "SELECT * FROM users where username=\"$accountid\"";
+$result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+
+$row = sqlite3_fetch_array($result);
+$name = $row["name"];
+$email = $row["email"];
+$website = $row["website"];
+$password = '';
+$repassword = '';
+}
+
+if(isset($_POST['submit'])) {
+       $name = $_REQUEST['name'];
+       $email = $_REQUEST['email'];
+       $website = $_REQUEST['website'];
+       $password = $_REQUEST['password'];
+       $repassword = $_REQUEST['repassword'];
+       if(trim($name) == '') { 
+               $errmsg = 'Please enter your name';
+       } 
+
+       else if(trim($email) == '') {
+               $errmsg = 'Please enter your email address';
+       }
+
+       else if(!isEmail($email)) {
+               $errmsg = 'Your email address is not valid';
+       }
+
+       if($password != '' || $repassword != '') {
+               if(strlen($password) < 6 || strlen($password) > 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'])) {
+?>
+               <h3 class="firstheader" align="center">Change CCAN account</h3>
+               <div align="center" class="errmsg"><font color="RED"><?=$errmsg;?></font></div>
+               <div align="center">Note: Please leave password fields blank if you donot want to change</div>
+               <form method="post" align="center" action="changedetail.php">
+               <table align="center" width="70%" border="0" bgcolor="gray" cellpadding="8" cellspacing="1">
+               <tr align="left" bgcolor="lightgray">
+               <td><p>Full name: </p><p><input name="name" type="text" value="<?=$name;?>"/></p></td
+               </tr>
+               <tr align="left" bgcolor="silver">
+               <td><p>Email: </p><p><input name="email" type="text" value="<?=$email;?>"/> </p></td>
+               </tr>
+               <tr align="left" bgcolor="lightgray">
+               <td><p>New Password: </p><p><input name="password" type="password" value="<?=$password;?>"/></p></td>
+               </tr>
+               <tr align="left" bgcolor="silver">
+               <td><p>Retype Password: </p><p><input name="repassword" type="password" value="<?=$repassword;?>"/><br /></p>
+               </td>
+               </tr>
+               <tr align="left" bgcolor="lightgray">
+               <td><p>Web Site[Optional]: </p><p><input name="website" type="text" value="<?=$website;?>"/><br /></p>
+               </td>
+               </tr>
+               <tr align="center">
+               <td><input type="submit" name="submit" value="Change Account"/></td>
+               </tr>
+               </table>
+               </form>
+               <hr>
+               </body>
+               </html>
+<?php
+}
+else {
+$handle = sqlite3_open($db) or die("Could not open database");
+$query = "update users set name=\"".$name."\",email=\"".$email."\",website=\"".$website."\" where username=\"$accountid\"";
+$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+$ispass = '';
+if($password != '' && $repassword != '' && $password == $repassword ) {
+       $password = md5($password);
+       $query = "update login set password=\"$password\" where username=\"$accountid\"";
+       $result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+       $ispass = "password. Please login again";
+       session_destroy();
+}
+echo "<div align=\"center\"> Sucessfully changed ".$ispass."... <//div><//body><//html>";
+}
+
+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 (file)
index 0000000..80c6b88
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+//path for db
+$db = "db/ccan.db";
+
+//path for repository
+$repopath = "testrepo/";
+
+//ccanlint
+$ccanlint = "tools/ccanlint -d ";
+
+//infotojson 
+$infotojson = "tools/infotojson ";
+
+//create tar of all dependencies
+$create_dep_tar = "../tools/create_dep_tar ";
+
+//junk code
+$junkcode = "junkcode/";
+
+//temp folder
+$tempfolder = "temp/";
+
+//infofile
+$infofile = '/_info.c';
+
+//temp repo
+$temprepo = "temprepo/";
+
+//email from 
+$frommail = "ccan@ozlabs.org";
+
+//email for admins
+$ccan_admin = "g.dinesh.cse@gmail.com";
+
+$ccan_home_dir = "ccan/";
+?>
\ No newline at end of file
diff --git a/web/db/ccan b/web/db/ccan
new file mode 100755 (executable)
index 0000000..09af376
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 (executable)
index 0000000..3007843
Binary files /dev/null and b/web/db/ccan.db differ
diff --git a/web/dbfunc b/web/dbfunc
new file mode 100644 (file)
index 0000000..99b33ea
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+function sqlite3_num_rows($dbRes) 
+{ 
+       $n = 0; 
+       while(sqlite3_fetch_array($dbRes) != '') 
+       { 
+               $n = $n + 1; 
+       } 
+       return $n; 
+} 
+?>
diff --git a/web/del.php b/web/del.php
new file mode 100644 (file)
index 0000000..f494f22
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+function createsearchindex($module, $path, $infofile, $db, $user) 
+{
+       $fh = fopen($path.$infofile, 'r') or die("Can't open file");
+
+       $title = extract_title($fh);
+       $desc = extract_desc($fh);
+       //foreach($desc as $temp)
+       //              $alldesc = $alldesc.$temp.'\n';
+       $author = $user;
+               
+       //storing in search db 
+       $handle = sqlite3_open($db) or die("Could not open database");
+       $query = "select * from search where module=\"$module\"";       
+       $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+       
+       if (($row = sqlite3_fetch_array($result)) == '') { 
+               $query = "insert into search values(\"$module\",\"$user\",\"$title\",\"$alldesc\");";
+       }
+       else {
+               $query = "update search set title=\"$title\", desc=\"$alldesc\" where module=\"$module\";";
+       }
+       $result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+       fclose($fh);
+}
+
+function extract_title($fh)
+{
+       while(substr(fgets($fh), 0, 3) != '/**');
+       
+       return substr(strstr(fgets($fh),'*'),1);
+}
+
+function extract_desc($fh)
+{
+$i = 0;
+       while(substr(($line = fgets($fh)), 0, 2) == ' *') {
+               $desc[$i] = substr(strstr($line,'*'),1);;
+               $i = $i + 1;
+                       }
+       return $desc;
+}
+?>
diff --git a/web/dispmoduleinfo.php b/web/dispmoduleinfo.php
new file mode 100644 (file)
index 0000000..b6f0817
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+session_start();
+include('logo.html');
+include('menulist.html');
+include('configuration');
+include('search.html');
+$handle = sqlite3_open($db) or die("Could not open database");
+$query = "select * from search where module=\"".$_GET['module']."\"";
+$result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+$row = sqlite3_fetch_array($result);
+
+if (!file_exists($repopath . $ccan_home_dir.$_GET['module']."/".$_GET['module'].".tar")) {
+       chdir($repopath);
+       exec("tar -cvvf ".$ccan_home_dir. $_GET['module']. "/". $_GET['module'].".tar ". $ccan_home_dir.$_GET['module'], $status);
+       chdir("..");
+}
+
+if (!file_exists($repopath . $ccan_home_dir.$_GET['module']."/".$_GET['module']."_dep.tar")) {
+       chdir($repopath);
+       exec($create_dep_tar." ".$ccan_home_dir.$_GET['module'], $status);
+       chdir("..");
+}
+
+
+?>
+<table align="center" bgcolor="lightblue" width="70%" border="0" cellpadding="3" cellspacing="1">
+<tr align="center" bgcolor="FFFFCC">
+<td width="50%"><a href=<?=$repopath . $ccan_home_dir.$_GET['module']?>/<?=$_GET['module']?>.tar>Download</a></td>
+<td><a href=<?=$repopath . $ccan_home_dir.$_GET['module']?>/<?=$_GET['module']?>_dep.tar>Download Dependencies</a></td>
+</tr>
+</table>
+<table align="center" bgcolor="lightblue" width="70%" border="0" cellpadding="8" cellspacing="1">
+<tr align="left" bgcolor="FFFFCC">
+<td><h3>Module: </h3> <pre><?=$row['module'];?></pre> </td>
+</tr>
+
+<tr align="left" bgcolor="FFFFCC">
+<td><h3>Title: </h3> <pre><?=$row['title'];?> </pre></td>
+</tr>
+               
+<tr align="left" bgcolor="FFFFCC"> 
+<td><h3>Author: </h3> <pre><a href=search.php?author=<?=$row['author'];?>><?=$row['author'];?></a></pre></td>
+</tr>
+
+<tr align="left" bgcolor="FFFFCC">
+<td><h3>Description: </h3> <pre><?=$row['desc'];?></pre></td>
+</tr>
+</table><hr>
diff --git a/web/functions.php b/web/functions.php
new file mode 100644 (file)
index 0000000..4228c3a
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+function rmdirr($dirname)
+{
+    // Sanity check
+    if (!file_exists($dirname)) {
+        return false;
+    }
+    // Simple delete for a file
+    if (is_file($dirname) || is_link($dirname)) {
+        return unlink($dirname);
+    }
+    // Loop through the folder
+    $dir = dir($dirname);
+    while (false !== $entry = $dir->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 (file)
index 0000000..b3e3c95
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+<title>ccan</title>
+</head>
+<body>
+<META HTTP-EQUIV="Refresh"
+      CONTENT="0; URL=login.php">
+</body>
+</html>
+
diff --git a/web/login.php b/web/login.php
new file mode 100644 (file)
index 0000000..90488f9
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+session_start(); // start session.
+include('configuration');
+
+if($_SESSION['slogged'] != ''){
+       include('logo.html');
+       include('menulist.html');
+       echo "<br><div align=\"center\">Already logged in as ".$_SESSION['susername']."...</div>";
+       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 "<br><div align=\"center\">Logged in sucessfully...<//div><//body><//html>";
+}
+
+
+
+function loginhtml($info)
+{
+?>
+<form action="<?=$PHP_SELF.$referer?><?if($QUERY_STRING){ echo"?". $QUERY_STRING;}?>" method="POST">
+<p align="center"><?=$info?></p>
+<table align="center" border="0">
+ <tr>
+  <th>
+Username:
+  </th>
+  <th>
+<input type="text" name="username">
+  </th>
+ </tr>
+ <tr>
+  <th>
+Password:
+  </th>
+  <th>
+<input type="password" name="password">
+  </th>
+ </tr>
+ <tr>
+  <th colspan="2" align="right">
+<input type="submit" name="submit" value="Login">
+</form>
+  </th>
+ </tr>
+</table><hr>
+</body>
+</html>
+<?php
+}
+?>
+
diff --git a/web/logo.html b/web/logo.html
new file mode 100644 (file)
index 0000000..7239556
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>ccan</title>
+<head>
+<body bgcolor="FFFFCC">
+<table align="center" width="100%" bgcolor="FFFFFF">
+ <tr>
+  <th>
+       <img src="ccan.jpg" width="250" height="80">
+  </th>
+  <th>
+       <h1>Comprehensive C Archieve Network <h1>
+  </th>
+ </tr>
+</table>
\ No newline at end of file
diff --git a/web/logout.php b/web/logout.php
new file mode 100644 (file)
index 0000000..ef6a9d7
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+session_start();
+
+include('logo.html');
+include('menulist.html');
+
+if($_SESSION['slogged'] != '')
+       echo "<br><div align=\"center\">Logged out Successfully...</div>";
+else
+   echo "<br><div align=\"center\">Please login...</div>";
+
+session_destroy();
+?>
\ No newline at end of file
diff --git a/web/menulist.html b/web/menulist.html
new file mode 100644 (file)
index 0000000..6e7e63b
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+session_start();
+?>
+<table align="center" width="100%" cellpadding="4" cellspacing="1" border="0" bgcolor="lightblue">
+ <tr align="left" bgcolor="CCFFCC" ><td>Welcome <?=$_SESSION['susername']?>! </td>
+  <td align="center">
+       <a href="login.php">    Login</a>
+  </td>
+  <td align="center">  
+       <a href="requestid.php">
+       Request CCAN account</a>
+  </td>        
+  <td align="center">
+       <a href="changedetail.php">
+       Change CCAN account detail</a>
+  </td>
+  <td align="center">
+       <a href="upload.php">
+       Upload Code</a>
+  </td>
+  <td align="center">
+       <a href="search.php">
+       Search CCAN</a>
+  </td>
+  <td align="center"> 
+       <a href="logout.php">
+       Logout</a>
+  </td>
+</table>
+<hr>
\ No newline at end of file
diff --git a/web/reponse.html b/web/reponse.html
new file mode 100644 (file)
index 0000000..0299cf1
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+<head>
+<title>CCAN Request Account</title>
+</head>
+<body>
+<b> Thank you for registering with CCAN. You will get the password to your after approval.</b>
+</body>
diff --git a/web/requestid.php b/web/requestid.php
new file mode 100644 (file)
index 0000000..eedada5
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+session_start();
+include('logo.html');
+include('menulist.html');
+include('configuration');
+
+if(isset($_POST['submit'])) {
+       $name = $_REQUEST['name'];
+       $email = $_REQUEST['email'];
+       $website = $_REQUEST['website'];
+       $accountid = $_REQUEST['accountid'];
+       $description = $_REQUEST['description'];
+       if(trim($name) == '') {
+               $errmsg = 'Please enter your name';
+       }
+       else if(trim($email) == '') {
+               $errmsg = 'Please enter your email address';
+       }
+       else if(!isEmail($email)) {
+               $errmsg = 'Your email address is not valid';
+       }
+       else if(trim($accountid) == '') {
+               $errmsg = 'Please enter your account id';
+       }       
+       else if(strlen($accountid) < 4 || strlen($accountid) > 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'])) {
+?>
+               <h3 class="firstheader" align="center">Request CCAN account</h3> 
+               <div align="center" class="errmsg"><font color="RED"><?=$errmsg;?></font></div>
+               <form method="post" action="requestid.php">
+               <table align="center" width="70%" border="0" bgcolor="999999" cellpadding="4" cellspacing="1">
+               <tr align="left" bgcolor="lightgray">
+               <td> <p>Full name: </p> <p><input name="name" type="text" value="<?=$name;?>"/></p> </td>
+               </tr>
+               <tr align="left" bgcolor="silver">
+               <td> <p>Email: </p>     <p><input name="email" type="text" value="<?=$email;?>"/> <br /></p>    </td>
+               </tr>
+               <tr align="left" bgcolor="lightgray">
+               <td> <p>Desired ID: </p><p><input name="accountid" type="text" value="<?=$accountid;?>"/><br /></p></td>
+               </tr>
+               <tr align="left" bgcolor="silver">
+               <td><p> Web Site[Optional]: </p><p><input name="website" type="text" value="<?=$website;?>"/><br /></p></td>
+               </tr>
+               <tr align="left" bgcolor="lightgray">
+               <td><p> A short description of what you are planning to contribute: </p>
+                       <p><textarea name="description" rows="10" cols="70" value="<?=$description;?>"> </textarea></p>
+               </td>
+               </tr>
+               <tr align="center">
+               <td> <input type="submit" name="submit" value="Request Account"/> </td>
+               </tr>
+               </table>
+               </form><hr>
+<?php
+}
+
+else {
+$handle = sqlite3_open($db) or die("Could not open database");
+$query = "insert into users values(\"".$name."\",\"".$email."\",\"".$accountid."\",\"".$website."\",\"".$description."\",\"false\" ,\"false\")";
+$result = sqlite3_exec($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+
+$subject = "Approval of ccan account";
+$message = "There is new request for ccan account id.\n\n Please use the following link to approve http://ccan.ozlabs.org/dinesh/approval.php?accountid=".$accountid;
+mail($ccan_admin, $subject, $message, "From: $email");
+?>
+       </br><div>Thank you for registering with CCAN. You will get the password to your mail after approval.</div>
+<?php
+}
+
+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/search.html b/web/search.html
new file mode 100644 (file)
index 0000000..3a497b9
--- /dev/null
@@ -0,0 +1,27 @@
+               <form method="post" action="search.php">
+               <table align="center">
+               <tr align="left">
+               <td>
+                       Search ccan repository:
+               </td>
+               <td>
+                               <p><input name="searchtext" type="text"/></p>
+               </td>
+               <td>
+                               <p> <select name="searchmenu">
+                                               <option value="all">All  </option>
+                                               <option value="author">Author   </option>
+                                               <option value="module">Module title   </option>
+                                        </select>
+                               </p>
+               </td>
+               </tr>
+               <tr align="center">
+               <td></td>
+               <td align="right">
+                               <input type="submit" name="search" value="Search"/>
+               </td>
+               <td align="left"><a href=search.php?disp=all>Display all</a></td>
+               </tr>
+               </table>
+               </form>
diff --git a/web/search.php b/web/search.php
new file mode 100644 (file)
index 0000000..d0c5533
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+session_start();
+include('logo.html');
+include('menulist.html');
+include('configuration');
+include('searchengine.php');
+include('search.html');
+
+if(isset($_POST['search'])) {
+       $searchtext = $_REQUEST['searchtext'];
+       $in = $_REQUEST['searchmenu'];
+       if(trim($searchtext) == '') { 
+               echo '<div align="center"><font color="RED">Please enter some keyword to search</font></div>';
+               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 '<table align="left" border="0" cellpadding="8" cellspacing="1">';
+if($row = sqlite3_fetch_array($result)) 
+       echo "<tr><td><a href=\"dispmoduleinfo.php?module=".$row['module']."\">".$row["module"]."</a></br>".
+                "<a href=\"search.php?author=".$row["author"]."\">".$row["author"]."</a> : ". $row["title"]." </br> </br></td></tr>";
+else
+       echo '<div align="center"><font color="RED"> No results found</font></div>';
+while($row = sqlite3_fetch_array($result)) {   
+       echo "<tr><td><a href=\"dispmoduleinfo.php?module=".$row['module']."\">".$row["module"]."</a></br>".
+                "<a href=\"search.php?author=".$row["author"]."\">".$row["author"]."</a> : ". $row["title"]." </br> </br></td></tr>";
+}
+echo '</table>';
+?>
diff --git a/web/searchengine.php b/web/searchengine.php
new file mode 100644 (file)
index 0000000..6117f38
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+function searchdb($text, $in, $db)
+{
+       //search db 
+       $handle = sqlite3_open($db) or die("Could not open database");
+       if($in == 'module')
+               $query = "select * from search where title LIKE \"%$text%\"";
+       else if($in == 'author')
+               $query = "select * from search where author LIKE \"%$text%\"";
+       else    
+               $query = "select * from search where title LIKE \"%$text%\" or author LIKE \"%$text%\"";
+               
+       $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
+       return $result;
+}
+
+?>
\ No newline at end of file
diff --git a/web/tools/ccanlint b/web/tools/ccanlint
new file mode 100755 (executable)
index 0000000..f870624
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 (executable)
index 0000000..50234d8
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 (executable)
index 0000000..9ceaa2f
Binary files /dev/null and b/web/tools/infotojson differ
diff --git a/web/upload.php b/web/upload.php
new file mode 100644 (file)
index 0000000..1a83d95
--- /dev/null
@@ -0,0 +1,31 @@
+<?php 
+session_start();
+
+include('logo.html');
+include('menulist.html');
+include('configuration');
+?>
+<html>
+<h3 align="center"> Upload Code</h3>
+<table width="80%" align="center">
+<tr>
+<th>
+<p>
+<form enctype="multipart/form-data" action="uploader.php" method="POST">
+<table align="center">
+<tr align="left">
+<td>
+       <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
+       Choose a file to upload:
+</td>
+<td>
+<input name="uploadedfile" type="file" /><br />
+</td>
+</tr>
+<td></td>
+<td><input type="submit" value="Upload File" /></td>
+</tr>
+</table>
+</form>
+<hr>
+</html>
diff --git a/web/uploader.php b/web/uploader.php
new file mode 100644 (file)
index 0000000..467c51c
--- /dev/null
@@ -0,0 +1,133 @@
+<?php
+session_start();
+include('logo.html');
+include('menulist.html');
+include('configuration');
+include('functions.php');
+include('searchengine.php');
+
+if ($_FILES["uploadedfile"]["error"] > 0) {
+  echo "Error: " . $_FILES["uploadedfile"]["error"] . "<br />";
+  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 "<div align=\"center\"> Stored to temporary repository. Mail will be send to admin to get verification of the code.<//div>";
+       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 "<div align=\"center\">".$repopath . $ccan_home_dir. $folder . " already exists. Renaming to ". $folder."-".$_SESSION['susername']."</div>";
+               else
+                               echo "<div align=\"center\">".$repopath . $ccan_home_dir. $folder."-".$_SESSION['susername'] . " already exists. Overwriting ". $folder."-".$_SESSION['susername']."</div>";
+                       $rename = $folder."-".$_SESSION['susername'];
+               }
+               else
+                       echo "<div align=\"center\">".$repopath. $ccan_home_dir. $folder. " already exists(uploaded by you). Overwriting ". $repopath. $folder."</div>";        
+               }
+               //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 "<div align=\"center\"> Stored to ".$repopath . $ccan_home_dir. $rename . "</div>";
+               
+               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 "<div align=\"center\"><table><tr><td> Score for code is low. Cannot copy to repository. Moving to ". $junkcode.$folder.'-'.$_SESSION['susername']."... </br></br>". $msg ." </br></br></td></tr><tr><td>";
+               foreach($score as $disp)
+                       echo "$disp</br>";
+               echo "</td></tr></table></div>";
+       }
+       unlink($tempfolder.$_FILES["uploadedfile"]["name"]);
+}
+else {
+       echo "<div align=\"center\"> File type not supported </div>";
+       exit();
+} 
+
+function checkerror($status, $msg)
+{
+       if($status != 0) {
+                   echo "<div align=\"center\">" . $msg . "Contact ccan admin. </div>";
+                   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