Changeset 1631 for trunk/website/scripts/downloads.php
- Timestamp:
- 1/22/2010 12:30:40 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/website/scripts/downloads.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/website/scripts/downloads.php
r1630 r1631 115 115 public function Build($branch, $revision) 116 116 { 117 $query = mysql_query(sprintf('SELECT downloads.DownloadID FROM downloads INNER JOIN builds ON 118 downloads.DownloadID=builds.DownloadID WHERE 119 builds.Branch=\'%s\' AND builds.Revision=%d', 117 $query = mysql_query(sprintf('SELECT DownloadID FROM builds WHERE 118 Branch=\'%s\' AND Revision=%d', 120 119 mysql_real_escape_string($branch), intval($revision))); 121 120 … … 123 122 if (($row = mysql_fetch_row($query)) === false || !$row[0]) 124 123 { 125 $this->ID = Build::InsertBuild($branch, $revision);124 throw new Exception('Build does not exist'); 126 125 } 127 126 else … … 150 149 continue; 151 150 152 try 151 $pathInfo = pathinfo($revision); 152 $revisionID = intval(substr($pathInfo['filename'], 1)); 153 if (Build::BuildExists($branchName, $revisionID)) 153 154 { 154 $result[$buildName][] = new Build($branchName, intval(substr($revision, 1)));155 $result[$buildName][] = new Build($branchName, $revisionID); 155 156 } 156 catch (Exception $e)157 else 157 158 { 159 $result[$buildName][] = Build::GetBuildFromID( 160 Build::InsertBuild($branchName, $revisionID, 161 Build::GetPath($branchName, $revision))); 158 162 } 159 163 } … … 161 165 162 166 return $result; 167 } 168 169 public static function BuildExists($branch, $revision) 170 { 171 $query = mysql_query(sprintf('SELECT DownloadID FROM builds WHERE 172 Branch=\'%s\' AND Revision=%d', 173 mysql_real_escape_string($branch), intval($revision))); 174 return mysql_num_rows($query) == 1; 163 175 } 164 176 … … 192 204 } 193 205 194 private static function InsertBuild($branch, $revision )206 private static function InsertBuild($branch, $revision, $buildPath) 195 207 { 196 208 //Find the binary that users will get to download. 197 $buildPath = Build::GetPath($branch, $revision);198 209 $installerPath = null; 199 210 … … 220 231 else if (is_file($buildPath)) 221 232 { 222 $installerPath = sprintf('builds/%s/r%s', $branch, $revision);233 $installerPath = sprintf('builds/%s/r%s', $branch, basename($buildPath)); 223 234 } 224 235
Note: See TracChangeset
for help on using the changeset viewer.
