diff options
author | Loui Chang <louipc.ist@gmail.com> | 2007-09-27 05:57:51 +0200 |
---|---|---|
committer | Loui Chang <louipc.ist@gmail.com> | 2007-09-27 05:57:51 +0200 |
commit | c764f078f10061c016228fb079dc7302af52f60c (patch) | |
tree | 5a3934a93523f9c1246fc0664dbf5ac8ccf0779c | |
parent | 5546779ad0ce7105770280c93e664a7edefbf573 (diff) | |
download | aur-c764f078f10061c016228fb079dc7302af52f60c.tar.gz aur-c764f078f10061c016228fb079dc7302af52f60c.tar.xz |
Made some things in config.inc.proto that should be constants constants
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
-rw-r--r-- | web/html/pkgsubmit.php | 64 | ||||
-rw-r--r-- | web/lib/aur.inc | 24 | ||||
-rw-r--r-- | web/lib/config.inc.proto | 42 | ||||
-rw-r--r-- | web/lib/pkgfuncs.inc | 3 |
4 files changed, 70 insertions, 63 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 89ecfa44..2e05f1cf 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -88,15 +88,15 @@ if ($_COOKIE["AURSID"]) { # 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)) { # 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 # - rm_rf($INCOMING_DIR . $pkg_name); + rm_rf(INCOMING_DIR . $pkg_name); } } else { @@ -111,13 +111,13 @@ if ($_COOKIE["AURSID"]) { # if (!$error) { - if (!@mkdir($INCOMING_DIR.$pkg_name)) { + if (!@mkdir(INCOMING_DIR.$pkg_name)) { $error = __("Could not create incoming directory: %s.", - array($INCOMING_DIR.$pkg_name)); + array(INCOMING_DIR.$pkg_name)); } else { - if (!@chdir($INCOMING_DIR.$pkg_name)) { + if (!@chdir(INCOMING_DIR.$pkg_name)) { $error = __("Could not change directory to %s.", - array($INCOMING_DIR.$pkg_name)); + array(INCOMING_DIR.$pkg_name)); } else { # try .gz first # @@ -135,40 +135,40 @@ if ($_COOKIE["AURSID"]) { } # 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 # packaged without the $pkg_name subdirectory, try and create it # and move the package contents into the new sub-directory. # if (!$error) { - if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) && - is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { + if (is_dir(INCOMING_DIR.$pkg_name."/".$pkg_name) && + is_file(INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { # 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.", - array($INCOMING_DIR.$pkg_name."/".$pkg_name)); + array(INCOMING_DIR.$pkg_name."/".$pkg_name)); } - $pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; - } elseif (is_file($INCOMING_DIR.$pkg_name."/PKGBUILD")) { + $pkg_dir = INCOMING_DIR.$pkg_name."/".$pkg_name; + } elseif (is_file(INCOMING_DIR.$pkg_name."/PKGBUILD")) { # 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 # - if (!@mkdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { + if (!@mkdir(INCOMING_DIR.$pkg_name."/".$pkg_name)) { $error = __("Could not create directory %s.", - array($INCOMING_DIR.$pkg_name."/".$pkg_name)); + array(INCOMING_DIR.$pkg_name."/".$pkg_name)); } else { 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."); } } - if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { + if (!@chdir(INCOMING_DIR.$pkg_name."/".$pkg_name)) { $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 { # some wierd packaging/extraction error - baal # @@ -177,7 +177,7 @@ if ($_COOKIE["AURSID"]) { } $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); # 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 # if (!$error) { - if (!@chdir($INCOMING_DIR.$pkg_name)) { + if (!@chdir(INCOMING_DIR.$pkg_name)) { $error = __("Could not change directory to %s.", - array($INCOMING_DIR.$pkg_name)); + array(INCOMING_DIR.$pkg_name)); } } if (!$error) { @@ -415,9 +415,9 @@ if ($_COOKIE["AURSID"]) { } else { $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)."', "; - $urlpath=$URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; + $urlpath=URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; $q.="URLPath='".mysql_real_escape_string($urlpath)."' "; $q.="WHERE ID = " . $pdata["ID"]; $result = db_query($q, $dbh); @@ -428,8 +428,8 @@ if ($_COOKIE["AURSID"]) { $q = "INSERT INTO PackageContents "; $q.= "(PackageID, FSPath, URLPath, FileSize) VALUES ("; $q.= $pdata['ID'].", "; - $q.= "'".$INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', "; - $q.= "'".$URL_DIR.$pkg_name."/".$pkg_name."/".$k."', "; + $q.= "'".INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', "; + $q.= "'".URL_DIR.$pkg_name."/".$pkg_name."/".$k."', "; $q.= $v.")"; db_query($q); } @@ -498,9 +498,9 @@ if ($_COOKIE["AURSID"]) { $q.= "UNIX_TIMESTAMP(), "; $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)."', '"; - $urlpath=$URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; + $urlpath=URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"]; $q.= mysql_real_escape_string($urlpath)."')"; $result = db_query($q, $dbh); # print $result . "<br>"; @@ -513,8 +513,8 @@ if ($_COOKIE["AURSID"]) { $q = "INSERT INTO PackageContents "; $q.= "(PackageID, FSPath, URLPath, FileSize) VALUES ("; $q.= $packageID.", "; - $q.= "'".$INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', "; - $q.= "'".$URL_DIR.$pkg_name."/".$pkg_name."/".$k."', "; + $q.= "'".INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', "; + $q.= "'".URL_DIR.$pkg_name."/".$pkg_name."/".$k."', "; $q.= $v.")"; db_query($q); } diff --git a/web/lib/aur.inc b/web/lib/aur.inc index cce53848..7342e857 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -12,26 +12,6 @@ include_once("aur_po.inc"); # 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 @@ -296,7 +276,7 @@ function db_query($query="", $db_handle="") { $db_handle = db_connect(); } if ($QBUG) { - $fp = fopen("/var/tmp/aurq.log", "a"); + $fp = fopen(AURQ_LOG, "a"); fwrite($fp, $query . "\n"); fclose($fp); } @@ -479,7 +459,7 @@ function html_footer($ver="") { # debug logging # function dbug($msg) { - $fp = fopen("/var/tmp/aurd.log", "a"); + $fp = fopen(AURD_LOG, "a"); fwrite($fp, $msg . "\n"); fclose($fp); return; diff --git a/web/lib/config.inc.proto b/web/lib/config.inc.proto index fcb8b3a2..bad94a0c 100644 --- a/web/lib/config.inc.proto +++ b/web/lib/config.inc.proto @@ -1,15 +1,43 @@ <?php # NOTE: modify these variables if your MySQL setup is different # -$AUR_db_host = "localhost:/tmp/mysql.sock"; -$AUR_db_name = "aur"; -$AUR_db_user = "aur"; -$AUR_db_pass = "aur"; +define( "AUR_db_host", "localhost:/tmp/mysql.sock" ); +define( "AUR_db_name", "aur" ); +define( "AUR_db_user", "aur" ); +define( "AUR_db_pass", "aur" ); # Configuration of directories where things live -$UPLOAD_DIR = "/home/aur/unsupported-temp/"; -$INCOMING_DIR = "/home/aur/unsupported/"; -$URL_DIR = "/packages/"; +define( "UPLOAD_DIR", "/home/aur/unsupported-temp/" ); +define( "INCOMING_DIR", "/home/aur/unsupported/" ); +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 ?> diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index b9ad0d4a..d6213d8d 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -365,8 +365,7 @@ function package_details($id=0, $SID="") { print "<tr>\n"; print " <td class='boxSoft' colspan='2'><span class='f3'>"; 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>"; } 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>"; |