From fa49c7df3c8ef793c380fa68d51fbc9d01f609d1 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 27 Jun 2005 08:41:53 +0000 Subject: fix broken requires due to file move --- lib/class/access.class.php | 189 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 lib/class/access.class.php (limited to 'lib/class/access.class.php') diff --git a/lib/class/access.class.php b/lib/class/access.class.php new file mode 100644 index 00000000..6e6afbf2 --- /dev/null +++ b/lib/class/access.class.php @@ -0,0 +1,189 @@ +id = $access_id; + + /* Get the information from the db */ + if ($info = $this->get_info()) { + + /* Assign Vars */ + $this->name = $info->name; + $this->start = $info->start; + $this->end = $info->end; + $this->level = $info->level; + } // if info + + } // if access_id + + } //constructor + + /*! + @function get_info + @discussion get's the vars for $this out of the database + @param $this->id Taken from the object + */ + function get_info() { + + /* Grab the basic information from the catalog and return it */ + $sql = "SELECT * FROM access_list WHERE id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + + $results = mysql_fetch_object($db_results); + + return $results; + + } //get_info + + /*! + @function create + @discussion creates a new entry + */ + function create($name,$start,$end,$level) { + + $start = ip2int($start); + $end = ip2int($end); + $name = sql_escape($name); + $level = intval($level); + + $sql = "INSERT INTO access_list (`name`,`level`,`start`,`end`) VALUES ". + "('$name','$level','$start','$end')"; + $db_results = mysql_query($sql, dbh()); + + } // create + + /*! + @function delete + @discussion deletes $this access_list entry + */ + function delete($access_id=0) { + + if (!$access_id) { + $access_id = $this->id; + } + + $sql = "DELETE FROM access_list WHERE id='$access_id'"; + $db_results = mysql_query($sql, dbh()); + + } // delete + + /*! + @function check + @discussion check to see if they have rights + */ + function check($needed, $ip) { + + // They aren't using access control + // lets just keep on trucking + if (!conf('access_control')) { + return true; + } + + $ip = ip2int($ip); + + $sql = "SELECT id FROM access_list WHERE start<='$ip' AND end>='$ip' AND level>='$needed'"; + $db_results = mysql_query($sql, dbh()); + + // Yah they have access they can use the mojo + if (mysql_fetch_row($db_results)) { + return true; + } + + // No Access Sucks to be them. + else { + return false; + } + + } // check + + /*! + @function get_access_list + @discussion returns a full listing of all access + rules on this server + */ + function get_access_list() { + + $sql = "SELECT * FROM access_list"; + $db_results = mysql_query($sql, dbh()); + + + while ($r = mysql_fetch_object($db_results)) { + $obj = new Access(); + $obj->id = $r->id; + $obj->start = $r->start; + $obj->end = $r->end; + $obj->name = $r->name; + $obj->level = $r->level; + $results[] = $obj; + } // end while access list mojo + + return $results; + + } // get_access_list + + + /*! + @function get_level_name + @discussion take the int level and return a + named level + */ + function get_level_name() { + + if ($this->level == '75') { + return "Full Access"; + } + if ($this->level == '5') { + return "Demo"; + } + if ($this->level == '25') { + return "Stream"; + } + if ($this->level == '50') { + return "Stream/Download"; + } + + + } // get_level_name + +} //end of access class + +?> -- cgit