From 24503e3abe705acde2df159aeae61be0d009f92e Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Wed, 19 Nov 2008 17:27:03 -0500 Subject: Imported sources --- .htaccess | 37 + favicon.ico | Bin 0 -> 1406 bytes header.inc | 25 + headerproc.php | 31 + includes/bbcode.php | 151 ++ includes/comments.php | 97 + includes/db.php | 49 + includes/definitions.php | 52 + includes/footer.php | 198 ++ includes/functions.php | 244 ++ includes/functions_quotes.php | 195 ++ includes/header.php | 66 + includes/hits.php | 102 + includes/http.php | 1982 +++++++++++++++ includes/index.php | 5 + includes/phpsvnclient.php | 420 ++++ includes/recaptchalib.php | 277 +++ includes/session.php | 61 + includes/specialdates.php | 314 +++ includes/template.php | 164 ++ includes/updatePending.php | 51 + includes/xml_parser.php | 427 ++++ includes/xmlrpc/array_key_exists.php | 55 + includes/xmlrpc/is_a.php | 47 + includes/xmlrpc/is_callable.php | 53 + includes/xmlrpc/is_scalar.php | 38 + includes/xmlrpc/var_export.php | 105 + includes/xmlrpc/version_compare.php | 179 ++ includes/xmlrpc/xmlrpc.inc | 3705 +++++++++++++++++++++++++++++ includes/xmlrpc/xmlrpc_wrappers.inc | 819 +++++++ includes/xmlrpc/xmlrpcs.inc | 1193 ++++++++++ index.php | 56 + ipdetails.txt | 1 + pages/addresses.php | 74 + pages/admin.php | 661 +++++ pages/blog.php | 197 ++ pages/comic.php | 177 ++ pages/error.php | 84 + pages/fourm.php | 27 + pages/holidates.php | 10 + pages/login.php | 64 + pages/logout.php | 28 + pages/poll.php | 85 + pages/polloftheweek.php | 73 + pages/post.php | 107 + pages/projects.php | 94 + pages/quotes.php | 166 ++ pages/splash.php | 28 + pages/vote.php | 115 + pages/welcome.php | 81 + pages/wiki.php | 179 ++ rss.php | 334 +++ theme/addresses.tpl | 9 + theme/admin/deleteDraft.tpl | 6 + theme/admin/deletePending.tpl | 6 + theme/admin/deletePost.tpl | 6 + theme/admin/deletedDraft.tpl | 6 + theme/admin/deletedPending.tpl | 6 + theme/admin/deletedPost.tpl | 6 + theme/admin/draftSuccess.tpl | 8 + theme/admin/editDraft.tpl | 16 + theme/admin/editPending.tpl | 10 + theme/admin/editPost.tpl | 10 + theme/admin/index.tpl | 31 + theme/admin/manageDrafts.tpl | 24 + theme/admin/managePages.tpl | 23 + theme/admin/managePending.tpl | 24 + theme/admin/managePendingQuotes.tpl | 21 + theme/admin/managePosts.tpl | 24 + theme/admin/moderateComments.tpl | 24 + theme/admin/newPoll.tpl | 10 + theme/admin/pageHistory.tpl | 23 + theme/admin/pendingSuccess.tpl | 8 + theme/admin/pollrss.tpl | 6 + theme/admin/postSuccess.tpl | 8 + theme/admin/viewComment.tpl | 12 + theme/admin/viewRevision.tpl | 5 + theme/admin/write.tpl | 16 + theme/archive.tpl | 43 + theme/comic.tpl | 46 + theme/comicarchive.tpl | 37 + theme/comments.tpl | 49 + theme/css.php | 40 + theme/css/backgrounds.php | 148 ++ theme/css/bubbles.css | 71 + theme/css/headers.php | 85 + theme/css/navigation.php | 198 ++ theme/css/quotes.php | 199 ++ theme/css/thickbox.css | 164 ++ theme/css/uniform.php | 270 +++ theme/css/website.php | 843 +++++++ theme/datefinder.tpl | 0 theme/errors/404.tpl | 64 + theme/footer.tpl | 241 ++ theme/footer.tpl~ | 225 ++ theme/header.tpl | 64 + theme/hits.tpl | 0 theme/images/Fourm.gif | Bin 0 -> 23001 bytes theme/images/Fourm_ro.gif | Bin 0 -> 23013 bytes theme/images/Home.gif | Bin 0 -> 22992 bytes theme/images/Home_ro.gif | Bin 0 -> 23014 bytes theme/images/Links.gif | Bin 0 -> 22985 bytes theme/images/Links_ro.gif | Bin 0 -> 23005 bytes theme/images/Login.gif | Bin 0 -> 23311 bytes theme/images/Login_ro.gif | Bin 0 -> 23552 bytes theme/images/Logout.gif | Bin 0 -> 23470 bytes theme/images/Logout_ro.gif | Bin 0 -> 23613 bytes theme/images/Panel.gif | Bin 0 -> 23368 bytes theme/images/Panel_ro.gif | Bin 0 -> 23577 bytes theme/images/Poll.gif | Bin 0 -> 23161 bytes theme/images/Poll_ro.gif | Bin 0 -> 23476 bytes theme/images/Projects.gif | Bin 0 -> 23098 bytes theme/images/Projects_ro.gif | Bin 0 -> 23033 bytes theme/images/Quotes.gif | Bin 0 -> 23969 bytes theme/images/Quotes_ro.gif | Bin 0 -> 23717 bytes theme/images/Random.gif | Bin 0 -> 23142 bytes theme/images/Random_ro.gif | Bin 0 -> 23043 bytes theme/images/Wiki.gif | Bin 0 -> 23256 bytes theme/images/Wiki_ro.gif | Bin 0 -> 23551 bytes theme/images/authors/Hatkirby.ico | Bin 0 -> 1150 bytes theme/images/authors/Starla.ico | Bin 0 -> 1150 bytes theme/images/backgrounds/4ofjuly.PNG | Bin 0 -> 16866 bytes theme/images/backgrounds/ashWeds.PNG | Bin 0 -> 14191 bytes theme/images/backgrounds/christmas.PNG | Bin 0 -> 14513 bytes theme/images/backgrounds/christmasEve.PNG | Bin 0 -> 11391 bytes theme/images/backgrounds/columbus.PNG | Bin 0 -> 14016 bytes theme/images/backgrounds/easter.PNG | Bin 0 -> 14073 bytes theme/images/backgrounds/fathers.PNG | Bin 0 -> 14976 bytes theme/images/backgrounds/flagDay.PNG | Bin 0 -> 14476 bytes theme/images/backgrounds/goodFriday.PNG | Bin 0 -> 12776 bytes theme/images/backgrounds/groundhog.PNG | Bin 0 -> 13936 bytes theme/images/backgrounds/halloween.PNG | Bin 0 -> 10937 bytes theme/images/backgrounds/hatkirbybday.PNG | Bin 0 -> 16655 bytes theme/images/backgrounds/island.PNG | Bin 0 -> 14751 bytes theme/images/backgrounds/island2.PNG | Bin 0 -> 19372 bytes theme/images/backgrounds/island3.PNG | Bin 0 -> 19848 bytes theme/images/backgrounds/island4.PNG | Bin 0 -> 21981 bytes theme/images/backgrounds/island5.PNG | Bin 0 -> 10225 bytes theme/images/backgrounds/island6.PNG | Bin 0 -> 13330 bytes theme/images/backgrounds/island6night.PNG | Bin 0 -> 10203 bytes theme/images/backgrounds/islandYearly.PNG | Bin 0 -> 16259 bytes theme/images/backgrounds/kirbyweek.PNG | Bin 0 -> 16824 bytes theme/images/backgrounds/mardiGras.PNG | Bin 0 -> 14333 bytes theme/images/backgrounds/martinLuther.PNG | Bin 0 -> 14114 bytes theme/images/backgrounds/memorial.PNG | Bin 0 -> 22185 bytes theme/images/backgrounds/mothers.PNG | Bin 0 -> 15125 bytes theme/images/backgrounds/newYear.PNG | Bin 0 -> 14184 bytes theme/images/backgrounds/newYearsEve.PNG | Bin 0 -> 12160 bytes theme/images/backgrounds/valentines.PNG | Bin 0 -> 15108 bytes theme/images/backgrounds/veterans.PNG | Bin 0 -> 13997 bytes theme/images/bg_body.gif | Bin 0 -> 421 bytes theme/images/bg_body_short.gif | Bin 0 -> 384 bytes theme/images/bg_footer.gif | Bin 0 -> 114 bytes theme/images/bg_header.gif | Bin 0 -> 642 bytes theme/images/bg_navbar.gif | Bin 0 -> 206 bytes theme/images/bg_search.gif | Bin 0 -> 837 bytes theme/images/blue.PNG | Bin 0 -> 125 bytes theme/images/corners_bottom.gif | Bin 0 -> 708 bytes theme/images/corners_left.png | Bin 0 -> 195 bytes theme/images/corners_right.png | Bin 0 -> 201 bytes theme/images/date-bg-1.gif | Bin 0 -> 2322 bytes theme/images/date-bg-2.gif | Bin 0 -> 2322 bytes theme/images/date-bg-3.gif | Bin 0 -> 2322 bytes theme/images/date-bg-4.gif | Bin 0 -> 2322 bytes theme/images/headers/ctnh.png | Bin 0 -> 20000 bytes theme/images/headers/fourm.png | Bin 0 -> 10596 bytes theme/images/headers/hatkirbybday.png | Bin 0 -> 12384 bytes theme/images/headers/islandYearly.png | Bin 0 -> 4527 bytes theme/images/headers/kfm.png | Bin 0 -> 10819 bytes theme/images/headers/links.png | Bin 0 -> 10711 bytes theme/images/headers/main.png | Bin 0 -> 12479 bytes theme/images/headers/main.xcf | Bin 0 -> 62769 bytes theme/images/headers/memorial.png | Bin 0 -> 11355 bytes theme/images/headers/mothers.png | Bin 0 -> 12532 bytes theme/images/headers/potw.png | Bin 0 -> 10919 bytes theme/images/headers/projects.png | Bin 0 -> 12846 bytes theme/images/headers/projects.xcf | Bin 0 -> 87437 bytes theme/images/headers/quotes.png | Bin 0 -> 12260 bytes theme/images/headers/random.png | Bin 0 -> 11632 bytes theme/images/headers/short.png | Bin 0 -> 10776 bytes theme/images/home.png | Bin 0 -> 673 bytes theme/images/icons/16-clock.png | Bin 0 -> 283 bytes theme/images/icons/16-em-pencil.png | Bin 0 -> 230 bytes theme/images/icons/16-file-archive.png | Bin 0 -> 251 bytes theme/images/icons/16-file-page.png | Bin 0 -> 319 bytes theme/images/icons/16-message-warn.png | Bin 0 -> 326 bytes theme/images/icons/16-star-hot.png | Bin 0 -> 296 bytes theme/images/icons/book_open.png | Bin 0 -> 622 bytes theme/images/icons/bricks.png | Bin 0 -> 825 bytes theme/images/icons/comment.png | Bin 0 -> 413 bytes theme/images/icons/comment_add.png | Bin 0 -> 530 bytes theme/images/icons/comments.png | Bin 0 -> 557 bytes theme/images/icons/computer.png | Bin 0 -> 667 bytes theme/images/icons/controller.png | Bin 0 -> 666 bytes theme/images/icons/css_valid.png | Bin 0 -> 661 bytes theme/images/icons/door_in.png | Bin 0 -> 693 bytes theme/images/icons/door_out.png | Bin 0 -> 688 bytes theme/images/icons/feed.png | Bin 0 -> 691 bytes theme/images/icons/fourm.png | Bin 0 -> 773 bytes theme/images/icons/house.png | Bin 0 -> 806 bytes theme/images/icons/html_valid.png | Bin 0 -> 704 bytes theme/images/icons/link_delete.png | Bin 0 -> 600 bytes theme/images/icons/link_edit.png | Bin 0 -> 703 bytes theme/images/icons/medal_gold_1.png | Bin 0 -> 629 bytes theme/images/icons/new.png | Bin 0 -> 378 bytes theme/images/icons/newspaper.png | Bin 0 -> 658 bytes theme/images/icons/note.png | Bin 0 -> 500 bytes theme/images/icons/note_delete.png | Bin 0 -> 631 bytes theme/images/icons/note_edit.png | Bin 0 -> 731 bytes theme/images/icons/note_go.png | Bin 0 -> 661 bytes theme/images/icons/overlays.png | Bin 0 -> 716 bytes theme/images/icons/page_attach.png | Bin 0 -> 794 bytes theme/images/icons/page_delete.png | Bin 0 -> 740 bytes theme/images/icons/page_edit.png | Bin 0 -> 807 bytes theme/images/icons/page_go.png | Bin 0 -> 779 bytes theme/images/icons/rainbow.png | Bin 0 -> 655 bytes theme/images/icons/report.png | Bin 0 -> 649 bytes theme/images/icons/script.png | Bin 0 -> 748 bytes theme/images/icons/tag.png | Bin 0 -> 389 bytes theme/images/icons/tag_blue.png | Bin 0 -> 586 bytes theme/images/icons/tag_blue_add.png | Bin 0 -> 671 bytes theme/images/icons/tag_blue_delete.png | Bin 0 -> 701 bytes theme/images/icons/tag_blue_edit.png | Bin 0 -> 748 bytes theme/images/icons/tag_green.png | Bin 0 -> 613 bytes theme/images/icons/tag_orange.png | Bin 0 -> 586 bytes theme/images/icons/tag_pink.png | Bin 0 -> 579 bytes theme/images/icons/tag_purple.png | Bin 0 -> 599 bytes theme/images/icons/tag_red.png | Bin 0 -> 592 bytes theme/images/icons/tag_yellow.png | Bin 0 -> 586 bytes theme/images/icons/thumb_down.png | Bin 0 -> 601 bytes theme/images/icons/thumb_up.png | Bin 0 -> 619 bytes theme/images/icons/tux.png | Bin 0 -> 696 bytes theme/images/icons/user_edit.png | Bin 0 -> 833 bytes theme/images/icons/vcard.png | Bin 0 -> 533 bytes theme/images/loadingAnimation.gif | Bin 0 -> 5886 bytes theme/images/misc.png | Bin 0 -> 720 bytes theme/images/no-ie6.png | Bin 0 -> 18666 bytes theme/images/projects.png | Bin 0 -> 794 bytes theme/images/sides_top.gif | Bin 0 -> 2559 bytes theme/images/tabBG.png | Bin 0 -> 2473 bytes theme/images/tabBG2.png | Bin 0 -> 2722 bytes theme/images/tabSe.png | Bin 0 -> 258 bytes theme/images/tabUn.png | Bin 0 -> 260 bytes theme/images/tip-pimped.gif | Bin 0 -> 102 bytes theme/images/tip-rounded.gif | Bin 0 -> 102 bytes theme/images/tip.gif | Bin 0 -> 64 bytes theme/images/webs.png | Bin 0 -> 772 bytes theme/images/youdropifollow.jpg | Bin 0 -> 6825 bytes theme/js/jquery-1.2.6.min.js | 32 + theme/js/jquery.ie6blocker.js | 34 + theme/js/message.js | 5 + theme/js/round_bubbles.js | 13 + theme/js/rounded_corners.inc.js | 279 +++ theme/js/thickbox.js | 328 +++ theme/login.tpl | 18 + theme/msg.tpl | 1 + theme/msg2.tpl | 1 + theme/poll.tpl | 30 + theme/pollIndex.tpl | 12 + theme/polloftheweek.tpl | 59 + theme/post.tpl | 66 + theme/postLogin.tpl | 16 + theme/quotes/add.tpl | 17 + theme/quotes/add_news.tpl | 8 + theme/quotes/browse.tpl | 25 + theme/quotes/home.tpl | 10 + theme/quotes/pagenumbers.tpl | 15 + theme/quotes/search.tpl | 19 + theme/related.tpl | 12 + theme/welcome.tpl | 5 + theme/wiki/create.tpl | 7 + theme/wiki/edit.tpl | 6 + theme/wiki/index.tpl | 6 + theme/wiki/page.tpl | 3 + thumb.php | 147 ++ xmlrpc.php | 101 + 276 files changed, 18193 insertions(+) create mode 100644 .htaccess create mode 100755 favicon.ico create mode 100644 header.inc create mode 100644 headerproc.php create mode 100644 includes/bbcode.php create mode 100644 includes/comments.php create mode 100755 includes/db.php create mode 100644 includes/definitions.php create mode 100644 includes/footer.php create mode 100644 includes/functions.php create mode 100644 includes/functions_quotes.php create mode 100644 includes/header.php create mode 100644 includes/hits.php create mode 100644 includes/http.php create mode 100644 includes/index.php create mode 100644 includes/phpsvnclient.php create mode 100644 includes/recaptchalib.php create mode 100644 includes/session.php create mode 100755 includes/specialdates.php create mode 100644 includes/template.php create mode 100644 includes/updatePending.php create mode 100644 includes/xml_parser.php create mode 100644 includes/xmlrpc/array_key_exists.php create mode 100644 includes/xmlrpc/is_a.php create mode 100644 includes/xmlrpc/is_callable.php create mode 100644 includes/xmlrpc/is_scalar.php create mode 100644 includes/xmlrpc/var_export.php create mode 100644 includes/xmlrpc/version_compare.php create mode 100644 includes/xmlrpc/xmlrpc.inc create mode 100644 includes/xmlrpc/xmlrpc_wrappers.inc create mode 100644 includes/xmlrpc/xmlrpcs.inc create mode 100644 index.php create mode 100755 ipdetails.txt create mode 100644 pages/addresses.php create mode 100644 pages/admin.php create mode 100644 pages/blog.php create mode 100644 pages/comic.php create mode 100644 pages/error.php create mode 100644 pages/fourm.php create mode 100644 pages/holidates.php create mode 100644 pages/login.php create mode 100644 pages/logout.php create mode 100644 pages/poll.php create mode 100644 pages/polloftheweek.php create mode 100644 pages/post.php create mode 100644 pages/projects.php create mode 100644 pages/quotes.php create mode 100644 pages/splash.php create mode 100644 pages/vote.php create mode 100644 pages/welcome.php create mode 100644 pages/wiki.php create mode 100644 rss.php create mode 100644 theme/addresses.tpl create mode 100644 theme/admin/deleteDraft.tpl create mode 100644 theme/admin/deletePending.tpl create mode 100644 theme/admin/deletePost.tpl create mode 100644 theme/admin/deletedDraft.tpl create mode 100644 theme/admin/deletedPending.tpl create mode 100644 theme/admin/deletedPost.tpl create mode 100644 theme/admin/draftSuccess.tpl create mode 100644 theme/admin/editDraft.tpl create mode 100644 theme/admin/editPending.tpl create mode 100644 theme/admin/editPost.tpl create mode 100644 theme/admin/index.tpl create mode 100644 theme/admin/manageDrafts.tpl create mode 100644 theme/admin/managePages.tpl create mode 100644 theme/admin/managePending.tpl create mode 100644 theme/admin/managePendingQuotes.tpl create mode 100644 theme/admin/managePosts.tpl create mode 100644 theme/admin/moderateComments.tpl create mode 100644 theme/admin/newPoll.tpl create mode 100644 theme/admin/pageHistory.tpl create mode 100644 theme/admin/pendingSuccess.tpl create mode 100644 theme/admin/pollrss.tpl create mode 100644 theme/admin/postSuccess.tpl create mode 100644 theme/admin/viewComment.tpl create mode 100644 theme/admin/viewRevision.tpl create mode 100644 theme/admin/write.tpl create mode 100644 theme/archive.tpl create mode 100644 theme/comic.tpl create mode 100644 theme/comicarchive.tpl create mode 100644 theme/comments.tpl create mode 100755 theme/css.php create mode 100755 theme/css/backgrounds.php create mode 100644 theme/css/bubbles.css create mode 100755 theme/css/headers.php create mode 100755 theme/css/navigation.php create mode 100644 theme/css/quotes.php create mode 100755 theme/css/thickbox.css create mode 100644 theme/css/uniform.php create mode 100755 theme/css/website.php create mode 100644 theme/datefinder.tpl create mode 100644 theme/errors/404.tpl create mode 100644 theme/footer.tpl create mode 100644 theme/footer.tpl~ create mode 100644 theme/header.tpl create mode 100644 theme/hits.tpl create mode 100755 theme/images/Fourm.gif create mode 100755 theme/images/Fourm_ro.gif create mode 100755 theme/images/Home.gif create mode 100755 theme/images/Home_ro.gif create mode 100755 theme/images/Links.gif create mode 100755 theme/images/Links_ro.gif create mode 100644 theme/images/Login.gif create mode 100644 theme/images/Login_ro.gif create mode 100644 theme/images/Logout.gif create mode 100644 theme/images/Logout_ro.gif create mode 100644 theme/images/Panel.gif create mode 100644 theme/images/Panel_ro.gif create mode 100644 theme/images/Poll.gif create mode 100644 theme/images/Poll_ro.gif create mode 100755 theme/images/Projects.gif create mode 100755 theme/images/Projects_ro.gif create mode 100644 theme/images/Quotes.gif create mode 100644 theme/images/Quotes_ro.gif create mode 100755 theme/images/Random.gif create mode 100755 theme/images/Random_ro.gif create mode 100644 theme/images/Wiki.gif create mode 100644 theme/images/Wiki_ro.gif create mode 100755 theme/images/authors/Hatkirby.ico create mode 100755 theme/images/authors/Starla.ico create mode 100755 theme/images/backgrounds/4ofjuly.PNG create mode 100755 theme/images/backgrounds/ashWeds.PNG create mode 100755 theme/images/backgrounds/christmas.PNG create mode 100755 theme/images/backgrounds/christmasEve.PNG create mode 100755 theme/images/backgrounds/columbus.PNG create mode 100755 theme/images/backgrounds/easter.PNG create mode 100755 theme/images/backgrounds/fathers.PNG create mode 100755 theme/images/backgrounds/flagDay.PNG create mode 100755 theme/images/backgrounds/goodFriday.PNG create mode 100755 theme/images/backgrounds/groundhog.PNG create mode 100755 theme/images/backgrounds/halloween.PNG create mode 100755 theme/images/backgrounds/hatkirbybday.PNG create mode 100755 theme/images/backgrounds/island.PNG create mode 100755 theme/images/backgrounds/island2.PNG create mode 100755 theme/images/backgrounds/island3.PNG create mode 100755 theme/images/backgrounds/island4.PNG create mode 100755 theme/images/backgrounds/island5.PNG create mode 100755 theme/images/backgrounds/island6.PNG create mode 100755 theme/images/backgrounds/island6night.PNG create mode 100755 theme/images/backgrounds/islandYearly.PNG create mode 100755 theme/images/backgrounds/kirbyweek.PNG create mode 100755 theme/images/backgrounds/mardiGras.PNG create mode 100755 theme/images/backgrounds/martinLuther.PNG create mode 100755 theme/images/backgrounds/memorial.PNG create mode 100755 theme/images/backgrounds/mothers.PNG create mode 100755 theme/images/backgrounds/newYear.PNG create mode 100755 theme/images/backgrounds/newYearsEve.PNG create mode 100755 theme/images/backgrounds/valentines.PNG create mode 100755 theme/images/backgrounds/veterans.PNG create mode 100755 theme/images/bg_body.gif create mode 100644 theme/images/bg_body_short.gif create mode 100755 theme/images/bg_footer.gif create mode 100755 theme/images/bg_header.gif create mode 100755 theme/images/bg_navbar.gif create mode 100644 theme/images/bg_search.gif create mode 100755 theme/images/blue.PNG create mode 100755 theme/images/corners_bottom.gif create mode 100755 theme/images/corners_left.png create mode 100755 theme/images/corners_right.png create mode 100755 theme/images/date-bg-1.gif create mode 100755 theme/images/date-bg-2.gif create mode 100755 theme/images/date-bg-3.gif create mode 100755 theme/images/date-bg-4.gif create mode 100644 theme/images/headers/ctnh.png create mode 100644 theme/images/headers/fourm.png create mode 100644 theme/images/headers/hatkirbybday.png create mode 100644 theme/images/headers/islandYearly.png create mode 100644 theme/images/headers/kfm.png create mode 100644 theme/images/headers/links.png create mode 100755 theme/images/headers/main.png create mode 100755 theme/images/headers/main.xcf create mode 100644 theme/images/headers/memorial.png create mode 100644 theme/images/headers/mothers.png create mode 100644 theme/images/headers/potw.png create mode 100644 theme/images/headers/projects.png create mode 100644 theme/images/headers/projects.xcf create mode 100644 theme/images/headers/quotes.png create mode 100644 theme/images/headers/random.png create mode 100644 theme/images/headers/short.png create mode 100755 theme/images/home.png create mode 100644 theme/images/icons/16-clock.png create mode 100644 theme/images/icons/16-em-pencil.png create mode 100644 theme/images/icons/16-file-archive.png create mode 100644 theme/images/icons/16-file-page.png create mode 100644 theme/images/icons/16-message-warn.png create mode 100644 theme/images/icons/16-star-hot.png create mode 100755 theme/images/icons/book_open.png create mode 100755 theme/images/icons/bricks.png create mode 100755 theme/images/icons/comment.png create mode 100755 theme/images/icons/comment_add.png create mode 100755 theme/images/icons/comments.png create mode 100755 theme/images/icons/computer.png create mode 100755 theme/images/icons/controller.png create mode 100755 theme/images/icons/css_valid.png create mode 100755 theme/images/icons/door_in.png create mode 100755 theme/images/icons/door_out.png create mode 100755 theme/images/icons/feed.png create mode 100755 theme/images/icons/fourm.png create mode 100755 theme/images/icons/house.png create mode 100755 theme/images/icons/html_valid.png create mode 100755 theme/images/icons/link_delete.png create mode 100755 theme/images/icons/link_edit.png create mode 100755 theme/images/icons/medal_gold_1.png create mode 100755 theme/images/icons/new.png create mode 100755 theme/images/icons/newspaper.png create mode 100755 theme/images/icons/note.png create mode 100755 theme/images/icons/note_delete.png create mode 100755 theme/images/icons/note_edit.png create mode 100755 theme/images/icons/note_go.png create mode 100755 theme/images/icons/overlays.png create mode 100755 theme/images/icons/page_attach.png create mode 100755 theme/images/icons/page_delete.png create mode 100755 theme/images/icons/page_edit.png create mode 100755 theme/images/icons/page_go.png create mode 100755 theme/images/icons/rainbow.png create mode 100755 theme/images/icons/report.png create mode 100755 theme/images/icons/script.png create mode 100755 theme/images/icons/tag.png create mode 100755 theme/images/icons/tag_blue.png create mode 100755 theme/images/icons/tag_blue_add.png create mode 100755 theme/images/icons/tag_blue_delete.png create mode 100755 theme/images/icons/tag_blue_edit.png create mode 100755 theme/images/icons/tag_green.png create mode 100755 theme/images/icons/tag_orange.png create mode 100755 theme/images/icons/tag_pink.png create mode 100755 theme/images/icons/tag_purple.png create mode 100755 theme/images/icons/tag_red.png create mode 100755 theme/images/icons/tag_yellow.png create mode 100644 theme/images/icons/thumb_down.png create mode 100644 theme/images/icons/thumb_up.png create mode 100755 theme/images/icons/tux.png create mode 100755 theme/images/icons/user_edit.png create mode 100755 theme/images/icons/vcard.png create mode 100755 theme/images/loadingAnimation.gif create mode 100755 theme/images/misc.png create mode 100644 theme/images/no-ie6.png create mode 100755 theme/images/projects.png create mode 100755 theme/images/sides_top.gif create mode 100755 theme/images/tabBG.png create mode 100755 theme/images/tabBG2.png create mode 100644 theme/images/tabSe.png create mode 100644 theme/images/tabUn.png create mode 100644 theme/images/tip-pimped.gif create mode 100644 theme/images/tip-rounded.gif create mode 100644 theme/images/tip.gif create mode 100755 theme/images/webs.png create mode 100644 theme/images/youdropifollow.jpg create mode 100644 theme/js/jquery-1.2.6.min.js create mode 100644 theme/js/jquery.ie6blocker.js create mode 100644 theme/js/message.js create mode 100644 theme/js/round_bubbles.js create mode 100644 theme/js/rounded_corners.inc.js create mode 100755 theme/js/thickbox.js create mode 100644 theme/login.tpl create mode 100644 theme/msg.tpl create mode 100644 theme/msg2.tpl create mode 100644 theme/poll.tpl create mode 100644 theme/pollIndex.tpl create mode 100644 theme/polloftheweek.tpl create mode 100644 theme/post.tpl create mode 100644 theme/postLogin.tpl create mode 100644 theme/quotes/add.tpl create mode 100644 theme/quotes/add_news.tpl create mode 100644 theme/quotes/browse.tpl create mode 100644 theme/quotes/home.tpl create mode 100644 theme/quotes/pagenumbers.tpl create mode 100644 theme/quotes/search.tpl create mode 100644 theme/related.tpl create mode 100644 theme/welcome.tpl create mode 100644 theme/wiki/create.tpl create mode 100644 theme/wiki/edit.tpl create mode 100644 theme/wiki/index.tpl create mode 100644 theme/wiki/page.tpl create mode 100644 thumb.php create mode 100644 xmlrpc.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..8738a13 --- /dev/null +++ b/.htaccess @@ -0,0 +1,37 @@ +RewriteEngine On + +RewriteRule ^blog/$ /index.php?area=blog [QSA,L] +RewriteRule ^blog/author/(.+).php /index.php?area=blog&author=$1 [QSA,L] +RewriteRule ^blog/tag/(.+).php /index.php?area=blog&tag=$1 [QSA,L] +RewriteRule ^blog/(.+)/ /index.php?area=blog&post=$1 [QSA,L] + +RewriteRule ^comments/(.+)/ /index.php?area=comment&id=$1 [QSA,L] + +RewriteRule ^wiki/$ /wiki/Main_Page [QSA] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^wiki/(.+) /w/index.php?title=$1 [QSA,L] + +RewriteRule ^poll/$ /index.php?area=poll [QSA,L] +RewriteRule ^poll/(.+).php /index.php?area=poll&id=$1 [QSA,L] + +RewriteRule ^quotes/$ /index.php?area=quotes [QSA,L] +RewriteRule ^quotes/(.+).php /index.php?area=quotes&act=$1 [QSA,L] + +RewriteRule ^admin/$ /index.php?area=admin [QSA,L] +RewriteRule ^admin/(.+).php /index.php?area=admin&page=$1 [QSA,L] + +RewriteRule ^error/$ /index.php?area=error [QSA,L] +RewriteRule ^error/(.+).php /index.php?area=error&id=$1 [QSA,L] + +RewriteRule ^projects/ - [L] + +RewriteRule ^comic/$ /index.php?area=comic [QSA,L] +RewriteRule ^comic/(.+)/ /index.php?area=comic&comic=$1 [QSA,L] + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.+).php /index.php?area=$1 [QSA,L] + +RewriteCond %{HTTP_HOST} ^www.fourisland.com [NC] +RewriteRule ^(.*)$ http://fourisland.com/$1 [R=301,NC] diff --git a/favicon.ico b/favicon.ico new file mode 100755 index 0000000..2f6633c Binary files /dev/null and b/favicon.ico differ diff --git a/header.inc b/header.inc new file mode 100644 index 0000000..2d677f2 --- /dev/null +++ b/header.inc @@ -0,0 +1,25 @@ + diff --git a/headerproc.php b/headerproc.php new file mode 100644 index 0000000..80310ac --- /dev/null +++ b/headerproc.php @@ -0,0 +1,31 @@ + diff --git a/includes/bbcode.php b/includes/bbcode.php new file mode 100644 index 0000000..4a1870a --- /dev/null +++ b/includes/bbcode.php @@ -0,0 +1,151 @@ + array('type' => BBCODE_TYPE_ROOT))); + +// [b][/b] - Bold +bbcode_add_element($bbcode,'b',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [i][/i] - Italic +bbcode_add_element($bbcode,'i',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [url][/url] - [url=][/url] - Link +bbcode_add_element($bbcode,'url',array( 'type' => BBCODE_TYPE_OPTARG, + 'open_tag' => '', + 'close_tag' => '', + 'default_arg' => '{CONTENT}')); + +// [img][/img] - [img=][/img] - Image +bbcode_add_element($bbcode,'img',array( 'type' => BBCODE_TYPE_OPTARG, + 'open_tag' => '{PARAM}', + 'default_tag' => '{CONTENT}')); + +// [big][/big] - Big +bbcode_add_element($bbcode,'big',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [small][/small] - Small +bbcode_add_element($bbcode,'small',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [ul][/ul] - Unordered List +bbcode_add_element($bbcode,'ul',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'childs' => 'li')); + +// [ol][/ol] - Ordered List +bbcode_add_element($bbcode,'ol',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '
    ', + 'close_tag' => '
', + 'childs' => 'li')); + +// [li][/li] - List Item +bbcode_add_element($bbcode,'li',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '
  • ', + 'close_tag' => '
  • ')); + +// [code][/code] - Code +bbcode_add_element($bbcode,'code',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [pre][/pre] - Preformatted Code +bbcode_add_element($bbcode,'pre',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '

    ',
    +					'close_tag' => '
    ')); + +function bb_fixCode($string) +{ + $he = htmlentities($string); + $br = nl2br($he); + $sp = str_replace(' ',' $nbsp;',$br); + $ta = str_replace(' ','      ',$sp); + return($ta); +} + +// [blog][/blog] - Blog Link +bbcode_add_element($bbcode,'blog',array( 'type' => BBCODE_TYPE_OPTARG, + 'open_tag' => (isset($oldBlog) ? '' : ''), + 'close_tag' => '', + 'default_arg' => '{CONTENT}')); + +// [quote][/quote] - Quotes DB Link +bbcode_add_element($bbcode,'quote',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => (isset($oldBlog) ? '#' : '#'), + 'close_tag' => '')); + +// [ins][/ins] - Insert +bbcode_add_element($bbcode,'ins',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [del][/del] - Delete +bbcode_add_element($bbcode,'del',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => '', + 'close_tag' => '')); + +// [bquote][/bquote] - Blockquote +bbcode_add_element($bbcode,'bquote',array( 'type' => BBCODE_TYPE_OPTARG, + 'open_tag' => '

    ', + 'close_tag' => '
    {PARAM}
    ', + 'default_arg' => 'Anonymous')); + +// [project][/project] - Project Link +bbcode_add_element($bbcode,'project',array( 'type' => BBCODE_TYPE_NOARG, + 'open_tag' => (isset($oldBlog) ? '' : ''), + 'close_tag' => '')); + +// [abbr][/abbr] - Abbreviation +bbcode_add_element($bbcode,'abbr',array( 'type' => BBCODE_TYPE_OPTARG, + 'open_tag' => '', + 'close_tag' => '', + 'default_arg' => '')); + +// [br] - Line Break +bbcode_add_element($bbcode,'br',array( 'type' => BBCODE_TYPE_SINGLE, + 'open_tag' => '
    ')); + +// [hidden][/hidden] - Hidden Text +bbcode_add_element($bbcode,'hidden',array( 'type' => BBCODE_TYPE_OPTARG, + 'open_tag' => '
    ', + 'close_tag' => '
    ', + 'default_arg' => '')); + +function parseBBCode($text) +{ + global $bbcode; + $to_parse = str_replace("\n",'[br]',htmlentities($text)); + $to_parse = bbcode_parse($bbcode,$to_parse); + return str_replace('[br]','',$to_parse); +} + +?> diff --git a/includes/comments.php b/includes/comments.php new file mode 100644 index 0000000..9cb8b18 --- /dev/null +++ b/includes/comments.php @@ -0,0 +1,97 @@ +add('PAGEID',$page_id); +$template->add('CODEDDEF',urlencode('http://www.fourisland.com/images/error404.png')); +$template->add('USERNAME',(isLoggedIn() ? sess_get('uname') : 'Anonymous')); + +if (!isLoggedIn()) +{ + $template->add('RECAPTCHA',recaptcha_get_html($publickey)); + $template->adds_block('NOLOG',array('exi'=>1)); +} + +$getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; +$getcomments2 = mysql_query($getcomments) or die($getcomments); +$i=0; +while ($getcomments3[$i] = mysql_fetch_array($getcomments2)) +{ + $getuser = "SELECT * FROM users WHERE username = \"" . $getcomments3[$i]['username'] . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + if ($getuser3['username'] == $getcomments3[$i]['username']) + { + $username = $getuser3['username']; + $email = $getuser3['user_email']; + $website = $getuser3['website']; + } else { + $getanon = "SELECT * FROM anon_commenters WHERE username = \"" . $getcomments3[$i]['username'] . "\""; + $getanon2 = mysql_query($getanon); + $getanon3 = mysql_fetch_array($getanon2); + + if ($getanon3['username'] == $getcomments3[$i]['username']) + { + $username = $getanon3['username'] . ' (Guest)'; + $email = $getanon3['email']; + $website = $getanon3['website']; + } + } + + if (isset($username)) + { + if ($getcomments3[$i]['rating'] > -2) + { + $text = parseBBCode($getcomments3[$i]['comment']); + } else { + $text = 'This comment has been rated down below the threshold for public viewing (-1), suggesting that it may contain inappropriate or off topic content. (Or it may have been flame bait, or simply bad!)'; + } + + if ($getcomments3[$i]['title'] != '') + { + $title2 = $getcomments3[$i]['title']; + } else { + $title2 = 'Untitled'; + } + + $template->add_ref($curID, 'COMMENTS', array( 'CODEDEMAIL' => md5(strtolower($email)), + 'USERNAME' => (($website != '') ? '' . $username . '' : $username), + 'DATE' => date("F dS Y \a\\t g:i:s a",strtotime($getcomments3[$i]['posttime'])), + 'RATING' => $getcomments3[$i]['rating'], + 'ID' => $getcomments3[$i]['id'], + 'TEXT' => $text, + 'TITLE' => $title2)); + } + $i++; +} +$template->display(); + +?> diff --git a/includes/db.php b/includes/db.php new file mode 100755 index 0000000..8cc5449 --- /dev/null +++ b/includes/db.php @@ -0,0 +1,49 @@ + diff --git a/includes/definitions.php b/includes/definitions.php new file mode 100644 index 0000000..581eb85 --- /dev/null +++ b/includes/definitions.php @@ -0,0 +1,52 @@ + +'); +define("PHPSVN_VERSION_REQUEST",''); +define("PHPSVN_LOGS_REQUEST",' %d%d'); + +define("SVN_LAST_MODIFIED","lp1:getlastmodified"); +define("SVN_URL","D:href"); +define("SVN_RELATIVE_URL","lp3:baseline-relative-path"); +define("SVN_FILE_ID","lp3:repository-uuid"); +define("SVN_STATUS","D:status"); +define("SVN_IN_FILE","D:propstat"); +define("SVN_FILE","D:response"); + +define("SVN_LOGS_BEGINGS","S:log-item"); +define("SVN_LOGS_VERSION","D:version-name"); +define("SVN_LOGS_AUTHOR","D:creator-displayname"); +define("SVN_LOGS_DATE","S:date"); +define("SVN_LOGS_COMMENT","D:comment"); + +define("NOT_FOUND", 2); +define("AUTH_REQUIRED", 3); +define("UNKNOWN_ERROR",4); +define("NO_ERROR",1) +?> diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..e4c88c8 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,198 @@ +add('EXTRASIDEBARS',(isset($extraSidebars) ? $extraSidebars : '')); + +if (isset($onFourm)) +{ + $template->adds_block('ONFOURM',array('exi'=>1)); +} + +if (!isset($noRightbar)) +{ + $template->adds_block('RIGHTBAR',array('exi'=>1)); + + if (!isset($noHatNav)) + { + $template->adds_block('USEHATNAV', array('exi'=>1)); + if (!isset($genHatNav)) + { + $gethnis = 'SELECT * FROM hatnav WHERE category = "' . + $pageCategory . '"'; + $gethnis2 = mysql_query($gethnis); + $i=0; + while ($gethnis3[$i] = mysql_fetch_array($gethnis2)) + { + $template->adds_block('HATNAV', array( 'AID' => $gethnis3[$i]['AID'], + 'HREF' => $gethnis3[$i]['href'], + 'IMAGE' => '/theme/images/icons/' . $gethnis3[$i]['image'] . '.png', + 'TEXT' => $gethnis3[$i]['text'], + 'NEW' => dispIfNotOld($gethnis3[$i]['lastEdit']))); + $i++; + } + } else { + $i=0; + while ($i < $genHatNavNum) + { + $template->adds_block('HATNAV', array( 'AID' => 'post', + 'HREF' => $genHatNav[$i]['href'], + 'IMAGE' => '/theme/images/blue.PNG', + 'TEXT' => $genHatNav[$i]['text'], + 'NEW' => '')); + $i++; + } + } + } + + include('pages/polloftheweek.php'); + + $getpopular = "SELECT * FROM updates ORDER BY popularity DESC LIMIT 0,5"; + $getpopular2 = mysql_query($getpopular); + $i=0; + while ($getpopular3[$i] = mysql_fetch_array($getpopular2)) + { + $template->adds_block('POPULAR', array( 'CODED' => $getpopular3[$i]['slug'], + 'TITLE' => stripslashes($getpopular3[$i]['title']))); + $i++; + } + + $getcomments = "SELECT * FROM comments WHERE page_id LIKE \"updates-%\" ORDER BY id DESC LIMIT 0,5"; + $getcomments2 = mysql_query($getcomments); + $i=0; + while ($getcomments3[$i] = mysql_fetch_array($getcomments2)) + { + $getpost = "SELECT * FROM updates WHERE id = " . substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $getuser = "SELECT * FROM users WHERE username = \"" . $getcomments3[$i]['username'] . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + if ($getuser3['username'] == $getcomments3[$i]['username']) + { + $username = $getuser3['username']; + $website = $getuser3['website']; + } else { + $getanon = "SELECT * FROM anon_commenters WHERE username = \"" . $getcomments3[$i]['username'] . "\""; + $getanon2 = mysql_query($getanon); + $getanon3 = mysql_fetch_array($getanon2); + + if ($getanon3['username'] == $getcomments3[$i]['username']) + { + $username = $getanon3['username'] . ' (Guest)'; + $website = $getanon3['website']; + } + } + + + $template->adds_block('COMMENTS', array( 'CODED' => $getpost3['slug'], + 'TITLE' => stripslashes($getpost3['title']), + 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); + $i++; + } + + $getusers = "SELECT DISTINCT username FROM comments"; + $getusers2 = mysql_query($getusers); + $i=0; + while ($getusers3[$i] = mysql_fetch_array($getusers2)) + { + $getcount = "SELECT COUNT(*) FROM comments WHERE username = \"" . $getusers3[$i]['username'] . "\""; + $getcount2 = mysql_query($getcount); + $getcount3 = mysql_fetch_array($getcount2); + + $getuser = "SELECT * FROM users WHERE username = \"" . $getusers3[$i]['username'] . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + if ($getuser3['username'] == $getusers3[$i]['username']) + { + $username = $getuser3['username']; + $website = $getuser3['website']; + } else { + $getanon = "SELECT * FROM anon_commenters WHERE username = \"" . $getusers3[$i]['username'] . "\""; + $getanon2 = mysql_query($getanon); + $getanon3 = mysql_fetch_array($getanon2); + + if ($getanon3['username'] == $getusers3[$i]['username']) + { + $username = $getanon3['username'] . ' (Guest)'; + $website = $getanon3['website']; + } + } + + $name = (($website != '') ? '' . $username . '' : $username); + $users[$name] = $getcount3[0]; + + $i++; + } + + arsort($users); + $i=0; + foreach ($users as $name => $count) + { + if ($i == 5) + { + break; + } + + if ($name != 'Pingback') + { + $template->adds_block('TOP', array( 'USERNAME' => $name, + 'COUNT' => $count)); + $i++; + } + } + + $gethits = "SELECT * FROM config WHERE name = \"hits\""; + $gethits2 = mysql_query($gethits); + $gethits3 = mysql_fetch_array($gethits2); + $template->add('HITS', $gethits3['value']); + + $gethits = "SELECT * FROM config WHERE name = \"todayHits\""; + $gethits2 = mysql_query($gethits); + $gethits3 = mysql_fetch_array($gethits2); + $template->add('TODAY', $gethits3['value']); + + $getpost = "SELECT * FROM phpbb_posts ORDER BY post_id DESC LIMIT 0,5"; + $getpost2 = mysql_query($getpost) or die($getpost); + $i=0; + while ($getpost3[$i] = mysql_fetch_array($getpost2)) + { + $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getpost3[$i]['poster_id']; + $getuser2 = mysql_query($getuser) or die($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + $template->adds_block('FOURM', array( 'SUBJECT' => $getpost3[$i]['post_subject'], + 'TOPIC' => $getpost3[$i]['topic_id'], + 'POST' => $getpost3[$i]['post_id'], + 'USERNAME' => $getuser3['username'])); + } +} + +$template->display(); + +?> diff --git a/includes/functions.php b/includes/functions.php new file mode 100644 index 0000000..c377c29 --- /dev/null +++ b/includes/functions.php @@ -0,0 +1,244 @@ += time()) + { + return('New!'); + } else { + return; + } +} + +function getpercent($getpoll3,$num) +{ + $maxper = ($getpoll3['clicks1'] + $getpoll3['clicks2'] + $getpoll3['clicks3'] + $getpoll3['clicks4']); + $percent = round(($getpoll3['clicks' . $num] / $maxper) * 100); + return($percent); +} + +function generateSlug($title,$table) +{ + $title = preg_replace('/[^A-Za-z0-9]/','-',$title); + $title = preg_replace('/-{2,}/','-',$title); + if (substr($title,0,1) == '-') + { + $title = substr($title,1); + } + if (substr($title,strlen($title)-1,1) == '-') + { + $title = substr($title,0,strlen($title)-1); + } + $title = strtolower($title); + + $getprevs = "SELECT COUNT(*) FROM " . $table . " WHERE slug = \"" . $title . "\" OR slug LIKE \"" . $title . "-%\""; + $getprevs2 = mysql_query($getprevs); + @$getprevs3 = mysql_fetch_array($getprevs2); + if ($getprevs3[0] > 0) + { + $title .= '-' . ($getprevs3[0]+1); + } + + return($title); +} + +function postBlogPost($title,$author,$tag1,$tag2,$tag3,$content) +{ + $slug = generateSlug($title,'updates'); + + $inspost = "INSERT INTO updates (title,slug,author,tag1,tag2,tag3,text) VALUES (\"" . $title . "\",\"" . $slug . "\",\"" . $author . "\",\"" . $tag1 . "\",\"" . $tag2 . "\",\"" . $tag3 . "\",\"" . addslashes($content) . "\")"; + $inspost2 = mysql_query($inspost); + + $upconf = "UPDATE config SET value = \"" . date('md') . "\" WHERE name = \"lastUpdate\""; + $upconf2 = mysql_query($upconf); + + preg_match_all('|]*href="([^"]+)"|i', parseBBCode($content), $matches); + + foreach ($matches[1] as $link) + { + if ($all_links[$link]) + { + continue; + } + + $all_links[$link] = true; + + if (preg_match('/^https{0,1}:/i', $link)) + { + $c = curl_init(); + curl_setopt($c, CURLOPT_URL, $link); + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); + curl_setopt($c, CURLOPT_HEADER, false); + $page_data = curl_exec($c); + curl_close($c); + + if (preg_match('/send($msg); + } + } + } + + $client = new xmlrpc_client('http://rpc.pingomatic.com'); + $msg = new xmlrpcmsg("weblogUpdates.ping", array( new xmlrpcval('Four Island', 'string'), + new xmlrpcval('http://www.fourisland.com/', 'string'))); + $client->send($msg); +} + +function recalcPop($id) +{ + $getpost = "SELECT * FROM updates WHERE id = " . $id; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + $popularity = $getpost3['home_views']; + $popularity += ($getpost3['views']*2); + $popularity += ($getpost3['rating']*5); + + $getcomments = "SELECT COUNT(*) FROM comments WHERE page_id = \"updates-" . $id . "\" AND username <> \"Pingback\""; + $getcomments2 = mysql_query($getcomments); + $getcomments3 = mysql_fetch_array($getcomments2); + $popularity += ($getcomments3[0] * 10); + + $getpings = "SELECT COUNT(*) FROM comments WHERE page_id = \"updates-" . $id . "\" AND username = \"Pingback\""; + $getpings2 = mysql_query($getpings); + $getpings3 = mysql_fetch_array($getpings2); + $popularity += ($getpings3[0] * 25); + + $setpost = "UPDATE updates SET popularity = " . $popularity . " WHERE id = " . $id; + $setpost2 = mysql_query($setpost); +} + +function updatePop($id, $area, $plus=1) +{ + $gettrack = "SELECT * FROM tracking WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $gettrack2 = mysql_query($gettrack); + $gettrack3 = mysql_fetch_array($gettrack2); + + $trackArr = explode(',',$gettrack3[$area]); + + if (($gettrack3['ip'] != $_SERVER['REMOTE_ADDR']) || (array_search($id,$trackArr) === FALSE)) + { + $setpost = "UPDATE updates SET " . $area . " = " . $area . "+" . $plus . " WHERE id = " . $id; + $setpost2 = mysql_query($setpost); + recalcPop($id); + + if ($gettrack3['ip'] == $_SERVER['REMOTE_ADDR']) + { + $settrack = "UPDATE tracking SET " . $area . " = \"" . $gettrack3[$area] . "," . $id . "\" WHERE id = " . $gettrack3['id']; + } else { + $settrack = "INSERT INTO tracking (ip," . $area . ") VALUES (\"" . $_SERVER['REMOTE_ADDR'] . "\",\"" . $id . "\")"; + } + $settrack2 = mysql_query($settrack) or die($settrack); + return 1; + } else { + return 0; + } +} + +function verifyUser($username, $password) +{ + $getuser = 'SELECT * FROM users WHERE username = "' . $username . '" AND user_password = "' . md5($password) . '"'; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + return (($_POST['username'] != '') && ($getuser3['username'] == $_POST['username'])); +} + +function updateCommentPop($id, $plus=1) +{ + $gettrack = "SELECT * FROM tracking_comments WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $gettrack2 = mysql_query($gettrack); + $gettrack3 = mysql_fetch_array($gettrack2); + + $trackArr = explode(',',$gettrack3['comment_id']); + + if (($gettrack3['ip'] != $_SERVER['REMOTE_ADDR']) || (array_search($id,$trackArr) === FALSE)) + { + $setcomment = "UPDATE comments SET rating = rating+" . $plus . " WHERE id = " . $id; + $setcomment2 = mysql_query($setcomment); + + if ($gettrack3['ip'] == $_SERVER['REMOTE_ADDR']) + { + $settrack = "UPDATE tracking SET rating = \"" . $gettrack3['comment_id'] . "," . $id . "\" WHERE id = " . $gettrack3['id']; + } else { + $settrack = "INSERT INTO tracking (ip,rating) VALUES (\"" . $_SERVER['REMOTE_ADDR'] . "\",\"" . $id . "\")"; + } + $settrack2 = mysql_query($settrack) or die($settrack); + return 1; + } else { + return 0; + } +} + +?> diff --git a/includes/functions_quotes.php b/includes/functions_quotes.php new file mode 100644 index 0000000..e3ca2c0 --- /dev/null +++ b/includes/functions_quotes.php @@ -0,0 +1,195 @@ +adds_block('PAGENUMBERS',array('exi'=>1)); + page_numbers($template, $origin, $quote_limit, $page, $page_limit); + $up_lim = ($quote_limit * $page); + $low_lim = $up_lim - $quote_limit; + $query .= "LIMIT $low_lim,$quote_limit"; + } + $template->add('ORIGIN',$origin); + + $getquotes2 = mysql_query($query); + $i=0; + while ($getquotes3[$i] = mysql_fetch_array($getquotes2)) + { + $template->adds_block('QUOTES',array( 'NUMBER' => $getquotes3[$i]['id'], + 'RATING' => $getquotes3[$i]['rating'], + 'QUOTE' => nl2br(stripslashes($getquotes3[$i]['quote'])))); + + $i++; + } + + $template->display(); +} + +function page_numbers($template, $origin, $quote_limit, $page_default, $page_limit) +{ + $numrows = countRows('rash_quotes'); + $testrows = $numrows; + $pagenum = (($testrows + 1) / ($quote_limit > 0 ? $quote_limit : 1)); + + if (($page_limit % 2)) + { + $page_limit++; + } + if (($page_limit < 2) || (!$page_limit)) + { + $page_limit = 5; + } + + $pagebase = 0; + do + { + $pagebase++; + $page_limit -= 2; + } while ($page_limit > 1); + + $template->add('LORIGIN',strtolower($origin)); + $template->add('MINUSTEN',(($page_default - 10) > 1) ? ($page_default - 10) : 1); + + if ($page_default - $pagebase > 1) + { + $template->add('BDDD','...'); + } + + $i = $page_default - $pagebase; + do + { + if ($i > 0) + { + $template->adds_block('BPAGES',array('PAGENUM' => $i)); + } + $i++; + } while ($i < $page_default); + + $template->add('CURPAGE',$page_default); + + $i = $page_default + 1; + do + { + if ($i <= $pagenum) + { + $template->adds_block('APAGES',array('PAGENUM' => $i)); + } + $i++; + } while ($i < ($page_default + $pagebase + 1)); + + if (($page_default + $pagebase) < $pagenum) + { + $template->add('ADDD','...'); + } + + $template->add('PLUSTEN',(($page_default + 10) < $pagenum) ? ($page_default + 10) : $pagenum); + $template->add('LASTPAGE',$pagenum); +} + +function user_quote_status($where, $quote_num, $template) +{ + $tracking_verdict = ip_track($where, $quote_num); + if ($where != 'flag') + { + switch ($tracking_verdict) + { + case 1: + $template->add('TRACKING',"Quote has been modified, and data of your action has been recorded in the database."); + break; + case 2: + $template->add('TRACKING',"Quote has been modified, your IP has been logged, and data of your action has been recorded in the database."); + break; + case 3: + $template->add('TRACKING',"You have already voted on this quote, please try again later."); + break; + } + } + return $tracking_verdict; +} + +function ip_track($where, $quote_num) +{ + switch ($where) + { + case 'flag': + $where2 = 'vote'; + break; + case 'vote': + $where2 = 'flag'; + break; + } + + $getip = "SELECT * FROM rash_tracking WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $getip2 = mysql_query($getip); + $getip3 = mysql_fetch_array($getip2); + + if ($getip3['ip'] == $_SERVER['REMOTE_ADDR']) + { + $quote_array = explode(",", $getip3['quote_id']); + $quote_place = array_search($quote_num, $quote_array); + if (in_array($quote_num, $quote_array)) + { + $where_result = explode(",", $getip3[$where]); + if (!isset($where_result[$quote_place])) + { + $where_result[$quote_place] = 1; + $where_result = implode(",", $where_result); + $setip = "UPDATE rash_tracking SET " . $where . " = \"" . $where_result . "\" WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $setip2 = mysql_query($getip); + return 1; + } else { + return 3; + } + } else { + $setip = "UPDATE rash_tracking SET " . $where . " = CONCAT(" . $where . ",\",1\"), " . $where2 . " = CONCAT(" . $where2 . ",\",0\"), quote_id = CONCAT(quote_id,\"," . $quote_num . "\") WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $setip2 = mysql_query($setip); + return 1; + } + } else { + $insip = "INSERT INTO rash_tracking (ip, quote_id, " . $where . ", " . $where2 . ") VALUES (\"" . $_SERVER['REMOTE_ADDR'] . "\", \"" . $quote_num . "\", 1, 0)"; + $insip2 = mysql_query($insip); + return 2; + } +} + +function verify_int($subject) +{ + $ymax = strlen($subject); + $y = 0; + while($y < $ymax) + { + if ((is_int((int)($subject{$y})) && (int)($subject{$y})) || (int)($subject{$y}) === 0 ) + { + $y++; + } else { + return false; + } + } + return true; +} + +?> diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..3bedbd7 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,66 @@ +adds_block('SPLASH', array('exi'=>1)); +} + +if ((date('G') >= 20) || (date('G') <= 6)) +{ + $bodyID = 'night'; +} else { + $bodyID = 'day'; +} +$headerTemp->add('BODYID',$bodyID); +$headerTemp->add('CATEGORY',(isset($pageCategory)) ? $pageCategory : 'none'); +$headerTemp->add('AID',(isset($pageAID)) ? $pageAID : 'none'); +$headerTemp->add('BODYTAGS',(isset($bodyTags)) ? $bodyTags : ''); +$headerTemp->add('HEADTAGS',isset($headtags) ? $headtags : ''); +$headerTemp->add('EXTRATITLE',isset($title) ? ($title . ' - ') : ''); +$headerTemp->add('PAGEID',(isset($pageID)) ? $pageID : 'none'); + +if (!isset($noMembers)) +{ + $headerTemp->add('LOWERLOGDATA',strtolower(echoLogData())); + $headerTemp->add('REDIRPAGE',rawurlencode($_SERVER['REQUEST_URI'])); + $headerTemp->add('LOGDATA',echoLogData()); + if (getUserlevel() < 3) + { + $headerTemp->adds_block('PANEL',array('exi'=>1)); + } +} + +if (isset($_POST['message'])) +{ + $headerTemp->adds_block('MESSAGE',array('MSG' => $_POST['message'])); +} + +$headerTemp->display(); + +?> diff --git a/includes/hits.php b/includes/hits.php new file mode 100644 index 0000000..053c6b4 --- /dev/null +++ b/includes/hits.php @@ -0,0 +1,102 @@ +($getlreset3['value'])) +{ + $sethits = "UPDATE config SET value = " . (floor(time()/86400)) . " WHERE name = 'lastReset'"; + $sethits2 = mysql_query($sethits); + $getips = "SELECT * FROM hits"; + $getips2 = mysql_query($getips); + $i=0; + while ($getips3[$i] = mysql_fetch_array($getips2)) + { + $ttime = strtotime($getips3[$i]['lasttime']); + $delip = "DELETE FROM hits WHERE id = " . $getips3[$i]['id']; + $delip2 = mysql_query($delip); + $i++; + } + $sethits6 = "UPDATE config SET value = 0 WHERE name = 'todayHits'"; + $sethits7 = mysql_query($sethits6); +} +$client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv('REMOTE_ADDR') ); +$user_ip = $client_ip; +$getip = "SELECT * FROM hits WHERE ip = '" . $user_ip . "'"; +$getip2 = mysql_query($getip); +$getip3 = mysql_fetch_array($getip2); +if ($getip3['ip'] != $user_ip) +{ + $gethits = "SELECT * FROM config WHERE name = 'hits'"; + $gethits2 = mysql_query($gethits); + $gethits3 = mysql_fetch_array($gethits2); + $sethits = "UPDATE config SET value = " . ($gethits3['value']+1) . " WHERE name = 'hits'"; + $sethits2 = mysql_query($sethits); + $gethits4 = "SELECT * FROM config WHERE name = 'todayHits'"; + $gethits5 = mysql_query($gethits4); + $gethits6 = mysql_fetch_array($gethits5); + $sethits4 = "UPDATE config SET value = " . ($gethits6['value']+1) . " WHERE name = 'todayHits'"; + $sethits5 = mysql_query($sethits4); + $gethits7 = "SELECT * FROM config WHERE name = 'imHits'"; + $gethits8 = mysql_query($gethits7); + $gethits9 = mysql_fetch_array($gethits8); + $setip = "INSERT INTO hits SET ip = '" . $user_ip . "'"; + $setip2 = mysql_query($setip); + if (isset($_SERVER['HTTP_REFERER'])) + { + $page = $_SERVER['HTTP_REFERER']; + } else { + $page = ''; + } + $ipdetails = str_pad($client_ip,15,' ') . ' - ' . str_pad($page,61,' ') . ' - ' . str_pad($_SERVER['REQUEST_URI'],27,' ') . ' - ' . time() . chr(13) . chr(10); +// file_put_contents('/var/www/fourisland/ipdetails.txt',$ipdetails,FILE_APPEND); + $milestones = array(100,500,1000,1337,4444,5000,10000,15000,50000,75000,100000,150000,250000,500000,750000,1000000); + $i=0; + for ($i=0; $i<15; $i++) { + if (($gethits3['value']+1)==$milestones[$i]) { + file_put_contents('/var/www/fourisland/tophits.txt',$ipdetails,FILE_APPEND); + $setmst = 'UPDATE config SET value = "' . time() . '" WHERE name = "milestonetime"'; + $setmst2 = mysql_query($setmst); + $setms = 'UPDATE config SET value = "' . ($gethits3['value']+1) . '" WHERE name = "milestone"'; + $setms2 = mysql_query($setms); + include('includes/header.php'); +?> +CONGRADULATIONS! You are the th person to visit this site! Refresh the page to return to the page you were visiting. + diff --git a/includes/http.php b/includes/http.php new file mode 100644 index 0000000..d0e55d7 --- /dev/null +++ b/includes/http.php @@ -0,0 +1,1982 @@ +"01", + "Feb"=>"02", + "Mar"=>"03", + "Apr"=>"04", + "May"=>"05", + "Jun"=>"06", + "Jul"=>"07", + "Aug"=>"08", + "Sep"=>"09", + "Oct"=>"10", + "Nov"=>"11", + "Dec"=>"12"); + var $session=''; + var $connection_close=0; + + /* Private methods - DO NOT CALL */ + + Function Tokenize($string,$separator="") + { + if(!strcmp($separator,"")) + { + $separator=$string; + $string=$this->next_token; + } + for($character=0;$characternext_token=substr($string,$found+1); + return(substr($string,0,$found)); + } + else + { + $this->next_token=""; + return($string); + } + } + + Function CookieEncode($value, $name) + { + return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value)); + } + + Function SetError($error) + { + return($this->error=$error); + } + + Function SetPHPError($error, &$php_error_message) + { + if(IsSet($php_error_message) + && strlen($php_error_message)) + $error.=": ".$php_error_message; + return($this->SetError($error)); + } + + Function SetDataAccessError($error,$check_connection=0) + { + $this->error=$error; + if(!$this->use_curl + && function_exists("socket_get_status")) + { + $status=socket_get_status($this->connection); + if($status["timed_out"]) + $this->error.=": data access time out"; + elseif($status["eof"]) + { + if($check_connection) + $this->error=""; + else + $this->error.=": the server disconnected"; + } + } + } + + Function OutputDebug($message) + { + $message.="\n"; + if($this->html_debug) + $message=str_replace("\n","
    \n",HtmlEntities($message)); + echo $message; + flush(); + } + + Function GetLine() + { + for($line="";;) + { + if($this->use_curl) + { + $eol=strpos($this->response,"\n",$this->read_response); + $data=($eol ? substr($this->response,$this->read_response,$eol+1-$this->read_response) : ""); + $this->read_response+=strlen($data); + } + else + { + if(feof($this->connection)) + { + $this->SetDataAccessError("reached the end of data while reading from the HTTP server connection"); + return(0); + } + $data=fgets($this->connection,100); + } + if(GetType($data)!="string" + || strlen($data)==0) + { + $this->SetDataAccessError("it was not possible to read line from the HTTP server"); + return(0); + } + $line.=$data; + $length=strlen($line); + if($length + && !strcmp(substr($line,$length-1,1),"\n")) + { + $length-=(($length>=2 && !strcmp(substr($line,$length-2,1),"\r")) ? 2 : 1); + $line=substr($line,0,$length); + if($this->debug) + $this->OutputDebug("S $line"); + return($line); + } + } + } + + Function PutLine($line) + { + if($this->debug) + $this->OutputDebug("C $line"); + if(!fputs($this->connection,$line."\r\n")) + { + $this->SetDataAccessError("it was not possible to send a line to the HTTP server"); + return(0); + } + return(1); + } + + Function PutData($data) + { + if(strlen($data)) + { + if($this->debug) + $this->OutputDebug('C '.$data); + if(!fputs($this->connection,$data)) + { + $this->SetDataAccessError("it was not possible to send data to the HTTP server"); + return(0); + } + } + return(1); + } + + Function FlushData() + { + if(!fflush($this->connection)) + { + $this->SetDataAccessError("it was not possible to send data to the HTTP server"); + return(0); + } + return(1); + } + + Function ReadChunkSize() + { + if($this->remaining_chunk==0) + { + $debug=$this->debug; + if(!$this->debug_response_body) + $this->debug=0; + $line=$this->GetLine(); + $this->debug=$debug; + if(GetType($line)!="string") + return($this->SetError("4 could not read chunk start: ".$this->error)); + $this->remaining_chunk=hexdec($line); + } + return(""); + } + + Function ReadBytes($length) + { + if($this->use_curl) + { + $bytes=substr($this->response,$this->read_response,min($length,strlen($this->response)-$this->read_response)); + $this->read_response+=strlen($bytes); + if($this->debug + && $this->debug_response_body + && strlen($bytes)) + $this->OutputDebug("S ".$bytes); + } + else + { + if($this->chunked) + { + for($bytes="",$remaining=$length;$remaining;) + { + if(strlen($this->ReadChunkSize())) + return(""); + if($this->remaining_chunk==0) + { + $this->last_chunk_read=1; + break; + } + $ask=min($this->remaining_chunk,$remaining); + $chunk=@fread($this->connection,$ask); + $read=strlen($chunk); + if($read==0) + { + $this->SetDataAccessError("it was not possible to read data chunk from the HTTP server"); + return(""); + } + if($this->debug + && $this->debug_response_body) + $this->OutputDebug("S ".$chunk); + $bytes.=$chunk; + $this->remaining_chunk-=$read; + $remaining-=$read; + if($this->remaining_chunk==0) + { + if(feof($this->connection)) + return($this->SetError("reached the end of data while reading the end of data chunk mark from the HTTP server")); + $data=@fread($this->connection,2); + if(strcmp($data,"\r\n")) + { + $this->SetDataAccessError("it was not possible to read end of data chunk from the HTTP server"); + return(""); + } + } + } + } + else + { + $bytes=@fread($this->connection,$length); + if(strlen($bytes)) + { + if($this->debug + && $this->debug_response_body) + $this->OutputDebug("S ".$bytes); + } + else + $this->SetDataAccessError("it was not possible to read data from the HTTP server", $this->connection_close); + } + } + return($bytes); + } + + Function EndOfInput() + { + if($this->use_curl) + return($this->read_response>=strlen($this->response)); + if($this->chunked) + return($this->last_chunk_read); + return(feof($this->connection)); + } + + Function Resolve($domain, &$ip, $server_type) + { + if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain)) + $ip=$domain; + else + { + if($this->debug) + $this->OutputDebug('Resolving '.$server_type.' server domain "'.$domain.'"...'); + if(!strcmp($ip=@gethostbyname($domain),$domain)) + $ip=""; + } + if(strlen($ip)==0 + || (strlen($this->exclude_address) + && !strcmp(@gethostbyname($this->exclude_address),$ip))) + return($this->SetError("could not resolve the host domain \"".$domain."\"")); + return(''); + } + + Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP') + { + $domain=$host_name; + $port = $host_port; + if(strlen($error = $this->Resolve($domain, $ip, $server_type))) + return($error); + if(strlen($this->socks_host_name)) + { + switch($this->socks_version) + { + case '4': + $version = 4; + break; + case '5': + $version = 5; + break; + default: + return('it was not specified a supported SOCKS protocol version'); + break; + } + $host_ip = $ip; + $port = $this->socks_host_port; + $host_server_type = $server_type; + $server_type = 'SOCKS'; + if(strlen($error = $this->Resolve($this->socks_host_name, $ip, $server_type))) + return($error); + } + if($this->debug) + $this->OutputDebug('Connecting to '.$server_type.' server IP '.$ip.' port '.$port.'...'); + if($ssl) + $ip="ssl://".$ip; + if(($this->connection=($this->timeout ? @fsockopen($ip, $port, $errno, $error, $this->timeout) : @fsockopen($ip, $port, $errno)))==0) + { + switch($errno) + { + case -3: + return($this->SetError("-3 socket could not be created")); + case -4: + return($this->SetError("-4 dns lookup on hostname \"".$host_name."\" failed")); + case -5: + return($this->SetError("-5 connection refused or timed out")); + case -6: + return($this->SetError("-6 fdopen() call failed")); + case -7: + return($this->SetError("-7 setvbuf() call failed")); + default: + return($this->SetPHPError($errno." could not connect to the host \"".$host_name."\"",$php_errormsg)); + } + } + else + { + if($this->data_timeout + && function_exists("socket_set_timeout")) + socket_set_timeout($this->connection,$this->data_timeout,0); + if(strlen($this->socks_host_name)) + { + if($this->debug) + $this->OutputDebug('Connected to the SOCKS server '.$this->socks_host_name); + $send_error = 'it was not possible to send data to the SOCKS server'; + $receive_error = 'it was not possible to receive data from the SOCKS server'; + switch($version) + { + case 4: + $command = 1; + if(!fputs($this->connection, chr($version).chr($command).pack('nN', $host_port, ip2long($host_ip)).$this->user.Chr(0))) + $error = $this->SetDataAccessError($send_error); + else + { + $response = fgets($this->connection, 9); + if(strlen($response) != 8) + $error = $this->SetDataAccessError($receive_error); + else + { + $socks_errors = array( + "\x5a"=>'', + "\x5b"=>'request rejected', + "\x5c"=>'request failed because client is not running identd (or not reachable from the server)', + "\x5d"=>'request failed because client\'s identd could not confirm the user ID string in the request', + ); + $error_code = $response[1]; + $error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown'); + if(strlen($error)) + $error = 'SOCKS error: '.$error; + } + } + break; + case 5: + if($this->debug) + $this->OutputDebug('Negotiating the authentication method ...'); + $methods = 1; + $method = 0; + if(!fputs($this->connection, chr($version).chr($methods).chr($method))) + $error = $this->SetDataAccessError($send_error); + else + { + $response = fgets($this->connection, 3); + if(strlen($response) != 2) + $error = $this->SetDataAccessError($receive_error); + elseif(Ord($response[1]) != $method) + $error = 'the SOCKS server requires an authentication method that is not yet supported'; + else + { + if($this->debug) + $this->OutputDebug('Connecting to '.$host_server_type.' server IP '.$host_ip.' port '.$host_port.'...'); + $command = 1; + $address_type = 1; + if(!fputs($this->connection, chr($version).chr($command)."\x00".chr($address_type).pack('Nn', ip2long($host_ip), $host_port))) + $error = $this->SetDataAccessError($send_error); + else + { + $response = fgets($this->connection, 11); + if(strlen($response) != 10) + $error = $this->SetDataAccessError($receive_error); + else + { + $socks_errors = array( + "\x00"=>'', + "\x01"=>'general SOCKS server failure', + "\x02"=>'connection not allowed by ruleset', + "\x03"=>'Network unreachable', + "\x04"=>'Host unreachable', + "\x05"=>'Connection refused', + "\x06"=>'TTL expired', + "\x07"=>'Command not supported', + "\x08"=>'Address type not supported' + ); + $error_code = $response[1]; + $error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown'); + if(strlen($error)) + $error = 'SOCKS error: '.$error; + } + } + } + } + break; + default: + $error = 'support for SOCKS protocol version '.$this->socks_version.' is not yet implemented'; + break; + } + if(strlen($error)) + { + fclose($this->connection); + return($error); + } + } + if($this->debug) + $this->OutputDebug("Connected to $host_name"); + if(strlen($this->proxy_host_name) + && !strcmp(strtolower($this->protocol), 'https')) + { + if(function_exists('stream_socket_enable_crypto') + && in_array('ssl', stream_get_transports())) + $this->state = "ConnectedToProxy"; + else + { + $this->OutputDebug("It is not possible to start SSL after connecting to the proxy server. If the proxy refuses to forward the SSL request, you may need to upgrade to PHP 5.1 or later with OpenSSL support enabled."); + $this->state="Connected"; + } + } + else + $this->state="Connected"; + return(""); + } + } + + Function Disconnect() + { + if($this->debug) + $this->OutputDebug("Disconnected from ".$this->host_name); + if($this->use_curl) + { + curl_close($this->connection); + $this->response=""; + } + else + fclose($this->connection); + $this->state="Disconnected"; + return(""); + } + + /* Public methods */ + + Function GetRequestArguments($url, &$arguments) + { + if(strlen($this->error)) + return($this->error); + $arguments=array(); + $parameters=@parse_url($url); + if(!$parameters) + return($this->SetError("it was not specified a valid URL")); + if(!IsSet($parameters["scheme"])) + return($this->SetError("it was not specified the protocol type argument")); + switch(strtolower($parameters["scheme"])) + { + case "http": + case "https": + $arguments["Protocol"]=$parameters["scheme"]; + break; + default: + return($parameters["scheme"]." connection scheme is not yet supported"); + } + if(!IsSet($parameters["host"])) + return($this->SetError("it was not specified the connection host argument")); + $arguments["HostName"]=$parameters["host"]; + $arguments["Headers"]=array("Host"=>$parameters["host"].(IsSet($parameters["port"]) ? ":".$parameters["port"] : "")); + if(IsSet($parameters["user"])) + { + $arguments["AuthUser"]=UrlDecode($parameters["user"]); + if(!IsSet($parameters["pass"])) + $arguments["AuthPassword"]=""; + } + if(IsSet($parameters["pass"])) + { + if(!IsSet($parameters["user"])) + $arguments["AuthUser"]=""; + $arguments["AuthPassword"]=UrlDecode($parameters["pass"]); + } + if(IsSet($parameters["port"])) + { + if(strcmp($parameters["port"],strval(intval($parameters["port"])))) + return($this->SetError("it was not specified a valid connection host argument")); + $arguments["HostPort"]=intval($parameters["port"]); + } + else + $arguments["HostPort"]=0; + $arguments["RequestURI"]=(IsSet($parameters["path"]) ? $parameters["path"] : "/").(IsSet($parameters["query"]) ? "?".$parameters["query"] : ""); + if(strlen($this->user_agent)) + $arguments["Headers"]["User-Agent"]=$this->user_agent; + return(""); + } + + Function Open($arguments) + { + if(strlen($this->error)) + return($this->error); + if($this->state!="Disconnected") + return("1 already connected"); + if(IsSet($arguments["HostName"])) + $this->host_name=$arguments["HostName"]; + if(IsSet($arguments["HostPort"])) + $this->host_port=$arguments["HostPort"]; + if(IsSet($arguments["ProxyHostName"])) + $this->proxy_host_name=$arguments["ProxyHostName"]; + if(IsSet($arguments["ProxyHostPort"])) + $this->proxy_host_port=$arguments["ProxyHostPort"]; + if(IsSet($arguments["SOCKSHostName"])) + $this->socks_host_name=$arguments["SOCKSHostName"]; + if(IsSet($arguments["SOCKSHostPort"])) + $this->socks_host_port=$arguments["SOCKSHostPort"]; + if(IsSet($arguments["SOCKSVersion"])) + $this->socks_version=$arguments["SOCKSVersion"]; + if(IsSet($arguments["Protocol"])) + $this->protocol=$arguments["Protocol"]; + switch(strtolower($this->protocol)) + { + case "http": + $default_port=80; + break; + case "https": + $default_port=443; + break; + default: + return($this->SetError("2 it was not specified a valid connection protocol")); + } + if(strlen($this->proxy_host_name)==0) + { + if(strlen($this->host_name)==0) + return($this->SetError("2 it was not specified a valid hostname")); + $host_name=$this->host_name; + $host_port=($this->host_port ? $this->host_port : $default_port); + $server_type = 'HTTP'; + } + else + { + $host_name=$this->proxy_host_name; + $host_port=$this->proxy_host_port; + $server_type = 'HTTP proxy'; + } + $ssl=(strtolower($this->protocol)=="https" && strlen($this->proxy_host_name)==0); + if($ssl + && strlen($this->socks_host_name)) + return($this->SetError('establishing SSL connections via a SOCKS server is not yet supported')); + $this->use_curl=($ssl && $this->prefer_curl && function_exists("curl_init")); + if($this->debug) + $this->OutputDebug("Connecting to ".$this->host_name); + if($this->use_curl) + { + $error=(($this->connection=curl_init($this->protocol."://".$this->host_name.($host_port==$default_port ? "" : ":".strval($host_port))."/")) ? "" : "Could not initialize a CURL session"); + if(strlen($error)==0) + { + if(IsSet($arguments["SSLCertificateFile"])) + curl_setopt($this->connection,CURLOPT_SSLCERT,$arguments["SSLCertificateFile"]); + if(IsSet($arguments["SSLCertificatePassword"])) + curl_setopt($this->connection,CURLOPT_SSLCERTPASSWD,$arguments["SSLCertificatePassword"]); + if(IsSet($arguments["SSLKeyFile"])) + curl_setopt($this->connection,CURLOPT_SSLKEY,$arguments["SSLKeyFile"]); + if(IsSet($arguments["SSLKeyPassword"])) + curl_setopt($this->connection,CURLOPT_SSLKEYPASSWD,$arguments["SSLKeyPassword"]); + } + $this->state="Connected"; + } + else + { + $error=""; + if(strlen($this->proxy_host_name) + && (IsSet($arguments["SSLCertificateFile"]) + || IsSet($arguments["SSLCertificateFile"]))) + $error="establishing SSL connections using certificates or private keys via non-SSL proxies is not supported"; + else + { + if($ssl) + { + if(IsSet($arguments["SSLCertificateFile"])) + $error="establishing SSL connections using certificates is only supported when the cURL extension is enabled"; + elseif(IsSet($arguments["SSLKeyFile"])) + $error="establishing SSL connections using a private key is only supported when the cURL extension is enabled"; + else + { + $version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7"); + $php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]); + if($php_version<4003000) + $error="establishing SSL connections requires at least PHP version 4.3.0 or having the cURL extension enabled"; + elseif(!function_exists("extension_loaded") + || !extension_loaded("openssl")) + $error="establishing SSL connections requires the OpenSSL extension enabled"; + } + } + if(strlen($error)==0) + $error=$this->Connect($host_name, $host_port, $ssl, $server_type); + } + } + if(strlen($error)) + return($this->SetError($error)); + $this->session=md5(uniqid("")); + return(""); + } + + Function Close() + { + if($this->state=="Disconnected") + return("1 already disconnected"); + $error=$this->Disconnect(); + if(strlen($error)==0) + $this->state="Disconnected"; + return($error); + } + + Function PickCookies(&$cookies,$secure) + { + if(IsSet($this->cookies[$secure])) + { + $now=gmdate("Y-m-d H-i-s"); + for($domain=0,Reset($this->cookies[$secure]);$domaincookies[$secure]);Next($this->cookies[$secure]),$domain++) + { + $domain_pattern=Key($this->cookies[$secure]); + $match=strlen($this->request_host)-strlen($domain_pattern); + if($match>=0 + && !strcmp($domain_pattern,substr($this->request_host,$match)) + && ($match==0 + || $domain_pattern[0]=="." + || $this->request_host[$match-1]==".")) + { + for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_partcookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++) + { + $path=Key($this->cookies[$secure][$domain_pattern]); + if(strlen($this->request_uri)>=strlen($path) + && substr($this->request_uri,0,strlen($path))==$path) + { + for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookiecookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++) + { + $cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]); + $expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"]; + if($expires=="" + || strcmp($now,$expires)<0) + $cookies[$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]; + } + } + } + } + } + } + } + + Function GetFileDefinition($file, &$definition) + { + $name=""; + if(IsSet($file["FileName"])) + $name=basename($file["FileName"]); + if(IsSet($file["Name"])) + $name=$file["Name"]; + if(strlen($name)==0) + return("it was not specified the file part name"); + if(IsSet($file["Content-Type"])) + { + $content_type=$file["Content-Type"]; + $type=$this->Tokenize(strtolower($content_type),"/"); + $sub_type=$this->Tokenize(""); + switch($type) + { + case "text": + case "image": + case "audio": + case "video": + case "application": + case "message": + break; + case "automatic": + switch($sub_type) + { + case "name": + switch(GetType($dot=strrpos($name,"."))=="integer" ? strtolower(substr($name,$dot)) : "") + { + case ".xls": + $content_type="application/excel"; + break; + case ".hqx": + $content_type="application/macbinhex40"; + break; + case ".doc": + case ".dot": + case ".wrd": + $content_type="application/msword"; + break; + case ".pdf": + $content_type="application/pdf"; + break; + case ".pgp": + $content_type="application/pgp"; + break; + case ".ps": + case ".eps": + case ".ai": + $content_type="application/postscript"; + break; + case ".ppt": + $content_type="application/powerpoint"; + break; + case ".rtf": + $content_type="application/rtf"; + break; + case ".tgz": + case ".gtar": + $content_type="application/x-gtar"; + break; + case ".gz": + $content_type="application/x-gzip"; + break; + case ".php": + case ".php3": + $content_type="application/x-httpd-php"; + break; + case ".js": + $content_type="application/x-javascript"; + break; + case ".ppd": + case ".psd": + $content_type="application/x-photoshop"; + break; + case ".swf": + case ".swc": + case ".rf": + $content_type="application/x-shockwave-flash"; + break; + case ".tar": + $content_type="application/x-tar"; + break; + case ".zip": + $content_type="application/zip"; + break; + case ".mid": + case ".midi": + case ".kar": + $content_type="audio/midi"; + break; + case ".mp2": + case ".mp3": + case ".mpga": + $content_type="audio/mpeg"; + break; + case ".ra": + $content_type="audio/x-realaudio"; + break; + case ".wav": + $content_type="audio/wav"; + break; + case ".bmp": + $content_type="image/bitmap"; + break; + case ".gif": + $content_type="image/gif"; + break; + case ".iff": + $content_type="image/iff"; + break; + case ".jb2": + $content_type="image/jb2"; + break; + case ".jpg": + case ".jpe": + case ".jpeg": + $content_type="image/jpeg"; + break; + case ".jpx": + $content_type="image/jpx"; + break; + case ".png": + $content_type="image/png"; + break; + case ".tif": + case ".tiff": + $content_type="image/tiff"; + break; + case ".wbmp": + $content_type="image/vnd.wap.wbmp"; + break; + case ".xbm": + $content_type="image/xbm"; + break; + case ".css": + $content_type="text/css"; + break; + case ".txt": + $content_type="text/plain"; + break; + case ".htm": + case ".html": + $content_type="text/html"; + break; + case ".xml": + $content_type="text/xml"; + break; + case ".mpg": + case ".mpe": + case ".mpeg": + $content_type="video/mpeg"; + break; + case ".qt": + case ".mov": + $content_type="video/quicktime"; + break; + case ".avi": + $content_type="video/x-ms-video"; + break; + case ".eml": + $content_type="message/rfc822"; + break; + default: + $content_type="application/octet-stream"; + break; + } + break; + default: + return($content_type." is not a supported automatic content type detection method"); + } + break; + default: + return($content_type." is not a supported file content type"); + } + } + else + $content_type="application/octet-stream"; + $definition=array( + "Content-Type"=>$content_type, + "NAME"=>$name + ); + if(IsSet($file["FileName"])) + { + if(GetType($length=@filesize($file["FileName"]))!="integer") + { + $error="it was not possible to determine the length of the file ".$file["FileName"]; + if(IsSet($php_errormsg) + && strlen($php_errormsg)) + $error.=": ".$php_errormsg; + if(!file_exists($file["FileName"])) + $error="it was not possible to access the file ".$file["FileName"]; + return($error); + } + $definition["FILENAME"]=$file["FileName"]; + $definition["Content-Length"]=$length; + } + elseif(IsSet($file["Data"])) + $definition["Content-Length"]=strlen($definition["DATA"]=$file["Data"]); + else + return("it was not specified a valid file name"); + return(""); + } + + Function ConnectFromProxy($arguments, &$headers) + { + if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0') + || (strlen($this->user_agent) + && !$this->PutLine('User-Agent: '.$this->user_agent)) + || (IsSet($arguments['Headers']['Proxy-Authorization']) + && !$this->PutLine('Proxy-Authorization: '.$arguments['Headers']['Proxy-Authorization'])) + || !$this->PutLine('')) + { + $this->Disconnect(); + return($this->error); + } + $this->state = "ConnectSent"; + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + $proxy_authorization=""; + while(!strcmp($this->response_status, "100")) + { + $this->state="ConnectSent"; + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + } + switch($this->response_status) + { + case "200": + if(!@stream_socket_enable_crypto($this->connection, 1, STREAM_CRYPTO_METHOD_SSLv23_CLIENT)) + { + $this->SetPHPError('it was not possible to start a SSL encrypted connection via this proxy', $php_errormsg); + $this->Disconnect(); + return($this->error); + } + $this->state = "Connected"; + break; + case "407": + if(strlen($error=$this->Authenticate($headers, -1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation))) + return($error); + break; + default: + return($this->SetError("unable to send request via proxy")); + } + return(""); + } + + Function SendRequest($arguments) + { + if(strlen($this->error)) + return($this->error); + if(IsSet($arguments["ProxyUser"])) + $this->proxy_request_user=$arguments["ProxyUser"]; + elseif(IsSet($this->proxy_user)) + $this->proxy_request_user=$this->proxy_user; + if(IsSet($arguments["ProxyPassword"])) + $this->proxy_request_password=$arguments["ProxyPassword"]; + elseif(IsSet($this->proxy_password)) + $this->proxy_request_password=$this->proxy_password; + if(IsSet($arguments["ProxyRealm"])) + $this->proxy_request_realm=$arguments["ProxyRealm"]; + elseif(IsSet($this->proxy_realm)) + $this->proxy_request_realm=$this->proxy_realm; + if(IsSet($arguments["ProxyWorkstation"])) + $this->proxy_request_workstation=$arguments["ProxyWorkstation"]; + elseif(IsSet($this->proxy_workstation)) + $this->proxy_request_workstation=$this->proxy_workstation; + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + $connect = 0; + break; + case "ConnectedToProxy": + if(strlen($error = $this->ConnectFromProxy($arguments, $headers))) + return($error); + $connect = 1; + break; + default: + return($this->SetError("2 can not send request in the current connection state")); + } + if(IsSet($arguments["RequestMethod"])) + $this->request_method=$arguments["RequestMethod"]; + if(IsSet($arguments["User-Agent"])) + $this->user_agent=$arguments["User-Agent"]; + if(!IsSet($arguments["Headers"]["User-Agent"]) + && strlen($this->user_agent)) + $arguments["Headers"]["User-Agent"]=$this->user_agent; + if(strlen($this->request_method)==0) + return($this->SetError("3 it was not specified a valid request method")); + if(IsSet($arguments["RequestURI"])) + $this->request_uri=$arguments["RequestURI"]; + if(strlen($this->request_uri)==0 + || substr($this->request_uri,0,1)!="/") + return($this->SetError("4 it was not specified a valid request URI")); + $this->request_arguments=$arguments; + $this->request_headers=(IsSet($arguments["Headers"]) ? $arguments["Headers"] : array()); + $body_length=0; + $this->request_body=""; + $get_body=1; + if($this->request_method=="POST" + || $this->request_method=="PUT") + { + if(IsSet($arguments['StreamRequest'])) + { + $get_body = 0; + $this->request_headers["Transfer-Encoding"]="chunked"; + } + elseif(IsSet($arguments["PostFiles"]) + || ($this->force_multipart_form_post + && IsSet($arguments["PostValues"]))) + { + $boundary="--".md5(uniqid(time())); + $this->request_headers["Content-Type"]="multipart/form-data; boundary=".$boundary.(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : ""); + $post_parts=array(); + if(IsSet($arguments["PostValues"])) + { + $values=$arguments["PostValues"]; + if(GetType($values)!="array") + return($this->SetError("5 it was not specified a valid POST method values array")); + for(Reset($values),$value=0;$value$headers,"DATA"=>$data); + $body_length+=strlen($headers)+strlen($data)+strlen("\r\n"); + } + } + $body_length+=strlen("--".$boundary."--\r\n"); + $files=(IsSet($arguments["PostFiles"]) ? $arguments["PostFiles"] : array()); + Reset($files); + $end=(GetType($input=Key($files))!="string"); + for(;!$end;) + { + if(strlen($error=$this->GetFileDefinition($files[$input],$definition))) + return("3 ".$error); + $headers="--".$boundary."\r\nContent-Disposition: form-data; name=\"".$input."\"; filename=\"".$definition["NAME"]."\"\r\nContent-Type: ".$definition["Content-Type"]."\r\n\r\n"; + $part=count($post_parts); + $post_parts[$part]=array("HEADERS"=>$headers); + if(IsSet($definition["FILENAME"])) + { + $post_parts[$part]["FILENAME"]=$definition["FILENAME"]; + $data=""; + } + else + $data=$definition["DATA"]; + $post_parts[$part]["DATA"]=$data; + $body_length+=strlen($headers)+$definition["Content-Length"]+strlen("\r\n"); + Next($files); + $end=(GetType($input=Key($files))!="string"); + } + $get_body=0; + } + elseif(IsSet($arguments["PostValues"])) + { + $values=$arguments["PostValues"]; + if(GetType($values)!="array") + return($this->SetError("5 it was not specified a valid POST method values array")); + for(Reset($values),$value=0;$value0) + $this->request_body.="&"; + $this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k][$v]); + } + } + else + { + if($value>0) + $this->request_body.="&"; + $this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k]); + } + } + $this->request_headers["Content-Type"]="application/x-www-form-urlencoded".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : ""); + $get_body=0; + } + } + if($get_body + && (IsSet($arguments["Body"]) + || IsSet($arguments["BodyStream"]))) + { + if(IsSet($arguments["Body"])) + $this->request_body=$arguments["Body"]; + else + { + $stream=$arguments["BodyStream"]; + $this->request_body=""; + for($part=0; $partrequest_body.=$stream[$part]["Data"]; + elseif(IsSet($stream[$part]["File"])) + { + if(!($file=@fopen($stream[$part]["File"],"rb"))) + return($this->SetPHPError("could not open upload file ".$stream[$part]["File"], $php_errormsg)); + while(!feof($file)) + { + if(GetType($block=@fread($file,$this->file_buffer_length))!="string") + { + $error=$this->SetPHPError("could not read body stream file ".$stream[$part]["File"], $php_errormsg); + fclose($file); + return($error); + } + $this->request_body.=$block; + } + fclose($file); + } + else + return("5 it was not specified a valid file or data body stream element at position ".$part); + } + } + if(!IsSet($this->request_headers["Content-Type"])) + $this->request_headers["Content-Type"]="application/octet-stream".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : ""); + } + if(IsSet($arguments["AuthUser"])) + $this->request_user=$arguments["AuthUser"]; + elseif(IsSet($this->user)) + $this->request_user=$this->user; + if(IsSet($arguments["AuthPassword"])) + $this->request_password=$arguments["AuthPassword"]; + elseif(IsSet($this->password)) + $this->request_password=$this->password; + if(IsSet($arguments["AuthRealm"])) + $this->request_realm=$arguments["AuthRealm"]; + elseif(IsSet($this->realm)) + $this->request_realm=$this->realm; + if(IsSet($arguments["AuthWorkstation"])) + $this->request_workstation=$arguments["AuthWorkstation"]; + elseif(IsSet($this->workstation)) + $this->request_workstation=$this->workstation; + if(strlen($this->proxy_host_name)==0 + || $connect) + $request_uri=$this->request_uri; + else + { + switch(strtolower($this->protocol)) + { + case "http": + $default_port=80; + break; + case "https": + $default_port=443; + break; + } + $request_uri=strtolower($this->protocol)."://".$this->host_name.(($this->host_port==0 || $this->host_port==$default_port) ? "" : ":".$this->host_port).$this->request_uri; + } + if($this->use_curl) + { + $version=(GetType($v=curl_version())=="array" ? (IsSet($v["version"]) ? $v["version"] : "0.0.0") : (ereg("^libcurl/([0-9]+\\.[0-9]+\\.[0-9]+)",$v,$m) ? $m[1] : "0.0.0")); + $curl_version=100000*intval($this->Tokenize($version,"."))+1000*intval($this->Tokenize("."))+intval($this->Tokenize("")); + $protocol_version=($curl_version<713002 ? "1.0" : $this->protocol_version); + } + else + $protocol_version=$this->protocol_version; + $this->request=$this->request_method." ".$request_uri." HTTP/".$protocol_version; + if($body_length + || ($body_length=strlen($this->request_body))) + $this->request_headers["Content-Length"]=$body_length; + for($headers=array(),$host_set=0,Reset($this->request_headers),$header=0;$headerrequest_headers);Next($this->request_headers),$header++) + { + $header_name=Key($this->request_headers); + $header_value=$this->request_headers[$header_name]; + if(GetType($header_value)=="array") + { + for(Reset($header_value),$value=0;$valuerequest_headers))=="host") + { + $this->request_host=strtolower($header_value); + $host_set=1; + } + } + if(!$host_set) + { + $headers[]="Host: ".$this->host_name; + $this->request_host=strtolower($this->host_name); + } + if(count($this->cookies)) + { + $cookies=array(); + $this->PickCookies($cookies,0); + if(strtolower($this->protocol)=="https") + $this->PickCookies($cookies,1); + if(count($cookies)) + { + $h=count($headers); + $headers[$h]="Cookie:"; + for(Reset($cookies),$cookie=0;$cookieuse_curl) + { + if(IsSet($arguments['StreamRequest'])) + return($this->SetError("Streaming request data is not supported when using Curl")); + if($body_length + && strlen($this->request_body)==0) + { + for($request_body="",$success=1,$part=0;$partSetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg); + $success=0; + break; + } + while(!feof($file)) + { + if(GetType($block=@fread($file,$this->file_buffer_length))!="string") + { + $this->SetPHPError("could not read upload file", $php_errormsg); + $success=0; + break; + } + $request_body.=$block; + } + fclose($file); + if(!$success) + break; + } + $request_body.="\r\n"; + } + $request_body.="--".$boundary."--\r\n"; + } + else + $request_body=$this->request_body; + curl_setopt($this->connection,CURLOPT_HEADER,1); + curl_setopt($this->connection,CURLOPT_RETURNTRANSFER,1); + if($this->timeout) + curl_setopt($this->connection,CURLOPT_TIMEOUT,$this->timeout); + curl_setopt($this->connection,CURLOPT_SSL_VERIFYPEER,0); + curl_setopt($this->connection,CURLOPT_SSL_VERIFYHOST,0); + $request=$this->request."\r\n".implode("\r\n",$headers)."\r\n\r\n".$request_body; + curl_setopt($this->connection,CURLOPT_CUSTOMREQUEST,$request); + if($this->debug) + $this->OutputDebug("C ".$request); + if(!($success=(strlen($this->response=curl_exec($this->connection))!=0))) + { + $error=curl_error($this->connection); + $this->SetError("Could not execute the request".(strlen($error) ? ": ".$error : "")); + } + } + else + { + if(($success=$this->PutLine($this->request))) + { + for($header=0;$headerPutLine($headers[$header])) + break; + } + if($success + && ($success=$this->PutLine(""))) + { + if(IsSet($arguments['StreamRequest'])) + $next_state = "SendingRequestBody"; + elseif($body_length) + { + if(strlen($this->request_body)) + $success=$this->PutData($this->request_body); + else + { + for($part=0;$partPutData($post_parts[$part]["HEADERS"])) + || !($success=$this->PutData($post_parts[$part]["DATA"]))) + break; + if(IsSet($post_parts[$part]["FILENAME"])) + { + if(!($file=@fopen($post_parts[$part]["FILENAME"],"rb"))) + { + $this->SetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg); + $success=0; + break; + } + while(!feof($file)) + { + if(GetType($block=@fread($file,$this->file_buffer_length))!="string") + { + $this->SetPHPError("could not read upload file", $php_errormsg); + $success=0; + break; + } + if(!($success=$this->PutData($block))) + break; + } + fclose($file); + if(!$success) + break; + } + if(!($success=$this->PutLine(""))) + break; + } + if($success) + $success=$this->PutLine("--".$boundary."--"); + } + if($success) + $sucess=$this->FlushData(); + } + } + } + } + if(!$success) + return($this->SetError("5 could not send the HTTP request: ".$this->error)); + $this->state=$next_state; + return(""); + } + + Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0) + { + if(strlen($this->error)) + return($this->error); + if(strlen($name)==0) + return($this->SetError("it was not specified a valid cookie name")); + if(strlen($path)==0 + || strcmp($path[0],"/")) + return($this->SetError($path." is not a valid path for setting cookie ".$name)); + if($domain=="" + || !strpos($domain,".",$domain[0]=="." ? 1 : 0)) + return($this->SetError($domain." is not a valid domain for setting cookie ".$name)); + $domain=strtolower($domain); + if(!strcmp($domain[0],".")) + $domain=substr($domain,1); + if(!$verbatim) + { + $name=$this->CookieEncode($name,1); + $value=$this->CookieEncode($value,0); + } + $secure=intval($secure); + $this->cookies[$secure][$domain][$path][$name]=array( + "name"=>$name, + "value"=>$value, + "domain"=>$domain, + "path"=>$path, + "expires"=>$expires, + "secure"=>$secure + ); + return(""); + } + + Function SendRequestBody($data, $end_of_data) + { + if(strlen($this->error)) + return($this->error); + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + case "ConnectedToProxy": + return($this->SetError("2 request was not sent")); + case "SendingRequestBody": + break; + case "RequestSent": + return($this->SetError("3 request body was already sent")); + default: + return($this->SetError("4 can not send the request body in the current connection state")); + } + $length = strlen($data); + if($length) + { + $size = dechex($length)."\r\n"; + if(!$this->PutData($size) + || !$this->PutData($data)) + return($this->error); + } + if($end_of_data) + { + $size = "0\r\n"; + if(!$this->PutData($size)) + return($this->error); + $this->state = "RequestSent"; + } + return(""); + } + + Function ReadReplyHeadersResponse(&$headers) + { + $headers=array(); + if(strlen($this->error)) + return($this->error); + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + return($this->SetError("2 request was not sent")); + case "ConnectedToProxy": + return($this->SetError("2 connection from the remote server from the proxy was not yet established")); + case "SendingRequestBody": + return($this->SetError("4 request body data was not completely sent")); + case "ConnectSent": + $connect = 1; + break; + case "RequestSent": + $connect = 0; + break; + default: + return($this->SetError("3 can not get request headers in the current connection state")); + } + $this->content_length=$this->read_length=$this->read_response=$this->remaining_chunk=0; + $this->content_length_set=$this->chunked=$this->last_chunk_read=$chunked=0; + $this->connection_close=0; + for($this->response_status="";;) + { + $line=$this->GetLine(); + if(GetType($line)!="string") + return($this->SetError("4 could not read request reply: ".$this->error)); + if(strlen($this->response_status)==0) + { + if(!eregi($match="^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$",$line,$matches)) + return($this->SetError("3 it was received an unexpected HTTP response status")); + $this->response_status=$matches[1]; + $this->response_message=$matches[2]; + } + if($line=="") + { + if(strlen($this->response_status)==0) + return($this->SetError("3 it was not received HTTP response status")); + $this->state=($connect ? "GotConnectHeaders" : "GotReplyHeaders"); + break; + } + $header_name=strtolower($this->Tokenize($line,":")); + $header_value=Trim(Chop($this->Tokenize("\r\n"))); + if(IsSet($headers[$header_name])) + { + if(GetType($headers[$header_name])=="string") + $headers[$header_name]=array($headers[$header_name]); + $headers[$header_name][]=$header_value; + } + else + $headers[$header_name]=$header_value; + if(!$connect) + { + switch($header_name) + { + case "content-length": + $this->content_length=intval($headers[$header_name]); + $this->content_length_set=1; + break; + case "transfer-encoding": + $encoding=$this->Tokenize($header_value,"; \t"); + if(!$this->use_curl + && !strcmp($encoding,"chunked")) + $chunked=1; + break; + case "set-cookie": + if($this->support_cookies) + { + if(GetType($headers[$header_name])=="array") + $cookie_headers=$headers[$header_name]; + else + $cookie_headers=array($headers[$header_name]); + for($cookie=0;$cookieTokenize($cookie_headers[$cookie],"=")); + $cookie_value=$this->Tokenize(";"); + $domain=$this->request_host; + $path="/"; + $expires=""; + $secure=0; + while(($name=trim(UrlDecode($this->Tokenize("="))))!="") + { + $value=UrlDecode($this->Tokenize(";")); + switch($name) + { + case "domain": + $domain=$value; + break; + case "path": + $path=$value; + break; + case "expires": + if(ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT\$",$value,$matches)) + { + $year=intval($matches[5]); + if($year<1900) + $year+=($year<70 ? 2000 : 1900); + $expires="$year-".$this->months[$matches[4]]."-".$matches[3]." ".$matches[6].":".$matches[7].":".$matches[8]; + } + break; + case "secure": + $secure=1; + break; + } + } + if(strlen($this->SetCookie($cookie_name, $cookie_value, $expires, $path , $domain, $secure, 1))) + $this->error=""; + } + } + break; + case "connection": + $this->connection_close=!strcmp(strtolower($header_value),"close"); + break; + } + } + } + $this->chunked=$chunked; + if($this->content_length_set) + $this->connection_close=0; + return(""); + } + + Function Redirect(&$headers) + { + if($this->follow_redirect) + { + if(!IsSet($headers["location"]) + || (GetType($headers["location"])!="array" + && strlen($location=$headers["location"])==0) + || (GetType($headers["location"])=="array" + && strlen($location=$headers["location"][0])==0)) + return($this->SetError("3 it was received a redirect without location URL")); + if(strcmp($location[0],"/")) + { + $location_arguments=parse_url($location); + if(!IsSet($location_arguments["scheme"])) + $location=((GetType($end=strrpos($this->request_uri,"/"))=="integer" && $end>1) ? substr($this->request_uri,0,$end) : "")."/".$location; + } + if(!strcmp($location[0],"/")) + $location=$this->protocol."://".$this->host_name.($this->host_port ? ":".$this->host_port : "").$location; + $error=$this->GetRequestArguments($location,$arguments); + if(strlen($error)) + return($this->SetError("could not process redirect url: ".$error)); + $arguments["RequestMethod"]="GET"; + if(strlen($error=$this->Close())==0 + && strlen($error=$this->Open($arguments))==0 + && strlen($error=$this->SendRequest($arguments))==0) + { + $this->redirection_level++; + if($this->redirection_level>$this->redirection_limit) + $error="it was exceeded the limit of request redirections"; + else + $error=$this->ReadReplyHeaders($headers); + $this->redirection_level--; + } + if(strlen($error)) + return($this->SetError($error)); + } + return(""); + } + + Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation) + { + if($proxy) + { + $authenticate_header="proxy-authenticate"; + $authorization_header="Proxy-Authorization"; + $authenticate_status="407"; + $authentication_mechanism=$this->proxy_authentication_mechanism; + } + else + { + $authenticate_header="www-authenticate"; + $authorization_header="Authorization"; + $authenticate_status="401"; + $authentication_mechanism=$this->authentication_mechanism; + } + if(IsSet($headers[$authenticate_header])) + { + if(function_exists("class_exists") + && !class_exists("sasl_client_class")) + return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site")); + if(GetType($headers[$authenticate_header])=="array") + $authenticate=$headers[$authenticate_header]; + else + $authenticate=array($headers[$authenticate_header]); + for($response="", $mechanisms=array(),$m=0;$mTokenize($authenticate[$m]," "); + $response=$this->Tokenize(""); + if(strlen($authentication_mechanism)) + { + if(!strcmp($authentication_mechanism,$mechanism)) + { + $mechanisms[]=$mechanism; + break; + } + } + else + $mechanisms[]=$mechanism; + } + $sasl=new sasl_client_class; + if(IsSet($user)) + $sasl->SetCredential("user",$user); + if(IsSet($password)) + $sasl->SetCredential("password",$password); + if(IsSet($realm)) + $sasl->SetCredential("realm",$realm); + if(IsSet($workstation)) + $sasl->SetCredential("workstation",$workstation); + $sasl->SetCredential("uri",$this->request_uri); + $sasl->SetCredential("method",$this->request_method); + $sasl->SetCredential("session",$this->session); + do + { + $status=$sasl->Start($mechanisms,$message,$interactions); + } + while($status==SASL_INTERACT); + switch($status) + { + case SASL_CONTINUE: + break; + case SASL_NOMECH: + return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".(strlen($authentication_mechanism) ? "authentication mechanism ".$authentication_mechanism." may not be used: " : "").$sasl->error)); + default: + return($this->SetError("Could not start the SASL ".($proxy ? "proxy " : "")."authentication client: ".$sasl->error)); + } + if($proxy >= 0) + { + for(;;) + { + if(strlen($error=$this->ReadReplyBody($body,$this->file_buffer_length))) + return($error); + if(strlen($body)==0) + break; + } + } + $authorization_value=$sasl->mechanism.(IsSet($message) ? " ".($sasl->encode_response ? base64_encode($message) : $message) : ""); + $request_arguments=$this->request_arguments; + $arguments=$request_arguments; + $arguments["Headers"][$authorization_header]=$authorization_value; + if(!$proxy + && strlen($proxy_authorization)) + $arguments["Headers"]["Proxy-Authorization"]=$proxy_authorization; + if(strlen($error=$this->Close()) + || strlen($error=$this->Open($arguments))) + return($this->SetError($error)); + $authenticated=0; + if(IsSet($message)) + { + if($proxy < 0) + { + if(strlen($error=$this->ConnectFromProxy($arguments, $headers))) + return($this->SetError($error)); + } + else + { + if(strlen($error=$this->SendRequest($arguments)) + || strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($this->SetError($error)); + } + if(!IsSet($headers[$authenticate_header])) + $authenticate=array(); + elseif(GetType($headers[$authenticate_header])=="array") + $authenticate=$headers[$authenticate_header]; + else + $authenticate=array($headers[$authenticate_header]); + for($mechanism=0;$mechanismTokenize($authenticate[$mechanism]," "),$sasl->mechanism)) + { + $response=$this->Tokenize(""); + break; + } + } + switch($this->response_status) + { + case $authenticate_status: + break; + case "301": + case "302": + case "303": + case "307": + if($proxy >= 0) + return($this->Redirect($headers)); + default: + if(intval($this->response_status/100)==2) + { + if($proxy) + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + if($proxy + && !strcmp($this->response_status,"401")) + { + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".$this->response_status." ".$this->response_message)); + } + } + for(;!$authenticated;) + { + do + { + $status=$sasl->Step($response,$message,$interactions); + } + while($status==SASL_INTERACT); + switch($status) + { + case SASL_CONTINUE: + $authorization_value=$sasl->mechanism.(IsSet($message) ? " ".($sasl->encode_response ? base64_encode($message) : $message) : ""); + $arguments=$request_arguments; + $arguments["Headers"][$authorization_header]=$authorization_value; + if(!$proxy + && strlen($proxy_authorization)) + $arguments["Headers"]["Proxy-Authorization"]=$proxy_authorization; + if($proxy < 0) + { + if(strlen($error=$this->ConnectFromProxy($arguments, $headers))) + return($this->SetError($error)); + } + else + { + if(strlen($error=$this->SendRequest($arguments)) + || strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($this->SetError($error)); + } + switch($this->response_status) + { + case $authenticate_status: + if(GetType($headers[$authenticate_header])=="array") + $authenticate=$headers[$authenticate_header]; + else + $authenticate=array($headers[$authenticate_header]); + for($response="",$mechanism=0;$mechanismTokenize($authenticate[$mechanism]," "),$sasl->mechanism)) + { + $response=$this->Tokenize(""); + break; + } + } + if($proxy >= 0) + { + for(;;) + { + if(strlen($error=$this->ReadReplyBody($body,$this->file_buffer_length))) + return($error); + if(strlen($body)==0) + break; + } + } + $this->state="Connected"; + break; + case "301": + case "302": + case "303": + case "307": + if($proxy >= 0) + return($this->Redirect($headers)); + default: + if(intval($this->response_status/100)==2) + { + if($proxy) + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + if($proxy + && !strcmp($this->response_status,"401")) + { + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".$this->response_status." ".$this->response_message)); + } + break; + default: + return($this->SetError("Could not process the SASL ".($proxy ? "proxy " : "")."authentication step: ".$sasl->error)); + } + } + } + return(""); + } + + Function ReadReplyHeaders(&$headers) + { + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + $proxy_authorization=""; + while(!strcmp($this->response_status, "100")) + { + $this->state="RequestSent"; + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + } + switch($this->response_status) + { + case "301": + case "302": + case "303": + case "307": + if(strlen($error=$this->Redirect($headers))) + return($error); + break; + case "407": + if(strlen($error=$this->Authenticate($headers, 1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation))) + return($error); + if(strcmp($this->response_status,"401")) + return(""); + case "401": + return($this->Authenticate($headers, 0, $proxy_authorization, $this->request_user, $this->request_password, $this->request_realm, $this->request_workstation)); + } + return(""); + } + + Function ReadReplyBody(&$body,$length) + { + $body=""; + if(strlen($this->error)) + return($this->error); + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + case "ConnectedToProxy": + return($this->SetError("2 request was not sent")); + case "RequestSent": + if(($error=$this->ReadReplyHeaders($headers))!="") + return($error); + break; + case "GotReplyHeaders": + break; + default: + return($this->SetError("3 can not get request headers in the current connection state")); + } + if($this->content_length_set) + $length=min($this->content_length-$this->read_length,$length); + if($length>0 + && !$this->EndOfInput() + && ($body=$this->ReadBytes($length))=="") + { + if(strlen($this->error)) + return($this->SetError("4 could not get the request reply body: ".$this->error)); + } + $this->read_length+=strlen($body); + return(""); + } + + Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0) + { + $now=gmdate("Y-m-d H-i-s"); + $cookies=array(); + for($secure_cookies=0,Reset($this->cookies);$secure_cookiescookies);Next($this->cookies),$secure_cookies++) + { + $secure=Key($this->cookies); + if(!$secure_only + || $secure) + { + for($cookie_domain=0,Reset($this->cookies[$secure]);$cookie_domaincookies[$secure]);Next($this->cookies[$secure]),$cookie_domain++) + { + $domain_pattern=Key($this->cookies[$secure]); + $match=strlen($domain)-strlen($domain_pattern); + if(strlen($domain)==0 + || ($match>=0 + && !strcmp($domain_pattern,substr($domain,$match)) + && ($match==0 + || $domain_pattern[0]=="." + || $domain[$match-1]=="."))) + { + for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_partcookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++) + { + $path=Key($this->cookies[$secure][$domain_pattern]); + for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookiecookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++) + { + $cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]); + $expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"]; + if((!$persistent_only + && strlen($expires)==0) + || (strlen($expires) + && strcmp($now,$expires)<0)) + $cookies[$secure][$domain_pattern][$path][$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]; + } + } + } + } + } + } + } + + Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0) + { + $this->SaveCookies($cookies, $domain, $secure_only, 1); + } + + Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0) + { + $this->SavePersistentCookies($cookies, $domain, $secure_only); + } + + Function RestoreCookies($cookies, $clear=1) + { + $new_cookies=($clear ? array() : $this->cookies); + for($secure_cookies=0, Reset($cookies); $secure_cookiesSetError("invalid cookie secure value type (".serialize($secure).")")); + for($cookie_domain=0,Reset($cookies[$secure]);$cookie_domainSetError("invalid cookie domain value type (".serialize($domain_pattern).")")); + for(Reset($cookies[$secure][$domain_pattern]),$path_part=0;$path_partSetError("invalid cookie path value type (".serialize($path).")")); + for(Reset($cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookieSetError("invalid cookie expiry value type (".serialize($expires).")")); + $new_cookies[$secure][$domain_pattern][$path][$cookie_name]=array( + "name"=>$cookie_name, + "value"=>$value, + "domain"=>$domain_pattern, + "path"=>$path, + "expires"=>$expires, + "secure"=>$secure + ); + } + } + } + } + $this->cookies=$new_cookies; + return(""); + } +}; + +?> \ No newline at end of file diff --git a/includes/index.php b/includes/index.php new file mode 100644 index 0000000..e6b9bab --- /dev/null +++ b/includes/index.php @@ -0,0 +1,5 @@ + diff --git a/includes/phpsvnclient.php b/includes/phpsvnclient.php new file mode 100644 index 0000000..811c86d --- /dev/null +++ b/includes/phpsvnclient.php @@ -0,0 +1,420 @@ + + * @license BSD License + */ +class phpSVNclient +{ + /** + * SVN Repository URL + * + * @var string + * @access private + */ + var $_url; + /** + * Cache, for don't request the same thing in a + * short period of time. + * + * @var string + * @access private + */ + var $_cache; + /** + * HTTP Client object + * + * @var object + * @access private + */ + var $_http; + /** + * Respository Version. + * + * @access private + * @var interger + */ + var $_repVersion; + /** + * Password + * + * @access private + * @var string + */ + var $pass; + /** + * Password + * + * @access private + * @var string + */ + var $user; + /** + * Last error number + * + * Possible values are NOT_ERROR, NOT_FOUND, AUTH_REQUIRED, UNKOWN_ERROR + * + * @access public + * @var integer + */ + var $errNro; + + function phpSVNclient() + { + $http = & $this->_http; + $http = new http_class; + $http->user_agent = "phpSVNclient (http://cesars.users.phpclasses.org/svnclient)"; + } + + /** + * Set URL + * + * Set the project repository URL. + * + * @param string $url URL of the project. + * @access public + */ + function setRespository($url) + { + $this->_url = $url; + } + + /** + * Add Authentication settings + * + * @param string $user Username + * @param string $pass Password + */ + function setAuth($user,$pass) { + $this->user = $user; + $this->pass = $pass; + } + + /** + * Get Files + * + * This method returns all the files in $folder + * in the version $version of the repository. + * + * @param string $folder Folder to get files + * @param integer $version Repository version, -1 means actual + * @return array List of files. + */ + function getDirectoryFiles($folder='/',$version=-1) { + $actVersion = $this->getVersion(); + if ( $version == -1 || $version > $actVersion) { + $version = $actVersion; + } + $url = $this->cleanURL($this->_url."/!svn/bc/".$version."/".$folder."/"); + $this->initQuery($args,"PROPFIND",$url); + $args['Body'] = PHPSVN_NORMAL_REQUEST; + $args['Headers']['Content-Length'] = strlen(PHPSVN_NORMAL_REQUEST); + + if ( ! $this->Request($args, $headers, $body) ) { + return false; + } + $parser=new xml_parser_class; + $parser->Parse( $body,true); + + + $fileinfo = array( + + SVN_LAST_MODIFIED => "last-mod", + SVN_RELATIVE_URL => "path", + SVN_STATUS => "status" + ); + + $start = false; + $last = ""; + $tmp = array(); + $files = array(); + $tmp1 = 0; + + + foreach($parser->structure as $key=>$value) { + if ( is_array($value) and $value["Tag"] == SVN_FILE) { + if ( count($tmp) > 0 && $tmp1++ > 0) { + $files[] = $tmp; + } + $start=true; + $last = ""; + $tmp = array(); + continue; + } + if (!$start) continue; + if ( $last != "") { + $tmp[ $fileinfo[$last] ] = $value; + $last = ""; + continue; + } + if ( is_array($value) && isset($value["Tag"]) && isset( $fileinfo[$value["Tag"]] ) ) { + $last = $value["Tag"]; + } + } + + return $files; + } + + /** + * Returns file contents + * + * @param string $file File pathname + * @param integer $version File Version + * @return Array File content and information + */ + function getFile($file,$version=-1) { + $actVersion = $this->getVersion(); + if ( $version == -1 || $version > $actVersion) { + $version = $actVersion; + } + $url = $this->cleanURL($this->_url."/!svn/bc/".$version."/".$file."/"); + $this->initQuery($args,"GET",$url); + if ( ! $this->Request($args, $headers, $body) ) + return false; + return $body; + } + + /** + * Get changes logs of a file. + * + * Get repository change logs between version + * $vini and $vend. + * + * @param integer $vini Initial Version + * @param integer $vend End Version + * @return Array Respository Logs + */ + function getRepositoryLogs($vini=0,$vend=-1) { + return $this->getFileLogs("/",$vini,$vend); + } + + /** + * Get changes logs of a file. + * + * Get repository change of a file between version + * $vini and $vend. + * + * @param + * @param integer $vini Initial Version + * @param integer $vend End Version + * @return Array Respository Logs + */ + function getFileLogs($file, $vini=0,$vend=-1) { + $actVersion = $this->getVersion(); + if ( $vend == -1 || $vend > $actVersion) + $vend = $actVersion; + else + $vend++; + + if ( $vini < 0) $vini=0; + if ( $vini > $vend) $vini = $vend; + + $url = $this->cleanURL($this->_url."/!svn/bc/".$actVersion."/".$file."/"); + $this->initQuery($args,"REPORT",$url); + $args['Body'] = sprintf(PHPSVN_LOGS_REQUEST,$vini,$vend); + $args['Headers']['Content-Length'] = strlen($args['Body']); + $args['Headers']['Depth']=1; + + if ( ! $this->Request($args, $headers, $body) ) + return false; + + + $parser=new xml_parser_class; + $parser->Parse( $body,true); + + + $fileinfo = array( + SVN_LOGS_VERSION=>"version", + SVN_LOGS_AUTHOR => "author", + SVN_LOGS_DATE => "date", + SVN_LOGS_COMMENT => "comment" + + ); + + $start = false; + $last = ""; + $tmp = array(); + $files = array(); + $tmp1 = 0; + + + foreach($parser->structure as $key=>$value) { + if ( is_array($value) and $value["Tag"] == SVN_LOGS_BEGINGS) { + if ( count($tmp) > 0 && $tmp1++ > 0) { + $logs[] = $tmp; + } + $start=true; + $last = ""; + $tmp = array(); + continue; + } + if (!$start) continue; + if ( $last != "") { + $tmp[ $fileinfo[$last] ] = $value; + $last = ""; + continue; + } + if ( is_array($value) && isset($value["Tag"]) && isset( $fileinfo[$value["Tag"]] ) ) { + $last = $value["Tag"]; + } + } + + return $logs; + } + + /** + * Get the repository version + * + * @return integer Repository version + * @access public + */ + function getVersion() { + if ( $this->_repVersion < 0) return $this->_repVersion; + + $this->_repVersion = -1; + + $this->initQuery($args,"PROPFIND",$this->cleanURL($this->_url."/!svn/vcc/default") ); + $args['Body'] = PHPSVN_VERSION_REQUEST; + $args['Headers']['Content-Length'] = strlen(PHPSVN_NORMAL_REQUEST); + $args['Headers']['Depth']=0; + + if ( !$this->Request($args, $tmp, $body) ) { + return $this->_repVersion; + } + + $parser=new xml_parser_class; + $parser->Parse( $body,true); + $enable=false; + foreach($parser->structure as $value) { + if ( $enable ) { + $t = explode("/",$value); + if ( is_numeric($t[ count($t) -1 ]) ) { + $this->_repVersion = $t[ count($t) -1 ]; + break; + } + } + if ( is_array($value) && $value['Tag'] == 'D:href') $enable = true; + } + + return $this->_repVersion; + } + + /** + * Prepare HTTP CLIENT object + * + * @param array &$arguments Byreferences variable. + * @param string $method Method for the request (GET,POST,PROPFIND, REPORT,ETC). + * @param string $url URL for the action. + * @access private + */ + function initQuery(&$arguments,$method, $url) { + $http = & $this->_http; + $http->GetRequestArguments($url,$arguments); + if ( isset($this->user) && isset($this->pass)) { + $arguments["Headers"]["Authorization"] = " Basic ".base64_encode($this->user.":".$this->pass); + } + $arguments["RequestMethod"]=$method; + $arguments["Headers"]["Content-Type"] = "text/xml"; + $arguments["Headers"]["Depth"] = 1; + } + + /** + * Open a connection, send request, read header + * and body. + * + * @param Array $args Connetion's argument + * @param Array &$headers Array with the header response. + * @param string &$body Body response. + * @return boolean True is query success + * @access private + */ + function Request($args, &$headers, &$body) { + $http = & $this->_http; + $http->Open($args); + $http->SendRequest($args); + $http->ReadReplyHeaders($headers); + if ($http->response_status[0] != 2) { + switch( $http->response_status ) { + case 404: + $this->errNro=NOT_FOUND; + break; + case 401: + $this->errNro=AUTH_REQUIRED; + break; + default: + $this->errNro=UNKNOWN_ERROR; + + } + $http->close(); + return false; + } + $this->errNro = NO_ERROR; + $body=''; + $tbody=''; + for(;;) + { + $error=$http->ReadReplyBody($tbody,1000); + if($error!="" || strlen($tbody)==0) break; + $body.=($tbody); + } + $http->close(); + return true; + } + + /** + * Clean URL + * + * Delete "//" on URL requests. + * + * @param string $url URL + * @return string New cleaned URL. + * @access private + */ + function cleanURL($url) { + $t = parse_url($url); + if ( isset($t['path']) ) + $t['path'] = str_replace("//","/",$t['path']); + return $t['scheme']."://".$t['host'].(isset($t['path']) ? $t['path'] : "/"); + } +} +?> diff --git a/includes/recaptchalib.php b/includes/recaptchalib.php new file mode 100644 index 0000000..897c509 --- /dev/null +++ b/includes/recaptchalib.php @@ -0,0 +1,277 @@ + $value ) + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; +} + + + +/** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ +function _recaptcha_http_post($host, $path, $data, $port = 80) { + + $req = _recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; +} + + + +/** + * Gets the challenge HTML (javascript and non-javascript version). + * This is called from the browser, and the resulting reCAPTCHA HTML widget + * is embedded within the HTML form it was called from. + * @param string $pubkey A public key for reCAPTCHA + * @param string $error The error given by reCAPTCHA (optional, default is null) + * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) + + * @return string - The HTML to be embedded in the user's form. + */ +function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) +{ + if ($pubkey == null || $pubkey == '') { + die ("To use reCAPTCHA you must get an API key from http://recaptcha.net/api/getkey"); + } + + if ($use_ssl) { + $server = RECAPTCHA_API_SECURE_SERVER; + } else { + $server = RECAPTCHA_API_SERVER; + } + + $errorpart = ""; + if ($error) { + $errorpart = "&error=" . $error; + } + return ' + + '; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from http://recaptcha.net/api/getkey"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $domain The domain where the page is hosted + * @param string $appname The name of your application + */ +function recaptcha_get_signup_url ($domain = null, $appname = null) { + return "http://recaptcha.net/api/getkey?" . _recaptcha_qsencode (array ('domain' => $domain, 'app' => $appname)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at http://mailhide.recaptcha.net/apikey"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://mailhide.recaptcha.net/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://mailhide.recaptcha.net/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "...@" . htmlentities ($emailparts [1]); + +} + + +?> diff --git a/includes/session.php b/includes/session.php new file mode 100644 index 0000000..ff47e12 --- /dev/null +++ b/includes/session.php @@ -0,0 +1,61 @@ + diff --git a/includes/specialdates.php b/includes/specialdates.php new file mode 100755 index 0000000..91a356e --- /dev/null +++ b/includes/specialdates.php @@ -0,0 +1,314 @@ +$dotw) + { + $ys+=(((7-sd_date('N',$ys))+$dotw)*60*60*24); + } else { + $ys+=(($dotw-sd_date('N',$ys))*60*60*24); + } + $ys+=(($wn-1)*60*60*24*7); + $did = sd_getMonthStart(sd_date('m',$ys)-1); + $did += (sd_date('j',$ys)-1); + sd_addDateIn($id,$did); +} + +function sd_getMonthStart($month) +{ + if ($month==0) + { + return 0; + } else { + $c = sd_daysInMonth($month-1)+sd_getMonthStart($month-1); + if (date('F jS Y',sd_clearDate()+($c*60*60*24)) == 'March 31st 2008' || $month == 2) + { +// echo($month . ':' . sd_daysInMonth($month-1) . ':' . sd_getMonthStart($month-1) . "\n"); + } + return ($c); + } +} + +function sd_daysInMonth($month) +{ + switch ($month) + { + case 0: return 31; + case 1: return (28+sd_isLeapYear()); + case 2: return 31; + case 3: return 30; + case 4: return 31; + case 5: return 30; + case 6: return 31; + case 7: return 31; + case 8: return 30; + case 9: return 31; + case 10: return 30; + case 11: return 31; + default: throw new Exception('Invalid month ID'); + } +} + +function sd_isLeapYear() +{ + return sd_date('L'); +} + +function sd_isSpecialDay($id) +{ + global $specialdates; + $did = sd_getMonthStart(sd_date('n')-1); + $did += (sd_date('j')-1); + if ($specialdates[$did] == $id) + { + return 1; + } else { + return 0; + } +} + +function sd_ifNoSpecialDay() +{ + global $specialdates; + $did = sd_getMonthStart(sd_date('n')-1); + $did += (sd_date('j')-1); + if ($specialdates[$did] == '') + { + return 1; + } else { + return 0; + } +} + +function sd_kirbyWeek() +{ + $did = sd_getMonthStart(11); + $ys = sd_clearDate(); + $ys+=(60*60*24*24); + $ys+=(60*60*24*$did); + $tWD=sd_date('N',$ys); + if ($tWD==7) {$tWD=0;} + $ys-=($tWD*60*60*24); + $ys-=(60*60*24*7); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+1); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+2); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+3); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+4); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+5); + sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+6); +} + +function sd_easter() +{ + $nYear = sd_date('Y'); + $nCent = $nYear/100; + $nRemain19 = $nYear%19; + $n1 = ($nCent-15)/2+202-11*$nRemain19; + if ($nCent>20) + { + if ($nCent>26) {$n1--;} + if ($nCent>38) {$n1--;} + if ($nCent==21 || $nCent==24 || $nCent==25 || $nCent==33 || $nCent==36 || $nCent==37) {$n1--;} + } + $n1%=30; + if ($n1==29 || ($n1 && $nRemain19>10)) {$n1--;} + $ys = sd_clearDate(); + if ($n1>10) + { + $ys+=(60*60*24*sd_getMonthStart(3)); + $ys+=(60*60*24*($n1-10-1)); + } else { + $ys+=(60*60*24*sd_getMonthStart(2)); + $ys+=(60*60*24*($n1+21-1)); + } + $nWD = sd_date('N',$ys); + if ($nWD==7) {$nWD=0;} + $ys+=(60*60*24*(7-$nWD)); + sd_solar_annual('Easter',sd_date('m',$ys),sd_date('j',$ys)); + $ys-=(60*60*24*46); + sd_solar_annual('Mardi Gras',sd_date('m',$ys),sd_date('j',$ys)); + $ys+=(60*60*24); + sd_solar_annual('Ash Wednesday',sd_date('m',$ys),sd_date('j',$ys)); + $ys+=(60*60*24*38); + sd_solar_annual('Palm Sunday',sd_date('m',$ys),sd_date('j',$ys)); + $ys+=(60*60*24*5); + sd_solar_annual('Good Friday',sd_date('m',$ys),sd_date('j',$ys)); +} + +function sd_findDay($id) +{ + global $specialdates; + $i=0; + for ($i=0;$i<(365+sd_isLeapYear());$i++) + { + if ($specialdates[$i] == $id) + { + return $i; + } + } + throw new Exception('Specified holiday does not exist'); +} + +function sd_findNextDay() +{ + global $specialdates; + $did = sd_getMonthStart(sd_date('n')-1); + $did += (sd_date('j')-1); + $i=0; + for ($i=$did;$i<(365+sd_isLeapYear());$i++) + { + if ($specialdates[$i] != '') + { + return $i; + } + } + throw new Exception('No more holidays this year'); +} + +function sd_getCurrentDay() +{ + global $specialdates; + $did = sd_getMonthStart(sd_date('n')-1); + $did += (sd_date('j')-1); + return $specialdates[$did]; +} + +function sd_solar_multiannual($id,$month,$date,$years,$sy) +{ + global $specialdates; + $cy = sd_date('Y'); + $cy -= $sy; + if ($cy==0 || $cy%$years==0) + { + $did = sd_getMonthStart($month-1); + $did += ($date-1); + $specialdates[$did] = $id; + } +} + +function sd_solar_once($id,$month,$date,$year) +{ + if ($year == sd_date('Y')) + { + sd_solar_annual($id,$month,$date); + } +} + +function sd_getDay($id) +{ + global $specialdates; + return $specialdates[$id]; +} + +function sd_lunar_monthly($id,$dotw,$wn) +{ + $i=1; + for ($i=1;$i<13;$i++) { + sd_lunar_annual($id,$i,$dotw,$wn); + } +} + +function sd_date($format,$timestamp = 0) +{ + if ($timestamp == 0) {$timestamp = time();} + return date($format,$timestamp); +} + +function sd_clearDate() +{ + $ys = strtotime('January 1 ' . date('Y')); + return $ys; +} + +function sd_addDateIn($id,$dateid) +{ + global $specialdates; + $specialdates[$dateid] = $id; +} + +?> diff --git a/includes/template.php b/includes/template.php new file mode 100644 index 0000000..d777475 --- /dev/null +++ b/includes/template.php @@ -0,0 +1,164 @@ +file = $tfn; + } else { + throw new Exception($tfn . ' does not exist'); + } + } + + function add($name, $value) + { + $this->tags[$name] = $value; + } + + function adds($tagarr) + { + foreach ($tagarr as $name => $value) + { + $this->add($name,$value); + } + } + + function adds_block($block, $tagarr) + { + if (!isset($this->blocks[$block])) + { + $this->blocks[$block] = array('count' => 1); + } + foreach ($tagarr as $name => $value) + { + $this->blocks[$block][$this->blocks[$block]['count']][$name] = $value; + } + $this->blocks[$block]['count']++; + } + + function add_ref($id, $block, $tagarr) + { + $this->adds_block($block,$tagarr); + $this->refs[$id] = &$this->blocks[$block][$this->blocks[$block]['count']-1];//'$this->blocks[\'' . $block . '\'][' . ($this->blocks[$block]['count']-1) . ']'; + } + + function adds_ref($id, $tagarr) + { + foreach ($tagarr as $name => $value) + { + $this->refs[$id][$name] = $value; + } + } + function adds_ref_sub($id, $block, $tagarr) + { + if (!isset($this->refs[$id][$block])) + { + $this->refs[$id][$block] = array('count' => 1); + } + foreach ($tagarr as $name => $value) + { + $this->refs[$id][$block][$this->refs[$id][$block]['count']][$name] = $value; + } + $this->refs[$id][$block]['count']++; + } + + function display() + { + $template = file_get_contents($this->file); + while (preg_match('//',$template) == 1) + { + preg_match('//',$template,$mat); + $fname = $mat[1]; + $itmp = new FITemplate($fname); + $template = str_replace('',file_get_contents($itmp->file),$template); + } + if (isset($this->tags)) + { + foreach ($this->tags as $name => $value) + { + $template = str_replace('',$value,$template); + } + } + if (isset($this->blocks)) + { + foreach ($this->blocks as $bname => $block) + { + $this->parseBlock($template, $bname, $block); + } + } + while (preg_match('//',$template) == 1) + { + preg_match('//',$template,$mat); + $bname = $mat[1]; + $start = strpos($template,''); + $end = strpos($template,''); + $template = str_replace(substr($template,$start,$end-$start+strlen($bname)+11),'',$template); + } + $template = preg_replace('//','',$template); + + echo($template); + } + + function parseBlock(&$template, $bname, $block) + { + while (strpos($template,'') !== FALSE) + { + $start = strpos($template,''); + $end = strpos($template,''); + $gencont = substr($template,$start+strlen($bname)+13,$end-$start-strlen($bname)-13); + $blockcont = ''; + foreach ($block as $lname => $blocktags) + { + if ($lname != 'count') + { + $scrcont = $gencont; + foreach ($blocktags as $name => $value) + { + if (!is_array($value)) + { + $scrcont = str_replace('',$value,$scrcont); + } else { + $this->parseBlock($scrcont, $bname . '.' . $name, $value); + } + } + $blockcont .= $scrcont; + } + } + $template = str_replace(substr($template,$start,$end-$start+strlen($bname)+11),$blockcont,$template); + } + } + +} + +?> diff --git a/includes/updatePending.php b/includes/updatePending.php new file mode 100644 index 0000000..a96a2b6 --- /dev/null +++ b/includes/updatePending.php @@ -0,0 +1,51 @@ + strtotime('12:30'))) + { + $cntpending = "SELECT COUNT(*) FROM pending"; + $cntpending2 = mysql_query($cntpending); + $cntpending3 = mysql_fetch_array($cntpending2); + if ($cntpending3[0] != 0) + { + $getpost = "SELECT * FROM pending ORDER BY id ASC LIMIT 0,1"; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + postBlogPost($getpost3['title'], $getpost3['author'], $getpost3['tag1'], $getpost3['tag2'], $getpost3['tag3'], $getpost3['text']); + + $delpost = "DELETE FROM pending WHERE id = " . $getpost3['id']; + $delpost2 = mysql_query($delpost); + } + } +} + +?> diff --git a/includes/xml_parser.php b/includes/xml_parser.php new file mode 100644 index 0000000..15e02e0 --- /dev/null +++ b/includes/xml_parser.php @@ -0,0 +1,427 @@ +error,"")) + $xml_parser_handlers[$parser]->StartElement($xml_parser_handlers[$parser],$name,$attrs); +} + +Function xml_parser_end_element_handler($parser,$name) +{ + global $xml_parser_handlers; + + if(!strcmp($xml_parser_handlers[$parser]->error,"")) + $xml_parser_handlers[$parser]->EndElement($xml_parser_handlers[$parser],$name); +} + +Function xml_parser_character_data_handler($parser,$data) +{ + global $xml_parser_handlers; + + if(!strcmp($xml_parser_handlers[$parser]->error,"")) + $xml_parser_handlers[$parser]->CharacterData($xml_parser_handlers[$parser],$data); +} + +class xml_parser_handler_class +{ + var $xml_parser; + var $error_number=0; + var $error=""; + var $error_code=0; + var $error_line,$error_column,$error_byte_index; + var $structure=array(); + var $positions=array(); + var $path=""; + var $store_positions=0; + var $simplified_xml=0; + var $fail_on_non_simplified_xml=0; + + Function SetError(&$object,$error_number,$error) + { + $object->error_number=$error_number; + $object->error=$error; + $object->error_line=xml_get_current_line_number($object->xml_parser); + $object->error_column=xml_get_current_column_number($object->xml_parser); + $object->error_byte_index=xml_get_current_byte_index($object->xml_parser); + } + + Function SetElementData(&$object,$path,&$data) + { + $object->structure[$path]=$data; + if($object->store_positions) + { + $object->positions[$path]=array( + "Line"=>xml_get_current_line_number($object->xml_parser), + "Column"=>xml_get_current_column_number($object->xml_parser), + "Byte"=>xml_get_current_byte_index($object->xml_parser) + ); + } + } + + Function StartElement(&$object,$name,&$attrs) + { + if(strcmp($this->path,"")) + { + $element=$object->structure[$this->path]["Elements"]; + $object->structure[$this->path]["Elements"]++; + $this->path.=",$element"; + } + else + { + $element=0; + $this->path="0"; + } + $data=array( + "Tag"=>$name, + "Elements"=>0 + ); + if($object->simplified_xml) + { + if($object->fail_on_non_simplified_xml + && count($attrs)>0) + { + $this->SetError($object,2,"Simplified XML can not have attributes in tags"); + return; + } + } + else + $data["Attributes"]=$attrs; + $this->SetElementData($object,$this->path,$data); + } + + Function EndElement(&$object,$name) + { + $this->path=(($position=strrpos($this->path,",")) ? substr($this->path,0,$position) : ""); + } + + Function CharacterData(&$object,$data) + { + $element=$object->structure[$this->path]["Elements"]; + $previous=$this->path.",".strval($element-1); + if($element>0 + && GetType($object->structure[$previous])=="string") + $object->structure[$previous].=$data; + else + { + $this->SetElementData($object,$this->path.",$element",$data); + $object->structure[$this->path]["Elements"]++; + } + } +}; + +class xml_parser_class +{ + var $xml_parser=0; + var $parser_handler; + var $error=""; + var $error_number=0; + var $error_line=0; + var $error_column=0; + var $error_byte_index=0; + var $error_code=0; + var $stream_buffer_size=4096; + var $structure=array(); + var $positions=array(); + var $store_positions=0; + var $case_folding=0; + var $target_encoding="ISO-8859-1"; + var $simplified_xml=0; + var $fail_on_non_simplified_xml=0; + + Function xml_parser_start_element_handler($parser,$name,$attrs) + { + if(!strcmp($this->error,"")) + $this->parser_handler->StartElement($this,$name,$attrs); + } + + Function xml_parser_end_element_handler($parser,$name) + { + if(!strcmp($this->error,"")) + $this->parser_handler->EndElement($this,$name); + } + + Function xml_parser_character_data_handler($parser,$data) + { + if(!strcmp($this->error,"")) + $this->parser_handler->CharacterData($this,$data); + } + + Function SetErrorPosition($error_number,$error,$line,$column,$byte_index) + { + $this->error_number=$error_number; + $this->error=$error; + $this->error_line=$line; + $this->error_column=$column; + $this->error_byte_index=$byte_index; + } + + Function SetError($error_number,$error) + { + $this->error_number=$error_number; + $this->error=$error; + if($this->xml_parser) + { + $line=xml_get_current_line_number($this->xml_parser); + $column=xml_get_current_column_number($this->xml_parser); + $byte_index=xml_get_current_byte_index($this->xml_parser); + } + else + { + $line=$column=1; + $byte_index=0; + } + $this->SetErrorPosition($error_number,$error,$line,$column,$byte_index); + } + + Function Parse($data,$end_of_data) + { + global $xml_parser_handlers; + + if(strcmp($this->error,"")) + return($this->error); + if(!$this->xml_parser) + { + if(!function_exists("xml_parser_create")) + { + $this->SetError(1,"XML support is not available in this PHP configuration"); + return($this->error); + } + if(!($this->xml_parser=xml_parser_create())) + { + $this->SetError(1,"Could not create the XML parser"); + return($this->error); + } + xml_parser_set_option($this->xml_parser,XML_OPTION_CASE_FOLDING,$this->case_folding); + xml_parser_set_option($this->xml_parser,XML_OPTION_TARGET_ENCODING,$this->target_encoding); + if(function_exists("xml_set_object")) + { + xml_set_object($this->xml_parser,$this); + $this->parser_handler=new xml_parser_handler_class; + $this->structure=array(); + $this->positions=array(); + } + else + { + $xml_parser_handlers[$this->xml_parser]=new xml_parser_handler_class; + $xml_parser_handlers[$this->xml_parser]->xml_parser=$this->xml_parser; + $xml_parser_handlers[$this->xml_parser]->store_positions=$this->store_positions; + $xml_parser_handlers[$this->xml_parser]->simplified_xml=$this->simplified_xml; + $xml_parser_handlers[$this->xml_parser]->fail_on_non_simplified_xml=$this->fail_on_non_simplified_xml; + } + xml_set_element_handler($this->xml_parser,"xml_parser_start_element_handler","xml_parser_end_element_handler"); + xml_set_character_data_handler($this->xml_parser,"xml_parser_character_data_handler"); + } + $parser_ok=xml_parse($this->xml_parser,$data,$end_of_data); + if(!function_exists("xml_set_object")) + $this->error=$xml_parser_handlers[$this->xml_parser]->error; + if(!strcmp($this->error,"")) + { + if($parser_ok) + { + if($end_of_data) + { + if(function_exists("xml_set_object")) + Unset($this->parser_handler); + else + { + $this->structure=$xml_parser_handlers[$this->xml_parser]->structure; + $this->positions=$xml_parser_handlers[$this->xml_parser]->positions; + Unset($xml_parser_handlers[$this->xml_parser]); + } + xml_parser_free($this->xml_parser); + $this->xml_parser=0; + } + } + else + $this->SetError(2,"Could not parse data: ".xml_error_string($this->error_code=xml_get_error_code($this->xml_parser))); + } + else + { + if(!function_exists("xml_set_object")) + { + $this->error_number=$xml_parser_handlers[$this->xml_parser]->error_number; + $this->error_code=$xml_parser_handlers[$this->xml_parser]->error_code; + $this->error_line=$xml_parser_handlers[$this->xml_parser]->error_line; + $this->error_column=$xml_parser_handlers[$this->xml_parser]->error_column; + $this->error_byte_index=$xml_parser_handlers[$this->xml_parser]->error_byte_index; + } + } + return($this->error); + } + + Function VerifyWhiteSpace($path) + { + if($this->store_positions) + { + $line=$parser->positions[$path]["Line"]; + $column=$parser->positions[$path]["Column"]; + $byte_index=$parser->positions[$path]["Byte"]; + } + else + { + $line=$column=1; + $byte_index=0; + } + if(!IsSet($this->structure[$path])) + { + $this->SetErrorPosition(2,"element path does not exist",$line,$column,$byte_index); + return($this->error); + } + if(GetType($this->structure[$path])!="string") + { + $this->SetErrorPosition(2,"element is not data",$line,$column,$byte_index); + return($this->error); + } + $data=$this->structure[$path]; + for($previous_return=0,$position=0;$positionSetErrorPosition(2,"data is not white space",$line,$column,$byte_index); + return($this->error); + } + } + return(""); + } + + Function ParseStream($stream) + { + if(strcmp($this->error,"")) + return($this->error); + do + { + if(!($data=@fread($stream,$this->stream_buffer_size))) + { + if(!feof($stream)) + { + $this->SetError(3,"Could not read from input stream".(IsSet($php_errormsg) ? ': '.$php_errormsg : '')); + break; + } + } + if(strcmp($error=$this->Parse($data,feof($stream)),"")) + break; + } + while(!feof($stream)); + return($this->error); + } + + Function ParseFile($file) + { + if(!file_exists($file)) + return("the XML file to parse ($file) does not exist"); + if(!($definition=@fopen($file,"r"))) + return("could not open the XML file ($file)".(IsSet($php_errormsg) ? ': '.$php_errormsg : '')); + $error=$this->ParseStream($definition); + fclose($definition); + return($error); + } +}; + +Function XMLParseFile(&$parser,$file,$store_positions,$cache="",$case_folding=0,$target_encoding="ISO-8859-1",$simplified_xml=0,$fail_on_non_simplified_xml=0) +{ + if(!file_exists($file)) + return("the XML file to parse ($file) does not exist"); + if(strcmp($cache,"")) + { + if(file_exists($cache) + && filemtime($file)<=filemtime($cache)) + { + if(($cache_file=@fopen($cache,"r"))) + { + if(function_exists("set_file_buffer")) + set_file_buffer($cache_file,0); + if(!($cache_contents=@fread($cache_file,filesize($cache)))) + $error="could not read from the XML cache file $cache".(IsSet($php_errormsg) ? ': '.$php_errormsg : ''); + else + $error=""; + fclose($cache_file); + if(!strcmp($error,"")) + { + if(GetType($parser=unserialize($cache_contents))=="object" + && IsSet($parser->structure)) + { + if(!IsSet($parser->simplified_xml)) + $parser->simplified_xml=0; + if(($simplified_xml + || !$parser->simplified_xml) + && (!$store_positions + || $parser->store_positions)) + { + return(""); + } + } + else + $error="it was not specified a valid cache object in XML file ($cache)"; + } + } + else + $error="could not open cache XML file ($cache)".(IsSet($php_errormsg) ? ': '.$php_errormsg : ''); + if(strcmp($error,"")) + return($error); + } + } + $parser=new xml_parser_class; + $parser->store_positions=$store_positions; + $parser->case_folding=$case_folding; + $parser->target_encoding=$target_encoding; + $parser->simplified_xml=$simplified_xml; + $parser->fail_on_non_simplified_xml=$fail_on_non_simplified_xml; + if(!strcmp($error=$parser->ParseFile($file),"") + && strcmp($cache,"")) + { + if(($cache_file=@fopen($cache,"w"))) + { + if(function_exists("set_file_buffer")) + set_file_buffer($cache_file,0); + if(!@fwrite($cache_file,serialize($parser)) + || !@fclose($cache_file)) + $error="could to write to the XML cache file ($cache)".(IsSet($php_errormsg) ? ': '.$php_errormsg : ''); + if(strcmp($error,"")) + unlink($cache); + } + else + $error="could not open for writing to the cache file ($cache)".(IsSet($php_errormsg) ? ': '.$php_errormsg : ''); + } + return($error); +} + +?> \ No newline at end of file diff --git a/includes/xmlrpc/array_key_exists.php b/includes/xmlrpc/array_key_exists.php new file mode 100644 index 0000000..c5ae519 --- /dev/null +++ b/includes/xmlrpc/array_key_exists.php @@ -0,0 +1,55 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: array_key_exists.php,v 1.1 2005/07/11 16:34:35 ggiunta Exp $ + + +/** + * Replace array_key_exists() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_key_exists + * @author Aidan Lister + * @version $Revision: 1.1 $ + * @since PHP 4.1.0 + * @require PHP 4.0.0 (user_error) + */ +if (!function_exists('array_key_exists')) { + function array_key_exists($key, $search) + { + if (!is_scalar($key)) { + user_error('array_key_exists() The first argument should be either a string or an integer', + E_USER_WARNING); + return false; + } + + if (is_object($search)) { + $search = get_object_vars($search); + } + + if (!is_array($search)) { + user_error('array_key_exists() The second argument should be either an array or an object', + E_USER_WARNING); + return false; + } + + return in_array($key, array_keys($search)); + } +} + +?> \ No newline at end of file diff --git a/includes/xmlrpc/is_a.php b/includes/xmlrpc/is_a.php new file mode 100644 index 0000000..d98db1f --- /dev/null +++ b/includes/xmlrpc/is_a.php @@ -0,0 +1,47 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: is_a.php,v 1.2 2005/11/21 10:57:23 ggiunta Exp $ + + +/** + * Replace function is_a() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.is_a + * @author Aidan Lister + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.0 (user_error) (is_subclass_of) + */ +if (!function_exists('is_a')) { + function is_a($object, $class) + { + if (!is_object($object)) { + return false; + } + + if (get_class($object) == strtolower($class)) { + return true; + } else { + return is_subclass_of($object, $class); + } + } +} + +?> \ No newline at end of file diff --git a/includes/xmlrpc/is_callable.php b/includes/xmlrpc/is_callable.php new file mode 100644 index 0000000..b769c41 --- /dev/null +++ b/includes/xmlrpc/is_callable.php @@ -0,0 +1,53 @@ + + * @version $Id: is_callable.php,v 1.3 2006/08/21 14:03:15 ggiunta Exp $ + * @since PHP 4.0.6 + * @require PHP 4.0.0 (true, false, etc...) + * @todo add the 3rd parameter syntax... + */ +if (!function_exists('is_callable')) { + function is_callable($var, $syntax_only=false) + { + if ($syntax_only) + { + /* from The Manual: + * If the syntax_only argument is TRUE the function only verifies + * that var might be a function or method. It will only reject simple + * variables that are not strings, or an array that does not have a + * valid structure to be used as a callback. The valid ones are + * supposed to have only 2 entries, the first of which is an object + * or a string, and the second a string + */ + return (is_string($var) || (is_array($var) && count($var) == 2 && is_string(end($var)) && (is_string(reset($var)) || is_object(reset($var))))); + } + else + { + if (is_string($var)) + { + return function_exists($var); + } + else if (is_array($var) && count($var) == 2 && is_string($method = end($var))) + { + $obj = reset($var); + if (is_string($obj)) + { + $methods = get_class_methods($obj); + return (bool)(is_array($methods) && in_array(strtolower($method), $methods)); + } + else if (is_object($obj)) + { + return method_exists($obj, $method); + } + } + return false; + } + } +} + +?> \ No newline at end of file diff --git a/includes/xmlrpc/is_scalar.php b/includes/xmlrpc/is_scalar.php new file mode 100644 index 0000000..c8f2bfc --- /dev/null +++ b/includes/xmlrpc/is_scalar.php @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/includes/xmlrpc/var_export.php b/includes/xmlrpc/var_export.php new file mode 100644 index 0000000..3a5ac3f --- /dev/null +++ b/includes/xmlrpc/var_export.php @@ -0,0 +1,105 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: var_export.php,v 1.2 2005/11/21 10:57:23 ggiunta Exp $ + + +/** + * Replace var_export() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.var_export + * @author Aidan Lister + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.0 (user_error) + */ +if (!function_exists('var_export')) { + function var_export($array, $return = false, $lvl=0) + { + // Common output variables + $indent = ' '; + $doublearrow = ' => '; + $lineend = ",\n"; + $stringdelim = '\''; + + // Check the export isn't a simple string / int + if (is_string($array)) { + $out = $stringdelim . str_replace('\'', '\\\'', str_replace('\\', '\\\\', $array)) . $stringdelim; + } elseif (is_int($array) || is_float($array)) { + $out = (string)$array; + } elseif (is_bool($array)) { + $out = $array ? 'true' : 'false'; + } elseif (is_null($array)) { + $out = 'NULL'; + } elseif (is_resource($array)) { + $out = 'resource'; + } else { + // Begin the array export + // Start the string + $out = "array (\n"; + + // Loop through each value in array + foreach ($array as $key => $value) { + // If the key is a string, delimit it + if (is_string($key)) { + $key = str_replace('\'', '\\\'', str_replace('\\', '\\\\', $key)); + $key = $stringdelim . $key . $stringdelim; + } + + $val = var_export($value, true, $lvl+1); + // Delimit value + /*if (is_array($value)) { + // We have an array, so do some recursion + // Do some basic recursion while increasing the indent + $recur_array = explode($newline, var_export($value, true)); + $temp_array = array(); + foreach ($recur_array as $recur_line) { + $temp_array[] = $indent . $recur_line; + } + $recur_array = implode($newline, $temp_array); + $value = $newline . $recur_array; + } elseif (is_null($value)) { + $value = 'NULL'; + } else { + $value = str_replace($find, $replace, $value); + $value = $stringdelim . $value . $stringdelim; + }*/ + + // Piece together the line + for ($i = 0; $i < $lvl; $i++) + $out .= $indent; + $out .= $key . $doublearrow . $val . $lineend; + } + + // End our string + for ($i = 0; $i < $lvl; $i++) + $out .= $indent; + $out .= ")"; + } + + // Decide method of output + if ($return === true) { + return $out; + } else { + echo $out; + return; + } + } +} +?> \ No newline at end of file diff --git a/includes/xmlrpc/version_compare.php b/includes/xmlrpc/version_compare.php new file mode 100644 index 0000000..fc3abac --- /dev/null +++ b/includes/xmlrpc/version_compare.php @@ -0,0 +1,179 @@ + | +// | Aidan Lister | +// +----------------------------------------------------------------------+ +// +// $Id: version_compare.php,v 1.1 2005/07/11 16:34:36 ggiunta Exp $ + + +/** + * Replace version_compare() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.version_compare + * @author Philippe Jausions + * @author Aidan Lister + * @version $Revision: 1.1 $ + * @since PHP 4.1.0 + * @require PHP 4.0.0 (user_error) + */ +if (!function_exists('version_compare')) { + function version_compare($version1, $version2, $operator = '<') + { + // Check input + if (!is_scalar($version1)) { + user_error('version_compare() expects parameter 1 to be string, ' . + gettype($version1) . ' given', E_USER_WARNING); + return; + } + + if (!is_scalar($version2)) { + user_error('version_compare() expects parameter 2 to be string, ' . + gettype($version2) . ' given', E_USER_WARNING); + return; + } + + if (!is_scalar($operator)) { + user_error('version_compare() expects parameter 3 to be string, ' . + gettype($operator) . ' given', E_USER_WARNING); + return; + } + + // Standardise versions + $v1 = explode('.', + str_replace('..', '.', + preg_replace('/([^0-9\.]+)/', '.$1.', + str_replace(array('-', '_', '+'), '.', + trim($version1))))); + + $v2 = explode('.', + str_replace('..', '.', + preg_replace('/([^0-9\.]+)/', '.$1.', + str_replace(array('-', '_', '+'), '.', + trim($version2))))); + + // Replace empty entries at the start of the array + while (empty($v1[0]) && array_shift($v1)) {} + while (empty($v2[0]) && array_shift($v2)) {} + + // Release state order + // '#' stands for any number + $versions = array( + 'dev' => 0, + 'alpha' => 1, + 'a' => 1, + 'beta' => 2, + 'b' => 2, + 'RC' => 3, + '#' => 4, + 'p' => 5, + 'pl' => 5); + + // Loop through each segment in the version string + $compare = 0; + for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++) { + if ($v1[$i] == $v2[$i]) { + continue; + } + $i1 = $v1[$i]; + $i2 = $v2[$i]; + if (is_numeric($i1) && is_numeric($i2)) { + $compare = ($i1 < $i2) ? -1 : 1; + break; + } + // We use the position of '#' in the versions list + // for numbers... (so take care of # in original string) + if ($i1 == '#') { + $i1 = ''; + } elseif (is_numeric($i1)) { + $i1 = '#'; + } + if ($i2 == '#') { + $i2 = ''; + } elseif (is_numeric($i2)) { + $i2 = '#'; + } + if (isset($versions[$i1]) && isset($versions[$i2])) { + $compare = ($versions[$i1] < $versions[$i2]) ? -1 : 1; + } elseif (isset($versions[$i1])) { + $compare = 1; + } elseif (isset($versions[$i2])) { + $compare = -1; + } else { + $compare = 0; + } + + break; + } + + // If previous loop didn't find anything, compare the "extra" segments + if ($compare == 0) { + if (count($v2) > count($v1)) { + if (isset($versions[$v2[$i]])) { + $compare = ($versions[$v2[$i]] < 4) ? 1 : -1; + } else { + $compare = -1; + } + } elseif (count($v2) < count($v1)) { + if (isset($versions[$v1[$i]])) { + $compare = ($versions[$v1[$i]] < 4) ? -1 : 1; + } else { + $compare = 1; + } + } + } + + // Compare the versions + if (func_num_args() > 2) { + switch ($operator) { + case '>': + case 'gt': + return (bool) ($compare > 0); + break; + case '>=': + case 'ge': + return (bool) ($compare >= 0); + break; + case '<=': + case 'le': + return (bool) ($compare <= 0); + break; + case '==': + case '=': + case 'eq': + return (bool) ($compare == 0); + break; + case '<>': + case '!=': + case 'ne': + return (bool) ($compare != 0); + break; + case '': + case '<': + case 'lt': + return (bool) ($compare < 0); + break; + default: + return; + } + } + + return $compare; + } +} + +?> \ No newline at end of file diff --git a/includes/xmlrpc/xmlrpc.inc b/includes/xmlrpc/xmlrpc.inc new file mode 100644 index 0000000..06c6e44 --- /dev/null +++ b/includes/xmlrpc/xmlrpc.inc @@ -0,0 +1,3705 @@ + +// $Id: xmlrpc.inc,v 1.169 2008/03/06 18:47:24 ggiunta Exp $ + +// Copyright (c) 1999,2000,2002 Edd Dumbill. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// * Neither the name of the "XML-RPC for PHP" nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. + + if(!function_exists('xml_parser_create')) + { + // For PHP 4 onward, XML functionality is always compiled-in on windows: + // no more need to dl-open it. It might have been compiled out on *nix... + if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) + { + dl('xml.so'); + } + } + + // Try to be backward compat with php < 4.2 (are we not being nice ?) + $phpversion = phpversion(); + if($phpversion[0] == '4' && $phpversion[2] < 2) + { + // give an opportunity to user to specify where to include other files from + if(!defined('PHP_XMLRPC_COMPAT_DIR')) + { + define('PHP_XMLRPC_COMPAT_DIR',dirname(__FILE__).'/compat/'); + } + if($phpversion[2] == '0') + { + if($phpversion[4] < 6) + { + include(PHP_XMLRPC_COMPAT_DIR.'is_callable.php'); + } + include(PHP_XMLRPC_COMPAT_DIR.'is_scalar.php'); + include(PHP_XMLRPC_COMPAT_DIR.'array_key_exists.php'); + include(PHP_XMLRPC_COMPAT_DIR.'version_compare.php'); + } + include(PHP_XMLRPC_COMPAT_DIR.'var_export.php'); + include(PHP_XMLRPC_COMPAT_DIR.'is_a.php'); + } + + // G. Giunta 2005/01/29: declare global these variables, + // so that xmlrpc.inc will work even if included from within a function + // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used. + $GLOBALS['xmlrpcI4']='i4'; + $GLOBALS['xmlrpcInt']='int'; + $GLOBALS['xmlrpcBoolean']='boolean'; + $GLOBALS['xmlrpcDouble']='double'; + $GLOBALS['xmlrpcString']='string'; + $GLOBALS['xmlrpcDateTime']='dateTime.iso8601'; + $GLOBALS['xmlrpcBase64']='base64'; + $GLOBALS['xmlrpcArray']='array'; + $GLOBALS['xmlrpcStruct']='struct'; + $GLOBALS['xmlrpcValue']='undefined'; + + $GLOBALS['xmlrpcTypes']=array( + $GLOBALS['xmlrpcI4'] => 1, + $GLOBALS['xmlrpcInt'] => 1, + $GLOBALS['xmlrpcBoolean'] => 1, + $GLOBALS['xmlrpcString'] => 1, + $GLOBALS['xmlrpcDouble'] => 1, + $GLOBALS['xmlrpcDateTime'] => 1, + $GLOBALS['xmlrpcBase64'] => 1, + $GLOBALS['xmlrpcArray'] => 2, + $GLOBALS['xmlrpcStruct'] => 3 + ); + + $GLOBALS['xmlrpc_valid_parents'] = array( + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'), + 'BOOLEAN' => array('VALUE'), + 'I4' => array('VALUE'), + 'INT' => array('VALUE'), + 'STRING' => array('VALUE'), + 'DOUBLE' => array('VALUE'), + 'DATETIME.ISO8601' => array('VALUE'), + 'BASE64' => array('VALUE'), + 'MEMBER' => array('STRUCT'), + 'NAME' => array('MEMBER'), + 'DATA' => array('ARRAY'), + 'ARRAY' => array('VALUE'), + 'STRUCT' => array('VALUE'), + 'PARAM' => array('PARAMS'), + 'METHODNAME' => array('METHODCALL'), + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), + 'FAULT' => array('METHODRESPONSE'), + 'NIL' => array('VALUE') // only used when extension activated + ); + + // define extra types for supporting NULL (useful for json or ) + $GLOBALS['xmlrpcNull']='null'; + $GLOBALS['xmlrpcTypes']['null']=1; + + // Not in use anymore since 2.0. Shall we remove it? + /// @deprecated + $GLOBALS['xmlEntities']=array( + 'amp' => '&', + 'quot' => '"', + 'lt' => '<', + 'gt' => '>', + 'apos' => "'" + ); + + // tables used for transcoding different charsets into us-ascii xml + + $GLOBALS['xml_iso88591_Entities']=array(); + $GLOBALS['xml_iso88591_Entities']['in'] = array(); + $GLOBALS['xml_iso88591_Entities']['out'] = array(); + for ($i = 0; $i < 32; $i++) + { + $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); + $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; + } + for ($i = 160; $i < 256; $i++) + { + $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); + $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; + } + + /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159? + /// These will NOT be present in true ISO-8859-1, but will save the unwary + /// windows user from sending junk (though no luck when reciving them...) + /* + $GLOBALS['xml_cp1252_Entities']=array(); + for ($i = 128; $i < 160; $i++) + { + $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i); + } + $GLOBALS['xml_cp1252_Entities']['out'] = array( + '€', '?', '‚', 'ƒ', + '„', '…', '†', '‡', + 'ˆ', '‰', 'Š', '‹', + 'Œ', '?', 'Ž', '?', + '?', '‘', '’', '“', + '”', '•', '–', '—', + '˜', '™', 'š', '›', + 'œ', '?', 'ž', 'Ÿ' + ); + */ + + $GLOBALS['xmlrpcerr'] = array( + 'unknown_method'=>1, + 'invalid_return'=>2, + 'incorrect_params'=>3, + 'introspect_unknown'=>4, + 'http_error'=>5, + 'no_data'=>6, + 'no_ssl'=>7, + 'curl_fail'=>8, + 'invalid_request'=>15, + 'no_curl'=>16, + 'server_error'=>17, + 'multicall_error'=>18, + 'multicall_notstruct'=>9, + 'multicall_nomethod'=>10, + 'multicall_notstring'=>11, + 'multicall_recursion'=>12, + 'multicall_noparams'=>13, + 'multicall_notarray'=>14, + + 'cannot_decompress'=>103, + 'decompress_fail'=>104, + 'dechunk_fail'=>105, + 'server_cannot_decompress'=>106, + 'server_decompress_fail'=>107 + ); + + $GLOBALS['xmlrpcstr'] = array( + 'unknown_method'=>'Unknown method', + 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload', + 'incorrect_params'=>'Incorrect parameters passed to method', + 'introspect_unknown'=>"Can't introspect: method unknown", + 'http_error'=>"Didn't receive 200 OK from remote server.", + 'no_data'=>'No data received from server.', + 'no_ssl'=>'No SSL support compiled in.', + 'curl_fail'=>'CURL error', + 'invalid_request'=>'Invalid request payload', + 'no_curl'=>'No CURL support compiled in.', + 'server_error'=>'Internal server error', + 'multicall_error'=>'Received from server invalid multicall response', + 'multicall_notstruct'=>'system.multicall expected struct', + 'multicall_nomethod'=>'missing methodName', + 'multicall_notstring'=>'methodName is not a string', + 'multicall_recursion'=>'recursive system.multicall forbidden', + 'multicall_noparams'=>'missing params', + 'multicall_notarray'=>'params is not an array', + + 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress', + 'decompress_fail'=>'Received from server invalid compressed HTTP', + 'dechunk_fail'=>'Received from server invalid chunked HTTP', + 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress', + 'server_decompress_fail'=>'Received from client invalid compressed HTTP request' + ); + + // The charset encoding used by the server for received messages and + // by the client for received responses when received charset cannot be determined + // or is not supported + $GLOBALS['xmlrpc_defencoding']='UTF-8'; + + // The encoding used internally by PHP. + // String values received as xml will be converted to this, and php strings will be converted to xml + // as if having been coded with this + $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1'; + + $GLOBALS['xmlrpcName']='XML-RPC for PHP'; + $GLOBALS['xmlrpcVersion']='2.2.1'; + + // let user errors start at 800 + $GLOBALS['xmlrpcerruser']=800; + // let XML parse errors start at 100 + $GLOBALS['xmlrpcerrxml']=100; + + // formulate backslashes for escaping regexp + // Not in use anymore since 2.0. Shall we remove it? + /// @deprecated + $GLOBALS['xmlrpc_backslash']=chr(92).chr(92); + + // set to TRUE to enable correct decoding of values + $GLOBALS['xmlrpc_null_extension']=false; + + // used to store state during parsing + // quick explanation of components: + // ac - used to accumulate values + // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1) + // isf_reason - used for storing xmlrpcresp fault string + // lv - used to indicate "looking for a value": implements + // the logic to allow values with no types to be strings + // params - used to store parameters in method calls + // method - used to store method name + // stack - array with genealogy of xml elements names: + // used to validate nesting of xmlrpc elements + $GLOBALS['_xh']=null; + + /** + * Convert a string to the correct XML representation in a target charset + * To help correct communication of non-ascii chars inside strings, regardless + * of the charset used when sending requests, parsing them, sending responses + * and parsing responses, an option is to convert all non-ascii chars present in the message + * into their equivalent 'charset entity'. Charset entities enumerated this way + * are independent of the charset encoding used to transmit them, and all XML + * parsers are bound to understand them. + * Note that in the std case we are not sending a charset encoding mime type + * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii. + * + * @todo do a bit of basic benchmarking (strtr vs. str_replace) + * @todo make usage of iconv() or recode_string() or mb_string() where available + */ + function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='') + { + if ($src_encoding == '') + { + // lame, but we know no better... + $src_encoding = $GLOBALS['xmlrpc_internalencoding']; + } + + switch(strtoupper($src_encoding.'_'.$dest_encoding)) + { + case 'ISO-8859-1_': + case 'ISO-8859-1_US-ASCII': + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); + break; + case 'ISO-8859-1_UTF-8': + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escaped_data = utf8_encode($escaped_data); + break; + case 'ISO-8859-1_ISO-8859-1': + case 'US-ASCII_US-ASCII': + case 'US-ASCII_UTF-8': + case 'US-ASCII_': + case 'US-ASCII_ISO-8859-1': + case 'UTF-8_UTF-8': + //case 'CP1252_CP1252': + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + break; + case 'UTF-8_': + case 'UTF-8_US-ASCII': + case 'UTF-8_ISO-8859-1': + // NB: this will choke on invalid UTF-8, going most likely beyond EOF + $escaped_data = ''; + // be kind to users creating string xmlrpcvals out of different php types + $data = (string) $data; + $ns = strlen ($data); + for ($nn = 0; $nn < $ns; $nn++) + { + $ch = $data[$nn]; + $ii = ord($ch); + //1 7 0bbbbbbb (127) + if ($ii < 128) + { + /// @todo shall we replace this with a (supposedly) faster str_replace? + switch($ii){ + case 34: + $escaped_data .= '"'; + break; + case 38: + $escaped_data .= '&'; + break; + case 39: + $escaped_data .= '''; + break; + case 60: + $escaped_data .= '<'; + break; + case 62: + $escaped_data .= '>'; + break; + default: + $escaped_data .= $ch; + } // switch + } + //2 11 110bbbbb 10bbbbbb (2047) + else if ($ii>>5 == 6) + { + $b1 = ($ii & 31); + $ii = ord($data[$nn+1]); + $b2 = ($ii & 63); + $ii = ($b1 * 64) + $b2; + $ent = sprintf ('&#%d;', $ii); + $escaped_data .= $ent; + $nn += 1; + } + //3 16 1110bbbb 10bbbbbb 10bbbbbb + else if ($ii>>4 == 14) + { + $b1 = ($ii & 31); + $ii = ord($data[$nn+1]); + $b2 = ($ii & 63); + $ii = ord($data[$nn+2]); + $b3 = ($ii & 63); + $ii = ((($b1 * 64) + $b2) * 64) + $b3; + $ent = sprintf ('&#%d;', $ii); + $escaped_data .= $ent; + $nn += 2; + } + //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + else if ($ii>>3 == 30) + { + $b1 = ($ii & 31); + $ii = ord($data[$nn+1]); + $b2 = ($ii & 63); + $ii = ord($data[$nn+2]); + $b3 = ($ii & 63); + $ii = ord($data[$nn+3]); + $b4 = ($ii & 63); + $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; + $ent = sprintf ('&#%d;', $ii); + $escaped_data .= $ent; + $nn += 3; + } + } + break; +/* + case 'CP1252_': + case 'CP1252_US-ASCII': + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); + $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); + break; + case 'CP1252_UTF-8': + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them) + $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); + $escaped_data = utf8_encode($escaped_data); + break; + case 'CP1252_ISO-8859-1': + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + // we might as well replave all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities... + $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); + break; +*/ + default: + $escaped_data = ''; + error_log("Converting from $src_encoding to $dest_encoding: not supported..."); + } + return $escaped_data; + } + + /// xml parser handler function for opening element tags + function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false) + { + // if invalid xmlrpc already detected, skip all processing + if ($GLOBALS['_xh']['isf'] < 2) + { + // check for correct element nesting + // top level element can only be of 2 types + /// @todo optimization creep: save this check into a bool variable, instead of using count() every time: + /// there is only a single top level element in xml anyway + if (count($GLOBALS['_xh']['stack']) == 0) + { + if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && ( + $name != 'VALUE' && !$accept_single_vals)) + { + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element'; + return; + } + else + { + $GLOBALS['_xh']['rt'] = strtolower($name); + } + } + else + { + // not top level element: see if parent is OK + $parent = end($GLOBALS['_xh']['stack']); + if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name])) + { + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent"; + return; + } + } + + switch($name) + { + // optimize for speed switch cases: most common cases first + case 'VALUE': + /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element + $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet + $GLOBALS['_xh']['ac']=''; + $GLOBALS['_xh']['lv']=1; + $GLOBALS['_xh']['php_class']=null; + break; + case 'I4': + case 'INT': + case 'STRING': + case 'BOOLEAN': + case 'DOUBLE': + case 'DATETIME.ISO8601': + case 'BASE64': + if ($GLOBALS['_xh']['vt']!='value') + { + //two data elements inside a value: an error occurred! + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; + return; + } + $GLOBALS['_xh']['ac']=''; // reset the accumulator + break; + case 'STRUCT': + case 'ARRAY': + if ($GLOBALS['_xh']['vt']!='value') + { + //two data elements inside a value: an error occurred! + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; + return; + } + // create an empty array to hold child values, and push it onto appropriate stack + $cur_val = array(); + $cur_val['values'] = array(); + $cur_val['type'] = $name; + // check for out-of-band information to rebuild php objs + // and in case it is found, save it + if (@isset($attrs['PHP_CLASS'])) + { + $cur_val['php_class'] = $attrs['PHP_CLASS']; + } + $GLOBALS['_xh']['valuestack'][] = $cur_val; + $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next + break; + case 'DATA': + if ($GLOBALS['_xh']['vt']!='data') + { + //two data elements inside a value: an error occurred! + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element"; + return; + } + case 'METHODCALL': + case 'METHODRESPONSE': + case 'PARAMS': + // valid elements that add little to processing + break; + case 'METHODNAME': + case 'NAME': + /// @todo we could check for 2 NAME elements inside a MEMBER element + $GLOBALS['_xh']['ac']=''; + break; + case 'FAULT': + $GLOBALS['_xh']['isf']=1; + break; + case 'MEMBER': + $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on + //$GLOBALS['_xh']['ac']=''; + // Drop trough intentionally + case 'PARAM': + // clear value type, so we can check later if no value has been passed for this param/member + $GLOBALS['_xh']['vt']=null; + break; + case 'NIL': + if ($GLOBALS['xmlrpc_null_extension']) + { + if ($GLOBALS['_xh']['vt']!='value') + { + //two data elements inside a value: an error occurred! + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; + return; + } + $GLOBALS['_xh']['ac']=''; // reset the accumulator + break; + } + // we do not support the extension, so + // drop through intentionally + default: + /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!! + $GLOBALS['_xh']['isf'] = 2; + $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name"; + break; + } + + // Save current element name to stack, to validate nesting + $GLOBALS['_xh']['stack'][] = $name; + + /// @todo optimization creep: move this inside the big switch() above + if($name!='VALUE') + { + $GLOBALS['_xh']['lv']=0; + } + } + } + + /// Used in decoding xml chunks that might represent single xmlrpc values + function xmlrpc_se_any($parser, $name, $attrs) + { + xmlrpc_se($parser, $name, $attrs, true); + } + + /// xml parser handler function for close element tags + function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true) + { + if ($GLOBALS['_xh']['isf'] < 2) + { + // push this element name from stack + // NB: if XML validates, correct opening/closing is guaranteed and + // we do not have to check for $name == $curr_elem. + // we also checked for proper nesting at start of elements... + $curr_elem = array_pop($GLOBALS['_xh']['stack']); + + switch($name) + { + case 'VALUE': + // This if() detects if no scalar was inside + if ($GLOBALS['_xh']['vt']=='value') + { + $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; + $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString']; + } + + if ($rebuild_xmlrpcvals) + { + // build the xmlrpc val out of the data received, and substitute it + $temp =& new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']); + // in case we got info about underlying php class, save it + // in the object we're rebuilding + if (isset($GLOBALS['_xh']['php_class'])) + $temp->_php_class = $GLOBALS['_xh']['php_class']; + // check if we are inside an array or struct: + // if value just built is inside an array, let's move it into array on the stack + $vscount = count($GLOBALS['_xh']['valuestack']); + if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') + { + $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp; + } + else + { + $GLOBALS['_xh']['value'] = $temp; + } + } + else + { + /// @todo this needs to treat correctly php-serialized objects, + /// since std deserializing is done by php_xmlrpc_decode, + /// which we will not be calling... + if (isset($GLOBALS['_xh']['php_class'])) + { + } + + // check if we are inside an array or struct: + // if value just built is inside an array, let's move it into array on the stack + $vscount = count($GLOBALS['_xh']['valuestack']); + if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') + { + $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value']; + } + } + break; + case 'BOOLEAN': + case 'I4': + case 'INT': + case 'STRING': + case 'DOUBLE': + case 'DATETIME.ISO8601': + case 'BASE64': + $GLOBALS['_xh']['vt']=strtolower($name); + /// @todo: optimization creep - remove the if/elseif cycle below + /// since the case() in which we are already did that + if ($name=='STRING') + { + $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; + } + elseif ($name=='DATETIME.ISO8601') + { + if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac'])) + { + error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']); + } + $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime']; + $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; + } + elseif ($name=='BASE64') + { + /// @todo check for failure of base64 decoding / catch warnings + $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']); + } + elseif ($name=='BOOLEAN') + { + // special case here: we translate boolean 1 or 0 into PHP + // constants true or false. + // Strings 'true' and 'false' are accepted, even though the + // spec never mentions them (see eg. Blogger api docs) + // NB: this simple checks helps a lot sanitizing input, ie no + // security problems around here + if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) + { + $GLOBALS['_xh']['value']=true; + } + else + { + // log if receiveing something strange, even though we set the value to false anyway + if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($_xh[$parser]['ac'], 'false') != 0) + error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']); + $GLOBALS['_xh']['value']=false; + } + } + elseif ($name=='DOUBLE') + { + // we have a DOUBLE + // we must check that only 0123456789-. are characters here + // NOTE: regexp could be much stricter than this... + if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac'])) + { + /// @todo: find a better way of throwing an error than this! + error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']); + $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; + } + else + { + // it's ok, add it on + $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac']; + } + } + else + { + // we have an I4/INT + // we must check that only 0123456789- are characters here + if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac'])) + { + /// @todo find a better way of throwing an error than this! + error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']); + $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; + } + else + { + // it's ok, add it on + $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac']; + } + } + //$GLOBALS['_xh']['ac']=''; // is this necessary? + $GLOBALS['_xh']['lv']=3; // indicate we've found a value + break; + case 'NAME': + $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac']; + break; + case 'MEMBER': + //$GLOBALS['_xh']['ac']=''; // is this necessary? + // add to array in the stack the last element built, + // unless no VALUE was found + if ($GLOBALS['_xh']['vt']) + { + $vscount = count($GLOBALS['_xh']['valuestack']); + $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value']; + } else + error_log('XML-RPC: missing VALUE inside STRUCT in received xml'); + break; + case 'DATA': + //$GLOBALS['_xh']['ac']=''; // is this necessary? + $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty + break; + case 'STRUCT': + case 'ARRAY': + // fetch out of stack array of values, and promote it to current value + $curr_val = array_pop($GLOBALS['_xh']['valuestack']); + $GLOBALS['_xh']['value'] = $curr_val['values']; + $GLOBALS['_xh']['vt']=strtolower($name); + if (isset($curr_val['php_class'])) + { + $GLOBALS['_xh']['php_class'] = $curr_val['php_class']; + } + break; + case 'PARAM': + // add to array of params the current value, + // unless no VALUE was found + if ($GLOBALS['_xh']['vt']) + { + $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value']; + $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt']; + } + else + error_log('XML-RPC: missing VALUE inside PARAM in received xml'); + break; + case 'METHODNAME': + $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']); + break; + case 'NIL': + if ($GLOBALS['xmlrpc_null_extension']) + { + $GLOBALS['_xh']['vt']='null'; + $GLOBALS['_xh']['value']=null; + $GLOBALS['_xh']['lv']=3; + break; + } + // drop through intentionally if nil extension not enabled + case 'PARAMS': + case 'FAULT': + case 'METHODCALL': + case 'METHORESPONSE': + break; + default: + // End of INVALID ELEMENT! + // shall we add an assert here for unreachable code??? + break; + } + } + } + + /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values + function xmlrpc_ee_fast($parser, $name) + { + xmlrpc_ee($parser, $name, false); + } + + /// xml parser handler function for character data + function xmlrpc_cd($parser, $data) + { + // skip processing if xml fault already detected + if ($GLOBALS['_xh']['isf'] < 2) + { + // "lookforvalue==3" means that we've found an entire value + // and should discard any further character data + if($GLOBALS['_xh']['lv']!=3) + { + // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2 + //if($GLOBALS['_xh']['lv']==1) + //{ + // if we've found text and we're just in a then + // say we've found a value + //$GLOBALS['_xh']['lv']=2; + //} + // we always initialize the accumulator before starting parsing, anyway... + //if(!@isset($GLOBALS['_xh']['ac'])) + //{ + // $GLOBALS['_xh']['ac'] = ''; + //} + $GLOBALS['_xh']['ac'].=$data; + } + } + } + + /// xml parser handler function for 'other stuff', ie. not char data or + /// element start/end tag. In fact it only gets called on unknown entities... + function xmlrpc_dh($parser, $data) + { + // skip processing if xml fault already detected + if ($GLOBALS['_xh']['isf'] < 2) + { + if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') + { + // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2 + //if($GLOBALS['_xh']['lv']==1) + //{ + // $GLOBALS['_xh']['lv']=2; + //} + $GLOBALS['_xh']['ac'].=$data; + } + } + return true; + } + + class xmlrpc_client + { + var $path; + var $server; + var $port=0; + var $method='http'; + var $errno; + var $errstr; + var $debug=0; + var $username=''; + var $password=''; + var $authtype=1; + var $cert=''; + var $certpass=''; + var $cacert=''; + var $cacertdir=''; + var $key=''; + var $keypass=''; + var $verifypeer=true; + var $verifyhost=1; + var $no_multicall=false; + var $proxy=''; + var $proxyport=0; + var $proxy_user=''; + var $proxy_pass=''; + var $proxy_authtype=1; + var $cookies=array(); + /** + * List of http compression methods accepted by the client for responses. + * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib + * + * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since + * in those cases it will be up to CURL to decide the compression methods + * it supports. You might check for the presence of 'zlib' in the output of + * curl_version() to determine wheter compression is supported or not + */ + var $accepted_compression = array(); + /** + * Name of compression scheme to be used for sending requests. + * Either null, gzip or deflate + */ + var $request_compression = ''; + /** + * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see: + * http://curl.haxx.se/docs/faq.html#7.3) + */ + var $xmlrpc_curl_handle = null; + /// Wheter to use persistent connections for http 1.1 and https + var $keepalive = false; + /// Charset encodings that can be decoded without problems by the client + var $accepted_charset_encodings = array(); + /// Charset encoding to be used in serializing request. NULL = use ASCII + var $request_charset_encoding = ''; + /** + * Decides the content of xmlrpcresp objects returned by calls to send() + * valid strings are 'xmlrpcvals', 'phpvals' or 'xml' + */ + var $return_type = 'xmlrpcvals'; + + /** + * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php + * @param string $server the server name / ip address + * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used + * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed + */ + function xmlrpc_client($path, $server='', $port='', $method='') + { + // allow user to specify all params in $path + if($server == '' and $port == '' and $method == '') + { + $parts = parse_url($path); + $server = $parts['host']; + $path = isset($parts['path']) ? $parts['path'] : ''; + if(isset($parts['query'])) + { + $path .= '?'.$parts['query']; + } + if(isset($parts['fragment'])) + { + $path .= '#'.$parts['fragment']; + } + if(isset($parts['port'])) + { + $port = $parts['port']; + } + if(isset($parts['scheme'])) + { + $method = $parts['scheme']; + } + if(isset($parts['user'])) + { + $this->username = $parts['user']; + } + if(isset($parts['pass'])) + { + $this->password = $parts['pass']; + } + } + if($path == '' || $path[0] != '/') + { + $this->path='/'.$path; + } + else + { + $this->path=$path; + } + $this->server=$server; + if($port != '') + { + $this->port=$port; + } + if($method != '') + { + $this->method=$method; + } + + // if ZLIB is enabled, let the client by default accept compressed responses + if(function_exists('gzinflate') || ( + function_exists('curl_init') && (($info = curl_version()) && + ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) + )) + { + $this->accepted_compression = array('gzip', 'deflate'); + } + + // keepalives: enabled by default ONLY for PHP >= 4.3.8 + // (see http://curl.haxx.se/docs/faq.html#7.3) + if(version_compare(phpversion(), '4.3.8') >= 0) + { + $this->keepalive = true; + } + + // by default the xml parser can support these 3 charset encodings + $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); + } + + /** + * Enables/disables the echoing to screen of the xmlrpc responses received + * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response) + * @access public + */ + function setDebug($in) + { + $this->debug=$in; + } + + /** + * Add some http BASIC AUTH credentials, used by the client to authenticate + * @param string $u username + * @param string $p password + * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth) + * @access public + */ + function setCredentials($u, $p, $t=1) + { + $this->username=$u; + $this->password=$p; + $this->authtype=$t; + } + + /** + * Add a client-side https certificate + * @param string $cert + * @param string $certpass + * @access public + */ + function setCertificate($cert, $certpass) + { + $this->cert = $cert; + $this->certpass = $certpass; + } + + /** + * Add a CA certificate to verify server with (see man page about + * CURLOPT_CAINFO for more details + * @param string $cacert certificate file name (or dir holding certificates) + * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false + * @access public + */ + function setCaCertificate($cacert, $is_dir=false) + { + if ($is_dir) + { + $this->cacertdir = $cacert; + } + else + { + $this->cacert = $cacert; + } + } + + /** + * Set attributes for SSL communication: private SSL key + * NB: does not work in older php/curl installs + * Thanks to Daniel Convissor + * @param string $key The name of a file containing a private SSL key + * @param string $keypass The secret password needed to use the private SSL key + * @access public + */ + function setKey($key, $keypass) + { + $this->key = $key; + $this->keypass = $keypass; + } + + /** + * Set attributes for SSL communication: verify server certificate + * @param bool $i enable/disable verification of peer certificate + * @access public + */ + function setSSLVerifyPeer($i) + { + $this->verifypeer = $i; + } + + /** + * Set attributes for SSL communication: verify match of server cert w. hostname + * @param int $i + * @access public + */ + function setSSLVerifyHost($i) + { + $this->verifyhost = $i; + } + + /** + * Set proxy info + * @param string $proxyhost + * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS + * @param string $proxyusername Leave blank if proxy has public access + * @param string $proxypassword Leave blank if proxy has public access + * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy + * @access public + */ + function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1) + { + $this->proxy = $proxyhost; + $this->proxyport = $proxyport; + $this->proxy_user = $proxyusername; + $this->proxy_pass = $proxypassword; + $this->proxy_authtype = $proxyauthtype; + } + + /** + * Enables/disables reception of compressed xmlrpc responses. + * Note that enabling reception of compressed responses merely adds some standard + * http headers to xmlrpc requests. It is up to the xmlrpc server to return + * compressed responses when receiving such requests. + * @param string $compmethod either 'gzip', 'deflate', 'any' or '' + * @access public + */ + function setAcceptedCompression($compmethod) + { + if ($compmethod == 'any') + $this->accepted_compression = array('gzip', 'deflate'); + else + $this->accepted_compression = array($compmethod); + } + + /** + * Enables/disables http compression of xmlrpc request. + * Take care when sending compressed requests: servers might not support them + * (and automatic fallback to uncompressed requests is not yet implemented) + * @param string $compmethod either 'gzip', 'deflate' or '' + * @access public + */ + function setRequestCompression($compmethod) + { + $this->request_compression = $compmethod; + } + + /** + * Adds a cookie to list of cookies that will be sent to server. + * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie: + * do not do it unless you know what you are doing + * @param string $name + * @param string $value + * @param string $path + * @param string $domain + * @param int $port + * @access public + * + * @todo check correctness of urlencoding cookie value (copied from php way of doing it...) + */ + function setCookie($name, $value='', $path='', $domain='', $port=null) + { + $this->cookies[$name]['value'] = urlencode($value); + if ($path || $domain || $port) + { + $this->cookies[$name]['path'] = $path; + $this->cookies[$name]['domain'] = $domain; + $this->cookies[$name]['port'] = $port; + $this->cookies[$name]['version'] = 1; + } + else + { + $this->cookies[$name]['version'] = 0; + } + } + + /** + * Send an xmlrpc request + * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request + * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply + * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used + * @return xmlrpcresp + * @access public + */ + function& send($msg, $timeout=0, $method='') + { + // if user deos not specify http protocol, use native method of this client + // (i.e. method set during call to constructor) + if($method == '') + { + $method = $this->method; + } + + if(is_array($msg)) + { + // $msg is an array of xmlrpcmsg's + $r = $this->multicall($msg, $timeout, $method); + return $r; + } + elseif(is_string($msg)) + { + $n =& new xmlrpcmsg(''); + $n->payload = $msg; + $msg = $n; + } + + // where msg is an xmlrpcmsg + $msg->debug=$this->debug; + + if($method == 'https') + { + $r =& $this->sendPayloadHTTPS( + $msg, + $this->server, + $this->port, + $timeout, + $this->username, + $this->password, + $this->authtype, + $this->cert, + $this->certpass, + $this->cacert, + $this->cacertdir, + $this->proxy, + $this->proxyport, + $this->proxy_user, + $this->proxy_pass, + $this->proxy_authtype, + $this->keepalive, + $this->key, + $this->keypass + ); + } + elseif($method == 'http11') + { + $r =& $this->sendPayloadCURL( + $msg, + $this->server, + $this->port, + $timeout, + $this->username, + $this->password, + $this->authtype, + null, + null, + null, + null, + $this->proxy, + $this->proxyport, + $this->proxy_user, + $this->proxy_pass, + $this->proxy_authtype, + 'http', + $this->keepalive + ); + } + else + { + $r =& $this->sendPayloadHTTP10( + $msg, + $this->server, + $this->port, + $timeout, + $this->username, + $this->password, + $this->authtype, + $this->proxy, + $this->proxyport, + $this->proxy_user, + $this->proxy_pass, + $this->proxy_authtype + ); + } + + return $r; + } + + /** + * @access private + */ + function &sendPayloadHTTP10($msg, $server, $port, $timeout=0, + $username='', $password='', $authtype=1, $proxyhost='', + $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1) + { + if($port==0) + { + $port=80; + } + + // Only create the payload if it was not created previously + if(empty($msg->payload)) + { + $msg->createPayload($this->request_charset_encoding); + } + + $payload = $msg->payload; + // Deflate request body and set appropriate request headers + if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) + { + if($this->request_compression == 'gzip') + { + $a = @gzencode($payload); + if($a) + { + $payload = $a; + $encoding_hdr = "Content-Encoding: gzip\r\n"; + } + } + else + { + $a = @gzcompress($payload); + if($a) + { + $payload = $a; + $encoding_hdr = "Content-Encoding: deflate\r\n"; + } + } + } + else + { + $encoding_hdr = ''; + } + + // thanks to Grant Rauscher for this + $credentials=''; + if($username!='') + { + $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; + if ($authtype != 1) + { + error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported with HTTP 1.0'); + } + } + + $accepted_encoding = ''; + if(is_array($this->accepted_compression) && count($this->accepted_compression)) + { + $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; + } + + $proxy_credentials = ''; + if($proxyhost) + { + if($proxyport == 0) + { + $proxyport = 8080; + } + $connectserver = $proxyhost; + $connectport = $proxyport; + $uri = 'http://'.$server.':'.$port.$this->path; + if($proxyusername != '') + { + if ($proxyauthtype != 1) + { + error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported with HTTP 1.0'); + } + $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n"; + } + } + else + { + $connectserver = $server; + $connectport = $port; + $uri = $this->path; + } + + // Cookie generation, as per rfc2965 (version 1 cookies) or + // netscape's rules (version 0 cookies) + $cookieheader=''; + if (count($this->cookies)) + { + $version = ''; + foreach ($this->cookies as $name => $cookie) + { + if ($cookie['version']) + { + $version = ' $Version="' . $cookie['version'] . '";'; + $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";'; + if ($cookie['path']) + $cookieheader .= ' $Path="' . $cookie['path'] . '";'; + if ($cookie['domain']) + $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; + if ($cookie['port']) + $cookieheader .= ' $Port="' . $cookie['port'] . '";'; + } + else + { + $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";"; + } + } + $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; + } + + $op= 'POST ' . $uri. " HTTP/1.0\r\n" . + 'User-Agent: ' . $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'] . "\r\n" . + 'Host: '. $server . ':' . $port . "\r\n" . + $credentials . + $proxy_credentials . + $accepted_encoding . + $encoding_hdr . + 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . + $cookieheader . + 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " . + strlen($payload) . "\r\n\r\n" . + $payload; + + if($this->debug > 1) + { + print "
    \n---SENDING---\n" . htmlentities($op) . "\n---END---\n
    "; + // let the client see this now in case http times out... + flush(); + } + + if($timeout>0) + { + $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); + } + else + { + $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr); + } + if($fp) + { + if($timeout>0 && function_exists('stream_set_timeout')) + { + stream_set_timeout($fp, $timeout); + } + } + else + { + $this->errstr='Connect error: '.$this->errstr; + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')'); + return $r; + } + + if(!fputs($fp, $op, strlen($op))) + { + $this->errstr='Write error'; + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); + return $r; + } + else + { + // reset errno and errstr on succesful socket connection + $this->errstr = ''; + } + // G. Giunta 2005/10/24: close socket before parsing. + // should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects) + $ipd=''; + while($data=fread($fp, 32768)) + { + // shall we check for $data === FALSE? + // as per the manual, it signals an error + $ipd.=$data; + } + fclose($fp); + $r =& $msg->parseResponse($ipd, false, $this->return_type); + return $r; + + } + + /** + * @access private + */ + function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='', + $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='', + $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, + $keepalive=false, $key='', $keypass='') + { + $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username, + $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport, + $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass); + return $r; + } + + /** + * Contributed by Justin Miller + * Requires curl to be built into PHP + * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers! + * @access private + */ + function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='', + $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='', + $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https', + $keepalive=false, $key='', $keypass='') + { + if(!function_exists('curl_init')) + { + $this->errstr='CURL unavailable on this install'; + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']); + return $r; + } + if($method == 'https') + { + if(($info = curl_version()) && + ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version'])))) + { + $this->errstr='SSL unavailable on this install'; + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']); + return $r; + } + } + + if($port == 0) + { + if($method == 'http') + { + $port = 80; + } + else + { + $port = 443; + } + } + + // Only create the payload if it was not created previously + if(empty($msg->payload)) + { + $msg->createPayload($this->request_charset_encoding); + } + + // Deflate request body and set appropriate request headers + $payload = $msg->payload; + if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) + { + if($this->request_compression == 'gzip') + { + $a = @gzencode($payload); + if($a) + { + $payload = $a; + $encoding_hdr = 'Content-Encoding: gzip'; + } + } + else + { + $a = @gzcompress($payload); + if($a) + { + $payload = $a; + $encoding_hdr = 'Content-Encoding: deflate'; + } + } + } + else + { + $encoding_hdr = ''; + } + + if($this->debug > 1) + { + print "
    \n---SENDING---\n" . htmlentities($payload) . "\n---END---\n
    "; + // let the client see this now in case http times out... + flush(); + } + + if(!$keepalive || !$this->xmlrpc_curl_handle) + { + $curl = curl_init($method . '://' . $server . ':' . $port . $this->path); + if($keepalive) + { + $this->xmlrpc_curl_handle = $curl; + } + } + else + { + $curl = $this->xmlrpc_curl_handle; + } + + // results into variable + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + + if($this->debug) + { + curl_setopt($curl, CURLOPT_VERBOSE, 1); + } + curl_setopt($curl, CURLOPT_USERAGENT, $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']); + // required for XMLRPC: post the data + curl_setopt($curl, CURLOPT_POST, 1); + // the data + curl_setopt($curl, CURLOPT_POSTFIELDS, $payload); + + // return the header too + curl_setopt($curl, CURLOPT_HEADER, 1); + + // will only work with PHP >= 5.0 + // NB: if we set an empty string, CURL will add http header indicating + // ALL methods it is supporting. This is possibly a better option than + // letting the user tell what curl can / cannot do... + if(is_array($this->accepted_compression) && count($this->accepted_compression)) + { + //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression)); + // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?) + if (count($this->accepted_compression) == 1) + { + curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]); + } + else + curl_setopt($curl, CURLOPT_ENCODING, ''); + } + // extra headers + $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); + // if no keepalive is wanted, let the server know it in advance + if(!$keepalive) + { + $headers[] = 'Connection: close'; + } + // request compression header + if($encoding_hdr) + { + $headers[] = $encoding_hdr; + } + + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + // timeout is borked + if($timeout) + { + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); + } + + if($username && $password) + { + curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); + if (defined('CURLOPT_HTTPAUTH')) + { + curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype); + } + else if ($authtype != 1) + { + error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported by the current PHP/curl install'); + } + } + + if($method == 'https') + { + // set cert file + if($cert) + { + curl_setopt($curl, CURLOPT_SSLCERT, $cert); + } + // set cert password + if($certpass) + { + curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass); + } + // whether to verify remote host's cert + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer); + // set ca certificates file/dir + if($cacert) + { + curl_setopt($curl, CURLOPT_CAINFO, $cacert); + } + if($cacertdir) + { + curl_setopt($curl, CURLOPT_CAPATH, $cacertdir); + } + // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?) + if($key) + { + curl_setopt($curl, CURLOPT_SSLKEY, $key); + } + // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?) + if($keypass) + { + curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass); + } + // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost); + } + + // proxy info + if($proxyhost) + { + if($proxyport == 0) + { + $proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080 + } + curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport); + //curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport); + if($proxyusername) + { + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword); + if (defined('CURLOPT_PROXYAUTH')) + { + curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype); + } + else if ($proxyauthtype != 1) + { + error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported by the current PHP/curl install'); + } + } + } + + // NB: should we build cookie http headers by hand rather than let CURL do it? + // the following code does not honour 'expires', 'path' and 'domain' cookie attributes + // set to client obj the the user... + if (count($this->cookies)) + { + $cookieheader = ''; + foreach ($this->cookies as $name => $cookie) + { + $cookieheader .= $name . '=' . $cookie['value'] . '; '; + } + curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2)); + } + + $result = curl_exec($curl); + + if ($this->debug > 1) + { + print "
    \n---CURL INFO---\n";
    +				foreach(curl_getinfo($curl) as $name => $val)
    +					 print $name . ': ' . htmlentities($val). "\n";
    +				print "---END---\n
    "; + } + + if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'? + { + $this->errstr='no response'; + $resp=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl)); + curl_close($curl); + if($keepalive) + { + $this->xmlrpc_curl_handle = null; + } + } + else + { + if(!$keepalive) + { + curl_close($curl); + } + $resp =& $msg->parseResponse($result, true, $this->return_type); + } + return $resp; + } + + /** + * Send an array of request messages and return an array of responses. + * Unless $this->no_multicall has been set to true, it will try first + * to use one single xmlrpc call to server method system.multicall, and + * revert to sending many successive calls in case of failure. + * This failure is also stored in $this->no_multicall for subsequent calls. + * Unfortunately, there is no server error code universally used to denote + * the fact that multicall is unsupported, so there is no way to reliably + * distinguish between that and a temporary failure. + * If you are sure that server supports multicall and do not want to + * fallback to using many single calls, set the fourth parameter to FALSE. + * + * NB: trying to shoehorn extra functionality into existing syntax has resulted + * in pretty much convoluted code... + * + * @param array $msgs an array of xmlrpcmsg objects + * @param integer $timeout connection timeout (in seconds) + * @param string $method the http protocol variant to be used + * @param boolean fallback When true, upon receiveing an error during multicall, multiple single calls will be attempted + * @return array + * @access public + */ + function multicall($msgs, $timeout=0, $method='', $fallback=true) + { + if ($method == '') + { + $method = $this->method; + } + if(!$this->no_multicall) + { + $results = $this->_try_multicall($msgs, $timeout, $method); + if(is_array($results)) + { + // System.multicall succeeded + return $results; + } + else + { + // either system.multicall is unsupported by server, + // or call failed for some other reason. + if ($fallback) + { + // Don't try it next time... + $this->no_multicall = true; + } + else + { + if (is_a($results, 'xmlrpcresp')) + { + $result = $results; + } + else + { + $result =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']); + } + } + } + } + else + { + // override fallback, in case careless user tries to do two + // opposite things at the same time + $fallback = true; + } + + $results = array(); + if ($fallback) + { + // system.multicall is (probably) unsupported by server: + // emulate multicall via multiple requests + foreach($msgs as $msg) + { + $results[] =& $this->send($msg, $timeout, $method); + } + } + else + { + // user does NOT want to fallback on many single calls: + // since we should always return an array of responses, + // return an array with the same error repeated n times + foreach($msgs as $msg) + { + $results[] = $result; + } + } + return $results; + } + + /** + * Attempt to boxcar $msgs via system.multicall. + * Returns either an array of xmlrpcreponses, an xmlrpc error response + * or false (when received response does not respect valid multicall syntax) + * @access private + */ + function _try_multicall($msgs, $timeout, $method) + { + // Construct multicall message + $calls = array(); + foreach($msgs as $msg) + { + $call['methodName'] =& new xmlrpcval($msg->method(),'string'); + $numParams = $msg->getNumParams(); + $params = array(); + for($i = 0; $i < $numParams; $i++) + { + $params[$i] = $msg->getParam($i); + } + $call['params'] =& new xmlrpcval($params, 'array'); + $calls[] =& new xmlrpcval($call, 'struct'); + } + $multicall =& new xmlrpcmsg('system.multicall'); + $multicall->addParam(new xmlrpcval($calls, 'array')); + + // Attempt RPC call + $result =& $this->send($multicall, $timeout, $method); + + if($result->faultCode() != 0) + { + // call to system.multicall failed + return $result; + } + + // Unpack responses. + $rets = $result->value(); + + if ($this->return_type == 'xml') + { + return $rets; + } + else if ($this->return_type == 'phpvals') + { + ///@todo test this code branch... + $rets = $result->value(); + if(!is_array($rets)) + { + return false; // bad return type from system.multicall + } + $numRets = count($rets); + if($numRets != count($msgs)) + { + return false; // wrong number of return values. + } + + $response = array(); + for($i = 0; $i < $numRets; $i++) + { + $val = $rets[$i]; + if (!is_array($val)) { + return false; + } + switch(count($val)) + { + case 1: + if(!isset($val[0])) + { + return false; // Bad value + } + // Normal return value + $response[$i] =& new xmlrpcresp($val[0], 0, '', 'phpvals'); + break; + case 2: + /// @todo remove usage of @: it is apparently quite slow + $code = @$val['faultCode']; + if(!is_int($code)) + { + return false; + } + $str = @$val['faultString']; + if(!is_string($str)) + { + return false; + } + $response[$i] =& new xmlrpcresp(0, $code, $str); + break; + default: + return false; + } + } + return $response; + } + else // return type == 'xmlrpcvals' + { + $rets = $result->value(); + if($rets->kindOf() != 'array') + { + return false; // bad return type from system.multicall + } + $numRets = $rets->arraysize(); + if($numRets != count($msgs)) + { + return false; // wrong number of return values. + } + + $response = array(); + for($i = 0; $i < $numRets; $i++) + { + $val = $rets->arraymem($i); + switch($val->kindOf()) + { + case 'array': + if($val->arraysize() != 1) + { + return false; // Bad value + } + // Normal return value + $response[$i] =& new xmlrpcresp($val->arraymem(0)); + break; + case 'struct': + $code = $val->structmem('faultCode'); + if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') + { + return false; + } + $str = $val->structmem('faultString'); + if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') + { + return false; + } + $response[$i] =& new xmlrpcresp(0, $code->scalarval(), $str->scalarval()); + break; + default: + return false; + } + } + return $response; + } + } + } // end class xmlrpc_client + + class xmlrpcresp + { + var $val = 0; + var $valtyp; + var $errno = 0; + var $errstr = ''; + var $payload; + var $hdrs = array(); + var $_cookies = array(); + var $content_type = 'text/xml'; + var $raw_data = ''; + + /** + * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string) + * @param integer $fcode set it to anything but 0 to create an error response + * @param string $fstr the error string, in case of an error response + * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml' + * + * @todo add check that $val / $fcode / $fstr is of correct type??? + * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain + * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called... + */ + function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='') + { + if($fcode != 0) + { + // error response + $this->errno = $fcode; + $this->errstr = $fstr; + //$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later. + } + else + { + // successful response + $this->val = $val; + if ($valtyp == '') + { + // user did not declare type of response value: try to guess it + if (is_object($this->val) && is_a($this->val, 'xmlrpcval')) + { + $this->valtyp = 'xmlrpcvals'; + } + else if (is_string($this->val)) + { + $this->valtyp = 'xml'; + + } + else + { + $this->valtyp = 'phpvals'; + } + } + else + { + // user declares type of resp value: believe him + $this->valtyp = $valtyp; + } + } + } + + /** + * Returns the error code of the response. + * @return integer the error code of this response (0 for not-error responses) + * @access public + */ + function faultCode() + { + return $this->errno; + } + + /** + * Returns the error code of the response. + * @return string the error string of this response ('' for not-error responses) + * @access public + */ + function faultString() + { + return $this->errstr; + } + + /** + * Returns the value received by the server. + * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects + * @access public + */ + function value() + { + return $this->val; + } + + /** + * Returns an array with the cookies received from the server. + * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...) + * with attributes being e.g. 'expires', 'path', domain'. + * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past) + * are still present in the array. It is up to the user-defined code to decide + * how to use the received cookies, and wheter they have to be sent back with the next + * request to the server (using xmlrpc_client::setCookie) or not + * @return array array of cookies received from the server + * @access public + */ + function cookies() + { + return $this->_cookies; + } + + /** + * Returns xml representation of the response. XML prologue not included + * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed + * @return string the xml representation of the response + * @access public + */ + function serialize($charset_encoding='') + { + if ($charset_encoding != '') + $this->content_type = 'text/xml; charset=' . $charset_encoding; + else + $this->content_type = 'text/xml'; + $result = "\n"; + if($this->errno) + { + // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients + // by xml-encoding non ascii chars + $result .= "\n" . +"\nfaultCode\n" . $this->errno . +"\n\n\nfaultString\n" . +xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n\n" . +"\n\n"; + } + else + { + if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) + { + if (is_string($this->val) && $this->valtyp == 'xml') + { + $result .= "\n\n" . + $this->val . + "\n"; + } + else + { + /// @todo try to build something serializable? + die('cannot serialize xmlrpcresp objects whose content is native php values'); + } + } + else + { + $result .= "\n\n" . + $this->val->serialize($charset_encoding) . + "\n"; + } + } + $result .= "\n"; + $this->payload = $result; + return $result; + } + } + + class xmlrpcmsg + { + var $payload; + var $methodname; + var $params=array(); + var $debug=0; + var $content_type = 'text/xml'; + + /** + * @param string $meth the name of the method to invoke + * @param array $pars array of parameters to be paased to the method (xmlrpcval objects) + */ + function xmlrpcmsg($meth, $pars=0) + { + $this->methodname=$meth; + if(is_array($pars) && count($pars)>0) + { + for($i=0; $iaddParam($pars[$i]); + } + } + } + + /** + * @access private + */ + function xml_header($charset_encoding='') + { + if ($charset_encoding != '') + { + return "\n\n"; + } + else + { + return "\n\n"; + } + } + + /** + * @access private + */ + function xml_footer() + { + return ''; + } + + /** + * @access private + */ + function kindOf() + { + return 'msg'; + } + + /** + * @access private + */ + function createPayload($charset_encoding='') + { + if ($charset_encoding != '') + $this->content_type = 'text/xml; charset=' . $charset_encoding; + else + $this->content_type = 'text/xml'; + $this->payload=$this->xml_header($charset_encoding); + $this->payload.='' . $this->methodname . "\n"; + $this->payload.="\n"; + for($i=0; $iparams); $i++) + { + $p=$this->params[$i]; + $this->payload.="\n" . $p->serialize($charset_encoding) . + "\n"; + } + $this->payload.="\n"; + $this->payload.=$this->xml_footer(); + } + + /** + * Gets/sets the xmlrpc method to be invoked + * @param string $meth the method to be set (leave empty not to set it) + * @return string the method that will be invoked + * @access public + */ + function method($meth='') + { + if($meth!='') + { + $this->methodname=$meth; + } + return $this->methodname; + } + + /** + * Returns xml representation of the message. XML prologue included + * @return string the xml representation of the message, xml prologue included + * @access public + */ + function serialize($charset_encoding='') + { + $this->createPayload($charset_encoding); + return $this->payload; + } + + /** + * Add a parameter to the list of parameters to be used upon method invocation + * @param xmlrpcval $par + * @return boolean false on failure + * @access public + */ + function addParam($par) + { + // add check: do not add to self params which are not xmlrpcvals + if(is_object($par) && is_a($par, 'xmlrpcval')) + { + $this->params[]=$par; + return true; + } + else + { + return false; + } + } + + /** + * Returns the nth parameter in the message. The index zero-based. + * @param integer $i the index of the parameter to fetch (zero based) + * @return xmlrpcval the i-th parameter + * @access public + */ + function getParam($i) { return $this->params[$i]; } + + /** + * Returns the number of parameters in the messge. + * @return integer the number of parameters currently set + * @access public + */ + function getNumParams() { return count($this->params); } + + /** + * Given an open file handle, read all data available and parse it as axmlrpc response. + * NB: the file handle is not closed by this function. + * @access public + * @return xmlrpcresp + * @todo add 2nd & 3rd param to be passed to ParseResponse() ??? + */ + function &parseResponseFile($fp) + { + $ipd=''; + while($data=fread($fp, 32768)) + { + $ipd.=$data; + } + //fclose($fp); + $r =& $this->parseResponse($ipd); + return $r; + } + + /** + * Parses HTTP headers and separates them from data. + * @access private + */ + function &parseResponseHeaders(&$data, $headers_processed=false) + { + // Support "web-proxy-tunelling" connections for https through proxies + if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) + { + // Look for CR/LF or simple LF as line separator, + // (even though it is not valid http) + $pos = strpos($data,"\r\n\r\n"); + if($pos || is_int($pos)) + { + $bd = $pos+4; + } + else + { + $pos = strpos($data,"\n\n"); + if($pos || is_int($pos)) + { + $bd = $pos+2; + } + else + { + // No separation between response headers and body: fault? + $bd = 0; + } + } + if ($bd) + { + // this filters out all http headers from proxy. + // maybe we could take them into account, too? + $data = substr($data, $bd); + } + else + { + error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTPS via proxy error, tunnel connection possibly failed'); + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)'); + return $r; + } + } + + // Strip HTTP 1.1 100 Continue header if present + while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) + { + $pos = strpos($data, 'HTTP', 12); + // server sent a Continue header without any (valid) content following... + // give the client a chance to know it + if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5 + { + break; + } + $data = substr($data, $pos); + } + if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) + { + $errstr= substr($data, 0, strpos($data, "\n")-1); + error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTP error, got response: ' .$errstr); + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')'); + return $r; + } + + $GLOBALS['_xh']['headers'] = array(); + $GLOBALS['_xh']['cookies'] = array(); + + // be tolerant to usage of \n instead of \r\n to separate headers and data + // (even though it is not valid http) + $pos = strpos($data,"\r\n\r\n"); + if($pos || is_int($pos)) + { + $bd = $pos+4; + } + else + { + $pos = strpos($data,"\n\n"); + if($pos || is_int($pos)) + { + $bd = $pos+2; + } + else + { + // No separation between response headers and body: fault? + // we could take some action here instead of going on... + $bd = 0; + } + } + // be tolerant to line endings, and extra empty lines + $ar = split("\r?\n", trim(substr($data, 0, $pos))); + while(list(,$line) = @each($ar)) + { + // take care of multi-line headers and cookies + $arr = explode(':',$line,2); + if(count($arr) > 1) + { + $header_name = strtolower(trim($arr[0])); + /// @todo some other headers (the ones that allow a CSV list of values) + /// do allow many values to be passed using multiple header lines. + /// We should add content to $GLOBALS['_xh']['headers'][$header_name] + /// instead of replacing it for those... + if ($header_name == 'set-cookie' || $header_name == 'set-cookie2') + { + if ($header_name == 'set-cookie2') + { + // version 2 cookies: + // there could be many cookies on one line, comma separated + $cookies = explode(',', $arr[1]); + } + else + { + $cookies = array($arr[1]); + } + foreach ($cookies as $cookie) + { + // glue together all received cookies, using a comma to separate them + // (same as php does with getallheaders()) + if (isset($GLOBALS['_xh']['headers'][$header_name])) + $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie); + else + $GLOBALS['_xh']['headers'][$header_name] = trim($cookie); + // parse cookie attributes, in case user wants to correctly honour them + // feature creep: only allow rfc-compliant cookie attributes? + // @todo support for server sending multiple time cookie with same name, but using different PATHs + $cookie = explode(';', $cookie); + foreach ($cookie as $pos => $val) + { + $val = explode('=', $val, 2); + $tag = trim($val[0]); + $val = trim(@$val[1]); + /// @todo with version 1 cookies, we should strip leading and trailing " chars + if ($pos == 0) + { + $cookiename = $tag; + $GLOBALS['_xh']['cookies'][$tag] = array(); + $GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val); + } + else + { + if ($tag != 'value') + { + $GLOBALS['_xh']['cookies'][$cookiename][$tag] = $val; + } + } + } + } + } + else + { + $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]); + } + } + elseif(isset($header_name)) + { + /// @todo version1 cookies might span multiple lines, thus breaking the parsing above + $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line); + } + } + + $data = substr($data, $bd); + + if($this->debug && count($GLOBALS['_xh']['headers'])) + { + print '
    ';
    +					foreach($GLOBALS['_xh']['headers'] as $header => $value)
    +					{
    +						print htmlentities("HEADER: $header: $value\n");
    +					}
    +					foreach($GLOBALS['_xh']['cookies'] as $header => $value)
    +					{
    +						print htmlentities("COOKIE: $header={$value['value']}\n");
    +					}
    +					print "
    \n"; + } + + // if CURL was used for the call, http headers have been processed, + // and dechunking + reinflating have been carried out + if(!$headers_processed) + { + // Decode chunked encoding sent by http 1.1 servers + if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked') + { + if(!$data = decode_chunked($data)) + { + error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to rebuild the chunked data received from server'); + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']); + return $r; + } + } + + // Decode gzip-compressed stuff + // code shamelessly inspired from nusoap library by Dietrich Ayala + if(isset($GLOBALS['_xh']['headers']['content-encoding'])) + { + $GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']); + if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip') + { + // if decoding works, use it. else assume data wasn't gzencoded + if(function_exists('gzinflate')) + { + if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) + { + $data = $degzdata; + if($this->debug) + print "
    ---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---
    "; + } + elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) + { + $data = $degzdata; + if($this->debug) + print "
    ---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---
    "; + } + else + { + error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to decode the deflated data received from server'); + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']); + return $r; + } + } + else + { + error_log('XML-RPC: xmlrpcmsg::parseResponse: the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']); + return $r; + } + } + } + } // end of 'if needed, de-chunk, re-inflate response' + + // real stupid hack to avoid PHP 4 complaining about returning NULL by ref + $r = null; + $r =& $r; + return $r; + } + + /** + * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object. + * @param string $data the xmlrpc response, eventually including http headers + * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding + * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals' + * @return xmlrpcresp + * @access public + */ + function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals') + { + if($this->debug) + { + //by maHo, replaced htmlspecialchars with htmlentities + print "
    ---GOT---\n" . htmlentities($data) . "\n---END---\n
    "; + } + + if($data == '') + { + error_log('XML-RPC: xmlrpcmsg::parseResponse: no response received from server.'); + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']); + return $r; + } + + $GLOBALS['_xh']=array(); + + $raw_data = $data; + // parse the HTTP headers of the response, if present, and separate them from data + if(substr($data, 0, 4) == 'HTTP') + { + $r =& $this->parseResponseHeaders($data, $headers_processed); + if ($r) + { + // failed processing of HTTP response headers + // save into response obj the full payload received, for debugging + $r->raw_data = $data; + return $r; + } + } + else + { + $GLOBALS['_xh']['headers'] = array(); + $GLOBALS['_xh']['cookies'] = array(); + } + + if($this->debug) + { + $start = strpos($data, '', $start); + $comments = substr($data, $start, $end-$start); + print "
    ---SERVER DEBUG INFO (DECODED) ---\n\t".htmlentities(str_replace("\n", "\n\t", base64_decode($comments)))."\n---END---\n
    "; + } + } + + // be tolerant of extra whitespace in response body + $data = trim($data); + + /// @todo return an error msg if $data=='' ? + + // be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts) + // idea from Luca Mariano originally in PEARified version of the lib + $bd = false; + // Poor man's version of strrpos for php 4... + $pos = strpos($data, ''); + while($pos || is_int($pos)) + { + $bd = $pos+17; + $pos = strpos($data, '', $bd); + } + if($bd) + { + $data = substr($data, 0, $bd); + } + + // if user wants back raw xml, give it to him + if ($return_type == 'xml') + { + $r =& new xmlrpcresp($data, 0, '', 'xml'); + $r->hdrs = $GLOBALS['_xh']['headers']; + $r->_cookies = $GLOBALS['_xh']['cookies']; + $r->raw_data = $raw_data; + return $r; + } + + // try to 'guestimate' the character encoding of the received response + $resp_encoding = guess_encoding(@$GLOBALS['_xh']['headers']['content-type'], $data); + + $GLOBALS['_xh']['ac']=''; + //$GLOBALS['_xh']['qt']=''; //unused... + $GLOBALS['_xh']['stack'] = array(); + $GLOBALS['_xh']['valuestack'] = array(); + $GLOBALS['_xh']['isf']=0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc + $GLOBALS['_xh']['isf_reason']=''; + $GLOBALS['_xh']['rt']=''; // 'methodcall or 'methodresponse' + + // if response charset encoding is not known / supported, try to use + // the default encoding and parse the xml anyway, but log a warning... + if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + // the following code might be better for mb_string enabled installs, but + // makes the lib about 200% slower... + //if (!is_valid_charset($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + { + error_log('XML-RPC: xmlrpcmsg::parseResponse: invalid charset encoding of received response: '.$resp_encoding); + $resp_encoding = $GLOBALS['xmlrpc_defencoding']; + } + $parser = xml_parser_create($resp_encoding); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); + // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell + // the xml parser to give us back data in the expected charset. + // What if internal encoding is not in one of the 3 allowed? + // we use the broadest one, ie. utf8 + // This allows to send data which is native in various charset, + // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding + if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + { + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); + } + else + { + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); + } + + if ($return_type == 'phpvals') + { + xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); + } + else + { + xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); + } + + xml_set_character_data_handler($parser, 'xmlrpc_cd'); + xml_set_default_handler($parser, 'xmlrpc_dh'); + + // first error check: xml not well formed + if(!xml_parse($parser, $data, count($data))) + { + // thanks to Peter Kocks + if((xml_get_current_line_number($parser)) == 1) + { + $errstr = 'XML error at line 1, check URL'; + } + else + { + $errstr = sprintf('XML error: %s at line %d, column %d', + xml_error_string(xml_get_error_code($parser)), + xml_get_current_line_number($parser), xml_get_current_column_number($parser)); + } + error_log($errstr); + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')'); + xml_parser_free($parser); + if($this->debug) + { + print $errstr; + } + $r->hdrs = $GLOBALS['_xh']['headers']; + $r->_cookies = $GLOBALS['_xh']['cookies']; + $r->raw_data = $raw_data; + return $r; + } + xml_parser_free($parser); + // second error check: xml well formed but not xml-rpc compliant + if ($GLOBALS['_xh']['isf'] > 1) + { + if ($this->debug) + { + /// @todo echo something for user? + } + + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], + $GLOBALS['xmlrpcstr']['invalid_return'] . ' ' . $GLOBALS['_xh']['isf_reason']); + } + // third error check: parsing of the response has somehow gone boink. + // NB: shall we omit this check, since we trust the parsing code? + elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value'])) + { + // something odd has happened + // and it's time to generate a client side error + // indicating something odd went on + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], + $GLOBALS['xmlrpcstr']['invalid_return']); + } + else + { + if ($this->debug) + { + print "
    ---PARSED---\n";
    +					// somehow htmlentities chokes on var_export, and some full html string...
    +					//print htmlentitites(var_export($GLOBALS['_xh']['value'], true));
    +					print htmlspecialchars(var_export($GLOBALS['_xh']['value'], true));
    +					print "\n---END---
    "; + } + + // note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object. + $v =& $GLOBALS['_xh']['value']; + + if($GLOBALS['_xh']['isf']) + { + /// @todo we should test here if server sent an int and a string, + /// and/or coerce them into such... + if ($return_type == 'xmlrpcvals') + { + $errno_v = $v->structmem('faultCode'); + $errstr_v = $v->structmem('faultString'); + $errno = $errno_v->scalarval(); + $errstr = $errstr_v->scalarval(); + } + else + { + $errno = $v['faultCode']; + $errstr = $v['faultString']; + } + + if($errno == 0) + { + // FAULT returned, errno needs to reflect that + $errno = -1; + } + + $r =& new xmlrpcresp(0, $errno, $errstr); + } + else + { + $r=&new xmlrpcresp($v, 0, '', $return_type); + } + } + + $r->hdrs = $GLOBALS['_xh']['headers']; + $r->_cookies = $GLOBALS['_xh']['cookies']; + $r->raw_data = $raw_data; + return $r; + } + } + + class xmlrpcval + { + var $me=array(); + var $mytype=0; + var $_php_class=null; + + /** + * @param mixed $val + * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed + */ + function xmlrpcval($val=-1, $type='') + { + /// @todo: optimization creep - do not call addXX, do it all inline. + /// downside: booleans will not be coerced anymore + if($val!==-1 || $type!='') + { + // optimization creep: inlined all work done by constructor + switch($type) + { + case '': + $this->mytype=1; + $this->me['string']=$val; + break; + case 'i4': + case 'int': + case 'double': + case 'string': + case 'boolean': + case 'dateTime.iso8601': + case 'base64': + case 'null': + $this->mytype=1; + $this->me[$type]=$val; + break; + case 'array': + $this->mytype=2; + $this->me['array']=$val; + break; + case 'struct': + $this->mytype=3; + $this->me['struct']=$val; + break; + default: + error_log("XML-RPC: xmlrpcval::xmlrpcval: not a known type ($type)"); + } + /*if($type=='') + { + $type='string'; + } + if($GLOBALS['xmlrpcTypes'][$type]==1) + { + $this->addScalar($val,$type); + } + elseif($GLOBALS['xmlrpcTypes'][$type]==2) + { + $this->addArray($val); + } + elseif($GLOBALS['xmlrpcTypes'][$type]==3) + { + $this->addStruct($val); + }*/ + } + } + + /** + * Add a single php value to an (unitialized) xmlrpcval + * @param mixed $val + * @param string $type + * @return int 1 or 0 on failure + */ + function addScalar($val, $type='string') + { + $typeof=@$GLOBALS['xmlrpcTypes'][$type]; + if($typeof!=1) + { + error_log("XML-RPC: xmlrpcval::addScalar: not a scalar type ($type)"); + return 0; + } + + // coerce booleans into correct values + // NB: we should iether do it for datetimes, integers and doubles, too, + // or just plain remove this check, implemnted on booleans only... + if($type==$GLOBALS['xmlrpcBoolean']) + { + if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false'))) + { + $val=true; + } + else + { + $val=false; + } + } + + switch($this->mytype) + { + case 1: + error_log('XML-RPC: xmlrpcval::addScalar: scalar xmlrpcval can have only one value'); + return 0; + case 3: + error_log('XML-RPC: xmlrpcval::addScalar: cannot add anonymous scalar to struct xmlrpcval'); + return 0; + case 2: + // we're adding a scalar value to an array here + //$ar=$this->me['array']; + //$ar[]=&new xmlrpcval($val, $type); + //$this->me['array']=$ar; + // Faster (?) avoid all the costly array-copy-by-val done here... + $this->me['array'][]=&new xmlrpcval($val, $type); + return 1; + default: + // a scalar, so set the value and remember we're scalar + $this->me[$type]=$val; + $this->mytype=$typeof; + return 1; + } + } + + /** + * Add an array of xmlrpcval objects to an xmlrpcval + * @param array $vals + * @return int 1 or 0 on failure + * @access public + * + * @todo add some checking for $vals to be an array of xmlrpcvals? + */ + function addArray($vals) + { + if($this->mytype==0) + { + $this->mytype=$GLOBALS['xmlrpcTypes']['array']; + $this->me['array']=$vals; + return 1; + } + elseif($this->mytype==2) + { + // we're adding to an array here + $this->me['array'] = array_merge($this->me['array'], $vals); + return 1; + } + else + { + error_log('XML-RPC: xmlrpcval::addArray: already initialized as a [' . $this->kindOf() . ']'); + return 0; + } + } + + /** + * Add an array of named xmlrpcval objects to an xmlrpcval + * @param array $vals + * @return int 1 or 0 on failure + * @access public + * + * @todo add some checking for $vals to be an array? + */ + function addStruct($vals) + { + if($this->mytype==0) + { + $this->mytype=$GLOBALS['xmlrpcTypes']['struct']; + $this->me['struct']=$vals; + return 1; + } + elseif($this->mytype==3) + { + // we're adding to a struct here + $this->me['struct'] = array_merge($this->me['struct'], $vals); + return 1; + } + else + { + error_log('XML-RPC: xmlrpcval::addStruct: already initialized as a [' . $this->kindOf() . ']'); + return 0; + } + } + + // poor man's version of print_r ??? + // DEPRECATED! + function dump($ar) + { + foreach($ar as $key => $val) + { + echo "$key => $val
    "; + if($key == 'array') + { + while(list($key2, $val2) = each($val)) + { + echo "-- $key2 => $val2
    "; + } + } + } + } + + /** + * Returns a string containing "struct", "array" or "scalar" describing the base type of the value + * @return string + * @access public + */ + function kindOf() + { + switch($this->mytype) + { + case 3: + return 'struct'; + break; + case 2: + return 'array'; + break; + case 1: + return 'scalar'; + break; + default: + return 'undef'; + } + } + + /** + * @access private + */ + function serializedata($typ, $val, $charset_encoding='') + { + $rs=''; + switch(@$GLOBALS['xmlrpcTypes'][$typ]) + { + case 1: + switch($typ) + { + case $GLOBALS['xmlrpcBase64']: + $rs.="<${typ}>" . base64_encode($val) . ""; + break; + case $GLOBALS['xmlrpcBoolean']: + $rs.="<${typ}>" . ($val ? '1' : '0') . ""; + break; + case $GLOBALS['xmlrpcString']: + // G. Giunta 2005/2/13: do NOT use htmlentities, since + // it will produce named html entities, which are invalid xml + $rs.="<${typ}>" . xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding). ""; + break; + case $GLOBALS['xmlrpcInt']: + case $GLOBALS['xmlrpcI4']: + $rs.="<${typ}>".(int)$val.""; + break; + case $GLOBALS['xmlrpcDouble']: + $rs.="<${typ}>".(double)$val.""; + break; + case $GLOBALS['xmlrpcNull']: + $rs.=""; + break; + default: + // no standard type value should arrive here, but provide a possibility + // for xmlrpcvals of unknown type... + $rs.="<${typ}>${val}"; + } + break; + case 3: + // struct + if ($this->_php_class) + { + $rs.='\n"; + } + else + { + $rs.="\n"; + } + foreach($val as $key2 => $val2) + { + $rs.=''.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."\n"; + //$rs.=$this->serializeval($val2); + $rs.=$val2->serialize($charset_encoding); + $rs.="\n"; + } + $rs.=''; + break; + case 2: + // array + $rs.="\n\n"; + for($i=0; $iserializeval($val[$i]); + $rs.=$val[$i]->serialize($charset_encoding); + } + $rs.="\n"; + break; + default: + break; + } + return $rs; + } + + /** + * Returns xml representation of the value. XML prologue not included + * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed + * @return string + * @access public + */ + function serialize($charset_encoding='') + { + // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... + //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) + //{ + reset($this->me); + list($typ, $val) = each($this->me); + return '' . $this->serializedata($typ, $val, $charset_encoding) . "\n"; + //} + } + + // DEPRECATED + function serializeval($o) + { + // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... + //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) + //{ + $ar=$o->me; + reset($ar); + list($typ, $val) = each($ar); + return '' . $this->serializedata($typ, $val) . "\n"; + //} + } + + /** + * Checks wheter a struct member with a given name is present. + * Works only on xmlrpcvals of type struct. + * @param string $m the name of the struct member to be looked up + * @return boolean + * @access public + */ + function structmemexists($m) + { + return array_key_exists($m, $this->me['struct']); + } + + /** + * Returns the value of a given struct member (an xmlrpcval object in itself). + * Will raise a php warning if struct member of given name does not exist + * @param string $m the name of the struct member to be looked up + * @return xmlrpcval + * @access public + */ + function structmem($m) + { + return $this->me['struct'][$m]; + } + + /** + * Reset internal pointer for xmlrpcvals of type struct. + * @access public + */ + function structreset() + { + reset($this->me['struct']); + } + + /** + * Return next member element for xmlrpcvals of type struct. + * @return xmlrpcval + * @access public + */ + function structeach() + { + return each($this->me['struct']); + } + + // DEPRECATED! this code looks like it is very fragile and has not been fixed + // for a long long time. Shall we remove it for 2.0? + function getval() + { + // UNSTABLE + reset($this->me); + list($a,$b)=each($this->me); + // contributed by I Sofer, 2001-03-24 + // add support for nested arrays to scalarval + // i've created a new method here, so as to + // preserve back compatibility + + if(is_array($b)) + { + @reset($b); + while(list($id,$cont) = @each($b)) + { + $b[$id] = $cont->scalarval(); + } + } + + // add support for structures directly encoding php objects + if(is_object($b)) + { + $t = get_object_vars($b); + @reset($t); + while(list($id,$cont) = @each($t)) + { + $t[$id] = $cont->scalarval(); + } + @reset($t); + while(list($id,$cont) = @each($t)) + { + @$b->$id = $cont; + } + } + // end contrib + return $b; + } + + /** + * Returns the value of a scalar xmlrpcval + * @return mixed + * @access public + */ + function scalarval() + { + reset($this->me); + list(,$b)=each($this->me); + return $b; + } + + /** + * Returns the type of the xmlrpcval. + * For integers, 'int' is always returned in place of 'i4' + * @return string + * @access public + */ + function scalartyp() + { + reset($this->me); + list($a,)=each($this->me); + if($a==$GLOBALS['xmlrpcI4']) + { + $a=$GLOBALS['xmlrpcInt']; + } + return $a; + } + + /** + * Returns the m-th member of an xmlrpcval of struct type + * @param integer $m the index of the value to be retrieved (zero based) + * @return xmlrpcval + * @access public + */ + function arraymem($m) + { + return $this->me['array'][$m]; + } + + /** + * Returns the number of members in an xmlrpcval of array type + * @return integer + * @access public + */ + function arraysize() + { + return count($this->me['array']); + } + + /** + * Returns the number of members in an xmlrpcval of struct type + * @return integer + * @access public + */ + function structsize() + { + return count($this->me['struct']); + } + } + + + // date helpers + + /** + * Given a timestamp, return the corresponding ISO8601 encoded string. + * + * Really, timezones ought to be supported + * but the XML-RPC spec says: + * + * "Don't assume a timezone. It should be specified by the server in its + * documentation what assumptions it makes about timezones." + * + * These routines always assume localtime unless + * $utc is set to 1, in which case UTC is assumed + * and an adjustment for locale is made when encoding + * + * @param int $timet (timestamp) + * @param int $utc (0 or 1) + * @return string + */ + function iso8601_encode($timet, $utc=0) + { + if(!$utc) + { + $t=strftime("%Y%m%dT%H:%M:%S", $timet); + } + else + { + if(function_exists('gmstrftime')) + { + // gmstrftime doesn't exist in some versions + // of PHP + $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet); + } + else + { + $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z')); + } + } + return $t; + } + + /** + * Given an ISO8601 date string, return a timet in the localtime, or UTC + * @param string $idate + * @param int $utc either 0 or 1 + * @return int (datetime) + */ + function iso8601_decode($idate, $utc=0) + { + $t=0; + if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) + { + if($utc) + { + $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); + } + else + { + $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); + } + } + return $t; + } + + /** + * Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types. + * + * Works with xmlrpc message objects as input, too. + * + * Given proper options parameter, can rebuild generic php object instances + * (provided those have been encoded to xmlrpc format using a corresponding + * option in php_xmlrpc_encode()) + * PLEASE NOTE that rebuilding php objects involves calling their constructor function. + * This means that the remote communication end can decide which php code will + * get executed on your server, leaving the door possibly open to 'php-injection' + * style of attacks (provided you have some classes defined on your server that + * might wreak havoc if instances are built outside an appropriate context). + * Make sure you trust the remote server/client before eanbling this! + * + * @author Dan Libby (dan@libby.com) + * + * @param xmlrpcval $xmlrpc_val + * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects + * @return mixed + */ + function php_xmlrpc_decode($xmlrpc_val, $options=array()) + { + switch($xmlrpc_val->kindOf()) + { + case 'scalar': + if (in_array('extension_api', $options)) + { + reset($xmlrpc_val->me); + list($typ,$val) = each($xmlrpc_val->me); + switch ($typ) + { + case 'dateTime.iso8601': + $xmlrpc_val->scalar = $val; + $xmlrpc_val->xmlrpc_type = 'datetime'; + $xmlrpc_val->timestamp = iso8601_decode($val); + return $xmlrpc_val; + case 'base64': + $xmlrpc_val->scalar = $val; + $xmlrpc_val->type = $typ; + return $xmlrpc_val; + default: + return $xmlrpc_val->scalarval(); + } + } + return $xmlrpc_val->scalarval(); + case 'array': + $size = $xmlrpc_val->arraysize(); + $arr = array(); + for($i = 0; $i < $size; $i++) + { + $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options); + } + return $arr; + case 'struct': + $xmlrpc_val->structreset(); + // If user said so, try to rebuild php objects for specific struct vals. + /// @todo should we raise a warning for class not found? + // shall we check for proper subclass of xmlrpcval instead of + // presence of _php_class to detect what we can do? + if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != '' + && class_exists($xmlrpc_val->_php_class)) + { + $obj = @new $xmlrpc_val->_php_class; + while(list($key,$value)=$xmlrpc_val->structeach()) + { + $obj->$key = php_xmlrpc_decode($value, $options); + } + return $obj; + } + else + { + $arr = array(); + while(list($key,$value)=$xmlrpc_val->structeach()) + { + $arr[$key] = php_xmlrpc_decode($value, $options); + } + return $arr; + } + case 'msg': + $paramcount = $xmlrpc_val->getNumParams(); + $arr = array(); + for($i = 0; $i < $paramcount; $i++) + { + $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i)); + } + return $arr; + } + } + + // This constant left here only for historical reasons... + // it was used to decide if we have to define xmlrpc_encode on our own, but + // we do not do it anymore + if(function_exists('xmlrpc_decode')) + { + define('XMLRPC_EPI_ENABLED','1'); + } + else + { + define('XMLRPC_EPI_ENABLED','0'); + } + + /** + * Takes native php types and encodes them into xmlrpc PHP object format. + * It will not re-encode xmlrpcval objects. + * + * Feature creep -- could support more types via optional type argument + * (string => datetime support has been added, ??? => base64 not yet) + * + * If given a proper options parameter, php object instances will be encoded + * into 'special' xmlrpc values, that can later be decoded into php objects + * by calling php_xmlrpc_decode() with a corresponding option + * + * @author Dan Libby (dan@libby.com) + * + * @param mixed $php_val the value to be converted into an xmlrpcval object + * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api' + * @return xmlrpcval + */ + function &php_xmlrpc_encode($php_val, $options=array()) + { + $type = gettype($php_val); + switch($type) + { + case 'string': + if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) + $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']); + else + $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcString']); + break; + case 'integer': + $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']); + break; + case 'double': + $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDouble']); + break; + // + // Add support for encoding/decoding of booleans, since they are supported in PHP + case 'boolean': + $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcBoolean']); + break; + // + case 'array': + // PHP arrays can be encoded to either xmlrpc structs or arrays, + // depending on wheter they are hashes or plain 0..n integer indexed + // A shorter one-liner would be + // $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1)); + // but execution time skyrockets! + $j = 0; + $arr = array(); + $ko = false; + foreach($php_val as $key => $val) + { + $arr[$key] =& php_xmlrpc_encode($val, $options); + if(!$ko && $key !== $j) + { + $ko = true; + } + $j++; + } + if($ko) + { + $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); + } + else + { + $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcArray']); + } + break; + case 'object': + if(is_a($php_val, 'xmlrpcval')) + { + $xmlrpc_val = $php_val; + } + else + { + $arr = array(); + while(list($k,$v) = each($php_val)) + { + $arr[$k] = php_xmlrpc_encode($v, $options); + } + $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); + if (in_array('encode_php_objs', $options)) + { + // let's save original class name into xmlrpcval: + // might be useful later on... + $xmlrpc_val->_php_class = get_class($php_val); + } + } + break; + case 'NULL': + if (in_array('extension_api', $options)) + { + $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcString']); + } + if (in_array('null_extension', $options)) + { + $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcNull']); + } + else + { + $xmlrpc_val =& new xmlrpcval(); + } + break; + case 'resource': + if (in_array('extension_api', $options)) + { + $xmlrpc_val =& new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']); + } + else + { + $xmlrpc_val =& new xmlrpcval(); + } + // catch "user function", "unknown type" + default: + // giancarlo pinerolo + // it has to return + // an empty object in case, not a boolean. + $xmlrpc_val =& new xmlrpcval(); + break; + } + return $xmlrpc_val; + } + + /** + * Convert the xml representation of a method response, method request or single + * xmlrpc value into the appropriate object (a.k.a. deserialize) + * @param string $xml_val + * @param array $options + * @return mixed false on error, or an instance of either xmlrpcval, xmlrpcmsg or xmlrpcresp + */ + function php_xmlrpc_decode_xml($xml_val, $options=array()) + { + $GLOBALS['_xh'] = array(); + $GLOBALS['_xh']['ac'] = ''; + $GLOBALS['_xh']['stack'] = array(); + $GLOBALS['_xh']['valuestack'] = array(); + $GLOBALS['_xh']['params'] = array(); + $GLOBALS['_xh']['pt'] = array(); + $GLOBALS['_xh']['isf'] = 0; + $GLOBALS['_xh']['isf_reason'] = ''; + $GLOBALS['_xh']['method'] = false; + $GLOBALS['_xh']['rt'] = ''; + /// @todo 'guestimate' encoding + $parser = xml_parser_create(); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); + // What if internal encoding is not in one of the 3 allowed? + // we use the broadest one, ie. utf8! + if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + { + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); + } + else + { + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); + } + xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee'); + xml_set_character_data_handler($parser, 'xmlrpc_cd'); + xml_set_default_handler($parser, 'xmlrpc_dh'); + if(!xml_parse($parser, $xml_val, 1)) + { + $errstr = sprintf('XML error: %s at line %d, column %d', + xml_error_string(xml_get_error_code($parser)), + xml_get_current_line_number($parser), xml_get_current_column_number($parser)); + error_log($errstr); + xml_parser_free($parser); + return false; + } + xml_parser_free($parser); + if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too??? + { + error_log($GLOBALS['_xh']['isf_reason']); + return false; + } + switch ($GLOBALS['_xh']['rt']) + { + case 'methodresponse': + $v =& $GLOBALS['_xh']['value']; + if ($GLOBALS['_xh']['isf'] == 1) + { + $vc = $v->structmem('faultCode'); + $vs = $v->structmem('faultString'); + $r =& new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval()); + } + else + { + $r =& new xmlrpcresp($v); + } + return $r; + case 'methodcall': + $m =& new xmlrpcmsg($GLOBALS['_xh']['method']); + for($i=0; $i < count($GLOBALS['_xh']['params']); $i++) + { + $m->addParam($GLOBALS['_xh']['params'][$i]); + } + return $m; + case 'value': + return $GLOBALS['_xh']['value']; + default: + return false; + } + } + + /** + * decode a string that is encoded w/ "chunked" transfer encoding + * as defined in rfc2068 par. 19.4.6 + * code shamelessly stolen from nusoap library by Dietrich Ayala + * + * @param string $buffer the string to be decoded + * @return string + */ + function decode_chunked($buffer) + { + // length := 0 + $length = 0; + $new = ''; + + // read chunk-size, chunk-extension (if any) and crlf + // get the position of the linebreak + $chunkend = strpos($buffer,"\r\n") + 2; + $temp = substr($buffer,0,$chunkend); + $chunk_size = hexdec( trim($temp) ); + $chunkstart = $chunkend; + while($chunk_size > 0) + { + $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size); + + // just in case we got a broken connection + if($chunkend == false) + { + $chunk = substr($buffer,$chunkstart); + // append chunk-data to entity-body + $new .= $chunk; + $length += strlen($chunk); + break; + } + + // read chunk-data and crlf + $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); + // append chunk-data to entity-body + $new .= $chunk; + // length := length + chunk-size + $length += strlen($chunk); + // read chunk-size and crlf + $chunkstart = $chunkend + 2; + + $chunkend = strpos($buffer,"\r\n",$chunkstart)+2; + if($chunkend == false) + { + break; //just in case we got a broken connection + } + $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); + $chunk_size = hexdec( trim($temp) ); + $chunkstart = $chunkend; + } + return $new; + } + + /** + * xml charset encoding guessing helper function. + * Tries to determine the charset encoding of an XML chunk + * received over HTTP. + * NB: according to the spec (RFC 3023, if text/xml content-type is received over HTTP without a content-type, + * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers, + * which will be most probably using UTF-8 anyway... + * + * @param string $httpheaders the http Content-type header + * @param string $xmlchunk xml content buffer + * @param string $encoding_prefs comma separated list of character encodings to be used as default (when mb extension is enabled) + * + * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!! + */ + function guess_encoding($httpheader='', $xmlchunk='', $encoding_prefs=null) + { + // discussion: see http://www.yale.edu/pclt/encoding/ + // 1 - test if encoding is specified in HTTP HEADERS + + //Details: + // LWS: (\13\10)?( |\t)+ + // token: (any char but excluded stuff)+ + // header: Content-type = ...; charset=value(; ...)* + // where value is of type token, no LWS allowed between 'charset' and value + // Note: we do not check for invalid chars in VALUE: + // this had better be done using pure ereg as below + + /// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it? + $matches = array(); + if(preg_match('/;\s*charset=([^;]+)/i', $httpheader, $matches)) + { + return strtoupper(trim($matches[1])); + } + + // 2 - scan the first bytes of the data for a UTF-16 (or other) BOM pattern + // (source: http://www.w3.org/TR/2000/REC-xml-20001006) + // NOTE: actually, according to the spec, even if we find the BOM and determine + // an encoding, we should check if there is an encoding specified + // in the xml declaration, and verify if they match. + /// @todo implement check as described above? + /// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM) + if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk)) + { + return 'UCS-4'; + } + elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk)) + { + return 'UTF-16'; + } + elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) + { + return 'UTF-8'; + } + + // 3 - test if encoding is specified in the xml declaration + // Details: + // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ + // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* + if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". + '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", + $xmlchunk, $matches)) + { + return strtoupper(substr($matches[2], 1, -1)); + } + + // 4 - if mbstring is available, let it do the guesswork + // NB: we favour finding an encoding that is compatible with what we can process + if(extension_loaded('mbstring')) + { + if($encoding_prefs) + { + $enc = mb_detect_encoding($xmlchunk, $encoding_prefs); + } + else + { + $enc = mb_detect_encoding($xmlchunk); + } + // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... + // IANA also likes better US-ASCII, so go with it + if($enc == 'ASCII') + { + $enc = 'US-'.$enc; + } + return $enc; + } + else + { + // no encoding specified: as per HTTP1.1 assume it is iso-8859-1? + // Both RFC 2616 (HTTP 1.1) and 1945(http 1.0) clearly state that for text/xxx content types + // this should be the standard. And we should be getting text/xml as request and response. + // BUT we have to be backward compatible with the lib, which always used UTF-8 as default... + return $GLOBALS['xmlrpc_defencoding']; + } + } + + /** + * Checks if a given charset encoding is present in a list of encodings or + * if it is a valid subset of any encoding in the list + * @param string $encoding charset to be tested + * @param mixed $validlist comma separated list of valid charsets (or array of charsets) + */ + function is_valid_charset($encoding, $validlist) + { + $charset_supersets = array( + 'US-ASCII' => array ('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', + 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', + 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12', + 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8', + 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN') + ); + if (is_string($validlist)) + $validlist = explode(',', $validlist); + if (@in_array(strtoupper($encoding), $validlist)) + return true; + else + { + if (array_key_exists($encoding, $charset_supersets)) + foreach ($validlist as $allowed) + if (in_array($allowed, $charset_supersets[$encoding])) + return true; + return false; + } + } + +?> \ No newline at end of file diff --git a/includes/xmlrpc/xmlrpc_wrappers.inc b/includes/xmlrpc/xmlrpc_wrappers.inc new file mode 100644 index 0000000..cd0a56f --- /dev/null +++ b/includes/xmlrpc/xmlrpc_wrappers.inc @@ -0,0 +1,819 @@ +isInternal()) + { + // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs + // instead of getparameters to fully reflect internal php functions ? + error_log('XML-RPC: function to be wrapped is internal: '.$funcname); + return false; + } + + // retrieve parameter names, types and description from javadoc comments + + // function description + $desc = ''; + // type of return val: by default 'any' + $returns = $GLOBALS['xmlrpcValue']; + // desc of return val + $returnsDocs = ''; + // type + name of function parameters + $paramDocs = array(); + + $docs = $func->getDocComment(); + if($docs != '') + { + $docs = explode("\n", $docs); + $i = 0; + foreach($docs as $doc) + { + $doc = trim($doc, " \r\t/*"); + if(strlen($doc) && strpos($doc, '@') !== 0 && !$i) + { + if($desc) + { + $desc .= "\n"; + } + $desc .= $doc; + } + elseif(strpos($doc, '@param') === 0) + { + // syntax: @param type [$name] desc + if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches)) + { + if(strpos($matches[1], '|')) + { + //$paramDocs[$i]['type'] = explode('|', $matches[1]); + $paramDocs[$i]['type'] = 'mixed'; + } + else + { + $paramDocs[$i]['type'] = $matches[1]; + } + $paramDocs[$i]['name'] = trim($matches[2]); + $paramDocs[$i]['doc'] = $matches[3]; + } + $i++; + } + elseif(strpos($doc, '@return') === 0) + { + // syntax: @return type desc + //$returns = preg_split('/\s+/', $doc); + if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches)) + { + $returns = php_2_xmlrpc_type($matches[1]); + if(isset($matches[2])) + { + $returnsDocs = $matches[2]; + } + } + } + } + } + + // execute introspection of actual function prototype + $params = array(); + $i = 0; + foreach($func->getParameters() as $paramobj) + { + $params[$i] = array(); + $params[$i]['name'] = '$'.$paramobj->getName(); + $params[$i]['isoptional'] = $paramobj->isOptional(); + $i++; + } + + + // start building of PHP code to be eval'd + $innercode = ''; + $i = 0; + $parsvariations = array(); + $pars = array(); + $pnum = count($params); + foreach($params as $param) + { + if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name'])) + { + // param name from phpdoc info does not match param definition! + $paramDocs[$i]['type'] = 'mixed'; + } + + if($param['isoptional']) + { + // this particular parameter is optional. save as valid previous list of parameters + $innercode .= "if (\$paramcount > $i) {\n"; + $parsvariations[] = $pars; + } + $innercode .= "\$p$i = \$msg->getParam($i);\n"; + if ($decode_php_objects) + { + $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i, array('decode_php_objs'));\n"; + } + else + { + $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i);\n"; + } + + $pars[] = "\$p$i"; + $i++; + if($param['isoptional']) + { + $innercode .= "}\n"; + } + if($i == $pnum) + { + // last allowed parameters combination + $parsvariations[] = $pars; + } + } + + $sigs = array(); + $psigs = array(); + if(count($parsvariations) == 0) + { + // only known good synopsis = no parameters + $parsvariations[] = array(); + $minpars = 0; + } + else + { + $minpars = count($parsvariations[0]); + } + + if($minpars) + { + // add to code the check for min params number + // NB: this check needs to be done BEFORE decoding param values + $innercode = "\$paramcount = \$msg->getNumParams();\n" . + "if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode; + } + else + { + $innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode; + } + + $innercode .= "\$np = false;\n"; + foreach($parsvariations as $pars) + { + $innercode .= "if (\$paramcount == " . count($pars) . ") \$retval = {$catch_warnings}$funcname(" . implode(',', $pars) . "); else\n"; + // build a 'generic' signature (only use an appropriate return type) + $sig = array($returns); + $psig = array($returnsDocs); + for($i=0; $i < count($pars); $i++) + { + if (isset($paramDocs[$i]['type'])) + { + $sig[] = php_2_xmlrpc_type($paramDocs[$i]['type']); + } + else + { + $sig[] = $GLOBALS['xmlrpcValue']; + } + $psig[] = isset($paramDocs[$i]['doc']) ? $paramDocs[$i]['doc'] : ''; + } + $sigs[] = $sig; + $psigs[] = $psig; + } + $innercode .= "\$np = true;\n"; + $innercode .= "if (\$np) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}'); else {\n"; + //$innercode .= "if (\$_xmlrpcs_error_occurred) return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']user, \$_xmlrpcs_error_occurred); else\n"; + $innercode .= "if (is_a(\$retval, '{$prefix}resp')) return \$retval; else\n"; + if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64']) + { + $innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));"; + } + else + { + if ($encode_php_objects) + $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n"; + else + $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n"; + } + // shall we exclude functions returning by ref? + // if($func->returnsReference()) + // return false; + $code = "function $xmlrpcfuncname(\$msg) {\n" . $innercode . "}\n}"; + //print_r($code); + if ($buildit) + { + $allOK = 0; + eval($code.'$allOK=1;'); + // alternative + //$xmlrpcfuncname = create_function('$m', $innercode); + + if(!$allOK) + { + error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap php function '.$funcname); + return false; + } + } + + /// @todo examine if $paramDocs matches $parsvariations and build array for + /// usage as method signature, plus put together a nice string for docs + + $ret = array('function' => $xmlrpcfuncname, 'signature' => $sigs, 'docstring' => $desc, 'signature_docs' => $psigs, 'source' => $code); + return $ret; + } + } + + /** + * Given an xmlrpc client and a method name, register a php wrapper function + * that will call it and return results using native php types for both + * params and results. The generated php function will return an xmlrpcresp + * oject for failed xmlrpc calls + * + * Known limitations: + * - server must support system.methodsignature for the wanted xmlrpc method + * - for methods that expose many signatures, only one can be picked (we + * could in priciple check if signatures differ only by number of params + * and not by type, but it would be more complication than we can spare time) + * - nested xmlrpc params: the caller of the generated php function has to + * encode on its own the params passed to the php function if these are structs + * or arrays whose (sub)members include values of type datetime or base64 + * + * Notes: the connection properties of the given client will be copied + * and reused for the connection used during the call to the generated + * php function. + * Calling the generated php function 'might' be slow: a new xmlrpc client + * is created on every invocation and an xmlrpc-connection opened+closed. + * An extra 'debug' param is appended to param list of xmlrpc method, useful + * for debugging purposes. + * + * @param xmlrpc_client $client an xmlrpc client set up correctly to communicate with target server + * @param string $methodname the xmlrpc method to be mapped to a php function + * @param array $extra_options array of options that specify conversion details. valid ptions include + * integer signum the index of the method signature to use in mapping (if method exposes many sigs) + * integer timeout timeout (in secs) to be used when executing function/calling remote method + * string protocol 'http' (default), 'http11' or 'https' + * string new_function_name the name of php function to create. If unsepcified, lib will pick an appropriate name + * string return_source if true return php code w. function definition instead fo function name + * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects + * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers --- + * mixed return_on_fault a php value to be returned when the xmlrpc call fails/returns a fault response (by default the xmlrpcresp object is returned in this case). If a string is used, '%faultCode%' and '%faultString%' tokens will be substituted with actual error values + * bool debug set it to 1 or 2 to see debug results of querying server for method synopsis + * @return string the name of the generated php function (or false) - OR AN ARRAY... + */ + function wrap_xmlrpc_method($client, $methodname, $extra_options=0, $timeout=0, $protocol='', $newfuncname='') + { + // mind numbing: let caller use sane calling convention (as per javadoc, 3 params), + // OR the 2.0 calling convention (no ptions) - we really love backward compat, don't we? + if (!is_array($extra_options)) + { + $signum = $extra_options; + $extra_options = array(); + } + else + { + $signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; + $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; + $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; + $newfuncname = isset($extra_options['new_function_name']) ? $extra_options['new_function_name'] : ''; + } + //$encode_php_objects = in_array('encode_php_objects', $extra_options); + //$verbatim_client_copy = in_array('simple_client_copy', $extra_options) ? 1 : + // in_array('build_class_code', $extra_options) ? 2 : 0; + + $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; + $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; + $simple_client_copy = isset($extra_options['simple_client_copy']) ? (int)($extra_options['simple_client_copy']) : 0; + $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; + $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; + if (isset($extra_options['return_on_fault'])) + { + $decode_fault = true; + $fault_response = $extra_options['return_on_fault']; + } + else + { + $decode_fault = false; + $fault_response = ''; + } + $debug = isset($extra_options['debug']) ? ($extra_options['debug']) : 0; + + $msgclass = $prefix.'msg'; + $valclass = $prefix.'val'; + $decodefunc = 'php_'.$prefix.'_decode'; + + $msg =& new $msgclass('system.methodSignature'); + $msg->addparam(new $valclass($methodname)); + $client->setDebug($debug); + $response =& $client->send($msg, $timeout, $protocol); + if($response->faultCode()) + { + error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname); + return false; + } + else + { + $msig = $response->value(); + if ($client->return_type != 'phpvals') + { + $msig = $decodefunc($msig); + } + if(!is_array($msig) || count($msig) <= $signum) + { + error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname); + return false; + } + else + { + // pick a suitable name for the new function, avoiding collisions + if($newfuncname != '') + { + $xmlrpcfuncname = $newfuncname; + } + else + { + // take care to insure that methodname is translated to valid + // php function name + $xmlrpcfuncname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), + array('_', ''), $methodname); + } + while($buildit && function_exists($xmlrpcfuncname)) + { + $xmlrpcfuncname .= 'x'; + } + + $msig = $msig[$signum]; + $mdesc = ''; + // if in 'offline' mode, get method description too. + // in online mode, favour speed of operation + if(!$buildit) + { + $msg =& new $msgclass('system.methodHelp'); + $msg->addparam(new $valclass($methodname)); + $response =& $client->send($msg, $timeout, $protocol); + if (!$response->faultCode()) + { + $mdesc = $response->value(); + if ($client->return_type != 'phpvals') + { + $mdesc = $mdesc->scalarval(); + } + } + } + + $results = build_remote_method_wrapper_code($client, $methodname, + $xmlrpcfuncname, $msig, $mdesc, $timeout, $protocol, $simple_client_copy, + $prefix, $decode_php_objects, $encode_php_objects, $decode_fault, + $fault_response); + + //print_r($code); + if ($buildit) + { + $allOK = 0; + eval($results['source'].'$allOK=1;'); + // alternative + //$xmlrpcfuncname = create_function('$m', $innercode); + if($allOK) + { + return $xmlrpcfuncname; + } + else + { + error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap remote method '.$methodname); + return false; + } + } + else + { + $results['function'] = $xmlrpcfuncname; + return $results; + } + } + } + } + + /** + * Similar to wrap_xmlrpc_method, but will generate a php class that wraps + * all xmlrpc methods exposed by the remote server as own methods. + * For more details see wrap_xmlrpc_method. + * @param xmlrpc_client $client the client obj all set to query the desired server + * @param array $extra_options list of options for wrapped code + * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriatevoption is set in extra_options) + */ + function wrap_xmlrpc_server($client, $extra_options=array()) + { + $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; + $signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; + $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; + $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; + $newclassname = isset($extra_options['new_class_name']) ? $extra_options['new_class_name'] : ''; + $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; + $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; + $verbatim_client_copy = isset($extra_options['simple_client_copy']) ? !($extra_options['simple_client_copy']) : true; + $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; + $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; + + $msgclass = $prefix.'msg'; + //$valclass = $prefix.'val'; + $decodefunc = 'php_'.$prefix.'_decode'; + + $msg =& new $msgclass('system.listMethods'); + $response =& $client->send($msg, $timeout, $protocol); + if($response->faultCode()) + { + error_log('XML-RPC: could not retrieve method list from remote server'); + return false; + } + else + { + $mlist = $response->value(); + if ($client->return_type != 'phpvals') + { + $mlist = $decodefunc($mlist); + } + if(!is_array($mlist) || !count($mlist)) + { + error_log('XML-RPC: could not retrieve meaningful method list from remote server'); + return false; + } + else + { + // pick a suitable name for the new function, avoiding collisions + if($newclassname != '') + { + $xmlrpcclassname = $newclassname; + } + else + { + $xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), + array('_', ''), $client->server).'_client'; + } + while($buildit && class_exists($xmlrpcclassname)) + { + $xmlrpcclassname .= 'x'; + } + + /// @todo add function setdebug() to new class, to enable/disable debugging + $source = "class $xmlrpcclassname\n{\nvar \$client;\n\n"; + $source .= "function $xmlrpcclassname()\n{\n"; + $source .= build_client_wrapper_code($client, $verbatim_client_copy, $prefix); + $source .= "\$this->client =& \$client;\n}\n\n"; + $opts = array('simple_client_copy' => 2, 'return_source' => true, + 'timeout' => $timeout, 'protocol' => $protocol, + 'encode_php_objs' => $encode_php_objects, 'prefix' => $prefix, + 'decode_php_objs' => $decode_php_objects + ); + /// @todo build javadoc for class definition, too + foreach($mlist as $mname) + { + if ($methodfilter == '' || preg_match($methodfilter, $mname)) + { + $opts['new_function_name'] = preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), + array('_', ''), $mname); + $methodwrap = wrap_xmlrpc_method($client, $mname, $opts); + if ($methodwrap) + { + if (!$buildit) + { + $source .= $methodwrap['docstring']; + } + $source .= $methodwrap['source']."\n"; + } + else + { + error_log('XML-RPC: will not create class method to wrap remote method '.$mname); + } + } + } + $source .= "}\n"; + if ($buildit) + { + $allOK = 0; + eval($source.'$allOK=1;'); + // alternative + //$xmlrpcfuncname = create_function('$m', $innercode); + if($allOK) + { + return $xmlrpcclassname; + } + else + { + error_log('XML-RPC: could not create class '.$xmlrpcclassname.' to wrap remote server '.$client->server); + return false; + } + } + else + { + return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => ''); + } + } + } + } + + /** + * Given the necessary info, build php code that creates a new function to + * invoke a remote xmlrpc method. + * Take care that no full checking of input parameters is done to ensure that + * valid php code is emitted. + * Note: real spaghetti code follows... + * @access private + */ + function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname, + $msig, $mdesc='', $timeout=0, $protocol='', $client_copy_mode=0, $prefix='xmlrpc', + $decode_php_objects=false, $encode_php_objects=false, $decode_fault=false, + $fault_response='') + { + $code = "function $xmlrpcfuncname ("; + if ($client_copy_mode < 2) + { + // client copy mode 0 or 1 == partial / full client copy in emitted code + $innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix); + $innercode .= "\$client->setDebug(\$debug);\n"; + $this_ = ''; + } + else + { + // client copy mode 2 == no client copy in emitted code + $innercode = ''; + $this_ = 'this->'; + } + $innercode .= "\$msg =& new {$prefix}msg('$methodname');\n"; + + if ($mdesc != '') + { + // take care that PHP comment is not terminated unwillingly by method description + $mdesc = "/**\n* ".str_replace('*/', '* /', $mdesc)."\n"; + } + else + { + $mdesc = "/**\nFunction $xmlrpcfuncname\n"; + } + + // param parsing + $plist = array(); + $pcount = count($msig); + for($i = 1; $i < $pcount; $i++) + { + $plist[] = "\$p$i"; + $ptype = $msig[$i]; + if($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' || + $ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null') + { + // only build directly xmlrpcvals when type is known and scalar + $innercode .= "\$p$i =& new {$prefix}val(\$p$i, '$ptype');\n"; + } + else + { + if ($encode_php_objects) + { + $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i, array('encode_php_objs'));\n"; + } + else + { + $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i);\n"; + } + } + $innercode .= "\$msg->addparam(\$p$i);\n"; + $mdesc .= '* @param '.xmlrpc_2_php_type($ptype)." \$p$i\n"; + } + if ($client_copy_mode < 2) + { + $plist[] = '$debug=0'; + $mdesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; + } + $plist = implode(', ', $plist); + $mdesc .= '* @return '.xmlrpc_2_php_type($msig[0])." (or an {$prefix}resp obj instance if call fails)\n*/\n"; + + $innercode .= "\$res =& \${$this_}client->send(\$msg, $timeout, '$protocol');\n"; + if ($decode_fault) + { + if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false))) + { + $respcode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $fault_response)."')"; + } + else + { + $respcode = var_export($fault_response, true); + } + } + else + { + $respcode = '$res'; + } + if ($decode_php_objects) + { + $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value(), array('decode_php_objs'));"; + } + else + { + $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());"; + } + + $code = $code . $plist. ") {\n" . $innercode . "\n}\n"; + + return array('source' => $code, 'docstring' => $mdesc); + } + + /** + * Given necessary info, generate php code that will rebuild a client object + * Take care that no full checking of input parameters is done to ensure that + * valid php code is emitted. + * @access private + */ + function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc') + { + $code = "\$client =& new {$prefix}_client('".str_replace("'", "\'", $client->path). + "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n"; + + // copy all client fields to the client that will be generated runtime + // (this provides for future expansion or subclassing of client obj) + if ($verbatim_client_copy) + { + foreach($client as $fld => $val) + { + if($fld != 'debug' && $fld != 'return_type') + { + $val = var_export($val, true); + $code .= "\$client->$fld = $val;\n"; + } + } + } + // only make sure that client always returns the correct data type + $code .= "\$client->return_type = '{$prefix}vals';\n"; + //$code .= "\$client->setDebug(\$debug);\n"; + return $code; + } +?> \ No newline at end of file diff --git a/includes/xmlrpc/xmlrpcs.inc b/includes/xmlrpc/xmlrpcs.inc new file mode 100644 index 0000000..9588919 --- /dev/null +++ b/includes/xmlrpc/xmlrpcs.inc @@ -0,0 +1,1193 @@ + +// $Id: xmlrpcs.inc,v 1.69 2007/09/20 20:14:25 ggiunta Exp $ + +// Copyright (c) 1999,2000,2002 Edd Dumbill. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// * Neither the name of the "XML-RPC for PHP" nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. + + // XML RPC Server class + // requires: xmlrpc.inc + + $GLOBALS['xmlrpcs_capabilities'] = array( + // xmlrpc spec: always supported + 'xmlrpc' => new xmlrpcval(array( + 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/spec', 'string'), + 'specVersion' => new xmlrpcval(1, 'int') + ), 'struct'), + // if we support system.xxx functions, we always support multicall, too... + // Note that, as of 2006/09/17, the following URL does not respond anymore + 'system.multicall' => new xmlrpcval(array( + 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/discuss/msgReader$1208', 'string'), + 'specVersion' => new xmlrpcval(1, 'int') + ), 'struct'), + // introspection: version 2! we support 'mixed', too + 'introspection' => new xmlrpcval(array( + 'specUrl' => new xmlrpcval('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 'string'), + 'specVersion' => new xmlrpcval(2, 'int') + ), 'struct') + ); + + /* Functions that implement system.XXX methods of xmlrpc servers */ + $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct'])); + $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; + $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec')); + function _xmlrpcs_getCapabilities($server, $m=null) + { + $outAr = $GLOBALS['xmlrpcs_capabilities']; + // NIL extension + if ($GLOBALS['xmlrpc_null_extension']) { + $outAr['nil'] = new xmlrpcval(array( + 'specUrl' => new xmlrpcval('http://www.ontosys.com/xml-rpc/extensions.php', 'string'), + 'specVersion' => new xmlrpcval(1, 'int') + ), 'struct'); + } + return new xmlrpcresp(new xmlrpcval($outAr, 'struct')); + } + + // listMethods: signature was either a string, or nothing. + // The useless string variant has been removed + $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray'])); + $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; + $_xmlrpcs_listMethods_sdoc=array(array('list of method names')); + function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing + { + + $outAr=array(); + foreach($server->dmap as $key => $val) + { + $outAr[]=&new xmlrpcval($key, 'string'); + } + if($server->allow_system_funcs) + { + foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) + { + $outAr[]=&new xmlrpcval($key, 'string'); + } + } + return new xmlrpcresp(new xmlrpcval($outAr, 'array')); + } + + $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); + $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; + $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); + function _xmlrpcs_methodSignature($server, $m) + { + // let accept as parameter both an xmlrpcval or string + if (is_object($m)) + { + $methName=$m->getParam(0); + $methName=$methName->scalarval(); + } + else + { + $methName=$m; + } + if(strpos($methName, "system.") === 0) + { + $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; + } + else + { + $dmap=$server->dmap; $sysCall=0; + } + if(isset($dmap[$methName])) + { + if(isset($dmap[$methName]['signature'])) + { + $sigs=array(); + foreach($dmap[$methName]['signature'] as $inSig) + { + $cursig=array(); + foreach($inSig as $sig) + { + $cursig[]=&new xmlrpcval($sig, 'string'); + } + $sigs[]=&new xmlrpcval($cursig, 'array'); + } + $r=&new xmlrpcresp(new xmlrpcval($sigs, 'array')); + } + else + { + // NB: according to the official docs, we should be returning a + // "none-array" here, which means not-an-array + $r=&new xmlrpcresp(new xmlrpcval('undef', 'string')); + } + } + else + { + $r=&new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); + } + return $r; + } + + $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); + $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; + $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); + function _xmlrpcs_methodHelp($server, $m) + { + // let accept as parameter both an xmlrpcval or string + if (is_object($m)) + { + $methName=$m->getParam(0); + $methName=$methName->scalarval(); + } + else + { + $methName=$m; + } + if(strpos($methName, "system.") === 0) + { + $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; + } + else + { + $dmap=$server->dmap; $sysCall=0; + } + if(isset($dmap[$methName])) + { + if(isset($dmap[$methName]['docstring'])) + { + $r=&new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); + } + else + { + $r=&new xmlrpcresp(new xmlrpcval('', 'string')); + } + } + else + { + $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); + } + return $r; + } + + $_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray'])); + $_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details'; + $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"')); + function _xmlrpcs_multicall_error($err) + { + if(is_string($err)) + { + $str = $GLOBALS['xmlrpcstr']["multicall_${err}"]; + $code = $GLOBALS['xmlrpcerr']["multicall_${err}"]; + } + else + { + $code = $err->faultCode(); + $str = $err->faultString(); + } + $struct = array(); + $struct['faultCode'] =& new xmlrpcval($code, 'int'); + $struct['faultString'] =& new xmlrpcval($str, 'string'); + return new xmlrpcval($struct, 'struct'); + } + + function _xmlrpcs_multicall_do_call($server, $call) + { + if($call->kindOf() != 'struct') + { + return _xmlrpcs_multicall_error('notstruct'); + } + $methName = @$call->structmem('methodName'); + if(!$methName) + { + return _xmlrpcs_multicall_error('nomethod'); + } + if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') + { + return _xmlrpcs_multicall_error('notstring'); + } + if($methName->scalarval() == 'system.multicall') + { + return _xmlrpcs_multicall_error('recursion'); + } + + $params = @$call->structmem('params'); + if(!$params) + { + return _xmlrpcs_multicall_error('noparams'); + } + if($params->kindOf() != 'array') + { + return _xmlrpcs_multicall_error('notarray'); + } + $numParams = $params->arraysize(); + + $msg =& new xmlrpcmsg($methName->scalarval()); + for($i = 0; $i < $numParams; $i++) + { + if(!$msg->addParam($params->arraymem($i))) + { + $i++; + return _xmlrpcs_multicall_error(new xmlrpcresp(0, + $GLOBALS['xmlrpcerr']['incorrect_params'], + $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i)); + } + } + + $result = $server->execute($msg); + + if($result->faultCode() != 0) + { + return _xmlrpcs_multicall_error($result); // Method returned fault. + } + + return new xmlrpcval(array($result->value()), 'array'); + } + + function _xmlrpcs_multicall_do_call_phpvals($server, $call) + { + if(!is_array($call)) + { + return _xmlrpcs_multicall_error('notstruct'); + } + if(!array_key_exists('methodName', $call)) + { + return _xmlrpcs_multicall_error('nomethod'); + } + if (!is_string($call['methodName'])) + { + return _xmlrpcs_multicall_error('notstring'); + } + if($call['methodName'] == 'system.multicall') + { + return _xmlrpcs_multicall_error('recursion'); + } + if(!array_key_exists('params', $call)) + { + return _xmlrpcs_multicall_error('noparams'); + } + if(!is_array($call['params'])) + { + return _xmlrpcs_multicall_error('notarray'); + } + + // this is a real dirty and simplistic hack, since we might have received a + // base64 or datetime values, but they will be listed as strings here... + $numParams = count($call['params']); + $pt = array(); + foreach($call['params'] as $val) + $pt[] = php_2_xmlrpc_type(gettype($val)); + + $result = $server->execute($call['methodName'], $call['params'], $pt); + + if($result->faultCode() != 0) + { + return _xmlrpcs_multicall_error($result); // Method returned fault. + } + + return new xmlrpcval(array($result->value()), 'array'); + } + + function _xmlrpcs_multicall($server, $m) + { + $result = array(); + // let accept a plain list of php parameters, beside a single xmlrpc msg object + if (is_object($m)) + { + $calls = $m->getParam(0); + $numCalls = $calls->arraysize(); + for($i = 0; $i < $numCalls; $i++) + { + $call = $calls->arraymem($i); + $result[$i] = _xmlrpcs_multicall_do_call($server, $call); + } + } + else + { + $numCalls=count($m); + for($i = 0; $i < $numCalls; $i++) + { + $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]); + } + } + + return new xmlrpcresp(new xmlrpcval($result, 'array')); + } + + $GLOBALS['_xmlrpcs_dmap']=array( + 'system.listMethods' => array( + 'function' => '_xmlrpcs_listMethods', + 'signature' => $_xmlrpcs_listMethods_sig, + 'docstring' => $_xmlrpcs_listMethods_doc, + 'signature_docs' => $_xmlrpcs_listMethods_sdoc), + 'system.methodHelp' => array( + 'function' => '_xmlrpcs_methodHelp', + 'signature' => $_xmlrpcs_methodHelp_sig, + 'docstring' => $_xmlrpcs_methodHelp_doc, + 'signature_docs' => $_xmlrpcs_methodHelp_sdoc), + 'system.methodSignature' => array( + 'function' => '_xmlrpcs_methodSignature', + 'signature' => $_xmlrpcs_methodSignature_sig, + 'docstring' => $_xmlrpcs_methodSignature_doc, + 'signature_docs' => $_xmlrpcs_methodSignature_sdoc), + 'system.multicall' => array( + 'function' => '_xmlrpcs_multicall', + 'signature' => $_xmlrpcs_multicall_sig, + 'docstring' => $_xmlrpcs_multicall_doc, + 'signature_docs' => $_xmlrpcs_multicall_sdoc), + 'system.getCapabilities' => array( + 'function' => '_xmlrpcs_getCapabilities', + 'signature' => $_xmlrpcs_getCapabilities_sig, + 'docstring' => $_xmlrpcs_getCapabilities_doc, + 'signature_docs' => $_xmlrpcs_getCapabilities_sdoc) + ); + + $GLOBALS['_xmlrpcs_occurred_errors'] = ''; + $GLOBALS['_xmlrpcs_prev_ehandler'] = ''; + /** + * Error handler used to track errors that occur during server-side execution of PHP code. + * This allows to report back to the client whether an internal error has occurred or not + * using an xmlrpc response object, instead of letting the client deal with the html junk + * that a PHP execution error on the server generally entails. + * + * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors. + * + */ + function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null) + { + // obey the @ protocol + if (error_reporting() == 0) + return; + + //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING) + if($errcode != 2048) // do not use E_STRICT by name, since on PHP 4 it will not be defined + { + $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n"; + } + // Try to avoid as much as possible disruption to the previous error handling + // mechanism in place + if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') + { + // The previous error handler was the default: all we should do is log error + // to the default error log (if level high enough) + if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) + { + error_log($errstring); + } + } + else + { + // Pass control on to previous error handler, trying to avoid loops... + if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') + { + // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers + if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) + { + // the following works both with static class methods and plain object methods as error handler + call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context)); + } + else + { + $GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context); + } + } + } + } + + $GLOBALS['_xmlrpc_debuginfo']=''; + + /** + * Add a string to the debug info that can be later seralized by the server + * as part of the response message. + * Note that for best compatbility, the debug string should be encoded using + * the $GLOBALS['xmlrpc_internalencoding'] character set. + * @param string $m + * @access public + */ + function xmlrpc_debugmsg($m) + { + $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n"; + } + + class xmlrpc_server + { + /// array defining php functions exposed as xmlrpc methods by this server + var $dmap=array(); + /** + * Defines how functions in dmap will be invokde: either using an xmlrpc msg object + * or plain php values. + * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' + */ + var $functions_parameters_type='xmlrpcvals'; + /// controls wether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3 + var $debug = 1; + /** + * When set to true, it will enable HTTP compression of the response, in case + * the client has declared its support for compression in the request. + */ + var $compress_response = false; + /** + * List of http compression methods accepted by the server for requests. + * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib + */ + var $accepted_compression = array(); + /// shall we serve calls to system.* methods? + var $allow_system_funcs = true; + /// list of charset encodings natively accepted for requests + var $accepted_charset_encodings = array(); + /** + * charset encoding to be used for response. + * NB: if we can, we will convert the generated response from internal_encoding to the intended one. + * can be: a supported xml encoding (only UTF-8 and ISO-8859-1 at present, unless mbstring is enabled), + * null (leave unspecified in response, convert output stream to US_ASCII), + * 'default' (use xmlrpc library default as specified in xmlrpc.inc, convert output stream if needed), + * or 'auto' (use client-specified charset encoding or same as request if request headers do not specify it (unless request is US-ASCII: then use library default anyway). + * NB: pretty dangerous if you accept every charset and do not have mbstring enabled) + */ + var $response_charset_encoding = ''; + /// storage for internal debug info + var $debug_info = ''; + /// extra data passed at runtime to method handling functions. Used only by EPI layer + var $user_data = null; + + /** + * @param array $dispmap the dispatch map withd efinition of exposed services + * @param boolean $servicenow set to false to prevent the server from runnung upon construction + */ + function xmlrpc_server($dispMap=null, $serviceNow=true) + { + // if ZLIB is enabled, let the server by default accept compressed requests, + // and compress responses sent to clients that support them + if(function_exists('gzinflate')) + { + $this->accepted_compression = array('gzip', 'deflate'); + $this->compress_response = true; + } + + // by default the xml parser can support these 3 charset encodings + $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); + + // dispMap is a dispatch array of methods + // mapped to function names and signatures + // if a method + // doesn't appear in the map then an unknown + // method error is generated + /* milosch - changed to make passing dispMap optional. + * instead, you can use the class add_to_map() function + * to add functions manually (borrowed from SOAPX4) + */ + if($dispMap) + { + $this->dmap = $dispMap; + if($serviceNow) + { + $this->service(); + } + } + } + + /** + * Set debug level of server. + * @param integer $in debug lvl: determines info added to xmlrpc responses (as xml comments) + * 0 = no debug info, + * 1 = msgs set from user with debugmsg(), + * 2 = add complete xmlrpc request (headers and body), + * 3 = add also all processing warnings happened during method processing + * (NB: this involves setting a custom error handler, and might interfere + * with the standard processing of the php function exposed as method. In + * particular, triggering an USER_ERROR level error will not halt script + * execution anymore, but just end up logged in the xmlrpc response) + * Note that info added at elevel 2 and 3 will be base64 encoded + * @access public + */ + function setDebug($in) + { + $this->debug=$in; + } + + /** + * Return a string with the serialized representation of all debug info + * @param string $charset_encoding the target charset encoding for the serialization + * @return string an XML comment (or two) + */ + function serializeDebug($charset_encoding='') + { + // Tough encoding problem: which internal charset should we assume for debug info? + // It might contain a copy of raw data received from client, ie with unknown encoding, + // intermixed with php generated data and user generated data... + // so we split it: system debug is base 64 encoded, + // user debug info should be encoded by the end user using the INTERNAL_ENCODING + $out = ''; + if ($this->debug_info != '') + { + $out .= "\n"; + } + if($GLOBALS['_xmlrpc_debuginfo']!='') + { + + $out .= "\n"; + // NB: a better solution MIGHT be to use CDATA, but we need to insert it + // into return payload AFTER the beginning tag + //$out .= "', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; + } + return $out; + } + + /** + * Execute the xmlrpc request, printing the response + * @param string $data the request body. If null, the http POST request will be examined + * @return xmlrpcresp the response object (usually not used by caller...) + * @access public + */ + function service($data=null, $return_payload=false) + { + if ($data === null) + { + // workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA + $ver = phpversion(); + if ($ver[0] >= 5) + { + $data = file_get_contents('php://input'); + } + else + { + $data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : ''; + } + } + $raw_data = $data; + + // reset internal debug info + $this->debug_info = ''; + + // Echo back what we received, before parsing it + if($this->debug > 1) + { + $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); + } + + $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); + if (!$r) + { + $r=$this->parseRequest($data, $req_charset); + } + + // save full body of request into response, for more debugging usages + $r->raw_data = $raw_data; + + if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) + { + $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . + $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); + } + + $payload=$this->xml_header($resp_charset); + if($this->debug > 0) + { + $payload = $payload . $this->serializeDebug($resp_charset); + } + + // G. Giunta 2006-01-27: do not create response serialization if it has + // already happened. Helps building json magic + if (empty($r->payload)) + { + $r->serialize($resp_charset); + } + $payload = $payload . $r->payload; + + if ($return_payload) + { + return $payload; + } + + // if we get a warning/error that has output some text before here, then we cannot + // add a new header. We cannot say we are sending xml, either... + if(!headers_sent()) + { + header('Content-Type: '.$r->content_type); + // we do not know if client actually told us an accepted charset, but if he did + // we have to tell him what we did + header("Vary: Accept-Charset"); + + // http compression of output: only + // if we can do it, and we want to do it, and client asked us to, + // and php ini settings do not force it already + $php_no_self_compress = ini_get('zlib.output_compression') == '' && (ini_get('output_handler') != 'ob_gzhandler'); + if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' + && $php_no_self_compress) + { + if(strpos($resp_encoding, 'gzip') !== false) + { + $payload = gzencode($payload); + header("Content-Encoding: gzip"); + header("Vary: Accept-Encoding"); + } + elseif (strpos($resp_encoding, 'deflate') !== false) + { + $payload = gzcompress($payload); + header("Content-Encoding: deflate"); + header("Vary: Accept-Encoding"); + } + } + + // do not ouput content-length header if php is compressing output for us: + // it will mess up measurements + if($php_no_self_compress) + { + header('Content-Length: ' . (int)strlen($payload)); + } + } + else + { + error_log('XML-RPC: xmlrpc_server::service: http headers already sent before response is fully generated. Check for php warning or error messages'); + } + + print $payload; + + // return request, in case subclasses want it + return $r; + } + + /** + * Add a method to the dispatch map + * @param string $methodname the name with which the method will be made available + * @param string $function the php function that will get invoked + * @param array $sig the array of valid method signatures + * @param string $doc method documentation + * @access public + */ + function add_to_map($methodname,$function,$sig=null,$doc='') + { + $this->dmap[$methodname] = array( + 'function' => $function, + 'docstring' => $doc + ); + if ($sig) + { + $this->dmap[$methodname]['signature'] = $sig; + } + } + + /** + * Verify type and number of parameters received against a list of known signatures + * @param array $in array of either xmlrpcval objects or xmlrpc type definitions + * @param array $sig array of known signatures to match against + * @access private + */ + function verifySignature($in, $sig) + { + // check each possible signature in turn + if (is_object($in)) + { + $numParams = $in->getNumParams(); + } + else + { + $numParams = count($in); + } + foreach($sig as $cursig) + { + if(count($cursig)==$numParams+1) + { + $itsOK=1; + for($n=0; $n<$numParams; $n++) + { + if (is_object($in)) + { + $p=$in->getParam($n); + if($p->kindOf() == 'scalar') + { + $pt=$p->scalartyp(); + } + else + { + $pt=$p->kindOf(); + } + } + else + { + $pt= $in[$n] == 'i4' ? 'int' : $in[$n]; // dispatch maps never use i4... + } + + // param index is $n+1, as first member of sig is return type + if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) + { + $itsOK=0; + $pno=$n+1; + $wanted=$cursig[$n+1]; + $got=$pt; + break; + } + } + if($itsOK) + { + return array(1,''); + } + } + } + if(isset($wanted)) + { + return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); + } + else + { + return array(0, "No method signature matches number of parameters"); + } + } + + /** + * Parse http headers received along with xmlrpc request. If needed, inflate request + * @return null on success or an xmlrpcresp + * @access private + */ + function parseRequestHeaders(&$data, &$req_encoding, &$resp_encoding, &$resp_compression) + { + // Play nice to PHP 4.0.x: superglobals were not yet invented... + if(!isset($_SERVER)) + { + $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; + } + + if($this->debug > 1) + { + if(function_exists('getallheaders')) + { + $this->debugmsg(''); // empty line + foreach(getallheaders() as $name => $val) + { + $this->debugmsg("HEADER: $name: $val"); + } + } + + } + + if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) + { + $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']); + } + else + { + $content_encoding = ''; + } + + // check if request body has been compressed and decompress it + if($content_encoding != '' && strlen($data)) + { + if($content_encoding == 'deflate' || $content_encoding == 'gzip') + { + // if decoding works, use it. else assume data wasn't gzencoded + if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) + { + if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) + { + $data = $degzdata; + if($this->debug > 1) + { + $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); + } + } + elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) + { + $data = $degzdata; + if($this->debug > 1) + $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); + } + else + { + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']); + return $r; + } + } + else + { + //error_log('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); + $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']); + return $r; + } + } + } + + // check if client specified accepted charsets, and if we know how to fulfill + // the request + if ($this->response_charset_encoding == 'auto') + { + $resp_encoding = ''; + if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) + { + // here we should check if we can match the client-requested encoding + // with the encodings we know we can generate. + /// @todo we should parse q=0.x preferences instead of getting first charset specified... + $client_accepted_charsets = explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET'])); + // Give preference to internal encoding + $known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII'); + foreach ($known_charsets as $charset) + { + foreach ($client_accepted_charsets as $accepted) + if (strpos($accepted, $charset) === 0) + { + $resp_encoding = $charset; + break; + } + if ($resp_encoding) + break; + } + } + } + else + { + $resp_encoding = $this->response_charset_encoding; + } + + if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) + { + $resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING']; + } + else + { + $resp_compression = ''; + } + + // 'guestimate' request encoding + /// @todo check if mbstring is enabled and automagic input conversion is on: it might mingle with this check??? + $req_encoding = guess_encoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '', + $data); + + return null; + } + + /** + * Parse an xml chunk containing an xmlrpc request and execute the corresponding + * php function registered with the server + * @param string $data the xml request + * @param string $req_encoding (optional) the charset encoding of the xml request + * @return xmlrpcresp + * @access private + */ + function parseRequest($data, $req_encoding='') + { + // 2005/05/07 commented and moved into caller function code + //if($data=='') + //{ + // $data=$GLOBALS['HTTP_RAW_POST_DATA']; + //} + + // G. Giunta 2005/02/13: we do NOT expect to receive html entities + // so we do not try to convert them into xml character entities + //$data = xmlrpc_html_entity_xlate($data); + + $GLOBALS['_xh']=array(); + $GLOBALS['_xh']['ac']=''; + $GLOBALS['_xh']['stack']=array(); + $GLOBALS['_xh']['valuestack'] = array(); + $GLOBALS['_xh']['params']=array(); + $GLOBALS['_xh']['pt']=array(); + $GLOBALS['_xh']['isf']=0; + $GLOBALS['_xh']['isf_reason']=''; + $GLOBALS['_xh']['method']=false; // so we can check later if we got a methodname or not + $GLOBALS['_xh']['rt']=''; + + // decompose incoming XML into request structure + if ($req_encoding != '') + { + if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + // the following code might be better for mb_string enabled installs, but + // makes the lib about 200% slower... + //if (!is_valid_charset($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + { + error_log('XML-RPC: xmlrpc_server::parseRequest: invalid charset encoding of received request: '.$req_encoding); + $req_encoding = $GLOBALS['xmlrpc_defencoding']; + } + /// @BUG this will fail on PHP 5 if charset is not specified in the xml prologue, + // the encoding is not UTF8 and there are non-ascii chars in the text... + /// @todo use an ampty string for php 5 ??? + $parser = xml_parser_create($req_encoding); + } + else + { + $parser = xml_parser_create(); + } + + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); + // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell + // the xml parser to give us back data in the expected charset + // What if internal encoding is not in one of the 3 allowed? + // we use the broadest one, ie. utf8 + // This allows to send data which is native in various charset, + // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding + if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) + { + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); + } + else + { + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); + } + + if ($this->functions_parameters_type != 'xmlrpcvals') + xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); + else + xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); + xml_set_character_data_handler($parser, 'xmlrpc_cd'); + xml_set_default_handler($parser, 'xmlrpc_dh'); + if(!xml_parse($parser, $data, 1)) + { + // return XML error as a faultCode + $r=&new xmlrpcresp(0, + $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser), + sprintf('XML error: %s at line %d, column %d', + xml_error_string(xml_get_error_code($parser)), + xml_get_current_line_number($parser), xml_get_current_column_number($parser))); + xml_parser_free($parser); + } + elseif ($GLOBALS['_xh']['isf']) + { + xml_parser_free($parser); + $r=&new xmlrpcresp(0, + $GLOBALS['xmlrpcerr']['invalid_request'], + $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']); + } + else + { + xml_parser_free($parser); + if ($this->functions_parameters_type != 'xmlrpcvals') + { + if($this->debug > 1) + { + $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++"); + } + $r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']); + } + else + { + // build an xmlrpcmsg object with data parsed from xml + $m=&new xmlrpcmsg($GLOBALS['_xh']['method']); + // now add parameters in + for($i=0; $iaddParam($GLOBALS['_xh']['params'][$i]); + } + + if($this->debug > 1) + { + $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++"); + } + $r = $this->execute($m); + } + } + return $r; + } + + /** + * Execute a method invoked by the client, checking parameters used + * @param mixed $m either an xmlrpcmsg obj or a method name + * @param array $params array with method parameters as php types (if m is method name only) + * @param array $paramtypes array with xmlrpc types of method parameters (if m is method name only) + * @return xmlrpcresp + * @access private + */ + function execute($m, $params=null, $paramtypes=null) + { + if (is_object($m)) + { + $methName = $m->method(); + } + else + { + $methName = $m; + } + $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0); + $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap; + + if(!isset($dmap[$methName]['function'])) + { + // No such method + return new xmlrpcresp(0, + $GLOBALS['xmlrpcerr']['unknown_method'], + $GLOBALS['xmlrpcstr']['unknown_method']); + } + + // Check signature + if(isset($dmap[$methName]['signature'])) + { + $sig = $dmap[$methName]['signature']; + if (is_object($m)) + { + list($ok, $errstr) = $this->verifySignature($m, $sig); + } + else + { + list($ok, $errstr) = $this->verifySignature($paramtypes, $sig); + } + if(!$ok) + { + // Didn't match. + return new xmlrpcresp( + 0, + $GLOBALS['xmlrpcerr']['incorrect_params'], + $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}" + ); + } + } + + $func = $dmap[$methName]['function']; + // let the 'class::function' syntax be accepted in dispatch maps + if(is_string($func) && strpos($func, '::')) + { + $func = explode('::', $func); + } + // verify that function to be invoked is in fact callable + if(!is_callable($func)) + { + error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler is not callable"); + return new xmlrpcresp( + 0, + $GLOBALS['xmlrpcerr']['server_error'], + $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method" + ); + } + + // If debug level is 3, we should catch all errors generated during + // processing of user function, and log them as part of response + if($this->debug > 2) + { + $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler'); + } + if (is_object($m)) + { + if($sysCall) + { + $r = call_user_func($func, $this, $m); + } + else + { + $r = call_user_func($func, $m); + } + if (!is_a($r, 'xmlrpcresp')) + { + error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler does not return an xmlrpcresp object"); + if (is_a($r, 'xmlrpcval')) + { + $r =& new xmlrpcresp($r); + } + else + { + $r =& new xmlrpcresp( + 0, + $GLOBALS['xmlrpcerr']['server_error'], + $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object" + ); + } + } + } + else + { + // call a 'plain php' function + if($sysCall) + { + array_unshift($params, $this); + $r = call_user_func_array($func, $params); + } + else + { + // 3rd API convention for method-handling functions: EPI-style + if ($this->functions_parameters_type == 'epivals') + { + $r = call_user_func_array($func, array($methName, $params, $this->user_data)); + // mimic EPI behaviour: if we get an array that looks like an error, make it + // an eror response + if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) + { + $r =& new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']); + } + else + { + // functions using EPI api should NOT return resp objects, + // so make sure we encode the return type correctly + $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api'))); + } + } + else + { + $r = call_user_func_array($func, $params); + } + } + // the return type can be either an xmlrpcresp object or a plain php value... + if (!is_a($r, 'xmlrpcresp')) + { + // what should we assume here about automatic encoding of datetimes + // and php classes instances??? + $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates'))); + } + } + if($this->debug > 2) + { + // note: restore the error handler we found before calling the + // user func, even if it has been changed inside the func itself + if($GLOBALS['_xmlrpcs_prev_ehandler']) + { + set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']); + } + else + { + restore_error_handler(); + } + } + return $r; + } + + /** + * add a string to the 'internal debug message' (separate from 'user debug message') + * @param string $strings + * @access private + */ + function debugmsg($string) + { + $this->debug_info .= $string."\n"; + } + + /** + * @access private + */ + function xml_header($charset_encoding='') + { + if ($charset_encoding != '') + { + return "\n"; + } + else + { + return "\n"; + } + } + + /** + * A debugging routine: just echoes back the input packet as a string value + * DEPRECATED! + */ + function echoInput() + { + $r=&new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string')); + print $r->serialize(); + } + } +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..12ba2ab --- /dev/null +++ b/index.php @@ -0,0 +1,56 @@ + diff --git a/ipdetails.txt b/ipdetails.txt new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/ipdetails.txt @@ -0,0 +1 @@ + diff --git a/pages/addresses.php b/pages/addresses.php new file mode 100644 index 0000000..c97dfad --- /dev/null +++ b/pages/addresses.php @@ -0,0 +1,74 @@ +adds_block('ADDRESS', array('ADDY' => $addy)); +} + +$template->display(); + +?> diff --git a/pages/admin.php b/pages/admin.php new file mode 100644 index 0000000..ca7a7fa --- /dev/null +++ b/pages/admin.php @@ -0,0 +1,661 @@ +add('ID', $getdraft3['id']); + } else if ($_POST['type'] == 'instant') + { + postBlogPost($_POST['title'], sess_get('uname'), $_POST['tag1'], $_POST['tag2'], $_POST['tag3'], $_POST['text']); + + $getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,1"; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $template = new FITemplate('admin/postSuccess'); + $template->add('ID', $getpost3['id']); + $template->add('CODED', $getpost3['slug']); + } else { + if ($_POST['type'] == 'normal') + { + $getpending = "SELECT * FROM pending ORDER BY id DESC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']+1; + } + } else if ($_POST['type'] == 'priority') + { + $getpending = "SELECT * FROM pending ORDER BY id ASC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']-1; + } + } else { + generateError(404); + } + + $inspending = "INSERT INTO pending (id,title,author,text,tag1,tag2,tag3,slug) VALUES (" . $id . ",\"" . addslashes($_POST['title']) . "\",\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\",\"" . $_POST['tag1'] . "\",\"" . $_POST['tag2'] . "\",\"" . $_POST['tag3'] . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; + $inspending2 = mysql_query($inspending); + + $template = new FITemplate('admin/pendingSuccess'); + $template->add('ID', $id); + } + } + } else if ($_GET['page'] == 'manageDrafts') + { + $template = new FITemplate('admin/manageDrafts'); + + $getdrafts = "SELECT * FROM drafts ORDER BY id ASC"; + $getdrafts2 = mysql_query($getdrafts); + $i=0; + while ($getdrafts3[$i] = mysql_fetch_array($getdrafts2)) + { + $template->adds_block('DRAFT', array( 'TITLE' => $getdrafts3[$i]['title'], + 'AUTHOR' => $getdrafts3[$i]['author'], + 'ID' => $getdrafts3[$i]['id'])); + $i++; + } + } else if ($_GET['page'] == 'editDraft') + { + $getdraft = "SELECT * FROM drafts WHERE id = " . $_GET['id']; + $getdraft2 = mysql_query($getdraft); + $getdraft3 = mysql_fetch_array($getdraft2); + + if ($getdraft3['id'] == $_GET['id']) + { + if (!isset($_GET['submit'])) + { + $template = new FITemplate('admin/editDraft'); + $template->add('ID', $_GET['id']); + $template->add('TEXT', $getdraft3['text']); + $template->add('TAG1', $getdraft3['tag1']); + $template->add('TAG2', $getdraft3['tag2']); + $template->add('TAG3', $getdraft3['tag3']); + $template->add('TITLE', $getdraft3['title']); + } else { + if ($_POST['type'] == 'draft') + { + $setdraft = "UPDATE drafts SET title = \"" . addslashes($_POST['title']) . "\", text = \"" . addslashes($_POST['text']) . "\", tag1 = \"" . $_POST['tag1'] . "\", tag2 = \"" . $_POST['tag2'] . "\", tag3 = \"" . $_POST['tag3'] . "\" WHERE id = " . $_GET['id']; + $setdraft2 = mysql_query($setdraft); + + $template = new FITemplate('admin/draftSuccess'); + $template->add('ID', $_GET['id']); + } else if ($_POST['type'] == 'instant') + { + postBlogPost($_POST['title'], sess_get('uname'), $_POST['tag1'], $_POST['tag2'], $_POST['tag3'], $_POST['text']); + + $deldraft = "DELETE FROM drafts WHERE id = " . $_GET['id']; + $deldraft2 = mysql_query($deldraft); + + $getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,1"; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $template = new FITemplate('admin/postSuccess'); + $template->add('ID', $getpost3['id']); + $template->add('CODED', $getpost3['slug']); + } else { + if ($_POST['type'] == 'normal') + { + $getpending = "SELECT * FROM pending ORDER BY id DESC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']+1; + } + } else if ($_POST['type'] == 'priority') + { + $getpending = "SELECT * FROM pending ORDER BY id ASC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']-1; + } + } else { + generateError(404); + } + + $inspending = "INSERT INTO pending (id,title,author,text,tag1,tag2,tag3,slug) VALUES (" . $id . ",\"" . addslashes($_POST['title']) . "\",\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\",\"" . $_POST['tag1'] . "\",\"" . $_POST['tag2'] . "\",\"" . $_POST['tag3'] . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; + $inspending2 = mysql_query($inspending); + + $deldraft = "DELETE FROM drafts WHERE id = " . $_GET['id']; + $deldraft2 = mysql_query($deldraft); + + $template = new FITemplate('admin/pendingSuccess'); + $template->add('ID', $id); + } + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that draft doesn\'t exist.'); + } + } else if ($_GET['page'] == 'deleteDraft') + { + $getdraft = "SELECT * FROM drafts WHERE id = " . $_GET['id']; + $getdraft2 = mysql_query($getdraft); + $getdraft3 = mysql_fetch_array($getdraft2); + + if ($getdraft3['id'] == $_GET['id']) + { + if (!isset($_GET['submit'])) + { + $template = new FITemplate('admin/deleteDraft'); + $template->add('ID', $_GET['id']); + } else { + $deldraft = "DELETE FROM drafts WHERE id = " . $_GET['id']; + $deldraft2 = mysql_query($deldraft); + + $template = new FITemplate('admin/deletedDraft'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that draft doesn\'t exist.'); + } + } else if ($_GET['page'] == 'viewDraft') + { + $getdraft = "SELECT * FROM drafts WHERE id = " . $_GET['id']; + $getdraft2 = mysql_query($getdraft); + $getdraft3 = mysql_fetch_array($getdraft2); + + if ($getdraft3['id'] == $_GET['id']) + { + $template = new FITemplate('post'); + $template->adds_block('INTERNAL',array('exi'=>1)); + $template->adds_block('POST', array( 'ID' => $getdraft3['id'], + 'YEARID' => ((date('Y')-2006) % 4), + 'DATE' => date('F dS Y \a\\t g:i:s a'), + 'MONTH' => date('M'), + 'DAY' => date('d'), + 'CODED' => $getdraft3['slug'], + 'TITLE' => $getdraft3['title'], + 'AUTHOR' => $getdraft3['author'], + 'TAG1' => $getdraft3['tag1'], + 'TAG2' => $getdraft3['tag2'], + 'TAG3' => $getdraft3['tag3'], + 'RATING' => 0, + 'TEXT' => parseBBCode($getdraft3['text']))); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that draft doesn\'t exist.'); + } + } else if ($_GET['page'] == 'managePending') + { + $template = new FITemplate('admin/managePending'); + + $getpending = "SELECT * FROM pending ORDER BY id ASC"; + $getpending2 = mysql_query($getpending); + $i=0; + while ($getpending3[$i] = mysql_fetch_array($getpending2)) + { + $template->adds_block('PENDING', array( 'TITLE' => $getpending3[$i]['title'], + 'AUTHOR' => $getpending3[$i]['author'], + 'ID' => $getpending3[$i]['id'])); + $i++; + } + } else if ($_GET['page'] == 'editPending') + { + $getpending = "SELECT * FROM pending WHERE id = " . $_GET['id']; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + + if ($getpending3['id'] == $_GET['id']) + { + if (!isset($_GET['submit'])) + { + $template = new FITemplate('admin/editPending'); + $template->add('ID', $_GET['id']); + $template->add('TEXT', $getpending3['text']); + $template->add('TAG1', $getpending3['tag1']); + $template->add('TAG2', $getpending3['tag2']); + $template->add('TAG3', $getpending3['tag3']); + $template->add('TITLE', $getpending3['title']); + } else { + $setpending = "UPDATE pending SET title = \"" . addslashes($_POST['title']) . "\", text = \"" . addslashes($_POST['text']) . "\", tag1 = \"" . $_POST['tag1'] . "\", tag2 = \"" . $_POST['tag2'] . "\", tag3 = \"" . $_POST['tag3'] . "\" WHERE id = " . $_GET['id']; + $setpending2 = mysql_query($setpending); + + $template = new FITemplate('admin/pendingSuccess'); + $template->add('ID', $_GET['id']); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that pending post doesn\'t exist.'); + } + } else if ($_GET['page'] == 'deletePending') + { + $getpending = "SELECT * FROM pending WHERE id = " . $_GET['id']; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + + if ($getpending3['id'] == $_GET['id']) + { + if (!isset($_GET['submit'])) + { + $template = new FITemplate('admin/deletePending'); + $template->add('ID', $_GET['id']); + } else { + $delpending = "DELETE FROM pending WHERE id = " . $_GET['id']; + $delpending2 = mysql_query($delpending); + + $template = new FITemplate('admin/deletedPending'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that pending post doesn\'t exist.'); + } + } else if ($_GET['page'] == 'viewPending') + { + $getpending = "SELECT * FROM pending WHERE id = " . $_GET['id']; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + + if ($getpending3['id'] == $_GET['id']) + { + $template = new FITemplate('post'); + $template->adds_block('INTERNAL',array('exi'=>1)); + $template->adds_block('POST', array( 'ID' => $getpending3['id'], + 'YEARID' => ((date('Y')-2006) % 4), + 'DATE' => date('F dS Y \a\\t g:i:s a'), + 'MONTH' => date('M'), + 'DAY' => date('d'), + 'CODED' => $getpending3['slug'], + 'TITLE' => $getpending3['title'], + 'AUTHOR' => $getpending3['author'], + 'TAG1' => $getpending3['tag1'], + 'TAG2' => $getpending3['tag2'], + 'TAG3' => $getpending3['tag3'], + 'RATING' => 0, + 'TEXT' => parseBBCode($getpending3['text']))); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that pending post doesn\'t exist.'); + } + } else if ($_GET['page'] == 'managePosts') + { + $template = new FITemplate('admin/managePosts'); + + $getposts = "SELECT * FROM updates ORDER BY id ASC"; + $getposts2 = mysql_query($getposts); + $i=0; + while ($getposts3[$i] = mysql_fetch_array($getposts2)) + { + $template->adds_block('POST', array( 'TITLE' => $getposts3[$i]['title'], + 'AUTHOR' => $getposts3[$i]['author'], + 'ID' => $getposts3[$i]['id'], + 'CODED' => $getposts3[$i]['slug'])); + $i++; + } + } else if ($_GET['page'] == 'editPost') + { + $getpost = "SELECT * FROM updates WHERE id = " . $_GET['id']; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + if ($getpost3['id'] == $_GET['id']) + { + if (!isset($_GET['submit'])) + { + $template = new FITemplate('admin/editPost'); + $template->add('ID', $_GET['id']); + $template->add('TEXT', $getpost3['text']); + $template->add('TAG1', $getpost3['tag1']); + $template->add('TAG2', $getpost3['tag2']); + $template->add('TAG3', $getpost3['tag3']); + $template->add('TITLE', $getpost3['title']); + } else { + $setpost = "UPDATE updates SET title = \"" . addslashes($_POST['title']) . "\", text = \"" . addslashes($_POST['text']) . "\", tag1 = \"" . $_POST['tag1'] . "\", tag2 = \"" . $_POST['tag2'] . "\", tag3 = \"" . $_POST['tag3'] . "\" WHERE id = " . $_GET['id']; + $setpost2 = mysql_query($setpost); + + $template = new FITemplate('admin/postSuccess'); + $template->add('ID', $_GET['id']); + $template->add('CODED', $getpost3['slug']); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that post doesn\'t exist.'); + } + } else if ($_GET['page'] == 'deletePost') + { + $getpost = "SELECT * FROM updates WHERE id = " . $_GET['id']; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + if ($getpost3['id'] == $_GET['id']) + { + if (!isset($_GET['submit'])) + { + $template = new FITemplate('admin/deletePost'); + $template->add('ID', $_GET['id']); + } else { + $delpost = "DELETE FROM updates WHERE id = " . $_GET['id']; + $delpost2 = mysql_query($delpost); + + $template = new FITemplate('admin/deletedPost'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that post doesn\'t exist.'); + } + } else if ($_GET['page'] == 'moderateComments') + { + $template = new FITemplate('admin/moderateComments'); + + $getcomments = "SELECT * FROM moderation ORDER BY id ASC"; + $getcomments2 = mysql_query($getcomments); + $i=0; + while ($getcomments3[$i] = mysql_fetch_array($getcomments2)) + { + $comType = substr($getcomments3[$i]['page_id'],0,strpos($getcomments3[$i]['page_id'],'-')); + $comID = substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); + + if ($comType == 'updates') + { + $getpost = "SELECT * FROM updates WHERE id = " . $comID; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + $title = $getpost3['title']; + } else if ($comType = 'polloftheweek') + { + $getpoll = "SELECT * FROM polloftheweek WHERE id = " . $comID; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + $title = $getpoll3['question']; + } else if ($comType = 'quotes') + { + $getquote = "SELECT * FROM rash_quotes WHERE id = " . $comID; + $getquote2 = mysql_query($getquote); + $getquote3 = mysql_fetch_array($getquote2); + $title = '#' . $getquote3['id']; + } + + $template->adds_block('COMMENT', array( 'TITLE' => $title, + 'AUTHOR' => $getcomments3[$i]['author'], + 'ID' => $getcomments3[$i]['id'])); + $i++; + } + } else if ($_GET['page'] == 'viewComment') + { + $getcomment = "SELECT * FROM moderation WHERE id = " . $_GET['id']; + $getcomment2 = mysql_query($getcomment); + $getcomment3 = mysql_fetch_array($getcomment2); + + if ($getcomment3['id'] == $_GET['id']) + { + $getuser = "SELECT * FROM users WHERE username = \"" . $getcomment3['author'] . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + $template = new FITemplate('admin/viewComment'); + $template->add('ID', $_GET['id']); + $template->add('USERNAME', $getcomment3['author']); + $template->add('CODEDEMAIL', md5(strtolower($getuser3['email']))); + $template->add('TEXT', parseBBCode($getcomment3['comment'])); + $template->add('DATE', date("F dS Y \a\\t g:i:s a",strtotime($getcomment3['pubDate']))); + $template->add('CODEDDEF',urlencode('http://www.fourisland.com/images/error404.png')); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that comment doesn\'t exist.'); + } + } else if ($_GET['page'] == 'actionComment') + { + $getcomment = "SELECT * FROM moderation WHERE id = " . $_GET['id']; + $getcomment2 = mysql_query($getcomment); + $getcomment3 = mysql_fetch_array($getcomment2); + + if ($getcomment3['id'] == $_GET['id']) + { + if (isset($_GET['approve'])) + { + $insanon = "INSERT INTO anon_commenters (username,email,website) VALUES (\"" . $getcomment3['author'] . "\",\"" . $getcomment3['email'] . "\",\"" . $getcomment3['website'] . "\")"; + $insanon2 = mysql_query($insanon); + + $inscomment = "INSERT INTO comments (page_id,username,comment) VALUES (\"" . $getcomment3['page_id'] . "\",\"" . $getcomment3['author'] . "\",\"" . $getcomment3['comment'] . "\")"; + $inscomment2 = mysql_query($inscomment); + + $delcomment = "DELETE FROM moderation WHERE id = " . $getcomment3['id']; + $delcomment2 = mysql_query($delcomment); + + $template = new FITemplate('msg'); + $template->add('BACK', 'Comment Moderation'); + $template->add('MSG', 'You\'ve successfully approved this comment.'); + } else if (isset($_GET['deny'])) + { + $delcomment = "DELETE FROM moderation WHERE id = " . $getcomment3['id']; + $delcomment2 = mysql_query($delcomment); + + $template = new FITemplate('msg'); + $template->add('BACK', 'Comment Moderation'); + $template->add('MSG', 'You\'ve successfully denied this comment.'); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', "Um, what on earth are you doing?"); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, that comment doesn\'t exist.'); + } + } else if ($_GET['page'] == 'managePages') + { + $template = new FITemplate('admin/managePages'); + + $getpages = "SELECT wiki_pages.*, wiki_revisions.author FROM wiki_pages, wiki_revisions WHERE wiki_revisions.id = wiki_pages.revision ORDER BY id ASC"; + $getpages2 = mysql_query($getpages); + $i=0; $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, but this page doesn\'t exist.'); + while ($getpages3[$i] = mysql_fetch_array($getpages2)) + { + $template->adds_block('PAGE', array( 'TITLE' => $getpages3[$i]['title'], + 'AUTHOR' => $getpages3[$i]['author'], + 'ID' => $getpages3[$i]['id'], + 'CODED' => $getpages3[$i]['slug'])); + $i++; + } + } else if ($_GET['page'] == 'pageHistory') + { + $getpage = "SELECT * FROM wiki_pages WHERE id = " . $_GET['id'] . " ORDER BY id ASC"; + $getpage2 = mysql_query($getpage); + $getpage3 = mysql_fetch_array($getpage2); + + if ($getpage3['id'] == $_GET['id']) + { + $template = new FITemplate('admin/pageHistory'); + + $getrev = "SELECT * FROM wiki_revisions WHERE id = " . $getpage3['revision']; + $getrev2 = mysql_query($getrev); + $getrev3 = mysql_fetch_array($getrev2); + + $template->adds_block('REV', array( 'AUTHOR' => $getrev3['author'], + 'DATE' => date("F dS Y \a\\t g:i:s a",strtotime($getrev3['pubDate'])), + 'ID' => $getrev3['id'])); + + while ($getrev3['previous'] != 0) + { + $getrev = "SELECT * FROM wiki_revisions WHERE id = " . $getrev3['previous']; + $getrev2 = mysql_query($getrev); + $getrev3 = mysql_fetch_array($getrev2); + + $template->adds_block('REV', array( 'AUTHOR' => $getrev3['author'], + 'DATE' => date("F dS Y \a\\t g:i:s a",strtotime($getrev3['pubDate'])), + 'ID' => $getrev3['id'])); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, but this page doesn\'t exist.'); + } + } else if ($_GET['page'] == 'viewRevision') + { + $getrev = "SELECT * FROM wiki_revisions WHERE id = " . $_GET['id']; + $getrev2 = mysql_query($getrev); + $getrev3 = mysql_fetch_array($getrev2); + + if ($getrev3['id'] == $_GET['id']) + { + $template = new FITemplate('admin/viewRevision'); + $template->add('TEXT', $getrev3['text']); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, but this revision doesn\'t exist.'); + } + } else if ($_GET['page'] == 'pollProcess') + { + if (!isset($_GET['step'])) + { + $template = new FITemplate('admin/pollrss'); + } else if ($_GET['step'] == 2) + { + $insrss = "INSERT INTO pollrss (author,rss) VALUES (\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\")"; + $insrss2 = mysql_query($insrss); + + $template = new FITemplate('admin/newPoll'); + } else if ($_GET['step'] == 3) + { + $inspoll = "INSERT INTO polloftheweek (question,option1,option2,option3,option4) VALUES (\"" . addslashes($_POST['question']) . "\",\"" . $_POST['option1'] . "\",\"" . $_POST['option2'] . "\",\"" . $_POST['option3'] . "\",\"" . $_POST['option4'] . "\")"; + $inspoll2 = mysql_query($inspoll); + + $cleardid = "TRUNCATE TABLE didpollalready"; + $cleardid2 = mysql_query($cleardid); + + $template = new FITemplate('msg2'); + $template->add('BACK', 'Back to the Admin Panel'); + $template->add('LINK', '/admin/'); + $template->add('MSG', "You've successfully created a poll!"); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', "Um, what on earth are you doing?"); + } + } else if ($_GET['page'] == 'managePendingQuotes') + { + $template = new FITemplate('admin/managePendingQuotes'); + + $getpending = "SELECT * FROM rash_queue ORDER BY id ASC"; + $getpending2 = mysql_query($getpending); + $i=0; + while ($getpending3[$i] = mysql_fetch_array($getpending2)) + { + $template->adds_block('QUOTE', array( 'ID' => $getpending3[$i]['id'], + 'TEXT' => $getpending3[$i]['quote'])); + $i++; + } + } else if ($_GET['page'] == 'actionPendingQuotes') + { + $getpending = "SELECT * FROM rash_queue WHERE id = " . $_GET['id']; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + + if ($getpending3['id'] == $_GET['id']) + { + if (isset($_GET['approve'])) + { + $insquote = "INSERT INTO rash_quotes (quote) VALUES (\"" . addslashes($getpending3['quote']) . "\")"; + $insquote2 = mysql_query($insquote); + + $delpending = "DELETE FROM rash_queue WHERE id = " . $_GET['id']; + $delpending2 = mysql_query($delpending); + + $template = new FITemplate('msg2'); + $template->add('BACK', 'Back to the Admin Panel'); + $template->add('LINK', '/admin/'); + $template->add('MSG', "You've successfully approved this quote."); + } else if (isset($_GET['deny'])) + { + $delpending = "DELETE FROM rash_queue WHERE id = " . $_GET['id']; + $delpending2 = mysql_query($delpending); + + $template = new FITemplate('msg2'); + $template->add('BACK', 'Back to the Admin Panel'); + $template->add('LINK', '/admin/'); + $template->add('MSG', "You've successfully denied this quote."); + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', "Um, what on earth are you doing?"); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK', 'the previous page'); + $template->add('MSG', 'I\'m sorry, but this pending quote doesn\'t exist.'); + } + } else { + generateError(404); + } + @$template->display(); + } else { + generateError(404); + } +} else { + generateError(404); +} + +?> diff --git a/pages/blog.php b/pages/blog.php new file mode 100644 index 0000000..93d5dc6 --- /dev/null +++ b/pages/blog.php @@ -0,0 +1,197 @@ +adds_block('INTERNAL',array('exi'=>1)); + + $getpost = "SELECT * FROM updates WHERE slug = \"" . urldecode($_GET['post']) . "\""; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + if ($getpost3['slug'] == urldecode($_GET['post'])) + { + updatePop($getpost3['id'],'views'); + + $title = stripslashes($getpost3['title']) . ' - Blog Archive'; + + $getback = "SELECT * FROM updates WHERE id = " . ($getpost3['id']-1); + $getback2 = mysql_query($getback); + $getback3 = mysql_fetch_array($getback2); + if (isset($getback3['title'])) + { + $template->adds_block('BACK', array( 'CODED' => $getback3['slug'], + 'TITLE' => $getback3['title'])); + } + + $getnext = "SELECT * FROM updates WHERE id = " . ($getpost3['id']+1); + $getnext2 = mysql_query($getnext); + $getnext3 = mysql_fetch_array($getnext2); + if (isset($getnext3['title'])) + { + $template->adds_block('NEXT', array( 'CODED' => $getnext3['slug'], + 'TITLE' => $getnext3['title'])); + } + + $template->adds_block('POST', array( 'ID' => $getpost3['id'], + 'YEARID' => ((date('Y',strtotime($getpost3['pubDate']))-2006) % 4), + 'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getpost3['pubDate'])), + 'MONTH' => date('M',strtotime($getpost3['pubDate'])), + 'DAY' => date('d',strtotime($getpost3['pubDate'])), + 'CODED' => $getpost3['slug'], + 'TITLE' => $getpost3['title'], + 'AUTHOR' => $getpost3['author'], + 'TAG1' => $getpost3['tag1'], + 'TAG2' => $getpost3['tag2'], + 'TAG3' => $getpost3['tag3'], + 'RATING' => $getpost3['rating'], + 'TEXT' => parseBBCode($getpost3['text']))); + + $template->display(); + $page_id = 'updates-' . $getpost3['id']; + include('includes/comments.php'); + + $getrelated = "SELECT *, MATCH (title, text) AGAINST (\"" . addslashes($getpost3['title']) . "\") AS score FROM updates WHERE MATCH (title, text) AGAINST (\"" . addslashes($getpost3['title']) . "\") AND id <> " . $getpost3['id'] . " LIMIT 0,5"; + $getrelated2 = mysql_query($getrelated); + $i=0; + while ($getrelated3[$i] = mysql_fetch_array($getrelated2)) + { + if ($i==0) + { + $template = new FITemplate('related'); + } + + $template->adds_block('POST', array( 'TITLE' => $getrelated3[$i]['title'], + 'CODED' => $getrelated3[$i]['slug'], + 'AUTHOR' => $getrelated3[$i]['author'], + 'DATE' => date('F d<\S\U\P>S Y',strtotime($getrelated3[$i]['pubDate'])))); + $i++; + } + + if ($i > 0) + { + $template->display(); + } + } else { + generateError('404'); + } +} else { + $template = new FITemplate('archive'); + if (isset($_GET['author'])) + { + $title = 'Author: ' . $_GET['author'] . ' - Blog Archive'; + $getposts = "SELECT * FROM updates WHERE author = \"" . $_GET['author'] . "\" ORDER BY id DESC"; + $getbio = "SELECT * FROM bio WHERE username = \"" . $_GET['author'] . "\""; + $getbio2 = mysql_query($getbio); + $getbio3 = mysql_fetch_array($getbio2); + if ($getbio3['username'] == $_GET['author']) + { + $template->adds_block('BIO', array( 'TEXT' => $getbio3['text'], + 'USERNAME' => $getbio3['username'], + 'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getbio3['lastUpdated'])))); + } + } elseif (isset($_GET['tag'])) + { + $title = 'Tag: ' . $_GET['tag'] . ' - Blog Archive'; + $getposts = "SELECT * FROM updates WHERE tag1 = \"" . $_GET['tag'] . "\" OR tag2 = \"" . $_GET['tag'] . "\" OR tag3 = \"" . $_GET['tag'] . "\" ORDER BY id DESC"; + } else { + $title = 'Blog Archive'; + $getposts = "SELECT * FROM updates ORDER BY id DESC"; + } + $getposts2 = mysql_query($getposts); + $i=0; + while ($getposts3[$i] = mysql_fetch_array($getposts2)) + { + if ((!isset($lastmonth)) || ($lastmonth != date('m-Y',strtotime($getposts3[$i]['pubDate'])))) + { + if (!isset($curID)) + { + $curID = 0; + } else { + $curID++; + } + $template->add_ref($curID, 'MONTH', array('TITLE' => date('F Y',strtotime($getposts3[$i]['pubDate'])))); + if ($curID == 0) + { + $template->adds_ref_sub($curID, 'BIGEND',array('exi'=>1)); + } + $lastmonth = date('m-Y',strtotime($getposts3[$i]['pubDate'])); + } + + $page_id = 'updates-' . $getposts3[$i]['id']; + $getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; + $getcomments2 = mysql_query($getcomments); + $total_post=0; + while ($getcomments3[$total_post] = mysql_fetch_array($getcomments2)) + { + $total_post++; + } + if ($total_post >= 2) + { + $plural = 's'; + } + if ($total_post == 0) + { + $comText = 'No Comments'; + } elseif ($total_post == 1) + { + $comText = '1 Comment'; + } else { + $comText = $total_post . ' Comments'; + } + + if ($curID == 0) + { + $template->adds_ref_sub($curID, 'BIG',array( 'DATE' => date('m-d-Y',strtotime($getposts3[$i]['pubDate'])), + 'CODED' => $getposts3[$i]['slug'], + 'TITLE' => $getposts3[$i]['title'], + 'ID' => $getposts3[$i]['id'], + 'YEARID' => ((date('Y',strtotime($getposts3[$i]['pubDate']))-2006) % 4), + 'MONTH' => date('M',strtotime($getposts3[$i]['pubDate'])), + 'DAY' => date('d',strtotime($getposts3[$i]['pubDate'])), + 'AUTHOR' => $getposts3[$i]['author'], + 'PLURALCOMMENT' => (isset($plural) ? $plural : ''), + 'COMMENTS' => $comText, + 'TAG1' => $getposts3[$i]['tag1'], + 'TAG2' => $getposts3[$i]['tag2'], + 'TAG3' => $getposts3[$i]['tag3'])); + } else { + $template->adds_ref_sub($curID, 'SMALL',array( 'DATE' => date('m-d-Y',strtotime($getposts3[$i]['pubDate'])), + 'CODED' => $getposts3[$i]['slug'], + 'TITLE' => $getposts3[$i]['title'])); + } + $i++; + } + if ($i==0) + { + generateError('404'); + } + $template->display(); +} + +?> diff --git a/pages/comic.php b/pages/comic.php new file mode 100644 index 0000000..103cb17 --- /dev/null +++ b/pages/comic.php @@ -0,0 +1,177 @@ +adds_block('INTERNAL',array('exi'=>1)); + + $getcomic = "SELECT * FROM comic WHERE slug = \"" . urldecode($_GET['comic']) . "\""; + $getcomic2 = mysql_query($getcomic); + $getcomic3 = mysql_fetch_array($getcomic2); + + if ($getcomic3['slug'] == urldecode($_GET['comic'])) + { + $title = stripslashes($getcomic3['title']) . ' - Kirby Fan Mail'; + + $getback = "SELECT * FROM comic WHERE id = " . ($getcomic3['id']-1); + $getback2 = mysql_query($getback); + $getback3 = mysql_fetch_array($getback2); + if (isset($getback3['title'])) + { + $template->adds_block('BACK', array( 'CODED' => $getback3['slug'], + 'TITLE' => $getback3['title'])); + } + + $getnext = "SELECT * FROM comic WHERE id = " . ($getcomic3['id']+1); + $getnext2 = mysql_query($getnext); + $getnext3 = mysql_fetch_array($getnext2); + if (isset($getnext3['title'])) + { + $template->adds_block('NEXT', array( 'CODED' => $getnext3['slug'], + 'TITLE' => $getnext3['title'])); + } + + if (stripos($getcomic3['image'], 'gif') !== FALSE) + { + $mode = 'scalegif'; + } else { + $mode = 'scale'; + } + + $template->adds_block('COMIC', array( 'ID' => $getcomic3['id'], + 'YEARID' => ((date('Y',strtotime($getcomic3['pubDate']))-2006) % 4), + 'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getcomic3['pubDate'])), + 'MONTH' => date('M',strtotime($getcomic3['pubDate'])), + 'DAY' => date('d',strtotime($getcomic3['pubDate'])), + 'CODED' => $getcomic3['slug'], + 'TITLE' => $getcomic3['title'], + 'RATING' => $getcomic3['rating'], + 'TEXT' => parseBBCode($getcomic3['text']), + 'IMAGE' => $getcomic3['image'], + 'MODE' => $mode)); + + $template->display(); + $page_id = 'kfm-' . $getcomic3['id']; + include('includes/comments.php'); + + $getrelated = "SELECT *, MATCH (title, text) AGAINST (\"" . addslashes($getcomic3['title']) . "\") AS score FROM comic WHERE MATCH (title, text) AGAINST (\"" . addslashes($getcomic3['title']) . "\") AND id <> " . $getcomic3['id'] . " LIMIT 0,5"; + $getrelated2 = mysql_query($getrelated); + $i=0; + while ($getrelated3[$i] = mysql_fetch_array($getrelated2)) + { + if ($i==0) + { + $template = new FITemplate('related'); + } + + $template->adds_block('POST', array( 'TITLE' => $getrelated3[$i]['title'], + 'CODED' => $getrelated3[$i]['slug'], + 'AUTHOR' => 'Hatkirby', + 'DATE' => date('F d<\S\U\P>S Y',strtotime($getrelated3[$i]['pubDate'])))); + $i++; + } + + if ($i > 0) + { + $template->display(); + } + } else { + generateError('404'); + } +} else { + $template = new FITemplate('comicarchive'); + $title = 'Kirby Fan Mail'; + $getcomics = "SELECT * FROM comic ORDER BY id DESC"; + $getcomics2 = mysql_query($getcomics); + $i=0; + while ($getcomics3[$i] = mysql_fetch_array($getcomics2)) + { + if ((!isset($lastmonth)) || ($lastmonth != date('m-Y',strtotime($getcomics3[$i]['pubDate'])))) + { + if (!isset($curID)) + { + $curID = 0; + } else { + $curID++; + } + $template->add_ref($curID, 'MONTH', array('TITLE' => date('F Y',strtotime($getcomics3[$i]['pubDate'])))); + if ($curID == 0) + { + $template->adds_ref_sub($curID, 'BIGEND',array('exi'=>1)); + } + $lastmonth = date('m-Y',strtotime($getcomics3[$i]['pubDate'])); + } + + $page_id = 'kfm-' . $getcomics3[$i]['id']; + $getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; + $getcomments2 = mysql_query($getcomments); + $total_post=0; + while ($getcomments3[$total_post] = mysql_fetch_array($getcomments2)) + { + $total_post++; + } + if ($total_post >= 2) + { + $plural = 's'; + } + if ($total_post == 0) + { + $comText = 'No Comments'; + } elseif ($total_post == 1) + { + $comText = '1 Comment'; + } else { + $comText = $total_post . ' Comments'; + } + + if ($curID == 0) + { + $template->adds_ref_sub($curID, 'BIG',array( 'DATE' => date('m-d-Y',strtotime($getcomics3[$i]['pubDate'])), + 'CODED' => $getcomics3[$i]['slug'], + 'TITLE' => $getcomics3[$i]['title'], + 'ID' => $getcomics3[$i]['id'], + 'YEARID' => ((date('Y',strtotime($getcomics3[$i]['pubDate']))-2006) % 4), + 'MONTH' => date('M',strtotime($getcomics3[$i]['pubDate'])), + 'DAY' => date('d',strtotime($getcomics3[$i]['pubDate'])), + 'AUTHOR' => 'Hatkirby', + 'PLURALCOMMENT' => (isset($plural) ? $plural : ''), + 'COMMENTS' => $comText)); + } else { + $template->adds_ref_sub($curID, 'SMALL',array( 'DATE' => date('m-d-Y',strtotime($getcomics3[$i]['pubDate'])), + 'CODED' => $getcomics3[$i]['slug'], + 'TITLE' => $getcomics3[$i]['title'])); + } + $i++; + } + if ($i==0) + { + generateError('404'); + } + $template->display(); +} + +?> diff --git a/pages/error.php b/pages/error.php new file mode 100644 index 0000000..7f6c505 --- /dev/null +++ b/pages/error.php @@ -0,0 +1,84 @@ +adds_block('NOREFERER',array('exi'=>1)); + } else { + if ((strpos($strReferer,".looksmart.co")>0) || (strpos($strReferer,".ifind.freeserve")>0) || (strpos($strReferer,".ask.co")>0) || (strpos($strReferer,"google.co")>0) || (strpos($strReferer,"altavista.co")>0) || (strpos($strReferer,"msn.co")>0) || (strpos($strReferer,"yahoo.co")>0)) + { + $arrSite = split("/",$strReferer); + $arrParams = split("?",$strReferer); + $strSearchTerms = $arrParams[1]; + $arrParams = split("&",$strSearchTerms); + $strSite = $arrSite[2]; + $sQryStr=""; + $arrQueryStrings = array("q=","p=","ask=","key="); + + for ($i=0;$iadds_block('SEARCHREF',array( 'REF' => $strReferer, + 'SITE' => $strSite, + 'TERMS' => $strSearchTerms)); + } else { + $strSite = $strReferer; + $strSite = split("/",$strSite); + $strSite = $strSite[2]; + + if (preg_match('/fourisland\.com/',$strSite) == 1) + { + $template->adds_block('OURBAD',array('exi'=>1)); + } + $template->adds_block('NORMALREF',array( 'REF' => $strReferer, + 'SITE' => $strSite)); + } + } + + $template->display(); +} diff --git a/pages/fourm.php b/pages/fourm.php new file mode 100644 index 0000000..41ae0a1 --- /dev/null +++ b/pages/fourm.php @@ -0,0 +1,27 @@ + diff --git a/pages/holidates.php b/pages/holidates.php new file mode 100644 index 0000000..29b0ca4 --- /dev/null +++ b/pages/holidates.php @@ -0,0 +1,10 @@ + $val) +{ + $date = sd_clearDate(); + $date += ($num*60*60*24); + echo(''); +} + +?>
    IDDateHolidate
    ' . $num . '' . date('F jS',$date) . '' . $val . '
    diff --git a/pages/login.php b/pages/login.php new file mode 100644 index 0000000..6270502 --- /dev/null +++ b/pages/login.php @@ -0,0 +1,64 @@ +add('REDIRECT',$_GET['redirect']); + + $template->add('RECAPTCHA',recaptcha_get_html($publickey)); +} else { + $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); + if (!$resp->is_valid) + { + $template = new FITemplate('login'); + $template->add('REDIRECT',$_GET['redirect']); + $template->adds_block('ERROR',array('msg' => "The reCAPTCHA wasn't entered correctly. Go back and try it again. (reCAPTCHA said: " . $resp->error . ")")); + + $template->add('RECAPTCHA',recaptcha_get_html($publickey)); + } else { + if (verifyUser($_POST['username'], $_POST['password'])) + { + sess_set('uname',$_POST['username']); + header('Location: ' . rawurldecode($_POST['redirect'])); + exit; + } else { + $template = new FITemplate('login'); + $template->add('REDIRECT',$_POST['redirect']); + $template->adds_block('ERROR',array('MSG' => "The username/password pair didn't resolve to a real user. Try logging on again, spelling the password right, or making sure you actually have an a account.")); + + $template->add('RECAPTCHA',recaptcha_get_html($publickey)); + } + } +} + +$template->display(); + +?> diff --git a/pages/logout.php b/pages/logout.php new file mode 100644 index 0000000..69b9386 --- /dev/null +++ b/pages/logout.php @@ -0,0 +1,28 @@ + diff --git a/pages/poll.php b/pages/poll.php new file mode 100644 index 0000000..67f51a8 --- /dev/null +++ b/pages/poll.php @@ -0,0 +1,85 @@ +adds_block('POLL', array( 'ID' => $getpolls3[$i]['id'], + 'QUESTION' => $getpolls3[$i]['question'], + 'WEEK' => date('F jS Y', strtotime($getpolls3[$i]['week'])))); + $i++; + } + + include('pages/polloftheweek.php'); + + $template->display(); +} else { + $template = new FITemplate('poll'); + + $getpoll = "SELECT * FROM polloftheweek WHERE id = " . $_GET['id']; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + + $template->add('QUESTION', $getpoll3['question']); + + $getrss = "SELECT * FROM pollrss WHERE id = " . $_GET['id']; + $getrss2 = mysql_query($getrss); + $getrss3 = mysql_fetch_array($getrss2); + + if ($getrss3['id'] == $_GET['id']) + { + $template->adds_block('COMPLETE', array( 'RSS' => parseBBCode($getrss3['rss']), + 'AUTHOR' => $getrss3['author'], + 'DATE' => date("F dS Y \a\\t g:i:s a",strtotime($getrss3['date'])), + 'OPTION1' => $getpoll3['option1'], + 'OPTION2' => $getpoll3['option2'], + 'OPTION3' => $getpoll3['option3'], + 'OPTION4' => $getpoll3['option4'], + 'CLICKS1' => $getpoll3['clicks1'], + 'CLICKS2' => $getpoll3['clicks2'], + 'CLICKS3' => $getpoll3['clicks3'], + 'CLICKS4' => $getpoll3['clicks4'])); + } else { + $template->adds_block('INCOMPLETE', array('exi'=>1)); + } + + $forceDisplay = $_GET['id']; + include('pages/polloftheweek.php'); + unset($forceDisplay); + + $template->display(); + + $page_id = 'polloftheweek-' . $getpoll3['id']; + include('includes/comments.php'); +} + +?> diff --git a/pages/polloftheweek.php b/pages/polloftheweek.php new file mode 100644 index 0000000..930f346 --- /dev/null +++ b/pages/polloftheweek.php @@ -0,0 +1,73 @@ +add('QUESTION', $getpoll3['question']); + $template->add('OPTION1', $getpoll3['option1']); + $template->add('OPTION2', $getpoll3['option2']); + $template->add('OPTION3', $getpoll3['option3']); + $template->add('OPTION4', $getpoll3['option4']); + + $getip = "SELECT * FROM didpollalready WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $getip2 = mysql_query($getip); + $getip3 = mysql_fetch_array($getip2); + + if (($getip3['ip'] != $_SERVER['REMOTE_ADDR']) && (!isset($forceDisplay))) + { + $template->adds_block('FORM',array('exi'=>1)); + } else { + $template->adds_block('DISPLAY',array('exi'=>1)); + + $template->add('PERCENT1', getpercent($getpoll3,'1')); + $template->add('PERCENT2', getpercent($getpoll3,'2')); + $template->add('PERCENT3', getpercent($getpoll3,'3')); + $template->add('PERCENT4', getpercent($getpoll3,'4')); + } +} else { + $setip = "INSERT INTO didpollalready SET ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $setip2 = mysql_query($setip); + $getpoll = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT 0,1"; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + $setpoll = "UPDATE polloftheweek SET clicks" . $_POST['options'] . " = " . ($getpoll3['clicks' . $_POST['options']]+1) . " WHERE id = " . $getpoll3['id']; + $setpoll2 = mysql_query($setpoll); + + $template = new FITemplate('msg'); + + $template->add('MSG','

    ' . $getpoll3['question'] . '

    Thank you for voting on the Poll of the Week!
    Click here to visit the page for this poll.'); + + $template->display(); +} + +?> diff --git a/pages/post.php b/pages/post.php new file mode 100644 index 0000000..f7990bd --- /dev/null +++ b/pages/post.php @@ -0,0 +1,107 @@ +add('BACK','the previous page'); + +if (!isset($_GET['id'])) +{ + $template->add('MSG','I\'m sorry, but there\'s no page-id set here, so sadly you can\'t comment yet. Why not contact the administratior (link on the HatBar) and tell him that you saw this error?'); +} else { + if ($_POST['comment'] == "") + { + $template->add('MSG','I\'m sorry, but you didn\'t enter a comment!'); + } else { + if (!isLoggedIn()) + { + $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); + if (!$resp->is_valid) + { + $template->add('MSG',"The reCAPTCHA wasn't entered correctly. Go back and try it again. (reCAPTCHA said: " . $resp->error . ")"); + } else { + if (preg_match('/^[A-Za-z0-9!#$&\'*+-\/=?^_`{|}~]+@[-A-Za-z0-9]+(\.[-A-Za-z0-9]+)+[A-Za-z]$/', $_POST['email'])) + { + $getanon = "SELECT * FROM anon_commenters WHERE username = \"" . $_POST['username'] . "\""; + $getanon2 = mysql_query($getanon); + $getanon3 = mysql_fetch_array($getanon2); + + if ($getanon3['username'] == $_POST['username']) + { + if ($getanon3['email'] == $_POST['email']) + { + $setcomment = "INSERT INTO comments SET page_id = \"" . $_GET['id'] . "\", username = \"" . $_POST['username'] . "\", comment = \"" . $_POST['comment'] . "\""; + $setcomment2 = mysql_query($setcomment); + + $page_id = $_GET['id']; + $comType = substr($page_id,0,strpos($page_id,'-')); + $comID = substr($page_id,strpos($page_id,'-')+1); + if ($comType == 'updates') + { + recalcPop($comID); + } + + $template->add('MSG',"Thank you, " . $getanon3['username'] . ", for posting your valuable comment!"); + } else { + $template->add('MSG',"I'm sorry, but this anonymous username is already in use. If this is in fact you, please verify that you have entered the same email address that you entered the first time you commented here."); + } + } else { + $setcomment = "INSERT INTO moderation SET page_id = \"" . $_GET['id'] . "\", author = \"" . $_POST['username'] . "\", email = \"" . $_POST['email'] . "\", comment = \"" . $_POST['comment'] . "\", website = \"" . $_POST['website'] . "\""; + $setcomment2 = mysql_query($setcomment); + + mail('hatkirby@fourisland.com', 'New comment to moderate on Four Island', 'Some one has anonymously left a comment on Four Island and it will require moderation.'); + + $template->add('MSG',"Thank you for posting your valuable comment!

    However, as you aren't logged in, your comment will have to be verified by a moderator before it appears. Sorry!"); + } + } else { + $template->add('MSG',"I'm sorry, but you've entered an invalid email address."); + } + } + } else { + $setcomment = "INSERT INTO comments SET page_id = \"" . $_GET['id'] . "\", username = \"" . sess_get('uname') . "\", comment = \"" . $_POST['comment'] . "\""; + $setcomment2 = mysql_query($setcomment); + + mail('hatkirby@fourisland.com', 'New comment on Four Island!', sess_get('uname') . ' has posted a comment on Four Island under the "page id" ' . $_GET['id']); + + $page_id = $_GET['id']; + $comType = substr($page_id,0,strpos($page_id,'-')); + $comID = substr($page_id,strpos($page_id,'-')+1); + if ($comType == 'updates') + { + recalcPop($comID); + } + + $template->add('MSG',"Thank you, " . sess_get('uname') . ", for posting your valuable comment!"); + } + } +} + +$template->display(); + +?> diff --git a/pages/projects.php b/pages/projects.php new file mode 100644 index 0000000..4129cdf --- /dev/null +++ b/pages/projects.php @@ -0,0 +1,94 @@ +setRespository('http://svn.fourisland.com/' . $_GET['project']); + $svn->setAuth('hatkirby','popstartwo506'); + $data = $svn->getFile($path,$rev); + + if (substr($path,strlen($path)-1,1) != '/') + { + $template->add('DATA', str_replace(' ','      ',str_replace(' ','  ',nl2br(htmlentities($data))))); + $template->adds_block('FILE', array('NAME' => $path)); + } else { + $template->add('DATA', $data); + } + + $logs = $svn->getFileLogs($path); + $template->add('LOGDATA', str_replace("\n\n",'

    ',htmlentities($logs[count($logs)-1]['comment']))); + $template->add('AUTHOR', $logs[count($logs)-1]['author']); + $template->add('DATE', date('F dS Y \a\\t g:i:s a',strtotime($logs[count($logs)-1]['date']))); + + if ($rev != -1) + { + $template->adds_block('FORWARD', array( 'URL' => ('/projects/' . $_GET['project'] . '/browse' . $path . '?rev=' . ($rev+1)), + 'NUM' => ($rev+1))); + } + + if ($rev == -1) + { + $rev = $svn->getVersion(); + } + + if ($rev != 1) + { + $template->adds_block('BACK', array( 'URL' => ('/projects/' . $_GET['project'] . '/browse' . $path . '?rev=' . ($rev-1)), + 'NUM' => ($rev-1))); + } + } + } else if (isset($_GET['file'])) + { + } +} + +$template->display(); + +?> diff --git a/pages/quotes.php b/pages/quotes.php new file mode 100644 index 0000000..78cd543 --- /dev/null +++ b/pages/quotes.php @@ -0,0 +1,166 @@ +adds_block('SUBMITTED',array('QUOTE' => (nl2br(htmlspecialchars($_POST['rash_quote'])) . "\n"))); + if (!isLoggedIn()) + { + $insquote = "INSERT INTO rash_queue (quote) VALUES(\"" . addslashes(htmlspecialchars($_POST['rash_quote'])) . "\")"; + } else { + $today = mktime(date('G'),date('i'),date('s'),date('m'),date('d'),date('Y')); + $insquote = "INSERT INTO rash_quotes (quote, rating, flag, date) VALUES (\"" . addslashes($_POST['rash_quote']) . "\", 0, 0, \"" . $today . "\")"; + } + $insquote2 = mysql_query($insquote); + } + $template->display(); +} elseif ($_GET['act'] == 'bottom') +{ + $query = "SELECT id, quote, rating, flag FROM rash_quotes WHERE rating < 0 ORDER BY rating ASC LIMIT 50"; + quote_generation($query, "Bottom", -1); +} elseif ($_GET['act'] == 'browse') +{ + $query = "SELECT id, quote, rating, flag FROM rash_quotes ORDER BY id ASC "; + quote_generation($query, "Browse", (isset($_GET['page']) ? $_GET['page'] : 1), 10, 5); +} elseif ($_GET['act'] == 'flag') +{ + $template = new FITemplate('msg'); + $tracking_verdict = user_quote_status('flag', $quote_num, $template); + if ($tracking_verdict < 3) + { + $getfla = "SELECT flag FROM rash_quotes WHERE id = " . $quote_num . " LIMIT 0,1"; + $getfla2 = mysql_query($getfla); + $getfla3 = mysql_fetch_array($getfla2); + + if ($getfla3['flag'] == 2) + { + $template->add('MSG',"This quote has been flagged and rechecked by a moderator already."); + } elseif ($getfla3['flag'] == 1) + { + $template->add('MSG',"This quote is currently pending deletion."); + } else { + $template->add('MSG',"You have marked this quote for deletion."); + $setfla = "UPDATE rash_quotes SET flag = 1 WHERE id = " . $quote_num; + $setfla2 = mysql_query($setfla); + } + } + $template->add('BACK','Quote #' . $quote_num); + $template->display(); +} elseif ($_GET['act'] == 'latest') +{ + $query = "SELECT id, quote, rating, flag FROM rash_quotes ORDER BY id DESC LIMIT 50"; + quote_generation($query, "Latest", -1); +} elseif ($_GET['act'] == 'random') +{ + $query = "SELECT id, quote, rating, flag FROM rash_quotes ORDER BY rand() LIMIT 50"; + quote_generation($query, "Random", -1); +} elseif ($_GET['act'] == 'random2') +{ + $query = "SELECT id, quote, rating, flag FROM rash_quotes WHERE rating > 1 ORDER BY rand() LIMIT 50"; + quote_generation($query, "Random2", -1); +} elseif ($_GET['act'] == 'search') +{ + if (isset($_GET['fetch'])) + { + if ($_POST['sortby'] == 'rating') + { + $how = 'desc'; + } else { + $how = 'asc'; + } + $getquotes = "SELECT id, quote, rating, flag FROM rash_quotes WHERE quote LIKE \"%" . $_POST['search'] . "%\" ORDER BY " . $_POST['sortby'] . " " . $how . " LIMIT 0," . $_POST['number']; + quote_generation($getquotes, "Query Results", -1); + } + $template = new FITemplate('quotes/search'); + $template->display(); +} elseif ($_GET['act'] == 'top') +{ + $query = "SELECT id, quote, rating, flag FROM rash_quotes WHERE rating > 0 ORDER BY rating DESC LIMIT 50"; + quote_generation($query, "Top", -1); +} elseif ($_GET['act'] == 'vote') +{ + $template = new FITemplate('msg'); + $tracking_verdict = user_quote_status('vote', $quote_num,$template); + $template->add('BACK','Quote #' . $quote_num); + $template->display(); + if ($tracking_verdict < 3) + { + if ($_GET['dir'] == "plus") + { + $setquote = "UPDATE rash_quotes SET rating = rating+1 WHERE id = " . $quote_num; + $setquote2 = mysql_query($setquote); + } elseif($_GET['dir'] == "minus") + { + $setquote = "UPDATE rash_quotes SET rating = rating-1 WHERE id = " . $quote_num; + $setquote2 = mysql_query($setquote); + } + } +} else { + if ((is_int($_GET['act']) || ($_GET['act'] != false)) && (verify_int($_GET['act']))) + { + $query = "SELECT id, quote, rating, flag FROM rash_quotes WHERE id = " . $_GET['act']; + quote_generation($query, "#" . $_GET['act'], -1); + $page_id = 'quote-' . $_GET['act']; + } else { + $template = new FITemplate('post'); + $template->adds_block('INTERNAL',array('exi'=>1)); + + $getpost = "SELECT * FROM updates WHERE tag1 = \"quotes\" OR tag2 = \"tag2\" OR tag3 = \"tag3\" ORDER BY id DESC LIMIT 0,1"; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $title = $getpost3['title'] . ' - Blog Archive'; + + $template->adds_block('POST', array( 'ID' => $getpost3['id'], + 'YEARID' => ((date('Y',strtotime($getpost3['pubDate']))-2006) % 4), + 'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getpost3['pubDate'])), + 'MONTH' => date('M',strtotime($getpost3['pubDate'])), + 'DAY' => date('d',strtotime($getpost3['pubDate'])), + 'CODED' => urlencode($getpost3['title']), + 'TITLE' => $getpost3['title'], + 'AUTHOR' => $getpost3['author'], + 'TAG1' => $getpost3['tag1'], + 'TAG2' => $getpost3['tag2'], + 'TAG3' => $getpost3['tag3'], + 'TEXT' => parseBBCode($getpost3['text']))); + + $template->display(); + $page_id = 'updates-' . $getpost3['id']; + } + include('includes/comments.php'); +} + +?> diff --git a/pages/splash.php b/pages/splash.php new file mode 100644 index 0000000..0a9ca89 --- /dev/null +++ b/pages/splash.php @@ -0,0 +1,28 @@ +display(); + +?> diff --git a/pages/vote.php b/pages/vote.php new file mode 100644 index 0000000..890b379 --- /dev/null +++ b/pages/vote.php @@ -0,0 +1,115 @@ +add('BACK','Back to ' . stripslashes($getpost3['title'])); + $template->add('LINK','/blog/' . $getpost3['slug'] . '/'); + + if ($_GET['dir'] == 'plus') + { + if (updatePop($_GET['id'],'rating')) + { + $template->add('MSG','Thank you for voting!'); + } else { + $template->add('MSG','I\'m sorry, but you\'ve already voted on this post.'); + } + } else if ($_GET['dir'] == 'minus') + { + if (updatePop($_GET['id'],'rating',-1)) + { + $template->add('MSG','Thank you for voting!'); + } else { + $template->add('MSG','I\'m sorry, but you\'ve already voted on this post.'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK','the previous page'); + $template->add('MSG','Um, what on earth are you doing?'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK','the previous page'); + $template->add('MSG','Um, what on earth are you doing?'); + } +} else if ($_GET['mode'] == 'comment') +{ + $getcomment = "SELECT * FROM comments WHERE id = " . $_GET['id']; + $getcomment2 = mysql_query($getcomment); + $getcomment3 = mysql_fetch_array($getcomment2); + + if ($getcomment3['id'] == $_GET['id']) + { + $page_id = $getcomment3['page_id']; + $comID = substr($page_id,strpos($page_id,'-')+1); + + $getpost = "SELECT * FROM updates WHERE id = " . $comID; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $template = new FITemplate('msg2'); + $template->add('BACK','Back to ' . stripslashes($getpost3['title'])); + $template->add('LINK','/blog/' . $getpost3['slug'] . '/'); + + if ($_GET['dir'] == 'plus') + { + if (updateCommentPop($_GET['id'])) + { + $template->add('MSG','Thank you for voting!'); + } else { + $template->add('MSG','I\'m sorry, but you\'ve already voted on this comment.'); + } + } else if ($_GET['dir'] == 'minus') + { + if (updateCommentPop($_GET['id'],-1)) + { + $template->add('MSG','Thank you for voting!'); + } else { + $template->add('MSG','I\'m sorry, but you\'ve already voted on this comment.'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK','the previous page'); + $template->add('MSG','Um, what on earth are you doing?'); + } + } else { + $template = new FITemplate('msg'); + $template->add('BACK','the previous page'); + $template->add('MSG','Um, what on earth are you doing?'); + } +} + +$template->display(); + +?> diff --git a/pages/welcome.php b/pages/welcome.php new file mode 100644 index 0000000..24fd7ad --- /dev/null +++ b/pages/welcome.php @@ -0,0 +1,81 @@ +adds_block('EXTERNAL',array('exi'=>1)); + +$curID = 0; + +$getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,4"; +$getpost2 = mysql_query($getpost); +while ($getpost3 = mysql_fetch_array($getpost2)) +{ + updatePop($getpost3['id'],'home_views'); + + $page_id = 'updates-' . $getpost3['id']; + $getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; + $getcomments2 = mysql_query($getcomments); + $total_post=0; + while ($getcomments3[$total_post] = mysql_fetch_array($getcomments2)) + { + $total_post++; + } + if ($total_post >= 2) + { + $plural = 's'; + } + if ($total_post == 0) + { + $comText = 'No Comments'; + } elseif ($total_post == 1) + { + $comText = '1 Comment'; + } else { + $comText = $total_post . ' Comments'; + } + + $template->add_ref($curID, 'POST', array( 'ID' => $getpost3['id'], + 'YEARID' => ((date('Y',strtotime($getpost3['pubDate']))-2006) % 4), + 'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getpost3['pubDate'])), + 'MONTH' => date('M',strtotime($getpost3['pubDate'])), + 'DAY' => date('d',strtotime($getpost3['pubDate'])), + 'CODED' => $getpost3['slug'], + 'TITLE' => $getpost3['title'], + 'AUTHOR' => $getpost3['author'], + 'TAG1' => $getpost3['tag1'], + 'TAG2' => $getpost3['tag2'], + 'TAG3' => $getpost3['tag3'], + 'PLURALCOMMENT' => (isset($plural) ? $plural : ''), + 'COMMENTS' => $comText, + 'RATING' => $getpost3['rating'], + 'TEXT' => parseBBCode($getpost3['text']))); + + $curID++; +} + +$template->display(); + +?> diff --git a/pages/wiki.php b/pages/wiki.php new file mode 100644 index 0000000..3e5a410 --- /dev/null +++ b/pages/wiki.php @@ -0,0 +1,179 @@ +add('TITLE', $getpage3['title']); + $template->add('CONTENT', parseBBCode($getrev3['text'])); + $template->display(); + } else { + if (isLoggedIn()) + { + header('Location: ./?action=create'); + exit; + } else { + $template = new FITemplate('msg'); + $template->add('MSG', "The wiki page you are trying to access does not yet exist, and as you are not logged in, you cannot create it. If you would like to, why not log in and create this page?"); + $template->add('BACK', "the previous page"); + $template->display(); + } + } +} else if ($_GET['action'] == 'create') +{ + if (isLoggedIn()) + { + $template = new FITemplate('wiki/create'); + $template->display(); + } else { + $template = new FITemplate('msg'); + $template->add('MSG', "I'm sorry, but you are attempting to create a wiki page while you aren't logged in. Please log in and then return."); + $template->add('BACK', "the previous page"); + $template->display(); + } +} else if ($_GET['action'] == 'edit') +{ + if (isLoggedIn()) + { + $getpage = "SELECT * FROM wiki_pages WHERE slug = \"" . $page . "\""; + $getpage2 = mysql_query($getpage); + $getpage3 = mysql_fetch_array($getpage2); + + if ($getpage3['slug'] == $page) + { + $getrev = "SELECT * FROM wiki_revisions WHERE id = " . $getpage3['revision']; + $getrev2 = mysql_query($getrev); + $getrev3 = mysql_fetch_array($getrev2); + + $template = new FITemplate('wiki/edit'); + $template->add('PAGENAME', $getpage3['title']); + $template->add('PAGETEXT', $getrev3['text']); + $template->display(); + } else { + header('Location: ./?action=create'); + exit; + } + } else { + $template = new FITemplate('msg'); + $template->add('MSG', "I'm sorry, but you are attempting to edit a wiki page while you aren't logged in. Please log in and then return."); + $template->add('BACK', "the previous page"); + $template->display(); + } +} else if ($_GET['action'] == 'submit') +{ + if (isLoggedIn()) + { + if ($_GET['submit'] == 'create') + { + $insrev = "INSERT INTO wiki_revisions (author,text) VALUES (\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\")"; + $insrev2 = mysql_query($insrev); + + $getrev = "SELECT * FROM wiki_revisions WHERE author = \"" . sess_get('uname') . "\" AND text = \"" . addslashes($_POST['text']) . "\" ORDER BY id DESC LIMIT 0,1"; + $getrev2 = mysql_query($getrev); + $getrev3 = mysql_fetch_array($getrev2); + + $slug = generateSlug($_POST['title'],'wiki-pages'); + + $inspage = "INSERT INTO wiki_pages (title,slug,revision) VALUES (\"" . $_POST['title'] . "\",\"" . $slug . "\"," . $getrev3['id'] . ")"; + $inspage2 = mysql_query($inspage); + + $template = new FITemplate('msg2'); + $template->add('MSG', 'YAY! You\'ve just created a page!'); + $template->add('LINK', '/wiki/' . $slug . '/'); + $template->add('BACK', 'View the page you just created'); + $template->display(); + } else if ($_GET['submit'] == 'edit') + { + $getpage = "SELECT * FROM wiki_pages WHERE slug = \"" . $_GET['page'] . "\""; + $getpage2 = mysql_query($getpage); + $getpage3 = mysql_fetch_array($getpage2); + + $insrev = "INSERT INTO wiki_revisions (author,text,previous) VALUES (\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\"," . $getpage3['revision'] . ")"; + $insrev2 = mysql_query($insrev); + + $getrev4 = "SELECT * FROM wiki_revisions WHERE author = \"" . sess_get('uname') . "\" AND text = \"" . addslashes($_POST['text']) . "\" AND previous = " . $getpage3['revision'] . " ORDER BY id DESC LIMIT 0,1"; + $getrev5 = mysql_query($getrev4); + $getrev6 = mysql_fetch_array($getrev5); + + $setpage = "UPDATE wiki_pages SET revision = " . $getrev6['id'] . " WHERE revision = " . $getpage3['revision']; + $setpage2 = mysql_query($setpage); + + $template = new FITemplate('msg2'); + $template->add('MSG', 'YAY! You\'ve just edited a page!'); + $template->add('LINK', './'); + $template->add('BACK', 'View the page you just edited'); + $template->display(); + } + } else { + $template = new FITemplate('msg'); + $template->add('MSG', "I'm sorry, but you are attempting to edit a wiki page while you aren't logged in. Please log in and then return."); + $template->add('BACK', "the previous page"); + $template->display(); + } +} else if ($_GET['action'] == 'index') +{ + $template = new FITemplate('wiki/index'); + $getpages = "SELECT * FROM wiki_pages, wiki_revisions WHERE wiki_revisions.id = wiki_pages.revision ORDER BY title ASC"; + $getpages2 = mysql_query($getpages); + $i=0; + $lastLetter=''; + while ($getpages3[$i] = mysql_fetch_array($getpages2)) + { + if (substr($getpages3[$i]['title'],0,1) != $lastLetter) + { + if (!isset($curID)) + { + $curID = 0; + } else { + $curID++; + } + $template->add_ref($curID, 'LETTER', array('TITLE' => substr($getpages3[$i]['title'],0,1))); + $lastLetter = substr($getpages3[$i]['title'],0,1); + } + + $template->adds_ref_sub($curID, 'PAGE', array( 'TITLE' => $getpages3[$i]['title'], + 'CODED' => ($getpages3[$i]['slug'] != '' ? $getpages3[$i]['slug'] . '/' : ''), + 'DATE' => date('m-d-y',strtotime($getpages3[$i]['pubDate'])))); + $i++; + } + $template->display(); +} + +?> diff --git a/rss.php b/rss.php new file mode 100644 index 0000000..c9e866f --- /dev/null +++ b/rss.php @@ -0,0 +1,334 @@ +'); + +?> + + + Four Island<?php +if (isset($_GET['mode'])) +{ + switch ($_GET['mode']) + { + case 'blog': + if (isset($_GET['blog'])) + { + switch ($_GET['blog']) + { + case 'author': +?> Blog Posts by <?php + echo($_GET['author']); + break; + case 'tag': +?> Blog Posts tagged with <?php + echo($_GET['tag']); + break; + } + } else { +?> Blog Posts<?php + } + break; + case 'quotes': +?> Quotes<?php + break; + case 'poll': +?> Polls<?php + break; + case 'projects': +?> Projects<?php + break; + case 'comments': +?> Comments<?php + break; + } +} +?> + + An archive of all Four Island blog posts written by An archive of all Four Island blog posts tagged with An archive of all Four Island blog postsAn archive of all Four Island quotesAn archive of all of the Four Island POTWsAn archive of all of the Four Island Project checkinsAn archive of all of the comments people have left on Four IslandAll the wonderfour going-ons on Four Island + + en + +setRespository('http://svn.fourisland.com/' . $name); +// $svn->setAuth('hatkirby','popstartwo506'); + $logs = $svn->getFileLogs(''); + + $k=0; + while (($items[$i] = $logs[$k])) + { + $items[$i]['sortDate'] = strtotime($items[$i]['date']); + $items[$i]['itemType'] = 'project'; + $items[$i]['project'] = $name; + $i++; + $k++; + } + } +} + +if (!isset($_GET['mode']) || ($_GET['mode'] == 'comments')) +{ + $getcomments = "SELECT * FROM comments ORDER BY id DESC LIMIT 0,10"; + $getcomments2 = mysql_query($getcomments); + while ($items[$i] = mysql_fetch_array($getcomments2)) + { + $items[$i]['sortDate'] = strtotime($items[$i]['posttime']); + $items[$i]['itemType'] = 'comment'; + + $page_id = $items[$i]['page_id']; + $comType = substr($page_id,0,strpos($page_id,'-')); + $comID = substr($page_id,strpos($page_id,'-')+1); + + switch ($comType) + { + case 'updates': + $getpost = "SELECT * FROM updates WHERE id = " . $comID; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $items[$i]['title'] = $getpost3['title']; + $items[$i]['url'] = 'blog/' . $getpost3['slug'] . '/'; + break; + case 'poll': + $getpoll = "SELECT * FROM polloftheweek WHERE id = " . $comID; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + + $items[$i]['title'] = $getpoll3['question']; + $items[$i]['url'] = 'poll/' . $getpoll3['id'] . '.php'; + break; + case 'quote': + $getquote = "SELECT * FROM rash_quotes WHERE id = " . $comID; + $getquote2 = mysql_query($getquote); + $getquote3 = mysql_fetch_array($getquote2); + + $items[$i]['title'] = '#' . $getquote3['id']; + $items[$i]['url'] = 'quotes/' . $getquote3['id'] . '.php'; + break; + } + $i++; + } +} + +function sortItems($a, $b) +{ + if ($a['sortDate'] < $b['sortDate']) + { + return 1; + } else if ($a['sortDate'] == $b['sortDate']) + { + return 0; + } else if ($a['sortDate'] > $b['sortDate']) + { + return -1; + } +} + +uasort($items,"sortItems"); + +$j=0; +foreach ($items as $key => $value) +{ + switch ($value['itemType']) + { + case 'post': +?> + + <?php echo($value['title']); ?> + + http://www.fourisland.com/blog// + + + + + + + + Quote #<?php echo($value['id']); ?> + + http://www.fourisland.com/quotes/.php + + + + + + + + <?php echo($value['project']); ?> r<?php echo($value['version']); ?> - <?php echo($title); ?> + + http://www.fourisland.com/projects//changeset/ + + + + + + + + Comment on <?php echo($value['title']); ?> by <?php echo($value['username']); ?> + + http://www.fourisland.com/comments// + + + + + + + + diff --git a/theme/addresses.tpl b/theme/addresses.tpl new file mode 100644 index 0000000..5b06a7a --- /dev/null +++ b/theme/addresses.tpl @@ -0,0 +1,9 @@ +

    Click here for information about this page.

    + +

    Calling all email-harvesting robots!

    + +

    Come fetch 1000 juicy email addresses here:

    + + +
    + diff --git a/theme/admin/deleteDraft.tpl b/theme/admin/deleteDraft.tpl new file mode 100644 index 0000000..346604e --- /dev/null +++ b/theme/admin/deleteDraft.tpl @@ -0,0 +1,6 @@ +

    Delete a Draft

    + +Are you ABSOLUTELY SURE that you want to delete this draft?

    + +Yes
    +Ummm.... actually I'd rather not diff --git a/theme/admin/deletePending.tpl b/theme/admin/deletePending.tpl new file mode 100644 index 0000000..03541f2 --- /dev/null +++ b/theme/admin/deletePending.tpl @@ -0,0 +1,6 @@ +

    Delete a Pending Post

    + +Are you ABSOLUTELY SURE that you want to delete this pending post?

    + +Yes
    +Ummm.... actually I'd rather not diff --git a/theme/admin/deletePost.tpl b/theme/admin/deletePost.tpl new file mode 100644 index 0000000..8c08112 --- /dev/null +++ b/theme/admin/deletePost.tpl @@ -0,0 +1,6 @@ +

    Delete a Post

    + +Are you ABSOLUTELY SURE that you want to delete this post?

    + +Yes
    +Ummm.... actually I'd rather not diff --git a/theme/admin/deletedDraft.tpl b/theme/admin/deletedDraft.tpl new file mode 100644 index 0000000..dd449f6 --- /dev/null +++ b/theme/admin/deletedDraft.tpl @@ -0,0 +1,6 @@ +You've just deleted a draft! + +

    diff --git a/theme/admin/deletedPending.tpl b/theme/admin/deletedPending.tpl new file mode 100644 index 0000000..220aa11 --- /dev/null +++ b/theme/admin/deletedPending.tpl @@ -0,0 +1,6 @@ +You've just deleted a pending post! + + diff --git a/theme/admin/deletedPost.tpl b/theme/admin/deletedPost.tpl new file mode 100644 index 0000000..12cc68a --- /dev/null +++ b/theme/admin/deletedPost.tpl @@ -0,0 +1,6 @@ +You've just deleted a post! + + diff --git a/theme/admin/draftSuccess.tpl b/theme/admin/draftSuccess.tpl new file mode 100644 index 0000000..7d76d2a --- /dev/null +++ b/theme/admin/draftSuccess.tpl @@ -0,0 +1,8 @@ +Congradulations, you've just made/edited a draft! + + diff --git a/theme/admin/editDraft.tpl b/theme/admin/editDraft.tpl new file mode 100644 index 0000000..b3197c4 --- /dev/null +++ b/theme/admin/editDraft.tpl @@ -0,0 +1,16 @@ +

    Edit a draft

    + +

    + Draft Title:
    +

    + Tag 1:
    + Tag 2: (Optional)
    + Tag 3: (Optional)
    + Post Type:
    + +

    diff --git a/theme/admin/editPending.tpl b/theme/admin/editPending.tpl new file mode 100644 index 0000000..ccded76 --- /dev/null +++ b/theme/admin/editPending.tpl @@ -0,0 +1,10 @@ +

    Edit a pending post

    + +

    + Post Title:
    +

    + Tag 1:
    + Tag 2: (Optional)
    + Tag 3: (Optional)
    + +

    diff --git a/theme/admin/editPost.tpl b/theme/admin/editPost.tpl new file mode 100644 index 0000000..544fe5f --- /dev/null +++ b/theme/admin/editPost.tpl @@ -0,0 +1,10 @@ +

    Edit a post

    + +

    + Post Title:
    +

    + Tag 1:
    + Tag 2: (Optional)
    + Tag 3: (Optional)
    + +

    diff --git a/theme/admin/index.tpl b/theme/admin/index.tpl new file mode 100644 index 0000000..f886f2d --- /dev/null +++ b/theme/admin/index.tpl @@ -0,0 +1,31 @@ +

    Admin Panel

    + +Welcome to the ubiquitous administration panel!

    + +

    Blog

    + + + +

    Wiki

    + + + +

    Poll

    + + + +

    Quotes

    + + diff --git a/theme/admin/manageDrafts.tpl b/theme/admin/manageDrafts.tpl new file mode 100644 index 0000000..8a498ac --- /dev/null +++ b/theme/admin/manageDrafts.tpl @@ -0,0 +1,24 @@ +

    Manage Drafts

    + + + + + + + + + + + + + + + + +
    Draft TitleDraft AuthorActions
    + Edit + Delete + View +
    + +Back to Admin Panel diff --git a/theme/admin/managePages.tpl b/theme/admin/managePages.tpl new file mode 100644 index 0000000..eef8c75 --- /dev/null +++ b/theme/admin/managePages.tpl @@ -0,0 +1,23 @@ +

    Manage Pages

    + + + + + + + + + + + + + + + + +
    Page TitleRevision AuthorActions
    + View History + View +
    + +Back to Admin Panel diff --git a/theme/admin/managePending.tpl b/theme/admin/managePending.tpl new file mode 100644 index 0000000..d119b92 --- /dev/null +++ b/theme/admin/managePending.tpl @@ -0,0 +1,24 @@ +

    Manage Pending

    + + + + + + + + + + + + + + + + +
    Pending Post TitlePending Post AuthorActions
    + Edit + Delete + View +
    + +Back to Admin Panel diff --git a/theme/admin/managePendingQuotes.tpl b/theme/admin/managePendingQuotes.tpl new file mode 100644 index 0000000..660e126 --- /dev/null +++ b/theme/admin/managePendingQuotes.tpl @@ -0,0 +1,21 @@ +

    Manage Pending Quotes

    + + + + + + + + + + + + + + +
    QuoteActions
    + Approve + Deny +
    + +Back to Admin Panel diff --git a/theme/admin/managePosts.tpl b/theme/admin/managePosts.tpl new file mode 100644 index 0000000..7e37b1f --- /dev/null +++ b/theme/admin/managePosts.tpl @@ -0,0 +1,24 @@ +

    Manage Posts

    + + + + + + + + + + + + + + + + +
    Post TitlePost AuthorActions
    + Edit + Delete + View +
    + +Back to Admin Panel diff --git a/theme/admin/moderateComments.tpl b/theme/admin/moderateComments.tpl new file mode 100644 index 0000000..f3da51c --- /dev/null +++ b/theme/admin/moderateComments.tpl @@ -0,0 +1,24 @@ +

    Moderate Comments

    + + + + + + + + + + + + + + + + +
    Title of Article Commented UponComment AuthorActions
    + View + Approve + Deny +
    + +Back to Admin Panel diff --git a/theme/admin/newPoll.tpl b/theme/admin/newPoll.tpl new file mode 100644 index 0000000..5f1d2a4 --- /dev/null +++ b/theme/admin/newPoll.tpl @@ -0,0 +1,10 @@ +Congradulations! You've successfully added a Poll RSS. Now it's time to add the new Poll Of The Week:

    + +

    + Question:
    + Option 1:
    + Option 2:
    + Option 3:
    + Option 4:
    + +
    diff --git a/theme/admin/pageHistory.tpl b/theme/admin/pageHistory.tpl new file mode 100644 index 0000000..b5fd326 --- /dev/null +++ b/theme/admin/pageHistory.tpl @@ -0,0 +1,23 @@ +

    Page History

    + + + + + + + + + + + + + + + + +
    Revision AuthorRevision DateActions
    + View +
    + +Back to Manage Pages
    +Back to Admin Panel diff --git a/theme/admin/pendingSuccess.tpl b/theme/admin/pendingSuccess.tpl new file mode 100644 index 0000000..64adbe6 --- /dev/null +++ b/theme/admin/pendingSuccess.tpl @@ -0,0 +1,8 @@ +Congradulations, you've just made/edited a pending post! + + diff --git a/theme/admin/pollrss.tpl b/theme/admin/pollrss.tpl new file mode 100644 index 0000000..5ea628f --- /dev/null +++ b/theme/admin/pollrss.tpl @@ -0,0 +1,6 @@ +

    Write a Poll RSS

    + +

    +

    + +

    diff --git a/theme/admin/postSuccess.tpl b/theme/admin/postSuccess.tpl new file mode 100644 index 0000000..12920fe --- /dev/null +++ b/theme/admin/postSuccess.tpl @@ -0,0 +1,8 @@ +Congradulations, you've just made/edited a post! + + diff --git a/theme/admin/viewComment.tpl b/theme/admin/viewComment.tpl new file mode 100644 index 0000000..9254f1d --- /dev/null +++ b/theme/admin/viewComment.tpl @@ -0,0 +1,12 @@ +
    +
    +
    + + +
    +
    + on +

    + +Back to Comment Moderation
    +Back to Admin Panel diff --git a/theme/admin/viewRevision.tpl b/theme/admin/viewRevision.tpl new file mode 100644 index 0000000..fc6fc83 --- /dev/null +++ b/theme/admin/viewRevision.tpl @@ -0,0 +1,5 @@ + +

    +Back to Page History +Back to Manage Pages
    +Back to Admin Panel diff --git a/theme/admin/write.tpl b/theme/admin/write.tpl new file mode 100644 index 0000000..30e870c --- /dev/null +++ b/theme/admin/write.tpl @@ -0,0 +1,16 @@ +

    Write a post

    + +

    + Post Title:
    +

    + Tag 1:
    + Tag 2: (Optional)
    + Tag 3: (Optional)
    + Post Type:
    + +

    diff --git a/theme/archive.tpl b/theme/archive.tpl new file mode 100644 index 0000000..7d85565 --- /dev/null +++ b/theme/archive.tpl @@ -0,0 +1,43 @@ + +

    + +
    + + +
    +

    + + + +

    + + + + + + + + +  » + +
    +
    + + + + |
    + + + +


    + + diff --git a/theme/comic.tpl b/theme/comic.tpl new file mode 100644 index 0000000..8ce4236 --- /dev/null +++ b/theme/comic.tpl @@ -0,0 +1,46 @@ +« + » + + +

    + + +
    +

    + + + +

    + + + Hatkirby + + + + Add Comment » + +
    + +
    +
    +
    +
    +
    + + + + +

    +
    +
    +
    + Hatkirby on +
    +
    +
    + diff --git a/theme/comicarchive.tpl b/theme/comicarchive.tpl new file mode 100644 index 0000000..dc5e443 --- /dev/null +++ b/theme/comicarchive.tpl @@ -0,0 +1,37 @@ + +

    + +
    + + +
    +

    + + + +

    + + + + + + +  » + +
    +
    + + + + |
    + + + +


    + + diff --git a/theme/comments.tpl b/theme/comments.tpl new file mode 100644 index 0000000..ab4e05b --- /dev/null +++ b/theme/comments.tpl @@ -0,0 +1,49 @@ + + + +

    +
    +
    + + +
    +
    + on + + + + + + +
    + + +
    +
    +
    +
    + +
    +
    + , feel free to post a comment +
    + +
    + + +

    + Name:
    + Email:
    + Website (Optional): +

    + + +

    +
    diff --git a/theme/css.php b/theme/css.php new file mode 100755 index 0000000..4984f03 --- /dev/null +++ b/theme/css.php @@ -0,0 +1,40 @@ + diff --git a/theme/css/backgrounds.php b/theme/css/backgrounds.php new file mode 100755 index 0000000..51e7dbf --- /dev/null +++ b/theme/css/backgrounds.php @@ -0,0 +1,148 @@ + +/* Four Island Background CSS */ += 20) || (date('G') <= 6)) + { +// $bodyID = 'night'; + } else { + $bodyID = 'day'; + } +} else { + $bodyID = $_GET['id']; +} + +if (!isset($bgcolor)) {$bgcolor='aqua';} +if (($bgimgm == 'island6') && ($bodyID == 'night')) {$bgcolor='black';} + +?> +/* Body */ + +body { + background-color: ; + background-image: url(/theme/images/backgrounds/.PNG); + background-repeat: repeat-x; + background-attachment: fixed; + background-position: bottom left; + font-family: Arial, FreeSans; + margin: 0px; + padding: 0px 0px 30px !important; +} + + +body#night { + background: black url(/theme/images/backgrounds/island6night.PNG) repeat-x fixed bottom left; +} + + diff --git a/theme/css/bubbles.css b/theme/css/bubbles.css new file mode 100644 index 0000000..e48eba0 --- /dev/null +++ b/theme/css/bubbles.css @@ -0,0 +1,71 @@ +/* Normal Bubble */ +div.bubble { + width: auto; + font-size: 0.75em; + margin-bottom: 24px; + font: 1em "Lucida Grande", Lucida, Verdana, sans-serif; +} + +div.bubble blockquote { + margin: 0px; + padding: 0px; + border: 1px solid #c9c2c1; + background-color: #fff; +} + +div.bubble blockquote div { + margin: 10px; + padding: 0px; +} + +div.bubble cite { + position: relative; + margin: 0px; + padding: 7px 0px 0px 15px; + top: 6px; + background: transparent url(/theme/images/tip.gif) no-repeat 20px 0; + font-style: normal; + font-size: small; +} + +/* Rounded Bubble */ +div.bubble div.rounded { + margin-bottom: 10px; + border: 3px solid #fff; + background-color: #b7e0ff; +} +div.bubble div.rounded blockquote { + border: 0; + background-color: transparent; +} +div.bubble div.rounded blockquote div { + margin: 0px 10px; +} +div.bubble cite.rounded { + position: relative; + margin: 0px; + padding-left: 15px; + padding-top: 12px; + top: 9px; + background: transparent url(/theme/images/tip-rounded.gif) no-repeat 15px 0; +} + +/* Pimped Bubble */ +div#pimped.bubble { + font-size: 0.9em; +} +div#pimped.bubble div.rounded { + color: #fff; + border: 3px solid #fff; + background-color: #111; +} +div#pimped.bubble cite.rounded { + background: transparent url(/theme/images/tip-pimped.gif) no-repeat 15px 0; +} + +div.bubble div.bquote blockquote { + margin: 0px; + padding: 0px; + border: 1px solid #c9c2c1; + background-color: #fff; +} diff --git a/theme/css/headers.php b/theme/css/headers.php new file mode 100755 index 0000000..bb5a179 --- /dev/null +++ b/theme/css/headers.php @@ -0,0 +1,85 @@ + +/* Four Island Header CSS */ + +/* Category-Based Headers */ +body.projects div#banner { + background-image: url("/theme/images/headers/projects.png"); +} +body.wiki div#banner { + background-image: url("/theme/images/headers/kfm.png"); +} +body.fourm div#banner { + background-image: url("/theme/images/headers/fourm.png"); +} +body.misc div#banner { + background-image: url("/theme/images/headers/random.png"); +} +body.webs div#banner { + background-image: url("/theme/images/headers/links.png"); +} +body.quotes div#banner { + background-image: url("/theme/images/headers/quotes.png"); +} +body.poll div#banner { + background-image: url("/theme/images/headers/potw.png"); +} +/* AID-Based Headers */ + +div#banner { + background-image: url("/theme/images/headers/.png"); /*850x129*/ +} diff --git a/theme/css/navigation.php b/theme/css/navigation.php new file mode 100755 index 0000000..4b5f117 --- /dev/null +++ b/theme/css/navigation.php @@ -0,0 +1,198 @@ + +/* Four Island NavBar CSS */ + +ul#bannernav { + list-style: none; + clear: both; + margin: 0px; +} + +div#banner-nav { + height: 30px; + clear: both; + margin: 1px 30px 0 30px; + background: url("/theme/images/bg_navbar.gif") repeat-x 0 0; +} + +ul#bannernav li { + float: left; + margin: 0; + padding: 0; + padding-right: 6px; +} + +ul#bannernav li a { + text-decoration: none; + display: block; + width: 100; + height: 30; +} + +ul#bannernav li a span { + visibility: hidden; +} + +ul#bannernav li img { + display: none; +} + +ul#bannernav li#bannernav-home a { + background-image: url("/theme/images/Home.gif"); +} + +body.home ul#bannernav li#bannernav-home a, +ul#bannernav li#bannernav-home a:hover { + background-image: url("/theme/images/Home_ro.gif"); +} + +ul#bannernav li#bannernav-projects a { + background-image: url("/theme/images/Projects.gif"); +} + +body.projects ul#bannernav li#bannernav-projects a, +ul#bannernav li#bannernav-projects a:hover { + background-image: url("/theme/images/Projects_ro.gif"); +} + +ul#bannernav li#bannernav-wiki a { + background-image: url("/theme/images/Wiki.gif"); +} + +body.wiki ul#bannernav li#bannernav-wiki a, +ul#bannernav li#bannernav-wiki a:hover { + background-image: url("/theme/images/Wiki_ro.gif"); +} + +ul#bannernav li#bannernav-fourm a { + background-image: url("/theme/images/Fourm.gif"); +} + +body.fourm ul#bannernav li#bannernav-fourm a, +ul#bannernav li#bannernav-fourm a:hover { + background-image: url("/theme/images/Fourm_ro.gif"); +} + +ul#bannernav li#bannernav-misc a { + background-image: url("/theme/images/Random.gif"); +} + +body.misc ul#bannernav li#bannernav-misc a, +ul#bannernav li#bannernav-misc a:hover { + background-image: url("/theme/images/Random_ro.gif"); +} + +ul#bannernav li#bannernav-webs a { + background-image: url("/theme/images/Links.gif"); +} + +body.webs ul#bannernav li#bannernav-webs a, +ul#bannernav li#bannernav-webs a:hover { + background-image: url("/theme/images/Links_ro.gif"); +} + +ul#bannernav li#bannernav-poll a { + background-image: url("/theme/images/Poll.gif"); +} + +body.poll ul#bannernav li#bannernav-poll a, +ul#bannernav li#bannernav-poll a:hover { + background-image: url("/theme/images/Poll_ro.gif"); +} + +ul#bannernav li#bannernav-quotes a { + background-image: url("/theme/images/Quotes.gif"); +} + +body.quotes ul#bannernav li#bannernav-quotes a, +ul#bannernav li#bannernav-quotes a:hover { + background-image: url("/theme/images/Quotes_ro.gif"); +} + +ul#bannernav li#bannernav-login a { + background-image: url("/theme/images/Login.gif"); +} + +body.login ul#bannernav li#bannernav-login a, +ul#bannernav li#bannernav-login a:hover { + background-image: url("/theme/images/Login_ro.gif"); +} + +ul#bannernav li#bannernav-logout a { + background-image: url("/theme/images/Logout.gif"); +} + +ul#bannernav li#bannernav-logout a:hover { + background-image: url("/theme/images/Logout_ro.gif"); +} + +ul#bannernav li#bannernav-panel a { + background-image: url("/theme/images/Panel.gif"); +} + +body.panel ul#bannernav li#bannernav-panel a, +ul#bannernav li#bannernav-panel a:hover { + background-image: url("/theme/images/Panel_ro.gif"); +} + +ul#bannernav li#bannernav-search { + display: block; + float: right; + width: 165px; + height: 30px; + margin: 0px; + background: url("/theme/images/bg_search.gif") 0 0 no-repeat; +} + +ul#bannernav li#bannernav-search fieldset { + border: none; + padding-top: 6px; + border-width:0pt; + font-family:Verdana,Helvetica,Arial,sans-serif; + font-size:1.1em; +} + +ul#bannernav li#bannernav-search input { + width: 125px; + height: 19px !important; + margin-left: 13px; + border: none !important; + background-color: transparent; + cursor:pointer; + font-family:Verdana,Helvetica,Arial,sans-serif; + font-weight:normal; + padding:0pt 3px; + vertical-align:middle; + line-height:1.3em; + color:#536482; + margin-top: -20px; +} + +body.fourm ul#bannernav li#bannernav-search input { + margin-top: 0px; + font-size: 1.1em !important; + margin-left: 28px; +} diff --git a/theme/css/quotes.php b/theme/css/quotes.php new file mode 100644 index 0000000..f66ad14 --- /dev/null +++ b/theme/css/quotes.php @@ -0,0 +1,199 @@ + +/* site-wide */ +div#site_all{ + font-family: serif; + font-size: 12pt; + margin-left: 9%; + margin-right: 9%; +} +a#site_nav_admin{ + color: #c08000; +} +a#site_nav_logout{ + color: #000000; +} +a#site_admin_flag, a#site_admin_queue{ + color: #336699; +} + + +/* quote-output styles */ + +div.quote_quote{ + padding-bottom: 5pt; +} +div.quote_whole{ + padding-top: 10pt; +} + +/* searchpage */ +input#search_submit-button{ + background-color: #c08000; +} +input#search_query-box{ + background-color: #f0f0f0; +} +select#search_sortby-dropdown{ + background-color: #f0f0f0; +} +select#search_limit-dropdown{ + background-color: #f0f0f0; +} + + +/* home_*: styles for the default homepage */ + +div.home_news_date{ + font-weight: bold; +} +div#home_greeting{ + float: left; + width: 50%; +} +div#home_news{ + width: 100%; +} + + +/* *admin*: used on administration pages and admin-only content */ + +div#site_admin_nav{ + position: relative; + margin-top: 90pt; + clear: both; + margin-top: -.1pt; +} +div#site_admin_nav_upper_linkbar{ + background-color: #f0f0f0; +} +div#site_admin_nav_lower_infobar{ + background-color: #c08000; + text-align: right; +} +html>body div#site_admin_nav{ /* hack for firefox, disabled in opera and ie */ + margin-top: 0pt; +} +.admin_queue_alt1{ + background-color: #ffffff; +} +.admin_queue_alt2{ + background-color: #f0f0f0; +} +input#admin_login_username-box{ + background-color: #f0f0f0; +} +input#admin_login_password-box{ + background-color: #f0f0f0; +} +input#admin_login_submit-button{ + background-color: #c08000; +} + + +/* site_nav_*: navigation on the top, for everyone */ + +div#site_nav_lower{ + background-color: #f0f0f0; +} +div#site_nav_lower_linkbar{ + clear: both; + text-align: right; +} +div#site_nav_upper{ + background-color: #c08000; + padding: 3px; +} +div#site_nav_upper_qms{ + position: relative; + z-index: 1; + float: left; + font-size: 14pt; + font-weight: bold; + font-style: italic; +} +div#site_nav_upper_qms-long{ + position: relative; + z-index: 1; + float: right; + font-weight: bold; + font-size: 15pt; +} +div#site_nav{ + position: relative; + z-index: 0; +} + + +/* user-based functions */ +div#add_outputmsg_quote{ + padding-top: 10pt; + font-family: monospace; + padding-bottom: 10pt; +} + + +/* page titles */ +div#quote_origin-name{ + font-size: 23.6pt; + font-weight: bold; +} +div#search_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#admin_add-news_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#add_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#admin_queue_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#admin_flag_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#admin_change-pw_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#admin_users_title{ + font-size: 23.6pt; + font-weight: bold; +} +div#admin_add-user_title{ + font-size: 23.6pt; + font-weight: bold; +} + +div.quote_pagenums{ + text-align: center; +} diff --git a/theme/css/thickbox.css b/theme/css/thickbox.css new file mode 100755 index 0000000..0de29b2 --- /dev/null +++ b/theme/css/thickbox.css @@ -0,0 +1,164 @@ +/* ----------------------------------------------------------------------------------------------------------------*/ +/* ---------->>> global settings needed for thickbox <<<-----------------------------------------------------------*/ +/* ----------------------------------------------------------------------------------------------------------------*/ +*{padding: 0; margin: 0;} + +/* ----------------------------------------------------------------------------------------------------------------*/ +/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/ +/* ----------------------------------------------------------------------------------------------------------------*/ +#TB_window { + font: 12px Arial, Helvetica, sans-serif; + color: #333333; +} + +#TB_secondLine { + font: 10px Arial, Helvetica, sans-serif; + color:#666666; +} + +#TB_window a:link {color: #666666;} +#TB_window a:visited {color: #666666;} +#TB_window a:hover {color: #000;} +#TB_window a:active {color: #666666;} +#TB_window a:focus{color: #666666;} + +/* ----------------------------------------------------------------------------------------------------------------*/ +/* ---------->>> thickbox settings <<<-----------------------------------------------------------------------------*/ +/* ----------------------------------------------------------------------------------------------------------------*/ +#TB_overlay { + position: fixed; + z-index:100; + top: 0px; + left: 0px; + height:100%; + width:100%; +} + +.TB_overlayMacFFBGHack {background: url(macFFBgHack.png) repeat;} +.TB_overlayBG { + background-color:#000; + filter:alpha(opacity=75); + -moz-opacity: 0.75; + opacity: 0.75; +} + +* html #TB_overlay { /* ie6 hack */ + position: absolute; + height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); +} + +#TB_window { + position: fixed; + background: #ffffff; + z-index: 102; + color:#000000; + display:none; + border: 4px solid #525252; + text-align:left; + top:50%; + left:50%; +} + +* html #TB_window { /* ie6 hack */ +position: absolute; +margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); +} + +#TB_window img#TB_Image { + display:block; + margin: 15px 0 0 15px; + border-right: 1px solid #ccc; + border-bottom: 1px solid #ccc; + border-top: 1px solid #666; + border-left: 1px solid #666; +} + +#TB_caption{ + height:25px; + padding:7px 30px 10px 25px; + float:left; +} + +#TB_closeWindow{ + height:25px; + padding:11px 25px 10px 0; + float:right; +} + +#TB_closeAjaxWindow{ + padding:7px 10px 5px 0; + margin-bottom:1px; + text-align:right; + float:right; +} + +#TB_ajaxWindowTitle{ + float:left; + padding:7px 0 5px 10px; + margin-bottom:1px; +} + +#TB_title{ + background-color:#e8e8e8; + height:27px; +} + +#TB_ajaxContent{ + clear:both; + padding:2px 15px 15px 15px; + overflow:auto; + text-align:center; + line-height:1.4em; + background: url(/theme/images/backgrounds/island6.PNG) bottom; +} + +#TB_ajaxContent.TB_modal{ + padding:15px; +} + +#TB_ajaxContent p{ + padding:5px 0px 5px 0px; +} + +#TB_load{ + position: fixed; + display:none; + height:13px; + width:208px; + z-index:103; + top: 50%; + left: 50%; + margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */ +} + +* html #TB_load { /* ie6 hack */ +position: absolute; +margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); +} + +#TB_HideSelect{ + z-index:99; + position:fixed; + top: 0; + left: 0; + background-color:#fff; + border:none; + filter:alpha(opacity=0); + -moz-opacity: 0; + opacity: 0; + height:100%; + width:100%; +} + +* html #TB_HideSelect { /* ie6 hack */ + position: absolute; + height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); +} + +#TB_iframeContent{ + clear:both; + border:none; + margin-bottom:-1px; + margin-top:1px; + _margin-bottom:1px; +} diff --git a/theme/css/uniform.php b/theme/css/uniform.php new file mode 100644 index 0000000..0a57b49 --- /dev/null +++ b/theme/css/uniform.php @@ -0,0 +1,270 @@ +/* Four Island UniForm CSS */ + +/* uniForm */ + .uniForm{ + margin:0; padding:0; + position:relative; + width:100%; + /* user prefs */ + padding:10px 0; + } + + /* Some generals */ + .uniForm fieldset{ + border:none; + margin:0; padding:0; + /* user prefs */ + margin:0 0 7px 0; padding:0 0 10px 0; + border-bottom:1px solid #efefef; + } + .uniForm fieldset legend{ + color:#000; /* Reset IE */ + margin:0; padding:0; + /* user prefs */ + margin:0 0 .5em 0; + font:bold small-caps 100%/100% "lucida grande", "lucida sans unicode", "trebuchet ms", arial, verdana, sans-serif; + letter-spacing:.1em; + color:#93b5be; + } + + .ctrlHolder{ /* This is the main unit that contains our form "modules" */ + overflow:hidden; + margin:0; padding:0; + clear:both; + /* user prefs */ + background:#f9f9f9; + margin:0; padding:7px 4px; + } + + .buttonHolder{ + overflow:hidden; + clear:both; + /* user prefs */ + background:#f9f9f9; + border:1px solid #ccc; border-width:1px 0; + margin:10px 0 0 0; padding:10px; + text-align:right; + } + .resetButton{ + } + .submitButton{ + } + + .uniForm .inlineLabel{ + width:auto; + float:none; + display:inline; + /* user prefs */ + margin:0 2em 0 0; + font-weight:normal; + } + .uniForm .inlineLabel input{ + } + + /* Highlighting the rows on input focus */ + .focused{ + background:#FFFCDF url(/theme/images/uf_focused.png); + border:1px solid #EFE795; border-width:1px 0; + padding:6px 4px; + } + + + /* Styles for form controls where labels are in line with the input elements */ + /* Set the class to the parent to .inlineLabels */ + .inlineLabels .ctrlHolder{ + } + .inlineLabels label, + .inlineLabels .label{ + float:left; + margin:.3em 0 0 0; padding:0; + line-height:100%; + /* user prefs */ + width:30%; + font-weight:bold; + } + + .inlineLabels .textInput, + .inlineLabels .fileUpload{ + float:left; + /* user prefs */ + width:68%; + border:2px solid #dfdfdf; + } + .inlineLabels .fileUpload > input{ + } + + .inlineLabels .selectInput{ + float:left; + /* user prefs */ + width:69%; + border:2px solid #dfdfdf; + } + + .inlineLabels textarea{ + float:left; + width:68%; + /* user prefs */ + border:2px solid #dfdfdf; + height:12em; + } + + .inlineLabels .formHint{ + clear:both; + /* user prefs */ + color:#999; + margin:.5em 0 0 30%; padding:3px 0; + font-size:80%; + } + + /* inlineLabels esthetics */ + .inlineLabels .formHint strong{ + padding:0 0 0 14px; + background:url(/theme/images/icon_alert.png) 0 0 no-repeat; + display:inline-block; + } + + + /* ########################################################################## */ + + /* Styles for form controls where labels are above the input elements */ + /* Set the class to the parent to .blockLabels */ + .blockLabels .ctrlHolder{ + } + + .blockLabels label, + .blockLabels .label{ + display:block; + float:none; + margin:.3em 0; padding:0; + line-height:100%; + width:60%; + /* user prefs */ + font-weight:bold; + width:auto; + } + .blockLabels .label{ + float:left; + margin-right:3em; + } + + .blockLabels .textInput{ + float:left; + width:60%; + /* user prefs */ + border:2px solid #dfdfdf; + } + + .blockLabels .selectInput{ + float:left; + width:60%; + /* user prefs */ + border:2px solid #dfdfdf; + + } + + .blockLabels textarea{ + display:block; + float:left; + /* user prefs */ + border:2px solid #dfdfdf; + height:12em; + } + + .blockLabels .formHint{ + float:right; + margin:0; + width:38%; + clear:none; + /* user prefs */ + color:#999; + font-size:80%; + font-style:italic; + } + + /* blockLabels esthetics */ + .blockLabels .ctrlHolder{ + border:1px solid #dfdfdf; border-width:1px 0; + margin-top:-1px; + } + + .blockLabels .focused{ + padding:7px 4px; + } + + /* ########################################################################## */ + + /* Focus pseudoclasses */ + .ctrlHolder .textInput:focus{ + border-color:#DFD77D; + } + div.focused .textInput:focus{ + } + div.focused .formHint{ + color:#000; + } + + /* Required asterisk styling, use if needed */ + label em, + .label em{ + display:block; + position:absolute; left:28%; + font-style:normal; + font-weight:bold; + } + .blockLabels label em, + .blockLabels .label em{ + position:static; + display:inline; + } + + /* Messages */ + .uniForm #errorMsg{ + background:#ffdfdf url(/theme/images/uf_error.png); + border:1px solid #df7d7d; border-width:1px 0; + margin:0 0 1em 0; padding:1em; + } + .uniForm .error, + .uniForm .blockLabels.ctrlHolder.error{ + background:#ffdfdf url(/theme/images/uf_error.png); + border:1px solid #df7d7d; border-width:1px 0; + position:relative; + } + .uniForm #errorMsg dt, + .uniForm #errorMsg h3{ + margin:0 0 .5em 0; + font-size:110%; + line-height:100%; + font-weight:bold; + color:#000; + padding:2px 0 2px 18px; + background:url(/theme/images/icon-error.png) 0 0 no-repeat; + } + .uniForm #errorMsg dd{ + margin:0; padding:0; + } + .uniForm #errorMsg ol{ + margin:0; padding:0; + } + .uniForm #errorMsg ol li{ + margin:0; padding:2px; + list-style-position:inside; + border-bottom:1px dotted #df7d7d; + position:relative; + } + .uniForm .errorField{ + margin:0 0 3px 0; + } + .uniForm .inlineLabels .errorField{ + margin-left:30%; + } + .uniForm .errorField strong{ + background:#FFE2E2; + padding:1px 3px 3px 3px; + } + .ctrlHolder.error input, + .ctrlHolder.error input:focus{ + border-color:#DF7D7D; + } + .ctrlHolder.error.focused{ + padding:7px 4px; + } diff --git a/theme/css/website.php b/theme/css/website.php new file mode 100755 index 0000000..9b26d7c --- /dev/null +++ b/theme/css/website.php @@ -0,0 +1,843 @@ + +/* Four Island General CSS */ + +ul#bannernav, p { + margin:0pt; + padding:0pt; +} + +.idw-container { + text-align: none !important; +} + +p {margin-top: 1em;} + +ul, ol {margin-top: 1em; margin-bottom: 1em} + +/*li {margin-left: 60px}*/ + +::selection { + background: pink; +} +::-moz-selection { + background: pink; +} + +/* A (Links) */ + +A:link { + color: blue; + font-weight: bold; + text-decoration: none; +} + +A:visited { + color: blue; + text-decoration: none; +} + +A:hover { + color: blue; + font-weight: bold; + text-decoration: none; + font-variant: small-caps; + text-transform: capitalize; +} + +A:active { + color: blue; + text-decoration: none; +} + +a img { + border: 0; +} + +/* Random Elements */ + +hr { + height:1px; + color: gray; + background: gray; + border: none; + text-align: left; + margin-left: 0; +} + +.center { + text-align: center; +} + +img.center, img[align="center"] { + display: block; + margin-left: auto; + margin-right: auto; +} + +acronym, abbr, span.caps { + cursor: help; +} + +acronym, abbr { + border-bottom: 1px dashed #999; +} + + + +blockquote { + padding-left: 10px; + border-left: 3px solid #CCC; + font-family: helvetica; + font-size: 14px; + margin-top: 10px; + margin-bottom: 10px; + margin-left: 50px; +} + + + +pre { + line-height: 12px; +} + +.toolTip { + border-bottom: 1px dashed #999; + cursor: help; +} + +* html div#members { + position: absolute; +} + +#wrap { + width: 910px; + background: #FFFFFF url("/theme/images/bg_body.gif") repeat-y 0 0; + margin: 10px auto; + text-align: left; + padding: 0; + margin-top: 25px; +/* margin-left: 50px; */ +} + +#page-header { + background: url("/theme/images/bg_header.gif") repeat-x 0 0; + height: 150px; + clear: both; +} + +span.side-left, span.side-right { + display: block; + width: 20px; + height: 150px; + background: url("/theme/images/sides_top.gif") no-repeat; +} +span.side-left { + float: left; + margin-right: 10px; +} +span.side-right { + background-position: 100% 0; + float: right; +} +span.fcorners-bottom, span.fcorners-bottom span { + font-size: 1px; + line-height: 1px; + display: block; + height: 20px; + background-repeat: no-repeat; + background-image: url("/theme/images/corners_bottom.gif"); + margin: 0; +} +span.fcorners-bottom { + background-position: 0 0; +} +span.fcorners-bottom span { + background-position: 100% -20px; +} + + + +/* Banner */ + +div#banner, div#fi-banner { + background-repeat: no-repeat; + width: 850px; + height: 129px; + float: left; + margin-top: 21px; +} + +body div#banner h1, body div#fi-banner h1 { + margin: 0; +} + +body div#banner h1 a, body div#fi-banner h1 a { + display: block; + width: 850px; + height: 129px; + text-indent: -5000px; + text-decoration: none; + margin: 0; +} + +div#banner h1, div#fi-banner h1 { + margin: 0; + font-size: 3.0em; + font-weight: normal; +} + +div#banner div#bannerNav, div#fi-banner div#bannerNav { + position: relative; + top: -20px; +} + +#page-body { + margin: 0 30px; + clear: both; +} + +body.fourm #page-body { + margin-left: 25; + margin-right: 10; + width: 95%; + font-size: 62.5%; +} + +#phpBB3-page-body { + margin: 4px 0 !important; + clear: both; +} + +div#pageTabs { + float: left; + margin-left: -40px; + padding-top: 140px; +} + +body.fourm div#pageTabs { + margin-left: 0; +} + +div#pageTabs ul li { + list-style-type: none; + background-image: url("/theme/images/tabUn.png"); + display: block; + height: 37; + width: 100; + margin-bottom: 2px; + text-align: right; +} + +div#pageTabs ul li * { + padding-top: 4px; + padding-right: 2px; +} + +body.main div#pageTabs ul li#bannernav-home, +body.projects div#pageTabs ul li#bannernav-proj, +body.wiki div#pageTabs ul li#bannernav-wiki, +body.fourm div#pageTabs ul li#bannernav-fourm, +body.misc div#pageTabs ul li#bannernav-misc, +body.webs div#pageTabs ul li#bannernav-webs, +body.login div#pageTabs ul li#bannernav-login { + background-image: url("/theme/images/tabSe.png"); +} + +/* Sidebar */ + +div#rightbar { + float: right; + width: 250px; /*210*/ +/* clear: right; */ + padding: 0 10; +} + +div#iconbar { + text-align: center; + margin-left: 20px; +} + +div#iconbar ul li { + list-style-type: none; +} + +div.sidebar { + width: 250px; /*250*/ /*240*/ /*210*/ + padding: 0 10px; + margin-bottom: 5px; +} + +div.sidebar h3 { + font-family: Verdana, Helvetica, Arial, sans-serif; + margin: 5px 0 0 0; + font-weight: bold; + color: #333333; +} + +div.sidebar p { + font-size: 0.8em; + margin: 3px 0; +} + +span.corners-top, +span.corners-bottom { + margin: 0 -10px; + background-image: url("/theme/images/corners_left.png"); +} + +span.corners-top span, +span.corners-bottom span { + background-image: url("/theme/images/corners_right.png"); +} + +span.corners-top span { + background-position: 100% 0pt; +} + +span.corners-bottom { + background-position: 0pt 100%; +} + +span.corners-bottom span { + background-position: 100% 100%; +} + +span.corners-top, +span.corners-bottom, +span.corners-top span, +span.corners-bottom span { + background-repeat:no-repeat; + display:block; + font-size:1px; + height:5px; + line-height:1px; +} + +div.sidebar ul { + list-style-type: none; + padding: 0; + margin: 0; + line-height: normal !important; + list-style-image: none !important; +} + +div#sidebar ul li { + margin-top: 4px; +} + +div#sidebar ul li a { + display: block; + width: 230px; +} + +body.main div#sidebar div#hatnav ul li a#main, +body.about div#sidebar div#hatnav ul li a#about, +body.archive div#sidebar div#hatnav ul li a#archive, +body.winProg div#sidebar div#hatnav ul li a#winProg, +body.winGames div#sidebar div#hatnav ul li a#winGames, +body.flash div#sidebar div#hatnav ul li a#flash, +body.challenge div#sidebar div#hatnav ul li a#challenge, +body.experiment div#sidebar div#hatnav ul li a#experiment, +body.kfm div#sidebar div#hatnav ul li a#kfm, +body.mailchat div#sidebar div#hatnav ul li a#mailchat, +body.articles div#sidebar div#hatnav ul li a#articles, +body.poll div#sidebar div#hatnav ul li a#poll, +body.subversion div#sidebar div#hatnav ul li a#subversion { + background: #FEFFB2; + font-weight: bold; + text-decoration: none; + color: black; +} + +div#sidebar li img { + border: 0; + height: 16px; + width: 16px; +} + +/* Content */ + +div#content, div#fi-content { + float: left; + width: 555px; /*465*/ /*555*/ +} + +body#day div#page div#content code { + display: block; + border: solid black 1px; + background-color: #FFFF64; + width: 485px; + overflow: visible; +} + + + + +div#content h2 { + color: #59770e; + margin: 0px 0px 2px; + border-bottom: 1px dotted #CCCCCC; + letter-spacing: -1px; + font: normal 140%/100% "Trebuchet MS", Tahoma, Arial; + padding-bottom: 3px; +} + +/* Random Divs/Spans */ + +div#stripe { + position: fixed; + top: 0; + left: 0; + width: 100%; + background-color: #FBEC5D; + height: 20px; + z-index: 99; + padding-top: 5px; + text-align: center; +} + +* > html div#stripe { + position: absolute; +} + +div.autosize { + display: table; + width: 1px; +} + +div.autosize > div { + display: table-cell; +} + +div#chat { + float: right; + position: fixed; + bottom: 0; + background-color: brown; + color: white; + right: 20; + height: 100%; + width: 40%; +} + +div.cleardiv { + clear: both; + height: 1em; +} + +div#footer { + clear: both; + padding-bottom: 1em; + padding-top: .5em; + margin-top: .5em; + text-align: center; + font-size: .68em; + width: 100%; + border-top: 1px black solid; + border-bottom: 4px gray solid; +} + +div#footer ul.rows li { + display: list-item; +} + +#rightbar-bottom { + background: url("/theme/images/bg_footer.gif") repeat-x 0 100%; +} + +#pollOfTheWeek { + color: black; +} + +div.post { + clear: both; + padding-top: 15px; +} + +span.back-post { + float: left; + font-size: 0.9em; +} + +span.next-post { + float: right; + font-size: 0.9em; +} + +span.up-post { + font-size: 0.9em; +} + +div.post-date-1 { + width: 45px; + height: 49px; + float: left; + background: url(/theme/images/date-bg-1.gif) no-repeat; +} + +div.post-date-0 { + width: 45px; + height: 49px; + float: left; +} + +div.post-date-0 span.post-month { + color: #999999; + font-size: 18px; +} + +span.post-month { + font-size: 11px; + text-transform: uppercase; + color: #FFFFFF; + text-align: center; + display: block; + line-height: 11px; + padding-top: 2px; + margin-left: -3px; +} + +span.post-day { + font-size: 18px; + text-transform: uppercase; + color: #999999; + text-align: center; + display: block; + line-height: 18px; + padding-top: 7px; + margin-left: -3px; +} + +div.post-title { + float: left; + margin-left: 10px; + width: 500px; /* 430px */ +} + +div.entry { + clear: both; + padding-top: 10px; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; +} + + +span.post-cat- { + background: url(/theme/images/authors/.ico) no-repeat; + padding-left: 20px; + float: left; + font-size: 95%; + color: #999999; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; +} + + +span.post-comment { + background: url(/theme/images/icons/comment.png) no-repeat; + padding-left: 20px; + float: right; + font-size: 95%; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; +} + +span.mini-add-comment { + background: url(/theme/images/icons/comment_add.png) no-repeat; + padding-left: 18px; + float: right; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; +} + +span.post-comments { + background: url(/theme/images/icons/comments.png) no-repeat; + padding-left: 20px; + float: right; + font-size: 95%; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; +} + +div#page { + /*margin: 0 auto;*/ + padding: 0; + width: 850px; + position: relative; + left: 50%; + margin-left: -422px; +} + +div#footer ul { + padding: 0; + margin: 0; + list-style-type: none; +} + +div#footer ul li { + display: inline; + margin-right: 1em; +} + +div#footer ul li img { + width: 20px; + height: 20px; + vertical-align: top; +} + + + +div#content ul { + list-style: url(/theme/images/bullet_disk_big.png); +} + + + +div.push { + clear: both; + height: 20px; +} + +span.print { + display: none; +} + +span.post-tag-1 { + background: url(/theme/images/icons/tag.png) no-repeat; + padding-left: 20px; + margin-left: 90px; + float: left; + font-size: 95%; + color: #999999; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; + text-transform: capitalize; +} + +form textarea:focus, form input:focus { + border: 2px solid #900; + background-color: #FEFFB2; +} + +span.post-tag-2 { + background: url(/theme/images/icons/tag.png) no-repeat; + padding-left: 20px; + margin-left: 75px; + float: left; + font-size: 95%; + color: #999999; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; + text-transform: capitalize; +} + +span.post-tag-3 { + background: url(/theme/images/icons/tag.png) no-repeat; + padding-left: 20px; + margin-left: 35px; + float: left; + font-size: 95%; + color: #999999; + font: 75%/150% Arial, "Trebuchet MS", Tahoma; + text-transform: capitalize; +} + +div.post-date-2 { + width: 45px; + height: 49px; + float: left; + background: url(/theme/images/date-bg-2.gif) no-repeat; +} + +div.post-date-3 { + width: 45px; + height: 49px; + float: left; + background: url(/theme/images/date-bg-3.gif) no-repeat; +} + +div.post-date-4 { + width: 45px; + height: 49px; + float: left; + background: url(/theme/images/date-bg-4.gif) no-repeat; +} + +div#members { + position: fixed; + left: -40px; + top: 20px; +} + +div#members ul li { + list-style-type: none; +} + +div#members ul li a { + color: white; + width: 100px; + height: 30px; + padding-right: 5px; + background-image: url(/theme/images/tabBG.png); + display: block; + text-align: right; + padding-top: 5px; + padding-bottom: 0px; + background-repeat: no-repeat; +} + +div#members ul li a:hover { + background-image: url(/theme/images/tabBG2.png); +} + +div#content a img { + border: solid transparent 1px; +} + +div#content a:hover img { + border: dashed gray 1px; +} + +div.morePost { + border-top: gray 1px dashed; +} + +div.plainText { + font-family: Courier New; + font-size: small; +} + +div.breadcrumb { + margin-bottom: 10px; + font-size: 10px; + border-bottom: 1px dotted black; +} + +.delicious-posts { margin: 1em; padding: 0.5em; font-family: sans-serif; } +.delicious-posts ul, .delicious-posts li, .delicious-banner { margin: 0; padding: 0} +.delicious-post { border-top: 1px solid #eee; padding: 0.25em; font-size: 80% } +.delicious-posts a:hover { text-decoration: underline } + +/* #twitter_div { + margin: 1em; + padding: 0.5em; + font-family: sans-serif; +} */ + +/* #twitter_div ul, #twitter_div li, .twitter-title { + margin: 0; + padding: 0; +} */ + +.twitter_update_list { + list-style-type: none; +} + +.twitter_update_list li { + /* border-top: 1px solid #eee; + padding: 0.25em; */ + display: inline; +} + +/* .twitter-title { + margin-left: -20px; + font-size: 120%; +} */ + +.dispIfNew a:visited img { + display: none; +} + +/* Tables */ + +table.webmail { + border: 0; + width: 100%; +} + +table.webmail, table.webmail td { + border-spacing: 0; +} + +table.webmail tr { + background-color: #3CE4ED; +} + +table.webmail tr.even { + background-color: #39B7CD; +} + +table.webmail th { + background-color: #FF9912; + text-align: left; +} + +table.webmail td { + word-wrap: break-word; +} + +/* Print Only */ + +@media print { + body { + width: 100% !important; + } + + div#banner, div#footer, div#members { + display: none; + } + + span.print { + display: inline; + } + + div#cleardiv { + clear: none; + } +} diff --git a/theme/datefinder.tpl b/theme/datefinder.tpl new file mode 100644 index 0000000..e69de29 diff --git a/theme/errors/404.tpl b/theme/errors/404.tpl new file mode 100644 index 0000000..1758a57 --- /dev/null +++ b/theme/errors/404.tpl @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + +
    +

    Hello, my name is Waddle Dee

    +
    Aaaa.... well... I'm really sorry, but I can't find the page you're looking for. Really, I'm so sorry! Please don't tell Hat Kirby! This is the 17'th page I lost this week!
    +

    Oh wait. Here we go. We can't find your page because... hmmm... oh not again... It seems Kirby ate the page you are looking for.
    Yes, I'm really sorry! He gets really hungry sometimes (all of the time) but we try to keep him fed. Anyway, instead of talking to me, you can:

    + + + + +

    I'm sure you'll have fun.

    +

    Oh, oh! More info has come in! You may not be able to find the page because of:

    + +
      +
    1. An out-of-date bookmark/favourite
    2. +
    3. A search engine that has an out-of-date listing for us
    4. +
    5. A mis-typed address
    6. +
    + + + +

    Oh, oh! More info has come in!

    +

    You did a search on for "". However, their index appears to be out of date. (Because Kirby ate the page)

    All is not lost!

    Why not try these links?

    + +

    I'm sure you'll have fun.

    + + + +

    Oh, oh! More info has come in!

    +

    You were referred to this page by:
    I guess they didn't know that Kirby ate the page.

    + +

    Wait a minute! That's us! Uh oh! It looks like one of our own links is broken - I'm really sorry about this, and I'll try to fix it before Hatkirby notices. Please send an email to the email address on the HatBar. Thanks!

    + +

    Why not try one of these links?

    + +

    I'm sure you'll have fun.

    + + +

    Oh wait, I have to go. Hat Kirby's coming, and I better have an explanation for this one!

    +


    +

    Kirby 404
    Property of hatkirby

    +
    diff --git a/theme/footer.tpl b/theme/footer.tpl new file mode 100644 index 0000000..220e0f7 --- /dev/null +++ b/theme/footer.tpl @@ -0,0 +1,241 @@ + + + +
    + + + + + + + + + + + + + + + + + + +

    + +

    + + + + +
    + + +
    + + +
    + +
    + + + + + + + + + + diff --git a/theme/footer.tpl~ b/theme/footer.tpl~ new file mode 100644 index 0000000..b332f0f --- /dev/null +++ b/theme/footer.tpl~ @@ -0,0 +1,225 @@ + + + +
    + + + + + + + + + + + + + + + + + + +

    + +

    + + + + +
    + + +
    + + +
    + +
    + + + + + + + + + + diff --git a/theme/header.tpl b/theme/header.tpl new file mode 100644 index 0000000..e0d000a --- /dev/null +++ b/theme/header.tpl @@ -0,0 +1,64 @@ + + + <!--EXTRATITLE-->Four Island + + + + + + + + + + + + + + + + + + + + + + + + > +
    + You can get notifications on new Four Island posts either via + RSS + or + Email +
    + +
    + + + + +
    + +
    +
    diff --git a/theme/hits.tpl b/theme/hits.tpl new file mode 100644 index 0000000..e69de29 diff --git a/theme/images/Fourm.gif b/theme/images/Fourm.gif new file mode 100755 index 0000000..1365fd6 Binary files /dev/null and b/theme/images/Fourm.gif differ diff --git a/theme/images/Fourm_ro.gif b/theme/images/Fourm_ro.gif new file mode 100755 index 0000000..8a1cad6 Binary files /dev/null and b/theme/images/Fourm_ro.gif differ diff --git a/theme/images/Home.gif b/theme/images/Home.gif new file mode 100755 index 0000000..e3e523d Binary files /dev/null and b/theme/images/Home.gif differ diff --git a/theme/images/Home_ro.gif b/theme/images/Home_ro.gif new file mode 100755 index 0000000..b409d75 Binary files /dev/null and b/theme/images/Home_ro.gif differ diff --git a/theme/images/Links.gif b/theme/images/Links.gif new file mode 100755 index 0000000..a223b3e Binary files /dev/null and b/theme/images/Links.gif differ diff --git a/theme/images/Links_ro.gif b/theme/images/Links_ro.gif new file mode 100755 index 0000000..d540220 Binary files /dev/null and b/theme/images/Links_ro.gif differ diff --git a/theme/images/Login.gif b/theme/images/Login.gif new file mode 100644 index 0000000..3573589 Binary files /dev/null and b/theme/images/Login.gif differ diff --git a/theme/images/Login_ro.gif b/theme/images/Login_ro.gif new file mode 100644 index 0000000..404f305 Binary files /dev/null and b/theme/images/Login_ro.gif differ diff --git a/theme/images/Logout.gif b/theme/images/Logout.gif new file mode 100644 index 0000000..12696fe Binary files /dev/null and b/theme/images/Logout.gif differ diff --git a/theme/images/Logout_ro.gif b/theme/images/Logout_ro.gif new file mode 100644 index 0000000..ff103a2 Binary files /dev/null and b/theme/images/Logout_ro.gif differ diff --git a/theme/images/Panel.gif b/theme/images/Panel.gif new file mode 100644 index 0000000..42075dc Binary files /dev/null and b/theme/images/Panel.gif differ diff --git a/theme/images/Panel_ro.gif b/theme/images/Panel_ro.gif new file mode 100644 index 0000000..e64c5ad Binary files /dev/null and b/theme/images/Panel_ro.gif differ diff --git a/theme/images/Poll.gif b/theme/images/Poll.gif new file mode 100644 index 0000000..08815d2 Binary files /dev/null and b/theme/images/Poll.gif differ diff --git a/theme/images/Poll_ro.gif b/theme/images/Poll_ro.gif new file mode 100644 index 0000000..6a4549f Binary files /dev/null and b/theme/images/Poll_ro.gif differ diff --git a/theme/images/Projects.gif b/theme/images/Projects.gif new file mode 100755 index 0000000..bf0cfc7 Binary files /dev/null and b/theme/images/Projects.gif differ diff --git a/theme/images/Projects_ro.gif b/theme/images/Projects_ro.gif new file mode 100755 index 0000000..718ab03 Binary files /dev/null and b/theme/images/Projects_ro.gif differ diff --git a/theme/images/Quotes.gif b/theme/images/Quotes.gif new file mode 100644 index 0000000..8bf0289 Binary files /dev/null and b/theme/images/Quotes.gif differ diff --git a/theme/images/Quotes_ro.gif b/theme/images/Quotes_ro.gif new file mode 100644 index 0000000..f15831c Binary files /dev/null and b/theme/images/Quotes_ro.gif differ diff --git a/theme/images/Random.gif b/theme/images/Random.gif new file mode 100755 index 0000000..94cb4be Binary files /dev/null and b/theme/images/Random.gif differ diff --git a/theme/images/Random_ro.gif b/theme/images/Random_ro.gif new file mode 100755 index 0000000..4e62f24 Binary files /dev/null and b/theme/images/Random_ro.gif differ diff --git a/theme/images/Wiki.gif b/theme/images/Wiki.gif new file mode 100644 index 0000000..e4a0cc7 Binary files /dev/null and b/theme/images/Wiki.gif differ diff --git a/theme/images/Wiki_ro.gif b/theme/images/Wiki_ro.gif new file mode 100644 index 0000000..b8d9438 Binary files /dev/null and b/theme/images/Wiki_ro.gif differ diff --git a/theme/images/authors/Hatkirby.ico b/theme/images/authors/Hatkirby.ico new file mode 100755 index 0000000..fbc13bd Binary files /dev/null and b/theme/images/authors/Hatkirby.ico differ diff --git a/theme/images/authors/Starla.ico b/theme/images/authors/Starla.ico new file mode 100755 index 0000000..fbc13bd Binary files /dev/null and b/theme/images/authors/Starla.ico differ diff --git a/theme/images/backgrounds/4ofjuly.PNG b/theme/images/backgrounds/4ofjuly.PNG new file mode 100755 index 0000000..41c71ea Binary files /dev/null and b/theme/images/backgrounds/4ofjuly.PNG differ diff --git a/theme/images/backgrounds/ashWeds.PNG b/theme/images/backgrounds/ashWeds.PNG new file mode 100755 index 0000000..b1f9db4 Binary files /dev/null and b/theme/images/backgrounds/ashWeds.PNG differ diff --git a/theme/images/backgrounds/christmas.PNG b/theme/images/backgrounds/christmas.PNG new file mode 100755 index 0000000..7491fa6 Binary files /dev/null and b/theme/images/backgrounds/christmas.PNG differ diff --git a/theme/images/backgrounds/christmasEve.PNG b/theme/images/backgrounds/christmasEve.PNG new file mode 100755 index 0000000..7f10edb Binary files /dev/null and b/theme/images/backgrounds/christmasEve.PNG differ diff --git a/theme/images/backgrounds/columbus.PNG b/theme/images/backgrounds/columbus.PNG new file mode 100755 index 0000000..069f2fd Binary files /dev/null and b/theme/images/backgrounds/columbus.PNG differ diff --git a/theme/images/backgrounds/easter.PNG b/theme/images/backgrounds/easter.PNG new file mode 100755 index 0000000..8a40688 Binary files /dev/null and b/theme/images/backgrounds/easter.PNG differ diff --git a/theme/images/backgrounds/fathers.PNG b/theme/images/backgrounds/fathers.PNG new file mode 100755 index 0000000..f0ba36f Binary files /dev/null and b/theme/images/backgrounds/fathers.PNG differ diff --git a/theme/images/backgrounds/flagDay.PNG b/theme/images/backgrounds/flagDay.PNG new file mode 100755 index 0000000..6440e46 Binary files /dev/null and b/theme/images/backgrounds/flagDay.PNG differ diff --git a/theme/images/backgrounds/goodFriday.PNG b/theme/images/backgrounds/goodFriday.PNG new file mode 100755 index 0000000..3eb2c0c Binary files /dev/null and b/theme/images/backgrounds/goodFriday.PNG differ diff --git a/theme/images/backgrounds/groundhog.PNG b/theme/images/backgrounds/groundhog.PNG new file mode 100755 index 0000000..3e7229e Binary files /dev/null and b/theme/images/backgrounds/groundhog.PNG differ diff --git a/theme/images/backgrounds/halloween.PNG b/theme/images/backgrounds/halloween.PNG new file mode 100755 index 0000000..b9897c6 Binary files /dev/null and b/theme/images/backgrounds/halloween.PNG differ diff --git a/theme/images/backgrounds/hatkirbybday.PNG b/theme/images/backgrounds/hatkirbybday.PNG new file mode 100755 index 0000000..f82354e Binary files /dev/null and b/theme/images/backgrounds/hatkirbybday.PNG differ diff --git a/theme/images/backgrounds/island.PNG b/theme/images/backgrounds/island.PNG new file mode 100755 index 0000000..440f8e2 Binary files /dev/null and b/theme/images/backgrounds/island.PNG differ diff --git a/theme/images/backgrounds/island2.PNG b/theme/images/backgrounds/island2.PNG new file mode 100755 index 0000000..7127a0f Binary files /dev/null and b/theme/images/backgrounds/island2.PNG differ diff --git a/theme/images/backgrounds/island3.PNG b/theme/images/backgrounds/island3.PNG new file mode 100755 index 0000000..bf74ab9 Binary files /dev/null and b/theme/images/backgrounds/island3.PNG differ diff --git a/theme/images/backgrounds/island4.PNG b/theme/images/backgrounds/island4.PNG new file mode 100755 index 0000000..3b31e79 Binary files /dev/null and b/theme/images/backgrounds/island4.PNG differ diff --git a/theme/images/backgrounds/island5.PNG b/theme/images/backgrounds/island5.PNG new file mode 100755 index 0000000..081a51c Binary files /dev/null and b/theme/images/backgrounds/island5.PNG differ diff --git a/theme/images/backgrounds/island6.PNG b/theme/images/backgrounds/island6.PNG new file mode 100755 index 0000000..319eeeb Binary files /dev/null and b/theme/images/backgrounds/island6.PNG differ diff --git a/theme/images/backgrounds/island6night.PNG b/theme/images/backgrounds/island6night.PNG new file mode 100755 index 0000000..95e9558 Binary files /dev/null and b/theme/images/backgrounds/island6night.PNG differ diff --git a/theme/images/backgrounds/islandYearly.PNG b/theme/images/backgrounds/islandYearly.PNG new file mode 100755 index 0000000..4125be6 Binary files /dev/null and b/theme/images/backgrounds/islandYearly.PNG differ diff --git a/theme/images/backgrounds/kirbyweek.PNG b/theme/images/backgrounds/kirbyweek.PNG new file mode 100755 index 0000000..202c5e0 Binary files /dev/null and b/theme/images/backgrounds/kirbyweek.PNG differ diff --git a/theme/images/backgrounds/mardiGras.PNG b/theme/images/backgrounds/mardiGras.PNG new file mode 100755 index 0000000..131efd2 Binary files /dev/null and b/theme/images/backgrounds/mardiGras.PNG differ diff --git a/theme/images/backgrounds/martinLuther.PNG b/theme/images/backgrounds/martinLuther.PNG new file mode 100755 index 0000000..8313af8 Binary files /dev/null and b/theme/images/backgrounds/martinLuther.PNG differ diff --git a/theme/images/backgrounds/memorial.PNG b/theme/images/backgrounds/memorial.PNG new file mode 100755 index 0000000..cc5be0a Binary files /dev/null and b/theme/images/backgrounds/memorial.PNG differ diff --git a/theme/images/backgrounds/mothers.PNG b/theme/images/backgrounds/mothers.PNG new file mode 100755 index 0000000..3c7d69d Binary files /dev/null and b/theme/images/backgrounds/mothers.PNG differ diff --git a/theme/images/backgrounds/newYear.PNG b/theme/images/backgrounds/newYear.PNG new file mode 100755 index 0000000..9884051 Binary files /dev/null and b/theme/images/backgrounds/newYear.PNG differ diff --git a/theme/images/backgrounds/newYearsEve.PNG b/theme/images/backgrounds/newYearsEve.PNG new file mode 100755 index 0000000..81f9a5b Binary files /dev/null and b/theme/images/backgrounds/newYearsEve.PNG differ diff --git a/theme/images/backgrounds/valentines.PNG b/theme/images/backgrounds/valentines.PNG new file mode 100755 index 0000000..7d105a9 Binary files /dev/null and b/theme/images/backgrounds/valentines.PNG differ diff --git a/theme/images/backgrounds/veterans.PNG b/theme/images/backgrounds/veterans.PNG new file mode 100755 index 0000000..a0a5a03 Binary files /dev/null and b/theme/images/backgrounds/veterans.PNG differ diff --git a/theme/images/bg_body.gif b/theme/images/bg_body.gif new file mode 100755 index 0000000..80d75d5 Binary files /dev/null and b/theme/images/bg_body.gif differ diff --git a/theme/images/bg_body_short.gif b/theme/images/bg_body_short.gif new file mode 100644 index 0000000..b396204 Binary files /dev/null and b/theme/images/bg_body_short.gif differ diff --git a/theme/images/bg_footer.gif b/theme/images/bg_footer.gif new file mode 100755 index 0000000..ff3f511 Binary files /dev/null and b/theme/images/bg_footer.gif differ diff --git a/theme/images/bg_header.gif b/theme/images/bg_header.gif new file mode 100755 index 0000000..46c22e8 Binary files /dev/null and b/theme/images/bg_header.gif differ diff --git a/theme/images/bg_navbar.gif b/theme/images/bg_navbar.gif new file mode 100755 index 0000000..d96c6ea Binary files /dev/null and b/theme/images/bg_navbar.gif differ diff --git a/theme/images/bg_search.gif b/theme/images/bg_search.gif new file mode 100644 index 0000000..79e040e Binary files /dev/null and b/theme/images/bg_search.gif differ diff --git a/theme/images/blue.PNG b/theme/images/blue.PNG new file mode 100755 index 0000000..e274621 Binary files /dev/null and b/theme/images/blue.PNG differ diff --git a/theme/images/corners_bottom.gif b/theme/images/corners_bottom.gif new file mode 100755 index 0000000..bea794f Binary files /dev/null and b/theme/images/corners_bottom.gif differ diff --git a/theme/images/corners_left.png b/theme/images/corners_left.png new file mode 100755 index 0000000..256bde3 Binary files /dev/null and b/theme/images/corners_left.png differ diff --git a/theme/images/corners_right.png b/theme/images/corners_right.png new file mode 100755 index 0000000..df41823 Binary files /dev/null and b/theme/images/corners_right.png differ diff --git a/theme/images/date-bg-1.gif b/theme/images/date-bg-1.gif new file mode 100755 index 0000000..cb7a771 Binary files /dev/null and b/theme/images/date-bg-1.gif differ diff --git a/theme/images/date-bg-2.gif b/theme/images/date-bg-2.gif new file mode 100755 index 0000000..49efaef Binary files /dev/null and b/theme/images/date-bg-2.gif differ diff --git a/theme/images/date-bg-3.gif b/theme/images/date-bg-3.gif new file mode 100755 index 0000000..60a6888 Binary files /dev/null and b/theme/images/date-bg-3.gif differ diff --git a/theme/images/date-bg-4.gif b/theme/images/date-bg-4.gif new file mode 100755 index 0000000..685e5c1 Binary files /dev/null and b/theme/images/date-bg-4.gif differ diff --git a/theme/images/headers/ctnh.png b/theme/images/headers/ctnh.png new file mode 100644 index 0000000..b9542fc Binary files /dev/null and b/theme/images/headers/ctnh.png differ diff --git a/theme/images/headers/fourm.png b/theme/images/headers/fourm.png new file mode 100644 index 0000000..e7bebde Binary files /dev/null and b/theme/images/headers/fourm.png differ diff --git a/theme/images/headers/hatkirbybday.png b/theme/images/headers/hatkirbybday.png new file mode 100644 index 0000000..ba7bff0 Binary files /dev/null and b/theme/images/headers/hatkirbybday.png differ diff --git a/theme/images/headers/islandYearly.png b/theme/images/headers/islandYearly.png new file mode 100644 index 0000000..099d963 Binary files /dev/null and b/theme/images/headers/islandYearly.png differ diff --git a/theme/images/headers/kfm.png b/theme/images/headers/kfm.png new file mode 100644 index 0000000..cc568ec Binary files /dev/null and b/theme/images/headers/kfm.png differ diff --git a/theme/images/headers/links.png b/theme/images/headers/links.png new file mode 100644 index 0000000..b24ded0 Binary files /dev/null and b/theme/images/headers/links.png differ diff --git a/theme/images/headers/main.png b/theme/images/headers/main.png new file mode 100755 index 0000000..009d3ac Binary files /dev/null and b/theme/images/headers/main.png differ diff --git a/theme/images/headers/main.xcf b/theme/images/headers/main.xcf new file mode 100755 index 0000000..fd37ee4 Binary files /dev/null and b/theme/images/headers/main.xcf differ diff --git a/theme/images/headers/memorial.png b/theme/images/headers/memorial.png new file mode 100644 index 0000000..b68b97d Binary files /dev/null and b/theme/images/headers/memorial.png differ diff --git a/theme/images/headers/mothers.png b/theme/images/headers/mothers.png new file mode 100644 index 0000000..e656d7d Binary files /dev/null and b/theme/images/headers/mothers.png differ diff --git a/theme/images/headers/potw.png b/theme/images/headers/potw.png new file mode 100644 index 0000000..9ce3174 Binary files /dev/null and b/theme/images/headers/potw.png differ diff --git a/theme/images/headers/projects.png b/theme/images/headers/projects.png new file mode 100644 index 0000000..d59f47a Binary files /dev/null and b/theme/images/headers/projects.png differ diff --git a/theme/images/headers/projects.xcf b/theme/images/headers/projects.xcf new file mode 100644 index 0000000..f1950ad Binary files /dev/null and b/theme/images/headers/projects.xcf differ diff --git a/theme/images/headers/quotes.png b/theme/images/headers/quotes.png new file mode 100644 index 0000000..9fb966e Binary files /dev/null and b/theme/images/headers/quotes.png differ diff --git a/theme/images/headers/random.png b/theme/images/headers/random.png new file mode 100644 index 0000000..e7db228 Binary files /dev/null and b/theme/images/headers/random.png differ diff --git a/theme/images/headers/short.png b/theme/images/headers/short.png new file mode 100644 index 0000000..4d4d267 Binary files /dev/null and b/theme/images/headers/short.png differ diff --git a/theme/images/home.png b/theme/images/home.png new file mode 100755 index 0000000..2615467 Binary files /dev/null and b/theme/images/home.png differ diff --git a/theme/images/icons/16-clock.png b/theme/images/icons/16-clock.png new file mode 100644 index 0000000..b583ae4 Binary files /dev/null and b/theme/images/icons/16-clock.png differ diff --git a/theme/images/icons/16-em-pencil.png b/theme/images/icons/16-em-pencil.png new file mode 100644 index 0000000..006974c Binary files /dev/null and b/theme/images/icons/16-em-pencil.png differ diff --git a/theme/images/icons/16-file-archive.png b/theme/images/icons/16-file-archive.png new file mode 100644 index 0000000..737bb5b Binary files /dev/null and b/theme/images/icons/16-file-archive.png differ diff --git a/theme/images/icons/16-file-page.png b/theme/images/icons/16-file-page.png new file mode 100644 index 0000000..2bae432 Binary files /dev/null and b/theme/images/icons/16-file-page.png differ diff --git a/theme/images/icons/16-message-warn.png b/theme/images/icons/16-message-warn.png new file mode 100644 index 0000000..3d41fec Binary files /dev/null and b/theme/images/icons/16-message-warn.png differ diff --git a/theme/images/icons/16-star-hot.png b/theme/images/icons/16-star-hot.png new file mode 100644 index 0000000..8a7d83c Binary files /dev/null and b/theme/images/icons/16-star-hot.png differ diff --git a/theme/images/icons/book_open.png b/theme/images/icons/book_open.png new file mode 100755 index 0000000..7d863f9 Binary files /dev/null and b/theme/images/icons/book_open.png differ diff --git a/theme/images/icons/bricks.png b/theme/images/icons/bricks.png new file mode 100755 index 0000000..0905f93 Binary files /dev/null and b/theme/images/icons/bricks.png differ diff --git a/theme/images/icons/comment.png b/theme/images/icons/comment.png new file mode 100755 index 0000000..7bc9233 Binary files /dev/null and b/theme/images/icons/comment.png differ diff --git a/theme/images/icons/comment_add.png b/theme/images/icons/comment_add.png new file mode 100755 index 0000000..75e78de Binary files /dev/null and b/theme/images/icons/comment_add.png differ diff --git a/theme/images/icons/comments.png b/theme/images/icons/comments.png new file mode 100755 index 0000000..39433cf Binary files /dev/null and b/theme/images/icons/comments.png differ diff --git a/theme/images/icons/computer.png b/theme/images/icons/computer.png new file mode 100755 index 0000000..9bc37dc Binary files /dev/null and b/theme/images/icons/computer.png differ diff --git a/theme/images/icons/controller.png b/theme/images/icons/controller.png new file mode 100755 index 0000000..5cf76ed Binary files /dev/null and b/theme/images/icons/controller.png differ diff --git a/theme/images/icons/css_valid.png b/theme/images/icons/css_valid.png new file mode 100755 index 0000000..4c72ca5 Binary files /dev/null and b/theme/images/icons/css_valid.png differ diff --git a/theme/images/icons/door_in.png b/theme/images/icons/door_in.png new file mode 100755 index 0000000..41676a0 Binary files /dev/null and b/theme/images/icons/door_in.png differ diff --git a/theme/images/icons/door_out.png b/theme/images/icons/door_out.png new file mode 100755 index 0000000..2541d2b Binary files /dev/null and b/theme/images/icons/door_out.png differ diff --git a/theme/images/icons/feed.png b/theme/images/icons/feed.png new file mode 100755 index 0000000..315c4f4 Binary files /dev/null and b/theme/images/icons/feed.png differ diff --git a/theme/images/icons/fourm.png b/theme/images/icons/fourm.png new file mode 100755 index 0000000..b7675de Binary files /dev/null and b/theme/images/icons/fourm.png differ diff --git a/theme/images/icons/house.png b/theme/images/icons/house.png new file mode 100755 index 0000000..fed6221 Binary files /dev/null and b/theme/images/icons/house.png differ diff --git a/theme/images/icons/html_valid.png b/theme/images/icons/html_valid.png new file mode 100755 index 0000000..71cec92 Binary files /dev/null and b/theme/images/icons/html_valid.png differ diff --git a/theme/images/icons/link_delete.png b/theme/images/icons/link_delete.png new file mode 100755 index 0000000..f66e297 Binary files /dev/null and b/theme/images/icons/link_delete.png differ diff --git a/theme/images/icons/link_edit.png b/theme/images/icons/link_edit.png new file mode 100755 index 0000000..5b3aed0 Binary files /dev/null and b/theme/images/icons/link_edit.png differ diff --git a/theme/images/icons/medal_gold_1.png b/theme/images/icons/medal_gold_1.png new file mode 100755 index 0000000..87584dc Binary files /dev/null and b/theme/images/icons/medal_gold_1.png differ diff --git a/theme/images/icons/new.png b/theme/images/icons/new.png new file mode 100755 index 0000000..6a9bf03 Binary files /dev/null and b/theme/images/icons/new.png differ diff --git a/theme/images/icons/newspaper.png b/theme/images/icons/newspaper.png new file mode 100755 index 0000000..6a2ecce Binary files /dev/null and b/theme/images/icons/newspaper.png differ diff --git a/theme/images/icons/note.png b/theme/images/icons/note.png new file mode 100755 index 0000000..244e6ca Binary files /dev/null and b/theme/images/icons/note.png differ diff --git a/theme/images/icons/note_delete.png b/theme/images/icons/note_delete.png new file mode 100755 index 0000000..8a1f0ff Binary files /dev/null and b/theme/images/icons/note_delete.png differ diff --git a/theme/images/icons/note_edit.png b/theme/images/icons/note_edit.png new file mode 100755 index 0000000..291bfc7 Binary files /dev/null and b/theme/images/icons/note_edit.png differ diff --git a/theme/images/icons/note_go.png b/theme/images/icons/note_go.png new file mode 100755 index 0000000..49e54fd Binary files /dev/null and b/theme/images/icons/note_go.png differ diff --git a/theme/images/icons/overlays.png b/theme/images/icons/overlays.png new file mode 100755 index 0000000..ab3100b Binary files /dev/null and b/theme/images/icons/overlays.png differ diff --git a/theme/images/icons/page_attach.png b/theme/images/icons/page_attach.png new file mode 100755 index 0000000..89ee2da Binary files /dev/null and b/theme/images/icons/page_attach.png differ diff --git a/theme/images/icons/page_delete.png b/theme/images/icons/page_delete.png new file mode 100755 index 0000000..3141467 Binary files /dev/null and b/theme/images/icons/page_delete.png differ diff --git a/theme/images/icons/page_edit.png b/theme/images/icons/page_edit.png new file mode 100755 index 0000000..046811e Binary files /dev/null and b/theme/images/icons/page_edit.png differ diff --git a/theme/images/icons/page_go.png b/theme/images/icons/page_go.png new file mode 100755 index 0000000..80fe1ed Binary files /dev/null and b/theme/images/icons/page_go.png differ diff --git a/theme/images/icons/rainbow.png b/theme/images/icons/rainbow.png new file mode 100755 index 0000000..5ede989 Binary files /dev/null and b/theme/images/icons/rainbow.png differ diff --git a/theme/images/icons/report.png b/theme/images/icons/report.png new file mode 100755 index 0000000..779ad58 Binary files /dev/null and b/theme/images/icons/report.png differ diff --git a/theme/images/icons/script.png b/theme/images/icons/script.png new file mode 100755 index 0000000..0f9ed4d Binary files /dev/null and b/theme/images/icons/script.png differ diff --git a/theme/images/icons/tag.png b/theme/images/icons/tag.png new file mode 100755 index 0000000..e093032 Binary files /dev/null and b/theme/images/icons/tag.png differ diff --git a/theme/images/icons/tag_blue.png b/theme/images/icons/tag_blue.png new file mode 100755 index 0000000..9757fc6 Binary files /dev/null and b/theme/images/icons/tag_blue.png differ diff --git a/theme/images/icons/tag_blue_add.png b/theme/images/icons/tag_blue_add.png new file mode 100755 index 0000000..f135248 Binary files /dev/null and b/theme/images/icons/tag_blue_add.png differ diff --git a/theme/images/icons/tag_blue_delete.png b/theme/images/icons/tag_blue_delete.png new file mode 100755 index 0000000..9fbae67 Binary files /dev/null and b/theme/images/icons/tag_blue_delete.png differ diff --git a/theme/images/icons/tag_blue_edit.png b/theme/images/icons/tag_blue_edit.png new file mode 100755 index 0000000..2a9f626 Binary files /dev/null and b/theme/images/icons/tag_blue_edit.png differ diff --git a/theme/images/icons/tag_green.png b/theme/images/icons/tag_green.png new file mode 100755 index 0000000..83ec984 Binary files /dev/null and b/theme/images/icons/tag_green.png differ diff --git a/theme/images/icons/tag_orange.png b/theme/images/icons/tag_orange.png new file mode 100755 index 0000000..454a59f Binary files /dev/null and b/theme/images/icons/tag_orange.png differ diff --git a/theme/images/icons/tag_pink.png b/theme/images/icons/tag_pink.png new file mode 100755 index 0000000..76e2296 Binary files /dev/null and b/theme/images/icons/tag_pink.png differ diff --git a/theme/images/icons/tag_purple.png b/theme/images/icons/tag_purple.png new file mode 100755 index 0000000..ebaf0e8 Binary files /dev/null and b/theme/images/icons/tag_purple.png differ diff --git a/theme/images/icons/tag_red.png b/theme/images/icons/tag_red.png new file mode 100755 index 0000000..6ebb37d Binary files /dev/null and b/theme/images/icons/tag_red.png differ diff --git a/theme/images/icons/tag_yellow.png b/theme/images/icons/tag_yellow.png new file mode 100755 index 0000000..83d1292 Binary files /dev/null and b/theme/images/icons/tag_yellow.png differ diff --git a/theme/images/icons/thumb_down.png b/theme/images/icons/thumb_down.png new file mode 100644 index 0000000..3c832d4 Binary files /dev/null and b/theme/images/icons/thumb_down.png differ diff --git a/theme/images/icons/thumb_up.png b/theme/images/icons/thumb_up.png new file mode 100644 index 0000000..2bd16cc Binary files /dev/null and b/theme/images/icons/thumb_up.png differ diff --git a/theme/images/icons/tux.png b/theme/images/icons/tux.png new file mode 100755 index 0000000..bbefe2e Binary files /dev/null and b/theme/images/icons/tux.png differ diff --git a/theme/images/icons/user_edit.png b/theme/images/icons/user_edit.png new file mode 100755 index 0000000..c1974cd Binary files /dev/null and b/theme/images/icons/user_edit.png differ diff --git a/theme/images/icons/vcard.png b/theme/images/icons/vcard.png new file mode 100755 index 0000000..c02f315 Binary files /dev/null and b/theme/images/icons/vcard.png differ diff --git a/theme/images/loadingAnimation.gif b/theme/images/loadingAnimation.gif new file mode 100755 index 0000000..82290f4 Binary files /dev/null and b/theme/images/loadingAnimation.gif differ diff --git a/theme/images/misc.png b/theme/images/misc.png new file mode 100755 index 0000000..fc226e6 Binary files /dev/null and b/theme/images/misc.png differ diff --git a/theme/images/no-ie6.png b/theme/images/no-ie6.png new file mode 100644 index 0000000..fef317c Binary files /dev/null and b/theme/images/no-ie6.png differ diff --git a/theme/images/projects.png b/theme/images/projects.png new file mode 100755 index 0000000..1821e93 Binary files /dev/null and b/theme/images/projects.png differ diff --git a/theme/images/sides_top.gif b/theme/images/sides_top.gif new file mode 100755 index 0000000..a84383a Binary files /dev/null and b/theme/images/sides_top.gif differ diff --git a/theme/images/tabBG.png b/theme/images/tabBG.png new file mode 100755 index 0000000..6c04d14 Binary files /dev/null and b/theme/images/tabBG.png differ diff --git a/theme/images/tabBG2.png b/theme/images/tabBG2.png new file mode 100755 index 0000000..15821a9 Binary files /dev/null and b/theme/images/tabBG2.png differ diff --git a/theme/images/tabSe.png b/theme/images/tabSe.png new file mode 100644 index 0000000..e3955fe Binary files /dev/null and b/theme/images/tabSe.png differ diff --git a/theme/images/tabUn.png b/theme/images/tabUn.png new file mode 100644 index 0000000..7ba116d Binary files /dev/null and b/theme/images/tabUn.png differ diff --git a/theme/images/tip-pimped.gif b/theme/images/tip-pimped.gif new file mode 100644 index 0000000..f3f604e Binary files /dev/null and b/theme/images/tip-pimped.gif differ diff --git a/theme/images/tip-rounded.gif b/theme/images/tip-rounded.gif new file mode 100644 index 0000000..d0308a6 Binary files /dev/null and b/theme/images/tip-rounded.gif differ diff --git a/theme/images/tip.gif b/theme/images/tip.gif new file mode 100644 index 0000000..4713f05 Binary files /dev/null and b/theme/images/tip.gif differ diff --git a/theme/images/webs.png b/theme/images/webs.png new file mode 100755 index 0000000..5506afd Binary files /dev/null and b/theme/images/webs.png differ diff --git a/theme/images/youdropifollow.jpg b/theme/images/youdropifollow.jpg new file mode 100644 index 0000000..c811576 Binary files /dev/null and b/theme/images/youdropifollow.jpg differ diff --git a/theme/js/jquery-1.2.6.min.js b/theme/js/jquery-1.2.6.min.js new file mode 100644 index 0000000..1acc8fd --- /dev/null +++ b/theme/js/jquery-1.2.6.min.js @@ -0,0 +1,32 @@ +/* + * jQuery 1.2.6 - New Wave Javascript + * + * Copyright (c) 2008 John Resig (jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $ + * $Rev: 5685 $ + */ +(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else +return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else +return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else +selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else +this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else +return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else +jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else +jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("",""]||!tags.indexOf("",""]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
    "]||!tags.indexOf("",""]||(!tags.indexOf("",""]||!tags.indexOf("",""]||jQuery.browser.msie&&[1,"div
    ","
    "]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf(""&&tags.indexOf("=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else +ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&¬xml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&¬xml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&¬xml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else +while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return im[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else +for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("
    ").append(res.responseText.replace(//g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else +xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else +jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else +for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else +s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else +e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;ithis.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})(); diff --git a/theme/js/jquery.ie6blocker.js b/theme/js/jquery.ie6blocker.js new file mode 100644 index 0000000..222f335 --- /dev/null +++ b/theme/js/jquery.ie6blocker.js @@ -0,0 +1,34 @@ +var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false; +if(IE6){ + + $(function(){ + + $("
    ") + .css({ + 'position': 'absolute', + 'top': '0px', + 'left': '0px', + backgroundColor: 'black', + 'opacity': '0.75', + 'width': '100%', + 'height': $(window).height(), + zIndex: 5000 + }) + .appendTo("body"); + + $("


    Sorry! This page doesn't support Internet Explorer 6.

    If you'd like to read our content please upgrade your browser or subscribe to our RSS feed.

    ") + .css({ + backgroundColor: 'white', + 'top': '50%', + 'left': '50%', + marginLeft: -210, + marginTop: -100, + width: 410, + paddingRight: 10, + height: 200, + 'position': 'absolute', + zIndex: 6000 + }) + .appendTo("body"); + }); +} diff --git a/theme/js/message.js b/theme/js/message.js new file mode 100644 index 0000000..9de4bae --- /dev/null +++ b/theme/js/message.js @@ -0,0 +1,5 @@ +$(document).ready(function() { + $("div#stripe").click(function() { + $("div#stripe").slideUp(); + }); +}); diff --git a/theme/js/round_bubbles.js b/theme/js/round_bubbles.js new file mode 100644 index 0000000..8423b99 --- /dev/null +++ b/theme/js/round_bubbles.js @@ -0,0 +1,13 @@ +window.onload = function() { + settings = { + tl: { radius: 10 }, + tr: { radius: 10 }, + bl: { radius: 10 }, + br: { radius: 10 }, + antiAlias: true, + autoPad: true + } + var myBoxObject = new curvyCorners(settings, "rounded"); + myBoxObject.applyCornersToAll(); + } + diff --git a/theme/js/rounded_corners.inc.js b/theme/js/rounded_corners.inc.js new file mode 100644 index 0000000..81af16d --- /dev/null +++ b/theme/js/rounded_corners.inc.js @@ -0,0 +1,279 @@ + + /**************************************************************** + * * + * curvyCorners * + * ------------ * + * * + * This script generates rounded corners for your divs. * + * * + * Version 1.2.7 * + * Copyright (c) 2006 Cameron Cooke * + * By: Cameron Cooke and Tim Hutchison. * + * * + * * + * Website: http://www.curvycorners.net * + * Email: info@totalinfinity.com * + * Forum: http://www.curvycorners.net/forum/ * + * * + * * + * This library is free software; you can redistribute * + * it and/or modify it under the terms of the GNU * + * Lesser General Public License as published by the * + * Free Software Foundation; either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will * + * be useful, but WITHOUT ANY WARRANTY; without even the * + * implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU Lesser General Public * + * License for more details. * + * * + * You should have received a copy of the GNU Lesser * + * General Public License along with this library; * + * Inc., 59 Temple Place, Suite 330, Boston, * + * MA 02111-1307 USA * + * * + ****************************************************************/ + +var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; function curvyCorners() +{ if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); if(typeof(arguments[1]) == "string") +{ var startIndex = 0; var boxCol = getElementsByClass(arguments[1]);} +else +{ var startIndex = 1; var boxCol = arguments;} +var curvyCornersCol = new Array(); for(var i = startIndex, j = boxCol.length; i < j; i++) +{ if(boxCol[i].tagName.toLowerCase() == "div") +{ curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);} +} +this.objects = curvyCornersCol; this.applyCornersToAll = function() +{ for(var x = 0, k = this.objects.length; x < k; x++) +{ this.objects[x].applyCorners();} +} +} +function curvyObject() +{ this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; if(this.settings.autoPad == true && this.boxPadding > 0) +this.box.innerHTML = ""; this.applyCorners = function() +{ for(var t = 0; t < 2; t++) +{ switch(t) +{ case 0: +if(this.settings.tl || this.settings.tr) +{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer);} +break; case 1: +if(this.settings.bl || this.settings.br) +{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer);} +break;} +} +if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; var corners = ["tr", "tl", "br", "bl"]; for(var i in corners) +{ var cc = corners[i]; if(!this.settings[cc]) +{ if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) +{ var newCorner = document.createElement("DIV"); newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; if(this.backgroundImage == "") +newCorner.style.backgroundColor = this.boxColour; else +newCorner.style.backgroundImage = this.backgroundImage; switch(cc) +{ case "tl": +newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr": +newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl": +newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br": +newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px" +newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break;} +} +} +else +{ if(this.masterCorners[this.settings[cc].radius]) +{ var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);} +else +{ var newCorner = document.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++) +{ if((intx +1) >= borderRadius) +var y1 = -1; else +var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); if(borderRadius != j) +{ if((intx) >= borderRadius) +var y2 = -1; else +var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j) +var y3 = -1; else +var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1);} +if((intx) >= j) +var y4 = -1; else +var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); if(borderRadius != j) +{ for(var inty = (y1 + 1); inty < y2; inty++) +{ if(this.settings.antiAlias) +{ if(this.backgroundImage != "") +{ var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30) +{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);} +else +{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);} +} +else +{ var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc);} +} +} +if(this.settings.antiAlias) +{ if(y3 >= y2) +{ if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0);} +} +else +{ if(y3 >= y1) +{ this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0);} +} +var outsideColour = this.borderColour;} +else +{ var outsideColour = this.boxColour; var y3 = y1;} +if(this.settings.antiAlias) +{ for(var inty = (y3 + 1); inty < y4; inty++) +{ this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius);} +} +} +this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);} +if(cc != "br") +{ for(var t = 0, k = newCorner.childNodes.length; t < k; t++) +{ var pixelBar = newCorner.childNodes[t]; var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px";} +if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px";} +switch(cc) +{ case "tr": +pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl": +pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl": +pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break;} +} +} +} +if(newCorner) +{ switch(cc) +{ case "tl": +if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr": +if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl": +if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br": +if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break;} +} +} +var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius) +radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff) +{ if(radiusDiff[z]) +{ var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); var newFiller = document.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px" +newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; switch(smallerCornerType) +{ case "tl": +newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr": +newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl": +newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br": +newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break;} +} +var newFillerBar = document.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z) +{ case "t": +if(this.topContainer) +{ if(this.settings.tl.radius && this.settings.tr.radius) +{ newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "") +newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar);} +this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px";} +break; case "b": +if(this.bottomContainer) +{ if(this.settings.bl.radius && this.settings.br.radius) +{ newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "") +newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar);} +} +break;} +} +if(this.settings.autoPad == true && this.boxPadding > 0) +{ var contentContainer = document.createElement("DIV"); contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); if(topMaxRadius < this.boxPadding) +contentContainer.style.paddingTop = topPadding + "px"; if(botMaxRadius < this.boxPadding) +contentContainer.style.paddingBottom = botMaxRadius + "px"; contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; this.contentDIV = this.box.appendChild(contentContainer);} +} +this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) +{ var pixel = document.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if(image == -1 && this.backgroundImage != "") +{ pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px";} +else +{ pixel.style.backgroundColor = colour;} +if (transAmount != 100) +setOpacity(pixel, transAmount); pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel);} +} +function insertAfter(parent, node, referenceNode) +{ parent.insertBefore(node, referenceNode.nextSibling);} +function BlendColour(Col1, Col2, Col1Fraction) +{ var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue);} +function IntToHex(strNum) +{ base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS;} +function MakeHex(x) +{ if((x >= 0) && (x <= 9)) +{ return x;} +else +{ switch(x) +{ case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F";} +} +} +function pixelFraction(x, y, r) +{ var pixelfraction = 0; var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1))) +{ whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1;} +var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1))) +{ whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1;} +var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1))) +{ whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1;} +var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1))) +{ whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0;} +switch (whatsides) +{ case "LeftRight": +pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight": +pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom": +pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom": +pixelfraction = (yvalues[0]*xvalues[1])/2; break; default: +pixelfraction = 1;} +return pixelfraction;} +function rgb2Hex(rgbColour) +{ try{ var rgbArray = rgb2Array(rgbColour); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);} +catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");} +return hexColour;} +function rgb2Array(rgbColour) +{ var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); var rgbArray = rgbValues.split(", "); return rgbArray;} +function setOpacity(obj, opacity) +{ opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME") +{ var rgbArray = rgb2Array(obj.style.backgroundColor); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")";} +else if(typeof(obj.style.opacity) != "undefined") +{ obj.style.opacity = opacity/100;} +else if(typeof(obj.style.MozOpacity) != "undefined") +{ obj.style.MozOpacity = opacity/100;} +else if(typeof(obj.style.filter) != "undefined") +{ obj.style.filter = "alpha(opacity:" + opacity + ")";} +else if(typeof(obj.style.KHTMLOpacity) != "undefined") +{ obj.style.KHTMLOpacity = opacity/100;} +} +function inArray(array, value) +{ for(var i = 0; i < array.length; i++){ if (array[i] === value) return i;} +return false;} +function inArrayKey(array, value) +{ for(key in array){ if(key === value) return true;} +return false;} +function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;} +else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;} +else { elm['on' + evType] = fn;} +} +function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true;} else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed");} +} +function format_colour(colour) +{ var returnColour = "#ffffff"; if(colour != "" && colour != "transparent") +{ if(colour.substr(0, 3) == "rgb") +{ returnColour = rgb2Hex(colour);} +else if(colour.length == 4) +{ returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4);} +else +{ returnColour = colour;} +} +return returnColour;} +function get_style(obj, property, propertyNS) +{ try +{ if(obj.currentStyle) +{ var returnVal = eval("obj.currentStyle." + property);} +else +{ if(isSafari && obj.style.display == "none") +{ obj.style.display = ""; var wasHidden = true;} +var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); if(isSafari && wasHidden) +{ obj.style.display = "none";} +} +} +catch(e) +{ } +return returnVal;} +function getElementsByClass(searchClass, node, tag) +{ var classElements = new Array(); if(node == null) +node = document; if(tag == null) +tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++) +{ if(pattern.test(els[i].className)) +{ classElements[j] = els[i]; j++;} +} +return classElements;} +function newCurvyError(errorMessage) +{ return new Error("curvyCorners Error:\n" + errorMessage) +} diff --git a/theme/js/thickbox.js b/theme/js/thickbox.js new file mode 100755 index 0000000..2ac1a21 --- /dev/null +++ b/theme/js/thickbox.js @@ -0,0 +1,328 @@ +/* + * Thickbox 3.1 - One Box To Rule Them All. + * By Cody Lindley (http://www.codylindley.com) + * Copyright (c) 2007 cody lindley + * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php +*/ + +var tb_pathToImage = "/theme/images/loadingAnimation.gif"; + +/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ + +//on page load call tb_init +$(document).ready(function(){ + tb_startup(); +}); + +function tb_startup() { + tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox + imgLoader = new Image();// preload image + imgLoader.src = tb_pathToImage; +} + +function tb_splash() { + tb_startup(); + tb_show("Welcome to Four Island!", "theme/welcome.tpl?no=", false); +} + +//add thickbox to href & area elements that have a class of .thickbox +function tb_init(domChunk){ + $(domChunk).click(function(){ + var t = this.title || this.name || null; + var a = this.href || this.alt; + var g = this.rel || false; + tb_show(t,a,g); + this.blur(); + return false; + }); +} + +function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link + + try { +/* if (typeof document.body.style.maxHeight === "undefined") {//if IE 6 + $("body","html").css({height: "100%", width: "100%"}); + $("html").css("overflow","hidden"); + if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6 + $("body").append("
    "); + $("#TB_overlay").click(tb_remove); + } + }else*/{//all others + if(document.getElementById("TB_overlay") === null){ + $("body").append("
    "); + $("#TB_overlay").click(tb_remove); + } + } + + if(tb_detectMacXFF()){ + $("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash + }else{ + $("#TB_overlay").addClass("TB_overlayBG");//use background and opacity + } + + if(caption===null){caption="";} + $("body").append("
    ");//add loader to the page + $('#TB_load').show();//show loader + + var baseURL; + if(url.indexOf("?")!==-1){ //ff there is a query string involved + baseURL = url.substr(0, url.indexOf("?")); + }else{ + baseURL = url; + } + + var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; + var urlType = baseURL.toLowerCase().match(urlString); + + if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images + + TB_PrevCaption = ""; + TB_PrevURL = ""; + TB_PrevHTML = ""; + TB_NextCaption = ""; + TB_NextURL = ""; + TB_NextHTML = ""; + TB_imageCount = ""; + TB_FoundURL = false; + if(imageGroup){ + TB_TempArray = $("a[@rel="+imageGroup+"]").get(); + for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { + var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); + if (!(TB_TempArray[TB_Counter].href == url)) { + if (TB_FoundURL) { + TB_NextCaption = TB_TempArray[TB_Counter].title; + TB_NextURL = TB_TempArray[TB_Counter].href; + TB_NextHTML = "  Next >"; + } else { + TB_PrevCaption = TB_TempArray[TB_Counter].title; + TB_PrevURL = TB_TempArray[TB_Counter].href; + TB_PrevHTML = "  < Prev"; + } + } else { + TB_FoundURL = true; + TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); + } + } + } + + imgPreloader = new Image(); + imgPreloader.onload = function(){ + imgPreloader.onload = null; + + // Resizing large images - orginal by Christian Montoya edited by me. + var pagesize = tb_getPageSize(); + var x = pagesize[0] - 150; + var y = pagesize[1] - 150; + var imageWidth = imgPreloader.width; + var imageHeight = imgPreloader.height; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + } + } else if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + } + } + // End Resizing + + TB_WIDTH = imageWidth + 30; + TB_HEIGHT = imageHeight + 60; + $("#TB_window").append(""+caption+"" + "
    "+caption+"
    " + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
    close or Esc Key
    "); + + $("#TB_closeWindowButton").click(tb_remove); + + if (!(TB_PrevHTML === "")) { + function goPrev(){ + if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);} + $("#TB_window").remove(); + $("body").append("
    "); + tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); + return false; + } + $("#TB_prev").click(goPrev); + } + + if (!(TB_NextHTML === "")) { + function goNext(){ + $("#TB_window").remove(); + $("body").append("
    "); + tb_show(TB_NextCaption, TB_NextURL, imageGroup); + return false; + } + $("#TB_next").click(goNext); + + } + + document.onkeydown = function(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + if(keycode == 27){ // close + tb_remove(); + } else if(keycode == 190){ // display previous image + if(!(TB_NextHTML == "")){ + document.onkeydown = ""; + goNext(); + } + } else if(keycode == 188){ // display next image + if(!(TB_PrevHTML == "")){ + document.onkeydown = ""; + goPrev(); + } + } + }; + + tb_position(); + $("#TB_load").remove(); + $("#TB_ImageOff").click(tb_remove); + $("#TB_window").css({display:"block"}); //for safari using css instead of show + }; + + imgPreloader.src = url; + }else{//code to show html + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = tb_parseQuery( queryString ); + + TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL + TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL + ajaxContentW = TB_WIDTH - 30; + ajaxContentH = TB_HEIGHT - 45; + + if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window + urlNoQuery = url.split('TB_'); + $("#TB_iframeContent").remove(); + if(params['modal'] != "true"){//iframe no modal + $("#TB_window").append("
    "+caption+"
    close or Esc Key
    "); + }else{//iframe modal + $("#TB_overlay").unbind(); + $("#TB_window").append(""); + } + }else{// not an iframe, ajax + if($("#TB_window").css("display") != "block"){ + if(params['modal'] != "true"){//ajax no modal + $("#TB_window").append("
    "+caption+"
    close or Esc Key
    "); + }else{//ajax modal + $("#TB_overlay").unbind(); + $("#TB_window").append("
    "); + } + }else{//this means the window is already up, we are just loading new content via ajax + $("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; + $("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; + $("#TB_ajaxContent")[0].scrollTop = 0; + $("#TB_ajaxWindowTitle").html(caption); + } + } + + $("#TB_closeWindowButton").click(tb_remove); + + if(url.indexOf('TB_inline') != -1){ + $("#TB_ajaxContent").append($('#' + params['inlineId']).children()); + $("#TB_window").unload(function () { + $('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished + }); + tb_position(); + $("#TB_load").remove(); + $("#TB_window").css({display:"block"}); + }else if(url.indexOf('TB_iframe') != -1){ + tb_position(); + if($.browser.safari){//safari needs help because it will not fire iframe onload + $("#TB_load").remove(); + $("#TB_window").css({display:"block"}); + } + }else{ + $("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method + tb_position(); + $("#TB_load").remove(); + tb_init("#TB_ajaxContent a.thickbox"); + $("#TB_window").css({display:"block"}); + }); + } + + } + + if(!params['modal']){ + document.onkeyup = function(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + if(keycode == 27){ // close + tb_remove(); + } + }; + } + + } catch(e) { + //nothing here + } +} + +//helper functions below +function tb_showIframe(){ + $("#TB_load").remove(); + $("#TB_window").css({display:"block"}); +} + +function tb_remove() { + $("#TB_imageOff").unbind("click"); + $("#TB_closeWindowButton").unbind("click"); + $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); + $("#TB_load").remove(); + if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 + $("body","html").css({height: "auto", width: "auto"}); + $("html").css("overflow",""); + } + document.onkeydown = ""; + document.onkeyup = ""; + return false; +} + +function tb_position() { +$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); + if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 + $("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); + } +} + +function tb_parseQuery ( query ) { + var Params = {}; + if ( ! query ) {return Params;}// return empty object + var Pairs = query.split(/[;&]/); + for ( var i = 0; i < Pairs.length; i++ ) { + var KeyVal = Pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) {continue;} + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ); + val = val.replace(/\+/g, ' '); + Params[key] = val; + } + return Params; +} + +function tb_getPageSize(){ + var de = document.documentElement; + var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; + arrayPageSize = [w,h]; + return arrayPageSize; +} + +function tb_detectMacXFF() { + var userAgent = navigator.userAgent.toLowerCase(); + if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { + return true; + } +} + + diff --git a/theme/login.tpl b/theme/login.tpl new file mode 100644 index 0000000..f175f59 --- /dev/null +++ b/theme/login.tpl @@ -0,0 +1,18 @@ +

    Four Island Login Page

    + +

    + +ERROR:

    + +Welcome to the Four Island Login page!
    +To post feedback on this site, and also to post on the forums, you must be a member.
    +Sadly, currently membership is invitation-only. But hopefully that will change in the near future.
    +HOWEVER, you may request membership by email hatkirby@fourisland.com (link on the right).
    +A NOTICE TO ALL MEMBERS! Do NOT share your password with anyone! If you misplace your password send an email to hatkirby@fourisland.com (link on the right).

    +

    +
    +
    + + + +
    diff --git a/theme/msg.tpl b/theme/msg.tpl new file mode 100644 index 0000000..25a4f36 --- /dev/null +++ b/theme/msg.tpl @@ -0,0 +1 @@ +

    Back to diff --git a/theme/msg2.tpl b/theme/msg2.tpl new file mode 100644 index 0000000..59c723e --- /dev/null +++ b/theme/msg2.tpl @@ -0,0 +1 @@ +

    diff --git a/theme/poll.tpl b/theme/poll.tpl new file mode 100644 index 0000000..3781e47 --- /dev/null +++ b/theme/poll.tpl @@ -0,0 +1,30 @@ +

    +

    +

    + +
    +

    +

    +
    +
    +
    + + +

    + - vote(s)!
    + - vote(s)!
    + - vote(s)!
    + - vote(s)! +

    +
    +
    + on + + + The results of this poll of the week are pending. Meanwhile, if you haven't voted yet, why not do so? +
    + +
    + +
    + diff --git a/theme/pollIndex.tpl b/theme/pollIndex.tpl new file mode 100644 index 0000000..2111b39 --- /dev/null +++ b/theme/pollIndex.tpl @@ -0,0 +1,12 @@ +

    Poll of the Week

    +

    +

    +

    +Welcome to the Poll of the Week! Feel free to vote on these! You can review old ones and also comment on them if +you're logged in using the links below! +

    +

      + +
    • - Week of
    • + +
    diff --git a/theme/polloftheweek.tpl b/theme/polloftheweek.tpl new file mode 100644 index 0000000..13a7dce --- /dev/null +++ b/theme/polloftheweek.tpl @@ -0,0 +1,59 @@ + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    + + + + + +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    %%<!--PERCENT1-->
    %%<!--PERCENT2-->
    %%<!--PERCENT3-->
    %%<!--PERCENT4-->
    + diff --git a/theme/post.tpl b/theme/post.tpl new file mode 100644 index 0000000..91bf4e9 --- /dev/null +++ b/theme/post.tpl @@ -0,0 +1,66 @@ + +« + » + + + +
    + + +
    +

    + + + +

    + + + + + + + + + +  » + + + + Add Comment » + + +
    + +
    +
    +
    +
    + +
    +
    + on + + + + + + +
    +
    +
    + diff --git a/theme/postLogin.tpl b/theme/postLogin.tpl new file mode 100644 index 0000000..31dce48 --- /dev/null +++ b/theme/postLogin.tpl @@ -0,0 +1,16 @@ +

    Four Island Login Page

    + +

    +

    Congradulations, you've logged in!
    + You can now: +
      +
    • Comment on the blog posts
    • +
    • Comment on Projects
    • +
    • Comment on Flash Games
    • +
    • Comment on a whole lot of other things I can't remember right now
    • +
    • Update your userpage
    • +
    • More soon...
    • +
    + Click here to return to the page you were on. +
    +

    diff --git a/theme/quotes/add.tpl b/theme/quotes/add.tpl new file mode 100644 index 0000000..4073277 --- /dev/null +++ b/theme/quotes/add.tpl @@ -0,0 +1,17 @@ +
    +
    Contribute
    + + +
    +
    The quote you have submitted is:
    +
    +
    If this is not the quote you have entered, please contact the administrator and explain your problem. Also, there is no need to press the submit button again. You're quote has already been sent.
    +
    + + +
    +
    + + +
    +
    diff --git a/theme/quotes/add_news.tpl b/theme/quotes/add_news.tpl new file mode 100644 index 0000000..3c81474 --- /dev/null +++ b/theme/quotes/add_news.tpl @@ -0,0 +1,8 @@ +
    +
    Add News
    + +
    +
    + +
    +
    diff --git a/theme/quotes/browse.tpl b/theme/quotes/browse.tpl new file mode 100644 index 0000000..d35abfe --- /dev/null +++ b/theme/quotes/browse.tpl @@ -0,0 +1,25 @@ +
    + + + + +
    + + +
    +
    + # + + + () + - + [X] +
    + +
    +
    + + + + + +
    diff --git a/theme/quotes/home.tpl b/theme/quotes/home.tpl new file mode 100644 index 0000000..7e8c10f --- /dev/null +++ b/theme/quotes/home.tpl @@ -0,0 +1,10 @@ +
    +

    Four Island Quotes DB

    + +
    + +
    +

    + +

    +
    diff --git a/theme/quotes/pagenumbers.tpl b/theme/quotes/pagenumbers.tpl new file mode 100644 index 0000000..3171c10 --- /dev/null +++ b/theme/quotes/pagenumbers.tpl @@ -0,0 +1,15 @@ +
    + First   + -10   + + +    + +    + +    + + + +10   + Last   +
    diff --git a/theme/quotes/search.tpl b/theme/quotes/search.tpl new file mode 100644 index 0000000..491c861 --- /dev/null +++ b/theme/quotes/search.tpl @@ -0,0 +1,19 @@ +
    +
    Search
    + +
    +   +
    + Sort:   + How many: +
    +
    diff --git a/theme/related.tpl b/theme/related.tpl new file mode 100644 index 0000000..c070359 --- /dev/null +++ b/theme/related.tpl @@ -0,0 +1,12 @@ +
    +
    +
    +
    + + by on
    + +
    +
    +
    + Theoretically Related Posts +
    diff --git a/theme/welcome.tpl b/theme/welcome.tpl new file mode 100644 index 0000000..7872c6f --- /dev/null +++ b/theme/welcome.tpl @@ -0,0 +1,5 @@ +

    Welcome to Four Island

    +
    You've reached Four Island, a fun place with:
      +
    • a blog
    • a fourm
    • a wiki
    • many projects
    • and a quotes database!
    +I hope you enjoy your time on Four Island!

    +

    ....Don't worry, I'll eventually think of something to actually put here :) diff --git a/theme/wiki/create.tpl b/theme/wiki/create.tpl new file mode 100644 index 0000000..ecd2d6b --- /dev/null +++ b/theme/wiki/create.tpl @@ -0,0 +1,7 @@ +

    Create a page

    + +

    + Page Title:
    +

    + +

    diff --git a/theme/wiki/edit.tpl b/theme/wiki/edit.tpl new file mode 100644 index 0000000..12d2deb --- /dev/null +++ b/theme/wiki/edit.tpl @@ -0,0 +1,6 @@ +

    Edit

    + +

    +

    + +

    diff --git a/theme/wiki/index.tpl b/theme/wiki/index.tpl new file mode 100644 index 0000000..ed4e513 --- /dev/null +++ b/theme/wiki/index.tpl @@ -0,0 +1,6 @@ + +

    + + |
    + + diff --git a/theme/wiki/page.tpl b/theme/wiki/page.tpl new file mode 100644 index 0000000..b021e95 --- /dev/null +++ b/theme/wiki/page.tpl @@ -0,0 +1,3 @@ +

    + + diff --git a/thumb.php b/thumb.php new file mode 100644 index 0000000..ba9c645 --- /dev/null +++ b/thumb.php @@ -0,0 +1,147 @@ + diff --git a/xmlrpc.php b/xmlrpc.php new file mode 100644 index 0000000..2c634d3 --- /dev/null +++ b/xmlrpc.php @@ -0,0 +1,101 @@ +getParam(0)->scalarVal(); + $to = $xmlrpcmsg->getParam(1)->scalarVal(); + + if (preg_match('/^http:\/\/w?w?w?\.?fourisland\.com\/blog\/([-a-z0-9]+)\/$/',$to)) + { + $slug = preg_replace('/^http:\/\/w?w?w?\.?fourisland\.com\/blog\/([-a-z0-9]+)\/$/','$1',$to); + + $getpost = "SELECT * FROM updates WHERE slug = \"" . $slug . "\""; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + if ($getpost3['slug'] == $slug) + { + + $c = curl_init(); + curl_setopt($c, CURLOPT_URL, $from); + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); + curl_setopt($c, CURLOPT_HEADER, false); + $page_data = curl_exec($c); + curl_close($c); + + if (stripos($page_data,$to) !== FALSE) + { + if (preg_match('/([^>]+)<\/TITLE>/i',$page_data,$matches)) + { + $title = $matches[1]; + } else { + $title = $from; + } + + $text = substr($page_data,(stripos($page_data,$to)-300),700); + $text = strip_tags($text); + $text = str_replace("\n",' ',$text); + + $commentText = "[url=" . $from . "]" . $title . "[/url]\n\n[....] " . $text . " [....]"; + + $getping = "SELECT * FROM comments WHERE page_id = \"updates-" . $getpost3['id'] . "\" AND comment = \"" . addslashes($commentText) . "\""; + $getping2 = mysql_query($getping); + $getping3 = mysql_fetch_array($getping2); + + if ($getping3['comment'] == $commentText) + { + return new xmlrpcresp(0, 48, "Target uri cannot be used as target"); + } else { + $insping = "INSERT INTO comments (page_id,username,comment) VALUES (\"updates-" . $getpost3['id'] . "\",\"Pingback\",\"" . $commentText . "\")"; + $insping2 = mysql_query($insping); + recalcPop($getpost3['id']); + + return new xmlrpcresp(new xmlrpcval("YAY! Your Pingback has been registered!", "string")); + } + } else { + return new xmlrpcresp(0, 17, "Source uri does have link to target uri"); + } + } else { + return new xmlrpcresp(0, 32, "Target uri does not exist"); + } + } else { + return new xmlrpcresp(0, 33, "Target uri cannot be used as target"); + } +} + +function rr($xmlrpcmsg) +{ + return new xmlrpcresp(new xmlrpcval(0, "int")); +} + +$s = new xmlrpc_server(array( + "pingback.ping" => array("function" => "ping"), + "InstaDisc.checkRegistration" => array("function" => "rr"))); + +?> -- cgit 1.4.1