Made some things in config.inc.proto that should be constants constants

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Loui Chang 2007-09-26 23:57:51 -04:00
parent 5546779ad0
commit c764f078f1
4 changed files with 70 additions and 63 deletions

View file

@ -88,15 +88,15 @@ if ($_COOKIE["AURSID"]) {
# the uploaded package file. # the uploaded package file.
# #
$upload_file = $UPLOAD_DIR . $_FILES["pfile"]["name"]; $upload_file = UPLOAD_DIR . $_FILES["pfile"]["name"];
if (move_uploaded_file($_FILES["pfile"]["tmp_name"], $upload_file)) { if (move_uploaded_file($_FILES["pfile"]["tmp_name"], $upload_file)) {
# ok, we can proceed # ok, we can proceed
# #
if (file_exists($INCOMING_DIR . $pkg_name)) { if (file_exists(INCOMING_DIR . $pkg_name)) {
# blow away the existing file/dir and contents # blow away the existing file/dir and contents
# #
rm_rf($INCOMING_DIR . $pkg_name); rm_rf(INCOMING_DIR . $pkg_name);
} }
} else { } else {
@ -111,13 +111,13 @@ if ($_COOKIE["AURSID"]) {
# #
if (!$error) { if (!$error) {
if (!@mkdir($INCOMING_DIR.$pkg_name)) { if (!@mkdir(INCOMING_DIR.$pkg_name)) {
$error = __("Could not create incoming directory: %s.", $error = __("Could not create incoming directory: %s.",
array($INCOMING_DIR.$pkg_name)); array(INCOMING_DIR.$pkg_name));
} else { } else {
if (!@chdir($INCOMING_DIR.$pkg_name)) { if (!@chdir(INCOMING_DIR.$pkg_name)) {
$error = __("Could not change directory to %s.", $error = __("Could not change directory to %s.",
array($INCOMING_DIR.$pkg_name)); array(INCOMING_DIR.$pkg_name));
} else { } else {
# try .gz first # try .gz first
# #
@ -135,40 +135,40 @@ if ($_COOKIE["AURSID"]) {
} }
# At this point, if no error exists, the package has been extracted # At this point, if no error exists, the package has been extracted
# There should be a $INCOMING_DIR.$pkg_name."/".$pkg_name directory # There should be a INCOMING_DIR.$pkg_name."/".$pkg_name directory
# if the user packaged it correctly. However, if the file was # if the user packaged it correctly. However, if the file was
# packaged without the $pkg_name subdirectory, try and create it # packaged without the $pkg_name subdirectory, try and create it
# and move the package contents into the new sub-directory. # and move the package contents into the new sub-directory.
# #
if (!$error) { if (!$error) {
if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) && if (is_dir(INCOMING_DIR.$pkg_name."/".$pkg_name) &&
is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { is_file(INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) {
# the files were packaged correctly # the files were packaged correctly
# #
if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { if (!@chdir(INCOMING_DIR.$pkg_name."/".$pkg_name)) {
$error = __("Could not change to directory %s.", $error = __("Could not change to directory %s.",
array($INCOMING_DIR.$pkg_name."/".$pkg_name)); array(INCOMING_DIR.$pkg_name."/".$pkg_name));
} }
$pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; $pkg_dir = INCOMING_DIR.$pkg_name."/".$pkg_name;
} elseif (is_file($INCOMING_DIR.$pkg_name."/PKGBUILD")) { } elseif (is_file(INCOMING_DIR.$pkg_name."/PKGBUILD")) {
# not packaged correctly, but recovery may be possible. # not packaged correctly, but recovery may be possible.
# try and create $INCOMING_DIR.$pkg_name."/".$pkg_name and # try and create INCOMING_DIR.$pkg_name."/".$pkg_name and
# move package contents into the new dir # move package contents into the new dir
# #
if (!@mkdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { if (!@mkdir(INCOMING_DIR.$pkg_name."/".$pkg_name)) {
$error = __("Could not create directory %s.", $error = __("Could not create directory %s.",
array($INCOMING_DIR.$pkg_name."/".$pkg_name)); array(INCOMING_DIR.$pkg_name."/".$pkg_name));
} else { } else {
exec("/bin/sh -c 'mv * ".$pkg_name."'"); exec("/bin/sh -c 'mv * ".$pkg_name."'");
if (!file_exists($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { if (!file_exists(INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) {
$error = __("Error exec'ing the mv command."); $error = __("Error exec'ing the mv command.");
} }
} }
if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { if (!@chdir(INCOMING_DIR.$pkg_name."/".$pkg_name)) {
$error = __("Could not change to directory %s.", $error = __("Could not change to directory %s.",
array($INCOMING_DIR.$pkg_name."/".$pkg_name)); array(INCOMING_DIR.$pkg_name."/".$pkg_name));
} }
$pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; $pkg_dir = INCOMING_DIR.$pkg_name."/".$pkg_name;
} else { } else {
# some wierd packaging/extraction error - baal # some wierd packaging/extraction error - baal
# #
@ -177,7 +177,7 @@ if ($_COOKIE["AURSID"]) {
} }
$shcmd = "/bin/mv ".$upload_file." "; $shcmd = "/bin/mv ".$upload_file." ";
$shcmd.= escapeshellarg($INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"]); $shcmd.= escapeshellarg(INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"]);
@exec($shcmd); @exec($shcmd);
# if no error, get list of directory contents and process PKGBUILD # if no error, get list of directory contents and process PKGBUILD
@ -353,9 +353,9 @@ if ($_COOKIE["AURSID"]) {
# Re-tar the package for consistency's sake # Re-tar the package for consistency's sake
# #
if (!$error) { if (!$error) {
if (!@chdir($INCOMING_DIR.$pkg_name)) { if (!@chdir(INCOMING_DIR.$pkg_name)) {
$error = __("Could not change directory to %s.", $error = __("Could not change directory to %s.",
array($INCOMING_DIR.$pkg_name)); array(INCOMING_DIR.$pkg_name));
} }
} }
if (!$error) { if (!$error) {
@ -415,9 +415,9 @@ if ($_COOKIE["AURSID"]) {
} else { } else {
$q.="Safe=0, "; $q.="Safe=0, ";
} }
$fspath=$INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; $fspath=INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.="FSPath='".mysql_real_escape_string($fspath)."', "; $q.="FSPath='".mysql_real_escape_string($fspath)."', ";
$urlpath=$URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; $urlpath=URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.="URLPath='".mysql_real_escape_string($urlpath)."' "; $q.="URLPath='".mysql_real_escape_string($urlpath)."' ";
$q.="WHERE ID = " . $pdata["ID"]; $q.="WHERE ID = " . $pdata["ID"];
$result = db_query($q, $dbh); $result = db_query($q, $dbh);
@ -428,8 +428,8 @@ if ($_COOKIE["AURSID"]) {
$q = "INSERT INTO PackageContents "; $q = "INSERT INTO PackageContents ";
$q.= "(PackageID, FSPath, URLPath, FileSize) VALUES ("; $q.= "(PackageID, FSPath, URLPath, FileSize) VALUES (";
$q.= $pdata['ID'].", "; $q.= $pdata['ID'].", ";
$q.= "'".$INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', "; $q.= "'".INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
$q.= "'".$URL_DIR.$pkg_name."/".$pkg_name."/".$k."', "; $q.= "'".URL_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
$q.= $v.")"; $q.= $v.")";
db_query($q); db_query($q);
} }
@ -498,9 +498,9 @@ if ($_COOKIE["AURSID"]) {
$q.= "UNIX_TIMESTAMP(), "; $q.= "UNIX_TIMESTAMP(), ";
$q.= uid_from_sid($_COOKIE["AURSID"]).", "; $q.= uid_from_sid($_COOKIE["AURSID"]).", ";
$q.= uid_from_sid($_COOKIE["AURSID"]).", '"; $q.= uid_from_sid($_COOKIE["AURSID"]).", '";
$fspath=$INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; $fspath=INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.= mysql_real_escape_string($fspath)."', '"; $q.= mysql_real_escape_string($fspath)."', '";
$urlpath=$URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; $urlpath=URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.= mysql_real_escape_string($urlpath)."')"; $q.= mysql_real_escape_string($urlpath)."')";
$result = db_query($q, $dbh); $result = db_query($q, $dbh);
# print $result . "<br>"; # print $result . "<br>";
@ -513,8 +513,8 @@ if ($_COOKIE["AURSID"]) {
$q = "INSERT INTO PackageContents "; $q = "INSERT INTO PackageContents ";
$q.= "(PackageID, FSPath, URLPath, FileSize) VALUES ("; $q.= "(PackageID, FSPath, URLPath, FileSize) VALUES (";
$q.= $packageID.", "; $q.= $packageID.", ";
$q.= "'".$INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', "; $q.= "'".INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
$q.= "'".$URL_DIR.$pkg_name."/".$pkg_name."/".$k."', "; $q.= "'".URL_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
$q.= $v.")"; $q.= $v.")";
db_query($q); db_query($q);
} }

View file

@ -12,26 +12,6 @@ include_once("aur_po.inc");
# is using... # is using...
# #
# Define global variables
#
$LOGIN_TIMEOUT = 7200; # number of idle seconds before timeout
$SUPPORTED_LANGS = array( # what languages we have translations for
"en" => "English",
"pl" => "Polski",
"it" => "Italiano",
"ca" => "Català",
"pt" => "Português",
# Eventually we will comment these in, when they are ready - PJM - 4/2005
"es" => "Español",
"de" => "Deutsch",
"ru" => "Русский",
"fr" => "Français",
);
# debugging variables
#
$QBUG = 1; # toggle query logging to /var/tmp/aurq.log
$DBUG = 1; # use dbug($msg) to log to /var/tmp/aurd.log
# return an array of info for each Trusted user # return an array of info for each Trusted user
@ -296,7 +276,7 @@ function db_query($query="", $db_handle="") {
$db_handle = db_connect(); $db_handle = db_connect();
} }
if ($QBUG) { if ($QBUG) {
$fp = fopen("/var/tmp/aurq.log", "a"); $fp = fopen(AURQ_LOG, "a");
fwrite($fp, $query . "\n"); fwrite($fp, $query . "\n");
fclose($fp); fclose($fp);
} }
@ -479,7 +459,7 @@ function html_footer($ver="") {
# debug logging # debug logging
# #
function dbug($msg) { function dbug($msg) {
$fp = fopen("/var/tmp/aurd.log", "a"); $fp = fopen(AURD_LOG, "a");
fwrite($fp, $msg . "\n"); fwrite($fp, $msg . "\n");
fclose($fp); fclose($fp);
return; return;

View file

@ -1,15 +1,43 @@
<?php <?php
# NOTE: modify these variables if your MySQL setup is different # NOTE: modify these variables if your MySQL setup is different
# #
$AUR_db_host = "localhost:/tmp/mysql.sock"; define( "AUR_db_host", "localhost:/tmp/mysql.sock" );
$AUR_db_name = "aur"; define( "AUR_db_name", "aur" );
$AUR_db_user = "aur"; define( "AUR_db_user", "aur" );
$AUR_db_pass = "aur"; define( "AUR_db_pass", "aur" );
# Configuration of directories where things live # Configuration of directories where things live
$UPLOAD_DIR = "/home/aur/unsupported-temp/"; define( "UPLOAD_DIR", "/home/aur/unsupported-temp/" );
$INCOMING_DIR = "/home/aur/unsupported/"; define( "INCOMING_DIR", "/home/aur/unsupported/" );
$URL_DIR = "/packages/"; define( "URL_DIR", "/packages/" );
define( "AURQ_LOG", "/home/aur/aurq.log" );
define( "AURD_LOG", "/home/aur/aurd.log" );
define( "USERNAME_MIN_LEN", 3 );
define( "USERNAME_MAX_LEN", 16 );
define( "PASSWD_MIN_LEN", 4 );
define( "PASSWD_MAX_LEN", 128 );
$LOGIN_TIMEOUT = 7200; # number of idle seconds before timeout
# debugging variables
#
$QBUG = 1; # toggle query logging to /var/tmp/aurq.log
$DBUG = 1; # use dbug($msg) to log to /var/tmp/aurd.log
$SUPPORTED_LANGS = array( # what languages we have translations for
"en" => "English",
"pl" => "Polski",
"it" => "Italiano",
"ca" => "Català",
"pt" => "Português",
"es" => "Español",
"de" => "Deutsch",
"ru" => "Русский",
"fr" => "Français"
);
# vim: ts=2 sw=2 noet ft=php # vim: ts=2 sw=2 noet ft=php
?> ?>

View file

@ -365,8 +365,7 @@ function package_details($id=0, $SID="") {
print "<tr>\n"; print "<tr>\n";
print " <td class='boxSoft' colspan='2'><span class='f3'>"; print " <td class='boxSoft' colspan='2'><span class='f3'>";
if ($row["LocationID"] == 2) { if ($row["LocationID"] == 2) {
global $URL_DIR; $urlpath = URL_DIR.$row["Name"]."/".$row["Name"];
$urlpath = $URL_DIR.$row["Name"]."/".$row["Name"];
print "<a href='$urlpath.tar.gz'>".__("Tarball")."</a> :: <a href='$urlpath'>".__("Files")."</a> :: <a href='$urlpath/PKGBUILD'>PKGBUILD</a></span></td>"; print "<a href='$urlpath.tar.gz'>".__("Tarball")."</a> :: <a href='$urlpath'>".__("Files")."</a> :: <a href='$urlpath/PKGBUILD'>PKGBUILD</a></span></td>";
} elseif ($row["LocationID"] == 3) { } elseif ($row["LocationID"] == 3) {
print "<a href='http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/" . $row["Category"] . "/" . $row["Name"] . "/?cvsroot=AUR&only_with_tag=CURRENT'>CVS</td>"; print "<a href='http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/" . $row["Category"] . "/" . $row["Name"] . "/?cvsroot=AUR&only_with_tag=CURRENT'>CVS</td>";