diff options
Diffstat (limited to 'shared/classes')
-rw-r--r-- | shared/classes/0sql_row_obj.php | 2 | ||||
-rw-r--r-- | shared/classes/1conf_build_common.php | 4 | ||||
-rw-r--r-- | shared/classes/build.php | 16 | ||||
-rw-r--r-- | shared/classes/configuration.php | 3 | ||||
-rw-r--r-- | shared/classes/gentoo_package.php | 2 | ||||
-rw-r--r-- | shared/classes/gentoo_profile.php | 16 | ||||
-rw-r--r-- | shared/classes/registrationtoken.php | 2 | ||||
-rw-r--r-- | shared/classes/session.php | 10 | ||||
-rw-r--r-- | shared/classes/task.php | 2 | ||||
-rw-r--r-- | shared/classes/validate.php | 4 |
10 files changed, 30 insertions, 31 deletions
diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php index 239dae3..4efacbd 100644 --- a/shared/classes/0sql_row_obj.php +++ b/shared/classes/0sql_row_obj.php @@ -285,8 +285,6 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up if (!array_key_exists($name, $this->db_values) || $this->values[$name] !== $this->db_values[$name]) { $sql_val=$col->sql_value($this->values[$name]); if (is_array($sql_val)) { - //echo $name."\n"; - print_r($sql_val); throw new Exception('Failed to write '.get_class($this).' object to table `'.$this->table.'` because column `'.$name.'` ('.$sql_val['description'].') '.$sql_val['reason'].' (value: '.$sql_val['value'].')'); } if (++$i > 1) { diff --git a/shared/classes/1conf_build_common.php b/shared/classes/1conf_build_common.php index f5721a4..af20eba 100644 --- a/shared/classes/1conf_build_common.php +++ b/shared/classes/1conf_build_common.php @@ -26,7 +26,7 @@ abstract class conf_build_common extends sql_row_obj { global $S; if (!isset($this->opt_cache)) { $this->opt_cache=array(); - $r=$S['pdo']->query('SELECT * FROM `'.$this->info['optstable'].'` WHERE `'.$this->info['self'].'`="'.$this->id.'"'); + $r=query('SELECT * FROM `'.$this->info['optstable'].'` WHERE `'.$this->info['self'].'`="'.$this->id.'"'); while ($opt=$r->fetch(PDO::FETCH_ASSOC)) { $this->opt_cache[$opt['name']]=new $this->info['optsclass']($opt); } @@ -59,7 +59,7 @@ abstract class conf_build_common extends sql_row_obj { while (true) { $id=randstring(6); debug("Trying id=$id..."); - $r=$S['pdo']->query('SELECT `id` FROM `'.$this->table.'` WHERE `id`="'.$id.'"'); + $r=query('SELECT `id` FROM `'.$this->table.'` WHERE `id`="'.$id.'"'); if ($r->rowCount() == 0) { break; } diff --git a/shared/classes/build.php b/shared/classes/build.php index db12801..7230673 100644 --- a/shared/classes/build.php +++ b/shared/classes/build.php @@ -60,8 +60,8 @@ class sql_build extends conf_build_common { $html='<div class="build"><span class="name">'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').'</span> '; $links=array(); if ($this->status == -128) { - $total=$S['pdo']->query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128')->fetch(PDO::FETCH_COLUMN); - $num=$S['pdo']->query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128 AND `ctime` <= '.$this->ctime)->fetch(PDO::FETCH_COLUMN); + $total=query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128')->fetch(PDO::FETCH_COLUMN); + $num=query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128 AND `ctime` <= '.$this->ctime)->fetch(PDO::FETCH_COLUMN); $html.="<span class=\"status queued\">[Queued ($num/$total)]</span>"; } elseif ($this->status == -127) { $html.='<span class="status successful">[uploading]</span>'; @@ -74,7 +74,7 @@ class sql_build extends conf_build_common { $links['Build Log']="build/$this->id"; } } elseif ($this->status == 0) { - $r=$S['pdo']->query('SELECT COUNT(*) as `count`, MAX(`time`) as `time` FROM `downloads` WHERE `build`="'.$this->id.'"')->fetch(PDO::FETCH_ASSOC); + $r=query('SELECT COUNT(*) as `count`, MAX(`time`) as `time` FROM `downloads` WHERE `build`="'.$this->id.'"')->fetch(PDO::FETCH_ASSOC); $d=($perms && $r['count']?'<a href="'.url("build/$this->id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($perms?'</a>':'').'<br/><span class="time">(last at '.date($format, $r['time']).')</span>':''); $html.='<span class="downloads">'.$d.'</span><span class="status successful">[successful]</span>'; $links['Download image']="build/$this->id/download"; @@ -125,15 +125,15 @@ class sql_build extends conf_build_common { global $S; static $cache; if (!isset($cache)) - $cache=$S['pdo']->query('SELECT COUNT(`order`) FROM `tasks` WHERE `start` IS NULL AND `build`="'.$this->id.'"')->fetch(PDO::FETCH_COLUMN); + $cache=query('SELECT COUNT(`order`) FROM `tasks` WHERE `start` IS NULL AND `build`="'.$this->id.'"')->fetch(PDO::FETCH_COLUMN); return $cache; } public function delete() { global $S; - $S['pdo']->query('DELETE FROM `buildlogs` WHERE `build`="'.$this->id.'"'); - $S['pdo']->query('DELETE FROM `tasks` WHERE `build`="'.$this->id.'"'); - $S['pdo']->query('DELETE FROM `buildopts` WHERE `build`="'.$this->id.'"'); - $S['pdo']->query('DELETE FROM `downloads` WHERE `build`="'.$this->id.'"'); + query('DELETE FROM `buildlogs` WHERE `build`="'.$this->id.'"'); + query('DELETE FROM `tasks` WHERE `build`="'.$this->id.'"'); + query('DELETE FROM `buildopts` WHERE `build`="'.$this->id.'"'); + query('DELETE FROM `downloads` WHERE `build`="'.$this->id.'"'); foreach (glob(COMPLETED."/build-.$this->id.*") as $file) unlink($file); parent::delete(); diff --git a/shared/classes/configuration.php b/shared/classes/configuration.php index c6d5766..c7795f4 100644 --- a/shared/classes/configuration.php +++ b/shared/classes/configuration.php @@ -48,6 +48,7 @@ class sql_configuration extends conf_build_common { } } $build=new sql_build(); + $build->visibility='public'; $build->init(); $build->name=$name; $build->module=$this->module; @@ -65,7 +66,7 @@ class sql_configuration extends conf_build_common { // Returns an array of the IDs of all the builds that report this configuration as their source public function get_builds() { global $S; - $r=$S['pdo']->query('SELECT `build` FROM `buildopts` WHERE `name`="configuration" AND `value`="'.$this->id.'"'); + $r=query('SELECT `build` FROM `buildopts` WHERE `name`="configuration" AND `value`="'.$this->id.'"'); if ($r->rowCount()) { $builds=array(); while ($b=$r->fetch(PDO::FETCH_COLUMN)) { diff --git a/shared/classes/gentoo_package.php b/shared/classes/gentoo_package.php index 2c06a26..01d6da4 100644 --- a/shared/classes/gentoo_package.php +++ b/shared/classes/gentoo_package.php @@ -88,7 +88,7 @@ class sql_gentoo_package extends sql_row_obj { } if ($name != '*') $c[]='`name`="'.$name.'"'; $c=implode(' AND ', $c); - $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE '.$c); + $r=query('SELECT * FROM `gentoo_packages` WHERE '.$c); while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) { $pkg=new sql_gentoo_package($pkg); if (!$pkg->is_masked()) diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php index 7184aad..d7726f8 100644 --- a/shared/classes/gentoo_profile.php +++ b/shared/classes/gentoo_profile.php @@ -55,8 +55,8 @@ class sql_gentoo_profile extends sql_row_obj { } // Reads the data from the Packages file in $this->pkgdir public function read_Packages($update_pkgs=false, $verbose=false) { - global $conf; - if (!is_readable($file="{$conf['pkgdir_root']}/$this->pkgdir/Packages")) { + global $S; + if (!is_readable($file="{$S['conf']['pkgdir_root']}/$this->pkgdir/Packages")) { throw_exception("Packages file doesn't exist for pkgdir $this->pkgdir"); } $file=fopen($file, 'r'); @@ -104,7 +104,7 @@ class sql_gentoo_profile extends sql_row_obj { $u=$d=$t=0; if ($update_pkgs) { global $S; - $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id); + $r=query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id); while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) { $pkg=new sql_gentoo_package($pkg); if (isset($p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version])) { @@ -152,7 +152,7 @@ class sql_gentoo_profile extends sql_row_obj { $name=array_shift($pkgs); $obj=new sql_gentoo_pkgset(); if ($update) { - $r=$S['pdo']->query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.' AND `name`="'.$name.'" LIMIT 1'); + $r=query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.' AND `name`="'.$name.'" LIMIT 1'); if ($r->rowCount()) $obj->from_array($r->fetch(PDO::FETCH_ASSOC), true); } @@ -169,13 +169,13 @@ class sql_gentoo_profile extends sql_row_obj { } } if ($update) - $S['pdo']->query('DELETE FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.($exists?' AND `id` NOT IN ('.implode(',', $exists).')':'')); + query('DELETE FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.($exists?' AND `id` NOT IN ('.implode(',', $exists).')':'')); } public function read_stage3($update=false) { global $S; if ($update) { - $S['pdo']->query('DELETE FROM `gentoo_basepkgs` WHERE `profile`='.$this->id); - $S['pdo']->query('DELETE FROM `gentoo_baseinit` WHERE `profile`='.$this->id); + query('DELETE FROM `gentoo_basepkgs` WHERE `profile`='.$this->id); + query('DELETE FROM `gentoo_baseinit` WHERE `profile`='.$this->id); } $file=realpath(CACHE.'/stage3/'.$this->stage3); if (!is_readable($file)) return false; @@ -198,7 +198,7 @@ class sql_gentoo_profile extends sql_row_obj { public function &get_packages($omit_masked=false, $trim=null) { global $S; $skip_masked=!in_array('masked', $trim); - $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id); + $r=query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id); $p=array(); while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) { $pkg=new sql_gentoo_package($pkg); diff --git a/shared/classes/registrationtoken.php b/shared/classes/registrationtoken.php index 9f331ae..93fe4e6 100644 --- a/shared/classes/registrationtoken.php +++ b/shared/classes/registrationtoken.php @@ -33,7 +33,7 @@ class sql_registrationtoken extends sql_row_obj { $id=null; do { $id=randstring(30); - if ($S['pdo']->query('SELECT COUNT(*) FROM `registrationtokens` WHERE `id`=\''.$id.'\'')->fetch(PDO::FETCH_COLUMN)) + if (query('SELECT COUNT(*) FROM `registrationtokens` WHERE `id`=\''.$id.'\'')->fetch(PDO::FETCH_COLUMN)) $id=null; } while ($id==null); return new sql_registrationtoken($id, null, null, null); diff --git a/shared/classes/session.php b/shared/classes/session.php index e422b21..1233a71 100644 --- a/shared/classes/session.php +++ b/shared/classes/session.php @@ -33,18 +33,18 @@ class sql_session extends sql_row_obj { ); // Creates a new session for the user at $S['user'] with a unique id, sends a cookie to the user and returns true for success, false for failure static function create() { - global $S, $conf; + global $S; $id=null; while (!$id) { $id=randstring(30); - $r=$S['pdo']->query('SELECT * FROM `sessions` WHERE `id`="'.$id.'"'); + $r=query('SELECT * FROM `sessions` WHERE `id`="'.$id.'"'); if ($r->rowCount()) { $id=null; } } - $S['session']=new sql_session($id, $S['user']->id, time(), $conf['sessionlength']); - debug('setcookie', $conf['cookiename'].'='.$id); - if (setcookie($conf['cookiename'], $S['session']->id, time()+$conf['sessionlength'], $S['cookie_dir'], '', false, true)) { + $S['session']=new sql_session($id, $S['user']->id, time(), $S['conf']['sessionlength']); + debug('setcookie', $S['conf']['cookiename'].'='.$id); + if (setcookie($S['conf']['cookiename'], $S['session']->id, time()+$S['conf']['sessionlength'], $S['cookie_dir'], '', false, true)) { $S['session']->write(); return true; } else { diff --git a/shared/classes/task.php b/shared/classes/task.php index cdcd15c..d763107 100644 --- a/shared/classes/task.php +++ b/shared/classes/task.php @@ -73,7 +73,7 @@ class sql_task extends sql_row_obj { $html.='<span class="status running">[running]</span> <span class="time">Running for <span class="time">'.display_time(time()-$this->start).'</span></span>'; } } else { - $num=$S['pdo']->query('SELECT COUNT(*) FROM `tasks` WHERE `builds`="'.$this->build.'" AND `start` IS NULL AND `order` <= '.$this->order)->fetch(PDO::FETCH_ASSOC); + $num=query('SELECT COUNT(*) FROM `tasks` WHERE `builds`="'.$this->build.'" AND `start` IS NULL AND `order` <= '.$this->order)->fetch(PDO::FETCH_ASSOC); $html.="<span class=\"status queued\">[queued $num/".$build->queued_tasks()."]</span>"; } $html.='</div></div>'; diff --git a/shared/classes/validate.php b/shared/classes/validate.php index c409db4..6c6f479 100644 --- a/shared/classes/validate.php +++ b/shared/classes/validate.php @@ -37,8 +37,8 @@ class Validate { } } // Checking DNS to make sure the domain is real is total overkill - global $conf; - if ($conf['check_email_dns'] && $isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { + global $S; + if ($S['conf']['check_email_dns'] && $isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } |