Commit 61ab4524 authored by Rusty Russell's avatar Rusty Russell

web: clean up directory

parent 6855b303
<?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
<?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));
}
?>
<?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';
//temp repo
$temprepo = "temprepo/";
//email from
$frommail = "ccan@ozlabs.org";
//ccan home
$ccan_home_dir = "ccan/";
//bzr clone
$bzr_clone = 'bzr clone /home/dinesh/testwebsite/ ';
//bzr push
$bzr_push = 'bzr push /home/dinesh/testwebsite/ ';
//tar home dir
$tar_dir = 'tarball/';
?>
<?php
function sqlite3_num_rows($dbRes)
{
$n = 0;
while(sqlite3_fetch_array($dbRes) != '')
{
$n = $n + 1;
}
return $n;
}
?>
<?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;
}
?>
<?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);
?>
<table align="center" bgcolor="lightblue" width="70%" border="0" cellpadding="3" cellspacing="1">
<tr align="center" bgcolor="FFFFCC">
<td width="50%">
<?php
if(file_exists($tar_dir . $_GET['module'].".tar"))
echo '<a href='. $tar_dir . $_GET['module'] . '.tar>Download</a>';
?>
<td>
<?php
if(file_exists($tar_dir . $_GET['module']."_with_deps.tar"))
echo '<a href='. $tar_dir . $_GET['module'] . '_with_deps.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>Dependencies: </h3> <pre><?=$row['depends'];?></pre></td>
</tr>
<tr align="left" bgcolor="FFFFCC">
<td><h3>Description: </h3> <pre><?=$row['desc'];?></pre></td>
</tr>
</table><hr>
<?php
function checkerror($status, $msg)
{
if($status != 0) {
echo "<div align=\"center\">" . $msg . "Contact ccan admin. </div>";
exit();
}
}
?>
<?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['email'].",";
return $admin;
}
?>
<?php
session_start();
include('logo.html');
include('menulist.html');
include('configuration');
include('searchengine.php');
include('main.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>';
?>
<?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
}
?>
<?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
<p>CCAN provides two kinds of useful C
code: <a href="http://ccan.ozlabs.org/repo/?cmd=inventory;path=junkcode">junkcode</a> is a
collection of uploaded code with no particular order, and
<a href="search.php?disp=all">CCAN modules</a> are more structured,
with documentation, dependencies and testcases.
</p>
<h2>Using The Code</h2>
<p>
You can <a href="search.php">search</a>, <a href="search.php?disp=all">browse summary pages for all the modules</a> or use the
<a href="http://bazaar-vcs.org/">Bazaar</a> repository
at <a href="http://ccan.ozlabs.org/repo">http://ccan.ozlabs.org/repo</a>.
</p>
<h2>Contributing Code</h2>
<p>
You can <a href="upload.php">upload a .tar.gz, .tar.bz, .tar or .zip
containing C code</a>; if you have not created an account this won't be
visible until the contents have been checked by a human.
</p>
<p>"GPLv2 or later" and supersets thereof (eg. LGPLv2+ or BSD)
licenses preferred.
</p>
<h2>Questions?</h2>
<p>
We have a <a href="http://ozlabs.org/mailman/listinfo/ccan">low volume
mailing list</a> for discussion of CCAN in general, and you're welcome
to join.
</p>
<p>
We also have an IRC channel: #ccan on <a href="http://freenode.net">Freenode</a>.
</p>
<p>
We also have a <a href="Wiki/">wiki</a>; feel free to enhance it.
</p>
<?php
session_start();
include('logo.html');
include('menulist.html');
include('configuration');
include('functions.php');
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(getccanadmin($db), $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));
}
?>
<?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();
}
$searchtext = '%'.$searchtext.'%';
}
else if($_GET['author'] != '') {
$searchtext = '%'.$_GET['author'].'%';
$in = "author";
}
else if ($_GET['disp'] == 'all') {
$searchtext = "%";
$in = "module";
}
else if ($_GET['disp'] != '') {
$searchtext = $_GET['disp'].'%';
$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>';
?>
<?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\" order by module,
author";
else if($in == 'author')
$query = "select * from search where author LIKE \"$text\" order by module,
author";
else
$query = "select * from search where title LIKE \"$text\" or author LIKE \"$text\"
order by module, author";
$result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
return $result;
}
?>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment