diff options
-rw-r--r-- | Makefile | 63 | ||||
-rw-r--r-- | Makefile-ccan | 11 | ||||
-rw-r--r-- | web/logo.html | 9 | ||||
-rw-r--r-- | web/menulist.html | 28 | ||||
-rw-r--r-- | web/static-configuration | 74 | ||||
-rw-r--r-- | web/staticall.php | 80 | ||||
-rw-r--r-- | web/staticindex.php | 77 | ||||
-rw-r--r-- | web/staticmoduleinfo.php | 90 | ||||
-rw-r--r-- | web/staticupload.php | 55 | ||||
-rw-r--r-- | web/upload.php | 14 | ||||
-rw-r--r-- | web/uploader.php | 175 |
11 files changed, 486 insertions, 190 deletions
@@ -1,27 +1,74 @@ # Hacky makefile to compile everything and run the tests in some kind of sane order. # V=--verbose for verbose tests. +# This can be overridden on cmdline to generate pages elsewhere. +WEBDIR=webpages/ + CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I. ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test)) ALL_DIRS=$(patsubst %, ccan/%, $(ALL)) ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL)) -ALL_LIBS=$(patsubst %, ccan/%.o, $(ALL)) +ALL_PAGES=$(patsubst ccan/%, $(WEBDIR)/info/%.html, $(ALL_DIRS)) +DIRECT_TARBALLS=$(patsubst ccan/%, $(WEBDIR)/tarballs/%.tar.bz2, $(ALL_DIRS)) +DEPEND_TARBALLS=$(patsubst ccan/%, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(ALL_DIRS)) +WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info -libccan.a: $(ALL_LIBS) - $(AR) r $@ $^ +include Makefile-ccan check: $(ALL_DIRS:%=test-%) distclean: clean rm -f $(ALL_DEPENDS) + rm -rf $(WEBDIR) + +webpages: $(WEB_SUBDIRS) $(WEBDIR)/junkcode $(ALL_PAGES) $(WEBDIR)/list.html $(WEBDIR)/index.html $(WEBDIR)/upload.html $(WEBDIR)/example-config.h $(WEBDIR)/ccan.jpg $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(WEBDIR)/Makefile-ccan + +$(WEB_SUBDIRS): + mkdir -p $@ + +$(WEBDIR)/junkcode: + cp -a junkcode $@ + +# Override implicit attempt to link directory. +$(ALL_DIRS): + @touch $@ + +$(WEBDIR)/ccan.tar.bz2: + tar cvfj $@ `bzr ls --versioned --kind=file ccan` + +$(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php + +$(WEBDIR)/list.html: web/staticall.php tools/doc_extract $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 + php5 web/staticall.php ccan/ $(WEBDIR) > $@ + +$(WEBDIR)/upload.html: web/staticupload.php + php5 web/staticupload.php > $@ + +$(WEBDIR)/index.html: web/staticindex.php + php5 web/staticindex.php > $@ + +$(WEBDIR)/example-config.h: config.h + cp $< $@ + +$(WEBDIR)/Makefile-ccan: Makefile-ccan + cp $< $@ + +$(WEBDIR)/ccan.jpg: web/ccan.jpg + cp $< $@ + +$(WEBDIR)/info/%.html: ccan/% ccan/%/test $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2 + URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@ + +$(WEBDIR)/tarballs/%.tar.bz2: ccan/% ccan/%/test + tar -c -v -j -f $@ `bzr ls --versioned --kind=file ccan/$*` + +$(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/% ccan/%/test tools/ccan_depends + tar cvfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file) $(ALL_DEPENDS): %/.depends: tools/ccan_depends tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 ) -$(ALL_LIBS): - $(LD) -r -o $@ $^ /dev/null - test-ccan/%: tools/run_tests ccan/%.o @echo Testing $*... @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi @@ -38,10 +85,6 @@ inter-depends: $(ALL_DEPENDS) test-depends: $(ALL_DEPENDS) for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@ -lib-depends: $(foreach D,$(ALL),$(wildcard $D/*.[ch])) - for c in $(ALL); do echo ccan/$$c.o: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@ - include tools/Makefile -include inter-depends -include test-depends --include lib-depends diff --git a/Makefile-ccan b/Makefile-ccan new file mode 100644 index 00000000..cbd9871c --- /dev/null +++ b/Makefile-ccan @@ -0,0 +1,11 @@ +# Example makefile which makes a "libccan.a" of everything under ccan/ +# You could just do: +# SRCFILES += $(shell find ccan/ -name '[a-z]*.c') + +CFLAGS=-g -O2 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I. + +CFILES=$(wildcard ccan/*/[a-z]*.c) +OBJFILES=$(CFILES:.c=.o) + +libccan.a: $(OBJFILES) + $(AR) r $@ $^ diff --git a/web/logo.html b/web/logo.html index 7239556c..61c8f7e7 100644 --- a/web/logo.html +++ b/web/logo.html @@ -1,3 +1,8 @@ +<?php +session_start(); +// Pages created in subdirs need ../ appended. +$url_prefix = getenv("URLPREFIX"); +?> <html> <head> <title>ccan</title> @@ -6,10 +11,10 @@ <table align="center" width="100%" bgcolor="FFFFFF"> <tr> <th> - <img src="ccan.jpg" width="250" height="80"> + <img src="<?=$url_prefix?>ccan.jpg" width="250" height="80"> </th> <th> <h1>Comprehensive C Archieve Network <h1> </th> </tr> -</table>
\ No newline at end of file +</table> diff --git a/web/menulist.html b/web/menulist.html index 7e0232cb..aa5993f5 100644 --- a/web/menulist.html +++ b/web/menulist.html @@ -1,30 +1,26 @@ <?php session_start(); +// Pages created in subdirs need ../ appended. +$url_prefix = getenv("URLPREFIX"); ?> <table align="center" width="100%" cellpadding="4" cellspacing="1" border="0" bgcolor="lightblue"> - <tr align="left" bgcolor="CCFFCC" ><td>Welcome <?=$_SESSION['susername']?>! </td> + <tr align="left" bgcolor="CCFFCC" > <td align="center"> - <a href="login.php"> Login</a> + <a href="<?=$url_prefix?>upload.html">Upload Code</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> + <a href="<?=$url_prefix?>list.html">Download Code</a> </td> <td align="center"> - <a href="upload.php"> - Upload Code</a> + <a href="<?=$url_prefix?>index.html">About</a> </td> <td align="center"> - <a href="search.php"> - Search CCAN</a> - </td> - <td align="center"> - <a href="logout.php"> - Logout</a> + <form method="get" action="http://www.google.com/search"> + <input type="text" name="q" size="25" + maxlength="255" value="" /> + <input type="hidden" name="sitesearch" value="ccan.ozlabs.org"/> + <input type="submit" value="Search CCAN (Google)" /> + </form> </td> </table> <hr> diff --git a/web/static-configuration b/web/static-configuration new file mode 100644 index 00000000..3ff84923 --- /dev/null +++ b/web/static-configuration @@ -0,0 +1,74 @@ +<?php +//temp folder for uploads +$tempfolder = "/home/ccan/upload-temp/"; + +//location of upload script (for posting uploads) +$uploadscript = "http://ccan.ozlabs.org/uploader.php"; + +//infofile +$infofile = '/_info.c'; + +//ccan admin +$ccanadmin = "rusty@rustcorp.com.au"; + +//email from +$frommail = "ccan@ozlabs.org"; + +//tar home dir +$tar_dir = 'tarballs'; + +//where bzr repo is: attach module name to browse +$repo_base = 'http://ccan.ozlabs.org/repo/?cmd=inventory;path='; + +function extract_field($field,$module) +{ + return htmlspecialchars(shell_exec('tools/doc_extract '.$field.' '.$module.'/_info.c')); +} + +# Convert double line breaks into paragraphs, and blank spaces into preformat. +function htmlize_field($field,$module) +{ + $state="inpara"; + $result="<p>"; + $raw=extract_field($field,$module); + foreach (explode("\n", $raw) as $line) { + if ($line == "") { + switch ($state) { + case "inpara": + $state="endpara"; + $result .= "</p>"; + break; + } + } else if ($line[0] == " " || $line[0] == "\t") { + switch ($state) { + case "literal": + break; + case "inpara": + $result .= "</p>"; + case "endpara": + $result .= "<pre>"; + $state = "literal"; + } + } else { + switch ($state) { + case "literal": + $result .= "</pre>"; + case "endpara": + $result .= "<p>"; + $state = "inpara"; + } + } + $result .= $line . "\n"; + } + + switch ($state) { + case "literal": + $result .= "</pre>"; + break; + case "inpara": + $result .= "</p>"; + break; + } + return $result; +} +?> diff --git a/web/staticall.php b/web/staticall.php new file mode 100644 index 00000000..3a6407ff --- /dev/null +++ b/web/staticall.php @@ -0,0 +1,80 @@ +<?php +session_start(); +include('logo.html'); +include('menulist.html'); +include('static-configuration'); + +$tarballsize=round((filesize($argv[2]."/ccan.tar.bz2") + 1023) / 1024); +?> + +<h1> List of all CCAN modules: </h1> + +<p> +Note that two downloads are offered: the first includes with all the +other ccan modules this module uses, the second is a standalone +download. +</p> + +<p> +Or you can just download the <a href="ccan.tar.bz2">tarball of everything (<?=$tarballsize?>K)</a>. +</p> + +<table align="center" width="80%" border="0" cellpadding="3" cellspacing="1"> +<th align="left">Name</th> +<th align="left">Summary / Link to details</th> +<th align="right">Download</th> + +<?php +$d = dir($argv[1]); +$modules = array(); +while (false !== ($entry = $d->read())) { + if ($entry[0] != '.') { + array_push($modules, $entry); + } +} +sort($modules); + +foreach ($modules as $module) { + $summary=extract_field('summary',$argv[1].$module); + $with_deps="$tar_dir/with-deps/$module.tar.bz2"; + $no_deps="$tar_dir/$module.tar.bz2"; + $with_dep_size = round((filesize($argv[2]."/".$with_deps) + 1023) / 1024); + $no_dep_size = round((filesize($argv[2]."/".$no_deps) + 1023) / 1024); + ?> + <tr> + <td><?=$module?></td> + <td><a href="info/<?=$module?>.html"><?=$summary?></a></td> + <td align="right"><a href="<?=$with_deps?>"><?=$with_dep_size?>K</a> / + <a href="<?=$no_deps?>"><?=$no_dep_size?>K</a></td> + </tr> + <?php +} +$d->close(); +?> +</table> + +<h2> Contents of Junkcode: </h2> + +(This is contributed code which was dumped here: these gems may need some polishing.) + +<table align="center" width="80%" border="0" cellpadding="3" cellspacing="1"> + +<?php +$d = dir($argv[2]."/junkcode"); +$files = array(); +while (false !== ($entry = $d->read())) { + if ($entry[0] != '.') { + array_push($files, $entry); + } +} + +sort($files); +foreach ($files as $file) { + $size = round((filesize($argv[2]."/junkcode/".$file) + 1023) / 1024); + echo "<tr><td><a href=\"junkcode/$file\">$file (${size}K)</a></td><tr>\n"; +} +$d->close(); +?> +</table> +<hr> +</body></html> diff --git a/web/staticindex.php b/web/staticindex.php new file mode 100644 index 00000000..9dace4e7 --- /dev/null +++ b/web/staticindex.php @@ -0,0 +1,77 @@ +<?php +session_start(); +include('logo.html'); +include('menulist.html'); +include('static-configuration'); +?> + +<h2>The Idea</h2> + +<p> +That nice snippets of C code should be moved out of junkcode +directories and exposed to a wider world, where they can become +something useful. +</p> + +<p> +CCAN is loosely modelled after the succesful <a href="http://cpan.org">CPAN project</a> +for Perl code development and sharing. +</p> + +<h2>Getting The Code</h2> + +<p> +Once you <a href="list.html">grab some modules</a>, there are two basic +ways to use it: +<ol> +<li> Just hack it to compile in your project. + +<li> Use it in place by giving it a "config.h" (steal + <a href="example-config.h">this example</a>) and compiling all the .c + files which don't start with "_" (eg. as in this <a href="Makefile-ccan">simple Makefile</a>). +</ol> +</p> + +<p> +There's also a +<a href="http://bazaar-vcs.org/">Bazaar</a> repository for all the CCAN +infrastructure at +<a href="http://ccan.ozlabs.org/repo">http://ccan.ozlabs.org/repo</a>. +</p> + +<h2>Module Contributions</h2> + +<p> +We welcome new code! The guide to creating new modules is a work in +progress (just copy an existing module), but anyone can +just <a href="upload.html">upload code</a>. +</p> + +<p> +"GPLv2 or later" and supersets thereof (eg. LGPLv2+ or BSD) +licenses preferred. +</p> + +<h2>Complaints, Ideas and Infrastructure</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> + +<p> +<i>Rusty Russell</i> +</p> + +<hr> +</body></html> diff --git a/web/staticmoduleinfo.php b/web/staticmoduleinfo.php new file mode 100644 index 00000000..5b16e62d --- /dev/null +++ b/web/staticmoduleinfo.php @@ -0,0 +1,90 @@ +<?php +session_start(); +include('logo.html'); +include('menulist.html'); +include('static-configuration'); +$module=$argv[1]; + +$maintainer=extract_field('maintainer',$module); +$author=extract_field('author',$module); +$summary=extract_field('summary',$module); +$description=htmlize_field('description',$module); +$example=extract_field('example',$module); +$dependencies=htmlspecialchars(shell_exec('tools/ccan_depends --direct '.$module)); +$licence=extract_field('licence',$module); +?> +<table align="center" bgcolor="lightblue" width="70%" border="0" cellpadding="3" cellspacing="1"> +<tr align="center" bgcolor="FFFFCC"> +<td> +<a href="<?=$repo_base.$module?>">Browse Source</a> +</td> +<td> +Download: +<a href="../<?=$tar_dir?>/<?=basename($module)?>.tar.bz2">(standalone)</a> +<a href="../<?=$tar_dir?>/with-deps/<?=basename($module)?>.tar.bz2">(with all dependencies)</a> +</tr> +</table> + +<p> +</p> + +<table align="center" bgcolor="lightblue" width="70%" border="0" cellpadding="8" cellspacing="1"> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Module: </h3> <?=$module?> </td> +</tr> + +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Summary: </h3> <?=$summary?></td> +</tr> + +<?php +if ($maintainer) { +?> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Maintainer: </h3> <?=$maintainer?></td> +</tr> +<?php +} + +if ($author) { +?> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Author: </h3> <?=$author?></td> +</tr> +<?php +} + +if ($dependencies) { +?> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Dependencies: </h3> <pre> <?php + foreach (preg_split("/\s+/", $dependencies) as $dep) { + echo '<a href="'.substr($dep, 5).'.html">'.$dep.'</a> '; + } +?></pre></td> +</tr> +<?php +} +?> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Description: </h3> <?=$description;?> </td> +</tr> +<?php +if ($example) { +?> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Example: </h3> <pre><?=$example?></pre></td> +</tr> +<?php +} + +if ($licence) { +?> +<tr align="left" bgcolor="FFFFCC"> +<td><h3>Licence: </h3> <?=$licence?></td> +</tr> +<?php +} +?> +</table><hr> +</body></html> diff --git a/web/staticupload.php b/web/staticupload.php new file mode 100644 index 00000000..d1252e16 --- /dev/null +++ b/web/staticupload.php @@ -0,0 +1,55 @@ +<?php +session_start(); + +include('logo.html'); +include('menulist.html'); +include('static-configuration'); +?> +<html> +<h3 align="center"> Upload Code</h3> + +<table width="70%" align="center"> +<tr> +<td> +<p> +Got C code sitting around which might help someone? Put it to work +by uploading here; .tar.gz, .zip or even single C files. +</p> + +<p> +If it has a valid _info.c file and a testsuite, it'll go into the +main repository. Otherwise, it'll go into our "junkcode" area where +people can browse and download it. +</p> +</td> +</tr> +</table> + +<table width="70%" align="center"> +<tr> +<p> +<form enctype="multipart/form-data" action="<?=$uploadscript?>" method="POST"> +<td align="right"> + Email address: +</td> +<td> +<input type="text" name="email" size="25" + maxlength="255" value="" /> +</td> +</tr> +<tr> +<td align="right"> + <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/upload.php b/web/upload.php index 1a83d958..2c208b47 100644 --- a/web/upload.php +++ b/web/upload.php @@ -7,6 +7,16 @@ include('configuration'); ?> <html> <h3 align="center"> Upload Code</h3> + +<p>Got C code sitting around which might help someone? Put it to work +by uploading here; .tar.gz, .zip or even single C files. +</p> + +<p>If it has a valid _info.c file and a testsuite, it'll go into the +main repository. Otherwise, it'll go into our "junkcode" area where +people can browse and download it. +</p> + <table width="80%" align="center"> <tr> <th> @@ -15,6 +25,10 @@ include('configuration'); <table align="center"> <tr align="left"> <td> + Email address: <input type="text" name="email" size="25" + maxlength="255" value="" /> +</td> +<td> <input type="hidden" name="MAX_FILE_SIZE" value="10000000" /> Choose a file to upload: </td> diff --git a/web/uploader.php b/web/uploader.php index 0cb1c184..40e29445 100644 --- a/web/uploader.php +++ b/web/uploader.php @@ -2,173 +2,24 @@ session_start(); include('logo.html'); include('menulist.html'); -include('configuration'); -include('functions.php'); -include('searchengine.php'); +include('static-configuration'); +// We just email notification for now. Auto-analysis RSN. 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,"Error: cannot extract(tar error)."); +$dest = tempnam($tempfolder, "upload-"); +move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $dest); - //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"; - - $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(); - } +$subject = "CCAN: code upload by '" . $_POST['email'] . "' with name " . $_FILES["uploadedfile"]["name"]; +$message = "File type: ".$_FILES["uploadedfile"]["type"]."\n". + "Size: ".$_FILES["uploadedfile"]["size"]."\n". + "Claimed email: ".$_POST['email']."\n". + "File destination: ".$dest."\n"; - //running ccanlint - exec($ccanlint.$tempfolder.$folder, $score, $status); - - //if not junk code - if($status == 0) { - $rename = $folder; - $exactpath = $repopath . $_SESSION['susername'] .'/'; - - if (file_exists($exactpath)) { - echo "<div align=\"center\"> Your another upload is in progress please wait...</div>"; - exit(); - } - - //bzr local repo for commit - chdir($repopath); - unset($op); exec($bzr_clone . $_SESSION['susername'], $op, $status); - checkerror($status, "Error: bzr local repo."); - chdir('..'); - - //if module already exist - if (file_exists($exactpath . $ccan_home_dir . $folder)) { - - // if owner is not same - if(!(getowner($ccan_home_dir . $folder, $db) == $_SESSION['susername'])) { - if(!file_exists($repopath . $ccan_home_dir . $folder . '-' . $_SESSION['susername'])) - echo "<div align=\"center\">". $ccan_home_dir . $folder . - " already exists. Renaming to " . $folder . "-" . $_SESSION['susername'] . "</div>"; - else - echo "<div align=\"center\">". $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($ccan_home_dir . $folder, $_SESSION['susername'], $db); - } - - rmdirr($exactpath . $ccan_home_dir . $rename); - rename($tempfolder . $folder, $exactpath . $ccan_home_dir . $rename); - - chdir($exactpath); - unset($op); exec($infotojson . $ccan_home_dir . $rename . " " . $ccan_home_dir. - $rename."/_info.c ". $ccan_home_dir . $rename . "/json_" . $rename . " " - . $_SESSION['susername']. " ../../" . $db, $op, $status); - checkerror($status,"Error: In infotojson."); - - unset($op); exec('bzr add', $op, $status); - checkerror($status,"Error: bzr add error."); - - unset($op); exec('bzr commit --unchanged -m "commiting from ccan web ' . $rename . - " " . $_SESSION['susername'] . '"', $op, $status); - checkerror($status,"Error: bzr commit error."); - - unset($op); exec($bzr_push, $op, $status); - checkerror($status,"Error: bzr push error."); - - unset($op); exec($create_dep_tar . " " . $ccan_home_dir. $rename . " ../../" . - $tar_dir . " ../../" . $db , $op, $status); - checkerror($status,"Error: bzr push error."); - - chdir('../..'); - rmdirr($exactpath); - echo "<div align=\"center\"> Stored to ". $ccan_home_dir . $rename . "</div>"; - } - - //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 +mail($ccanadmin, $subject, $message, "From: $frommail"); +echo "<div align=\"center\"> Thanks!<br>Stored to temporary location. + Mail will be send to admin to get verification of the code.<//div>"; +?> |