base = $_SERVER['argc'] >= 2 ? $_SERVER['argv'][1] : 'http://localhost/wordpress/app.php'; $this->user = $_SERVER['argc'] >= 3 ? $_SERVER['argv'][2] : 'demo'; $this->password = $_SERVER['argc'] >= 3 ? $_SERVER['argv'][3] : 'demo'; } // credentials function get_user() { return $this->user; } function get_password() { return $this->password; } // urls function get_base_url() { return $this->base; } function get_service_url() { return $this->base . "/service"; } function get_posts_url() { return $this->base . "/posts"; } function get_categories_url() { return $this->base . "/categories"; } function get_attachments_url() { return $this->base . "/attachments"; } // content-types function get_atom_content_type() { return 'application/atom+xml'; } function get_atom_entry_content_type() { return 'application/atom+xml;type=entry'; } function get_atom_feed_content_type() { return 'application/atom+xml;type=feed'; } function get_atom_service_content_type() { return 'application/atomsvc+xml'; } function get_atom_categories_content_type() { return 'application/atomcat+xml'; } // http utilities function get_header($headers, $header) { $lines = split("\r\n", $headers); foreach ($lines as $line) { $components = split(':', $line, 2); if($components[0] == $header) return $components[1]; } } } // date function rfc3339_str2time($str) { $match = false; if(!preg_match("/(\d{4}-\d{2}-\d{2})T(\d{2}\:\d{2}\:\d{2})\.?\d{0,3}(Z|[+-]+\d{2}\:\d{2})/", $str, $match)) return false; if($match[3] == 'Z') $match[3] == '+0000'; return strtotime($match[1] . " " . $match[2] . " " . $match[3]); } // I18N function asciiToUtf8 ($str) { $str = fixCharacters ($str); $str = preg_replace_callback ('/&#([0-9]+);/',create_function ('$s','return code2utf($s[1]);'),$str); $str = preg_replace_callback ('/&#x([a-f0-9]+);/i',create_function ('$s','return code2utf(hexdec($s[1]));'),$str); return $str; } function fixCharacters ($str) { $r = array ('€' =>'€','' =>'','‚' =>'‚','ƒ' =>'ƒ', '„' =>'„','…' =>'…','†' =>'†','‡' =>'‡', 'ˆ' =>'ˆ','‰' =>'‰','Š' =>'Š','‹' =>'‹', 'Œ' =>'Œ','' =>'','Ž' =>'Ž', '' =>'','' =>'', '‘' =>'‘','’' =>'’','“' =>'“','”' =>'”', '•' =>'•','–' =>'–','—' =>'—','˜' =>'˜', '™' =>'™','š' =>'š','›' =>'›','œ' =>'œ', '' =>'','ž' =>'ž', 'Ÿ' =>'Ÿ'); return strtr ($str, $r); } // From php.net: function code2utf ($num) { if ($num < 128) { return chr ($num); } if ($num < 2048) { return chr (($num >> 6) + 192).chr (($num & 63) + 128); } if ($num < 65536) { return chr (($num >> 12) + 224).chr ((($num >> 6) & 63) + 128).chr (($num & 63) + 128); } if ($num < 2097152) { return chr (($num >> 18) + 240).chr ((($num >> 12) & 63) + 128).chr ((($num >> 6) & 63) + 128).chr (($num & 63) + 128); } return ''; } ?>