Mercurial > SimpleWebPresenter
comparison sitemap.php @ 44:79f708a48a7c
Added a constants include.
Refactored out functions from sitemap.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Mon, 08 Oct 2012 02:01:04 +0200 |
| parents | f37be50a70cf |
| children | 2cfea6e84694 3898353ed1d8 |
comparison
equal
deleted
inserted
replaced
| 43:f42dbf44b661 | 44:79f708a48a7c |
|---|---|
| 7 xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" | 7 xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" |
| 8 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 8 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 9 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 | 9 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 |
| 10 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> | 10 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> |
| 11 <? | 11 <? |
| 12 include_once('php/Options.inc'); | 12 include_once 'CacheTimeCheck.inc'; |
| 13 | 13 |
| 14 function startswith($haystack, $needle) { | 14 $cache = CacheTimeCheck::instance(__FILE__); |
| 15 return strpos($haystack, $needle) === 0; | 15 $cache->includeOnce('Options.inc', dirname(__FILE__)); |
| 16 } | |
| 17 | |
| 18 function endsWith($haystack, $needle) { | |
| 19 $l = strlen($haystack) - strlen($needle); | |
| 20 return strrpos($haystack, $needle) === $l; | |
| 21 } | |
| 22 | |
| 23 function getHeaders($url) | |
| 24 { | |
| 25 $response = http_head($url, array("timeout"=>1), $info); | |
| 26 $headers = array(); | |
| 27 $str = explode("\n", $response); | |
| 28 foreach($str as $kv) { | |
| 29 $p = strpos($kv, ":"); | |
| 30 if ($p) { | |
| 31 $key = substr($kv, 0, $p); | |
| 32 $value = trim(substr($kv, $p + 1)); | |
| 33 $headers[$key] = $value; | |
| 34 } | |
| 35 } | |
| 36 return $headers; | |
| 37 } | |
| 38 | |
| 39 function opttostring($opts) | |
| 40 { | |
| 41 $str = ''; | |
| 42 foreach (array_keys($opts) as $key) { | |
| 43 $value = $opts[$key]; | |
| 44 if ($str) { | |
| 45 $str .= "&${key}=${value}"; | |
| 46 } | |
| 47 else { | |
| 48 $str = "?${key}=${value}"; | |
| 49 } | |
| 50 } | |
| 51 return $str; | |
| 52 } | |
| 53 | |
| 54 | 16 |
| 55 $master = new DOMDocument(); | 17 $master = new DOMDocument(); |
| 56 $master->load("master.xml"); | 18 $master->load("master.xml"); |
| 57 | 19 |
| 58 $options = new Options($master); | 20 $options = new Options($master); |
