imgurl = $relpath; } else { $this->imgurl = $imgurl; } // title $this->title = $title; // description $this->description = $description; // longitude if (!isset ($lon) || !is_numeric ($lon) || ($lon < -180) || ($lon > 180)) { throw new Exception ($this->err_lonlat_invalid); } $this->lon = $lon; // latitude if (!isset ($lat) || !is_numeric ($lat) || ($lat < -90) || ($lat > 90)) { throw new Exception ($this->err_lonlat_invalid); } $this->lat = $lat; } public function __get ($attr) { if (isset ($this->$attr)) return $this->$attr; else throw new Exception ('Unknow attribute '.$attr); } public function __set ($attr,$value) { throw new Exception ('properties can only be set in constructor'); } public function imgurl_exists () { if (file_exists ($this->imgurl)) { return true; } if (!function_exists ("curl_init")) { return false; } $handle = curl_init ($this->imgurl); if ($handle === false) { return false; } curl_setopt ($handle, CURLOPT_NOBODY, true); curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt ($handle, CURLOPT_TIMEOUT, 10); $connectable = curl_exec ($handle); curl_close ($handle); return $connectable; } } interface anydbConnection { const err_driver_unavailable = 1; const err_connection = 2; const err_unknown_database = 3; const err_query = 3; /* * connect to database; That method may be called multiple times. */ public function connect($host, $user, $pwd, $dbname, $dbprefix); /* * return true if users table already exists */ public function users_table_exists(); /* * create users table; if $error_if_exists is true; throws an err_query * error in case users table already exists. */ public function create_users_table($error_if_exists); /* * return true if items table already exists */ public function items_table_exists(); /* * create items table; if $error_if_exists is true; throws an err_query * error in case items table already exists. */ public function create_items_table($error_if_exists); /* * set password $pwd for user $usrname. If $usrname does not exist, create * it. */ public function setpwd($usrname, $pwd); /* * check that $pwd_md5 is md5 for $username password. */ public function checkpwdmd5($usrname, $pwd_md5); /* * saves feature in database. Returns false if $feature does not exist and * if $feature->imgurl is not accessible; returns true otherwise. */ public function save_feature($feature); /* * delete feature from database. Returns true in case of success, even if * image was not referenced in the database. */ public function delete_feature($feature); /* * Returns feature with given imgurl. If none exists, returns null. */ public function getfeature($imgurl); /* * returns an array of available features */ public function listfeatures(); /* * returns true if a feature with imgurl exists */ public function imgurl_exists($imgurl); /* * returns Minimum Bounding Rectangle containing all feature locations. * That function must return a result even if database is not functional. * Minimum Bounding Rectangle is presented as an Array: * [bottom, left, top, right] */ public function mbr(); /* * get name of database backend */ public function getdbname(); } ?>