summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorGit <git@what.cd>2012-10-09 08:00:17 +0000
committerGit <git@what.cd>2012-10-09 08:00:17 +0000
commit0be451b5525c29dbc52026bc211d6c2f9afed94b (patch)
tree11c69fc4f8bd780346dad2e037d5f6ddaa521c49 /classes
parent8e4937f6ff45f88540402415b419ce3d0f6bb353 (diff)
downloadGazelle-0be451b5525c29dbc52026bc211d6c2f9afed94b.zip
Gazelle-0be451b5525c29dbc52026bc211d6c2f9afed94b.tar.gz
Gazelle-0be451b5525c29dbc52026bc211d6c2f9afed94b.tar.bz2
Empty commit
Diffstat (limited to 'classes')
-rw-r--r--classes/class_cache.php3
-rw-r--r--classes/class_torrent.php25
-rw-r--r--classes/class_torrent_32bit.php23
-rw-r--r--classes/class_torrent_form.php10
-rw-r--r--classes/class_wiki.php28
-rw-r--r--classes/script_start.php34
6 files changed, 92 insertions, 31 deletions
diff --git a/classes/class_cache.php b/classes/class_cache.php
index 88952b1..d3bc5a2 100644
--- a/classes/class_cache.php
+++ b/classes/class_cache.php
@@ -37,7 +37,8 @@ class CACHE extends Memcache {
private $PersistentKeys = array(
'stats_*',
'percentiles_*',
- 'top10tor_*'
+ 'top10tor_*',
+ 'query_lock_*'
);
public $CanClear = false;
diff --git a/classes/class_torrent.php b/classes/class_torrent.php
index 966486b..407c3d5 100644
--- a/classes/class_torrent.php
+++ b/classes/class_torrent.php
@@ -251,29 +251,42 @@ class TORRENT extends BENCODE_DICT {
// * the total size of files described therein
function file_list() {
$FileList = array();
- if(!$this->Val['info']->Val['files']) { // Single file mode
+ if (!isset($this->Val['info']->Val['files'])) { // Single file mode
$TotalSize = $this->Val['info']->Val['length'];
- $FileList[]= array($this->Val['info']->Val['length'], $this->Val['info']->Val['name']);
+ $FileList[] = array($TotalSize, $this->get_name());
} else { // Multiple file mode
$FileNames = array();
$FileSizes = array();
$TotalSize = 0;
$Files = $this->Val['info']->Val['files']->Val;
- foreach($Files as $File) {
- $TotalSize += $File->Val['length'];
+ if (isset($Files[0]->Val['path.utf-8'])) {
+ $PathKey = 'path.utf-8';
+ } else {
+ $PathKey = 'path';
+ }
+ foreach ($Files as $File) {
$FileSize = $File->Val['length'];
+ $TotalSize += $FileSize;
- $FileName = ltrim(implode('/',$File->Val['path']->Val), '/');
+ $FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/');
$FileSizes[] = $FileSize;
$FileNames[] = $FileName;
}
natcasesort($FileNames);
- foreach($FileNames as $Index => $FileName) {
+ foreach ($FileNames as $Index => $FileName) {
$FileList[] = array($FileSizes[$Index], $FileName);
}
}
return array($TotalSize, $FileList);
}
+
+ function get_name() {
+ if (isset($this->Val['info']->Val['name.utf-8'])) {
+ return $this->Val['info']->Val['name.utf-8'];
+ } else {
+ return $this->Val['info']->Val['name'];
+ }
+ }
function make_private() {
//----- The following properties do not affect the infohash:
diff --git a/classes/class_torrent_32bit.php b/classes/class_torrent_32bit.php
index 2afb118..643923a 100644
--- a/classes/class_torrent_32bit.php
+++ b/classes/class_torrent_32bit.php
@@ -248,29 +248,42 @@ class TORRENT extends BENCODE_DICT {
// * the total size of files described therein
function file_list() {
$FileList = array();
- if(!$this->Val['info']->Val['files']) { // Single file mode
+ if (!isset($this->Val['info']->Val['files'])) { // Single file mode
$TotalSize = substr($this->Val['info']->Val['length'],7);
- $FileList[]= array($TotalSize, $this->Val['info']->Val['name']);
+ $FileList[] = array($TotalSize, $this->get_name());
} else { // Multiple file mode
$FileNames = array();
$FileSizes = array();
$TotalSize = 0;
$Files = $this->Val['info']->Val['files']->Val;
- foreach($Files as $File) {
+ if (isset($Files[0]->Val['path.utf-8'])) {
+ $PathKey = 'path.utf-8';
+ } else {
+ $PathKey = 'path';
+ }
+ foreach ($Files as $File) {
$FileSize = substr($File->Val['length'], 7);
$TotalSize += $FileSize;
- $FileName = ltrim(implode('/',$File->Val['path']->Val), '/');
+ $FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/');
$FileSizes[] = $FileSize;
$FileNames[] = $FileName;
}
natcasesort($FileNames);
- foreach($FileNames as $Index => $FileName) {
+ foreach ($FileNames as $Index => $FileName) {
$FileList[] = array($FileSizes[$Index], $FileName);
}
}
return array($TotalSize, $FileList);
}
+
+ function get_name() {
+ if (isset($this->Val['info']->Val['name.utf-8'])) {
+ return $this->Val['info']->Val['name.utf-8'];
+ } else {
+ return $this->Val['info']->Val['name'];
+ }
+ }
function make_private() {
//----- The following properties do not affect the infohash:
diff --git a/classes/class_torrent_form.php b/classes/class_torrent_form.php
index 3e31c46..905e187 100644
--- a/classes/class_torrent_form.php
+++ b/classes/class_torrent_form.php
@@ -78,7 +78,7 @@ class TORRENT_FORM {
} ?>
</div>
<? if($this->NewTorrent) { ?>
- <table cellpadding="3" cellspacing='1' border='0' class='layout border' width="100%">
+ <table cellpadding="3" cellspacing="1" border="0" class="layout border" width="100%">
<tr>
<td class="label">
Torrent file
@@ -94,8 +94,8 @@ class TORRENT_FORM {
<td>
<select id="categories" name="type" onchange="Categories()"<?=$this->Disabled?>>
<? foreach(display_array($this->Categories) as $Index => $Cat) {
- echo "<option value='$Index'";
- if($Cat == $this->Torrent['CategoryName']) { echo " selected='selected'"; }
+ echo "<option value=\"$Index\"";
+ if($Cat == $this->Torrent['CategoryName']) { echo ' selected="selected"'; }
echo ">";
echo $Cat;
echo "</option>\n";
@@ -145,7 +145,7 @@ class TORRENT_FORM {
<td colspan="2" style="text-align: center;">
<p>Be sure that your torrent is approved by the <a href="rules.php?p=upload">rules</a>. Not doing this will result in a <strong>warning</strong> or <strong>worse</strong>.</p>
<? if($this->NewTorrent) { ?>
- <p>After uploading the torrent, you will have a one hour grace period during which no one other than you can fill requests with this torrent. Make use of this time wisely, and search the requests. </p>
+ <p>After uploading the torrent, you will have a one hour grace period during which no one other than you can fill requests with this torrent. Make use of this time wisely, and search the requests.</p>
<? } ?>
<input id="post" type="submit" <? if($this->NewTorrent) { echo "value=\"Upload torrent\""; } else { echo "value=\"Edit torrent\"";} ?> />
</td>
@@ -300,7 +300,7 @@ function hide() {
<span id="year_label_remaster"<? if(!$IsRemaster) { echo ' class="hidden"';}?>>Year of original release</span>
</td>
<td>
- <p id="yearwarning" class="hidden">You have entered a year for a release which predates the medium's availibility. You will need to change the year, enter additional edition information or if this information cannot be provided, select the 'Unknown Release' checkbox below</p>
+ <p id="yearwarning" class="hidden">You have entered a year for a release which predates the medium's availibility. You will need to change the year, enter additional edition information. If this information cannot be provided, select the &quot;Unknown Release&quot; checkbox below</p>
<input type="text" id="year" name="year" size="5" value="<?=display_str($Torrent['Year']) ?>"<?=$this->Disabled?> onblur="CheckYear();" /> This is the year of the original release.
</td>
</tr>
diff --git a/classes/class_wiki.php b/classes/class_wiki.php
index 1752598..301670d 100644
--- a/classes/class_wiki.php
+++ b/classes/class_wiki.php
@@ -1,6 +1,6 @@
<?
/*########################################################################
-## Wiki class ##
+## Wiki class ##
##########################################################################
Seeing as each page has to manage its wiki separately (for performance
@@ -12,19 +12,19 @@ table with the revision history for that particular wiki page.
class_wiki depends on your wiki table being structured like this:
-+------------+---------------+------+-----+---------------------+-------+
-| Field | Type | Null | Key | Default | Extra |
-+------------+---------------+------+-----+---------------------+-------+
-| RevisionID | int(12) | NO | PRI | 0 | |
-| PageID | int(10) | NO | MUL | 0 | |
-| Body | text | YES | | NULL | |
-| UserID | int(10) | NO | MUL | 0 | |
-| Summary | varchar(100) | YES | | NULL | |
-| Time | datetime | NO | MUL | 0000-00-00 00:00:00 | |
-+------------+---------------+------+-----+---------------------+-------+
++------------+--------------+------+-----+----------------------+-------+
+| Field | Type | Null | Key | Default | Extra |
++------------+--------------+------+-----+----------------------+-------+
+| RevisionID | int(12) | NO | PRI | 0 | |
+| PageID | int(10) | NO | MUL | 0 | |
+| Body | text | YES | | NULL | |
+| UserID | int(10) | NO | MUL | 0 | |
+| Summary | varchar(100) | YES | | NULL | |
+| Time | datetime | NO | MUL | 0000-00-00 00:00:00 | |
++------------+--------------+------+-----+----------------------+-------+
It is also recommended that you have a field in the main table for
-whatever the page is (eg. details.php main table = torrents), so you can
+whatever the page is (e.g. details.php main table = torrents), so you can
do a JOIN.
@@ -55,7 +55,7 @@ class WIKI {
WHERE wiki.PageID = ".$this->PageID."
ORDER BY RevisionID DESC");
//----------------------------------------------- ?>
- <table cellpadding='6' cellspacing='1' border='0' width='100%' class='border'>
+ <table cellpadding="6" cellspacing="1" border="0" width="100%" class="border">
<tr class="colhead">
<td>Revision</td>
<td>Summary</td>
@@ -83,4 +83,4 @@ class WIKI {
}
} // class
-?> \ No newline at end of file
+?>
diff --git a/classes/script_start.php b/classes/script_start.php
index 18d28b5..147b0ee 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -2534,6 +2534,40 @@ function isset_request($Request, $Keys=NULL, $AllowEmpty = False, $Error=0) {
}
}
+/**
+ * Test if there's an active lock with the given name
+ *
+ * @param string $LockName name on the lock
+ * @return true if lock is active
+ */
+function query_locked($LockName) {
+ global $Cache;
+ if ($Cache->get_value('query_lock_'.$LockName) !== false) {
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Add lock. Expiry time is one hour to avoid indefinite locks
+ *
+ * @param string $LockName name on the lock
+ */
+function set_query_lock($LockName) {
+ global $Cache;
+ $Cache->cache_value('query_lock_'.$LockName, 1, 3600);
+}
+
+/**
+ * Remove lock. Expiry time is one hour to avoid indefinite locks
+ *
+ * @param string $LockName name on the lock
+ */
+function clear_query_lock($LockName) {
+ global $Cache;
+ $Cache->delete_value('query_lock_'.$LockName);
+}
+
$Debug->set_flag('ending function definitions');
//Include /sections/*/index.php
$Document = basename(parse_url($_SERVER['SCRIPT_FILENAME'], PHP_URL_PATH), '.php');