").attr("id","xe_gallery_screen").css({position:"absolute",display:"none",backgroundColor:"black",zIndex:500,opacity:0.5});controls=$("
')
-function doResize(contentWidth,count){if(!count)count=0;if(count>=10)return;var $img=this,beforSize={width:$img.width(),height:$img.height()};if(!beforSize.width||!beforSize.height){setTimeout(function(){doResize.call($img,contentWidth,++count)},200);return};if(beforSize.width<=contentWidth)return;var resize_ratio=contentWidth/beforSize.width;$img.removeAttr('width').removeAttr('height').css({width:contentWidth,height:parseInt(beforSize.height*resize_ratio,10)})};$('div.xe_content').each(function(){var contentWidth=dummy.appendTo(this).width();dummy.remove();if(!contentWidth)return;$('img',this).each(function(){var $img=$(this),imgSrc=$img.attr('src');if(regx_skip.test(imgSrc)&&!regx_allow_i6pngfix.test(imgSrc))return;$img.attr('rel','xe_gallery');doResize.call($img,contentWidth)});$('img[rel=xe_gallery]',this).live('mouseover',function(){var $img=$(this);if(!$img.parent('a').length&&!$img.attr('onclick'))$img.css('cursor','pointer').click(slideshow)})})})})(jQuery)
\ No newline at end of file
+(function(c){var d=null;function a(){var g=c(document.body);var h,f,e,j,i;if(!d){d=c("
").attr("id","xe_gallery_screen").css({position:"fixed",display:"none",backgroundColor:"black",zIndex:500,opacity:0.7});h=c("
").attr("id","xe_gallery_controls").css({position:"fixed",display:"none",overflow:"hidden",zIndex:510});j=c('
').css({left:"10px",backgroundPosition:"0 -64px"}).click(function(){d.xePrev()}).appendTo(h);e=c('
').css({top:"10px",backgroundPosition:"0 0"}).click(function(){d.xeHide()}).appendTo(h);i=c('
').attr("id","xe_gallery_nextbtn").css({right:"10px",backgroundPosition:"0 -128px"}).click(function(){d.xeNext()}).appendTo(h);h.find(">button").css({position:"absolute",width:"64px",height:"64px",zIndex:530,cursor:"pointer",border:0,margin:0,padding:0,backgroundColor:"transparent",backgroundImage:"url("+request_uri+"addons/resize_image/btn.png)",backgroundRepeat:"no-repeat",opacity:".5",filter:"alpha(opacity=50)"}).mouseover(function(){c(this).css({opacity:"1",filter:"alpha(opacity=100)"})}).mouseout(function(){c(this).css({opacity:".5",filter:"alpha(opacity=50)"})}).focus(function(){c(this).trigger("mouseover")}).blur(function(){c(this).trigger("mouseout")});f=c("
").attr("id","xe_gallery_holder").css({border:"5px solid white",zindex:520,maxWidth:"none",borderRadius:"5px",boxShadow:"0 0 10px #000"}).appendTo(h).draggable();g.append(d).append(h);d.xeShow=function(){var l=c(window).width();var k=c(window).height();c("#xe_gallery_controls,#xe_gallery_screen").show().css({top:0,right:0,bottom:0,left:0});c("#xe_gallery_prevbtn,#xe_gallery_nextbtn").css("top",Math.round(k/2-32)+"px");this.xeMove(0)};d.xeHide=function(k){d.hide();h.hide()};d.xePrev=function(){this.xeMove(-1)};d.xeNext=function(){this.xeMove(1)};d.xeMove=function(n){var m=c(window).width();var k=c(window).height();this.index+=n;j.css("visibility",(this.index>0)?"visible":"hidden");i.css("visibility",(this.index
');function e(k,m){if(!m){m=0}if(m>=10){return}var l=this;var j={width:l.width(),height:l.height()};if(!j.width||!j.height){setTimeout(function(){e.call(l,k,++m)},200);return}if(j.width<=k){return}var i=k/j.width;l.removeAttr("width").removeAttr("height").css({width:k,height:parseInt(j.height*i,10)})}c(".xe_content").each(function(){var i=h.appendTo(this).width();h.remove();if(!i){return}c("img",this).each(function(){var j=c(this);var k=j.attr("src");if(g.test(k)&&!f.test(k)){return}j.attr("rel","xe_gallery");e.call(j,i)});c("img[rel=xe_gallery]",this).live("mouseover",function(){var j=c(this);if(!j.parent("a").length&&!j.attr("onclick")){j.css("cursor","pointer").click(b)}})})})})(jQuery);
\ No newline at end of file
diff --git a/addons/resize_image/resize_image.addon.php b/addons/resize_image/resize_image.addon.php
index 5b10d33ec..29ee1b319 100644
--- a/addons/resize_image/resize_image.addon.php
+++ b/addons/resize_image/resize_image.addon.php
@@ -1,18 +1,25 @@
+
+/* End of file resize_image.addon.php */
+/* Location: ./addons/resize_image/resize_image.addon.php */
diff --git a/admin/help/img/admin/dashboard.PNG b/admin/help/img/admin/dashboard.PNG
new file mode 100644
index 000000000..df44b1f54
Binary files /dev/null and b/admin/help/img/admin/dashboard.PNG differ
diff --git a/admin/help/img/admin/easyinstall_for_textyle.PNG b/admin/help/img/admin/easyinstall_for_textyle.PNG
new file mode 100644
index 000000000..b772f7639
Binary files /dev/null and b/admin/help/img/admin/easyinstall_for_textyle.PNG differ
diff --git a/admin/help/img/admin/ftp_config.PNG b/admin/help/img/admin/ftp_config.PNG
new file mode 100644
index 000000000..c179cf44d
Binary files /dev/null and b/admin/help/img/admin/ftp_config.PNG differ
diff --git a/admin/help/img/admin/installed_module.PNG b/admin/help/img/admin/installed_module.PNG
new file mode 100644
index 000000000..a0a78c74e
Binary files /dev/null and b/admin/help/img/admin/installed_module.PNG differ
diff --git a/admin/help/img/faq/add_multilingual.PNG b/admin/help/img/faq/add_multilingual.PNG
new file mode 100644
index 000000000..e07b70c66
Binary files /dev/null and b/admin/help/img/faq/add_multilingual.PNG differ
diff --git a/admin/help/img/faq/admin_ip_band.PNG b/admin/help/img/faq/admin_ip_band.PNG
new file mode 100644
index 000000000..6d7895c72
Binary files /dev/null and b/admin/help/img/faq/admin_ip_band.PNG differ
diff --git a/admin/help/img/faq/apply_multilingual.PNG b/admin/help/img/faq/apply_multilingual.PNG
new file mode 100644
index 000000000..9d397d1b1
Binary files /dev/null and b/admin/help/img/faq/apply_multilingual.PNG differ
diff --git a/admin/help/img/faq/board_basic_setup.PNG b/admin/help/img/faq/board_basic_setup.PNG
new file mode 100644
index 000000000..cfe7918e5
Binary files /dev/null and b/admin/help/img/faq/board_basic_setup.PNG differ
diff --git a/admin/help/img/faq/comment_publish.PNG b/admin/help/img/faq/comment_publish.PNG
new file mode 100644
index 000000000..9a49136f1
Binary files /dev/null and b/admin/help/img/faq/comment_publish.PNG differ
diff --git a/admin/help/img/faq/defence_login_limit.PNG b/admin/help/img/faq/defence_login_limit.PNG
new file mode 100644
index 000000000..44550138d
Binary files /dev/null and b/admin/help/img/faq/defence_login_limit.PNG differ
diff --git a/admin/help/img/faq/deny_admin_by_ip.PNG b/admin/help/img/faq/deny_admin_by_ip.PNG
new file mode 100644
index 000000000..e890693b8
Binary files /dev/null and b/admin/help/img/faq/deny_admin_by_ip.PNG differ
diff --git a/admin/help/img/faq/export1.PNG b/admin/help/img/faq/export1.PNG
new file mode 100644
index 000000000..5e91a387a
Binary files /dev/null and b/admin/help/img/faq/export1.PNG differ
diff --git a/admin/help/img/faq/export2.PNG b/admin/help/img/faq/export2.PNG
new file mode 100644
index 000000000..1a2bb94e2
Binary files /dev/null and b/admin/help/img/faq/export2.PNG differ
diff --git a/admin/help/img/faq/export3.PNG b/admin/help/img/faq/export3.PNG
new file mode 100644
index 000000000..1a078226a
Binary files /dev/null and b/admin/help/img/faq/export3.PNG differ
diff --git a/admin/help/img/faq/exposure_target.PNG b/admin/help/img/faq/exposure_target.PNG
new file mode 100644
index 000000000..887fec8aa
Binary files /dev/null and b/admin/help/img/faq/exposure_target.PNG differ
diff --git a/admin/help/img/faq/file_status.PNG b/admin/help/img/faq/file_status.PNG
new file mode 100644
index 000000000..314b53729
Binary files /dev/null and b/admin/help/img/faq/file_status.PNG differ
diff --git a/admin/help/img/faq/import1.PNG b/admin/help/img/faq/import1.PNG
new file mode 100644
index 000000000..d14319f31
Binary files /dev/null and b/admin/help/img/faq/import1.PNG differ
diff --git a/admin/help/img/faq/import2.PNG b/admin/help/img/faq/import2.PNG
new file mode 100644
index 000000000..18ae9e9bd
Binary files /dev/null and b/admin/help/img/faq/import2.PNG differ
diff --git a/admin/help/img/faq/import_complete.PNG b/admin/help/img/faq/import_complete.PNG
new file mode 100644
index 000000000..bf7a5ca55
Binary files /dev/null and b/admin/help/img/faq/import_complete.PNG differ
diff --git a/admin/help/img/faq/joinform_manage.PNG b/admin/help/img/faq/joinform_manage.PNG
new file mode 100644
index 000000000..1ea39ea8e
Binary files /dev/null and b/admin/help/img/faq/joinform_manage.PNG differ
diff --git a/admin/help/img/faq/joinform_type.PNG b/admin/help/img/faq/joinform_type.PNG
new file mode 100644
index 000000000..5b850f0eb
Binary files /dev/null and b/admin/help/img/faq/joinform_type.PNG differ
diff --git a/admin/help/img/faq/login_config.PNG b/admin/help/img/faq/login_config.PNG
new file mode 100644
index 000000000..db65417fa
Binary files /dev/null and b/admin/help/img/faq/login_config.PNG differ
diff --git a/admin/help/img/faq/menu_name_modify.PNG b/admin/help/img/faq/menu_name_modify.PNG
new file mode 100644
index 000000000..8a6b340a8
Binary files /dev/null and b/admin/help/img/faq/menu_name_modify.PNG differ
diff --git a/admin/help/img/faq/search_multilingual.PNG b/admin/help/img/faq/search_multilingual.PNG
new file mode 100644
index 000000000..36e478ab6
Binary files /dev/null and b/admin/help/img/faq/search_multilingual.PNG differ
diff --git a/admin/help/img/faq/use_multilingual.PNG b/admin/help/img/faq/use_multilingual.PNG
new file mode 100644
index 000000000..5b5422318
Binary files /dev/null and b/admin/help/img/faq/use_multilingual.PNG differ
diff --git a/admin/help/img/faq/user_defined_joinform.PNG b/admin/help/img/faq/user_defined_joinform.PNG
new file mode 100644
index 000000000..b670b91da
Binary files /dev/null and b/admin/help/img/faq/user_defined_joinform.PNG differ
diff --git a/admin/help/img/image001.png b/admin/help/img/image001.png
new file mode 100644
index 000000000..733a0ded1
Binary files /dev/null and b/admin/help/img/image001.png differ
diff --git a/admin/help/img/image002.jpg b/admin/help/img/image002.jpg
new file mode 100644
index 000000000..c0ac026ab
Binary files /dev/null and b/admin/help/img/image002.jpg differ
diff --git a/admin/help/img/image003.jpg b/admin/help/img/image003.jpg
new file mode 100644
index 000000000..9c4c659a9
Binary files /dev/null and b/admin/help/img/image003.jpg differ
diff --git a/admin/help/img/image004.jpg b/admin/help/img/image004.jpg
new file mode 100644
index 000000000..16c08f779
Binary files /dev/null and b/admin/help/img/image004.jpg differ
diff --git a/admin/help/img/image005.jpg b/admin/help/img/image005.jpg
new file mode 100644
index 000000000..32208e059
Binary files /dev/null and b/admin/help/img/image005.jpg differ
diff --git a/admin/help/img/image006.jpg b/admin/help/img/image006.jpg
new file mode 100644
index 000000000..323308b53
Binary files /dev/null and b/admin/help/img/image006.jpg differ
diff --git a/admin/help/img/image007.jpg b/admin/help/img/image007.jpg
new file mode 100644
index 000000000..29be2bd5c
Binary files /dev/null and b/admin/help/img/image007.jpg differ
diff --git a/admin/help/img/image008.jpg b/admin/help/img/image008.jpg
new file mode 100644
index 000000000..298315ed4
Binary files /dev/null and b/admin/help/img/image008.jpg differ
diff --git a/admin/help/img/image009.jpg b/admin/help/img/image009.jpg
new file mode 100644
index 000000000..1e74d8cc4
Binary files /dev/null and b/admin/help/img/image009.jpg differ
diff --git a/admin/help/img/image010.jpg b/admin/help/img/image010.jpg
new file mode 100644
index 000000000..f4f283915
Binary files /dev/null and b/admin/help/img/image010.jpg differ
diff --git a/admin/help/img/image011.jpg b/admin/help/img/image011.jpg
new file mode 100644
index 000000000..3d8591315
Binary files /dev/null and b/admin/help/img/image011.jpg differ
diff --git a/admin/help/img/image012.jpg b/admin/help/img/image012.jpg
new file mode 100644
index 000000000..36e54830d
Binary files /dev/null and b/admin/help/img/image012.jpg differ
diff --git a/admin/help/img/image013.jpg b/admin/help/img/image013.jpg
new file mode 100644
index 000000000..a2b37c4b7
Binary files /dev/null and b/admin/help/img/image013.jpg differ
diff --git a/admin/help/img/image014.jpg b/admin/help/img/image014.jpg
new file mode 100644
index 000000000..e4228f11b
Binary files /dev/null and b/admin/help/img/image014.jpg differ
diff --git a/admin/help/img/image015.jpg b/admin/help/img/image015.jpg
new file mode 100644
index 000000000..df5228cb4
Binary files /dev/null and b/admin/help/img/image015.jpg differ
diff --git a/admin/help/img/image016.jpg b/admin/help/img/image016.jpg
new file mode 100644
index 000000000..d07482c9a
Binary files /dev/null and b/admin/help/img/image016.jpg differ
diff --git a/admin/help/img/image017.jpg b/admin/help/img/image017.jpg
new file mode 100644
index 000000000..f360d8b3d
Binary files /dev/null and b/admin/help/img/image017.jpg differ
diff --git a/admin/help/img/image018.jpg b/admin/help/img/image018.jpg
new file mode 100644
index 000000000..0035cd1f4
Binary files /dev/null and b/admin/help/img/image018.jpg differ
diff --git a/admin/help/img/image019.jpg b/admin/help/img/image019.jpg
new file mode 100644
index 000000000..a02c79512
Binary files /dev/null and b/admin/help/img/image019.jpg differ
diff --git a/admin/help/img/image020.jpg b/admin/help/img/image020.jpg
new file mode 100644
index 000000000..9040a641d
Binary files /dev/null and b/admin/help/img/image020.jpg differ
diff --git a/admin/help/img/image021.jpg b/admin/help/img/image021.jpg
new file mode 100644
index 000000000..1692b5691
Binary files /dev/null and b/admin/help/img/image021.jpg differ
diff --git a/admin/help/img/image022.jpg b/admin/help/img/image022.jpg
new file mode 100644
index 000000000..4e7dc1144
Binary files /dev/null and b/admin/help/img/image022.jpg differ
diff --git a/admin/help/img/image023.png b/admin/help/img/image023.png
new file mode 100644
index 000000000..5c5276450
Binary files /dev/null and b/admin/help/img/image023.png differ
diff --git a/admin/help/img/image024.jpg b/admin/help/img/image024.jpg
new file mode 100644
index 000000000..674000805
Binary files /dev/null and b/admin/help/img/image024.jpg differ
diff --git a/admin/help/img/image025.jpg b/admin/help/img/image025.jpg
new file mode 100644
index 000000000..ecd54d993
Binary files /dev/null and b/admin/help/img/image025.jpg differ
diff --git a/admin/help/img/image026.png b/admin/help/img/image026.png
new file mode 100644
index 000000000..54b0f2635
Binary files /dev/null and b/admin/help/img/image026.png differ
diff --git a/admin/help/img/image027.jpg b/admin/help/img/image027.jpg
new file mode 100644
index 000000000..3207a8aa1
Binary files /dev/null and b/admin/help/img/image027.jpg differ
diff --git a/admin/help/img/image028.png b/admin/help/img/image028.png
new file mode 100644
index 000000000..6c9d65aec
Binary files /dev/null and b/admin/help/img/image028.png differ
diff --git a/admin/help/img/image029.jpg b/admin/help/img/image029.jpg
new file mode 100644
index 000000000..b407b9677
Binary files /dev/null and b/admin/help/img/image029.jpg differ
diff --git a/admin/help/img/image030.png b/admin/help/img/image030.png
new file mode 100644
index 000000000..32b14e1cd
Binary files /dev/null and b/admin/help/img/image030.png differ
diff --git a/admin/help/img/image031.jpg b/admin/help/img/image031.jpg
new file mode 100644
index 000000000..5954df1f1
Binary files /dev/null and b/admin/help/img/image031.jpg differ
diff --git a/admin/help/img/image032.jpg b/admin/help/img/image032.jpg
new file mode 100644
index 000000000..a217d94da
Binary files /dev/null and b/admin/help/img/image032.jpg differ
diff --git a/admin/help/img/image033.jpg b/admin/help/img/image033.jpg
new file mode 100644
index 000000000..064e3bcf1
Binary files /dev/null and b/admin/help/img/image033.jpg differ
diff --git a/admin/help/img/image034.jpg b/admin/help/img/image034.jpg
new file mode 100644
index 000000000..98ab1cbfc
Binary files /dev/null and b/admin/help/img/image034.jpg differ
diff --git a/admin/help/img/image035.jpg b/admin/help/img/image035.jpg
new file mode 100644
index 000000000..b3b8f54a5
Binary files /dev/null and b/admin/help/img/image035.jpg differ
diff --git a/admin/help/img/image036.jpg b/admin/help/img/image036.jpg
new file mode 100644
index 000000000..c62db0266
Binary files /dev/null and b/admin/help/img/image036.jpg differ
diff --git a/admin/help/img/image037.jpg b/admin/help/img/image037.jpg
new file mode 100644
index 000000000..58699beec
Binary files /dev/null and b/admin/help/img/image037.jpg differ
diff --git a/admin/help/img/image038.jpg b/admin/help/img/image038.jpg
new file mode 100644
index 000000000..060948d5a
Binary files /dev/null and b/admin/help/img/image038.jpg differ
diff --git a/admin/help/img/image039.jpg b/admin/help/img/image039.jpg
new file mode 100644
index 000000000..0a3f38f4a
Binary files /dev/null and b/admin/help/img/image039.jpg differ
diff --git a/admin/help/img/image040.jpg b/admin/help/img/image040.jpg
new file mode 100644
index 000000000..d9080512d
Binary files /dev/null and b/admin/help/img/image040.jpg differ
diff --git a/admin/help/img/image041.jpg b/admin/help/img/image041.jpg
new file mode 100644
index 000000000..192723992
Binary files /dev/null and b/admin/help/img/image041.jpg differ
diff --git a/admin/help/img/image042.jpg b/admin/help/img/image042.jpg
new file mode 100644
index 000000000..25ade7342
Binary files /dev/null and b/admin/help/img/image042.jpg differ
diff --git a/admin/help/img/image043.jpg b/admin/help/img/image043.jpg
new file mode 100644
index 000000000..38afb6ed1
Binary files /dev/null and b/admin/help/img/image043.jpg differ
diff --git a/admin/help/img/image044.jpg b/admin/help/img/image044.jpg
new file mode 100644
index 000000000..bc227a2cc
Binary files /dev/null and b/admin/help/img/image044.jpg differ
diff --git a/admin/help/img/image045.jpg b/admin/help/img/image045.jpg
new file mode 100644
index 000000000..4ba225526
Binary files /dev/null and b/admin/help/img/image045.jpg differ
diff --git a/admin/help/img/image046.png b/admin/help/img/image046.png
new file mode 100644
index 000000000..d946ef165
Binary files /dev/null and b/admin/help/img/image046.png differ
diff --git a/admin/help/img/image047.png b/admin/help/img/image047.png
new file mode 100644
index 000000000..bb3333996
Binary files /dev/null and b/admin/help/img/image047.png differ
diff --git a/admin/help/img/image048.jpg b/admin/help/img/image048.jpg
new file mode 100644
index 000000000..1a1046109
Binary files /dev/null and b/admin/help/img/image048.jpg differ
diff --git a/admin/help/img/image049.jpg b/admin/help/img/image049.jpg
new file mode 100644
index 000000000..ad806987b
Binary files /dev/null and b/admin/help/img/image049.jpg differ
diff --git a/admin/help/img/image050.jpg b/admin/help/img/image050.jpg
new file mode 100644
index 000000000..ca35259b6
Binary files /dev/null and b/admin/help/img/image050.jpg differ
diff --git a/admin/help/img/image051.jpg b/admin/help/img/image051.jpg
new file mode 100644
index 000000000..38158751c
Binary files /dev/null and b/admin/help/img/image051.jpg differ
diff --git a/admin/help/img/image052.png b/admin/help/img/image052.png
new file mode 100644
index 000000000..9b8cd8cc1
Binary files /dev/null and b/admin/help/img/image052.png differ
diff --git a/admin/help/img/image053.jpg b/admin/help/img/image053.jpg
new file mode 100644
index 000000000..0feae788a
Binary files /dev/null and b/admin/help/img/image053.jpg differ
diff --git a/admin/help/img/image054.jpg b/admin/help/img/image054.jpg
new file mode 100644
index 000000000..75194c5eb
Binary files /dev/null and b/admin/help/img/image054.jpg differ
diff --git a/admin/help/img/image055.jpg b/admin/help/img/image055.jpg
new file mode 100644
index 000000000..cdbe6664e
Binary files /dev/null and b/admin/help/img/image055.jpg differ
diff --git a/admin/help/img/image056.jpg b/admin/help/img/image056.jpg
new file mode 100644
index 000000000..cd34df9c0
Binary files /dev/null and b/admin/help/img/image056.jpg differ
diff --git a/admin/help/img/image057.jpg b/admin/help/img/image057.jpg
new file mode 100644
index 000000000..b22a38ef9
Binary files /dev/null and b/admin/help/img/image057.jpg differ
diff --git a/admin/help/img/image058.jpg b/admin/help/img/image058.jpg
new file mode 100644
index 000000000..89e4f39c8
Binary files /dev/null and b/admin/help/img/image058.jpg differ
diff --git a/admin/help/img/image059.jpg b/admin/help/img/image059.jpg
new file mode 100644
index 000000000..13db6a447
Binary files /dev/null and b/admin/help/img/image059.jpg differ
diff --git a/admin/help/img/image060.jpg b/admin/help/img/image060.jpg
new file mode 100644
index 000000000..a2bf14aa2
Binary files /dev/null and b/admin/help/img/image060.jpg differ
diff --git a/admin/help/img/image061.png b/admin/help/img/image061.png
new file mode 100644
index 000000000..79e2bb660
Binary files /dev/null and b/admin/help/img/image061.png differ
diff --git a/admin/help/img/image062.png b/admin/help/img/image062.png
new file mode 100644
index 000000000..f9bc24810
Binary files /dev/null and b/admin/help/img/image062.png differ
diff --git a/admin/help/img/image063.png b/admin/help/img/image063.png
new file mode 100644
index 000000000..ec384ab60
Binary files /dev/null and b/admin/help/img/image063.png differ
diff --git a/admin/help/img/install/complete_install.PNG b/admin/help/img/install/complete_install.PNG
new file mode 100644
index 000000000..819e00859
Binary files /dev/null and b/admin/help/img/install/complete_install.PNG differ
diff --git a/admin/help/img/install/db_select.PNG b/admin/help/img/install/db_select.PNG
new file mode 100644
index 000000000..11bccdab4
Binary files /dev/null and b/admin/help/img/install/db_select.PNG differ
diff --git a/admin/help/img/install/environment_setting.PNG b/admin/help/img/install/environment_setting.PNG
new file mode 100644
index 000000000..305b00102
Binary files /dev/null and b/admin/help/img/install/environment_setting.PNG differ
diff --git a/admin/help/img/install/insert_admin_info.PNG b/admin/help/img/install/insert_admin_info.PNG
new file mode 100644
index 000000000..9d6b18473
Binary files /dev/null and b/admin/help/img/install/insert_admin_info.PNG differ
diff --git a/admin/help/img/install/insert_db_info.PNG b/admin/help/img/install/insert_db_info.PNG
new file mode 100644
index 000000000..41fa8cedb
Binary files /dev/null and b/admin/help/img/install/insert_db_info.PNG differ
diff --git a/admin/help/img/install/install_condition_check.PNG b/admin/help/img/install/install_condition_check.PNG
new file mode 100644
index 000000000..bda900fb2
Binary files /dev/null and b/admin/help/img/install/install_condition_check.PNG differ
diff --git a/admin/help/img/install/install_condition_check_error.PNG b/admin/help/img/install/install_condition_check_error.PNG
new file mode 100644
index 000000000..cd655f81d
Binary files /dev/null and b/admin/help/img/install/install_condition_check_error.PNG differ
diff --git a/admin/help/img/install/language_select.PNG b/admin/help/img/install/language_select.PNG
new file mode 100644
index 000000000..b4cf98052
Binary files /dev/null and b/admin/help/img/install/language_select.PNG differ
diff --git a/admin/help/img/make_general_site/add_home.PNG b/admin/help/img/make_general_site/add_home.PNG
new file mode 100644
index 000000000..1c714b02a
Binary files /dev/null and b/admin/help/img/make_general_site/add_home.PNG differ
diff --git a/admin/help/img/make_general_site/board_install.PNG b/admin/help/img/make_general_site/board_install.PNG
new file mode 100644
index 000000000..c1ac923e6
Binary files /dev/null and b/admin/help/img/make_general_site/board_install.PNG differ
diff --git a/admin/help/img/make_general_site/change_start_page.PNG b/admin/help/img/make_general_site/change_start_page.PNG
new file mode 100644
index 000000000..bd5483ec3
Binary files /dev/null and b/admin/help/img/make_general_site/change_start_page.PNG differ
diff --git a/admin/help/img/make_general_site/default_layout_setting.PNG b/admin/help/img/make_general_site/default_layout_setting.PNG
new file mode 100644
index 000000000..ab29f630d
Binary files /dev/null and b/admin/help/img/make_general_site/default_layout_setting.PNG differ
diff --git a/admin/help/img/make_general_site/delete_menu1.PNG b/admin/help/img/make_general_site/delete_menu1.PNG
new file mode 100644
index 000000000..e39f9c1f4
Binary files /dev/null and b/admin/help/img/make_general_site/delete_menu1.PNG differ
diff --git a/admin/help/img/make_general_site/ftp_password_confirm.PNG b/admin/help/img/make_general_site/ftp_password_confirm.PNG
new file mode 100644
index 000000000..146af09c3
Binary files /dev/null and b/admin/help/img/make_general_site/ftp_password_confirm.PNG differ
diff --git a/admin/help/img/make_general_site/home_page1.PNG b/admin/help/img/make_general_site/home_page1.PNG
new file mode 100644
index 000000000..dea7e9a36
Binary files /dev/null and b/admin/help/img/make_general_site/home_page1.PNG differ
diff --git a/admin/help/img/make_general_site/home_page2.PNG b/admin/help/img/make_general_site/home_page2.PNG
new file mode 100644
index 000000000..0f818f907
Binary files /dev/null and b/admin/help/img/make_general_site/home_page2.PNG differ
diff --git a/admin/help/img/make_general_site/home_page3.PNG b/admin/help/img/make_general_site/home_page3.PNG
new file mode 100644
index 000000000..e8e9cdabc
Binary files /dev/null and b/admin/help/img/make_general_site/home_page3.PNG differ
diff --git a/admin/help/img/make_general_site/home_page4.PNG b/admin/help/img/make_general_site/home_page4.PNG
new file mode 100644
index 000000000..bcf1123b7
Binary files /dev/null and b/admin/help/img/make_general_site/home_page4.PNG differ
diff --git a/admin/help/img/make_general_site/home_page5.PNG b/admin/help/img/make_general_site/home_page5.PNG
new file mode 100644
index 000000000..6e104bca0
Binary files /dev/null and b/admin/help/img/make_general_site/home_page5.PNG differ
diff --git a/admin/help/img/make_general_site/home_page6.PNG b/admin/help/img/make_general_site/home_page6.PNG
new file mode 100644
index 000000000..db408e996
Binary files /dev/null and b/admin/help/img/make_general_site/home_page6.PNG differ
diff --git a/admin/help/img/make_general_site/home_page7.PNG b/admin/help/img/make_general_site/home_page7.PNG
new file mode 100644
index 000000000..ef94d6fae
Binary files /dev/null and b/admin/help/img/make_general_site/home_page7.PNG differ
diff --git a/admin/help/img/make_general_site/home_page8.PNG b/admin/help/img/make_general_site/home_page8.PNG
new file mode 100644
index 000000000..8eb526194
Binary files /dev/null and b/admin/help/img/make_general_site/home_page8.PNG differ
diff --git a/admin/help/img/make_general_site/home_page_completed.PNG b/admin/help/img/make_general_site/home_page_completed.PNG
new file mode 100644
index 000000000..61fb36884
Binary files /dev/null and b/admin/help/img/make_general_site/home_page_completed.PNG differ
diff --git a/admin/help/img/make_general_site/menu_delete_confirm.PNG b/admin/help/img/make_general_site/menu_delete_confirm.PNG
new file mode 100644
index 000000000..2b01fc205
Binary files /dev/null and b/admin/help/img/make_general_site/menu_delete_confirm.PNG differ
diff --git a/admin/help/img/make_general_site/notice01_add.PNG b/admin/help/img/make_general_site/notice01_add.PNG
new file mode 100644
index 000000000..54608c56f
Binary files /dev/null and b/admin/help/img/make_general_site/notice01_add.PNG differ
diff --git a/admin/help/img/make_general_site/other_mentype_install.PNG b/admin/help/img/make_general_site/other_mentype_install.PNG
new file mode 100644
index 000000000..aee130f16
Binary files /dev/null and b/admin/help/img/make_general_site/other_mentype_install.PNG differ
diff --git a/admin/help/img/make_general_site/progress.PNG b/admin/help/img/make_general_site/progress.PNG
new file mode 100644
index 000000000..02b5fc061
Binary files /dev/null and b/admin/help/img/make_general_site/progress.PNG differ
diff --git a/admin/help/index.html b/admin/help/index.html
new file mode 100644
index 000000000..bee717b3a
--- /dev/null
+++ b/admin/help/index.html
@@ -0,0 +1,1669 @@
+
+
+
+
+
+
XE Admin Help
+
+
+
+
+
+
+
+
메뉴건너뛰기
+
+
+
+
+
+
+
+
+
+
+ XE 소개
+
+ XE란 무엇인가?
+ XE는 'eXpress'와 'Engine'이라는 두 단어를 합쳐 만든 이름으로, '사람들이 자신의 생각이나 느낌을 표현할 수 있도록 도와주는 장치'라는 의미를 담았습니다.
+ XE는 서버 컴퓨터에 설치해서 쓰는 웹 사이트 제작 프로그램입니다. 웹 사이트를 만들기 위해서는 HTML, CSS, PHP, SQL 등과 같은 프로그래밍 언어를 기본적으로 알아야 합니다. 하지만 XE를 사용하면 프로그래밍 언어를 잘 모르더라도 웹 사이트를 쉽게 만들 수 있습니다.
+ XE는 XE core라는 핵심 프로그램을 기반으로 다양한 추가 기능을 조합하여 사용자가 원하는 웹 사이트를 제작할 수 있습니다.
+
+
+ XE 개요
+
+ 참고
+ XE에 관한 자세한 정보는 XE 공식 사이트를 참조하십시오.
+ http://www.xpressengine.com
+
+
+
+ XE 기능 및 특징
+ XE의 기능 및 특징은 다음과 같습니다.
+ 손쉬운 사이트 구축
+ XE는 Textyle(블로그형), CafeXE(카페형), PlanetXE(마이크로 블로그형) 등 다양한 모듈을 제공합니다. 사용자는 만들고자 하는 사이트에 적합한 모듈을 선택하여 편리하게 사이트를 구축할 수 있습니다.
+ 모듈형 구조
+ XE에서 모듈은 하나의 프로그램을 의미합니다. XE는 기능의 제작과 추가, 사용이 쉽도록 레고 블록과 같은 모듈 구조로 제작되었습니다. 사용자는 XE에서 제공하는 기본 모듈과 커뮤니티를 통해 공유되는 확장 기능을 자유롭게 조합하여 다양한 웹 사이트를 제작할 수 있습니다. 개발자는 XE에 추가할 수 있는 새로운 기능의 모듈을 쉽게 개발하고 커뮤니티를 통해 공유할 수 있습니다.
+
+ XE는 오픈 커뮤니티를 통해 다양한 정보를 제공합니다. XE 커뮤니티에는 제로보드 시절부터 사용해 온 사용자와 자유/오픈 소스 프로젝트 멤버가 많습니다. 사용자는 커뮤니티 내에서 원하는 정보를 찾거나, 다른 사용자들에게 자유롭게 문의할 수 있습니다.
+ 다국어 지원
+ XE는 여러 나라의 언어를 지원합니다. 사용자는 웹 사이트를 언어별로 분리하지 않고도 한국어뿐 아니라 영어, 일본어, 중국어, 러시아어 등의 웹 사이트를 쉽게 제작할 수 있습니다.
+
+
+ 용어 정리
+
+ APMsetup
+ XE를 설치하는 데 필요한 구성 요소인 아파치 웹 서버, PHP, MySQL 데이터베이스를 한 번에 설치하고, 사용에 필요한 연동 설정을 자동으로 해 주는 프로그램. 공식 사이트는 http://www.apmsetup.com/ 입니다.
+ FileZilla
+ 무료 FTP(File Transfer Protocol) 접속 프로그램. 공식 사이트는 http://filezilla-project.org/ 입니다.
+ mod_rewrite
+ URL을 기억하기 쉽게 줄여 주는 기능. 예를 들어, http://example.com/index.php?module=admin을 http://example.com/admin과 같이 줄여 쓸 수 있습니다. 웹 서버에서 해당 기능을 지원해야 사용할 수 있습니다.
+ PuTTY
+ 텔넷(telnet)이나 SSH(Secure Shell) 프로토콜을 지원하는 원격 접속 프로그램. 공식 사이트는 http://www.putty.nl/ 이며, 한글 버전은 http://www.kldp.net/projects/iputty/download 에서 다운로드할 수 있습니다.
+ WPI
+ Web Platform Installer의 약어. 마이크로소프트 사에서 웹 플랫폼 제품을 편리하게 사용할 수 있도록 만든 도구이며, 공식 사이트는 http://www.microsoft.com/web/default.aspx 입니다.
+ XE core
+ XE의 설치와 운영을 담당하는 핵심 프로그램. XE core가 있어야 모듈, 레이아웃, 스킨 등의 추가 기능을 설치하고 실행할 수 있습니다.
+ XE 추가 기능
+ 사용자가 사이트를 더 편리하게 운영하도록 XE core에 추가할 수 있는 구성 요소. XE 추가 기능에는 모듈, 애드온, 위젯, 스킨, 위젯 스타일, 레이아웃이 있습니다.
+ XE
+ XpressEngine의 약어. 서버 컴퓨터에 설치해서 쓰는 오픈 소스 웹 사이트 제작 프로그램이며, 공식 사이트는 http://www.xpressengine.com/ 입니다.
+ 가상 사이트
+ XE에서 만들어진 웹 페이지를 XE의 기본 사이트와 다른 별개의 사이트처럼 사용할 수 있는 기능.
+ 레이아웃
+ 사이트에 설치한 추가 기능의 배치를 담당하는 구성 요소.
+ 모듈
+ XE에 추가해서 사용할 수 있는 하나의 프로그램.
+ 쉬운 설치
+ XE에서 모듈, 스킨 등의 추가 기능을 설치할 때 XE 공식 사이트에서 소스를 다운로드해서 서버에 업로드할 필요 없이 사이트에서 XE 공식 사이트와 연동하여 선택한 추가 기능을 설치할 수 있는 기능.
+ 스킨
+ 사이트에 설치된 프로그램의 디자인.
+ 애드온
+ 모듈 기능의 동작 사이에 끼어들어 자신의 기능을 수행하는 작은 프로그램.
+ 위젯 스타일
+ 위젯의 외관을 꾸미는 구성 요소.
+ 위젯
+ 레이아웃이나 페이지 모듈에 삽입되어 동작하는 구성 요소.
+ 제로보드
+ 1999년 개발된 게시판 소프트웨어. 제로보드 XE를 거쳐 현재의 XE로 발전되었습니다.
+ 사이트맵
+ 각 메뉴를 그룹핑하여 모아놓은 것으로 사이트맵을 사이트의 상단, 좌측, 우측, 하단 등에 배치하여 사용할 수 있습니다.
+
+
+
+
+ 설치 및 제거
+
+ 설치 전 준비
+ XE는 설치형 웹 응용프로그램입니다. XE를 사용하여 사이트를 만들기 위해서는 XE가 설치될 웹 서버가 필요합니다. XE를 설치할 서버의 공간을 확보하는 방법에는 여러 가지가 있지만, 크게 나누어 직접 서버로 사용할 컴퓨터를 확보하는 방법과 비용을 지불하고 웹 호스팅 업체가 제공하는 웹 서버의 공간 일부를 임대하는 방법이 있습니다.
+
+ 설치 프로그램 목록
+ 웹 서버가 구축된 환경에서 XE 설치를 위해 필요한 프로그램 목록은 다음과 같습니다. WPI(Microsoft Web Platform Installer)나 APMsetup을 사용해서 XE를 설치할 경우에는 아래 프로그램이 자동으로 설치됩니다. 그렇지 않은 경우에는 필요한 프로그램과 라이브러리를 미리 확인하여 설치해야 합니다.
+
+
+ 설치 프로그램 목록
+
+
+
+ 프로그램
+ 필수/선택
+
+
+ PHP
+ XE Core 1.5.x 이하: PHP 4.x ~ 5.x(5.2.2 제외)
+ 필수
+
+
+ XE Core 1.7 이상: PHP 5.2.4 이상
+ 필수
+
+
+ PHP 라이브러리
+ XML 라이브러리
+ 필수
+
+
+ GD 라이브러리
+ 필수
+
+
+ ICONV
+ 선택
+
+
+ DBMS(Database Management System)
+ CUBRID
+ 택1
+
+
+ Firebird (XE Core 1.7.x 이상부터 공식 지원 안함)
+
+
+ MySQL 4.1이상
+
+
+ PostgreSQL (XE Core 1.7.x 이상부터 공식 지원 안함)
+
+
+ SQLite2/SQLite3 (XE Core 1.7.x 이상부터 공식 지원 안함)
+
+
+ MS-SQL
+
+
+
+
+ XE core 설치 파일 다운로드
+ XE를 사용하여 사이트를 생성하려면 XE core를 설치해야 합니다. XE core는 XE의 설치와 운영을 담당하는 핵심 프로그램입니다. XE core에는 사이트 관리에 사용되는 기능이 없습니다. 하지만 XE core가 있어야 사용자가 추가 기능(모듈, 레이아웃, 스킨 등)을 설치하고 실행할 수 있습니다.
+ 최신 XE core 설치 파일은 http://code.google.com/p/xe-core/downloads/list 에서 무료로 다운로드할 수 있습니다.
+ 참고
+ Windows 환경에서 WPI를 사용해 XE를 설치할 때는 XE core 설치 파일을 다운로드할 필요가 없습니다.
+
+ XE core 설치 파일은 zip과 tgz, 두 가지 형식으로 제공됩니다. 내 컴퓨터에서 압축을 해제한 후 서버에 업로드하려면 zip 파일을, 압축 파일을 서버에 업로드한 후 압축을 해제하려면 tgz 파일을 다운로드합니다. 각 형식의 파일 업로드 방식은 "XE core 설치 파일 형식별 업로드 방법"을 참조하십시오.
+
+
+
+ 서버 환경 설정
+ XE는 서버 OS 종류에 상관없이 "설치 프로그램 목록" 이 설치된 모든 환경에서 설치할 수 있습니다. 사용자는 XE를 설치하기 전에 필요한 웹 서버 환경을 구축해야 합니다.
+ Windows 환경에서는 WPI나 APMsetup 중 하나를 선택해서 필요한 설치 프로그램과 XE를 함께 설치할 수 있습니다. 자세한 내용은 "Windows 환경 설정" 을 참조하십시오.
+ Linux 환경에서는 XE를 설치하기 전에 "설치 프로그램 목록" 의 프로그램을 수동으로 설치해야 합니다. 각 프로그램의 자세한 설치 과정은 이 문서에서 설명하지 않습니다. Linux 환경에서 계정을 설정하거나 원격으로 서버에 접속하는 방법, XE core 설치 파일을 업로드하는 방법은 "Linux 환경 설정" 을 참조하십시오.
+
+
+ XE core 설치
+ XE core를 설치하는 과정은 다음과 같습니다.
+
+ 웹 브라우저를 통해 XE core 설치 파일을 업로드한 경로(www.example.com 또는 www.example.com/xe)로 접근합니다.
+ 다음과 같이 사용할 언어를 선택하는 화면에서 원하는 언어를 선택하시고 '다음' 버튼을 누릅니다.
+
+ 참고
+ 페이지에 접근은 되지만 이미지가 제대로 보이지 않거나 내용이 비어 있으면, XE core 설치 파일을 다시 업로드해야 합니다.
+
+
+ 필수 설치 조건이 모두 가능으로 표시된 것을 확인하고 '설치를 진행합니다'를 클릭합니다.
+ 이 화면에서 '자세히'를 클릭하면 XE core를 설치할 때 최소 PHP 버전과 필수 라이브러리 설치 여부를 자동으로 확인할 수 있습니다. 필수 설치 조건에 가능으로 표시되지 않은 항목이 있으면 오류 메시지를 확인하여 해결합니다.
+ 짧은 주소를 사용할 수 없을 경우 경고창이 나타납니다. 짧은 주소를 사용하길 원치 않을 경우에는 그대로 설치를 진행합니다.
+
+ 참고
+ 파일 권한 설정 오류 때문에 퍼미션이 불가능으로 표시될 때는 "XE 설치 시 권한 설정 누락 오류"를 참조하십시오.
+
+
+ XE에서 사용할 DBMS를 선택하고 아래의 설치를 진행합니다를 클릭합니다. 이 문서에서는 mysqli를 선택합니다.
+
+ 참고
+ XE에서 사용 가능한 DBMS가 없으면 모든 항목이 비활성화됩니다. 이때는 사용할 DBMS를 직접 설치하거나, 호스팅 업체에 설치를 요청합니다.
+
+
+ 다음과 같이 DB 정보를 입력하고, 다음을 클릭합니다. 추가적인 설정의 변경이 필요할 경우에는 '고급 설정'을 클릭해서 수정할 수 있습니다.
+
+ 참고
+ DB 정보를 입력할 때 문제가 발생하면, "DB 계정 정보 오류" 를 참조하십시오.
+
+
+ 사이트 표준 시간대를 설정한 후 다음을 클릭합니다.
+
+ 관리자 정보를 입력합니다. XE 1.5부터는 이메일 주소가 로그인 계정이므로 실제 관리자가 사용할 이메일 주소를 입력하시기 바랍니다.
+
+
+ 설치가 완료되면 다음과 같이 XE Home(시작 페이지)이 나타납니다.
+
+
+
+
+
+ 제거
+ XE를 더 이상 사용하지 않는다면 XE가 설치되어 있는 폴더의 하위 내용을 모두 삭제합니다.
+ XE를 사용해서 제작한 사이트를 운영하는 데 사용된 모든 데이터는 DB에 저장됩니다. 데이터를 모두 삭제하려면 사이트 운영에 사용된 모든 DB 테이블을 삭제합니다. XE를 재설치하거나 서버를 이전할 때는 데이터를 이관하여 재사용할 수 있습니다.
+ 자세한 데이터 삭제 및 이관 방법은 사이트 운영에 사용한 DBMS의 사용법을 참조하십시오.
+
+
+
+ XE core 둘러보기
+
+ 관리자 페이지 시작
+ 다음과 같이 XE 관리자 페이지를 열고 관리자 계정 정보를 입력하여 로그인합니다. 아래 주소에서 'example.com'은 XE가 설치된 도메인 주소를 의미합니다.
+
+ 짧은 주소(mod_rewrite)를 사용할 경우:
+ http://example.com/admin
+ 짧은 주소(mod_rewrite)를 사용하지 않는 경우:
+ http://example.com/index.php?module=admin
+
+
+ XE 관리자 페이지
+
+
+
+
+ 이 절에서는 관리자가 사용 가능한 기본 메뉴를 설명합니다.
+
+ 대시보드
+ XE 관리자 홈입니다. 통계 및 사이트 현황, 최근 글, 댓글, 엮인글, 공지 등을 보여 줍니다.
+
+
+ 사이트 제작/편집
+
+ 사이트에서 사용되는 메뉴를 타입별로 쉽게 생성, 수정, 삭제할 수 있게 도와줍니다. 기본적으로 설치가 되지 않은 메뉴 타입이 있을 경우에는 손쉽게 설치할 수 있습니다. 또한 메뉴의 디자인 및 설정 정보도 손쉽게 수정이 가능합니다. 디자인 정보를 별도로 설정하지 않는다면 '사이트 디자인 설정'에서 설정한 내용이 적용 됩니다.
+ 사이트 디자인 설정
+ 사이트에서 사용되는 기본 디자인 설정을 할 수 있도록 도와 줍니다. 기본적으로 제공하는 디자인 설정 뿐 아니라 직접 html, css를 수정할 수 도 있습니다. 이곳에서 수정한 내용은 각 메뉴에서 별도로 설정하지 않는이상 모두 적용 됩니다.
+
+
+ 회원
+
+ 회원 목록
+ 사이트에 가입된 사용자 목록을 보여줍니다. 사용자의 소속 그룹을 변경하거나, 로그인 차단 등 사용자 정보를 확인, 수정, 삭제할 수 있습니다.
+ 회원 설정
+ 사이트 회원 가입 허가, 회원 가입 시 입력 양식 등 회원 관리에 필요한 다양한 설정을 할 수 있습니다.
+ 회원 그룹
+
+ 사이트에서 사용하는 회원 그룹을 관리합니다. 새로운 그룹을 생성하거나, 기존 그룹을 수정, 삭제할 수 있습니다.
+
+ 참고
+ 회원 그룹 내 '관리그룹'과 '관리자'의 차이는 "관리그룹, 관리자" 를 참고하시기 바랍니다.
+
+
+ 포인트
+ 회원이 글, 댓글을 작성하거나 업로드, 다운로드할 때 포인트를 부여할 수 있습니다. 또한 그룹의 레벨을 설정하여 포인트를 통한 레벨 업그레이드 기능을 설정할 수 있습니다.
+
+
+
+ 콘텐츠
+
+ 문서
+ 사이트에 등록된 문서를 관리합니다. 문서 내용을 확인하고 삭제할 수 있으며, 회원이 신고, 삭제한 문서를 확인할 수 있습니다.
+
+ 사이트에 등록된 댓글을 관리합니다. 댓글 내용을 확인하고 삭제할 수 있으며, 신고된 댓글을 확인할 수 있습니다.
+ 엮인글
+ 외부에서 링크했거나 엮인글의 목록을 볼 수 있습니다. 엮인글의 허용 여부를 선택할 수 있으며, 엮인글을 허용하지 않으면 글을 엮을 수 없고 링크하더라도 표시되지 않습니다.
+ 파일
+ 사이트에 등록된 글과 댓글에 첨부된 파일을 관리합니다. 등록된 파일을 삭제할 수 있습니다.
+ 설문
+ 사이트에 등록된 설문 콘텐츠를 관리합니다.
+
+ XE를 통해 생성된 다양한 모듈의 RSS(Rich Site Summary) 피드를 하나로 묶어서 제공할 수 있습니다. 기본값은 통합피드 사용입니다. 사이트 초기 화면을 통해 통합 피드가 제공되며, 피드 공개가 허용되지 않은 개별 모듈은 피드 목록에서 제외됩니다. 일부 모듈은 피드 공개의 기본값이 공개하지 않음으로 되어 있으므로, 모든 피드를 공개하려면 반드시 개별 모듈의 추가 설정 메뉴에서 피드 공개 항목이 전문 공개 또는 요약 공개로 되어 있는지 확인해야 합니다.
+ 다국어
+
+ XE는 글로벌 사이트를 별도로 생성하지 않고 하나의 사이트에서 다국어를 지원합니다. 다국어에 추가한 단어/문장에 연동된 목록은 사이트 언어 설정을 변경하면 자동으로 해당 언어의 내용으로 변환되어 표시됩니다. 다국어 메뉴는 사이트에 사용된 다국어 목록을 관리합니다. 등록된 다국어 목록을 확인할 수 있으며, 새로운 단어 또는 문장을 추가할 수 있습니다.
+
+ 참고
+ 다국어의 자세한 사용법은 FAQ의 "다국어" 를 참고하시기 바랍니다.
+
+
+ 데이터 들여오기
+
+ 제로보드4, zb5beta 또는 다른 프로그램의 데이터를 XE 데이터로 이전할 수 있습니다.
+
+ 참고
+ 데이터 들여오기의 자세한 사용법은 FAQ의 "데이터 들여오기" 를 참고하시기 바랍니다.
+
+
+ 휴지통
+ 문서나 댓글을 삭제하면 DB에서 바로 제거하지 않고 휴지통으로 이동합니다. 관리자가 내용을 다시 확인한 후 삭제된 문서나 댓글을 복구하거나 완전히 삭제할 수 있습니다.
+ 스팸필터
+ 글, 댓글 등이 등록될 때 스팸 여부를 확인하여 등록을 금지할 수 있습니다. 스팸필터 관리 메뉴에서 금지 IP와 금지 단어 목록을 설정할 수 있습니다.
+
+
+
+ 즐겨찾기
+ '고급 > 설치된 모듈'에서 자주 사용하는 모듈의 별 모양을 클릭하면 즐겨찾기에 추가할 수 있습니다. 추가 된 즐겨찾기는 '즐겨찾기' 메뉴에 노출됩니다.
+
+
+ 설정
+
+ 일반
+
+ 사이트 시작 화면을 결정하는 기본 모듈 설정, 기본 언어 등 사이트를 운영하기 위해 필요한 기본 설정을 할 수 있습니다. 또한, 보안을 위한 관리자 페이지 접근 가능 IP 대역 지정 등 다양한 고급 설정이 가능합니다.
+
+ 사이트 제목: XE Core 1.7 이상에서 새롭게 추가된 값입니다. 레이아웃에서 {Context::getSiteTitle()} 변수로 표시할 수 있습니다. default 레이아웃에 적용되어 있습니다.
+ 홈페이지: 사이트 접속 시 기본으로 호출될 페이지 지정할 수 있습니다.
+ 모바일 뷰 사용: 모바일 기기로 접속시 모바일 페이지를 보여줍니다.
+ 관리자 IP대역: 관리자 페이지로 접근가능한 IP대역을 지정합니다. 해당 IP에 대해서만 관리자 페이지로 접근이 가능하므로 주의 바랍니다. IP대역 정보는 /files/config/db.config.php 파일에 저장됩니다. 여러개의 항목은 줄을 바꾸어 입력하세요.
+ 기본 URL: 여러 사이트를 운영할 때 기본 URL이 필요합니다. XE 설치 경로를 포함한 URL을 입력하세요. (예: http://도메인/설치경로)
+ SSL(Secure Socket Layer) 사용: '선택적으로'는 회원가입, 정보수정 등의 지정된 동작(action)에서 보안접속(SSL)을 사용합니다. '항상 사용'은 모든 서비스에 SSL을 사용 합니다. SSL 환경이 갖춰지지 않은 상태에서 SSL을 사용할 경우 접속이 되지 않을 수 있으니 주의 바랍니다.
+ SSO 사용: 사용자가 한 번만 로그인하면 기본 사이트와 가상 사이트에 동시에 로그인이 됩니다. 가상 사이트를 사용할 때만 필요합니다.
+ 인증 세션 DB 사용: 인증 시 사용되는 PHP 세션을 DB로 사용하는 기능입니다. 웹서버의 사용률이 낮은 사이트에서는 비활성화시 사이트 응답 속도가 향상될 수 있습니다. 단, 현재 접속자를 구할 수 없어 관련된 기능을 사용할 수 없게 됩니다.
+ Qmail 호환: Qmail등 CRLF를 줄 구분자로 인식하지 못하는 MTA에서 메일이 발송되도록 합니다.
+
+
+ FTP 설정
+ 쉬운 설치 사용을 위한 FTP 계정을 설정합니다.
+ 관리자 설정
+ 관리자 화면의 제목과 로고, 메뉴를 설정할 수 있습니다.
+ 파일 업로드
+
+ 사이트에 등록할 수 있는 파일의 종류와 크기 등을 설정할 수 있습니다.
+
+ 파일 외부 링크: 리퍼러에 따라 파일 외부 링크를 차단할 수 있습니다.(*.wmv, *.mp3등 미디어 파일 제외)
+ 파일 크기 제한: 하나의 파일에 대해 최고 용량을 지정할 수 있습니다.(관리자는 제외)
+ 문서 첨부 제한: 하나의 문서에 첨부할 수 있는 최고 용량을 지정할 수 있습니다.(관리자는 제외)
+
+
+
+ 파일박스
+ 파일박스를 관리할 수 있습니다. 파일박스는 관리자가 재사용할 수 있는 이미지 파일을 관리하는 기능입니다. 회원 그룹 아이콘을 등록하면 이미지 파일은 파일박스에 업로드됩니다.
+
+
+
+ 고급
+
+ 쉬운 설치
+ 모듈, 스킨, 레이아웃, 위젯 등을 추가로 설치할 때, XE 공식 사이트에서 해당 소스를 다운로드해서 서버에 업로드할 필요 없이 사이트에서 XE 공식 사이트와 연동하여 선택한 추가 기능을 바로 설치합니다.
+ 설치된 레이아웃
+ 사이트에 설치된 레이아웃을 관리합니다. 각 레이아웃의 관리자 화면을 통해 인스턴스를 추가, 수정, 삭제할 수 있습니다.
+ 설치된 모듈
+ 사이트에 설치된 모듈을 출력합니다. 각 모듈의 관리자 화면에 접근하여 모듈을 관리할 수 있습니다. 목록의 즐겨찾기 버튼을 이용해서 자주 사용하는 모듈 관리자 링크를 화면 오른쪽 위에 즐겨찾기로 추가할 수 있습니다.
+ 설치된 위젯
+ 사이트에 설치된 위젯을 출력합니다. 각 위젯의 코드를 생성할 수 있습니다.
+ 설치된 애드온
+ 사이트에 설치된 애드온을 출력합니다. 각 애드온을 PC와 모바일 환경에서 사용하거나 사용하지 않도록 설정할 수 있습니다.
+
+ 참고
+ 1.5 버전부터는 쉬운 설치를 통해 설치된 레이아웃과 모듈, 위젯, 애드온을 '확장기능(v1.7에서는 고급) > 설치된 레이아웃, 설치된 모듈, 설치된 위젯, 설치된 애드온' 관리자 화면에서 삭제할 수 있습니다.
+
+
+ 에디터
+ 사이트의 기본 위지윅 에디터 설정과 확장 기능인 에디터 컴포넌트를 관리할 수 있습니다.
+
+
+
+
+
+ XE 추가 기능
+
+ XE 추가 기능의 종류
+ XE의 가장 큰 장점은 사용자가 원하는 다양한 기능을 추가하여 사이트를 좀 더 편리하게 운영할 수 있다는 것입니다. 다음과 같은 XE 추가 기능을 사용할 수 있습니다. 각 추가 기능의 설치 방법은 "추가 기능 설치 방법"을 참조하십시오.
+ 모듈
+ XE에서 모듈은 하나의 프로그램을 의미합니다. 여러 개의 모듈이 모여서 하나의 큰 모듈을 구성하기도 하고, 모듈이 개별적으로 동작하기도 합니다. 즉, 모듈은 사이트에 특정 기능을 구현하기 위해 추가로 설치한 프로그램입니다.
+ XE에서 제공하는 대표적인 모듈에는 게시판, CafeXE, Textyle 등이 있습니다.
+
+
+ 모듈
+
+ 애드온
+ 애드온은 모듈의 기능이 동작하는 사이사이에 끼어들어 자신의 기능을 수행하는 작은 프로그램입니다. 애드온은 모듈과 같이 스스로 기능을 수행하기는 하지만, 기능 수행 결과를 외부로 제공하지는 못한다는 점에서 모듈과 다릅니다.
+ XE에서 제공하고 있는 대표적인 애드온에는 기본 카운터, 모바일 XE 등이 있습니다.
+
+ 위젯은 레이아웃 또는 페이지 모듈에 삽입되어 동작합니다. 모듈에서 이미 생성된 데이터를 표시하거나, 일부 데이터를 생산할 수도 있습니다. 예를 들어, 게시판 모듈에서 작성된 최신 글 목록을 사이트의 시작 페이지에 나타내고 싶을 때 위젯을 사용합니다. XE에서 제공하는 대표적인 위젯에는 언어 선택, 로그인 정보 출력 위젯 등이 있습니다.
+
+ 위젯 스타일은 위젯의 외관을 꾸미는 역할을 합니다. 스킨이 위젯의 출력 부분을 꾸며준다면, 위젯 스타일은 위젯의 외곽부분에 대한 스킨이라고 생각할 수 있습니다. 위젯 스타일을 적용하면 외관 변경 외에도 위젯 블록에 제목이나 더보기 링크 등의 내용을 추가할 수 있습니다.
+
+ 위젯과 위젯 스타일
+
+ 스킨
+ 스킨은 사이트에 설치된 프로그램의 디자인을 의미합니다. 즉, 스킨은 프로그램(모듈, 위젯)의 옷이라고 할 수 있습니다.
+ XE 공식 사이트에서는 프로그램별로 다양한 스킨을 제공하고 있습니다. 이를 잘 활용하면 본인만의 개성이 담긴 사이트를 운영할 수 있습니다.
+ 레이아웃
+ 사이트에 여러 가지 추가 기능을 설치한 후에는 이들을 화면에 적절하게 배치해야 합니다. 이렇게 화면 배치를 담당하는 것이 레이아웃입니다. 레이아웃과 추가 기능(모듈, 위젯)은 매우 긴밀한 관계를 유지합니다. 추가 기능이 없으면 레이아웃은 아무런 내용도 출력할 수 없기 때문에 화면에 표시되지 않습니다. 반대로 프로그램은 설치되어 있으나 레이아웃이 없으면 각 요소가 출력될 위치를 알 수 없기 때문에 역시 화면에 표시되지 않습니다.
+
+ 레이아웃
+
+
+
+ 추가 기능 설치 방법
+ XE의 다양한 추가 기능을 설치 하는 방법에는 2가지가 있습니다. XE 공식 사이트에서 소스 파일을 다운로드해서 XE 설치 서버에 업로드하는 방법과 XE core에서 제공하는 쉬운 설치 기능을 사용하는 방법입니다.
+ 참고
+ XE에서 추가 기능을 설치하는 것은 추가 기능의 소스 코드를 운영하고 있는 서버에 옮기는 것을 의미합니다. 즉, 추가 기능 설치 과정만으로는 실제 사이트에 표시할 콘텐츠를 제작할 수 없습니다. 추가 기능을 생성하여 사이트와 연동하는 과정은 "사이트 만들기" 를 참조하시기 바랍니다.
+
+
+ 소스 파일 업로드로 추가 기능 설치
+ XE 공식 사이트에서 추가 기능 소스 파일을 다운로드해서 XE 설치 서버에 업로드하는 방법입니다.
+ 예를 들어, 소스 파일 업로드로 게시판 모듈을 설치하는 방법은 다음과 같습니다.
+
+ XE 공식 사이트 자료실(http://www.xpressengine.com/download )에 접속합니다.
+ 게시판 모듈을 하나 선택해서 내 컴퓨터에 다운로드합니다.
+
+
+ 다운로드한 게시판 모듈(zip 파일)의 압축을 해제합니다. 압축 해제가 완료되면 board라는 디렉터리가 생성됩니다.
+ 압축 해제한 board 디렉터리를 XE 설치 경로의 ./modules 디렉터리로 옮깁니다. 모든 모듈은 XE 설치 경로의 ./modules 디렉터리에 설치됩니다.
+ '고급 > 설치된 모듈' 목록에 다음 그림과 같이 게시판 모듈이 추가되었는지 확인합니다.
+
+
+ '이 항목 업데이트가 가능합니다. 업데이트하시겠습니까' 링크가 있을 경우에는 해당 링크를 클릭하면 설치가 완료됩니다.
+
+
+
+ 쉬운 설치로 추가 기능 설치
+ FTP 설정
+ 쉬운 설치로 추가 기능을 설치하려면 쉬운 설치 사용을 위한 계정을 설정해야 합니다. 방법은 다음과 같습니다.
+
+ 관리자 메뉴의 '설정 > FTP 설정'을 클릭합니다.
+ 다음과 같이 웹 서버의 FTP 계정 정보를 입력합니다.
+
+ 아이디:
+ 서버에 접근 가능한 아이디
+ 비밀번호:
+ 서버에 접근 가능한 비밀번호
+
+
+ 아이디, 비밀번호 외에 추가정보의 수정이 필요한 경우에는 '고급'에서 수정할 수 있습니다.
+
+ FTP 서버 주소:
+ 서버 주소는 XE가 설치된 서버로부터 접근하기 위한 주소입니다. 특별한 경우가 아니라면 XE는 자신이 설치된 서버에 구성 요소를 설치합니다. 따라서 자기 자신을 나타내는 주소인 localhost, 혹은 127.0.0.1을 입력합니다.
+ FTP port:
+ FTP 포트 번호의 경우 기본적으로 21을 쓰도록 되어 있으나, 서버에 따라 설정이 다를 수도 있습니다. 21이 아닐 때에는 서버 관리자에게 문의합니다.
+ Passive 모드를 사용:
+ 클라이언트(사용할 웹 서버)가 방화벽 환경에 있어도 FTP 서비스를 정상적으로 사용할 수 있게 하는 기능입니다. 예를 선택해야 방화벽이 설치된 환경에서 FTP를 사용할 수 있습니다. 따라서 쉬운 설치 기능을 사용하려면 서버에서 FTP Passive mode를 지원해야 합니다.
+ SFTP를 사용:
+ FTP 프로토콜을 통해 주고받는 데이터는 암호화되어 있지 않습니다. SFTP(SSH File Transfer Protocol)를 사용하면 쉬운 설치 기능을 더 안전하게 사용할 수 있습니다. SFTP는 관련 PHP 모듈이 설치되어 있어야 사용할 수 있습니다.
+
+
+
+ 모든 정보를 입력했으면 '저장'을 클릭합니다.
+
+ 쉬운 설치 사용을 위한 계정 설정을 완료하였습니다.
+ 참고
+ 쉬운 설치 진행 중에 FTP 홈 디렉터리 설정 관련 오류가 발생하면 "쉬운 설치 진행 시 FTP 홈 디렉터리 설정 오류" 를 참조하십시오.
+
+ 쉬운 설치 사용
+ 예를 들어, 쉬운 설치로 Textyle 모듈을 설치하는 방법은 다음과 같습니다.
+
+ 관리자 메뉴의 '고급 > 쉬운 설치'를 클릭합니다.
+ Textyle 모듈을 찾아서 모듈 설명 오른쪽에 있는 설치를 클릭합니다. 설치가 완료되면 오른쪽에 있는 설치 버튼이 사라집니다.
+
+
+
+
+
+
+
+ 사이트 만들기
+
+ 일반 사이트 만들기
+ 이 절에서는 3개의 게시판과 각 게시판과 링크된 메뉴, 게시판의 최신 글을 메인 페이지에 출력하는 간단한 일반 사이트를 만들어 보겠습니다.
+ 이 절에서 만들 사이트의 완성된 모습은 다음과 같습니다.
+
+ 일반 사이트 완성 화면
+
+
+ 사이트 제목 바꾸기
+ '설정 > 일반 > 기본 > 사이트 제목' 항목을 작성 또는 변경합니다. '생성된 레이아웃'에서 사이트 제목을 설정하지 않았을 때 이 제목이 노출됩니다.
+
+
+
+ 사이트 디자인 설정
+ 사이트에 사용할 메뉴들을 모두 생성하였으면, 전체적인 디자인을 설정해야 합니다. 먼저 레이아웃 설정을 합니다.
+
+ 관리자 화면에서 '사이트 제작/편집 > 사이트 디자인 설정 > 레이아웃'을 클릭합니다.
+ 레이아웃 목록에서 'Bootstrap.Layout'을 선택합니다.
+ 선택 후 'PC 설정 저장' 버튼을 눌러 내용을 저장합니다.
+
+
+ 이곳에서 선택한 레이아웃은 위에서 생성한 '홈', '공지사항', '자유게시판', '등업게시판' 모두에 적용 됩니다. 단 각 메뉴별로 별도의 레이아웃을 적용할 수도 있습니다. 각 메뉴별 별도 레이아웃을 적용하고자 하는 경우에는 '사이트맵 > 디자인 > 레이아웃' 에서 '사이트 기본 레이아웃 사용'을 체크 해제한 후 원하는 레이아웃을 선택하면 됩니다.
+
+
+
+ 페이지 수정
+ 이 절에서는 각 게시판에 최신 글을 볼 수 있도록 홈페이지를 수정해 보겠습니다.
+
+ XE가 설치된 도메인 주소를 브라우져 창에 입력하고 들어갑니다. (ex: http://example.com/) 또는 관리자 페이지 상단 로고 우측에 있는 도메인을 클릭해도 됩니다.
+ 아래와 같은 페이지가 표시되면 화면 오른쪽에 있는 '페이지 수정...'을 클릭합니다.
+
+ 참고
+ 페이지에 관리자 권한으로 접근하면 페이지의 콘텐츠를 편집하거나 설정할 수 있는 '캐시파일 재생성', '설정', '페이지 수정'이 표시됩니다. 이 버튼들이 보이지 않는다면 관리자 아이디로 로그인했는지 확인하시기 바랍니다.
+
+ 각 게시판의 최신 글을 페이지에 출력하려면 콘텐츠를 출력할 수 있는 위젯이 필요합니다. 우선, 자유게시판 내용을 나타내기 위한 위젯을 생성합니다.
+
+ 다음과 같이 페이지 수정 화면이 나타나면 Content 위젯을 선택하고 추가를 클릭합니다.
+
+
+ 위젯 코드 생성 창이 나타나면 다음과 같이 필요한 항목을 입력하고 코드생성을 클릭합니다.
+
+ 위젯:
+ Content 위젯 ver 0.1
+ 스킨:
+ Content 위젯 기본 스킨(default)
+ 캐시:
+ 5분
+ 추출대상:
+ 변경하지 않음
+ 내용형태:
+ 이미지+제목+내용
+ 탭형태:
+ 없음
+ 표시항목 및 순서:
+ 제목, 등록일, 글쓴이, 내용
+ 게시판 이름 표시:
+ 출력하지 않음
+ 댓글수 표시:
+ 출력
+ 엮인글수 표시:
+ 출력
+ 분류 표시:
+ 출력
+ 아이콘 표시:
+ 출력
+ 정렬 대상:
+ 최신 등록순
+ 정렬 방법:
+ 내림차순
+ 썸네일 생성 방법:
+ Crop(채우기)
+ 이미지 가로 크기:
+ 100
+ 이미지 세로 크기:
+ 75
+ 가로 이미지수:
+ 5
+ 목록수:
+ 5
+ 페이지수:
+ 1
+ new 표시 시간 (hours):
+ 12
+ 제목 글자수:
+ 0
+ 내용 글자수:
+ 100
+ 대상 모듈:
+ 추가를 클릭하고 모듈 선택 팝업에서 모듈에 게시판으로 검색하여 자유게시판을 선택
+ HTML 출력방식:
+ Table
+
+ 위젯이 생성되면 다음 그림과 같은 화면을 확인할 수 있습니다.
+
+ 참고
+ 게시판에 작성된 글이 없는 경우 위젯에 내용이 나타나지 않습니다. 위젯의 내용을 확인하기 위해서는 각 게시판에 테스트를 위한 게시물을 미리 작성해 두어야 합니다.
+
+ 위젯 윗부분에 위젯과 연동되어 있는 게시판 이름과 게시판으로 이동할 수 있는 링크를 삽입하기 위해 위젯 스타일을 적용해 보겠습니다.
+
+ 추가된 위젯 영역 위로 마우스 커서를 움직여서 위젯 영역 왼쪽 윗부분에 표시되는 아이콘 메뉴 중 위젯 스타일 추가( )를 클릭합니다.
+ 위젯 스타일 팝업 창이 나타나면 적용할 위젯 스타일로 심플 스트롱을 선택하고 설정을 클릭합니다.
+ 위젯 스타일을 설정하는 화면이 나타나면 다음과 같이 설정합니다.
+
+ 컬러셋:
+ 하얀색
+ 제목:
+ 자유게시판
+ 더보기 URL:
+ 해당 게시판의 URL을 입력합니다. 자유게시판의 모듈 이름은 freeboard01이므로, http://xe설치경로/freeboard01을 입력합니다.
+ 더보기 텍스트:
+ 위젯과 연동된 게시판으로 이동하기 위한 링크의 텍스트입니다. 이 예제에서는 more로 지정합니다.
+
+
+ 자유게시판 위젯에 위젯 스타일이 다음과 같이 적용되었는지 확인합니다.
+
+
+ 나머지 두 게시판과 연동되는 위젯을 생성하고 위젯 스타일을 적용합니다.
+ 공지사항 코드를 생성할 때 아래의 설정 정보 외에 다른 내용은 모두 자유게시판 위젯을 생성할 때 입력한 내용과 동일하므로, 자유게시판 위젯 생성 과정을 참고하여 진행합니다.
+
+ 내용형태:
+ 제목
+ 표시항목 및 순서:
+ 제목, 등록일, 글쓴이
+ 대상 모듈:
+ 추가를 클릭하고 모듈 선택 팝업에서 모듈에 공지사항을 선택
+
+ 등업게시판 코드를 생성할 때도 아래의 설정 정보 외에 다른 내용은 모두 자유게시판 위젯을 생성할 때 입력한 내용과 동일합니다.
+
+ 내용형태:
+ 제목
+ 표시항목 및 순서:
+ 제목, 등록일, 글쓴이
+ 대상 모듈:
+ 추가를 클릭하고 모듈 선택 팝업에서 모듈에 등업게시판을 선택
+
+
+ 다음과 같이 3가지 위젯이 모두 추가되었는지 확인합니다. 단, 게시판에 게시된 글에 따라 위젯의 내용은 다를 수 있습니다.
+
+ 위젯 생성이 완료되었으면 이를 재배치합니다. 자유게시판 위젯은 그대로 두고 그 아래에 공지사항과 등업게시판 위젯을 가로로 나란히 배치하겠습니다.
+
+ 등업게시판 위젯 영역 위로 마우스 커서를 움직여 위젯 영역 왼쪽 위에 나타나는 아이콘 메뉴 중 화살표( )를 클릭합니다.
+ 다음과 같은 위젯 설정 화면이 나타나면 등업게시판 위젯 왼쪽에 공지사항 위젯을 나란히 둘 공간을 만들기 위해 위젯 정렬 속성을 오른쪽으로 변경하고 저장을 클릭합니다.
+
+
+ 등업게시판 위젯의 왼쪽 아래에 있는 크기 변경 핸들( )을 마우스로 끌어서 오른쪽으로 이동시켜 위젯의 가로 크기를 반 정도로 줄입니다.
+
+
+ 공지사항 위젯의 오른쪽 아래에 있는 크기 변경 핸들( )을 왼쪽으로 끌어서 가로 크기를 줄입니다. 공지사항 위젯의 가로 폭이 등업게시판 왼쪽의 빈 공간보다 작아지면 등업게시판 위젯과 나란히 정렬됩니다
+ 다음과 같이 정렬이 완료되면 오른쪽 아래에 있는 메뉴의 저장을 클릭합니다.
+
+
+
+
+
+
+ 시작 메뉴 설정
+ 설정한 메뉴들 중에 하나의 메뉴를 접속 시 기본페이지로 사용할 수 있습니다. XE 최초 설치시에는 자동으로 'welcome_menu' 메뉴의 'menu1이 '접속 시 기본페이지'로 지정되어 있습니다.
+ 접속 시 기본 페이지는 아래와 같이 변경할 수 있습니다.
+
+ '사이트 제작/편집' > '사이트 메뉴 편집'으로 이동합니다.
+ 원하는 메뉴를 클릭하면 나오는 서브메뉴에서 '사이트 접속 시 기본 페이지로 사용'을 클릭합니다.
+
+
+ XE 최초 설치시 기본페이지로 지정되어 있던 'menu1'이 '홈'으로 변경된 것을 확인할 수 있습니다.
+
+
+
+
+
+ FAQ
+
+
+ 계정 무한 대입 방지
+ 악의적인 목적을 가지고 로그인을 시도하는 경우를 방지하고자 로그인 실패 횟수를 제한하는 장치입니다. '계정 무한 대입 방지'를 사용하고자 할 경우에는 다음과 같이 하면 됩니다.
+
+ '회원 > 회원설정 > 로그인'으로 이동합니다. 아래와 같은 모습을 볼 수 있습니다.
+
+
+ 로그인 설정
+
+
+ '계정 무한 대입 방지 사용'에 '예'를 선택합니다.
+ '로그인 시도 횟수 제한 횟수'에 몇번의 로그인 시도를 허용할지 원하는 숫자를 입력합니다.
+ '로그인 시도 횟수 제한 시간'에는 제한 횟수를 넘겼을 경우 로그인을 허용하지 않을 시간을 입력합니다.
+ 위에서 설정한 휫수 이상 로그인이 실패할 경우 아래와 같이 표시 됩니다.
+
+
+ 로그인 제한 초과
+
+
+
+
+
+ 관리그룹, 관리자
+ 관리그룹과 관리자와의 이름이 유사하여 혼동이 생길 수 있습니다. 관리그룹과 관리자의 차이는 아래와 같습니다.
+
+ 관리그룹: '회원 > 회원 그룹'에 기본적으로 생성되는 그룹으로서 실질적 관리권한이 있는 것이 아닙니다. 각 모듈 별 '권한 관리'에서 관리권한을 '관리그룹'에게 줄 경우 해당 그룹에 속해있는 회원에게 권한이 부여됩니다.
+ 관리자: XE를 최초 설치할 때 입력한 정보의 회원을 말하는 것입니다. 사이트의 모든 실절적 권한은 '관리자'에게 있습니다.
+
+
+
+ '임시' 문서
+ '콘텐츠 > 문서 > 임시'에 보면 문서목록이 보입니다. 여기에 보이게 되는 문서는 회원들이 글을 작성하는 도중 '임시 저장' 버튼을 눌러 저장한 문서입니다.
+ 임시 저장한 문서는 다른 회원들에게 보여지지 않습니다.
+ 임시 저장한 문서는 추후 글쓰기 화면에서 '불러오기'를 통해 다시 불러 쓸 수 있습니다.
+ 임시 저장과 비슷한 개념으로 '자동 저장'이 있습니다. 자동 저장은 임시저장과는 달리 글쓴이가 직접 저장하는 행동을 취하지 않아도 저장되며, 글쓰기를 시작할 때 자동저장 된 글이 있으면 자동저장된 글을 불러올 것인지 물어보게 됩니다.
+
+
+ 파일 목록의 '유효', '대기'
+ '콘텐츠 > 파일'에 보면 파일의 상태가 '유효'와 '대기'로 나누어 집니다. 각 상태는 아래와 같습니다.
+
+ 유효: 문서를 작성하면서 파일을 등록한 후 문서 작성을 완료 한 상태
+ 대기: 문서를 작성하면서 파일을 등록하였지만 아직 문서 작성을 완료하지 않은 상태 또는 작성을 취소한 상태 에서 남아있는 파일
+
+
+
+
+ 관리자 접속 아이피 대역 관리
+ 관리자의 아이디와 비밀번호만 알게 되면 관리자로 어느 곳에서나 로그인이 가능합니다. 따라서 관리자 아이디로 접속할 수 있는 아이피 대역을 제한해 두면 보안에 유리합니다.
+ 관리자의 아이디로 접속할 수 있는 아이피 대역을 설정하기 위해서는 다음과 같이 하면 됩니다.
+
+ '설정 > 일반'을 접속합니다.
+ '고급'의 '관리자 IP대역'에 원하는 IP를 입력합니다.
+
+
+ 관리자 IP 대역 입력
+
+
+ ip를 직접 수정하고 싶으신 분은 'XE설치폴더/files/db.config.php'의 "$db_info->admin_ip_list = '127.0.0.1,127.0.0.2';" 부분을 수정해 주면 됩니다.
+ 관리자 아이디로 로그인 하였지만 ip 제한에 걸린 경우에는 다음과 같은 모습을 보게 됩니다.
+
+
+ 관리자 접속 제한
+
+
+
+
+
+ SSL 접속
+ 일반 접속은 사용자와 서버간에 전송되는 내용이 암호화되지 않아 중요한 정보가 악의적인 사용자에 의해 탈취당할 수 있습니다. 이를 방지하기 위해 SSL 접속을 사용할 수 있습니다.
+ XE에서는 SSL 접속을 '선택적'으로 또는 '항상' 사용할 수 있습니다.
+ 선택적으로 사용할 경우에는 '회원가입', '정보 수정' 등에서만 SSL 접속을 유지합니다.
+ 관련 설정은 '설정 > 일반 > 고급 > SSL(Secure Sockets Layer) 사용'에서 선택할 수 있습니다.
+ 참고
+ 서버에 SSL이 설치되어 있지 않은 경우에는 접속 기능이 동작하지 않습니다. 먼저 SSL이 설치되어 있는지 확인 후 사용하시기 바랍니다.
+
+
+
+ 짧은 주소
+ 짧은 주소는 복잡하고 어려운 XE의 주소를 간단하게 사용할 수 있도록 줄여주는 기능입니다. 짧은 주소를 사용하게 되면 아래와 같은 이점이 있습니다.
+
+ 짧은 주소: http://xemanual.com/freeboard/123
+ 원래 주소: http://xemanual.com/index.php?mid=freeboard&document_srl=123
+
+ 짧은 주소를 사용하길 원할 경우에는 '설정 > 일반 > 고급 > 짧은 주소 사용'에 '예'를 선택한 후 '저장'하면 됩니다.
+
+
+ 데이터 들여오기
+ 제로보드4, zb5beta 또는 다른 프로그램의 데이터를 XE 데이터로 이전할 수 있습니다. 데이터의 추출은 공식사이트의 자료실 에서 다운로드 받으시거나 svn을 통해 xe-migration project 를 export 받으시면 됩니다.
+ XE의 '게시물 정보'를 다른 XE사이트 게시물로 이전하는 작업을 예로 들어 설명해 드리도록 하겠습니다.
+
+ 공식사이트의 자료실에서 "XpressEngine 데이터 추출 Ver 0.3" 을 다운로드 받거나 xe-migration project 에서 소스를 export 받습니다.
+ 다운로드 받은 소스를 URL로 접근 가능한 곳에 압축을 풉니다. 이 예제에서는 XE의 URL이 http://example.com/xe/라면 http://example.com/migration/ 아래로 하겠습니다.
+ 브라우져로 http://example.com/migration/index.php으로 접근하면 아래와 같은 모습을 볼 수 있습니다.
+
+
+ XE data export 초기화면
+
+
+ 2번에서 이야기한 url에 근거해 '설치 경로 입력'란에 "../xe" 라고 입력합니다. 절대 경로로 입력해도 됩니다. 사용자에 따라 입력 경로가 달라질 수 있습니다.
+ 설치 경로 입력 후 '설치 경로 입력' 버튼을 누르면 아래와 같은 모습을 볼 수 있습니다.
+
+
+ 추출 대상 선택
+
+
+ 이 예제에서는 게시물 정보를 이전할 예정이니 '게시판'을 선택 후 '자유게시판'을 선택합니다. 선택 후 '추출 대상 선택' 버튼을 누릅니다.
+ 아래와 같은 결과가 나옵니다.
+
+
+ 추출 옵션 선택 및 다운로드
+
+
+ 분할 수는 추출하는 데이터를 몇개의 파일로 나누어서 받을 지 결정하는 것입니다. 여기서는 게시물의 수가 많지 않으므로 1개로 받도록 하겠습니다.
+ 첨부파일을 포함하고 싶지 않을 경우에는 '첨부파일 미포함'에 체크를 합니다.
+ 데이터 들여오기 시 실제 xml 파일을 서버에 올려놓아 사용하거나 URL을 복사해서 사용할 수 있습니다. 여기서는 실제 xml 파일을 다운로드 받아 사용하도록 하겠습니다.
+ 옵션을 모두 결정했다면 파일명(module_57395.000001.xml)을 눌러 다운로드를 받습니다.
+ 다운로드 받은 파일을 xe가 설치된 위치에 업로드 합니다.
+ 관리자의 '콘텐츠 > 데이터 들여오기'로 들어갑니다.
+ '게시물 정보'의 xml 파일 입력 폼에 파일 명을 아래와 같이 입력한 후 '경로 확인' 버튼을 누릅니다.
+
+
+ 경로 확인
+
+ 참고
+ 실제 파일이 아니라 export에서 복사한 url을 입력해도 됩니다.ex) http://example.com/migration/export.php?filename=module_57395.000001.xml&path=..%2Fmaserati&target_module=module&module_id=57395&start=0&limit_count=1232&exclude_attach=
+
+
+ 'XML 파일을 찾았습니다.'란 메시지가 뜨면서 추가 입력상자가 보이게 됩니다. 'XML 파일을 찾을 수 없습니다.'라는 메시지가 보이게 되면 경로가 잘못 입력한 것이니 경로를 위치가 맞는지 확인해 보아야 합니다.
+ '찾기' 버튼을 통해 어떤 메뉴로 데이터를 이전할 것인지 선택합니다.
+ 회원 아이디 기반으로 회원정보를 동기화 시키고 싶다면 '회원정보 동기화' 체크박스에 체크합니다.
+ 필요한 내용을 모두 입력하였으면, '데이터 들여오기' 버튼을 클릭합니다. 아래와 같이 '데이터 이전중입니다'라는 프로그레스바가 보이면서 데이터가 이전 됩니다.
+
+
+ 데이터 이전 중
+
+ 참고
+ 데이터 이전에는 오랜 시간이 걸릴 수 있으므로, 게시물의 수가 많을 경우에는 분할하여 이전하시고 프로그레스바가 표시 중일때는 브라우져를 새로고침하지 말고 기다려 주시기 바랍니다.
+
+
+ 데이터 이전이 완료되면 아래와 같이 메시지가 나타납니다.
+
+
+ 데이터 이전 완료
+
+
+
+
+
+
+ 관리자 메뉴는 "설정 > 관리자 설정"에서 추가, 삭제할 수 있습니다. 추가, 삭제후 최초의 관리자 메뉴로 되돌리고 싶을 경우 '관리자 메뉴 초기화'를 할 수 있습니다. 관리자 메뉴 초기화를 하게 되면 XE 최초 설치시 설정 된 관리자 메뉴로 복원 됩니다.
+
+
+ 캐시파일 재생성
+
+ XE는 최적의 성능을 내기 위해 각종 캐시 파일을 사용합니다. 하지만 캐시 파일이 최신 내용의 적용되지 않음으로 인해 문제가 발생할 수 있습니다. 이럴 경우에는 관리자 하단에 있는 '캐시파일 재생성'을 통해 캐시파일을 새롭게 만들어 줄 수 있습니다.
+
참고
+ XE의 모든 기능에 캐시 기능이 들어 있는 것이 아니며, 캐시파일 재생성 역시 모든 기능에서 지원하는 것이 아닙니다. 따라서 캐시파일 재생성을 지원하는 기능에 한해 동작하게 됩니다.
+
+
+
+
+ 세션 정리
+ 오랜기간 사이트를 운영하다 보면 사용자의 정보 등을 담고 있는 세션들 중 일부 데이터가 가비지(찌꺼기) 데이터가 되는 경우가 있습니다. 이로 인해 사이트 자체가 느려지게 될 수 있습니다. 이럴 경우 '세션 정리'를 하게 되면 사이트의 속도 향상에 도움이 됩니다. 세션 정리의 경우 사이트에 부하가 발생할 수 있으므로 접속자가 적은 시간 또는 사이트의 운영을 중지한 상태로 진행하시기 바랍니다.
+
+
+ 문서 페이지
+ '회사 소개'와 같이 거의 갱신할 필요가 없는 정적인 문서입니다. 관리자는 '글, 이미지, 멀티미디어' 등을 문서 페이지에 직접 작성하거나 수정할 수 있습니다. 만약 프로그램에 의해 동적으로 갱신되는 콘텐츠를 문서에 삽입하고 싶다면 '문서 페이지' 대신 '위젯 페이지'를 사용하세요.
+
+
+
+ '초기 화면'과 같이 수시로 갱신할 필요가 있는 동적인 문서입니다. '문서 페이지'와 같이 정적인 내용을 추가할 수도 있지만 각종 '위젯'을 삽입하면 동적인 내용을 출력할 수 있습니다. 위젯 페이지에 '콘텐츠 위젯'을 삽입함으로써 초기 화면에 최근 게시물을 표시할 수 있습니다.
+
+
+ 외부 페이지
+ '사이트 제작/편집 > 사이트 메뉴 편집'에서 메뉴 추가 시 '외부 페이지' 타입이 있습니다. 여기서 말하는 '외부 페이지'란 XE의 모듈을 이용하지 않고 별도로 개발자가 작성한 페이지를 말합니다. 외부 페이지는 3rd party 개발자가 작성한 프로그램 소스가 들어가 있을 수 있으며, 아니면 순수 html로만 만들어진 경우도 있습니다.
+ 외부 페이지에서도 XE의 모듈 개발시 사용되는 기본적인 라이브러리 사용이 가능합니다.
+
참고
+ 메뉴 추가의 '바로가기' 타입에서 URL링크를 통해 추가할 수 있는 것과는 다른 개념입니다.
+
+
+
+
+ 바로가기
+ '사이트 제작/편집 > 사이트 메뉴 편집'에서 메뉴 추가 시 '바로가기'가 있습니다. 여기서 말하는 '바로가기'란 이미 만들어져 있는 메뉴 또는 외부 링크를 연결하는 메뉴입니다. 윈도우의 바로가기와 비슷한 메뉴라고 보면 됩니다.
+ 윈도우의 '바로가기' 삭제 시 원본이 삭제 되지 않는 것처럼, XE에서도 바로가기 메뉴 삭제시 원본 메뉴에는 영향을 미치치 않습니다.
+
+
+ 메뉴 노출 대상
+ '사이트 제작/편집 > 사이트 메뉴 편집 > 권한'에 '메뉴 노출 대상'이 있습니다. '메뉴 노출 대상'은 다른 권한과는 달리 접근 자체를 제한하는 기능은 없습니다. 다만 메뉴를 보여주고 싶지 않은 대상일 경우 노출을 제한할 수 있습니다.
+
+ 예를 들어 아래와 같이 노출 대상은 '로그인 사용자', 접근 권한은 '모든 사용자'로 설정을 하게 될 경우, 로그인을 안한 사용자에게 메뉴는 보이지 않지만 접근 URL을 알고 있다면 해당 메뉴에 접근할 수 있습니다.
+
+
+ 권한 설정
+
+
+
+
+
+ 부록
+
+ Windows 환경 설정
+ Windows 환경에서 XE를 설치하는 방법에는 크게 두 가지가 있습니다. WPI를 사용하는 방법과 APMsetup을 사용하는 방법입니다. 두 가지 방법 모두 웹 서버인 IIS(Internet Information Server)를 설치할 때 포트 번호로 80을 사용하도록 설정하기 때문에, 한 컴퓨터에 두 가지 방법을 모두 사용할 수 없습니다. 사용자의 설치 환경에 따라 두 가지 방법 중 하나를 선택해서 사용합니다.
+ 참고
+ Windows XP에서 WPI를 사용하여 XE를 설치하면 URL을 기억하기 쉽게 줄여주는 mod_rewrite를 사용할 수 없습니다. mod_rewrite를 사용하려면 APMsetup을 사용해서 XE를 설치해야 합니다.
+ WPI로 패키징된 XE는 1.4.0.5 버전입니다. 최신 버전의 XE를 설치하려면 APMsetup을 사용하거나, WPI를 사용해서 설치한 후에 XE core를 별도로 업데이트해야 합니다.
+
+
+ 계정 설정
+ Windows 계열 서버에 XE를 설치하려면 서버에 접근할 수 있는 계정이 필요합니다. 서버 계정은 서버 관리자에게 문의하여 얻습니다. 서버를 직접 관리하는 경우에는 기존 계정을 사용하거나 새로운 계정을 생성하여 사용합니다.
+ 계정 이름을 정하고 나면 계정 유형을 선택할 수 있습니다. 서버 보안을 유지하기 위해 가능하면 제한된 계정을 선택하여 해당 계정의 권한을 최소화하는 것을 권장합니다.
+
+
+ 원격 데스크톱 연결
+ 서버를 직접 조작할 수 없을 경우 원격에서 서버에 접속하여 조작할 수 있는 방법이 필요합니다. Windows 시스템은 다른 컴퓨터에 접속하여 조작할 수 있게 하는 '원격 데스크톱 연결' 프로그램을 제공합니다.
+ 원격 데스크톱 연결을 사용하려면 서버의 도메인 주소나 IP 주소가 필요합니다. 이미 도메인 설정이 되어 있으면 설정된 도메인을 사용하여 접속하면 되지만, 그렇지 않은 경우 IP 주소를 사용해야 합니다. 서버의 IP 주소를 확인하고 원격 데스크톱 연결로 그 주소에 접속하는 방법은 다음과 같습니다.
+
+ Windows 서버의 명령 프롬프트를 실행합니다.
+ ipconfig 명령어를 입력해서 서버의 IP 주소를 확인합니다.
+
+
+ 내 컴퓨터에서 시작 > 보조프로그램 > 원격 데스크톱 연결을 실행하거나, 명령 프롬프트에서 mstsc를 실행합니다.
+ 원격 데스크톱 연결 창이 나타나면 컴퓨터에 연결할 서버의 주소를 입력하고 연결을 클릭합니다.
+
+
+ 서버의 계정과 암호를 입력하는 화면이 나타나면, "계정 설정"에서 생성한 계정 정보를 입력하여 서버에 로그인합니다.
+
+
+
+ WPI 사용
+ WPI는 마이크로소프트 사에서 웹 플랫폼 제품을 편리하게 사용할 수 있도록 만든 도구입니다. 서버에 필요한 구성 요소나 웹 응용프로그램을 자동으로 설치 및 설정합니다.
+ WPI는 웹 응용프로그램을 설치할 때 그 웹 응용프로그램에 필요한 구성 요소를 한꺼번에 설치합니다. 따라서 WPI를 사용하여 XE를 설치할 때 XE 설치에 필요한 프로그램도 함께 설치됩니다.
+ 마이크로소프트 웹 플랫폼 공식 사이트(http://www.microsoft.com/web/default.aspx )에서 WPI 실행기를 다운로드합니다.
+ WPI 실행기 실행 및 XE 설치 시작
+
+ WPI 실행기를 실행하고, 웹 응용 프로그램 탭에서 콘텐츠 관리를 선택합니다.
+ 콘텐츠 관리 탭의 응용 프로그램 목록 중에서 XpressEngine을 찾아 선택하고 설치를 누릅니다.
+
+
+ XE core를 설치하기 위해 추가로 설치 및 설정되는 구성 요소 정보를 확인하고 동의함을 클릭하여 설치합니다.
+
+ 추가 구성 요소의 설치
+ 추가로 설치되는 구성 요소 중에 MySQL DBMS가 포함되어 있으면 MySQL DBMS을 설치하면서 관리자 암호를 지정해야 합니다. 관리자 암호를 지정하는 화면이 나타나면 암호를 지정하고 계속을 클릭합니다.
+ 참고
+ WPI에서 MySQL 관리자 암호를 처음 지정할 때, 영소문자, 영대문자, 숫자, 기호가 모두 포함된 암호를 지정해야 합니다. MySQL 관리자 암호는 XE를 설치할 때 반드시 필요한 정보이므로 꼭 기억해 두어야 합니다.
+
+ 계정 설정이 완료되면 구성 요소가 설치됩니다.
+
+ XE 설치에 필요한 구성 요소의 설치가 끝나면 XE 설치가 시작됩니다.
+
+ 다음과 같이 XE를 설치할 사이트 정보를 입력하고 계속을 클릭합니다.
+ 특별히 추가로 설정할 내용이 없다면 기본 설정을 그대로 사용합니다.
+
+
+ 다음과 같이 XE core 설치 정보를 입력하고 계속을 클릭합니다.
+
+ 데이터베이스:
+ XE에서 사용할 DBMS의 종류. 이 문서에서는 MySQL을 선택합니다.
+ 새 데이터베이스 만들기 또는 기존 데이터베이스 사용:
+ 기존의 데이터베이스를 사용하여 XE를 운영할 것인지, 새 데이터베이스를 사용할 것인지 선택. 가능하면 새 데이터베이스 만들기를 권장합니다.
+ 데이터베이스 관리자:
+ 선택된 DBMS의 관리자 ID. 이 문서에서 사용된 MySQL의 관리자 ID는 root입니다.
+ 데이터베이스 관리자 암호:
+ 선택된 DBMS의 관리자 암호. "추가 구성 요소의 설치"에서 지정한 MySQL 관리자 암호를 입력합니다.
+ 데이터베이스 사용자 이름:
+ XE에서 데이터베이스에 접근할 때 사용할 사용자 이름
+ 데이터베이스 암호:
+ XE에서 데이터베이스에 접근할 때 사용할 사용자 암호
+ 데이터베이스 서버:
+ DBMS가 설치된 위치를 URL 형식으로 지정. 이 문서에서는 서버와 DBMS가 같은 컴퓨터에서 동작하므로 localhost를 입력합니다.
+ 데이터베이스 이름:
+ XE에서 사용할 기존 혹은 새 데이터베이스의 이름
+ 데이터베이스 테이블 접두사:
+ XE에서 생성한 테이블 이름에 사용할 머리말
+ XE 관리자 ID:
+ XE 관리자 ID
+ XE 관리자 이름:
+ XE 관리자 이름
+ XE 관리자 닉네임:
+ XE 관리자 계정의 별명
+ XE 관리자 패스워드:
+ XE 관리자 계정의 패스워드
+ XE 관리자 e-mail 주소:
+ XE 관리자 계정의 e-mail 주소
+ URL Rewrite 사용 여부:
+ mod_rewrite 사용 여부. 이 항목을 활성화하면 URL을 기억하기 쉽게 줄여서 사용할 수 있습니다.
+ GMT Timezone:
+ XE가 서비스할 지역의 표준시
+
+
+
+ 설치 확인
+ 모든 설치 과정이 완료되면 웹 브라우저를 사용하여 사이트에 접속합니다. 정상적으로 설치가 완료되었으면 다음과 같은 화면이 나타납니다.
+
+ XE 설치 완료 화면
+
+ 참고
+ WPI를 사용해서 XE를 설치하면 최신 버전의 XE core가 설치되지 않습니다. XE core를 최신 버전으로 업데이트하려면 공식사이트에서 제공하는 XE core 최신 버전 파일을 다운로드해서 압축을 해제한 후 XE 설치 사이트 최상위 폴더(C:\Inetpub\wwwroot\xe)에 덮어 쓰도록 합니다.
+
+
+
+ APMsetup 사용
+ APMsetup은 XE를 설치하는 데 필요한 구성 요소인 아파치 웹 서버, PHP, MySQL 데이터베이스를 한 번에 설치하고, 사용에 필요한 연동 설정을 자동으로 해 주는 프로그램입니다.
+ APMsetup 설치
+ 다음과 같이 APMsetup을 설치합니다.
+
+ APMsetup 공식 사이트(http://www.apmsetup.com )에서 최신 APMsetup 설치 파일을 다운로드합니다. 문서 작성 시점에 배포되어 있는 최신 버전은 APMsetup 7입니다.
+ 다운로드한 설치 파일을 실행합니다. 특별한 설정이 필요 없으면 기본 설정 상태로 설치를 진행하여 완료합니다.
+ 참고
+ APMsetup은 아파치 웹 서버를 설치할 때 포트 번호로 80을 사용하도록 설정합니다. 그러므로 시스템에 이미 포트 번호로 80을 사용하는 소프트웨어가 있을 경우에는 APMsetup을 정상적으로 설치할 수 없습니다.
+
+
+ http://localhost/로 접근해서 다음과 같은 페이지가 나타나는지 확인합니다.
+
+
+
+ APMsetup 설정
+ APMsetup 설정에서는 DB root 계정 패스워드를 변경하고 새로운 계정을 생성합니다. 이 과정이 XE를 설치하는 데 필수 조건은 아니지만 서버 보안을 위해서 아래와 같이 설정하기를 권장합니다.
+
+ 작업 표시줄에 있는 APMsetup의 아이콘( )을 마우스 오른쪽 버튼으로 클릭하고, APMsetup 설정 메뉴에서 MySQL root 패스워드 변경을 선택합니다.
+
+
+ 현재 MySQL root계정 패스워드에 초기 패스워드인 apmsetup을 입력하고, 새 패스워드를 입력한 후 MySQL root계정 패스워드 변경을 클릭합니다.
+ 참고
+ 이 문서는 APMsetup 7을 기준으로 설명합니다. 초기 패스워드가 apmsetup이 아니면 APMsetup 공식 사이트에서 설치하고 있는 APMsetup 버전의 초기 패스워드를 확인하시기 바랍니다.
+
+
+ XE를 설치할 때 사용할 새로운 데이터베이스 계정과 데이터베이스를 생성하기 위해 APMsetup 설정 메뉴에서 MySQL 신규 계정 생성을 선택합니다.
+ MySQL 계정 생성 창이 나타나면 계정 생성 정보를 입력하고 신규 계정 생성을 클릭합니다.
+ 현재 MySQL root계정 패스워드에 변경한 MySQL 관리자 패스워드를 입력하고, 생성할 MySQL 계정 아이와 패스워드, 디비명에 사용자가 원하는 값을 입력합니다. 연결 문자 집합과 정렬은 기본값을 그대로 사용합니다.
+ 참고
+ 새로 생성할 MySQL 계정과 패스워드, 데이터베이스 이름은 XE를 설치하는 데 필요한 정보이므로 꼭 기억해 두어야 합니다.
+
+
+
+ XE core 설치 파일 압축 해제
+ \APM_setup\htdocs에 XE core 최신 설치 파일의 압축을 해제합니다.
+ 압축 해제가 완료되면 xe 디렉터리가 생성된 것을 확인할 수 있습니다. 도메인 경로로 웹 페이지에 접근하려면 생성된 xe 디렉터리 하위 내용을 최상위 디렉터리로 이동시킵니다.
+ 이제 "XE core 설치" 를 참조해서 XE core를 설치합니다.
+
+
+
+ Linux 환경 설정
+ 이 절에서는 Linux 서버를 사용하여 XE를 설치할 때 필요한 기본 정보를 설명합니다.
+
+
+ PuTTY 사용
+ 서버에 접근하기 위해서 PuTTY(퍼티)라는 원격 접속 프로그램을 사용합니다. PuTTY는 telnet이나 SSH(Secure Shell) 프로토콜을 지원하는 서버에서만 사용할 수 있습니다.
+ PuTTY 프로그램의 설치 및 사용 방법은 다음과 같습니다.
+
+ KLDP 한글 iPuTTY 프로젝트(http://www.kldp.net/projects/iputty/download )에서 설치 파일을 다운로드해서 설치합니다.
+ 참고
+ PuTTY 공식 사이트(http://www.putty.nl/ )에서 다운로드한 프로그램은 한글이 지원되지 않으므로, 위의 사이트에서 설치 파일을 다운로드하기를 권장합니다.
+
+
+ PuTTY 실행 화면에서 Host Name에 서버 주소를 입력하고 창 아래쪽의 열기를 클릭합니다.
+ 로그인 화면이 나타나면 아이디와 비밀번호를 차례대로 입력합니다.
+ 비밀번호를 입력할 때 화면에 변화가 없어서 입력 내용을 확인할 수는 없지만, 비밀번호를 올바로 입력하고 엔터 키를 누르면 인증 성공/실패 여부가 나타납니다.
+
+ PuTTY 로그인 화면
+
+
+
+
+
+ XE core 설치 파일 업로드
+ 내 컴퓨터에 저장된 파일을 웹 서버에 업로드하려면 FTP(File Transfer Protocol) 프로그램이 필요합니다. 이 문서에서는 FileZilla라는 무료 공개 프로그램을 사용합니다. FileZilla는 FileZilla 공식 사이트(http://filezilla-project.org/download.php?type=client )에서 다운로드할 수 있습니다.
+ FileZilla를 사용해서 XE가 설치될 서버에 접속하여 파일을 업로드합니다.
+
+ 호스트:
+ 서버 도메인 주소 또는 IP주소
+ 사용자명:
+ 서버 접근 권한이 있는 계정. 위에서 설명한 PuTTY로 서버에 접속할 때 사용한 계정을 입력합니다.
+ 비밀번호:
+ 계정 비밀번호
+ 포트:
+ 접근 서버의 FTP 포트 번호. 일반적으로 21을 사용합니다. 서버 관리자가 FTP 포트 번호를 변경할 수 있으므로, 접속이 되지 않으면 접근 서버의 FTP 포트 번호를 다시 한 번 확인하십시오.
+
+
+ FileZilla 실행 후 서버 접속 성공 화면
+
+
+
+
+ XE core 설치 파일 형식별 업로드 방법
+ 웹 서버에 XE core 파일을 업로드하는 방법에는 두 가지가 있습니다.
+
+ zip 파일을 다운로드해서 압축을 해제한 후 서버에 업로드
+ tgz 파일을 다운로드해서 서버에 업로드한 후 압축 해제
+
+ 두 가지 방법 중 편한 방법을 선택해서 사용합니다.
+
+ 압축 해제 후 파일 업로드
+
+ 확장자가 zip인 XE core 설치 파일을 내 컴퓨터에 다운로드해서 압축을 해제합니다.
+ FileZilla를 사용해서 압축이 해제되어 생성된 xe 디렉터리에 포함된 파일을 서버에 업로드합니다.
+
+ 참고
+ XE core 파일은 서버의 root 디렉터리에 업로드합니다. 예를 들어, manual.xpressengine.com 서버의 root 디렉터리에 xe 디렉터리를 업로드하면, manual.xpressengine.com/xe로 접근해야 합니다.
+
+
+
+ 파일 업로드 후 압축 해제
+ Windows 환경에서는 파일을 업로드한 후 설치된 압축 프로그램을 사용하여 압축을 해제합니다.
+ Linux 환경에서는 다음과 같이 파일을 업로드한 후 압축을 해제합니다.
+
+ 확장자가 tgz인 XE core 설치 파일을 내 컴퓨터에 다운로드해서 서버에 업로드합니다.
+ PuTTY를 실행해서 서버에 접속한 후 root 디렉터리로 이동합니다.
+ ls 명령어를 입력해서 xe.x.x.x.tgz 파일이 업로드되었는지 확인합니다.
+ tar 명령어를 이용하여 tgz 파일의 압축을 해제합니다.
+
+
+ mv 명령어를 사용해서 생성된 xe 디렉터리의 하위 내용을 root 디렉터리로 옮깁니다. 그러면 도메인 경로로 웹 페이지에 접근할 수 있습니다.
+ mv xe/* .
+ 이때, 명령어 마지막의 점(.)을 빠트리지 않도록 주의합니다.
+ .htaccess 파일은 '*'로 옮겨지지 않을 수 있으므로 아래와 같이 한번더 합니다. '.htaccess' 파일은 짧은주소를 사용하기 위해 필요합니다.
+ mv xe/.htaccess .
+
+
+ 이미 xe.x.x.x.tgz 파일의 압축을 해제하고 xe 디렉터리 내용을 모두 이동시켰으므로, rm 명령어를 사용해서 xe.x.x.x.tgz 파일과 xe 디렉터리를 삭제합니다.
+ 참고
+ Linux 명령어에 대한 자세한 설명은 "Linux 명령어" 를 참조하십시오.
+
+
+
+
+
+
+ Linux 명령어
+
+ 파일 압축 및 해제 명령어 - tar
+
+ 사용 형식:
+ tar <Operation> [Options] (디렉터리 경로 또는 압축파일 경로)
+
+ <Operation>
+
+ [-]A:
+ 압축 파일에 tar 파일 추가
+ [-]c:
+ tar 파일 생성
+ [-]d:
+ 압축 파일과 비교할 때 사용. tar 파일과 해당 파일 시스템의 차이점을 확인할 때 사용
+ [-]r:
+ 압축 파일의 끝부분에 파일 추가
+ [-]t:
+ 압축 파일의 목록 확인
+ [-]u:
+ 이미 압축되어 있는 파일보다 더 새로운 파일일 때 추가
+ [-]x:
+ 압축 파일의 압축 해제
+ --delete:
+ 압축 파일에서 파일 삭제
+
+ <Common Options>
+
+ -C:
+ 압축 파일을 해제할 위치 지정
+ -f:
+ 파일 이름 지정
+ -j:
+ bzip2로 압축 또는 압축 해제
+ -p:
+ tar 파일을 생성하거나 압축을 해제할 때 원본 파일의 속성(권한, 디렉터리 소유자 등의 속성 정보)을 그대로 유지
+ -v:
+ 압축하거나 해제할 때 과정을 자세히 출력
+ -z:
+ gzip으로 압축이나 압축 해제를 한꺼번에 하려고 할 때 사용
+
+
+
+ 파일 및 디렉터리 삭제 명령어 - rm
+
+ 사용 형식:
+ rm [Option] (파일 또는 디렉터리 경로)
+
+ [Option]
+
+ [-]f:
+ 삭제할 파일을 추가 확인 없이 강제로 삭제
+ [-]r:
+ 디렉터리와 하위 디렉터리 및 파일을 모두 삭제
+ [-]v:
+ 삭제하고 있는 파일의 정보 출력
+
+
+
+ 파일 및 디렉터리 이동 명령어 - mv
+
+ 사용 형식:
+ mv [option] (파일 또는 디렉터리 경로) (파일 이름 또는 디렉터리 경로)
+
+ [Option]
+
+ [-]b:
+ 대상 파일이 있는 경우 덮어 쓰기 전 백업 파일 생성
+ [-]f:
+ 대상 파일이 있는 경우 강제로 덮어 씀
+ [-]u:
+ 대상 파일이 있는 경우 대상 내용이 최신일 때만 덮어 씀
+ [-]v:
+ 파일 이동 과정 출력
+
+
+
+ 디렉터리 생성 명령어 - mkdir
+
+ 사용 형식:
+ mkdir [Option] (디렉터리 이름)
+
+ [Option]
+
+ [-]p:
+ 최종 디렉터리 이름의 상위 디렉터리가 없으면 상위 디렉터리까지 모두 생성
+
+
+
+ 파일 및 디렉터리 권한 변경 명령어 - chmod
+
+ 사용 형식:
+ chmod [Option] <mode> (파일 또는 디렉터리 경로)
+
+ [Option]
+
+ [-]c:
+ 실제로 파일의 권한이 바뀐 파일만 출력
+ [-]f:
+ 파일의 권한을 변경할 수 없는 경우에 발생하는 오류 메시지를 출력하지 않고자 할 때 사용
+ [-]v:
+ 변경된 권한에 대한 내용 출력
+ [-]R:
+ 디렉터리와 파일의 권한을 모두 변경
+
+ <mode>
+ 파일 및 디렉터리가 가질 수 있는 권한은 r(read 읽기), w(write 쓰기), x(execute 실행) 이렇게 세 가지입니다. 각 권한은 아래 표와 같이 고유의 값을 가지며, 이 값을 더한 값으로 mode를 생성할 수 있습니다.
+
+
+
+ User
+ Group
+ Others
+
+
+
+
+ r
+ w
+ x
+ r
+ w
+ x
+ r
+ w
+ x
+
+
+ 400
+ 200
+ 100
+ 40
+ 20
+ 10
+ 4
+ 2
+ 1
+
+
+ 700
+ 70
+ 7
+
+
+
+ 예를 들어, 모든 권한을 주려면 위의 값을 모두 더한 777을 mode로 사용합니다. 사용자는 모든 권한을 갖고, 그 외의 사용자들은 읽기와 실행권한만 주려면, mode를 755로 설정합니다.
+
+
+ 계정 생성 명령어 - useradd
+
+ 사용형식:
+ useradd [Option] (계정이름)
+
+ [Option]
+
+ [-]u:
+ 사용자 ID
+ [-]g:
+ 그룹ID 또는 그룹 이름
+ [-]s:
+ 사용되는 SHELL 정보
+ [-]d:
+ 사용자 Home 디렉터리
+
+
+
+ 오류 처리
+ 이 절에서는 XE를 설치 및 설정할 때 발생할 수 있는 오류와 해결 방법을 설명합니다.
+
+ MySQL 최소 버전 오류
+
+ 오류 사항:
+ "XE cannot be installed under the version of MySQL 4.1. Current MySQL version is x.x.x-log" 메시지가 나타납니다.
+ 원인:
+ MySQL 버전이 최소 지원 버전보다 낮은 경우 발생합니다.
+ 해결 방법:
+ MySQL을 4.1 이상으로 업데이트합니다.
+
+
+
+ DB 계정 정보 오류
+
+ 오류 사항:
+ "Access denied for user 'xxx'@'xxxx' (using password: YES) xxx" 메시지가 나타납니다.
+ 원인:
+ DB 계정이 없거나, 비밀번호가 잘못되었거나, 연결하려는 데이터베이스에 대한 접근 권한이 없는 경우 발생합니다.
+ 해결 방법:
+ 계정 설정 및 접근 권한 정보, 입력한 데이터베이스 정보가 올바른지 확인합니다.
+
+
+
+ XE 설치 시 권한 설정 누락 오류
+
+ 권한 설정 누락 오류 화면
+
+
+ 오류 사항:
+ "[필수] XE의 설치 경로 또는 ./files 디렉터리의 퍼미션이 707이어야 합니다." 메시지가 나타납니다.
+ 원인:
+ XE 설치 경로에 files 디렉터리가 없는 경우 발생합니다.
+ 해결 방법(Windows):
+ XE 설치 경로에 files 디렉터리가 있는지 확인합니다.
+
+ Windows XP에서는 파일이나 폴더에 대한 권한을 별도로 설정할 필요 없이 XE를 설치할 수 있습니다. 단, Windows 7(IIS7)에서는 다음과 같이 IIS_IUSRS(그룹) 및 IUSRS(사용자)에게 권한을 부여해야 합니다.
+
+ XE를 설치한 폴더(여기서는 C:\Inetpub\wwwroot\xe)에서 마우스 오른쪽 버튼을 클릭하여 나타난 컨텍스트 메뉴에서 속성을 선택합니다.
+ 폴더의 속성 창에서 보안 탭을 선택합니다.
+ 창 가운데의 편집을 클릭합니다.
+ 폴더의 사용 권한 창에서 그룹 또는 사용자 이름 목록 중에 IIS_IUSRS 그룹과 IUSR 사용자가 있는지 확인하고, 없으면 추가를 클릭합니다.
+ 사용자 또는 그룹 선택 창에서 선택할 개체 이름을 입력하십시오 아래에 IUSR를 입력하고, 이름 확인을 클릭한 후 확인을 클릭합니다.
+ 폴더의 사용 권한 창에서 다시 한 번 추가를 클릭합니다.
+ 사용자 또는 그룹 선택 창에서 이번에는 IIS_USRS를 입력하고, 이름 확인을 클릭한 후 확인을 클릭합니다.
+ 사용자와 그룹이 모두 추가되었으면 IUSR를 선택하고, 아래의 사용 권한 중 모든 권한에 허용을 클릭한 후 적용을 클릭합니다.
+
+
+ IIS_IUSRS에도 동일하게 모든 권한을 적용하도록 설정합니다.
+
+ 해결 방법(Linux):
+ XE 설치 경로에 files 디렉터리가 있는지 확인합니다.
+
+ Linux 환경에서는 files 디렉터리가 없으면 mkdir 명령어로 files 디렉터리를 생성하고, chmod 명령어를 이용하여 권한을 설정합니다.
+
+
+
+
+ 쉬운 설치 진행 시 FTP 홈 디렉터리 설정 오류
+
+ 오류 사항:
+ "msg_make_directory_failed" 메시지가 나타납니다.
+ 원인:
+ 사이트 환경 설정의 '설치된 XE의 FTP경로 설정' 값이 잘못된 경우 발생합니다.
+ 해결 방법:
+ 설치된 XE의 절대 경로를 확인하여 값을 다시 설정합니다(XE의 절대 경로 끝에 반드시 '/'를 함께 표기해야 합니다).
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/index.php b/admin/index.php
index a9ee24778..1a6d787e3 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,2 +1,5 @@
valid_time;
- return apc_store(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
+ function put($key, $buff, $valid_time = 0)
+ {
+ if($valid_time == 0)
+ {
+ $valid_time = $this->valid_time;
+ }
+
+ return apc_store(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
}
/**
@@ -61,20 +74,25 @@ class CacheApc extends CacheBase {
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, the data is invalid.
+ * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid.
*/
- function isValid($key, $modified_time = 0) {
- $_key = md5(_XE_PATH_.$key);
+ function isValid($key, $modified_time = 0)
+ {
+ $_key = md5(_XE_PATH_ . $key);
$obj = apc_fetch($_key, $success);
- if(!$success || !is_array($obj)) return false;
+ if(!$success || !is_array($obj))
+ {
+ return false;
+ }
unset($obj[1]);
- if($modified_time > 0 && $modified_time > $obj[0]) {
+ if($modified_time > 0 && $modified_time > $obj[0])
+ {
$this->_delete($_key);
return false;
}
-
+
return true;
}
@@ -83,15 +101,20 @@ class CacheApc extends CacheBase {
*
* @param string $key The $key used to store the value.
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, return false.
+ * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/
- function get($key, $modified_time = 0) {
- $_key = md5(_XE_PATH_.$key);
+ function get($key, $modified_time = 0)
+ {
+ $_key = md5(_XE_PATH_ . $key);
$obj = apc_fetch($_key, $success);
- if(!$success || !is_array($obj)) return false;
+ if(!$success || !is_array($obj))
+ {
+ return false;
+ }
- if($modified_time > 0 && $modified_time > $obj[0]) {
+ if($modified_time > 0 && $modified_time > $obj[0])
+ {
$this->_delete($_key);
return false;
}
@@ -105,8 +128,9 @@ class CacheApc extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
- function _delete($_key) {
- $this->put($_key,null,1);
+ function _delete($_key)
+ {
+ $this->put($_key, null, 1);
}
/**
@@ -115,7 +139,8 @@ class CacheApc extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
- function delete($key) {
+ function delete($key)
+ {
$this->_delete($key);
}
@@ -124,10 +149,11 @@ class CacheApc extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
- function truncate() {
+ function truncate()
+ {
return apc_clear_cache('user');
}
-}
+}
/* End of file CacheApc.class.php */
/* Location: ./classes/cache/CacheApc.class.php */
diff --git a/classes/cache/CacheFile.class.php b/classes/cache/CacheFile.class.php
index bc3f11336..5e8b31dd7 100644
--- a/classes/cache/CacheFile.class.php
+++ b/classes/cache/CacheFile.class.php
@@ -1,12 +1,15 @@
cache_dir = _XE_PATH_ . $this->cache_dir;
- if(!is_dir($this->cache_dir)) FileHandler::makeDir($this->cache_dir);
+ if(!is_dir($this->cache_dir))
+ {
+ FileHandler::makeDir($this->cache_dir);
+ }
}
/**
@@ -47,16 +56,18 @@ class CacheFile extends CacheBase {
* @param string $key The key that will be associated with the item.
* @return string Returns cache file path
*/
- function getCacheFileName($key){
+ function getCacheFileName($key)
+ {
return $this->cache_dir . str_replace(':', '_', $key);
}
-
+
/**
* Return whether support or not support cache
*
* @return true
*/
- function isSupport(){
+ function isSupport()
+ {
return true;
}
@@ -68,8 +79,9 @@ class CacheFile extends CacheBase {
* @param int $valid_time Not used
* @return void
*/
- function put($key, $obj, $valid_time = 0){
- $cache_file = $this->getCacheFileName($key);
+ function put($key, $obj, $valid_time = 0)
+ {
+ $cache_file = $this->getCacheFileName($key);
$text = serialize($obj);
FileHandler::writeFile($cache_file, $text);
}
@@ -81,10 +93,14 @@ class CacheFile extends CacheBase {
* @param int $modified_time Not used
* @return bool Return true on valid or false on invalid.
*/
- function isValid($key, $modified_time = 0) {
+ function isValid($key, $modified_time = 0)
+ {
$cache_file = $this->getCacheFileName($key);
- if(file_exists($cache_file)) return true;
-
+ if(file_exists($cache_file))
+ {
+ return true;
+ }
+
return false;
}
@@ -95,11 +111,15 @@ class CacheFile extends CacheBase {
* @param int $modified_time Not used
* @return false|mixed Return false on failure. Return the string associated with the $key on success.
*/
- function get($key, $modified_time = 0) {
+ function get($key, $modified_time = 0)
+ {
$cache_file = $this->getCacheFileName($key);
$content = FileHandler::readFile($cache_file);
- if(!$content) return false;
-
+ if(!$content)
+ {
+ return false;
+ }
+
return unserialize($content);
}
@@ -109,7 +129,8 @@ class CacheFile extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
- function _delete($_key) {
+ function _delete($_key)
+ {
$cache_file = $this->getCacheFileName($_key);
FileHandler::removeFile($cache_file);
}
@@ -120,7 +141,8 @@ class CacheFile extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
- function delete($key) {
+ function delete($key)
+ {
$this->_delete($key);
}
@@ -129,10 +151,11 @@ class CacheFile extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
- function truncate() {
+ function truncate()
+ {
FileHandler::removeFilesInDir($this->cache_dir);
}
-}
+}
/* End of file CacheFile.class.php */
/* Location: ./classes/cache/CacheFile.class.php */
diff --git a/classes/cache/CacheHandler.class.php b/classes/cache/CacheHandler.class.php
index 1fa0040ae..dc574b6e3 100644
--- a/classes/cache/CacheHandler.class.php
+++ b/classes/cache/CacheHandler.class.php
@@ -1,10 +1,13 @@
use_object_cache =='apc') $type = 'apc';
- else if(substr($info->use_object_cache,0,8)=='memcache'){
+ function CacheHandler($target, $info = null, $always_use_file = false)
+ {
+ if(!$info)
+ {
+ $info = Context::getDBInfo();
+ }
+
+ if($info)
+ {
+ if($target == 'object')
+ {
+ if($info->use_object_cache == 'apc')
+ {
+ $type = 'apc';
+ }
+ else if(substr($info->use_object_cache, 0, 8) == 'memcache')
+ {
$type = 'memcache';
$url = $info->use_object_cache;
- } else if($info->use_object_cache == 'wincache') $type = 'wincache';
- else if($info->use_object_cache =='file') $type = 'file';
- else if($always_use_file) $type = 'file';
- }else if($target == 'template'){
- if($info->use_template_cache =='apc') $type = 'apc';
- else if(substr($info->use_template_cache,0,8)=='memcache'){
+ }
+ else if($info->use_object_cache == 'wincache')
+ {
+ $type = 'wincache';
+ }
+ else if($info->use_object_cache == 'file')
+ {
+ $type = 'file';
+ }
+ else if($always_use_file)
+ {
+ $type = 'file';
+ }
+ }
+ else if($target == 'template')
+ {
+ if($info->use_template_cache == 'apc')
+ {
+ $type = 'apc';
+ }
+ else if(substr($info->use_template_cache, 0, 8) == 'memcache')
+ {
$type = 'memcache';
$url = $info->use_template_cache;
- } else if($info->use_template_cache == 'wincache') $type = 'wincache';
+ }
+ else if($info->use_template_cache == 'wincache')
+ {
+ $type = 'wincache';
+ }
}
- if($type){
+ if($type)
+ {
$class = 'Cache' . ucfirst($type);
include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class);
- $this->handler = call_user_func(array($class,'getInstance'), $url);
- $this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
- if(!$this->keyGroupVersions) {
- $this->keyGroupVersions = array();
- $this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
- }
+ $this->handler = call_user_func(array($class, 'getInstance'), $url);
+ $this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
+ if(!$this->keyGroupVersions)
+ {
+ $this->keyGroupVersions = array();
+ $this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
+ }
}
}
}
@@ -81,8 +119,12 @@ class CacheHandler extends Handler {
*
* @return boolean
*/
- function isSupport(){
- if($this->handler && $this->handler->isSupport()) return true;
+ function isSupport()
+ {
+ if($this->handler && $this->handler->isSupport())
+ {
+ return true;
+ }
return false;
}
@@ -91,11 +133,15 @@ class CacheHandler extends Handler {
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, return false.
+ * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/
- function get($key, $modified_time = 0){
- if(!$this->handler) return false;
+ function get($key, $modified_time = 0)
+ {
+ if(!$this->handler)
+ {
+ return false;
+ }
return $this->handler->get($key, $modified_time);
}
@@ -105,12 +151,16 @@ class CacheHandler extends Handler {
* @param string $key Cache key
* @param mixed $obj Value of a variable to store. $value supports all data types except resources, such as file handlers.
* @param int $valid_time Time for the variable to live in the cache in seconds.
- * After the value specified in ttl has passed the stored variable will be deleted from the cache.
- * If no ttl is supplied, use the default valid time.
+ * After the value specified in ttl has passed the stored variable will be deleted from the cache.
+ * If no ttl is supplied, use the default valid time.
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
- function put($key, $obj, $valid_time = 0){
- if(!$this->handler) return false;
+ function put($key, $obj, $valid_time = 0)
+ {
+ if(!$this->handler)
+ {
+ return false;
+ }
return $this->handler->put($key, $obj, $valid_time);
}
@@ -120,8 +170,12 @@ class CacheHandler extends Handler {
* @param string $key Cache key
* @return void
*/
- function delete($key){
- if(!$this->handler) return false;
+ function delete($key)
+ {
+ if(!$this->handler)
+ {
+ return false;
+ }
return $this->handler->delete($key);
}
@@ -130,11 +184,15 @@ class CacheHandler extends Handler {
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, the data is invalid.
+ * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid.
*/
- function isValid($key, $modified_time){
- if(!$this->handler) return false;
+ function isValid($key, $modified_time)
+ {
+ if(!$this->handler)
+ {
+ return false;
+ }
return $this->handler->isValid($key, $modified_time);
}
@@ -143,8 +201,12 @@ class CacheHandler extends Handler {
*
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
- function truncate(){
- if(!$this->handler) return false;
+ function truncate()
+ {
+ if(!$this->handler)
+ {
+ return false;
+ }
return $this->handler->truncate();
}
@@ -164,8 +226,10 @@ class CacheHandler extends Handler {
* @param string $key Cache key
* @return string
*/
- function getGroupKey($keyGroupName, $key){
- if(!$this->keyGroupVersions[$keyGroupName]){
+ function getGroupKey($keyGroupName, $key)
+ {
+ if(!$this->keyGroupVersions[$keyGroupName])
+ {
$this->keyGroupVersions[$keyGroupName] = 1;
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
@@ -179,10 +243,12 @@ class CacheHandler extends Handler {
* @param string $keyGroupName Group name
* @return void
*/
- function invalidateGroupKey($keyGroupName){
+ function invalidateGroupKey($keyGroupName)
+ {
$this->keyGroupVersions[$keyGroupName]++;
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
+
}
/**
@@ -190,17 +256,19 @@ class CacheHandler extends Handler {
*
* @author NHN (developer@xpressengine.com)
*/
-class CacheBase{
+class CacheBase
+{
/**
* Get cached data
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, return false.
+ * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/
- function get($key, $modified_time = 0){
+ function get($key, $modified_time = 0)
+ {
return false;
}
@@ -210,11 +278,12 @@ class CacheBase{
* @param string $key Cache key
* @param mixed $obj Value of a variable to store. $value supports all data types except resources, such as file handlers.
* @param int $valid_time Time for the variable to live in the cache in seconds.
- * After the value specified in ttl has passed the stored variable will be deleted from the cache.
- * If no ttl is supplied, use the default valid time.
+ * After the value specified in ttl has passed the stored variable will be deleted from the cache.
+ * If no ttl is supplied, use the default valid time.
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
- function put($key, $obj, $valid_time = 0){
+ function put($key, $obj, $valid_time = 0)
+ {
return false;
}
@@ -223,10 +292,11 @@ class CacheBase{
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, the data is invalid.
+ * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid.
*/
- function isValid($key, $modified_time = 0){
+ function isValid($key, $modified_time = 0)
+ {
return false;
}
@@ -235,7 +305,8 @@ class CacheBase{
*
* @return boolean
*/
- function isSupport(){
+ function isSupport()
+ {
return false;
}
@@ -244,10 +315,11 @@ class CacheBase{
*
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
- function truncate(){
+ function truncate()
+ {
return false;
}
-}
+}
/* End of file CacheHandler.class.php */
/* Location: ./classes/cache/CacheHandler.class.php */
diff --git a/classes/cache/CacheMemcache.class.php b/classes/cache/CacheMemcache.class.php
index 17962a71c..1ba319ef2 100644
--- a/classes/cache/CacheMemcache.class.php
+++ b/classes/cache/CacheMemcache.class.php
@@ -1,10 +1,13 @@
Memcache = new Memcache;
- foreach($config['url'] as $url) {
+ foreach($config['url'] as $url)
+ {
$info = parse_url($url);
$this->Memcache->addServer($info['host'], $info['port']);
}
@@ -53,11 +60,18 @@ class CacheMemcache extends CacheBase {
*
* @return bool Return true on support or false on not support
*/
- function isSupport(){
- if($GLOBALS['XE_MEMCACHE_SUPPORT']) return true;
- if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1)) {
+ function isSupport()
+ {
+ if($GLOBALS['XE_MEMCACHE_SUPPORT'])
+ {
+ return true;
+ }
+ if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1))
+ {
$GLOBALS['XE_MEMCACHE_SUPPORT'] = true;
- } else {
+ }
+ else
+ {
$GLOBALS['XE_MEMCACHE_SUPPORT'] = false;
}
return $GLOBALS['XE_MEMCACHE_SUPPORT'];
@@ -69,8 +83,9 @@ class CacheMemcache extends CacheBase {
* @param string $key Cache key
* @return string Return unique key
*/
- function getKey($key){
- return md5(_XE_PATH_.$key);
+ function getKey($key)
+ {
+ return md5(_XE_PATH_ . $key);
}
/**
@@ -86,12 +101,16 @@ class CacheMemcache extends CacheBase {
* @param string $key The key that will be associated with the item.
* @param mixed $buff The variable to store. Strings and integers are stored as is, other types are stored serialized.
* @param int $valid_time Expiration time of the item.
- * You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).
- * If it's equal to zero, use the default valid time CacheMemcache::valid_time.
+ * You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).
+ * If it's equal to zero, use the default valid time CacheMemcache::valid_time.
* @return bool Returns true on success or false on failure.
*/
- function put($key, $buff, $valid_time = 0){
- if($valid_time == 0) $valid_time = $this->valid_time;
+ function put($key, $buff, $valid_time = 0)
+ {
+ if($valid_time == 0)
+ {
+ $valid_time = $this->valid_time;
+ }
return $this->Memcache->set($this->getKey($key), array(time(), $buff), MEMCACHE_COMPRESSED, $valid_time);
}
@@ -101,17 +120,22 @@ class CacheMemcache extends CacheBase {
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, the data is invalid.
+ * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid.
*/
- function isValid($key, $modified_time = 0) {
+ function isValid($key, $modified_time = 0)
+ {
$_key = $this->getKey($key);
$obj = $this->Memcache->get($_key);
- if(!$obj || !is_array($obj)) return false;
+ if(!$obj || !is_array($obj))
+ {
+ return false;
+ }
unset($obj[1]);
- if($modified_time > 0 && $modified_time > $obj[0]) {
+ if($modified_time > 0 && $modified_time > $obj[0])
+ {
$this->_delete($_key);
return false;
}
@@ -126,15 +150,20 @@ class CacheMemcache extends CacheBase {
*
* @param string $key The key to fetch
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, return false.
+ * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/
- function get($key, $modified_time = 0) {
+ function get($key, $modified_time = 0)
+ {
$_key = $this->getKey($key);
$obj = $this->Memcache->get($_key);
- if(!$obj || !is_array($obj)) return false;
+ if(!$obj || !is_array($obj))
+ {
+ return false;
+ }
- if($modified_time > 0 && $modified_time > $obj[0]) {
+ if($modified_time > 0 && $modified_time > $obj[0])
+ {
$this->_delete($_key);
return false;
}
@@ -152,7 +181,8 @@ class CacheMemcache extends CacheBase {
* @param string $key The key associated with the item to delete.
* @return void
*/
- function delete($key) {
+ function delete($key)
+ {
$_key = $this->getKey($key);
$this->_delete($_key);
}
@@ -164,7 +194,8 @@ class CacheMemcache extends CacheBase {
* @param string $_key The key associated with the item to delete.
* @return void
*/
- function _delete($_key) {
+ function _delete($_key)
+ {
$this->Memcache->delete($_key);
}
@@ -177,10 +208,11 @@ class CacheMemcache extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
- function truncate() {
+ function truncate()
+ {
return $this->Memcache->flush();
}
-}
+}
/* End of file CacheMemcache.class.php */
/* Location: ./classes/cache/CacheMemcache.class.php */
diff --git a/classes/cache/CacheWincache.class.php b/classes/cache/CacheWincache.class.php
index 248e98932..3b86815ee 100644
--- a/classes/cache/CacheWincache.class.php
+++ b/classes/cache/CacheWincache.class.php
@@ -1,12 +1,15 @@
valid_time;
- return wincache_ucache_set(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
+ function put($key, $buff, $valid_time = 0)
+ {
+ if($valid_time == 0)
+ {
+ $valid_time = $this->valid_time;
+ }
+ return wincache_ucache_set(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
}
/**
@@ -64,20 +76,25 @@ class CacheWincache extends CacheBase {
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, the data is invalid.
+ * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid.
*/
- function isValid($key, $modified_time = 0) {
- $_key = md5(_XE_PATH_.$key);
+ function isValid($key, $modified_time = 0)
+ {
+ $_key = md5(_XE_PATH_ . $key);
$obj = wincache_ucache_get($_key, $success);
- if(!$success || !is_array($obj)) return false;
+ if(!$success || !is_array($obj))
+ {
+ return false;
+ }
unset($obj[1]);
- if($modified_time > 0 && $modified_time > $obj[0]) {
+ if($modified_time > 0 && $modified_time > $obj[0])
+ {
$this->_delete($_key);
return false;
}
-
+
return true;
}
@@ -86,15 +103,20 @@ class CacheWincache extends CacheBase {
*
* @param string $key The $key that was used to store the variable in the cache.
* @param int $modified_time Unix time of data modified.
- * If stored time is older then modified time, return false.
+ * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/
- function get($key, $modified_time = 0) {
- $_key = md5(_XE_PATH_.$key);
+ function get($key, $modified_time = 0)
+ {
+ $_key = md5(_XE_PATH_ . $key);
$obj = wincache_ucache_get($_key, $success);
- if(!$success || !is_array($obj)) return false;
+ if(!$success || !is_array($obj))
+ {
+ return false;
+ }
- if($modified_time > 0 && $modified_time > $obj[0]) {
+ if($modified_time > 0 && $modified_time > $obj[0])
+ {
$this->_delete($_key);
return false;
}
@@ -108,7 +130,8 @@ class CacheWincache extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
- function _delete($_key) {
+ function _delete($_key)
+ {
wincache_ucache_delete($_key);
}
@@ -118,8 +141,9 @@ class CacheWincache extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
- function delete($key) {
- $_key = md5(_XE_PATH_.$key);
+ function delete($key)
+ {
+ $_key = md5(_XE_PATH_ . $key);
$this->_delete($_key);
}
@@ -128,10 +152,11 @@ class CacheWincache extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
- function truncate() {
+ function truncate()
+ {
return wincache_ucache_clear();
}
-}
+}
/* End of file CacheWincache.class.php */
/* Location: ./classes/cache/CacheWincache.class.php */
diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php
index 90a7b4f87..6fc4792dc 100644
--- a/classes/context/Context.class.php
+++ b/classes/context/Context.class.php
@@ -1,7 +1,8 @@
..
* @var string
*/
var $html_header = NULL;
+
/**
* class names of
* @var array
*/
- var $body_class = array();
+ var $body_class = array();
+
/**
* codes after
* @var string
*/
var $body_header = NULL;
+
/**
* class names before
* @var string
*/
var $html_footer = NULL;
+
/**
- * path of Xpress Engine
+ * path of Xpress Engine
* @var string
*/
var $path = '';
-
// language information - it is changed by HTTP_USER_AGENT or user's cookie
/**
- * language type
+ * language type
* @var string
*/
var $lang_type = '';
+
/**
* contains language-specific data
- * @var object
+ * @var object
*/
var $lang = NULL;
+
/**
* list of loaded languages (to avoid re-loading them)
* @var array
*/
var $loaded_lang_files = array();
+
/**
* site's browser title
* @var string
*/
var $site_title = '';
+
/**
* variables from GET or form submit
* @var mixed
*/
var $get_vars = NULL;
+
/**
- * Checks uploaded
+ * Checks uploaded
* @var bool true if attached file exists
*/
var $is_uploaded = false;
@@ -133,19 +158,12 @@ class Context {
*
* @return object Instance
*/
- function &getInstance() {
+ function &getInstance()
+ {
static $theInstance = null;
- if(!$theInstance) $theInstance = new Context();
-
- // include ssl action cache file
- $theInstance->sslActionCacheFile = FileHandler::getRealPath($theInstance->sslActionCacheFile);
- if(is_readable($theInstance->sslActionCacheFile))
+ if(!$theInstance)
{
- require_once($theInstance->sslActionCacheFile);
- if(isset($sslActions))
- {
- $theInstance->ssl_actions = $sslActions;
- }
+ $theInstance = new Context();
}
return $theInstance;
@@ -159,6 +177,18 @@ class Context {
function Context()
{
$this->oFrontEndFileHandler = new FrontEndFileHandler();
+ $this->get_vars = new stdClass();
+
+ // include ssl action cache file
+ $this->sslActionCacheFile = FileHandler::getRealPath($this->sslActionCacheFile);
+ if(is_readable($this->sslActionCacheFile))
+ {
+ require_once($this->sslActionCacheFile);
+ if(isset($sslActions))
+ {
+ $this->ssl_actions = $sslActions;
+ }
+ }
}
/**
@@ -167,7 +197,8 @@ class Context {
* @see This function should be called only once
* @return void
*/
- function init() {
+ function init()
+ {
// set context variables in $GLOBALS (to use in display handler)
$this->context = &$GLOBALS['__Context__'];
$this->context->lang = &$GLOBALS['lang'];
@@ -183,115 +214,170 @@ class Context {
$this->loadDBInfo();
// If XE is installed, get virtual site information
- if(Context::isInstalled()) {
- $oModuleModel = &getModel('module');
+ if(Context::isInstalled())
+ {
+ $oModuleModel = getModel('module');
$site_module_info = $oModuleModel->getDefaultMid();
+
+ if(!isset($site_module_info))
+ {
+ $site_module_info = new stdClass();
+ }
+
// if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config
- if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) {
+ if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url)
+ {
$site_module_info->domain = $this->db_info->default_url;
}
$this->set('site_module_info', $site_module_info);
- if($site_module_info->site_srl && isSiteID($site_module_info->domain)) $this->set('vid', $site_module_info->domain, true);
+ if($site_module_info->site_srl && isSiteID($site_module_info->domain))
+ {
+ $this->set('vid', $site_module_info->domain, true);
+ }
+
+ if(!isset($this->db_info))
+ {
+ $this->db_info = new stdClass();
+ }
$this->db_info->lang_type = $site_module_info->default_language;
- if(!$this->db_info->lang_type) $this->db_info->lang_type = 'en';
- if(!$this->db_info->use_db_session) $this->db_info->use_db_session = 'N';
+ if(!$this->db_info->lang_type)
+ {
+ $this->db_info->lang_type = 'en';
+ }
+ if(!$this->db_info->use_db_session)
+ {
+ $this->db_info->use_db_session = 'N';
+ }
}
// Load Language File
$lang_supported = $this->loadLangSelected();
// Retrieve language type set in user's cookie
- if($this->get('l')) {
+ if($this->get('l'))
+ {
$this->lang_type = $this->get('l');
- if($_COOKIE['lang_type'] != $this->lang_type) {
- setcookie('lang_type', $this->lang_type, time()+3600*24*1000, '/');
+ if($_COOKIE['lang_type'] != $this->lang_type)
+ {
+ setcookie('lang_type', $this->lang_type, time() + 3600 * 24 * 1000, '/');
}
- } elseif($_COOKIE['lang_type']) {
+ }
+ elseif($_COOKIE['lang_type'])
+ {
$this->lang_type = $_COOKIE['lang_type'];
}
// If it's not exists, follow default language type set in db_info
- if(!$this->lang_type) $this->lang_type = $this->db_info->lang_type;
+ if(!$this->lang_type)
+ {
+ $this->lang_type = $this->db_info->lang_type;
+ }
// if still lang_type has not been set or has not-supported type , set as English.
- if(!$this->lang_type) $this->lang_type = 'en';
- if(is_array($lang_supported)&&!isset($lang_supported[$this->lang_type])) $this->lang_type = 'en';
+ if(!$this->lang_type)
+ {
+ $this->lang_type = 'en';
+ }
+ if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type]))
+ {
+ $this->lang_type = 'en';
+ }
$this->set('lang_supported', $lang_supported);
$this->setLangType($this->lang_type);
// load module module's language file according to language setting
- $this->loadLang(_XE_PATH_.'modules/module/lang');
+ $this->loadLang(_XE_PATH_ . 'modules/module/lang');
// set session handler
- if(Context::isInstalled() && $this->db_info->use_db_session == 'Y') {
- $oSessionModel = &getModel('session');
- $oSessionController = &getController('session');
+ if(Context::isInstalled() && $this->db_info->use_db_session == 'Y')
+ {
+ $oSessionModel = getModel('session');
+ $oSessionController = getController('session');
session_set_save_handler(
- array(&$oSessionController, 'open'),
- array(&$oSessionController, 'close'),
- array(&$oSessionModel, 'read'),
- array(&$oSessionController, 'write'),
- array(&$oSessionController, 'destroy'),
- array(&$oSessionController, 'gc')
+ array(&$oSessionController, 'open'), array(&$oSessionController, 'close'), array(&$oSessionModel, 'read'), array(&$oSessionController, 'write'), array(&$oSessionController, 'destroy'), array(&$oSessionController, 'gc')
);
}
session_start();
- if($sess=$_POST[session_name()]) session_id($sess);
+ if($sess = $_POST[session_name()])
+ {
+ session_id($sess);
+ }
// set authentication information in Context and session
- if(Context::isInstalled()) {
- $oModuleModel = &getModel('module');
+ if(Context::isInstalled())
+ {
+ $oModuleModel = getModel('module');
$oModuleModel->loadModuleExtends();
- $oMemberModel = &getModel('member');
- $oMemberController = &getController('member');
+ $oMemberModel = getModel('member');
+ $oMemberController = getController('member');
if($oMemberController && $oMemberModel)
{
// if signed in, validate it.
- if($oMemberModel->isLogged()) {
+ if($oMemberModel->isLogged())
+ {
$oMemberController->setSessionInfo();
}
- elseif($_COOKIE['xeak']) { // check auto sign-in
+ // check auto sign-in
+ elseif($_COOKIE['xeak'])
+ {
$oMemberController->doAutologin();
}
- $this->set('is_logged', $oMemberModel->isLogged() );
- $this->set('logged_info', $oMemberModel->getLoggedInfo() );
+ $this->set('is_logged', $oMemberModel->isLogged());
+ $this->set('logged_info', $oMemberModel->getLoggedInfo());
}
}
// load common language file
$this->lang = &$GLOBALS['lang'];
- $this->loadLang(_XE_PATH_.'common/lang/');
+ $this->loadLang(_XE_PATH_ . 'common/lang/');
// check if using rewrite module
- if(file_exists(_XE_PATH_.'.htaccess')&&$this->db_info->use_rewrite == 'Y') $this->allow_rewrite = true;
- else $this->allow_rewrite = false;
+ if(file_exists(_XE_PATH_ . '.htaccess') && $this->db_info->use_rewrite == 'Y')
+ {
+ $this->allow_rewrite = true;
+ }
+ else
+ {
+ $this->allow_rewrite = false;
+ }
// set locations for javascript use
- if($_SERVER['REQUEST_METHOD'] == 'GET') {
- if($this->get_vars) {
- foreach($this->get_vars as $key=>$val) {
- if(is_array($val)&&count($val)) {
- foreach($val as $k => $v) {
- $url .= ($url?'&':'').$key.'['.$k.']='.urlencode($v);
+ if($_SERVER['REQUEST_METHOD'] == 'GET')
+ {
+ if($this->get_vars)
+ {
+ foreach($this->get_vars as $key => $val)
+ {
+ if(is_array($val) && count($val))
+ {
+ foreach($val as $k => $v)
+ {
+ $url .= ($url ? '&' : '') . $key . '[' . $k . ']=' . urlencode($v);
}
- } elseif ($val) {
- $url .= ($url?'&':'').$key.'='.urlencode($val);
+ }
+ elseif($val)
+ {
+ $url .= ($url ? '&' : '') . $key . '=' . urlencode($val);
}
}
- $this->set('current_url',sprintf('%s?%s', Context::getRequestUri(), $url));
- } else {
- $this->set('current_url',$this->getUrl());
+ $this->set('current_url', sprintf('%s?%s', Context::getRequestUri(), $url));
+ }
+ else
+ {
+ $this->set('current_url', $this->getUrl());
}
- } else {
- $this->set('current_url',Context::getRequestUri());
}
- $this->set('request_uri',Context::getRequestUri());
+ else
+ {
+ $this->set('current_url', Context::getRequestUri());
+ }
+ $this->set('request_uri', Context::getRequestUri());
}
/**
@@ -299,13 +385,20 @@ class Context {
*
* @return void
*/
- function close() {
+ function close()
+ {
// Session Close
- if(function_exists('session_write_close')) session_write_close();
+ if(function_exists('session_write_close'))
+ {
+ session_write_close();
+ }
// DB close
- $oDB = &DB::getInstance();
- if(is_object($oDB)&&method_exists($oDB, 'close')) $oDB->close();
+ $oDB = DB::getInstance();
+ if(is_object($oDB) && method_exists($oDB, 'close'))
+ {
+ $oDB->close();
+ }
}
/**
@@ -313,52 +406,76 @@ class Context {
*
* @return void
*/
- function loadDBInfo() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function loadDBInfo()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- if(!$self->isInstalled()) return;
+ if(!$self->isInstalled())
+ {
+ return;
+ }
$config_file = $self->getConfigFile();
- if(is_readable($config_file)) @include($config_file);
+ if(is_readable($config_file))
+ {
+ @include($config_file);
+ }
- // If master_db information does not exist, the config file needs to be updated
- if(!isset($db_info->master_db)) {
- $db_info->master_db = array();
- $db_info->master_db["db_type"] = $db_info->db_type; unset($db_info->db_type);
- $db_info->master_db["db_port"] = $db_info->db_port; unset($db_info->db_port);
- $db_info->master_db["db_hostname"] = $db_info->db_hostname; unset($db_info->db_hostname);
- $db_info->master_db["db_password"] = $db_info->db_password; unset($db_info->db_password);
- $db_info->master_db["db_database"] = $db_info->db_database; unset($db_info->db_database);
- $db_info->master_db["db_userid"] = $db_info->db_userid; unset($db_info->db_userid);
- $db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix; unset($db_info->db_table_prefix);
- if(substr($db_info->master_db["db_table_prefix"],-1)!='_') $db_info->master_db["db_table_prefix"] .= '_';
+ // If master_db information does not exist, the config file needs to be updated
+ if(!isset($db_info->master_db))
+ {
+ $db_info->master_db = array();
+ $db_info->master_db["db_type"] = $db_info->db_type;
+ unset($db_info->db_type);
+ $db_info->master_db["db_port"] = $db_info->db_port;
+ unset($db_info->db_port);
+ $db_info->master_db["db_hostname"] = $db_info->db_hostname;
+ unset($db_info->db_hostname);
+ $db_info->master_db["db_password"] = $db_info->db_password;
+ unset($db_info->db_password);
+ $db_info->master_db["db_database"] = $db_info->db_database;
+ unset($db_info->db_database);
+ $db_info->master_db["db_userid"] = $db_info->db_userid;
+ unset($db_info->db_userid);
+ $db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix;
+ unset($db_info->db_table_prefix);
+ if(substr($db_info->master_db["db_table_prefix"], -1) != '_')
+ {
+ $db_info->master_db["db_table_prefix"] .= '_';
+ }
- $slave_db = $db_info->master_db;
- $db_info->slave_db = array($slave_db);
-
- $self->setDBInfo($db_info);
+ $slave_db = $db_info->master_db;
+ $db_info->slave_db = array($slave_db);
- $oInstallController = &getController('install');
- $oInstallController->makeConfigFile();
- }
-
- if(!$db_info->use_prepared_statements)
+ $self->setDBInfo($db_info);
+
+ $oInstallController = getController('install');
+ $oInstallController->makeConfigFile();
+ }
+
+ if(!$db_info->use_prepared_statements)
{
$db_info->use_prepared_statements = 'Y';
}
-
- if(!$db_info->time_zone) $db_info->time_zone = date('O');
+
+ if(!$db_info->time_zone)
+ $db_info->time_zone = date('O');
$GLOBALS['_time_zone'] = $db_info->time_zone;
- if($db_info->qmail_compatibility != 'Y') $db_info->qmail_compatibility = 'N';
+ if($db_info->qmail_compatibility != 'Y')
+ $db_info->qmail_compatibility = 'N';
$GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
- if(!$db_info->use_db_session) $db_info->use_db_session = 'N';
- if(!$db_info->use_ssl) $db_info->use_ssl = 'none';
+ if(!$db_info->use_db_session)
+ $db_info->use_db_session = 'N';
+ if(!$db_info->use_ssl)
+ $db_info->use_ssl = 'none';
$this->set('_use_ssl', $db_info->use_ssl);
- if($db_info->http_port) $self->set('_http_port', $db_info->http_port);
- if($db_info->https_port) $self->set('_https_port', $db_info->https_port);
+ if($db_info->http_port)
+ $self->set('_http_port', $db_info->http_port);
+ if($db_info->https_port)
+ $self->set('_https_port', $db_info->https_port);
$self->setDBInfo($db_info);
}
@@ -368,8 +485,9 @@ class Context {
*
* @return string DB's db_type
*/
- function getDBType() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getDBType()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->db_info->master_db["db_type"];
}
@@ -379,8 +497,9 @@ class Context {
* @param object $db_info DB information
* @return void
*/
- function setDBInfo($db_info) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function setDBInfo($db_info)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->db_info = $db_info;
}
@@ -389,15 +508,16 @@ class Context {
*
* @return object DB information
*/
- function getDBInfo() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getDBInfo()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->db_info;
}
/**
* Return ssl status
*
- * @return object SSL status (Optional - none|always|optional)
+ * @return object SSL status (Optional - none|always|optional)
*/
function getSslStatus()
{
@@ -410,7 +530,8 @@ class Context {
*
* @return string Default URL
*/
- function getDefaultUrl() {
+ function getDefaultUrl()
+ {
$db_info = Context::getDBInfo();
return $db_info->default_url;
}
@@ -420,12 +541,15 @@ class Context {
*
* @return array Supported languages
*/
- function loadLangSupported() {
+ function loadLangSupported()
+ {
static $lang_supported = null;
- if(!$lang_supported) {
- $langs = file(_XE_PATH_.'common/lang/lang.info');
- foreach($langs as $val) {
- list($lang_prefix, $lang_text) = explode(',',$val);
+ if(!$lang_supported)
+ {
+ $langs = file(_XE_PATH_ . 'common/lang/lang.info');
+ foreach($langs as $val)
+ {
+ list($lang_prefix, $lang_text) = explode(',', $val);
$lang_text = trim($lang_text);
$lang_supported[$lang_prefix] = $lang_text;
}
@@ -438,24 +562,31 @@ class Context {
*
* @return array Selected languages
*/
- function loadLangSelected() {
+ function loadLangSelected()
+ {
static $lang_selected = null;
- if(!$lang_selected) {
- $orig_lang_file = _XE_PATH_.'common/lang/lang.info';
- $selected_lang_file = _XE_PATH_.'files/config/lang_selected.info';
- if(!FileHandler::hasContent($selected_lang_file)) {
- $old_selected_lang_file = _XE_PATH_.'files/cache/lang_selected.info';
+ if(!$lang_selected)
+ {
+ $orig_lang_file = _XE_PATH_ . 'common/lang/lang.info';
+ $selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info';
+ if(!FileHandler::hasContent($selected_lang_file))
+ {
+ $old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info';
FileHandler::moveFile($old_selected_lang_file, $selected_lang_file);
}
- if(!FileHandler::hasContent($selected_lang_file)) {
+ if(!FileHandler::hasContent($selected_lang_file))
+ {
$buff = FileHandler::readFile($orig_lang_file);
FileHandler::writeFile($selected_lang_file, $buff);
$lang_selected = Context::loadLangSupported();
- } else {
+ }
+ else
+ {
$langs = file($selected_lang_file);
- foreach($langs as $val) {
- list($lang_prefix, $lang_text) = explode(',',$val);
+ foreach($langs as $val)
+ {
+ list($lang_prefix, $lang_text) = explode(',', $val);
$lang_text = trim($lang_text);
$lang_selected[$lang_prefix] = $lang_text;
}
@@ -469,42 +600,62 @@ class Context {
*
* @return bool True : Module handling is necessary in the control path of current request , False : Otherwise
*/
- function checkSSO() {
+ function checkSSO()
+ {
// pass if it's not GET request or XE is not yet installed
- if($this->db_info->use_sso != 'Y' || isCrawler()) return true;
- $checkActList = array('rss'=>1, 'atom'=>1);
- if(Context::getRequestMethod()!='GET' || !Context::isInstalled() || isset($checkActList[Context::get('act')])) return true;
+ if($this->db_info->use_sso != 'Y' || isCrawler())
+ {
+ return true;
+ }
+ $checkActList = array('rss' => 1, 'atom' => 1);
+ if(Context::getRequestMethod() != 'GET' || !Context::isInstalled() || isset($checkActList[Context::get('act')]))
+ {
+ return true;
+ }
// pass if default URL is not set
$default_url = trim($this->db_info->default_url);
- if(!$default_url) return true;
- if(substr($default_url,-1)!='/') $default_url .= '/';
+ if(!$default_url)
+ {
+ return true;
+ }
+ if(substr($default_url, -1) != '/')
+ {
+ $default_url .= '/';
+ }
// for sites recieving SSO valdiation
- if($default_url == Context::getRequestUri()) {
- if(Context::get('default_url')) {
+ if($default_url == Context::getRequestUri())
+ {
+ if(Context::get('default_url'))
+ {
$url = base64_decode(Context::get('default_url'));
$url_info = parse_url($url);
- $url_info['query'].= ($url_info['query']?'&':'').'SSOID='.session_id();
- $redirect_url = sprintf('%s://%s%s%s?%s',$url_info['scheme'],$url_info['host'],$url_info['port']?':'.$url_info['port']:'',$url_info['path'], $url_info['query']);
- header('location:'.$redirect_url);
+ $url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id();
+ $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']);
+ header('location:' . $redirect_url);
return false;
}
- // for sites requesting SSO validation
- } else {
+ // for sites requesting SSO validation
+ }
+ else
+ {
// result handling : set session_name()
- if(Context::get('SSOID')) {
+ if(Context::get('SSOID'))
+ {
$session_name = Context::get('SSOID');
setcookie(session_name(), $session_name);
- $url = preg_replace('/([\?\&])$/','',str_replace('SSOID='.$session_name,'',Context::getRequestUrl()));
- header('location:'.$url);
+ $url = preg_replace('/([\?\&])$/', '', str_replace('SSOID=' . $session_name, '', Context::getRequestUrl()));
+ header('location:' . $url);
return false;
- // send SSO request
- } else if($_COOKIE['sso']!=md5(Context::getRequestUri()) && !Context::get('SSOID')) {
- setcookie('sso',md5(Context::getRequestUri()),0,'/');
+ // send SSO request
+ }
+ else if($_COOKIE['sso'] != md5(Context::getRequestUri()) && !Context::get('SSOID'))
+ {
+ setcookie('sso', md5(Context::getRequestUri()), 0, '/');
$url = sprintf("%s?default_url=%s", $default_url, base64_encode(Context::getRequestUrl()));
- header('location:'.$url);
+ header('location:' . $url);
return false;
}
}
@@ -517,9 +668,13 @@ class Context {
*
* @return bool True: FTP information is registered, False: otherwise
*/
- function isFTPRegisted() {
+ function isFTPRegisted()
+ {
$ftp_config_file = Context::getFTPConfigFile();
- if(file_exists($ftp_config_file)) return true;
+ if(file_exists($ftp_config_file))
+ {
+ return true;
+ }
return false;
}
@@ -528,9 +683,13 @@ class Context {
*
* @return object FTP information
*/
- function getFTPInfo() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- if(!$self->isFTPRegisted()) return null;
+ function getFTPInfo()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ if(!$self->isFTPRegisted())
+ {
+ return null;
+ }
$ftp_config_file = $self->getFTPConfigFile();
@include($ftp_config_file);
@@ -544,12 +703,22 @@ class Context {
* @param string $site_title Browser title to be added
* @return void
*/
- function addBrowserTitle($site_title) {
- if(!$site_title) return;
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function addBrowserTitle($site_title)
+ {
+ if(!$site_title)
+ {
+ return;
+ }
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- if($self->site_title) $self->site_title .= ' - '.$site_title;
- else $self->site_title = $site_title;
+ if($self->site_title)
+ {
+ $self->site_title .= ' - ' . $site_title;
+ }
+ else
+ {
+ $self->site_title = $site_title;
+ }
}
/**
@@ -558,9 +727,13 @@ class Context {
* @param string $site_title Browser title to be set
* @return void
*/
- function setBrowserTitle($site_title) {
- if(!$site_title) return;
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function setBrowserTitle($site_title)
+ {
+ if(!$site_title)
+ {
+ return;
+ }
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->site_title = $site_title;
}
@@ -569,19 +742,40 @@ class Context {
*
* @return string Browser title(htmlspecialchars applied)
*/
- function getBrowserTitle() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getBrowserTitle()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- $oModuleController = &getController('module');
+ $oModuleController = getController('module');
$oModuleController->replaceDefinedLangCode($self->site_title);
return htmlspecialchars($self->site_title);
}
+
+ /**
+ * Return layout's title
+ * @return string layout's title
+ */
+ public function getSiteTitle()
+ {
+ $oModuleModel = &getModel('module');
+ $moduleConfig = $oModuleModel->getModuleConfig('module');
+
+ if(isset($moduleConfig->siteTitle))
+ {
+ return $moduleConfig->siteTitle;
+ }
+ return '';
+ }
+
/**
* Get browser title
* @deprecated
*/
- function _getBrowserTitle() { return $this->getBrowserTitle(); }
+ function _getBrowserTitle()
+ {
+ return $this->getBrowserTitle();
+ }
/**
* Load language file according to language type
@@ -589,23 +783,42 @@ class Context {
* @param string $path Path of the language file
* @return void
*/
- function loadLang($path) {
+ function loadLang($path)
+ {
global $lang;
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- if(!is_object($lang)) $lang = new stdClass;
- if(!$self->lang_type) return;
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ if(!is_object($lang))
+ {
+ $lang = new stdClass;
+ }
+ if(!$self->lang_type)
+ {
+ return;
+ }
$filename = $self->_loadXmlLang($path);
- if(!$filename) $filename = $self->_loadPhpLang($path);
+ if(!$filename)
+ {
+ $filename = $self->_loadPhpLang($path);
+ }
- if(!is_array($self->loaded_lang_files)) $self->loaded_lang_files = array();
- if(in_array($filename, $self->loaded_lang_files)) return;
+ if(!is_array($self->loaded_lang_files))
+ {
+ $self->loaded_lang_files = array();
+ }
+ if(in_array($filename, $self->loaded_lang_files))
+ {
+ return;
+ }
- if ($filename && is_readable($filename)){
+ if($filename && is_readable($filename))
+ {
$self->loaded_lang_files[] = $filename;
@include($filename);
- }else{
+ }
+ else
+ {
$self->_evalxmlLang($path);
}
}
@@ -616,20 +829,28 @@ class Context {
* @param string Path of the language file
* @return void
*/
- function _evalxmlLang($path) {
+ function _evalxmlLang($path)
+ {
global $lang;
-
- $_path = 'eval://'.$path;
- if(in_array($_path, $this->loaded_lang_files)) return;
+ $_path = 'eval://' . $path;
- if(substr($path,-1)!='/') $path .= '/';
- $file = $path.'lang.xml';
+ if(in_array($_path, $this->loaded_lang_files))
+ {
+ return;
+ }
+
+ if(substr($path, -1) != '/')
+ {
+ $path .= '/';
+ }
+ $file = $path . 'lang.xml';
$oXmlLangParser = new XmlLangParser($file, $this->lang_type);
$content = $oXmlLangParser->getCompileContent();
- if ($content){
+ if($content)
+ {
$this->loaded_lang_files[] = $_path;
eval($content);
}
@@ -641,9 +862,13 @@ class Context {
* @param string $path Path of the language file
* @return string file name
*/
- function _loadXmlLang($path) {
- if(substr($path,-1)!='/') $path .= '/';
- $file = $path.'lang.xml';
+ function _loadXmlLang($path)
+ {
+ if(substr($path, -1) != '/')
+ {
+ $path .= '/';
+ }
+ $file = $path . 'lang.xml';
$oXmlLangParser = new XmlLangParser($file, $this->lang_type);
$file = $oXmlLangParser->compile();
@@ -657,17 +882,25 @@ class Context {
* @param string $path Path of the language file
* @return string file name
*/
- function _loadPhpLang($path) {
- if(substr($path,-1)!='/') $path .= '/';
- $path_tpl = $path.'%s.lang.php';
+ function _loadPhpLang($path)
+ {
+ if(substr($path, -1) != '/')
+ {
+ $path .= '/';
+ }
+ $path_tpl = $path . '%s.lang.php';
$file = sprintf($path_tpl, $this->lang_type);
- $langs = array('ko','en'); // this will be configurable.
- while(!is_readable($file) && $langs[0]) {
+ $langs = array('ko', 'en'); // this will be configurable.
+ while(!is_readable($file) && $langs[0])
+ {
$file = sprintf($path_tpl, array_shift($langs));
}
- if(!is_readable($file)) return false;
+ if(!is_readable($file))
+ {
+ return false;
+ }
return $file;
}
@@ -677,8 +910,9 @@ class Context {
* @param string $lang_type Language type.
* @return void
*/
- function setLangType($lang_type = 'ko') {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function setLangType($lang_type = 'ko')
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->lang_type = $lang_type;
$self->set('lang_type', $lang_type);
@@ -691,8 +925,9 @@ class Context {
*
* @return string Language type
*/
- function getLangType() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getLangType()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->lang_type;
}
@@ -702,9 +937,16 @@ class Context {
* @param string $code Language variable name
* @return string If string for the code exists returns it, otherwise returns original code
*/
- function getLang($code) {
- if(!$code) return;
- if($GLOBALS['lang']->{$code}) return $GLOBALS['lang']->{$code};
+ function getLang($code)
+ {
+ if(!$code)
+ {
+ return;
+ }
+ if($GLOBALS['lang']->{$code})
+ {
+ return $GLOBALS['lang']->{$code};
+ }
return $code;
}
@@ -715,7 +957,12 @@ class Context {
* @param string $val `$code`s value
* @return void
*/
- function setLang($code, $val) {
+ function setLang($code, $val)
+ {
+ if(!isset($GLOBALS['lang']))
+ {
+ $GLOBALS['lang'] = new stdClass();
+ }
$GLOBALS['lang']->{$code} = $val;
}
@@ -725,7 +972,8 @@ class Context {
* @param object $source_obj Conatins strings to convert
* @return object converted object
*/
- function convertEncoding($source_obj) {
+ function convertEncoding($source_obj)
+ {
$charset_list = array(
'UTF-8', 'EUC-KR', 'CP949', 'ISO8859-1', 'EUC-JP', 'SHIFT_JIS', 'CP932',
'EUC-CN', 'HZ', 'GBK', 'GB18030', 'EUC-TW', 'BIG5', 'CP950', 'BIG5-HKSCS',
@@ -737,27 +985,31 @@ class Context {
'CP1257', 'CP850', 'CP866',
);
- $obj = clone($source_obj);
+ $obj = clone $source_obj;
- foreach($charset_list as $charset)
+ foreach($charset_list as $charset)
{
array_walk($obj,'Context::checkConvertFlag',$charset);
$flag = Context::checkConvertFlag($flag = true);
if($flag)
{
- if($charset == 'UTF-8') return $obj;
+ if($charset == 'UTF-8')
+ {
+ return $obj;
+ }
array_walk($obj,'Context::doConvertEncoding',$charset);
return $obj;
}
}
return $obj;
}
+
/**
- * Check flag
+ * Check flag
*
* @param mixed $val
* @param string $key
- * @param mixed $charset charset
+ * @param mixed $charset charset
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
* @return void
*/
@@ -780,7 +1032,7 @@ class Context {
}
/**
- * Convert array type variables into UTF-8
+ * Convert array type variables into UTF-8
*
* @param mixed $val
* @param string $key
@@ -803,7 +1055,9 @@ class Context {
* @param string $str String to convert
* @return string converted string
*/
- function convertEncodingStr($str) {
+ function convertEncodingStr($str)
+ {
+ $obj = new stdClass();
$obj->str = $str;
$obj = Context::convertEncoding($obj);
return $obj->str;
@@ -815,10 +1069,11 @@ class Context {
* @param string $method Response method. [HTML|XMLRPC|JSON]
* @return void
*/
- function setResponseMethod($method='HTML') {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function setResponseMethod($method = 'HTML')
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- $methods = array('HTML'=>1, 'XMLRPC'=>1, 'JSON'=>1);
+ $methods = array('HTML' => 1, 'XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
$self->response_method = isset($methods[$method]) ? $method : 'HTML';
}
@@ -827,13 +1082,17 @@ class Context {
*
* @return string Response method. If it's not set, returns request method.
*/
- function getResponseMethod() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getResponseMethod()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- if($self->response_method) return $self->response_method;
+ if($self->response_method)
+ {
+ return $self->response_method;
+ }
- $method = $self->getRequestMethod();
- $methods = array('HTML'=>1, 'XMLRPC'=>1, 'JSON'=>1);
+ $method = $self->getRequestMethod();
+ $methods = array('HTML' => 1, 'XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
return isset($methods[$method]) ? $method : 'HTML';
}
@@ -844,13 +1103,17 @@ class Context {
* @param string $type Request method. (Optional - GET|POST|XMLRPC|JSON)
* @return void
*/
- function setRequestMethod($type='') {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function setRequestMethod($type = '')
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- ($type && $self->request_method=$type) or
- (strpos($_SERVER['CONTENT_TYPE'],'json') && $self->request_method='JSON') or
- ($GLOBALS['HTTP_RAW_POST_DATA'] && $self->request_method='XMLRPC') or
- ($self->request_method = $_SERVER['REQUEST_METHOD']);
+ $self->js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback'];
+
+ ($type && $self->request_method = $type) or
+ (strpos($_SERVER['CONTENT_TYPE'], 'json') && $self->request_method = 'JSON') or
+ ($GLOBALS['HTTP_RAW_POST_DATA'] && $self->request_method = 'XMLRPC') or
+ ($self->js_callback_func && $self->request_method = 'JS_CALLBACK') or
+ ($self->request_method = $_SERVER['REQUEST_METHOD']);
}
/**
@@ -858,16 +1121,37 @@ class Context {
*
* @return void
*/
- function _setRequestArgument() {
- if(!count($_REQUEST)) return;
+ function _setRequestArgument()
+ {
+ if(!count($_REQUEST))
+ {
+ return;
+ }
- foreach($_REQUEST as $key => $val) {
- if($val === '' || Context::get($key)) continue;
+ foreach($_REQUEST as $key => $val)
+ {
+ if($val === '' || Context::get($key))
+ {
+ continue;
+ }
$val = $this->_filterRequestVar($key, $val);
- if($this->getRequestMethod()=='GET'&&isset($_GET[$key])) $set_to_vars = true;
- elseif($this->getRequestMethod()=='POST'&&isset($_POST[$key])) $set_to_vars = true;
- else $set_to_vars = false;
+ if($this->getRequestMethod() == 'GET' && isset($_GET[$key]))
+ {
+ $set_to_vars = true;
+ }
+ elseif($this->getRequestMethod() == 'POST' && isset($_POST[$key]))
+ {
+ $set_to_vars = true;
+ }
+ elseif($this->getRequestMethod() == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
+ {
+ $set_to_vars = true;
+ }
+ else
+ {
+ $set_to_vars = false;
+ }
if($set_to_vars)
{
@@ -906,14 +1190,19 @@ class Context {
*
* @return void
*/
- function _setJSONRequestArgument() {
- if($this->getRequestMethod() != 'JSON') return;
+ function _setJSONRequestArgument()
+ {
+ if($this->getRequestMethod() != 'JSON')
+ {
+ return;
+ }
$params = array();
- parse_str($GLOBALS['HTTP_RAW_POST_DATA'],$params);
+ parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
- foreach($params as $key => $val) {
- $val = $this->_filterRequestVar($key, $val,0);
+ foreach($params as $key => $val)
+ {
+ $val = $this->_filterRequestVar($key, $val, 1);
$this->set($key, $val, true);
}
}
@@ -923,8 +1212,12 @@ class Context {
*
* @return void
*/
- function _setXmlRpcArgument() {
- if($this->getRequestMethod() != 'XMLRPC') return;
+ function _setXmlRpcArgument()
+ {
+ if($this->getRequestMethod() != 'XMLRPC')
+ {
+ return;
+ }
$oXml = new XmlParser();
$xml_obj = $oXml->parse();
@@ -932,9 +1225,13 @@ class Context {
unset($params->node_name);
unset($params->attrs);
- if(!count($params)) return;
- foreach($params as $key => $obj) {
- $val = $this->_filterRequestVar($key, $obj->body,0);
+ if(!count($params))
+ {
+ return;
+ }
+ foreach($params as $key => $obj)
+ {
+ $val = $this->_filterRequestVar($key, $obj->body, 0);
$this->set($key, $val, true);
}
}
@@ -948,7 +1245,8 @@ class Context {
* @param string $do_stripslashes Whether to strip slashes
* @return mixed filtered value. Type are string or array
*/
- function _filterRequestVar($key, $val, $do_stripslashes = 1) {
+ function _filterRequestVar($key, $val, $do_stripslashes = 1)
+ {
$isArray = TRUE;
if(!is_array($val))
{
@@ -960,7 +1258,7 @@ class Context {
{
if($key === 'page' || $key === 'cpage' || substr($key, -3) === 'srl')
{
- $val[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int)$v : $v;
+ $val[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v;
}
elseif($key === 'mid' || $key === 'vid' || $key === 'search_keyword')
{
@@ -973,7 +1271,10 @@ class Context {
$v = stripslashes($v);
}
- if (is_string($v)) $val[$k] = trim($v);
+ if(!is_array($v))
+ {
+ $val[$k] = trim($v);
+ }
}
}
@@ -992,8 +1293,9 @@ class Context {
*
* @return bool True: exists, False: otherwise
*/
- function isUploaded() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function isUploaded()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->is_uploaded;
}
@@ -1002,26 +1304,45 @@ class Context {
*
* @return void
*/
- function _setUploadedArgument() {
- if($this->getRequestMethod() != 'POST') return;
- if(!preg_match('/multipart\/form-data/i',$_SERVER['CONTENT_TYPE'])) return;
- if(!$_FILES) return;
+ function _setUploadedArgument()
+ {
+ if($_SERVER['REQUEST_METHOD'] != 'POST')
+ {
+ return;
+ }
+ if(!preg_match('/multipart\/form-data/i', $_SERVER['CONTENT_TYPE']))
+ {
+ return;
+ }
+ if(!$_FILES)
+ {
+ return;
+ }
- foreach($_FILES as $key => $val) {
+ foreach($_FILES as $key => $val)
+ {
$tmp_name = $val['tmp_name'];
- if(!is_array($tmp_name)){
- if(!$tmp_name || !is_uploaded_file($tmp_name)) continue;
+ if(!is_array($tmp_name))
+ {
+ if(!$tmp_name || !is_uploaded_file($tmp_name))
+ {
+ continue;
+ }
$val['name'] = htmlspecialchars($val['name']);
$this->set($key, $val, true);
$this->is_uploaded = true;
- }else {
- for($i=0;$i< count($tmp_name);$i++){
- if($val['size'][$i] > 0){
- $file['name']=$val['name'][$i];
- $file['type']=$val['type'][$i];
- $file['tmp_name']=$val['tmp_name'][$i];
- $file['error']=$val['error'][$i];
- $file['size']=$val['size'][$i];
+ }
+ else
+ {
+ for($i = 0; $i < count($tmp_name); $i++)
+ {
+ if($val['size'][$i] > 0)
+ {
+ $file['name'] = $val['name'][$i];
+ $file['type'] = $val['type'][$i];
+ $file['tmp_name'] = $val['tmp_name'][$i];
+ $file['error'] = $val['error'][$i];
+ $file['size'] = $val['size'][$i];
$files[] = $file;
}
}
@@ -1034,8 +1355,9 @@ class Context {
* Return request method
* @return string Request method type. (Optional - GET|POST|XMLRPC|JSON)
*/
- function getRequestMethod() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getRequestMethod()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->request_method;
}
@@ -1043,9 +1365,11 @@ class Context {
* Return request URL
* @return string request URL
*/
- function getRequestUrl() {
+ function getRequestUrl()
+ {
static $url = null;
- if(is_null($url)) {
+ if(is_null($url))
+ {
$url = Context::getRequestUri();
if(count($_GET))
{
@@ -1059,6 +1383,16 @@ class Context {
return $url;
}
+ /**
+ * Return js callback func.
+ * @return string callback func.
+ */
+ function getJSCallbackFunc()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ return $self->js_callback_func;
+ }
+
/**
* Make URL with args_list upon request URL
*
@@ -1069,59 +1403,89 @@ class Context {
* @param bool $autoEncode If true, url encode automatically, detailed. Use this option, $encode value should be true
* @return string URL
*/
- function getUrl($num_args=0, $args_list=array(), $domain = null, $encode = true, $autoEncode = false) {
+ function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = true, $autoEncode = false)
+ {
static $site_module_info = null;
static $current_info = null;
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
// retrieve virtual site information
- if(is_null($site_module_info)) $site_module_info = Context::get('site_module_info');
+ if(is_null($site_module_info))
+ {
+ $site_module_info = Context::get('site_module_info');
+ }
// If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid)
- if($domain && isSiteID($domain)) {
+ if($domain && isSiteID($domain))
+ {
$vid = $domain;
$domain = '';
}
// If $domain, $vid are not set, use current site information
- if(!$domain && !$vid) {
- if($site_module_info->domain && isSiteID($site_module_info->domain)) $vid = $site_module_info->domain;
- else $domain = $site_module_info->domain;
+ if(!$domain && !$vid)
+ {
+ if($site_module_info->domain && isSiteID($site_module_info->domain))
+ {
+ $vid = $site_module_info->domain;
+ }
+ else
+ {
+ $domain = $site_module_info->domain;
+ }
}
// if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain.
- if($domain) {
+ if($domain)
+ {
$domain_info = parse_url($domain);
- if(is_null($current_info)) $current_info = parse_url(($_SERVER['HTTPS']=='on'?'https':'http').'://'.$_SERVER['HTTP_HOST'].getScriptPath());
- if($domain_info['host'].$domain_info['path']==$current_info['host'].$current_info['path']) {
+ if(is_null($current_info))
+ {
+ $current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . getScriptPath());
+ }
+ if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
+ {
unset($domain);
- } else {
- $domain = preg_replace('/^(http|https):\/\//i','', trim($domain));
- if(substr($domain,-1) != '/') $domain .= '/';
+ }
+ else
+ {
+ $domain = preg_replace('/^(http|https):\/\//i', '', trim($domain));
+ if(substr($domain, -1) != '/')
+ {
+ $domain .= '/';
+ }
}
}
$get_vars = null;
// If there is no GET variables or first argument is '' to reset variables
- if(!$self->get_vars || $args_list[0]=='') {
+ if(!$self->get_vars || $args_list[0] == '')
+ {
// rearrange args_list
- if(is_array($args_list) && $args_list[0]=='') array_shift($args_list);
- } else {
+ if(is_array($args_list) && $args_list[0] == '')
+ {
+ array_shift($args_list);
+ }
+ }
+ else
+ {
// Otherwise, make GET variables into array
$get_vars = get_object_vars($self->get_vars);
}
// arrange args_list
- for($i=0,$c=count($args_list);$i<$c;$i=$i+2) {
+ for($i = 0, $c = count($args_list); $i < $c; $i = $i + 2)
+ {
$key = $args_list[$i];
- $val = trim($args_list[$i+1]);
+ $val = trim($args_list[$i + 1]);
// If value is not set, remove the key
- if(!isset($val) || !strlen($val)) {
- unset($get_vars[$key]);
- continue;
+ if(!isset($val) || !strlen($val))
+ {
+ unset($get_vars[$key]);
+ continue;
}
// set new variables
$get_vars[$key] = $val;
@@ -1129,24 +1493,35 @@ class Context {
// remove vid, rnd
unset($get_vars['rnd']);
- if($vid) $get_vars['vid'] = $vid;
- else unset($get_vars['vid']);
+ if($vid)
+ {
+ $get_vars['vid'] = $vid;
+ }
+ else
+ {
+ unset($get_vars['vid']);
+ }
// for compatibility to lower versions
$act = $get_vars['act'];
$act_alias = array(
- 'dispMemberFriend'=>'dispCommunicationFriend',
- 'dispMemberMessages'=>'dispCommunicationMessages',
- 'dispDocumentAdminManageDocument'=>'dispDocumentManageDocument',
- 'dispModuleAdminSelectList'=>'dispModuleSelectList'
+ 'dispMemberFriend' => 'dispCommunicationFriend',
+ 'dispMemberMessages' => 'dispCommunicationMessages',
+ 'dispDocumentAdminManageDocument' => 'dispDocumentManageDocument',
+ 'dispModuleAdminSelectList' => 'dispModuleSelectList'
);
- if($act_alias[$act]) $get_vars['act'] = $act_alias[$act];
+ if($act_alias[$act])
+ {
+ $get_vars['act'] = $act_alias[$act];
+ }
// organize URL
$query = '';
- if(count($get_vars)) {
+ if(count($get_vars))
+ {
// if using rewrite mod
- if($self->allow_rewrite) {
+ if($self->allow_rewrite)
+ {
$var_keys = array_keys($get_vars);
sort($var_keys);
@@ -1158,85 +1533,117 @@ class Context {
$key = $get_vars['key'];
$srl = $get_vars['document_srl'];
- $tmpArray = array('rss'=>1, 'atom'=>1, 'api'=>1);
+ $tmpArray = array('rss' => 1, 'atom' => 1, 'api' => 1);
$is_feed = isset($tmpArray[$act]);
$target_map = array(
- 'vid'=>$vid,
- 'mid'=>$mid,
- 'mid.vid'=>"$vid/$mid",
-
- 'entry.mid' =>"$mid/entry/".$get_vars['entry'],
- 'entry.mid.vid'=>"$vid/$mid/entry/".$get_vars['entry'],
-
- 'document_srl'=>$srl,
- 'document_srl.mid'=>"$mid/$srl",
- 'document_srl.vid'=>"$vid/$srl",
- 'document_srl.mid.vid'=>"$vid/$mid/$srl",
-
- 'act.mid' =>$is_feed?"$mid/$act":'',
- 'act.mid.vid'=>$is_feed?"$vid/$mid/$act":'',
- 'act.document_srl.key' =>($act=='trackback')?"$srl/$key/$act":'',
- 'act.document_srl.key.mid'=>($act=='trackback')?"$mid/$srl/$key/$act":'',
- 'act.document_srl.key.vid'=>($act=='trackback')?"$vid/$srl/$key/$act":'',
- 'act.document_srl.key.mid.vid'=>($act=='trackback')?"$vid/$mid/$srl/$key/$act":''
+ 'vid' => $vid,
+ 'mid' => $mid,
+ 'mid.vid' => "$vid/$mid",
+ 'entry.mid' => "$mid/entry/" . $get_vars['entry'],
+ 'entry.mid.vid' => "$vid/$mid/entry/" . $get_vars['entry'],
+ 'document_srl' => $srl,
+ 'document_srl.mid' => "$mid/$srl",
+ 'document_srl.vid' => "$vid/$srl",
+ 'document_srl.mid.vid' => "$vid/$mid/$srl",
+ 'act.mid' => $is_feed ? "$mid/$act" : '',
+ 'act.mid.vid' => $is_feed ? "$vid/$mid/$act" : '',
+ 'act.document_srl.key' => ($act == 'trackback') ? "$srl/$key/$act" : '',
+ 'act.document_srl.key.mid' => ($act == 'trackback') ? "$mid/$srl/$key/$act" : '',
+ 'act.document_srl.key.vid' => ($act == 'trackback') ? "$vid/$srl/$key/$act" : '',
+ 'act.document_srl.key.mid.vid' => ($act == 'trackback') ? "$vid/$mid/$srl/$key/$act" : ''
);
- $query = $target_map[$target];
+ $query = $target_map[$target];
}
- if(!$query) {
+ if(!$query)
+ {
$queries = array();
- foreach($get_vars as $key => $val) {
- if(is_array($val) && count($val)) {
- foreach($val as $k => $v) $queries[] = $key.'['.$k.']='.urlencode($v);
- } else {
- $queries[] = $key.'='.@urlencode($val);
+ foreach($get_vars as $key => $val)
+ {
+ if(is_array($val) && count($val))
+ {
+ foreach($val as $k => $v)
+ {
+ $queries[] = $key . '[' . $k . ']=' . urlencode($v);
+ }
+ }
+ else
+ {
+ $queries[] = $key . '=' . @urlencode($val);
}
}
- if(count($queries)) $query = 'index.php?'.implode('&', $queries);
+ if(count($queries))
+ {
+ $query = 'index.php?' . implode('&', $queries);
+ }
}
}
// If using SSL always
$_use_ssl = $self->get('_use_ssl');
- if($_use_ssl == 'always') {
- $query = $self->getRequestUri(ENFORCE_SSL, $domain).$query;
- // optional SSL use
- } elseif($_use_ssl == 'optional') {
+ if($_use_ssl == 'always')
+ {
+ $query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
+ // optional SSL use
+ }
+ elseif($_use_ssl == 'optional')
+ {
$ssl_mode = RELEASE_SSL;
- if($get_vars['act'] && $self->isExistsSSLAction($get_vars['act'])) $ssl_mode = ENFORCE_SSL;
- $query = $self->getRequestUri($ssl_mode, $domain).$query;
- // no SSL
- } else {
+ if($get_vars['act'] && $self->isExistsSSLAction($get_vars['act']))
+ {
+ $ssl_mode = ENFORCE_SSL;
+ }
+ $query = $self->getRequestUri($ssl_mode, $domain) . $query;
+ // no SSL
+ }
+ else
+ {
// currently on SSL but target is not based on SSL
- if($_SERVER['HTTPS']=='on' ) $query = $self->getRequestUri(ENFORCE_SSL, $domain).$query;
+ if($_SERVER['HTTPS'] == 'on')
+ {
+ $query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
+ }
// if $domain is set
- else if($domain) $query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain).$query;
+ else if($domain)
+ {
+ $query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query;
+ }
- else $query = getScriptPath().$query;
+ else
+ {
+ $query = getScriptPath() . $query;
+ }
}
- if ($encode){
- if($autoEncode){
+ if($encode)
+ {
+ if($autoEncode)
+ {
$parsedUrl = parse_url($query);
parse_str($parsedUrl['query'], $output);
$encode_queries = array();
- foreach($output as $key=>$value){
- if (preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value))){
+ foreach($output as $key => $value)
+ {
+ if(preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value)))
+ {
$value = urlencode(htmlspecialchars_decode(urldecode($value)));
}
- $encode_queries[] = $key.'='.$value;
+ $encode_queries[] = $key . '=' . $value;
}
$encode_query = implode('&', $encode_queries);
- return htmlspecialchars($parsedUrl['path'].'?'.$encode_query);
+ return htmlspecialchars($parsedUrl['path'] . '?' . $encode_query);
}
- else{
+ else
+ {
return htmlspecialchars($query);
}
- }else{
- return $query;
+ }
+ else
+ {
+ return $query;
}
}
@@ -1247,51 +1654,93 @@ class Context {
* @param string $domain Domain
* @retrun string converted URL
*/
- function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null) {
+ function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null)
+ {
static $url = array();
// HTTP Request가 아니면 패스
- if(!isset($_SERVER['SERVER_PROTOCOL'])) return ;
- if(Context::get('_use_ssl') == 'always') $ssl_mode = ENFORCE_SSL;
-
- if($domain) $domain_key = md5($domain);
- else $domain_key = 'default';
-
- if(isset($url[$ssl_mode][$domain_key])) return $url[$ssl_mode][$domain_key];
-
- $current_use_ssl = $_SERVER['HTTPS']=='on' ? true : false;
-
- switch($ssl_mode) {
- case FOLLOW_REQUEST_SSL: $use_ssl = $current_use_ssl; break;
- case ENFORCE_SSL: $use_ssl = true; break;
- case RELEASE_SSL: $use_ssl = false; break;
+ if(!isset($_SERVER['SERVER_PROTOCOL']))
+ {
+ return;
}
- if($domain) {
+ if(Context::get('_use_ssl') == 'always')
+ {
+ $ssl_mode = ENFORCE_SSL;
+ }
+
+ if($domain)
+ {
+ $domain_key = md5($domain);
+ }
+ else
+ {
+ $domain_key = 'default';
+ }
+
+ if(isset($url[$ssl_mode][$domain_key]))
+ {
+ return $url[$ssl_mode][$domain_key];
+ }
+
+ $current_use_ssl = $_SERVER['HTTPS'] == 'on' ? true : false;
+
+ switch($ssl_mode)
+ {
+ case FOLLOW_REQUEST_SSL: $use_ssl = $current_use_ssl;
+ break;
+ case ENFORCE_SSL: $use_ssl = true;
+ break;
+ case RELEASE_SSL: $use_ssl = false;
+ break;
+ }
+
+ if($domain)
+ {
$target_url = trim($domain);
- if(substr($target_url,-1) != '/') $target_url.= '/';
- } else {
- $target_url= $_SERVER['HTTP_HOST'].getScriptPath();
+ if(substr($target_url, -1) != '/')
+ {
+ $target_url.= '/';
+ }
+ }
+ else
+ {
+ $target_url = $_SERVER['HTTP_HOST'] . getScriptPath();
}
- $url_info = parse_url('http://'.$target_url);
+ $url_info = parse_url('http://' . $target_url);
if($current_use_ssl != $use_ssl)
{
unset($url_info['port']);
}
- if($use_ssl) {
+ if($use_ssl)
+ {
$port = Context::get('_https_port');
- if($port && $port != 443) $url_info['port'] = $port;
- elseif($url_info['port']==443) unset($url_info['port']);
- } else {
+ if($port && $port != 443)
+ {
+ $url_info['port'] = $port;
+ }
+ elseif($url_info['port'] == 443)
+ {
+ unset($url_info['port']);
+ }
+ }
+ else
+ {
$port = Context::get('_http_port');
- if($port && $port != 80) $url_info['port'] = $port;
- elseif($url_info['port']==80) unset($url_info['port']);
+ if($port && $port != 80)
+ {
+ $url_info['port'] = $port;
+ }
+ elseif($url_info['port'] == 80)
+ {
+ unset($url_info['port']);
+ }
}
- $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s',$use_ssl?'https':$url_info['scheme'], $url_info['host'], $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$url_info['path']);
+ $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':' . $url_info['port'] : '', $url_info['path']);
return $url[$ssl_mode][$domain_key];
}
@@ -1304,16 +1753,23 @@ class Context {
* @param mixed $set_to_get_vars If not false, Set to get vars.
* @return void
*/
- function set($key, $val, $set_to_get_vars=0) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function set($key, $val, $set_to_get_vars = 0)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->context->{$key} = $val;
- if($set_to_get_vars === false) return;
+ if($set_to_get_vars === false)
+ {
+ return;
+ }
if($val === NULL || $val === '')
{
unset($self->get_vars->{$key});
return;
}
- if($set_to_get_vars || $self->get_vars->{$key}) $self->get_vars->{$key} = $val;
+ if($set_to_get_vars || $self->get_vars->{$key})
+ {
+ $self->get_vars->{$key} = $val;
+ }
}
/**
@@ -1322,10 +1778,14 @@ class Context {
* @param string $key Key
* @return string Key
*/
- function get($key) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function get($key)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- if(!isset($self->context->{$key})) return null;
+ if(!isset($self->context->{$key}))
+ {
+ return null;
+ }
return $self->context->{$key};
}
@@ -1334,13 +1794,19 @@ class Context {
*
* @return object
*/
- function gets() {
+ function gets()
+ {
$num_args = func_num_args();
- if($num_args<1) return;
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ if($num_args < 1)
+ {
+ return;
+ }
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$args_list = func_get_args();
- foreach($args_list as $v) {
+ $output = new stdClass();
+ foreach($args_list as $v)
+ {
$output->{$v} = $self->get($v);
}
return $output;
@@ -1351,8 +1817,9 @@ class Context {
*
* @return object All data
*/
- function getAll() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getAll()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->context;
}
@@ -1361,22 +1828,25 @@ class Context {
*
* @return Object Request variables.
*/
- function getRequestVars() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- if($self->get_vars) return clone($self->get_vars);
+ function getRequestVars()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ if($self->get_vars)
+ {
+ return clone($self->get_vars);
+ }
return new stdClass;
}
-
/**
- * Register if actions is to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js
+ * Register if an action is to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js
*
* @param string $action act name
* @return void
*/
function addSSLAction($action)
{
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
if(!is_readable($self->sslActionCacheFile))
{
@@ -1386,19 +1856,71 @@ class Context {
if(!isset($self->ssl_actions[$action]))
{
+ $self->ssl_actions[$action] = 1;
$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
FileHandler::writeFile($self->sslActionCacheFile, $sslActionCacheString, 'a');
}
}
+ /**
+ * Register if actions are to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js
+ *
+ * @param string $action act name
+ * @return void
+ */
+ function addSSLActions($action_array)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+
+ if(!is_readable($self->sslActionCacheFile))
+ {
+ unset($self->ssl_actions);
+ $buff = 'sslActionCacheFile, $buff);
+ }
+
+ foreach($action_array as $action)
+ {
+ if(!isset($self->ssl_actions[$action]))
+ {
+ $self->ssl_actions[$action] = 1;
+ $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
+ FileHandler::writeFile($self->sslActionCacheFile, $sslActionCacheString, 'a');
+ }
+ }
+ }
+
+ /**
+ * Delete if action is registerd to be encrypted by SSL.
+ *
+ * @param string $action act name
+ * @return void
+ */
+ function subtractSSLAction($action)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+
+ if($self->isExistsSSLAction($action))
+ {
+ $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
+ $buff = FileHandler::readFile($self->sslActionCacheFile);
+ $buff = str_replace($sslActionCacheString, '', $buff);
+ FileHandler::writeFile($self->sslActionCacheFile, $buff);
+ }
+ }
+
/**
* Get SSL Action
*
- * @return string act
+ * @return string acts in array
*/
- function getSSLActions() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- return $self->ssl_actions;
+ function getSSLActions()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ if($self->getSslStatus() == 'optional')
+ {
+ return $self->ssl_actions;
+ }
}
/**
@@ -1407,8 +1929,9 @@ class Context {
* @param string $action act name
* @return bool If SSL exists, return true.
*/
- function isExistsSSLAction($action) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function isExistsSSLAction($action)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return isset($self->ssl_actions[$action]);
}
@@ -1419,10 +1942,17 @@ class Context {
* @param string $file file path
* @return string normalized file path
*/
- function normalizeFilePath($file) {
- if(strpos($file,'://')===false && $file{0}!='/' && $file{0}!='.') $file = './'.$file;
+ function normalizeFilePath($file)
+ {
+ if(strpos($file, '://') === false && $file{0} != '/' && $file{0} != '.')
+ {
+ $file = './' . $file;
+ }
$file = preg_replace('@/\./|(?oFrontEndFileHandler->unloadFile($file, $targetIe, $media);
}
@@ -1494,10 +2031,9 @@ class Context {
* @param string $type Unload target (optional - all|css|js)
* @return void
*/
-
function unloadAllFiles($type = 'all')
{
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->unloadAllFiles($type);
}
@@ -1514,19 +2050,24 @@ class Context {
* @param string $autoPath If path not readed, set the path automatically.
* @return void
*/
- function addJsFile($file, $optimized = false, $targetie = '',$index=0, $type='head', $isRuleset = false, $autoPath = null) {
+ function addJsFile($file, $optimized = false, $targetie = '', $index = 0, $type = 'head', $isRuleset = false, $autoPath = null)
+ {
if($isRuleset)
{
- if (strpos($file, '#') !== false){
+ if(strpos($file, '#') !== false)
+ {
$file = str_replace('#', '', $file);
- if (!is_readable($file)) $file = $autoPath;
+ if(!is_readable($file))
+ {
+ $file = $autoPath;
+ }
}
- $validator = new Validator($file);
+ $validator = new Validator($file);
$validator->setCacheDir('files/cache');
$file = $validator->getJsPath();
}
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->loadFile(array($file, $type, $targetie, $index));
}
@@ -1539,8 +2080,9 @@ class Context {
* @param string $targetie target IE
* @return void
*/
- function unloadJsFile($file, $optimized = false, $targetie = '') {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function unloadJsFile($file, $optimized = false, $targetie = '')
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->unloadFile($file, $targetie);
}
@@ -1549,8 +2091,9 @@ class Context {
*
* @return void
*/
- function unloadAllJsFiles() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function unloadAllJsFiles()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->unloadAllFiles('js');
}
@@ -1558,28 +2101,34 @@ class Context {
* Add javascript filter
*
* @param string $path File path
- * @param string $filename File name
+ * @param string $filename File name
* @return void
*/
- function addJsFilter($path, $filename) {
+ function addJsFilter($path, $filename)
+ {
$oXmlFilter = new XmlJSFilter($path, $filename);
$oXmlFilter->compile();
}
+
/**
* Same as array_unique but works only for file subscript
*
* @deprecated
* @param array $files File list
* @return array File list
- */
- function _getUniqueFileList($files) {
+ */
+ function _getUniqueFileList($files)
+ {
ksort($files);
$files = array_values($files);
$filenames = array();
$size = count($files);
- for($i = 0; $i < $size; ++ $i)
+ for($i = 0; $i < $size; ++$i)
{
- if(in_array($files[$i]['file'], $filenames)) unset($files[$i]);
+ if(in_array($files[$i]['file'], $filenames))
+ {
+ unset($files[$i]);
+ }
$filenames[] = $files[$i]['file'];
}
@@ -1592,8 +2141,9 @@ class Context {
* @param string $type Added position. (head:.., body:..)
* @return array Returns javascript file list. Array contains file, targetie.
*/
- function getJsFile($type='head') {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getJsFile($type = 'head')
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->oFrontEndFileHandler->getJsFileList($type);
}
@@ -1609,8 +2159,9 @@ class Context {
* @return void
*
*/
- function addCSSFile($file, $optimized=false, $media='all', $targetie='',$index=0) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function addCSSFile($file, $optimized = false, $media = 'all', $targetie = '', $index = 0)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->loadFile(array($file, $media, $targetie, $index));
}
@@ -1624,8 +2175,9 @@ class Context {
* @param string $targetie target IE
* @return void
*/
- function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '') {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '')
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->unloadFile($file, $targetie, $media);
}
@@ -1634,8 +2186,9 @@ class Context {
*
* @return void
*/
- function unloadAllCSSFiles() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function unloadAllCSSFiles()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->oFrontEndFileHandler->unloadAllFiles('css');
}
@@ -1644,41 +2197,122 @@ class Context {
*
* @return array Returns css file list. Array contains file, media, targetie.
*/
- function getCSSFile() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getCSSFile()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->oFrontEndFileHandler->getCssFileList();
}
+ /**
+ * Returns javascript plugin file info
+ * @param string $pluginName
+ * @return stdClass
+ */
+ function getJavascriptPluginInfo($pluginName)
+ {
+ if($plugin_name == 'ui.datepicker')
+ {
+ $plugin_name = 'ui';
+ }
+
+ $plugin_path = './common/js/plugins/' . $pluginName . '/';
+ $info_file = $plugin_path . 'plugin.load';
+ if(!is_readable($info_file))
+ {
+ return;
+ }
+
+ $list = file($info_file);
+ $result = new stdClass();
+ $result->jsList = array();
+ $result->cssList = array();
+
+ foreach($list as $filename)
+ {
+ $filename = trim($filename);
+ if(!$filename)
+ {
+ continue;
+ }
+
+ if(substr($filename, 0, 2) == './')
+ {
+ $filename = substr($filename, 2);
+ }
+
+ if(preg_match('/\.js$/i', $filename))
+ {
+ $result->jsList[] = $plugin_path . $filename;
+ }
+ elseif(preg_match('/\.css$/i', $filename))
+ {
+ $result->cssList[] = $plugin_path . $filename;
+ }
+ }
+
+ if(is_dir($plugin_path . 'lang'))
+ {
+ $result->langPath = $plugin_path . 'lang';
+ }
+
+ return $result;
+ }
/**
* Load javascript plugin
*
* @param string $plugin_name plugin name
* @return void
*/
- function loadJavascriptPlugin($plugin_name) {
+ function loadJavascriptPlugin($plugin_name)
+ {
static $loaded_plugins = array();
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- if($plugin_name == 'ui.datepicker') $plugin_name = 'ui';
-
- if($loaded_plugins[$plugin_name]) return;
- $loaded_plugins[$plugin_name] = true;
-
- $plugin_path = './common/js/plugins/'.$plugin_name.'/';
- $info_file = $plugin_path.'plugin.load';
- if(!is_readable($info_file)) return;
-
- $list = file($info_file);
- foreach($list as $filename) {
- $filename = trim($filename);
- if(!$filename) continue;
-
- if(substr($filename,0,2)=='./') $filename = substr($filename,2);
- if(preg_match('/\.js$/i', $filename)) $self->loadFile(array($plugin_path.$filename, 'body', '', 0), true);
- elseif(preg_match('/\.css$/i', $filename)) $self->loadFile(array($plugin_path.$filename, 'all', '', 0), true);
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ if($plugin_name == 'ui.datepicker')
+ {
+ $plugin_name = 'ui';
}
- if(is_dir($plugin_path.'lang')) $self->loadLang($plugin_path.'lang');
+ if($loaded_plugins[$plugin_name])
+ {
+ return;
+ }
+ $loaded_plugins[$plugin_name] = true;
+
+ $plugin_path = './common/js/plugins/' . $plugin_name . '/';
+ $info_file = $plugin_path . 'plugin.load';
+ if(!is_readable($info_file))
+ {
+ return;
+ }
+
+ $list = file($info_file);
+ foreach($list as $filename)
+ {
+ $filename = trim($filename);
+ if(!$filename)
+ {
+ continue;
+ }
+
+ if(substr($filename, 0, 2) == './')
+ {
+ $filename = substr($filename, 2);
+ }
+ if(preg_match('/\.js$/i', $filename))
+ {
+ $self->loadFile(array($plugin_path . $filename, 'body', '', 0), true);
+ }
+ elseif(preg_match('/\.css$/i', $filename))
+ {
+ $self->loadFile(array($plugin_path . $filename, 'all', '', 0), true);
+ }
+ }
+
+ if(is_dir($plugin_path . 'lang'))
+ {
+ $self->loadLang($plugin_path . 'lang');
+ }
}
/**
@@ -1687,9 +2321,16 @@ class Context {
* @param string $header add html code before .
* @return void
*/
- function addHtmlHeader($header) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- $self->html_header .= "\n".$header;
+ function addHtmlHeader($header)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ $self->html_header .= "\n" . $header;
+ }
+
+ function clearHtmlHeader()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ $self->html_header = '';
}
/**
@@ -1697,8 +2338,9 @@ class Context {
*
* @return string Added html code before
*/
- function getHtmlHeader() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getHtmlHeader()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->html_header;
}
@@ -1707,8 +2349,9 @@ class Context {
*
* @param string $class_name class name
*/
- function addBodyClass($class_name) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function addBodyClass($class_name)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->body_class[] = $class_name;
}
@@ -1717,11 +2360,12 @@ class Context {
*
* @return string Return class to html body
*/
- function getBodyClass() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getBodyClass()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
$self->body_class = array_unique($self->body_class);
- return count($self->body_class)?sprintf(' class="%s"', implode(' ',$self->body_class)):'';
+ return count($self->body_class) ? sprintf(' class="%s"', implode(' ', $self->body_class)) : '';
}
/**
@@ -1729,9 +2373,10 @@ class Context {
*
* @param string $header Add html code after
*/
- function addBodyHeader($header) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- $self->body_header .= "\n".$header;
+ function addBodyHeader($header)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ $self->body_header .= "\n" . $header;
}
/**
@@ -1739,8 +2384,9 @@ class Context {
*
* @return string Added html code after
*/
- function getBodyHeader() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getBodyHeader()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->body_header;
}
@@ -1749,9 +2395,10 @@ class Context {
*
* @param string $footer Add html code before
*/
- function addHtmlFooter($footer) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
- $self->html_footer .= ($self->Htmlfooter?"\n":'').$footer;
+ function addHtmlFooter($footer)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
+ $self->html_footer .= ($self->Htmlfooter ? "\n" : '') . $footer;
}
/**
@@ -1759,8 +2406,9 @@ class Context {
*
* @return string Added html code before
*/
- function getHtmlFooter() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getHtmlFooter()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
return $self->html_footer;
}
@@ -1769,8 +2417,9 @@ class Context {
*
* @retrun string The path of the config file that contains database settings
*/
- function getConfigFile() {
- return _XE_PATH_.'files/config/db.config.php';
+ function getConfigFile()
+ {
+ return _XE_PATH_ . 'files/config/db.config.php';
}
/**
@@ -1778,8 +2427,9 @@ class Context {
*
* @return string The path of the config file that contains FTP settings
*/
- function getFTPConfigFile() {
- return _XE_PATH_.'files/config/ftp.config.php';
+ function getFTPConfigFile()
+ {
+ return _XE_PATH_ . 'files/config/ftp.config.php';
}
/**
@@ -1787,7 +2437,8 @@ class Context {
*
* @return bool True if the config file exists, otherwise false.
*/
- function isInstalled() {
+ function isInstalled()
+ {
return FileHandler::hasContent(Context::getConfigFile());
}
@@ -1797,7 +2448,8 @@ class Context {
* @param string Transforms codes
* @return string Transforms codes
*/
- function transContent($content) {
+ function transContent($content)
+ {
return $content;
}
@@ -1806,8 +2458,9 @@ class Context {
*
* @return bool True if it is allowed to use rewrite mod, otherwise false
*/
- function isAllowRewrite() {
- $oContext = &Context::getInstance();
+ function isAllowRewrite()
+ {
+ $oContext = Context::getInstance();
return $oContext->allow_rewrite;
}
@@ -1817,35 +2470,54 @@ class Context {
* @param string $path URL path
* @return string Converted path
*/
- function pathToUrl($path) {
- $xe = _XE_PATH_;
+ function pathToUrl($path)
+ {
+ $xe = _XE_PATH_;
$path = strtr($path, "\\", "/");
$base_url = preg_replace('@^https?://[^/]+/?@', '', Context::getRequestUri());
- $_xe = explode('/', $xe);
+ $_xe = explode('/', $xe);
$_path = explode('/', $path);
$_base = explode('/', $base_url);
- if(!$_base[count($_base)-1]) array_pop($_base);
+ if(!$_base[count($_base) - 1])
+ {
+ array_pop($_base);
+ }
- foreach($_xe as $idx=>$dir) {
- if($_path[0] != $dir) break;
+ foreach($_xe as $idx => $dir)
+ {
+ if($_path[0] != $dir)
+ {
+ break;
+ }
array_shift($_path);
}
$idx = count($_xe) - $idx - 1;
- while($idx--) {
- if(count($_base)) array_shift($_base);
- else array_unshift($_base, '..');
+ while($idx--)
+ {
+ if(count($_base))
+ {
+ array_shift($_base);
+ }
+ else
+ {
+ array_unshift($_base, '..');
+ }
}
- if(count($_base)) {
+ if(count($_base))
+ {
array_unshift($_path, implode('/', $_base));
}
- $path = '/'.implode('/', $_path);
- if(substr($path,-1)!='/') $path .= '/';
+ $path = '/' . implode('/', $_path);
+ if(substr($path, -1) != '/')
+ {
+ $path .= '/';
+ }
return $path;
}
@@ -1853,17 +2525,22 @@ class Context {
* Get meta tag
* @return array The list of meta tags
*/
- function getMetaTag() {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function getMetaTag()
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- if(!is_array($self->meta_tags)) $self->meta_tags = array();
+ if(!is_array($self->meta_tags))
+ {
+ $self->meta_tags = array();
+ }
$ret = array();
$map = &$self->meta_tags;
- foreach($map as $key=>$val) {
+ foreach($map as $key => $val)
+ {
list($name, $is_http_equiv) = explode("\t", $key);
- $ret[] = array('name'=>$name, 'is_http_equiv'=>$is_http_equiv, 'content' => $val);
+ $ret[] = array('name' => $name, 'is_http_equiv' => $is_http_equiv, 'content' => $val);
}
return $ret;
@@ -1877,12 +2554,16 @@ class Context {
* @param mixed $is_http_equiv value of http_equiv
* @return void
*/
- function addMetaTag($name, $content, $is_http_equiv = false) {
- is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
+ function addMetaTag($name, $content, $is_http_equiv = false)
+ {
+ is_a($this, 'Context') ? $self = $this : $self = Context::getInstance();
- $key = $name."\t".($is_http_equiv ? '1' : '0');
+ $key = $name . "\t" . ($is_http_equiv ? '1' : '0');
$map = &$self->meta_tags;
$map[$key] = $content;
}
+
}
+/* End of file Context.class.php */
+/* Location: ./classes/context/Context.class.php */
diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php
index d25a3fe11..8ac6079ba 100644
--- a/classes/db/DB.class.php
+++ b/classes/db/DB.class.php
@@ -1,1063 +1,1426 @@
'=',
- 'more' => '>=',
- 'excess' => '>',
- 'less' => '<=',
- 'below' => '<',
- 'notequal' => '<>',
- 'notnull' => 'is not null',
- 'null' => 'is null',
- );
-
- /**
- * master database connection string
- * @var array
- */
- var $master_db = NULL;
- /**
- * array of slave databases connection strings
- * @var array
- */
- var $slave_db = NULL;
-
- var $result = NULL;
-
- /**
- * error code (0 means no error)
- * @var int
- */
- var $errno = 0;
- /**
- * error message
- * @var string
- */
- var $errstr = '';
- /**
- * query string of latest executed query
- * @var string
- */
- var $query = '';
- var $connection = '';
- /**
- * elapsed time of latest executed query
- * @var int
- */
- var $elapsed_time = 0;
- /**
- * elapsed time of latest executed DB class
- * @var int
- */
- var $elapsed_dbclass_time = 0;
-
- /**
- * transaction flag
- * @var boolean
- */
- var $transaction_started = FALSE;
-
- var $is_connected = FALSE;
-
- /**
- * returns enable list in supported dbms list
- * will be written by classes/DB/DB***.class.php
- * @var array
- */
- var $supported_list = array();
-
- /**
- * location of query cache
- * @var string
- */
- var $cache_file = 'files/cache/queries/';
-
- /**
- * stores database type: 'mysql','cubrid','mssql' etc. or 'db' when database is not yet set
- * @var string
- */
- var $db_type;
-
- /**
- * flag to decide if class prepared statements or not (when supported); can be changed from db.config.info
- * @var string
- */
- var $use_prepared_statements;
-
- /**
- * returns instance of certain db type
- * @param string $db_type type of db
- * @return DB return DB object instance
- */
- function &getInstance($db_type = NULL) {
- if(!$db_type) $db_type = Context::getDBType();
- if(!$db_type && Context::isInstalled()) return new Object(-1, 'msg_db_not_setted');
-
- if(!isset($GLOBALS['__DB__'])) $GLOBALS['__DB__'] = array();
- if(!isset($GLOBALS['__DB__'][$db_type])) {
- $class_name = 'DB'.ucfirst($db_type);
- $class_file = _XE_PATH_."classes/db/$class_name.class.php";
- if(!file_exists($class_file)) return new Object(-1, 'msg_db_not_setted');
-
- // get a singletone instance of the database driver class
- require_once($class_file);
- $GLOBALS['__DB__'][$db_type] = call_user_func(array($class_name, 'create'));
- $GLOBALS['__DB__'][$db_type]->db_type = $db_type;
- }
-
- return $GLOBALS['__DB__'][$db_type];
- }
-
- /**
- * returns instance of db
- * @return DB return DB object instance
- */
- function create() {
- return new DB;
- }
-
- /**
- * constructor
- * @return void
- */
- function DB() {
- $this->count_cache_path = _XE_PATH_.$this->count_cache_path;
- $this->cache_file = _XE_PATH_.$this->cache_file;
- }
-
- /**
- * returns list of supported dbms list
- * this list return by directory list
- * check by instance can creatable
- * @return array return supported DBMS list
- */
- function getSupportedList() {
- $oDB = new DB();
- return $oDB->_getSupportedList();
- }
-
- /**
- * returns enable list in supported dbms list
- * this list return by child class
- * @return array return enable DBMS list in supported dbms list
- */
- function getEnableList()
- {
- if(!$this->supported_list)
- {
- $oDB = new DB();
- $this->supported_list = $oDB->_getSupportedList();
- }
-
- $enableList = array();
- if(is_array($this->supported_list))
- {
- foreach($this->supported_list AS $key=>$value)
- if($value->enable) array_push($enableList, $value);
- }
- return $enableList;
- }
-
- /**
- * returns list of disable in supported dbms list
- * this list return by child class
- * @return array return disable DBMS list in supported dbms list
- */
- function getDisableList()
- {
- if(!$this->supported_list)
- {
- $oDB = new DB();
- $this->supported_list = $oDB->_getSupportedList();
- }
-
- $disableList = array();
- if(is_array($this->supported_list))
- {
- foreach($this->supported_list AS $key=>$value)
- if(!$value->enable) array_push($disableList, $value);
- }
- return $disableList;
- }
-
- /**
- * returns list of supported dbms list
- * this method is private
- * @return array return supported DBMS list
- */
- function _getSupportedList() {
- static $get_supported_list = '';
- if(is_array($get_supported_list)) {
- $this->supported_list = $get_supported_list;
- return $this->supported_list;
- }
- $get_supported_list = array();
- $db_classes_path = _XE_PATH_."classes/db/";
- $filter = "/^DB([^\.]+)\.class\.php/i";
- $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE);
- sort($supported_list);
-
- // after creating instance of class, check is supported
- for($i = 0; $i < count($supported_list); $i++) {
- $db_type = $supported_list[$i];
-
- if(version_compare(phpversion(), '5.0') < 0 && preg_match('/pdo/i',$db_type)) continue;
-
- $class_name = sprintf("DB%s%s", strtoupper(substr($db_type,0,1)), strtolower(substr($db_type,1)));
- $class_file = sprintf(_XE_PATH_."classes/db/%s.class.php", $class_name);
- if(!file_exists($class_file)) continue;
-
- unset($oDB);
- require_once($class_file);
- $tmp_fn = create_function('', "return new {$class_name}();");
- $oDB = $tmp_fn();
-
- if(!$oDB) continue;
-
- $obj = NULL;
- $obj->db_type = $db_type;
- $obj->enable = $oDB->isSupported() ? TRUE : FALSE;
-
- $get_supported_list[] = $obj;
- }
- $this->supported_list = $get_supported_list;
- return $this->supported_list;
- }
-
- /**
- * Return dbms supportable status
- * The value is set in the child class
- * @return boolean true: is supported, false: is not supported
- */
- function isSupported() {
- return FALSE;
- }
-
- /**
- * Return connected status
- * @param string $type master or slave
- * @param int $indx key of server list
- * @return boolean true: connected, false: not connected
- */
- function isConnected($type = 'master', $indx = 0) {
- if($type == 'master') return $this->master_db["is_connected"] ? TRUE : FALSE;
- else return $this->slave_db[$indx]["is_connected"] ? TRUE : FALSE;
- }
-
- /**
- * start recording log
- * @param string $query query string
- * @return void
- */
- function actStart($query) {
- $this->setError(0, 'success');
- $this->query = $query;
- $this->act_start = getMicroTime();
- $this->elapsed_time = 0;
- }
-
- /**
- * finish recording log
- * @return void
- */
- function actFinish() {
- if(!$this->query) return;
- $this->act_finish = getMicroTime();
- $elapsed_time = $this->act_finish - $this->act_start;
- $this->elapsed_time = $elapsed_time;
- $GLOBALS['__db_elapsed_time__'] += $elapsed_time;
-
- $log['query'] = $this->query;
- $log['elapsed_time'] = $elapsed_time;
- $log['connection'] = $this->connection;
-
- // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined)
- if($this->isError()) {
- $site_module_info = Context::get('site_module_info');
- $log['module'] = $site_module_info->module;
- $log['act'] = Context::get('act');
- $log['query_id'] = $this->query_id;
- $log['time'] = date('Y-m-d H:i:s');
- $log['result'] = 'Failed';
- $log['errno'] = $this->errno;
- $log['errstr'] = $this->errstr;
-
- if(__DEBUG_DB_OUTPUT__ == 1) {
- $debug_file = _XE_PATH_."files/_debug_db_query.php";
- $buff = array();
- if(!file_exists($debug_file)) $buff[] = '';
- $buff[] = print_r($log, TRUE);
-
- if(@!$fp = fopen($debug_file, "a")) return;
- fwrite($fp, implode("\n", $buff)."\n\n");
- fclose($fp);
- }
- } else {
- $log['result'] = 'Success';
- }
- $GLOBALS['__db_queries__'][] = $log;
-
- // if __LOG_SLOW_QUERY__ if defined, check elapsed time and leave query log
- if(__LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) {
- $buff = '';
- $log_file = _XE_PATH_.'files/_db_slow_query.php';
- if(!file_exists($log_file)) {
- $buff = ''."\n";
- }
-
- $buff .= sprintf("%s\t%s\n\t%0.6f sec\tquery_id:%s\n\n", date("Y-m-d H:i"), $this->query, $elapsed_time, $this->query_id);
-
- if($fp = fopen($log_file, 'a')) {
- fwrite($fp, $buff);
- fclose($fp);
- }
- }
- }
-
- /**
- * set error
- * @param int $errno error code
- * @param string $errstr error message
- * @return void
- */
- function setError($errno = 0, $errstr = 'success') {
- $this->errno = $errno;
- $this->errstr = $errstr;
- }
-
- /**
- * Return error status
- * @return boolean true: error, false: no error
- */
- function isError() {
- return $this->errno === 0 ? FALSE : TRUE;
- }
-
- /**
- * Returns object of error info
- * @return object object of error
- */
- function getError() {
- $this->errstr = Context::convertEncodingStr($this->errstr);
- return new Object($this->errno, $this->errstr);
- }
-
- /**
- * Execute Query that result of the query xml file
- * This function finds xml file or cache file of $query_id, compiles it and then execute it
- * @param string $query_id query id (module.queryname)
- * @param array|object $args arguments for query
- * @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns
- * @return object result of query
- */
- function executeQuery($query_id, $args = NULL, $arg_columns = NULL) {
- static $cache_file = array();
-
- if(!$query_id) return new Object(-1, 'msg_invalid_queryid');
- if(!$this->db_type) return;
-
- $this->actDBClassStart();
-
- $this->query_id = $query_id;
-
- if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) {
- $id_args = explode('.', $query_id);
- if(count($id_args) == 2) {
- $target = 'modules';
- $module = $id_args[0];
- $id = $id_args[1];
- } elseif(count($id_args) == 3) {
- $target = $id_args[0];
- $typeList = array('addons'=>1, 'widgets'=>1);
- if(!isset($typeList[$target])){
- $this->actDBClassFinish();
- return;
- }
- $module = $id_args[1];
- $id = $id_args[2];
- }
- if(!$target || !$module || !$id){
- $this->actDBClassFinish();
- return new Object(-1, 'msg_invalid_queryid');
- }
-
- $xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id);
- if(!file_exists($xml_file)){
- $this->actDBClassFinish();
- return new Object(-1, 'msg_invalid_queryid');
- }
-
- // look for cache file
- $cache_file[$query_id] = $this->checkQueryCacheFile($query_id, $xml_file);
- }
- $result = $this->_executeQuery($cache_file[$query_id], $args, $query_id, $arg_columns);
-
- $this->actDBClassFinish();
- // execute query
- return $result;
- }
-
-
- /**
- * Look for query cache file
- * @param string $query_id query id for finding
- * @param string $xml_file original xml query file
- * @return string cache file
- */
- function checkQueryCacheFile($query_id,$xml_file){
- // first try finding cache file
- $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type);
-
- if(file_exists($cache_file)) $cache_time = filemtime($cache_file);
- else $cache_time = -1;
-
- // if there is no cache file or is not new, find original xml query file and parse it
- if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_.'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_.'classes/xml/XmlQueryParser.150.class.php')) {
- require_once(_XE_PATH_.'classes/xml/XmlQueryParser.150.class.php');
- $oParser = new XmlQueryParser();
- $oParser->parse($query_id, $xml_file, $cache_file);
- }
-
- return $cache_file;
- }
-
-
- /**
- * Execute query and return the result
- * @param string $cache_file cache file of query
- * @param array|object $source_args arguments for query
- * @param string $query_id query id
- * @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns
- * @return object result of query
- */
- function _executeQuery($cache_file, $source_args, $query_id, $arg_columns) {
- global $lang;
-
- if(!file_exists($cache_file)) return new Object(-1, 'msg_invalid_queryid');
-
- if($source_args) $args = @clone($source_args);
-
- $output = include($cache_file);
-
- if( (is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output;
-
- // execute appropriate query
- switch($output->getAction()) {
- case 'insert' :
- case 'insert-select' :
- $this->resetCountCache($output->tables);
- $output = $this->_executeInsertAct($output);
- break;
- case 'update' :
- $this->resetCountCache($output->tables);
- $output = $this->_executeUpdateAct($output);
- break;
- case 'delete' :
- $this->resetCountCache($output->tables);
- $output = $this->_executeDeleteAct($output);
- break;
- case 'select' :
- $arg_columns = is_array($arg_columns)?$arg_columns:array();
- $output->setColumnList($arg_columns);
- $connection = $this->_getConnection('slave');
- $output = $this->_executeSelectAct($output, $connection);
- break;
- }
-
- if($this->isError()) $output = $this->getError();
- else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) $output = new Object();
- $output->add('_query', $this->query);
- $output->add('_elapsed_time', sprintf("%0.5f", $this->elapsed_time));
-
- return $output;
- }
-
-
- /**
- * Returns counter cache data
- * @param array|string $tables tables to get data
- * @param string $condition condition to get data
- * @return int count of cache data
- */
- function getCountCache($tables, $condition) {
- return FALSE;
- if(!$tables) return FALSE;
- if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
-
- $condition = md5($condition);
-
- if(!is_array($tables)) $tables_str = $tables;
- else $tables_str = implode('.',$tables);
-
- $cache_path = sprintf('%s/%s%s', $this->count_cache_path, $this->prefix, $tables_str);
- if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
-
- $cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
- if(!file_exists($cache_filename)) return FALSE;
-
- $cache_mtime = filemtime($cache_filename);
-
- if(!is_array($tables)) $tables = array($tables);
- foreach($tables as $alias => $table) {
- $table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table) ;
- if(!file_exists($table_filename) || filemtime($table_filename) > $cache_mtime) return FALSE;
- }
-
- $count = (int)FileHandler::readFile($cache_filename);
- return $count;
- }
-
- /**
- * Save counter cache data
- * @param array|string $tables tables to save data
- * @param string $condition condition to save data
- * @param int $count count of cache data to save
- * @return void
- */
- function putCountCache($tables, $condition, $count = 0) {
- return FALSE;
- if(!$tables) return FALSE;
- if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
-
- $condition = md5($condition);
-
- if(!is_array($tables)) $tables_str = $tables;
- else $tables_str = implode('.',$tables);
-
- $cache_path = sprintf('%s/%s%s', $this->count_cache_path, $this->prefix, $tables_str);
- if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
-
- $cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
-
- FileHandler::writeFile($cache_filename, $count);
- }
-
- /**
- * Reset counter cache data
- * @param array|string $tables tables to reset cache data
- * @return boolean true: success, false: failed
- */
- function resetCountCache($tables) {
- return FALSE;
- if(!$tables) return FALSE;
- if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
-
- if(!is_array($tables)) $tables = array($tables);
- foreach($tables as $alias => $table) {
- $filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table);
- FileHandler::removeFile($filename);
- FileHandler::writeFile($filename, '');
- }
-
- return TRUE;
- }
-
- /**
- * Returns supported database list
- * @return array list of supported database
- */
- function getSupportedDatabase(){
- $result = array();
-
- if(function_exists('mysql_connect')) $result[] = 'MySQL';
- if(function_exists('cubrid_connect')) $result[] = 'Cubrid';
- if(function_exists('ibase_connect')) $result[] = 'FireBird';
- if(function_exists('pg_connect')) $result[] = 'Postgre';
- if(function_exists('sqlite_open')) $result[] = 'sqlite2';
- if(function_exists('mssql_connect')) $result[] = 'MSSQL';
- if(function_exists('PDO')) $result[] = 'sqlite3(PDO)';
-
- return $result;
- }
-
- /**
- * Drop tables
- * @param string $table_name
- * @return void
- */
- function dropTable($table_name){
- if(!$table_name) return;
- $query = sprintf("drop table %s%s", $this->prefix, $table_name);
- $this->_query($query);
- }
-
- /**
- * Return select query string
- * @param object $query
- * @param boolean $with_values
- * @return string
- */
- function getSelectSql($query, $with_values = TRUE){
- $select = $query->getSelectString($with_values);
- if($select == '') return new Object(-1, "Invalid query");
- $select = 'SELECT ' .$select;
-
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
- $from = ' FROM '.$from;
-
- $where = $query->getWhereString($with_values);
- if($where != '') $where = ' WHERE ' . $where;
-
- $tableObjects = $query->getTables();
- $index_hint_list = '';
- foreach($tableObjects as $tableObject){
- if(is_a($tableObject, 'CubridTableWithHint'))
- $index_hint_list .= $tableObject->getIndexHintString() . ', ';
- }
- $index_hint_list = substr($index_hint_list, 0, -2);
- if($index_hint_list != '')
- $index_hint_list = 'USING INDEX ' . $index_hint_list;
-
- $groupBy = $query->getGroupByString();
- if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
-
- $orderBy = $query->getOrderByString();
- if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
-
- $limit = $query->getLimitString();
- if($limit != '') $limit = ' LIMIT ' . $limit;
-
- return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
- }
-
- /**
- * Given a SELECT statement that uses click count
- * returns the corresponding update sql string
- * for databases that don't have click count support built in
- * (aka all besides CUBRID)
- *
- * Function does not check if click count columns exist!
- * You must call $query->usesClickCount() before using this function
- *
- * @param $queryObject
- */
- function getClickCountQuery($queryObject)
+ var $priority_dbms = array(
+ 'mysqli' => 5,
+ 'mysql' => 4,
+ 'mysql_innodb' => 3,
+ 'cubrid' => 2,
+ 'mssql' => 1
+ );
+
+ /**
+ * count cache path
+ * @var string
+ */
+ var $count_cache_path = 'files/cache/db';
+
+ /**
+ * operations for condition
+ * @var array
+ */
+ var $cond_operation = array(
+ 'equal' => '=',
+ 'more' => '>=',
+ 'excess' => '>',
+ 'less' => '<=',
+ 'below' => '<',
+ 'notequal' => '<>',
+ 'notnull' => 'is not null',
+ 'null' => 'is null',
+ );
+
+ /**
+ * master database connection string
+ * @var array
+ */
+ var $master_db = NULL;
+
+ /**
+ * array of slave databases connection strings
+ * @var array
+ */
+ var $slave_db = NULL;
+ var $result = NULL;
+
+ /**
+ * error code (0 means no error)
+ * @var int
+ */
+ var $errno = 0;
+
+ /**
+ * error message
+ * @var string
+ */
+ var $errstr = '';
+
+ /**
+ * query string of latest executed query
+ * @var string
+ */
+ var $query = '';
+ var $connection = '';
+
+ /**
+ * elapsed time of latest executed query
+ * @var int
+ */
+ var $elapsed_time = 0;
+
+ /**
+ * elapsed time of latest executed DB class
+ * @var int
+ */
+ var $elapsed_dbclass_time = 0;
+
+ /**
+ * transaction flag
+ * @var boolean
+ */
+ var $transaction_started = FALSE;
+ var $is_connected = FALSE;
+
+ /**
+ * returns enable list in supported dbms list
+ * will be written by classes/DB/DB***.class.php
+ * @var array
+ */
+ var $supported_list = array();
+
+ /**
+ * location of query cache
+ * @var string
+ */
+ var $cache_file = 'files/cache/queries/';
+
+ /**
+ * stores database type: 'mysql','cubrid','mssql' etc. or 'db' when database is not yet set
+ * @var string
+ */
+ var $db_type;
+
+ /**
+ * flag to decide if class prepared statements or not (when supported); can be changed from db.config.info
+ * @var string
+ */
+ var $use_prepared_statements;
+
+ /**
+ * leve of transaction
+ * @var unknown
+ */
+ private $transationNestedLevel = 0;
+
+ /**
+ * returns instance of certain db type
+ * @param string $db_type type of db
+ * @return DB return DB object instance
+ */
+ function &getInstance($db_type = NULL)
+ {
+ if(!$db_type)
{
- $new_update_columns = array();
- $click_count_columns = $queryObject->getClickCountColumns();
- foreach($click_count_columns as $click_count_column)
+ $db_type = Context::getDBType();
+ }
+ if(!$db_type && Context::isInstalled())
+ {
+ return new Object(-1, 'msg_db_not_setted');
+ }
+
+ if(!isset($GLOBALS['__DB__']))
+ {
+ $GLOBALS['__DB__'] = array();
+ }
+ if(!isset($GLOBALS['__DB__'][$db_type]))
+ {
+ $class_name = 'DB' . ucfirst($db_type);
+ $class_file = _XE_PATH_ . "classes/db/$class_name.class.php";
+ if(!file_exists($class_file))
{
- $click_count_column_name = $click_count_column->column_name;
-
- $increase_by_1 = new Argument($click_count_column_name, null);
- $increase_by_1->setColumnOperation('+');
- $increase_by_1->ensureDefaultValue(1);
-
- $update_expression = new UpdateExpression($click_count_column_name, $increase_by_1);
- $new_update_columns[] = $update_expression;
+ return new Object(-1, 'msg_db_not_setted');
}
- $queryObject->columns = $new_update_columns;
- return $queryObject;
+
+ // get a singletone instance of the database driver class
+ require_once($class_file);
+ $GLOBALS['__DB__'][$db_type] = call_user_func(array($class_name, 'create'));
+ $GLOBALS['__DB__'][$db_type]->db_type = $db_type;
}
- /**
- * Return delete query string
- * @param object $query
- * @param boolean $with_values
- * @param boolean $with_priority
- * @return string
- */
- function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE){
- $sql = 'DELETE ';
+ return $GLOBALS['__DB__'][$db_type];
+ }
- $sql .= $with_priority?$query->getPriority():'';
- $tables = $query->getTables();
+ /**
+ * returns instance of db
+ * @return DB return DB object instance
+ */
+ function create()
+ {
+ return new DB;
+ }
- $sql .= $tables[0]->getAlias();
+ /**
+ * constructor
+ * @return void
+ */
+ function DB()
+ {
+ $this->count_cache_path = _XE_PATH_ . $this->count_cache_path;
+ $this->cache_file = _XE_PATH_ . $this->cache_file;
+ }
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
- $sql .= ' FROM '.$from;
+ /**
+ * returns list of supported dbms list
+ * this list return by directory list
+ * check by instance can creatable
+ * @return array return supported DBMS list
+ */
+ function getSupportedList()
+ {
+ $oDB = new DB();
+ return $oDB->_getSupportedList();
+ }
- $where = $query->getWhereString($with_values);
- if($where != '') $sql .= ' WHERE ' . $where;
-
- return $sql;
+ /**
+ * returns enable list in supported dbms list
+ * this list return by child class
+ * @return array return enable DBMS list in supported dbms list
+ */
+ function getEnableList()
+ {
+ if(!$this->supported_list)
+ {
+ $oDB = new DB();
+ $this->supported_list = $oDB->_getSupportedList();
}
- /**
- * Return update query string
- * @param object $query
- * @param boolean $with_values
- * @param boolean $with_priority
- * @return string
- */
- function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE){
- $columnsList = $query->getUpdateString($with_values);
- if($columnsList == '') return new Object(-1, "Invalid query");
+ $enableList = array();
+ if(is_array($this->supported_list))
+ {
+ foreach($this->supported_list AS $key => $value)
+ {
+ if($value->enable)
+ {
+ array_push($enableList, $value);
+ }
+ }
+ }
+ return $enableList;
+ }
- $tables = $query->getFromString($with_values);
- if($tables == '') return new Object(-1, "Invalid query");
-
- $where = $query->getWhereString($with_values);
- if($where != '') $where = ' WHERE ' . $where;
-
- $priority = $with_priority?$query->getPriority():'';
-
- return "UPDATE $priority $tables SET $columnsList ".$where;
+ /**
+ * returns list of disable in supported dbms list
+ * this list return by child class
+ * @return array return disable DBMS list in supported dbms list
+ */
+ function getDisableList()
+ {
+ if(!$this->supported_list)
+ {
+ $oDB = new DB();
+ $this->supported_list = $oDB->_getSupportedList();
}
- /**
- * Return insert query string
- * @param object $query
- * @param boolean $with_values
- * @param boolean $with_priority
- * @return string
- */
- function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE){
- $tableName = $query->getFirstTableName();
- $values = $query->getInsertString($with_values);
- $priority = $with_priority?$query->getPriority():'';
+ $disableList = array();
+ if(is_array($this->supported_list))
+ {
+ foreach($this->supported_list AS $key => $value)
+ {
+ if(!$value->enable)
+ {
+ array_push($disableList, $value);
+ }
+ }
+ }
+ return $disableList;
+ }
- return "INSERT $priority INTO $tableName \n $values";
+ /**
+ * returns list of supported dbms list
+ * this method is private
+ * @return array return supported DBMS list
+ */
+ function _getSupportedList()
+ {
+ static $get_supported_list = '';
+ if(is_array($get_supported_list))
+ {
+ $this->supported_list = $get_supported_list;
+ return $this->supported_list;
+ }
+ $get_supported_list = array();
+ $db_classes_path = _XE_PATH_ . "classes/db/";
+ $filter = "/^DB([^\.]+)\.class\.php/i";
+ $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE);
+
+ // after creating instance of class, check is supported
+ for($i = 0; $i < count($supported_list); $i++)
+ {
+ $db_type = $supported_list[$i];
+
+ if(version_compare(phpversion(), '5.0') < 0 && preg_match('/pdo/i', $db_type))
+ {
+ continue;
+ }
+
+ $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1)));
+ $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name);
+ if(!file_exists($class_file))
+ {
+ continue;
+ }
+
+ unset($oDB);
+ require_once($class_file);
+ $tmp_fn = create_function('', "return new {$class_name}();");
+ $oDB = $tmp_fn();
+
+ if(!$oDB)
+ {
+ continue;
+ }
+
+ $obj = NULL;
+ $obj->db_type = $db_type;
+ $obj->enable = $oDB->isSupported() ? TRUE : FALSE;
+
+ $get_supported_list[] = $obj;
}
- /**
- * Return index from slave server list
- * @return int
- */
- function _getSlaveConnectionStringIndex() {
- $max = count($this->slave_db);
- $indx = rand(0, $max - 1);
- return $indx;
- }
+ // sort
+ @usort($get_supported_list, array($this, '_sortDBMS'));
- /**
- * Return connection resource
- * @param string $type use 'master' or 'slave'. default value is 'master'
- * @param int $indx if indx value is NULL, return rand number in slave server list
- * @return resource
- */
- function _getConnection($type = 'master', $indx = NULL){
- if($type == 'master'){
- if(!$this->master_db['is_connected'])
- $this->_connect($type);
- $this->connection = 'Master ' . $this->master_db['db_hostname'];
- return $this->master_db["resource"];
- }
+ $this->supported_list = $get_supported_list;
+ return $this->supported_list;
+ }
- if($indx === NULL)
- $indx = $this->_getSlaveConnectionStringIndex($type);
+ /**
+ * sort dbms as priority
+ */
+ function _sortDBMS($a, $b)
+ {
+ if(!isset($this->priority_dbms[$a->db_type]))
+ {
+ $priority_a = 0;
+ }
+ else
+ {
+ $priority_a = $this->priority_dbms[$a->db_type];
+ }
- if(!$this->slave_db[$indx]['is_connected'])
- $this->_connect($type, $indx);
+ if(!isset($this->priority_dbms[$b->db_type]))
+ {
+ $priority_b = 0;
+ }
+ else
+ {
+ $priority_b = $this->priority_dbms[$b->db_type];
+ }
- $this->connection = 'Slave ' . $this->slave_db[$indx]['db_hostname'];
- return $this->slave_db[$indx]["resource"];
- }
+ if($priority_a == $priority_b)
+ {
+ return 0;
+ }
- /**
- * check db information exists
- * @return boolean
- */
- function _dbInfoExists() {
- if (!$this->master_db)
- return FALSE;
- if (count($this->slave_db) === 0)
- return FALSE;
- return TRUE;
- }
+ return ($priority_a > $priority_b) ? -1 : 1;
+ }
- /**
- * DB disconnection
- * this method is protected
- * @param resource $connection
- * @return void
- */
- function _close($connection){
+ /**
+ * Return dbms supportable status
+ * The value is set in the child class
+ * @return boolean true: is supported, false: is not supported
+ */
+ function isSupported()
+ {
+ return FALSE;
+ }
- }
+ /**
+ * Return connected status
+ * @param string $type master or slave
+ * @param int $indx key of server list
+ * @return boolean true: connected, false: not connected
+ */
+ function isConnected($type = 'master', $indx = 0)
+ {
+ if($type == 'master')
+ {
+ return $this->master_db["is_connected"] ? TRUE : FALSE;
+ }
+ else
+ {
+ return $this->slave_db[$indx]["is_connected"] ? TRUE : FALSE;
+ }
+ }
- /**
- * DB disconnection
- * @param string $type 'master' or 'slave'
- * @param int $indx number in slave dbms server list
- * @return void
- */
- function close($type = 'master', $indx = 0) {
- if (!$this->isConnected($type, $indx))
- return;
+ /**
+ * start recording log
+ * @param string $query query string
+ * @return void
+ */
+ function actStart($query)
+ {
+ $this->setError(0, 'success');
+ $this->query = $query;
+ $this->act_start = getMicroTime();
+ $this->elapsed_time = 0;
+ }
- if ($type == 'master')
- $connection = &$this->master_db;
- else
- $connection = &$this->slave_db[$indx];
+ /**
+ * finish recording log
+ * @return void
+ */
+ function actFinish()
+ {
+ if(!$this->query)
+ {
+ return;
+ }
+ $this->act_finish = getMicroTime();
+ $elapsed_time = $this->act_finish - $this->act_start;
+ $this->elapsed_time = $elapsed_time;
+ $GLOBALS['__db_elapsed_time__'] += $elapsed_time;
- $this->_close($connection["resource"]);
+ $log['query'] = $this->query;
+ $log['elapsed_time'] = $elapsed_time;
+ $log['connection'] = $this->connection;
- $connection["is_connected"] = FALSE;
- }
+ // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined)
+ if($this->isError())
+ {
+ $site_module_info = Context::get('site_module_info');
+ $log['module'] = $site_module_info->module;
+ $log['act'] = Context::get('act');
+ $log['query_id'] = $this->query_id;
+ $log['time'] = date('Y-m-d H:i:s');
+ $log['result'] = 'Failed';
+ $log['errno'] = $this->errno;
+ $log['errstr'] = $this->errstr;
- /**
- * DB transaction start
- * this method is protected
- * @return boolean
- */
- function _begin(){
- return TRUE;
- }
+ if(__DEBUG_DB_OUTPUT__ == 1)
+ {
+ $debug_file = _XE_PATH_ . "files/_debug_db_query.php";
+ $buff = array();
+ if(!file_exists($debug_file))
+ {
+ $buff[] = '';
+ }
+ $buff[] = print_r($log, TRUE);
- /**
- * DB transaction start
- * @return void
- */
- function begin() {
- if (!$this->isConnected() || $this->transaction_started)
- return;
+ if(@!$fp = fopen($debug_file, "a"))
+ {
+ return;
+ }
+ fwrite($fp, implode("\n", $buff) . "\n\n");
+ fclose($fp);
+ }
+ }
+ else
+ {
+ $log['result'] = 'Success';
+ }
+ $GLOBALS['__db_queries__'][] = $log;
- if($this->_begin())
- $this->transaction_started = TRUE;
- }
+ // if __LOG_SLOW_QUERY__ if defined, check elapsed time and leave query log
+ if(__LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__)
+ {
+ $buff = '';
+ $log_file = _XE_PATH_ . 'files/_db_slow_query.php';
+ if(!file_exists($log_file))
+ {
+ $buff = '' . "\n";
+ }
- /**
- * DB transaction rollback
- * this method is protected
- * @return boolean
- */
- function _rollback(){
- return TRUE;
- }
+ $buff .= sprintf("%s\t%s\n\t%0.6f sec\tquery_id:%s\n\n", date("Y-m-d H:i"), $this->query, $elapsed_time, $this->query_id);
- /**
- * DB transaction rollback
- * @return void
- */
- function rollback() {
- if (!$this->isConnected() || !$this->transaction_started)
- return;
- if($this->_rollback())
- $this->transaction_started = FALSE;
- }
+ if($fp = fopen($log_file, 'a'))
+ {
+ fwrite($fp, $buff);
+ fclose($fp);
+ }
+ }
+ }
- /**
- * DB transaction commit
- * this method is protected
- * @return boolean
- */
- function _commit(){
- return TRUE;
- }
+ /**
+ * set error
+ * @param int $errno error code
+ * @param string $errstr error message
+ * @return void
+ */
+ function setError($errno = 0, $errstr = 'success')
+ {
+ $this->errno = $errno;
+ $this->errstr = $errstr;
+ }
- /**
- * DB transaction commit
- * @param boolean $force regardless transaction start status or connect status, forced to commit
- * @return void
- */
- function commit($force = FALSE) {
- if (!$force && (!$this->isConnected() || !$this->transaction_started))
- return;
- if($this->_commit())
- $this->transaction_started = FALSE;
- }
+ /**
+ * Return error status
+ * @return boolean true: error, false: no error
+ */
+ function isError()
+ {
+ return $this->errno === 0 ? FALSE : TRUE;
+ }
- /**
- * Execute the query
- * this method is protected
- * @param string $query
- * @param resource $connection
- * @return void
- */
- function __query($query, $connection){
+ /**
+ * Returns object of error info
+ * @return object object of error
+ */
+ function getError()
+ {
+ $this->errstr = Context::convertEncodingStr($this->errstr);
+ return new Object($this->errno, $this->errstr);
+ }
- }
+ /**
+ * Execute Query that result of the query xml file
+ * This function finds xml file or cache file of $query_id, compiles it and then execute it
+ * @param string $query_id query id (module.queryname)
+ * @param array|object $args arguments for query
+ * @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns
+ * @return object result of query
+ */
+ function executeQuery($query_id, $args = NULL, $arg_columns = NULL)
+ {
+ static $cache_file = array();
- /**
- * Execute the query
- * this method is protected
- * @param string $query
- * @param resource $connection
- * @return resource
- */
- function _query($query, $connection = NULL) {
- if($connection == NULL)
- $connection = $this->_getConnection('master');
- // Notify to start a query execution
- $this->actStart($query);
+ if(!$query_id)
+ {
+ return new Object(-1, 'msg_invalid_queryid');
+ }
+ if(!$this->db_type)
+ {
+ return;
+ }
- // Run the query statement
- $result = $this->__query($query, $connection);
+ $this->actDBClassStart();
- // Notify to complete a query execution
- $this->actFinish();
- // Return result
- return $result;
- }
+ $this->query_id = $query_id;
- /**
- * DB info settings
- * this method is protected
- * @return void
- */
- function _setDBInfo(){
- $db_info = Context::getDBInfo();
- $this->master_db = $db_info->master_db;
- if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"]
- && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"]
- && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"]
- && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"]
- && $db_info->master_db["db_database"] == $db_info->slave_db[0]["db_database"]
- )
- $this->slave_db[0] = &$this->master_db;
- else
- $this->slave_db = $db_info->slave_db;
- $this->prefix = $db_info->master_db["db_table_prefix"];
- $this->use_prepared_statements = $db_info->use_prepared_statements;
- }
+ if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id]))
+ {
+ $id_args = explode('.', $query_id);
+ if(count($id_args) == 2)
+ {
+ $target = 'modules';
+ $module = $id_args[0];
+ $id = $id_args[1];
+ }
+ elseif(count($id_args) == 3)
+ {
+ $target = $id_args[0];
+ $typeList = array('addons' => 1, 'widgets' => 1);
+ if(!isset($typeList[$target]))
+ {
+ $this->actDBClassFinish();
+ return;
+ }
+ $module = $id_args[1];
+ $id = $id_args[2];
+ }
+ if(!$target || !$module || !$id)
+ {
+ $this->actDBClassFinish();
+ return new Object(-1, 'msg_invalid_queryid');
+ }
- /**
- * DB Connect
- * this method is protected
- * @param array $connection
- * @return void
- */
- function __connect($connection){
+ $xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id);
+ if(!file_exists($xml_file))
+ {
+ $this->actDBClassFinish();
+ return new Object(-1, 'msg_invalid_queryid');
+ }
- }
+ // look for cache file
+ $cache_file[$query_id] = $this->checkQueryCacheFile($query_id, $xml_file);
+ }
+ $result = $this->_executeQuery($cache_file[$query_id], $args, $query_id, $arg_columns);
- /**
- * If have a task after connection, add a taks in this method
- * this method is protected
- * @param resource $connection
- * @return void
- */
- function _afterConnect($connection){
+ $this->actDBClassFinish();
+ // execute query
+ return $result;
+ }
- }
+ /**
+ * Look for query cache file
+ * @param string $query_id query id for finding
+ * @param string $xml_file original xml query file
+ * @return string cache file
+ */
+ function checkQueryCacheFile($query_id, $xml_file)
+ {
+ // first try finding cache file
+ $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type);
- /**
- * DB Connect
- * this method is protected
- * @param string $type 'master' or 'slave'
- * @param int $indx number in slave dbms server list
- * @return void
- */
- function _connect($type = 'master', $indx = 0) {
- if ($this->isConnected($type, $indx))
- return;
+ if(file_exists($cache_file))
+ {
+ $cache_time = filemtime($cache_file);
+ }
+ else
+ {
+ $cache_time = -1;
+ }
- // Ignore if no DB information exists
- if (!$this->_dbInfoExists())
- return;
+ // if there is no cache file or is not new, find original xml query file and parse it
+ if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_ . 'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_ . 'classes/xml/XmlQueryParser.150.class.php'))
+ {
+ require_once(_XE_PATH_ . 'classes/xml/XmlQueryParser.150.class.php');
+ $oParser = new XmlQueryParser();
+ $oParser->parse($query_id, $xml_file, $cache_file);
+ }
- if ($type == 'master')
- $connection = &$this->master_db;
- else
- $connection = &$this->slave_db[$indx];
+ return $cache_file;
+ }
- $result = $this->__connect($connection);
- if($result === NULL || $result === FALSE) {
- $connection["is_connected"] = FALSE;
- return;
- }
+ /**
+ * Execute query and return the result
+ * @param string $cache_file cache file of query
+ * @param array|object $source_args arguments for query
+ * @param string $query_id query id
+ * @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns
+ * @return object result of query
+ */
+ function _executeQuery($cache_file, $source_args, $query_id, $arg_columns)
+ {
+ global $lang;
- // Check connections
- $connection["resource"] = $result;
- $connection["is_connected"] = TRUE;
+ if(!file_exists($cache_file))
+ {
+ return new Object(-1, 'msg_invalid_queryid');
+ }
- // Save connection info for db logs
- $this->connection = ucfirst($type) . ' ' . $connection["db_hostname"];
+ if($source_args)
+ {
+ $args = clone $source_args;
+ }
- $this->_afterConnect($result);
- }
+ $output = include($cache_file);
- /**
- * Start recording DBClass log
- * @return void
- */
- function actDBClassStart() {
- $this->setError(0, 'success');
- $this->act_dbclass_start = getMicroTime();
- $this->elapsed_dbclass_time = 0;
- }
+ if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool())
+ {
+ return $output;
+ }
- /**
- * Finish recording DBClass log
- * @return void
- */
- function actDBClassFinish() {
- if(!$this->query) return;
- $this->act_dbclass_finish = getMicroTime();
- $elapsed_dbclass_time = $this->act_dbclass_finish - $this->act_dbclass_start;
- $this->elapsed_dbclass_time = $elapsed_dbclass_time;
- $GLOBALS['__dbclass_elapsed_time__'] += $elapsed_dbclass_time;
- }
+ // execute appropriate query
+ switch($output->getAction())
+ {
+ case 'insert' :
+ case 'insert-select' :
+ $this->resetCountCache($output->tables);
+ $output = $this->_executeInsertAct($output);
+ break;
+ case 'update' :
+ $this->resetCountCache($output->tables);
+ $output = $this->_executeUpdateAct($output);
+ break;
+ case 'delete' :
+ $this->resetCountCache($output->tables);
+ $output = $this->_executeDeleteAct($output);
+ break;
+ case 'select' :
+ $arg_columns = is_array($arg_columns) ? $arg_columns : array();
+ $output->setColumnList($arg_columns);
+ $connection = $this->_getConnection('slave');
+ $output = $this->_executeSelectAct($output, $connection);
+ break;
+ }
- /**
- * Returns a database specific parser instance
- * used for escaping expressions and table/column identifiers
- *
- * Requires an implementation of the DB class (won't work if database is not set)
- * this method is singleton
- *
- * @param boolean $force force load DBParser instance
- * @return DBParser
- */
- function &getParser($force = FALSE){
- static $dbParser = NULL;
- if(!$dbParser || $force) {
- $oDB = &DB::getInstance();
- $dbParser = $oDB->getParser();
- }
+ if($this->isError())
+ {
+ $output = $this->getError();
+ }
+ else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object'))
+ {
+ $output = new Object();
+ }
+ $output->add('_query', $this->query);
+ $output->add('_elapsed_time', sprintf("%0.5f", $this->elapsed_time));
- return $dbParser;
- }
+ return $output;
+ }
- }
-?>
+ /**
+ * Returns counter cache data
+ * @param array|string $tables tables to get data
+ * @param string $condition condition to get data
+ * @return int count of cache data
+ */
+ function getCountCache($tables, $condition)
+ {
+ return FALSE;
+ if(!$tables)
+ {
+ return FALSE;
+ }
+ if(!is_dir($this->count_cache_path))
+ {
+ return FileHandler::makeDir($this->count_cache_path);
+ }
+
+ $condition = md5($condition);
+
+ if(!is_array($tables))
+ {
+ $tables_str = $tables;
+ }
+ else
+ {
+ $tables_str = implode('.', $tables);
+ }
+
+ $cache_path = sprintf('%s/%s%s', $this->count_cache_path, $this->prefix, $tables_str);
+ if(!is_dir($cache_path))
+ {
+ FileHandler::makeDir($cache_path);
+ }
+
+ $cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
+ if(!file_exists($cache_filename))
+ {
+ return FALSE;
+ }
+
+ $cache_mtime = filemtime($cache_filename);
+
+ if(!is_array($tables))
+ {
+ $tables = array($tables);
+ }
+ foreach($tables as $alias => $table)
+ {
+ $table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table);
+ if(!file_exists($table_filename) || filemtime($table_filename) > $cache_mtime)
+ {
+ return FALSE;
+ }
+ }
+
+ $count = (int) FileHandler::readFile($cache_filename);
+ return $count;
+ }
+
+ /**
+ * Save counter cache data
+ * @param array|string $tables tables to save data
+ * @param string $condition condition to save data
+ * @param int $count count of cache data to save
+ * @return void
+ */
+ function putCountCache($tables, $condition, $count = 0)
+ {
+ return FALSE;
+ if(!$tables)
+ {
+ return FALSE;
+ }
+ if(!is_dir($this->count_cache_path))
+ {
+ return FileHandler::makeDir($this->count_cache_path);
+ }
+
+ $condition = md5($condition);
+
+ if(!is_array($tables))
+ {
+ $tables_str = $tables;
+ }
+ else
+ {
+ $tables_str = implode('.', $tables);
+ }
+
+ $cache_path = sprintf('%s/%s%s', $this->count_cache_path, $this->prefix, $tables_str);
+ if(!is_dir($cache_path))
+ {
+ FileHandler::makeDir($cache_path);
+ }
+
+ $cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
+
+ FileHandler::writeFile($cache_filename, $count);
+ }
+
+ /**
+ * Reset counter cache data
+ * @param array|string $tables tables to reset cache data
+ * @return boolean true: success, false: failed
+ */
+ function resetCountCache($tables)
+ {
+ return FALSE;
+ if(!$tables)
+ {
+ return FALSE;
+ }
+ if(!is_dir($this->count_cache_path))
+ {
+ return FileHandler::makeDir($this->count_cache_path);
+ }
+
+ if(!is_array($tables))
+ {
+ $tables = array($tables);
+ }
+ foreach($tables as $alias => $table)
+ {
+ $filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table);
+ FileHandler::removeFile($filename);
+ FileHandler::writeFile($filename, '');
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Returns supported database list
+ * @return array list of supported database
+ */
+ function getSupportedDatabase()
+ {
+ $result = array();
+
+ if(function_exists('mysql_connect'))
+ {
+ $result[] = 'MySQL';
+ }
+ if(function_exists('cubrid_connect'))
+ {
+ $result[] = 'Cubrid';
+ }
+ if(function_exists('ibase_connect'))
+ {
+ $result[] = 'FireBird';
+ }
+ if(function_exists('pg_connect'))
+ {
+ $result[] = 'Postgre';
+ }
+ if(function_exists('sqlite_open'))
+ {
+ $result[] = 'sqlite2';
+ }
+ if(function_exists('mssql_connect'))
+ {
+ $result[] = 'MSSQL';
+ }
+ if(function_exists('PDO'))
+ {
+ $result[] = 'sqlite3(PDO)';
+ }
+
+ return $result;
+ }
+
+ /**
+ * Drop tables
+ * @param string $table_name
+ * @return void
+ */
+ function dropTable($table_name)
+ {
+ if(!$table_name)
+ {
+ return;
+ }
+ $query = sprintf("drop table %s%s", $this->prefix, $table_name);
+ $this->_query($query);
+ }
+
+ /**
+ * Return select query string
+ * @param object $query
+ * @param boolean $with_values
+ * @return string
+ */
+ function getSelectSql($query, $with_values = TRUE)
+ {
+ $select = $query->getSelectString($with_values);
+ if($select == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $select = 'SELECT ' . $select;
+
+ $from = $query->getFromString($with_values);
+ if($from == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $from = ' FROM ' . $from;
+
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $where = ' WHERE ' . $where;
+ }
+
+ $tableObjects = $query->getTables();
+ $index_hint_list = '';
+ foreach($tableObjects as $tableObject)
+ {
+ if(is_a($tableObject, 'CubridTableWithHint'))
+ {
+ $index_hint_list .= $tableObject->getIndexHintString() . ', ';
+ }
+ }
+ $index_hint_list = substr($index_hint_list, 0, -2);
+ if($index_hint_list != '')
+ {
+ $index_hint_list = 'USING INDEX ' . $index_hint_list;
+ }
+
+ $groupBy = $query->getGroupByString();
+ if($groupBy != '')
+ {
+ $groupBy = ' GROUP BY ' . $groupBy;
+ }
+
+ $orderBy = $query->getOrderByString();
+ if($orderBy != '')
+ {
+ $orderBy = ' ORDER BY ' . $orderBy;
+ }
+
+ $limit = $query->getLimitString();
+ if($limit != '')
+ {
+ $limit = ' LIMIT ' . $limit;
+ }
+
+ return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
+ }
+
+ /**
+ * Given a SELECT statement that uses click count
+ * returns the corresponding update sql string
+ * for databases that don't have click count support built in
+ * (aka all besides CUBRID)
+ *
+ * Function does not check if click count columns exist!
+ * You must call $query->usesClickCount() before using this function
+ *
+ * @param $queryObject
+ */
+ function getClickCountQuery($queryObject)
+ {
+ $new_update_columns = array();
+ $click_count_columns = $queryObject->getClickCountColumns();
+ foreach($click_count_columns as $click_count_column)
+ {
+ $click_count_column_name = $click_count_column->column_name;
+
+ $increase_by_1 = new Argument($click_count_column_name, null);
+ $increase_by_1->setColumnOperation('+');
+ $increase_by_1->ensureDefaultValue(1);
+
+ $update_expression = new UpdateExpression($click_count_column_name, $increase_by_1);
+ $new_update_columns[] = $update_expression;
+ }
+ $queryObject->columns = $new_update_columns;
+ return $queryObject;
+ }
+
+ /**
+ * Return delete query string
+ * @param object $query
+ * @param boolean $with_values
+ * @param boolean $with_priority
+ * @return string
+ */
+ function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE)
+ {
+ $sql = 'DELETE ';
+
+ $sql .= $with_priority ? $query->getPriority() : '';
+ $tables = $query->getTables();
+
+ $sql .= $tables[0]->getAlias();
+
+ $from = $query->getFromString($with_values);
+ if($from == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $sql .= ' FROM ' . $from;
+
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $sql .= ' WHERE ' . $where;
+ }
+
+ return $sql;
+ }
+
+ /**
+ * Return update query string
+ * @param object $query
+ * @param boolean $with_values
+ * @param boolean $with_priority
+ * @return string
+ */
+ function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE)
+ {
+ $columnsList = $query->getUpdateString($with_values);
+ if($columnsList == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+
+ $tables = $query->getFromString($with_values);
+ if($tables == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $where = ' WHERE ' . $where;
+ }
+
+ $priority = $with_priority ? $query->getPriority() : '';
+
+ return "UPDATE $priority $tables SET $columnsList " . $where;
+ }
+
+ /**
+ * Return insert query string
+ * @param object $query
+ * @param boolean $with_values
+ * @param boolean $with_priority
+ * @return string
+ */
+ function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE)
+ {
+ $tableName = $query->getFirstTableName();
+ $values = $query->getInsertString($with_values);
+ $priority = $with_priority ? $query->getPriority() : '';
+
+ return "INSERT $priority INTO $tableName \n $values";
+ }
+
+ /**
+ * Return index from slave server list
+ * @return int
+ */
+ function _getSlaveConnectionStringIndex()
+ {
+ $max = count($this->slave_db);
+ $indx = rand(0, $max - 1);
+ return $indx;
+ }
+
+ /**
+ * Return connection resource
+ * @param string $type use 'master' or 'slave'. default value is 'master'
+ * @param int $indx if indx value is NULL, return rand number in slave server list
+ * @return resource
+ */
+ function _getConnection($type = 'master', $indx = NULL)
+ {
+ if($type == 'master')
+ {
+ if(!$this->master_db['is_connected'])
+ {
+ $this->_connect($type);
+ }
+ $this->connection = 'Master ' . $this->master_db['db_hostname'];
+ return $this->master_db["resource"];
+ }
+
+ if($indx === NULL)
+ {
+ $indx = $this->_getSlaveConnectionStringIndex($type);
+ }
+
+ if(!$this->slave_db[$indx]['is_connected'])
+ {
+ $this->_connect($type, $indx);
+ }
+
+ $this->connection = 'Slave ' . $this->slave_db[$indx]['db_hostname'];
+ return $this->slave_db[$indx]["resource"];
+ }
+
+ /**
+ * check db information exists
+ * @return boolean
+ */
+ function _dbInfoExists()
+ {
+ if(!$this->master_db)
+ {
+ return FALSE;
+ }
+ if(count($this->slave_db) === 0)
+ {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * DB disconnection
+ * this method is protected
+ * @param resource $connection
+ * @return void
+ */
+ function _close($connection)
+ {
+
+ }
+
+ /**
+ * DB disconnection
+ * @param string $type 'master' or 'slave'
+ * @param int $indx number in slave dbms server list
+ * @return void
+ */
+ function close($type = 'master', $indx = 0)
+ {
+ if(!$this->isConnected($type, $indx))
+ {
+ return;
+ }
+
+ if($type == 'master')
+ {
+ $connection = &$this->master_db;
+ }
+ else
+ {
+ $connection = &$this->slave_db[$indx];
+ }
+
+ $this->_close($connection["resource"]);
+
+ $connection["is_connected"] = FALSE;
+ }
+
+ /**
+ * DB transaction start
+ * this method is protected
+ * @return boolean
+ */
+ function _begin()
+ {
+ return TRUE;
+ }
+
+ /**
+ * DB transaction start
+ * @return void
+ */
+ function begin()
+ {
+ if(!$this->isConnected())
+ {
+ return;
+ }
+
+ if($this->_begin($this->transationNestedLevel))
+ {
+ $this->transaction_started = TRUE;
+ $this->transationNestedLevel++;
+ }
+ }
+
+ /**
+ * DB transaction rollback
+ * this method is protected
+ * @return boolean
+ */
+ function _rollback()
+ {
+ return TRUE;
+ }
+
+ /**
+ * DB transaction rollback
+ * @return void
+ */
+ function rollback()
+ {
+ if(!$this->isConnected() || !$this->transaction_started)
+ {
+ return;
+ }
+ if($this->_rollback($this->transationNestedLevel))
+ {
+ $this->transationNestedLevel--;
+
+ if(!$this->transationNestedLevel)
+ {
+ $this->transaction_started = FALSE;
+ }
+ }
+ }
+
+ /**
+ * DB transaction commit
+ * this method is protected
+ * @return boolean
+ */
+ function _commit()
+ {
+ return TRUE;
+ }
+
+ /**
+ * DB transaction commit
+ * @param boolean $force regardless transaction start status or connect status, forced to commit
+ * @return void
+ */
+ function commit($force = FALSE)
+ {
+ if(!$force && (!$this->isConnected() || !$this->transaction_started))
+ {
+ return;
+ }
+ if($this->transationNestedLevel == 1 && $this->_commit())
+ {
+ $this->transaction_started = FALSE;
+ $this->transationNestedLevel = 0;
+ }
+ else
+ {
+ $this->transationNestedLevel--;
+ }
+ }
+
+ /**
+ * Execute the query
+ * this method is protected
+ * @param string $query
+ * @param resource $connection
+ * @return void
+ */
+ function __query($query, $connection)
+ {
+
+ }
+
+ /**
+ * Execute the query
+ * this method is protected
+ * @param string $query
+ * @param resource $connection
+ * @return resource
+ */
+ function _query($query, $connection = NULL)
+ {
+ if($connection == NULL)
+ {
+ $connection = $this->_getConnection('master');
+ }
+ // Notify to start a query execution
+ $this->actStart($query);
+
+ // Run the query statement
+ $result = $this->__query($query, $connection);
+
+ // Notify to complete a query execution
+ $this->actFinish();
+ // Return result
+ return $result;
+ }
+
+ /**
+ * DB info settings
+ * this method is protected
+ * @return void
+ */
+ function _setDBInfo()
+ {
+ $db_info = Context::getDBInfo();
+ $this->master_db = $db_info->master_db;
+ if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"]
+ && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"]
+ && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"]
+ && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"]
+ && $db_info->master_db["db_database"] == $db_info->slave_db[0]["db_database"]
+ )
+ {
+ $this->slave_db[0] = &$this->master_db;
+ }
+ else
+ {
+ $this->slave_db = $db_info->slave_db;
+ }
+ $this->prefix = $db_info->master_db["db_table_prefix"];
+ $this->use_prepared_statements = $db_info->use_prepared_statements;
+ }
+
+ /**
+ * DB Connect
+ * this method is protected
+ * @param array $connection
+ * @return void
+ */
+ function __connect($connection)
+ {
+
+ }
+
+ /**
+ * If have a task after connection, add a taks in this method
+ * this method is protected
+ * @param resource $connection
+ * @return void
+ */
+ function _afterConnect($connection)
+ {
+
+ }
+
+ /**
+ * DB Connect
+ * this method is protected
+ * @param string $type 'master' or 'slave'
+ * @param int $indx number in slave dbms server list
+ * @return void
+ */
+ function _connect($type = 'master', $indx = 0)
+ {
+ if($this->isConnected($type, $indx))
+ {
+ return;
+ }
+
+ // Ignore if no DB information exists
+ if(!$this->_dbInfoExists())
+ {
+ return;
+ }
+
+ if($type == 'master')
+ {
+ $connection = &$this->master_db;
+ }
+ else
+ {
+ $connection = &$this->slave_db[$indx];
+ }
+
+ $result = $this->__connect($connection);
+ if($result === NULL || $result === FALSE)
+ {
+ $connection["is_connected"] = FALSE;
+ return;
+ }
+
+ // Check connections
+ $connection["resource"] = $result;
+ $connection["is_connected"] = TRUE;
+
+ // Save connection info for db logs
+ $this->connection = ucfirst($type) . ' ' . $connection["db_hostname"];
+
+ $this->_afterConnect($result);
+ }
+
+ /**
+ * Start recording DBClass log
+ * @return void
+ */
+ function actDBClassStart()
+ {
+ $this->setError(0, 'success');
+ $this->act_dbclass_start = getMicroTime();
+ $this->elapsed_dbclass_time = 0;
+ }
+
+ /**
+ * Finish recording DBClass log
+ * @return void
+ */
+ function actDBClassFinish()
+ {
+ if(!$this->query)
+ {
+ return;
+ }
+ $this->act_dbclass_finish = getMicroTime();
+ $elapsed_dbclass_time = $this->act_dbclass_finish - $this->act_dbclass_start;
+ $this->elapsed_dbclass_time = $elapsed_dbclass_time;
+ $GLOBALS['__dbclass_elapsed_time__'] += $elapsed_dbclass_time;
+ }
+
+ /**
+ * Returns a database specific parser instance
+ * used for escaping expressions and table/column identifiers
+ *
+ * Requires an implementation of the DB class (won't work if database is not set)
+ * this method is singleton
+ *
+ * @param boolean $force force load DBParser instance
+ * @return DBParser
+ */
+ function &getParser($force = FALSE)
+ {
+ static $dbParser = NULL;
+ if(!$dbParser || $force)
+ {
+ $oDB = DB::getInstance();
+ $dbParser = $oDB->getParser();
+ }
+
+ return $dbParser;
+ }
+
+}
+/* End of file DB.class.php */
+/* Location: ./classes/db/DB.class.php */
diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php
index 8debbbcd3..4a4b26f53 100644
--- a/classes/db/DBCubrid.class.php
+++ b/classes/db/DBCubrid.class.php
@@ -1,241 +1,263 @@
'numeric(20)',
+ 'number' => 'integer',
+ 'varchar' => 'character varying',
+ 'char' => 'character',
+ 'tinytext' => 'character varying(256)',
+ 'text' => 'character varying(1073741823)',
+ 'bigtext' => 'character varying(1073741823)',
+ 'date' => 'character varying(14)',
+ 'float' => 'float',
+ );
+
+ /**
+ * constructor
+ * @return void
+ */
+ function DBCubrid()
{
+ $this->_setDBInfo();
+ $this->_connect();
+ }
- /**
- * prefix of XE tables(One more XE can be installed on a single DB)
- * @var string
- */
- var $prefix = 'xe_';
- /**
- * max size of constant in CUBRID(if string is larger than this, '...'+'...' should be used)
- * @var int
- */
- var $cutlen = 12000;
- var $comment_syntax = '/* %s */';
+ /**
+ * Create an instance of this class
+ * @return DBCubrid return DBCubrid object instance
+ */
+ function create()
+ {
+ return new DBCubrid;
+ }
- /**
- * column type used in CUBRID
- *
- * column_type should be replaced for each DBMS's type
- * becasue it uses commonly defined type in the schema/query xml
- * @var array
- **/
- var $column_type = array(
- 'bignumber' => 'numeric(20)',
- 'number' => 'integer',
- 'varchar' => 'character varying',
- 'char' => 'character',
- 'tinytext' => 'character varying(256)',
- 'text' => 'character varying(1073741823)',
- 'bigtext' => 'character varying(1073741823)',
- 'date' => 'character varying(14)',
- 'float' => 'float',
- );
-
- /**
- * constructor
- * @return void
- */
- function DBCubrid()
+ /**
+ * Return if supportable
+ * Check 'cubrid_connect' function exists.
+ * @return boolean
+ */
+ function isSupported()
+ {
+ if(!function_exists('cubrid_connect'))
{
- $this->_setDBInfo();
- $this->_connect();
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * DB Connect
+ * this method is private
+ * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
+ * @return resource
+ */
+ function __connect($connection)
+ {
+ // attempts to connect
+ $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]);
+
+ // check connections
+ if(!$result)
+ {
+ $this->setError(-1, 'database connect fail');
+ return;
}
- /**
- * Create an instance of this class
- * @return DBCubrid return DBCubrid object instance
- */
- function create()
+ if(!defined('__CUBRID_VERSION__'))
{
- return new DBCubrid;
+ $cubrid_version = cubrid_get_server_info($result);
+ $cubrid_version_elem = explode('.', $cubrid_version);
+ $cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2];
+ define('__CUBRID_VERSION__', $cubrid_version);
}
- /**
- * Return if supportable
- * Check 'cubrid_connect' function exists.
- * @return boolean
- */
- function isSupported()
+ if(__CUBRID_VERSION__ >= '8.4.0')
+ cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE);
+
+ return $result;
+ }
+
+ /**
+ * DB disconnection
+ * this method is private
+ * @param resource $connection
+ * @return void
+ */
+ function _close($connection)
+ {
+ @cubrid_commit($connection);
+ @cubrid_disconnect($connection);
+ $this->transaction_started = FALSE;
+ }
+
+ /**
+ * Handles quatation of the string variables from the query
+ * @param string $string
+ * @return string
+ */
+ function addQuotes($string)
+ {
+ if(version_compare(PHP_VERSION, "5.9.0", "<") &&
+ get_magic_quotes_gpc())
{
- if (!function_exists('cubrid_connect')) return FALSE;
- return TRUE;
+ $string = stripslashes(str_replace("\\", "\\\\", $string));
}
- /**
- * DB Connect
- * this method is private
- * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
- * @return resource
- */
- function __connect($connection)
+ if(!is_numeric($string))
{
- // attempts to connect
- $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]);
-
- // check connections
- if (!$result) {
- $this->setError (-1, 'database connect fail');
- return;
- }
-
- if(!defined('__CUBRID_VERSION__')) {
- $cubrid_version = cubrid_get_server_info($result);
- $cubrid_version_elem = explode('.', $cubrid_version);
- $cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2];
- define('__CUBRID_VERSION__', $cubrid_version);
- }
-
- if(__CUBRID_VERSION__ >= '8.4.0')
- cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE);
-
- return $result;
- }
-
- /**
- * DB disconnection
- * this method is private
- * @param resource $connection
- * @return void
- */
- function _close($connection)
- {
- @cubrid_commit ($connection);
- @cubrid_disconnect ($connection);
- $this->transaction_started = FALSE;
- }
-
- /**
- * Handles quatation of the string variables from the query
- * @param string $string
- * @return string
- */
- function addQuotes($string)
- {
- if (version_compare (PHP_VERSION, "5.9.0", "<") &&
- get_magic_quotes_gpc ()) {
- $string = stripslashes (str_replace ("\\","\\\\", $string));
- }
-
- if (!is_numeric ($string)) {
/*
- if ($this->isConnected()) {
- $string = cubrid_real_escape_string($string);
- }
- else {
- $string = str_replace("'","\'",$string);
- }
- */
+ if ($this->isConnected()) {
+ $string = cubrid_real_escape_string($string);
+ }
+ else {
+ $string = str_replace("'","\'",$string);
+ }
+ */
- $string = str_replace("'","''",$string);
- }
-
- return $string;
+ $string = str_replace("'", "''", $string);
}
- /**
- * DB transaction start
- * this method is private
- * @return boolean
- */
- function _begin()
- {
- if(__CUBRID_VERSION__ >= '8.4.0')
- {
- $connection = $this->_getConnection('master');
- cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE);
- }
- return TRUE;
- }
+ return $string;
+ }
- /**
- * DB transaction rollback
- * this method is private
- * @return boolean
- */
- function _rollback()
- {
- $connection = $this->_getConnection('master');
- @cubrid_rollback ($connection);
- return TRUE;
- }
-
- /**
- * DB transaction commit
- * this method is private
- * @return boolean
- */
- function _commit()
+ /**
+ * DB transaction start
+ * this method is private
+ * @return boolean
+ */
+ function _begin($transactionLevel)
+ {
+ if(__CUBRID_VERSION__ >= '8.4.0')
{
$connection = $this->_getConnection('master');
- @cubrid_commit($connection);
- return TRUE;
+
+ if(!$transactionLevel)
+ {
+ cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE);
+ }
+ else
+ {
+ $this->_query("SAVEPOINT SP" . $transactionLevel, $connection);
+ }
+ }
+ return TRUE;
+ }
+
+ /**
+ * DB transaction rollback
+ * this method is private
+ * @return boolean
+ */
+ function _rollback($transactionLevel)
+ {
+ $connection = $this->_getConnection('master');
+
+ $point = $transactionLevel - 1;
+
+ if($point)
+ {
+ $this->_query("ROLLBACK TO SP" . $point, $connection);
+ }
+ else
+ {
+ @cubrid_rollback($connection);
}
- /**
- * Execute the query
- * this method is private
- * @param string $query
- * @param resource $connection
- * @return resource
- */
- function __query($query, $connection)
+ return TRUE;
+ }
+
+ /**
+ * DB transaction commit
+ * this method is private
+ * @return boolean
+ */
+ function _commit()
+ {
+ $connection = $this->_getConnection('master');
+ @cubrid_commit($connection);
+ return TRUE;
+ }
+
+ /**
+ * Execute the query
+ * this method is private
+ * @param string $query
+ * @param resource $connection
+ * @return resource
+ */
+ function __query($query, $connection)
+ {
+ if($this->use_prepared_statements == 'Y')
{
- if($this->use_prepared_statements == 'Y')
+ $req = @cubrid_prepare($connection, $query);
+ if(!$req)
{
- $req = @cubrid_prepare($connection, $query);
- if(!$req)
- {
- $this->_setError();
- return false;
- }
+ $this->_setError();
+ return false;
+ }
- $position = 0;
- if($this->param)
+ $position = 0;
+ if($this->param)
+ {
+ foreach($this->param as $param)
{
- foreach($this->param as $param)
+ $value = $param->getUnescapedValue();
+ $type = $param->getType();
+
+ if($param->isColumnName())
{
- $value = $param->getUnescapedValue();
- $type = $param->getType();
-
- if($param->isColumnName()) continue;
+ continue;
+ }
- switch($type)
- {
- case 'number' :
- $bind_type = 'numeric';
- break;
- case 'varchar' :
- $bind_type = 'string';
- break;
- default:
- $bind_type = 'string';
- }
+ switch($type)
+ {
+ case 'number' :
+ $bind_type = 'numeric';
+ break;
+ case 'varchar' :
+ $bind_type = 'string';
+ break;
+ default:
+ $bind_type = 'string';
+ }
- if(is_array($value)){
- foreach($value as $v)
- {
- $bound = @cubrid_bind($req, ++$position, $v, $bind_type);
- if(!$bound)
- {
- $this->_setError();
- return false;
- }
- }
- }
- else
+ if(is_array($value))
+ {
+ foreach($value as $v)
{
- $bound = @cubrid_bind($req, ++$position, $value, $bind_type);
+ $bound = @cubrid_bind($req, ++$position, $v, $bind_type);
if(!$bound)
{
$this->_setError();
@@ -243,764 +265,929 @@
}
}
}
+ else
+ {
+ $bound = @cubrid_bind($req, ++$position, $value, $bind_type);
+ if(!$bound)
+ {
+ $this->_setError();
+ return false;
+ }
+ }
}
-
- $result = @cubrid_execute($req);
- if(!$result)
- {
- $this->_setError();
- return false;
- }
- return $req;
-
}
- // Execute the query
- $result = @cubrid_execute ($connection, $query);
- // error check
- if (!$result) {
+
+ $result = @cubrid_execute($req);
+ if(!$result)
+ {
$this->_setError();
return false;
}
- // Return the result
- return $result;
+ return $req;
+ }
+ // Execute the query
+ $result = @cubrid_execute($connection, $query);
+ // error check
+ if(!$result)
+ {
+ $this->_setError();
+ return false;
+ }
+ // Return the result
+ return $result;
+ }
+
+ /**
+ * Retrieve CUBRID error and set to object
+ *
+ * @author Corina Udrescu (dev@xpressengine.org)
+ */
+ function _setError()
+ {
+ $code = cubrid_error_code();
+ $msg = cubrid_error_msg();
+
+ $this->setError($code, $msg);
+ }
+
+ /**
+ * Fetch the result
+ * @param resource $result
+ * @param int|NULL $arrayIndexEndValue
+ * @return array
+ */
+ function _fetch($result, $arrayIndexEndValue = NULL)
+ {
+ $output = array();
+ if(!$this->isConnected() || $this->isError() || !$result)
+ {
+ return array();
}
- /**
- * Retrieve CUBRID error and set to object
- *
- * @author Corina Udrescu (dev@xpressengine.org)
- */
- function _setError()
+ if($this->use_prepared_statements == 'Y')
{
- $code = cubrid_error_code ();
- $msg = cubrid_error_msg ();
- $this->setError ($code, $msg);
}
- /**
- * Fetch the result
- * @param resource $result
- * @param int|NULL $arrayIndexEndValue
- * @return array
- */
- function _fetch($result, $arrayIndexEndValue = NULL)
- {
- $output = array();
- if (!$this->isConnected() || $this->isError() || !$result) return array();
+ // TODO Improve this piece of code
+ // This code trims values from char type columns
+ $col_types = cubrid_column_types($result);
+ $col_names = cubrid_column_names($result);
+ $max = count($col_types);
- if($this->use_prepared_statements == 'Y')
+ for($count = 0; $count < $max; $count++)
+ {
+ if(preg_match("/^char/", $col_types[$count]) > 0)
{
-
+ $char_type_fields[] = $col_names[$count];
}
-
- // TODO Improve this piece of code
- // This code trims values from char type columns
- $col_types = cubrid_column_types ($result);
- $col_names = cubrid_column_names ($result);
- $max = count ($col_types);
-
- for ($count = 0; $count < $max; $count++) {
- if (preg_match ("/^char/", $col_types[$count]) > 0) {
- $char_type_fields[] = $col_names[$count];
- }
- }
-
- while ($tmp = cubrid_fetch ($result, CUBRID_OBJECT)) {
- if (is_array ($char_type_fields)) {
- foreach ($char_type_fields as $val) {
- $tmp->{$val} = rtrim ($tmp->{$val});
- }
- }
-
- if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $tmp;
- else $output[] = $tmp;
- }
-
- unset ($char_type_fields);
-
- if ($result) cubrid_close_request($result);
-
- if(count($output)==1){
- // If call is made for pagination, always return array
- if(isset($arrayIndexEndValue)) return $output;
- // Else return object instead of array
- else return $output[0];
- }
- return $output;
}
- /**
- * Return the sequence value incremented by 1
- * Auto_increment column only used in the CUBRID sequence table
- * @return int
- */
- function getNextSequence()
+ while($tmp = cubrid_fetch($result, CUBRID_OBJECT))
{
- $this->_makeSequence();
+ if(is_array($char_type_fields))
+ {
+ foreach($char_type_fields as $val)
+ {
+ $tmp->{$val} = rtrim($tmp->{$val});
+ }
+ }
+
+ if($arrayIndexEndValue)
+ {
+ $output[$arrayIndexEndValue--] = $tmp;
+ }
+ else
+ {
+ $output[] = $tmp;
+ }
+ }
+
+ unset($char_type_fields);
+
+ if($result)
+ {
+ cubrid_close_request($result);
+ }
+
+ if(count($output) == 1)
+ {
+ // If call is made for pagination, always return array
+ if(isset($arrayIndexEndValue))
+ {
+ return $output;
+ }
+ // Else return object instead of array
+ else
+ {
+ return $output[0];
+ }
+ }
+ return $output;
+ }
+
+ /**
+ * Return the sequence value incremented by 1
+ * Auto_increment column only used in the CUBRID sequence table
+ * @return int
+ */
+ function getNextSequence()
+ {
+ $this->_makeSequence();
+
+ $query = sprintf("select \"%ssequence\".\"nextval\" as \"seq\" from db_root", $this->prefix);
+ $result = $this->_query($query);
+ $output = $this->_fetch($result);
+
+ return $output->seq;
+ }
+
+ /**
+ * if the table already exists, set the status to GLOBALS
+ * @return void
+ */
+ function _makeSequence()
+ {
+ if($_GLOBALS['XE_EXISTS_SEQUENCE'])
+ return;
+
+ // check cubrid serial
+ $query = sprintf('select count(*) as "count" from "db_serial" where name=\'%ssequence\'', $this->prefix);
+ $result = $this->_query($query);
+ $output = $this->_fetch($result);
+
+ // if do not create serial
+ if($output->count == 0)
+ {
+ $query = sprintf('select max("a"."srl") as "srl" from ' .
+ '( select max("document_srl") as "srl" from ' .
+ '"%sdocuments" UNION ' .
+ 'select max("comment_srl") as "srl" from ' .
+ '"%scomments" UNION ' .
+ 'select max("member_srl") as "srl" from ' .
+ '"%smember"' .
+ ') as "a"', $this->prefix, $this->prefix, $this->prefix);
- $query = sprintf ("select \"%ssequence\".\"nextval\" as \"seq\" from db_root", $this->prefix);
$result = $this->_query($query);
$output = $this->_fetch($result);
-
- return $output->seq;
- }
-
- /**
- * if the table already exists, set the status to GLOBALS
- * @return void
- */
- function _makeSequence()
- {
- if($_GLOBALS['XE_EXISTS_SEQUENCE']) return;
-
- // check cubrid serial
- $query = sprintf('select count(*) as "count" from "db_serial" where name=\'%ssequence\'', $this->prefix);
- $result = $this->_query($query);
- $output = $this->_fetch($result);
-
- // if do not create serial
- if ($output->count == 0) {
- $query = sprintf('select max("a"."srl") as "srl" from '.
- '( select max("document_srl") as "srl" from '.
- '"%sdocuments" UNION '.
- 'select max("comment_srl") as "srl" from '.
- '"%scomments" UNION '.
- 'select max("member_srl") as "srl" from '.
- '"%smember"'.
- ') as "a"', $this->prefix, $this->prefix, $this->prefix);
-
- $result = $this->_query($query);
- $output = $this->_fetch($result);
- $srl = $output->srl;
- if ($srl < 1) {
- $start = 1;
- }
- else {
- $start = $srl + 1000000;
- }
-
- // create sequence
- $query = sprintf('create serial "%ssequence" start with %s increment by 1 minvalue 1 maxvalue 10000000000000000000000000000000000000 nocycle;', $this->prefix, $start);
- $this->_query($query);
+ $srl = $output->srl;
+ if($srl < 1)
+ {
+ $start = 1;
+ }
+ else
+ {
+ $start = $srl + 1000000;
}
- $_GLOBALS['XE_EXISTS_SEQUENCE'] = TRUE;
- }
-
-
- /**
- * Check a table exists status
- * @param string $target_name
- * @return boolean
- */
- function isTableExists ($target_name)
- {
- if($target_name == 'sequence') {
- $query = sprintf ("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name);
- }
- else {
- $query = sprintf ("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name);
- }
-
- $result = $this->_query ($query);
- if (cubrid_num_rows($result) > 0) {
- $output = TRUE;
- }
- else {
- $output = FALSE;
- }
-
- if ($result) cubrid_close_request ($result);
-
- return $output;
- }
-
- /**
- * Add a column to the table
- * @param string $table_name table name
- * @param string $column_name column name
- * @param string $type column type, default value is 'number'
- * @param int $size column size
- * @param string|int $default default value
- * @param boolean $notnull not null status, default value is false
- * @return void
- */
- function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = FALSE)
- {
- $type = strtoupper($this->column_type[$type]);
- if ($type == 'INTEGER') $size = '';
-
- $query = sprintf ("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name);
-
- if ($type == 'char' || $type == 'varchar') {
- if ($size) $size = $size * 3;
- }
-
- if ($size) {
- $query .= sprintf ("%s(%s) ", $type, $size);
- }
- else {
- $query .= sprintf ("%s ", $type);
- }
-
- if ($default) {
- if ($type == 'INTEGER' || $type == 'BIGINT' || $type=='INT') {
- $query .= sprintf ("default %d ", $default);
- }
- else {
- $query .= sprintf ("default '%s' ", $default);
- }
- }
-
- if ($notnull) $query .= "not null ";
-
- return $this->_query ($query);
- }
-
- /**
- * Drop a column from the table
- * @param string $table_name table name
- * @param string $column_name column name
- * @return void
- */
- function dropColumn ($table_name, $column_name)
- {
- $query = sprintf ("alter class \"%s%s\" drop \"%s\" ", $this->prefix, $table_name, $column_name);
-
- $this->_query ($query);
- }
-
- /**
- * Check column exist status of the table
- * @param string $table_name table name
- * @param string $column_name column name
- * @return boolean
- */
- function isColumnExists ($table_name, $column_name)
- {
- $query = sprintf ("select \"attr_name\" from \"db_attribute\" where ". "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name);
- $result = $this->_query ($query);
-
- if (cubrid_num_rows ($result) > 0) $output = TRUE;
- else $output = FALSE;
-
- if ($result) cubrid_close_request ($result);
-
- return $output;
- }
-
- /**
- * Add an index to the table
- * $target_columns = array(col1, col2)
- * $is_unique? unique : none
- * @param string $table_name table name
- * @param string $index_name index name
- * @param string|array $target_columns target column or columns
- * @param boolean $is_unique
- * @return void
- */
- function addIndex ($table_name, $index_name, $target_columns, $is_unique = FALSE)
- {
- if (!is_array ($target_columns)) {
- $target_columns = array ($target_columns);
- }
-
- $query = sprintf ("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique?'unique':'', $index_name, $this->prefix, $table_name, '"'.implode('","',$target_columns).'"');
-
- $this->_query ($query);
- }
-
- /**
- * Drop an index from the table
- * @param string $table_name table name
- * @param string $index_name index name
- * @param boolean $is_unique
- * @return void
- */
- function dropIndex ($table_name, $index_name, $is_unique = FALSE)
- {
- $query = sprintf ("drop %s index \"%s\" on \"%s%s\"", $is_unique?'unique':'', $index_name, $this->prefix, $table_name);
-
+ // create sequence
+ $query = sprintf('create serial "%ssequence" start with %s increment by 1 minvalue 1 maxvalue 10000000000000000000000000000000000000 nocycle;', $this->prefix, $start);
$this->_query($query);
}
- /**
- * Check index status of the table
- * @param string $table_name table name
- * @param string $index_name index name
- * @return boolean
- */
- function isIndexExists ($table_name, $index_name)
+ $_GLOBALS['XE_EXISTS_SEQUENCE'] = TRUE;
+ }
+
+ /**
+ * Check a table exists status
+ * @param string $target_name
+ * @return boolean
+ */
+ function isTableExists($target_name)
+ {
+ if($target_name == 'sequence')
{
- $query = sprintf ("select \"index_name\" from \"db_index\" where ". "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix .$index_name, $index_name);
- $result = $this->_query ($query);
-
- if ($this->isError ()) return FALSE;
-
- $output = $this->_fetch ($result);
-
- if (!$output) return FALSE;
- return TRUE;
+ $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name);
+ }
+ else
+ {
+ $query = sprintf("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name);
}
- /**
- * Delete duplicated index of the table
- * @return boolean
- */
- function deleteDuplicateIndexes()
- {
- $query = sprintf("
- select \"class_name\"
- , case
- when substr(\"index_name\", 0, %d) = '%s'
- then substr(\"index_name\", %d)
- else \"index_name\" end as unprefixed_index_name
- , \"is_unique\"
- from \"db_index\"
- where \"class_name\" like %s
- group by \"class_name\"
- , case
- when substr(\"index_name\", 0, %d) = '%s'
- then substr(\"index_name\", %d)
- else \"index_name\"
- end
- having count(*) > 1
- ", strlen($this->prefix)
- , $this->prefix
- , strlen($this->prefix) + 1
- , "'" . $this->prefix . '%' . "'"
- , strlen($this->prefix)
- , $this->prefix
- , strlen($this->prefix) + 1
- );
- $result = $this->_query ($query);
-
- if ($this->isError ()) return FALSE;
-
- $output = $this->_fetch ($result);
- if (!$output) return FALSE;
-
- if(!is_array($output)) {
- $indexes_to_be_deleted = array($output);
- }
- else {
- $indexes_to_be_deleted = $output;
- }
-
- foreach($indexes_to_be_deleted as $index)
- {
- $this->dropIndex(substr($index->class_name, strlen($this->prefix))
- , $this->prefix . $index->unprefixed_index_name
- , $index->is_unique == 'YES' ? TRUE : FALSE);
- }
-
- return TRUE;
- }
-
- /**
- * Creates a table by using xml contents
- * @param string $xml_doc xml schema contents
- * @return void|object
- */
- function createTableByXml ($xml_doc)
+ $result = $this->_query($query);
+ if(cubrid_num_rows($result) > 0)
{
- return $this->_createTable ($xml_doc);
+ $output = TRUE;
+ }
+ else
+ {
+ $output = FALSE;
}
- /**
- * Creates a table by using xml file path
- * @param string $file_name xml schema file path
- * @return void|object
- */
- function createTableByXmlFile ($file_name)
+ if($result)
{
- if (!file_exists ($file_name)) return;
- // read xml file
- $buff = FileHandler::readFile ($file_name);
- return $this->_createTable ($buff);
+ cubrid_close_request($result);
}
- /**
- * Create table by using the schema xml
- *
- * type : number, varchar, tinytext, text, bigtext, char, date, \n
- * opt : notnull, default, size\n
- * index : primary key, index, unique\n
- * @param string $xml_doc xml schema contents
- * @return void|object
- */
- function _createTable ($xml_doc)
+ return $output;
+ }
+
+ /**
+ * Add a column to the table
+ * @param string $table_name table name
+ * @param string $column_name column name
+ * @param string $type column type, default value is 'number'
+ * @param int $size column size
+ * @param string|int $default default value
+ * @param boolean $notnull not null status, default value is false
+ * @return void
+ */
+ function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = FALSE)
+ {
+ $type = strtoupper($this->column_type[$type]);
+ if($type == 'INTEGER')
{
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
-
- // if the table already exists exit function
- if ($this->isTableExists($table_name)) return;
-
- // If the table name is sequence, it creates a serial
- if ($table_name == 'sequence') {
- $query = sprintf ('create serial "%s" start with 1 increment by 1'.
- ' minvalue 1 '.
- 'maxvalue 10000000000000000000000000000000000000'. ' nocycle;', $this->prefix.$table_name);
-
- return $this->_query($query);
- }
-
-
- $table_name = $this->prefix.$table_name;
-
- $query = sprintf ('create class "%s";', $table_name);
- $this->_query ($query);
-
- if (!is_array ($xml_obj->table->column)) {
- $columns[] = $xml_obj->table->column;
- }
- else {
- $columns = $xml_obj->table->column;
- }
-
- $query = sprintf ("alter class \"%s\" add attribute ", $table_name);
-
- $primary_list = array();
- $unique_list = array();
- $index_list = array();
-
- foreach ($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
-
- switch ($this->column_type[$type]) {
- case 'integer' :
- $size = NULL;
- break;
- case 'text' :
- $size = NULL;
- break;
- }
-
- if (isset ($default) && ($type == 'varchar' || $type == 'char' ||
- $type == 'text' || $type == 'tinytext' || $type == 'bigtext')) {
- $default = sprintf ("'%s'", $default);
- }
-
- if ($type == 'varchar' || $type == 'char') {
- if($size) $size = $size * 3;
- }
-
-
- $column_schema[] = sprintf ('"%s" %s%s %s %s',
- $name,
- $this->column_type[$type],
- $size?'('.$size.')':'',
- isset($default)?"default ".$default:'',
- $notnull?'not null':'');
-
- if ($primary_key) {
- $primary_list[] = $name;
- }
- else if ($unique) {
- $unique_list[$unique][] = $name;
- }
- else if ($index) {
- $index_list[$index][] = $name;
- }
- }
-
- $query .= implode (',', $column_schema).';';
- $this->_query ($query);
-
- if (count ($primary_list)) {
- $query = sprintf ("alter class \"%s\" add attribute constraint ". "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"'.implode('","',$primary_list).'"');
- $this->_query ($query);
- }
-
- if (count ($unique_list)) {
- foreach ($unique_list as $key => $val) {
- $query = sprintf ("create unique index \"%s\" on \"%s\" ". "(%s);", $key, $table_name, '"'.implode('","', $val).'"');
- $this->_query ($query);
- }
- }
-
- if (count ($index_list)) {
- foreach ($index_list as $key => $val) {
- $query = sprintf ("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"'.implode('","',$val).'"');
- $this->_query ($query);
- }
- }
+ $size = '';
}
+ $query = sprintf("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name);
-
-
- /**
- * Handles insertAct
- * @param Object $queryObject
- * @param boolean $with_values
- * @return resource
- */
- function _executeInsertAct($queryObject, $with_values = TRUE)
+ if($type == 'char' || $type == 'varchar')
{
- if($this->use_prepared_statements == 'Y')
+ if($size)
{
- $this->param = $queryObject->getArguments();
- $with_values = FALSE;
+ $size = $size * 3;
}
- $query = $this->getInsertSql($queryObject, $with_values);
- if(is_a($query, 'Object')) return;
+ }
- $query .= (__DEBUG_QUERY__&1 && $this->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
+ if($size)
+ {
+ $query .= sprintf("%s(%s) ", $type, $size);
+ }
+ else
+ {
+ $query .= sprintf("%s ", $type);
+ }
- $result = $this->_query ($query);
- if ($result && !$this->transaction_started) {
- $this->_commit();
+ if($default)
+ {
+ if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT')
+ {
+ $query .= sprintf("default %d ", $default);
}
+ else
+ {
+ $query .= sprintf("default '%s' ", $default);
+ }
+ }
+
+ if($notnull)
+ {
+ $query .= "not null ";
+ }
+
+ return $this->_query($query);
+ }
+
+ /**
+ * Drop a column from the table
+ * @param string $table_name table name
+ * @param string $column_name column name
+ * @return void
+ */
+ function dropColumn($table_name, $column_name)
+ {
+ $query = sprintf("alter class \"%s%s\" drop \"%s\" ", $this->prefix, $table_name, $column_name);
+
+ $this->_query($query);
+ }
+
+ /**
+ * Check column exist status of the table
+ * @param string $table_name table name
+ * @param string $column_name column name
+ * @return boolean
+ */
+ function isColumnExists($table_name, $column_name)
+ {
+ $query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name);
+ $result = $this->_query($query);
+
+ if(cubrid_num_rows($result) > 0)
+ {
+ $output = TRUE;
+ }
+ else
+ {
+ $output = FALSE;
+ }
+
+ if($result)
+ {
+ cubrid_close_request($result);
+ }
+
+ return $output;
+ }
+
+ /**
+ * Add an index to the table
+ * $target_columns = array(col1, col2)
+ * $is_unique? unique : none
+ * @param string $table_name table name
+ * @param string $index_name index name
+ * @param string|array $target_columns target column or columns
+ * @param boolean $is_unique
+ * @return void
+ */
+ function addIndex($table_name, $index_name, $target_columns, $is_unique = FALSE)
+ {
+ if(!is_array($target_columns))
+ {
+ $target_columns = array($target_columns);
+ }
+
+ $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"' . implode('","', $target_columns) . '"');
+
+ $this->_query($query);
+ }
+
+ /**
+ * Drop an index from the table
+ * @param string $table_name table name
+ * @param string $index_name index name
+ * @param boolean $is_unique
+ * @return void
+ */
+ function dropIndex($table_name, $index_name, $is_unique = FALSE)
+ {
+ $query = sprintf("drop %s index \"%s\" on \"%s%s\"", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name);
+
+ $this->_query($query);
+ }
+
+ /**
+ * Check index status of the table
+ * @param string $table_name table name
+ * @param string $index_name index name
+ * @return boolean
+ */
+ function isIndexExists($table_name, $index_name)
+ {
+ $query = sprintf("select \"index_name\" from \"db_index\" where " . "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix . $index_name, $index_name);
+ $result = $this->_query($query);
+
+ if($this->isError())
+ {
+ return FALSE;
+ }
+
+ $output = $this->_fetch($result);
+
+ if(!$output)
+ {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete duplicated index of the table
+ * @return boolean
+ */
+ function deleteDuplicateIndexes()
+ {
+ $query = sprintf("
+ select \"class_name\"
+ , case
+ when substr(\"index_name\", 0, %d) = '%s'
+ then substr(\"index_name\", %d)
+ else \"index_name\" end as unprefixed_index_name
+ , \"is_unique\"
+ from \"db_index\"
+ where \"class_name\" like %s
+ group by \"class_name\"
+ , case
+ when substr(\"index_name\", 0, %d) = '%s'
+ then substr(\"index_name\", %d)
+ else \"index_name\"
+ end
+ having count(*) > 1
+ ", strlen($this->prefix)
+ , $this->prefix
+ , strlen($this->prefix) + 1
+ , "'" . $this->prefix . '%' . "'"
+ , strlen($this->prefix)
+ , $this->prefix
+ , strlen($this->prefix) + 1
+ );
+ $result = $this->_query($query);
+
+ if($this->isError())
+ {
+ return FALSE;
+ }
+
+ $output = $this->_fetch($result);
+ if(!$output)
+ {
+ return FALSE;
+ }
+
+ if(!is_array($output))
+ {
+ $indexes_to_be_deleted = array($output);
+ }
+ else
+ {
+ $indexes_to_be_deleted = $output;
+ }
+
+ foreach($indexes_to_be_deleted as $index)
+ {
+ $this->dropIndex(substr($index->class_name, strlen($this->prefix))
+ , $this->prefix . $index->unprefixed_index_name
+ , $index->is_unique == 'YES' ? TRUE : FALSE);
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Creates a table by using xml contents
+ * @param string $xml_doc xml schema contents
+ * @return void|object
+ */
+ function createTableByXml($xml_doc)
+ {
+ return $this->_createTable($xml_doc);
+ }
+
+ /**
+ * Creates a table by using xml file path
+ * @param string $file_name xml schema file path
+ * @return void|object
+ */
+ function createTableByXmlFile($file_name)
+ {
+ if(!file_exists($file_name))
+ {
+ return;
+ }
+ // read xml file
+ $buff = FileHandler::readFile($file_name);
+ return $this->_createTable($buff);
+ }
+
+ /**
+ * Create table by using the schema xml
+ *
+ * type : number, varchar, tinytext, text, bigtext, char, date, \n
+ * opt : notnull, default, size\n
+ * index : primary key, index, unique\n
+ * @param string $xml_doc xml schema contents
+ * @return void|object
+ */
+ function _createTable($xml_doc)
+ {
+ // xml parsing
+ $oXml = new XmlParser();
+ $xml_obj = $oXml->parse($xml_doc);
+ // Create a table schema
+ $table_name = $xml_obj->table->attrs->name;
+
+ // if the table already exists exit function
+ if($this->isTableExists($table_name))
+ {
+ return;
+ }
+
+ // If the table name is sequence, it creates a serial
+ if($table_name == 'sequence')
+ {
+ $query = sprintf('create serial "%s" start with 1 increment by 1' .
+ ' minvalue 1 ' .
+ 'maxvalue 10000000000000000000000000000000000000' . ' nocycle;', $this->prefix . $table_name);
+
+ return $this->_query($query);
+ }
+
+
+ $table_name = $this->prefix . $table_name;
+
+ $query = sprintf('create class "%s";', $table_name);
+ $this->_query($query);
+
+ if(!is_array($xml_obj->table->column))
+ {
+ $columns[] = $xml_obj->table->column;
+ }
+ else
+ {
+ $columns = $xml_obj->table->column;
+ }
+
+ $query = sprintf("alter class \"%s\" add attribute ", $table_name);
+
+ $primary_list = array();
+ $unique_list = array();
+ $index_list = array();
+
+ foreach($columns as $column)
+ {
+ $name = $column->attrs->name;
+ $type = $column->attrs->type;
+ $size = $column->attrs->size;
+ $notnull = $column->attrs->notnull;
+ $primary_key = $column->attrs->primary_key;
+ $index = $column->attrs->index;
+ $unique = $column->attrs->unique;
+ $default = $column->attrs->default;
+
+ switch($this->column_type[$type])
+ {
+ case 'integer' :
+ $size = NULL;
+ break;
+ case 'text' :
+ $size = NULL;
+ break;
+ }
+
+ if(isset($default) && ($type == 'varchar' || $type == 'char' ||
+ $type == 'text' || $type == 'tinytext' || $type == 'bigtext'))
+ {
+ $default = sprintf("'%s'", $default);
+ }
+
+ if($type == 'varchar' || $type == 'char')
+ {
+ if($size)
+ $size = $size * 3;
+ }
+
+
+ $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default " . $default : '', $notnull ? 'not null' : '');
+
+ if($primary_key)
+ {
+ $primary_list[] = $name;
+ }
+ else if($unique)
+ {
+ $unique_list[$unique][] = $name;
+ }
+ else if($index)
+ {
+ $index_list[$index][] = $name;
+ }
+ }
+
+ $query .= implode(',', $column_schema) . ';';
+ $this->_query($query);
+
+ if(count($primary_list))
+ {
+ $query = sprintf("alter class \"%s\" add attribute constraint " . "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"' . implode('","', $primary_list) . '"');
+ $this->_query($query);
+ }
+
+ if(count($unique_list))
+ {
+ foreach($unique_list as $key => $val)
+ {
+ $query = sprintf("create unique index \"%s\" on \"%s\" " . "(%s);", $key, $table_name, '"' . implode('","', $val) . '"');
+ $this->_query($query);
+ }
+ }
+
+ if(count($index_list))
+ {
+ foreach($index_list as $key => $val)
+ {
+ $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"' . implode('","', $val) . '"');
+ $this->_query($query);
+ }
+ }
+ }
+
+ /**
+ * Handles insertAct
+ * @param Object $queryObject
+ * @param boolean $with_values
+ * @return resource
+ */
+ function _executeInsertAct($queryObject, $with_values = TRUE)
+ {
+ if($this->use_prepared_statements == 'Y')
+ {
+ $this->param = $queryObject->getArguments();
+ $with_values = FALSE;
+ }
+ $query = $this->getInsertSql($queryObject, $with_values);
+ if(is_a($query, 'Object'))
+ {
unset($this->param);
- return $result;
+ return;
}
- /**
- * Handles updateAct
- * @param Object $queryObject
- * @param boolean $with_values
- * @return resource
- */
- function _executeUpdateAct($queryObject, $with_values = TRUE)
+ $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+
+ $result = $this->_query($query);
+ if($result && !$this->transaction_started)
{
- if($this->use_prepared_statements == 'Y')
- {
- $this->param = $queryObject->getArguments();
- $with_values = FALSE;
- }
- $query = $this->getUpdateSql($queryObject, $with_values);
- if(is_a($query, 'Object')) return;
-
- $query .= (__DEBUG_QUERY__&1 && $this->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
-
- $result = $this->_query($query);
-
- if ($result && !$this->transaction_started) $this->_commit();
- unset($this->param);
- return $result;
+ $this->_commit();
}
+ unset($this->param);
+ return $result;
+ }
-
- /**
- * Handles deleteAct
- * @param Object $queryObject
- * @param boolean $with_values
- * @return resource
- */
- function _executeDeleteAct($queryObject, $with_values = TRUE)
+ /**
+ * Handles updateAct
+ * @param Object $queryObject
+ * @param boolean $with_values
+ * @return resource
+ */
+ function _executeUpdateAct($queryObject, $with_values = TRUE)
+ {
+ if($this->use_prepared_statements == 'Y')
+ {
+ $this->param = $queryObject->getArguments();
+ $with_values = FALSE;
+ }
+ $query = $this->getUpdateSql($queryObject, $with_values);
+ if(is_a($query, 'Object'))
{
- if($this->use_prepared_statements == 'Y')
- {
- $this->param = $queryObject->getArguments();
- $with_values = FALSE;
- }
- $query = $this->getDeleteSql($queryObject, $with_values);
- if(is_a($query, 'Object')) return;
-
- $query .= (__DEBUG_QUERY__&1 && $this->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
-
- $result = $this->_query ($query);
-
- if ($result && !$this->transaction_started) $this->_commit();
-
unset($this->param);
- return $result;
+ return;
}
- /**
- * Handle selectAct
- * To get a specific page list easily in select statement,
- * a method, navigation, is used
- * @param Object $queryObject
- * @param resource $connection
- * @param boolean $with_values
- * @return Object
- */
- function _executeSelectAct($queryObject, $connection = NULL, $with_values = TRUE) {
- if ($this->use_prepared_statements == 'Y') {
- $this->param = $queryObject->getArguments();
- $with_values = FALSE;
- }
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler())
+ $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+
+ $result = $this->_query($query);
+
+ if($result && !$this->transaction_started)
+ {
+ $this->_commit();
+ }
+ unset($this->param);
+ return $result;
+ }
+
+ /**
+ * Handles deleteAct
+ * @param Object $queryObject
+ * @param boolean $with_values
+ * @return resource
+ */
+ function _executeDeleteAct($queryObject, $with_values = TRUE)
+ {
+ if($this->use_prepared_statements == 'Y')
+ {
+ $this->param = $queryObject->getArguments();
+ $with_values = FALSE;
+ }
+ $query = $this->getDeleteSql($queryObject, $with_values);
+ if(is_a($query, 'Object'))
+ {
+ unset($this->param);
+ return;
+ }
+
+ $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+
+ $result = $this->_query($query);
+
+ if($result && !$this->transaction_started)
+ {
+ $this->_commit();
+ }
+
+ unset($this->param);
+ return $result;
+ }
+
+ /**
+ * Handle selectAct
+ * To get a specific page list easily in select statement,
+ * a method, navigation, is used
+ * @param Object $queryObject
+ * @param resource $connection
+ * @param boolean $with_values
+ * @return Object
+ */
+ function _executeSelectAct($queryObject, $connection = NULL, $with_values = TRUE)
+ {
+ if($this->use_prepared_statements == 'Y')
+ {
+ $this->param = $queryObject->getArguments();
+ $with_values = FALSE;
+ }
+ $limit = $queryObject->getLimit();
+ if($limit && $limit->isPageHandler())
+ {
+ return $this->queryPageLimit($queryObject, $connection, $with_values);
+ }
+ else
+ {
+ $query = $this->getSelectSql($queryObject, $with_values);
+ if(is_a($query, 'Object'))
{
- return $this->queryPageLimit($queryObject, $connection, $with_values);
- }
- else {
- $query = $this->getSelectSql($queryObject, $with_values);
- if (is_a($query, 'Object'))
- return;
-
- $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- $result = $this->_query($query, $connection);
-
- if ($this->isError())
- return $this->queryError($queryObject);
-
- $data = $this->_fetch($result);
- $buff = new Object ();
- $buff->data = $data;
-
unset($this->param);
- return $buff;
- }
- }
-
- /**
- * If have a error, return error object
- * @param Object $queryObject
- * @return Object
- */
- function queryError($queryObject){
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()){
- $buff = new Object ();
- $buff->total_count = 0;
- $buff->total_page = 0;
- $buff->page = 1;
- $buff->data = array ();
- $buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
- return $buff;
- }else
- return;
- }
-
- /**
- * If select query execute, return page info
- * @param Object $queryObject
- * @param resource $connection
- * @param boolean $with_values
- * @return Object Object with page info containing
- */
- function queryPageLimit($queryObject, $connection, $with_values){
- $limit = $queryObject->getLimit();
- // Total count
- $temp_where = $queryObject->getWhereString($with_values, FALSE);
- $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '. $temp_where));
-
- // Check for distinct query and if found update count query structure
- $temp_select = $queryObject->getSelectString($with_values);
- $uses_distinct = strpos(strtolower($temp_select), "distinct") !== FALSE;
- $uses_groupby = $queryObject->getGroupByString() != '';
- if($uses_distinct || $uses_groupby) {
- $count_query = sprintf('select %s %s %s %s'
- , $temp_select
- , 'FROM ' . $queryObject->getFromString($with_values)
- , ($temp_where === '' ? '' : ' WHERE '. $temp_where)
- , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '')
- );
-
- // If query uses grouping or distinct, count from original select
- $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
- }
-
- $count_query .= (__DEBUG_QUERY__&1 && $queryObject->queryID)?sprintf (' '.$this->comment_syntax, $queryObject->queryID):'';
- $result = $this->_query($count_query, $connection);
- $count_output = $this->_fetch($result);
- $total_count = (int)(isset($count_output->count) ? $count_output->count : NULL);
-
- $list_count = $limit->list_count->getValue();
- if (!$list_count) $list_count = 20;
- $page_count = $limit->page_count->getValue();
- if (!$page_count) $page_count = 10;
- $page = $limit->page->getValue();
- if (!$page) $page = 1;
-
- // total pages
- if ($total_count) {
- $total_page = (int) (($total_count - 1) / $list_count) + 1;
- }
- else {
- $total_page = 1;
+ return;
}
- // check the page variables
- if ($page > $total_page) {
- // If requested page is bigger than total number of pages, return empty list
-
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = array();
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- return $buff;
- }
- $start_count = ($page - 1) * $list_count;
+ $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+ $result = $this->_query($query, $connection);
- $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count);
- $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
- $result = $this->_query ($query, $connection);
- if ($this->isError ())
+ if($this->isError())
+ {
+ unset($this->param);
return $this->queryError($queryObject);
+ }
- $virtual_no = $total_count - ($page - 1) * $list_count;
- $data = $this->_fetch($result, $virtual_no);
+ $data = $this->_fetch($result);
+ $buff = new Object ();
+ $buff->data = $data;
- $buff = new Object ();
+ unset($this->param);
+ return $buff;
+ }
+ }
+
+ /**
+ * If have a error, return error object
+ * @param Object $queryObject
+ * @return Object
+ */
+ function queryError($queryObject)
+ {
+ $limit = $queryObject->getLimit();
+ if($limit && $limit->isPageHandler())
+ {
+ $buff = new Object ();
+ $buff->total_count = 0;
+ $buff->total_page = 0;
+ $buff->page = 1;
+ $buff->data = array();
+ $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
+ return $buff;
+ }else
+ return;
+ }
+
+ /**
+ * If select query execute, return page info
+ * @param Object $queryObject
+ * @param resource $connection
+ * @param boolean $with_values
+ * @return Object Object with page info containing
+ */
+ function queryPageLimit($queryObject, $connection, $with_values)
+ {
+ $limit = $queryObject->getLimit();
+ // Total count
+ $temp_where = $queryObject->getWhereString($with_values, FALSE);
+ $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
+
+ // Check for distinct query and if found update count query structure
+ $temp_select = $queryObject->getSelectString($with_values);
+ $uses_distinct = strpos(strtolower($temp_select), "distinct") !== FALSE;
+ $uses_groupby = $queryObject->getGroupByString() != '';
+ if($uses_distinct || $uses_groupby)
+ {
+ $count_query = sprintf('select %s %s %s %s'
+ , $temp_select
+ , 'FROM ' . $queryObject->getFromString($with_values)
+ , ($temp_where === '' ? '' : ' WHERE ' . $temp_where)
+ , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '')
+ );
+
+ // If query uses grouping or distinct, count from original select
+ $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
+ }
+
+ $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
+ $result = $this->_query($count_query, $connection);
+ $count_output = $this->_fetch($result);
+ $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL);
+
+ $list_count = $limit->list_count->getValue();
+ if(!$list_count)
+ {
+ $list_count = 20;
+ }
+ $page_count = $limit->page_count->getValue();
+ if(!$page_count)
+ {
+ $page_count = 10;
+ }
+ $page = $limit->page->getValue();
+ if(!$page || $page < 1)
+ {
+ $page = 1;
+ }
+
+ // total pages
+ if($total_count)
+ {
+ $total_page = (int) (($total_count - 1) / $list_count) + 1;
+ }
+ else
+ {
+ $total_page = 1;
+ }
+
+ // check the page variables
+ if($page > $total_page)
+ {
+ // If requested page is bigger than total number of pages, return empty list
+
+ $buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $page;
- $buff->data = $data;
+ $buff->data = array();
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
unset($this->param);
return $buff;
}
+ $start_count = ($page - 1) * $list_count;
- /**
- * Return the DBParser
- * @param boolean $force
- * @return DBParser
- */
- function getParser($force = FALSE){
- return new DBParser('"', '"', $this->prefix);
+ $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count);
+ $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+ $result = $this->_query($query, $connection);
+ if($this->isError())
+ {
+ unset($this->param);
+ return $this->queryError($queryObject);
}
- /**
- * If select query execute, return paging sql
- * @param object $query
- * @param boolean $with_values
- * @param int $start_count
- * @param int $list_count
- * @return string select paging sql
- */
- function getSelectPageSql($query, $with_values = TRUE, $start_count = 0, $list_count = 0) {
+ $virtual_no = $total_count - ($page - 1) * $list_count;
+ $data = $this->_fetch($result, $virtual_no);
- $select = $query->getSelectString($with_values);
- if($select == '') return new Object(-1, "Invalid query");
- $select = 'SELECT ' .$select;
+ $buff = new Object ();
+ $buff->total_count = $total_count;
+ $buff->total_page = $total_page;
+ $buff->page = $page;
+ $buff->data = $data;
+ $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
+ unset($this->param);
+ return $buff;
+ }
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
- $from = ' FROM '.$from;
+ /**
+ * Return the DBParser
+ * @param boolean $force
+ * @return DBParser
+ */
+ function getParser($force = FALSE)
+ {
+ return new DBParser('"', '"', $this->prefix);
+ }
- $where = $query->getWhereString($with_values);
- if($where != '')
- $where = ' WHERE ' . $where;
+ /**
+ * If select query execute, return paging sql
+ * @param object $query
+ * @param boolean $with_values
+ * @param int $start_count
+ * @param int $list_count
+ * @return string select paging sql
+ */
+ function getSelectPageSql($query, $with_values = TRUE, $start_count = 0, $list_count = 0)
+ {
- $groupBy = $query->getGroupByString();
- if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
+ $select = $query->getSelectString($with_values);
+ if($select == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $select = 'SELECT ' . $select;
- $orderBy = $query->getOrderByString();
- if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
+ $from = $query->getFromString($with_values);
+ if($from == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $from = ' FROM ' . $from;
- $limit = $query->getLimitString();
- if ($limit != '') $limit = sprintf (' LIMIT %d, %d', $start_count, $list_count);
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $where = ' WHERE ' . $where;
+ }
+
+ $groupBy = $query->getGroupByString();
+ if($groupBy != '')
+ {
+ $groupBy = ' GROUP BY ' . $groupBy;
+ }
+
+ $orderBy = $query->getOrderByString();
+ if($orderBy != '')
+ {
+ $orderBy = ' ORDER BY ' . $orderBy;
+ }
+
+ $limit = $query->getLimitString();
+ if($limit != '')
+ {
+ $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count);
+ }
+
+ return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
+ }
- return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
- }
}
-?>
+/* End of file DBCubrid.class.php */
+/* Location: ./classes/db/DBCubrid.class.php */
diff --git a/classes/db/DBFirebird.class.php b/classes/db/DBFirebird.class.php
deleted file mode 100644
index b3c0bb4e8..000000000
--- a/classes/db/DBFirebird.class.php
+++ /dev/null
@@ -1,868 +0,0 @@
- 'BIGINT',
- 'number' => 'INTEGER',
- 'varchar' => 'VARCHAR',
- 'char' => 'CHAR',
- 'text' => 'BLOB SUB_TYPE TEXT SEGMENT SIZE 32',
- 'bigtext' => 'BLOB SUB_TYPE TEXT SEGMENT SIZE 32',
- 'date' => 'VARCHAR(14)',
- 'float' => 'FLOAT',
- );
-
- /**
- * @brief constructor
- **/
- function DBFireBird() {
- $this->_setDBInfo();
- $this->_connect();
- }
-
- /**
- * @brief create an instance of this class
- */
- function create()
- {
- return new DBFireBird;
- }
-
- /**
- * @brief Return if installable
- **/
- function isSupported() {
- if(!function_exists('ibase_connect')) return false;
- return true;
- }
-
- /**
- * @brief DB Connection
- **/
- function __connect($connection) {
- //if(strpos($this->hostname, ':')===false && $this->port) $this->hostname .= ':'.$this->port;
- // attempts to connect
- $host = $connection["db_hostname"]."/".$connection["db_port"].":".$connection["db_database"];
-
- $result = ibase_connect($host, $connection["db_userid"], $connection["db_password"]);
- if(ibase_errmsg()) {
- $this->setError(ibase_errcode(), ibase_errmsg());
- return;
- }
- // Error when Firebird version is lower than 2.0
- if (($service = ibase_service_attach($connection["db_hostname"], $connection["db_userid"], $connection["db_password"])) != FALSE) {
- // get server version and implementation strings
- $server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
- ibase_service_detach($service);
- }
- else {
- $this->setError(ibase_errcode(), ibase_errmsg());
- ibase_close($result);
- return;
- }
-
- $pos = strpos($server_info, "Firebird");
- if($pos !== false) {
- $ver = substr($server_info, $pos+strlen("Firebird"));
- $ver = trim($ver);
- }
-
- if($ver < "2.0") {
- $this->setError(-1, "XE cannot be installed under the version of firebird 2.0. Current firebird version is ".$ver);
- ibase_close($result);
- return;
- }
- return $result;
- }
-
- /**
- * @brief DB disconnect
- **/
- function _close($connection) {
- ibase_commit($connection);
- ibase_close($connection);
- }
-
- /**
- * @brief handles quatation of the string variables from the query
- **/
- function addQuotes($string) {
- if(get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
- if(!is_numeric($string)) $string = str_replace("'","''", $string);
- return $string;
- }
-
- /**
- * @brief put double quotes for tabls, column names in the query statement
- **/
- function addDoubleQuotes($string) {
- if($string == "*") return $string;
-
- if(strpos($string, "'")!==false) {
- $string = str_replace("'", "\"", $string);
- }
- else if(strpos($string, "\"")!==false) {
- }
- else {
- $string = "\"".$string."\"";
- }
-
- return $string;
- }
-
- /**
- * @brief put double quotes for tabls, column names in the query statement
- **/
- function autoQuotes($string){
- $string = strtolower($string);
- // for substr function
- if(strpos($string, "substr(") !== false) {
- $tokken = strtok($string, "(,)");
- $tokken = strtok("(,)");
- while($tokken) {
- $tokkens[] = $tokken;
- $tokken = strtok("(,)");
- }
-
- if(count($tokkens) !== 3) return $string;
- return sprintf("substring(%s from %s for %s)", $this->addDoubleQuotes($tokkens[0]), $tokkens[1], $tokkens[2]);
- }
-
- // as
- $as = false;
- if(($no1 = strpos($string," as ")) !== false) {
- $as = substr($string, $no1, strlen($string)-$no1);
- $string = substr($string, 0, $no1);
-
- $as = str_replace(" as ", "", $as);
- $as = trim($as);
- $as = $this->addDoubleQuotes($as);
- }
- // for functions
- $tmpFunc1 = null;
- $tmpFunc2 = null;
- if(($no1 = strpos($string,'('))!==false && ($no2 = strpos($string, ')'))!==false) {
- $tmpFunc1 = substr($string, 0, $no1+1);
- $tmpFunc2 = substr($string, $no2, strlen($string)-$no2+1);
- $string = trim(substr($string, $no1+1, $no2-$no1-1));
- }
- // for (table.column) structure
- preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $string, $matches);
-
- if($matches) {
- $string = $this->addDoubleQuotes($matches[1]).".".$this->addDoubleQuotes($matches[2]);
- }
- else {
- $string = $this->addDoubleQuotes($string);
- }
-
- if($tmpFunc1 != null) $string = $tmpFunc1.$string;
- if($tmpFunc2 != null) $string = $string.$tmpFunc2;
-
- if($as !== false) $string = $string." as ".$as;
- return $string;
- }
-
- function autoValueQuotes($string, $tables){
- $tok = strtok($string, ",");
- while($tok !== false) {
- $values[] = $tok;
- $tok = strtok(",");
- }
-
- foreach($values as $val1) {
- // for (table.column) structure
- preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $val1, $matches);
- if($matches) {
- $isTable = false;
-
- foreach($tables as $key2 => $val2) {
- if($key2 == $matches[1]) $isTable = true;
- if($val2 == $matches[1]) $isTable = true;
- }
-
- if($isTable) {
- $return[] = $this->addDoubleQuotes($matches[1]).".".$this->addDoubleQuotes($matches[2]);
- }
- else {
- $return[] = $val1;
- }
- }
- else if(!is_numeric($val1)) {
- if(strpos($val1, "'") !== 0)
- $return[] = "'".$val1."'";
- else
- $return[] = $val1;
- }
- else {
- $return[] = $val1;
- }
- }
-
- return implode(",", $return);
- }
-
- /**
- * @brief Begin transaction
- **/
- function _begin() {
- return true;
- }
-
- /**
- * @brief Rollback
- **/
- function _rollback() {
- $connection = $this->_getConnection('master');
- ibase_rollback($connection);
- return true;
- }
-
- /**
- * @brief Commits
- **/
- function _commit() {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- return true;
- }
-
- /**
- * @brief : Run a query and fetch the result
- *
- * query: run a query and return the result\n
- * fetch: NULL if no value returned \n
- * array object if rows returned \n
- * object if a row returned \n
- * return\n
- **/
- function __query($query, $connection, $params = null) {
- if(count($params) == 0) {
- // Execute the query statement
- $result = ibase_query($connection, $query);
- }
- else {
- // Execute the query(for blob type)
- $query = ibase_prepare($connection, $query);
- //$fnarr = array_merge(array($query), $params);
- $result = ibase_execute($query);
- }
- // Error Check
- if(ibase_errmsg()) $this->setError(ibase_errcode(), ibase_errmsg());
-
- return $result;
- }
-
- function _queryInsertUpdateDeleteSelect($query, $params=null, $connection) {
- if(!$connection) return;
-
- if(count($params) == 0) {
- // Notify to start a query execution
- $this->actStart($query);
- // Execute the query statement
- $trans = ibase_trans(IBASE_DEFAULT,$connection);
- $result = ibase_query($trans, $query);
- ibase_commit($trans);
- unset($trans);
- }
- else {
- // Notify to start a query execution
- $log = $query."\n\t\t\t";
- $log .= implode(",", $params);
- $this->actStart($log);
- // Execute the query(for blob type)
- $query = ibase_prepare($connection, $query);
- //$fnarr = array_merge(array($query), $params);
- $result = ibase_execute($query);
- }
- // Error Check
- if(ibase_errmsg()) $this->setError(ibase_errcode(), ibase_errmsg());
- // Notify to complete a query execution
- $this->actFinish();
- // Return the result
- return $result;
- }
-
- function getTableInfo($result){
- $coln = ibase_num_fields($result);
- $column_type = array();
- for ($i = 0; $i < $coln; $i++) {
- $col_info = ibase_field_info($result, $i);
- if($col_info['name'] === "") $column_type[$col_info['alias']] = $col_info['type'];
- else $column_type[$col_info['name']] = $col_info['type'];
- }
- return $column_type;
- }
- /**
- * @brief Fetch the result
- **/
- function _fetch($result, $output = null) {
- if(!$this->isConnected() || $this->isError() || !$result) return;
- $output->column_type = $this->getTableInfo($result);
-
- while($tmp = ibase_fetch_object($result)) {
- foreach($tmp as $key => $val) {
- $type = $output->column_type[$key];
- // type value is null when $key is an alias. so get a type by finding actual coloumn name
- if($type == null && $output->columns && count($output->columns)) {
- foreach($output->columns as $cols) {
- if($cols['alias'] == $key) {
- // checks if the format is table.column or a regular expression
- preg_match("/\w+[.](\w+)/", $cols['name'], $matches);
- if($matches) {
- $type = $output->column_type[$matches[1]];
- }
- else {
- $type = $output->column_type[$cols['name']];
- }
- }
- }
- }
-
- if(($type == "text" || $type == "bigtext" || $type == "BLOB") && $tmp->{$key}) {
- $blob_data = ibase_blob_info($tmp->{$key});
- $blob_hndl = ibase_blob_open($tmp->{$key});
-
- if($blob_data[1] === 1) {
- $tmp->{$key} = ibase_blob_get($blob_hndl, $blob_data[0]);
- } else {
- for ($i = 0; $i < $blob_data[1]; $i++) {
- $readsize = $blob_data[2];
- if ($i == ($blob_data[1] - 1)) {
- $readsize = $blob_data[0] - (($blob_data[1] - 1) * $blob_data[2]);
- }
- $totalimage .= ibase_blob_get($blob_hndl, $readsize);
- }
- }
-
- ibase_blob_close($blob_hndl);
- }
- else if($type == "CHAR") {
- $tmp->{$key} = trim($tmp->{$key}); // remove blanks generated when DB character set is UTF8
- }
- }
-
- $return[] = $tmp;
- }
-
- if(count($return)==1) return $return[0];
- return $return;
- }
-
- /**
- * @brief return sequence value incremented by 1(increase the value of the generator in firebird)
- **/
- function getNextSequence() {
- //$gen = "GEN_".$this->prefix."sequence_ID";
- $gen = 'GEN_XE_SEQUENCE_ID';
- $sequence = ibase_gen_id($gen, 1);
- return $sequence;
- }
-
- /**
- * @brief returns if the table already exists
- **/
- function isTableExists($target_name) {
- $query = sprintf("select rdb\$relation_name from rdb\$relations where rdb\$system_flag=0 and rdb\$relation_name = '%s%s';", $this->prefix, $target_name);
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
- $connection = $this->_getConnection('master');
- if(!$tmp) {
- if(!$this->transaction_started) ibase_rollback($connection);
- return false;
- }
- if(!$this->transaction_started) ibase_commit($connection);
- return true;
- }
-
- /**
- * @brief add a column to the table
- **/
- function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
- $type = $this->column_type[$type];
- if(strtoupper($type)=='INTEGER') $size = null;
- else if(strtoupper($type)=='BIGINT') $size = null;
- else if(strtoupper($type)=='BLOB SUB_TYPE TEXT SEGMENT SIZE 32') $size = null;
- else if(strtoupper($type)=='VARCHAR' && !$size) $size = 256;
-
- $query = sprintf("ALTER TABLE \"%s%s\" ADD \"%s\" ", $this->prefix, $table_name, $column_name);
- if($size) $query .= sprintf(" %s(%s) ", $type, $size);
- else $query .= sprintf(" %s ", $type);
- if(!is_null($default)) $query .= sprintf(" DEFAULT '%s' ", $default);
- if($notnull) $query .= " NOT NULL ";
-
- $this->_query($query);
-
- if(!$this->transaction_started) {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- }
- }
-
- /**
- * @brief drop a column from the table
- **/
- function dropColumn($table_name, $column_name) {
- $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
- $this->_query($query);
- if(!$this->transaction_started) {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- }
-
- }
-
-
- /**
- * @brief return column information of the table
- **/
- function isColumnExists($table_name, $column_name) {
- $query = sprintf("SELECT RDB\$FIELD_NAME as \"FIELD\" FROM RDB\$RELATION_FIELDS WHERE RDB\$RELATION_NAME = '%s%s'", $this->prefix, $table_name);
- $result = $this->_query($query);
- $connection = $this->_getConnection('master');
-
- if($this->isError()) {
- if(!$this->transaction_started) ibase_rollback($connection);
- return false;
- }
-
- $output = $this->_fetch($result);
- if(!$this->transaction_started) ibase_commit($connection);
-
- if($output) {
- $column_name = strtolower($column_name);
- foreach($output as $key => $val) {
- $name = trim(strtolower($val->FIELD));
- if($column_name == $name) return true;
- }
- }
- return false;
- }
-
- /**
- * @brief add an index to the table
- * $target_columns = array(col1, col2)
- * $is_unique? unique : none
- **/
- function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
- // index name size should be limited to 31 byte. no index name assigned
- // if index name omitted, Firebird automatically assign its name like "RDB $10"
- // deletes indexes when deleting the table
- if(!is_array($target_columns)) $target_columns = array($target_columns);
-
- $query = sprintf('CREATE %s INDEX "" ON "%s%s" ("%s");', $is_unique?'UNIQUE':'', $this->prefix, $table_name, implode('", "',$target_columns));
- $this->_query($query);
-
- $connection = $this->_getConnection('master');
- if(!$this->transaction_started) ibase_commit($connection);
- }
-
- /**
- * @brief drop an index from the table
- **/
- function dropIndex($table_name, $index_name, $is_unique = false) {
- $query = sprintf('DROP INDEX "%s" ON "%s%s"', $index_name, $this->prefix, $table_name);
- $this->_query($query);
-
- $connection = $this->_getConnection('master');
- if(!$this->transaction_started) ibase_commit($connection);
- }
-
-
- /**
- * @brief return index information of the table
- **/
- function isIndexExists($table_name, $index_name) {
- $query = "SELECT\n";
- $query .= " RDB\$INDICES.rdb\$index_name AS Key_name\n";
- $query .= "FROM\n";
- $query .= " RDB\$INDICES, rdb\$index_segments\n";
- $query .= "WHERE\n";
- $query .= " RDB\$INDICES.rdb\$index_name = rdb\$index_segments.rdb\$index_name AND\n";
- $query .= " RDB\$INDICES.rdb\$relation_name = '";
- $query .= $this->prefix;
- $query .= $table_name;
- $query .= "' AND\n";
- $query .= " RDB\$INDICES.rdb\$index_name = '";
- $query .= $index_name;
- $query .= "'";
-
- $result = $this->_query($query);
- if($this->isError()) return;
- $output = $this->_fetch($result);
-
- if(!$output) {
- $connection = $this->_getConnection('master');
- if(!$this->transaction_started) ibase_rollback($connection);
- return false;
- }
-
- if(!$this->transaction_started) {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- }
-
- if(!is_array($output)) $output = array($output);
- for($i=0;$i
KEY_NAME) == $index_name) return true;
- }
-
- return false;
- }
-
- /**
- * @brief creates a table by using xml file
- **/
- function createTableByXml($xml_doc) {
- return $this->_createTable($xml_doc);
- }
-
- /**
- * @brief creates a table by using xml file
- **/
- function createTableByXmlFile($file_name) {
- if(!file_exists($file_name)) return;
- // read xml file
- $buff = FileHandler::readFile($file_name);
- return $this->_createTable($buff);
- }
-
- /**
- * @brief create table by using the schema xml
- *
- * type : number, varchar, text, char, date, \n
- * opt : notnull, default, size\n
- * index : primary key, index, unique\n
- **/
- function _createTable($xml_doc) {
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
- if($this->isTableExists($table_name)) return;
- $table_name = $this->prefix.$table_name;
-
- if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
- else $columns = $xml_obj->table->column;
-
- foreach($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
- $auto_increment = $column->attrs->auto_increment;
-
- if($this->column_type[$type]=='INTEGER') $size = null;
- else if($this->column_type[$type]=='BIGINT') $size = null;
- else if($this->column_type[$type]=='BLOB SUB_TYPE TEXT SEGMENT SIZE 32') $size = null;
- else if($this->column_type[$type]=='VARCHAR' && !$size) $size = 256;
-
- $column_schema[] = sprintf('"%s" %s%s %s %s',
- $name,
- $this->column_type[$type],
- $size?'('.$size.')':'',
- is_null($default)?"":"DEFAULT '".$default."'",
- $notnull?'NOT NULL':'');
-
- if($auto_increment) $auto_increment_list[] = $name;
-
- if($primary_key) $primary_list[] = $name;
- else if($unique) $unique_list[$unique][] = $name;
- else if($index) $index_list[$index][] = $name;
- }
-
- if(count($primary_list)) {
- $column_schema[] = sprintf("PRIMARY KEY(\"%s\")%s", implode("\",\"", $primary_list), "\n");
- }
-
- if(count($unique_list)) {
- foreach($unique_list as $key => $val) {
- $column_schema[] = sprintf("UNIQUE(\"%s\")%s", implode("\",\"", $val), "\n");
- }
- }
-
- $schema = sprintf("CREATE TABLE \"%s\" (%s%s); \n", $table_name, "\n", implode($column_schema, ",\n"));
-
- $output = $this->_query($schema);
- if(!$this->transaction_started) {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- }
- if(!$output) return false;
-
- if(count($index_list)) {
- foreach($index_list as $key => $val) {
- // index name size should be limited to 31 byte. no index name assigned
- // if index name omitted, Firebird automatically assign its name like "RDB $10"
- // deletes indexes when deleting the table
- $schema = sprintf("CREATE INDEX \"\" ON \"%s\" (\"%s\");",
- $table_name, implode($val, "\",\""));
- $output = $this->_query($schema);
- if(!$this->transaction_started) {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- }
- if(!$output) return false;
- }
- }
-
- if($_GLOBALS['XE_EXISTS_SEQUENCE']) return;
- $schema = 'CREATE GENERATOR GEN_XE_SEQUENCE_ID;';
- $output = $this->_query($schema);
- if(!$this->transaction_started) {
- $connection = $this->_getConnection('master');
- ibase_commit($connection);
- }
- if(!$output) return false;
- $_GLOBALS['XE_EXISTS_SEQUENCE'] = true;
- /*if($auto_increment_list)
- foreach($auto_increment_list as $increment) {
- $schema = sprintf('CREATE GENERATOR GEN_%s_ID;', $table_name);
- $output = $this->_query($schema);
- if(!$this->transaction_started) ibase_commit($this->fd);
- if(!$output) return false;*/
- // auto_increment in Firebird creates a generator which activates a trigger when insert occurs
- // the generator increases the value of the generator and then insert to the table
- // The trigger below acts like auto_increment however I commented the below because the trigger cannot be defined by a query statement
- // php api has a function to increase a generator, so
- // no need to use auto increment in XE
- /*
- $schema = 'SET TERM ^ ; ';
- $schema .= sprintf('CREATE TRIGGER "%s_BI" FOR "%s" ', $table_name, $table_name);
- $schema .= 'ACTIVE BEFORE INSERT POSITION 0 ';
- $schema .= sprintf('AS BEGIN IF (NEW."%s" IS NULL) THEN ', $increment);
- $schema .= sprintf('NEW."%s" = GEN_ID("GEN_%s_ID",1);', $increment, $table_name);
- $schema .= 'END^ SET TERM ; ^';
-
- $output = $this->_query($schema);
- if(!$output) return false;
- */
- //}
- }
-
-
- /**
- * @brief Handle the insertAct
- **/
- function _executeInsertAct($queryObject) {
- $query = $this->getInsertSql($queryObject);
- if(is_a($query, 'Object')) return;
- return $this->_queryInsertUpdateDeleteSelect($query);
- }
-
- /**
- * @brief handles updateAct
- **/
- function _executeUpdateAct($queryObject) {
- $query = $this->getUpdateSql($queryObject);
- if(is_a($query, 'Object')) return;
- return $this->_queryInsertUpdateDeleteSelect($query);
- }
-
- /**
- * @brief handles deleteAct
- **/
- function _executeDeleteAct($queryObject) {
- $query = $this->getDeleteSql($queryObject);
- if(is_a($query, 'Object')) return;
- return $this->_queryInsertUpdateDeleteSelect($query);
- }
-
- /**
- * @brief Handle selectAct
- *
- * In order to get a list of pages easily when selecting \n
- * it supports a method as navigation
- **/
- function _executeSelectAct($queryObject, $connection) {
- $query = $this->getSelectSql($queryObject);
- if(strpos($query, "substr")) {
- $query = str_replace ("substr", "substring", $query);
- $query = $this->replaceSubstrFormat($query);
- }
- if(is_a($query, 'Object')) return;
- $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
- $result = $this->_queryInsertUpdateDeleteSelect ($query, null, $connection);
-
- if ($this->isError ()) return $this->queryError($queryObject);
- else return $this->queryPageLimit($queryObject, $result, $connection);
- }
-
- function queryError($queryObject) {
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()) {
- $buff = new Object ();
- $buff->total_count = 0;
- $buff->total_page = 0;
- $buff->page = 1;
- $buff->data = array();
- $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
- }else
- return;
- }
-
- function queryPageLimit($queryObject, $result, $connection) {
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()) {
- // Total count
- $temp_where = $queryObject->getWhereString(true, false);
- $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
- if ($queryObject->getGroupByString() != '') {
- $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
- }
-
- $count_query .= ( __DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- $result_count = $this->_query($count_query, null, $connection);
- $count_output = $this->_fetch($result_count);
- $total_count = (int) $count_output->count;
-
- $list_count = $limit->list_count->getValue();
- if (!$list_count) $list_count = 20;
- $page_count = $limit->page_count->getValue();
- if (!$page_count) $page_count = 10;
- $page = $limit->page->getValue();
- if (!$page) $page = 1;
- // Total pages
- if ($total_count) $total_page = (int) (($total_count - 1) / $list_count) + 1;
- else $total_page = 1;
-
- // check the page variables
- if ($page > $total_page) {
- // If requested page is bigger than total number of pages, return empty list
-
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = array();
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- return $buff;
- }
- $start_count = ($page-1)*$list_count;
-
- $query = $this->getSelectSql($queryObject, true, $start_count);
- if(strpos($query, "substr")) {
- $query = str_replace ("substr", "substring", $query);
- $query = $this->replaceSubstrFormat($query);
- }
- $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
- $result = $this->_query ($query, null, $connection);
- if ($this->isError ())
- return $this->queryError($queryObject);
-
- $virtual_no = $total_count - ($page - 1) * $list_count;
- while ($tmp = ibase_fetch_object($result))
- $data[$virtual_no--] = $tmp;
-
- if (!$this->transaction_started)
- ibase_commit($connection);
-
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = $data;
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- }else {
- $data = $this->_fetch($result);
- $buff = new Object ();
- $buff->data = $data;
- }
- return $buff;
- }
-
- function getParser() {
- return new DBParser('"', '"', $this->prefix);
- }
-
- function getSelectSql($query, $with_values = true, $start_count = 0) {
- $limit = $query->getLimit();
- if ($limit && $limit->isPageHandler()) {
- $list_count = $limit->list_count->getValue();
- if(!$limit->page) $page = 1;
- else $page = $limit->page->getValue();
- if(!$start_count)
- $start_count = ($page - 1) * $list_count;
- $limit = sprintf('SELECT FIRST %d SKIP %d ', $list_count, $start_count);
- }
-
- $select = $query->getSelectString($with_values);
-
- if ($select == '')
- return new Object(-1, "Invalid query");
-
- if ($limit && $limit->isPageHandler())
- $select = $limit . ' ' . $select;
- else
- $select = 'SELECT ' . $select;
- $from = $query->getFromString($with_values);
- if ($from == '')
- return new Object(-1, "Invalid query");
- $from = ' FROM ' . $from;
-
- $where = $query->getWhereString($with_values);
- if ($where != '')
- $where = ' WHERE ' . $where;
-
- $groupBy = $query->getGroupByString();
- if ($groupBy != '')
- $groupBy = ' GROUP BY ' . $groupBy;
-
- $orderBy = $query->getOrderByString();
- if ($orderBy != '')
- $orderBy = ' ORDER BY ' . $orderBy;
-
- return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy;
- }
-
- function getDeleteSql($query, $with_values = true){
- $sql = 'DELETE ';
-
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
-
- $sql .= ' FROM '.$from;
-
- $where = $query->getWhereString($with_values);
- if($where != '') $sql .= ' WHERE ' . $where;
-
- return $sql;
- }
-
- function replaceSubstrFormat($queryString){
- //replacing substr("string",number,number) with substr("string" from number for number)
- $pattern = '/substring\("(\w+)",(\d+),(\d+)\)/i';
- $replacement = 'substring("${1}" from $2 for $3)';
-
- return preg_replace($pattern, $replacement, $queryString);
- }
-
-}
-?>
diff --git a/classes/db/DBMssql.class.php b/classes/db/DBMssql.class.php
index 6a6b85414..9f9e6d13a 100644
--- a/classes/db/DBMssql.class.php
+++ b/classes/db/DBMssql.class.php
@@ -1,734 +1,994 @@
'bigint',
+ 'number' => 'int',
+ 'varchar' => 'varchar',
+ 'char' => 'char',
+ 'text' => 'text',
+ 'bigtext' => 'text',
+ 'date' => 'varchar(14)',
+ 'float' => 'float',
+ );
- /**
- * prefix of XE tables(One more XE can be installed on a single DB)
- * @var string
- */
- var $prefix = 'xe';
- var $param = array();
- var $comment_syntax = '/* %s */';
+ /**
+ * Constructor
+ * @return void
+ */
+ function DBMssql()
+ {
+ $this->_setDBInfo();
+ $this->_connect();
+ }
- /**
- * column type used in mssql
- *
- * column_type should be replaced for each DBMS's type
- * becasue it uses commonly defined type in the schema/query xml
- * @var array
- */
- var $column_type = array(
- 'bignumber' => 'bigint',
- 'number' => 'int',
- 'varchar' => 'varchar',
- 'char' => 'char',
- 'text' => 'text',
- 'bigtext' => 'text',
- 'date' => 'varchar(14)',
- 'float' => 'float',
- );
+ /**
+ * Create an instance of this class
+ * @return DBMssql return DBMssql object instance
+ */
+ function create()
+ {
+ return new DBMssql;
+ }
- /**
- * Constructor
- * @return void
- */
- function DBMssql() {
- $this->_setDBInfo();
- $this->_connect();
- }
-
- /**
- * Create an instance of this class
- * @return DBMssql return DBMssql object instance
- */
- function create()
+ /**
+ * Return if supportable
+ * Check 'sqlsrv' extension loaded.
+ * @return boolean
+ */
+ function isSupported()
+ {
+ if(!extension_loaded("sqlsrv"))
{
- return new DBMssql;
+ return false;
}
+ return true;
+ }
- /**
- * Return if supportable
- * Check 'sqlsrv' extension loaded.
- * @return boolean
- */
- function isSupported() {
- if (!extension_loaded("sqlsrv")) return false;
- return true;
- }
+ /**
+ * DB Connect
+ * this method is private
+ * @param array $connection connection's value is db_hostname, db_database, db_userid, db_password
+ * @return resource
+ */
+ function __connect($connection)
+ {
+ //sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
+ //sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
+ //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL );
+ $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"]));
- /**
- * DB Connect
- * this method is private
- * @param array $connection connection's value is db_hostname, db_database, db_userid, db_password
- * @return resource
- */
- function __connect($connection) {
- //sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
- //sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
- //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL );
- $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"]));
+ if(!$result)
+ {
+ $errors = print_r(sqlsrv_errors(), true);
+ $this->setError(-1, 'database connect fail' . PHP_EOL . $errors);
+ return;
+ }
+ return $result;
+ }
- if(!$result)
- {
- $errors = print_r(sqlsrv_errors(), true);
- $this->setError (-1, 'database connect fail' . PHP_EOL . $errors);
- return;
- }
- return $result;
- }
+ /**
+ * DB disconnection
+ * this method is private
+ * @param resource $connection
+ * @return void
+ */
+ function _close($connection)
+ {
+ $this->commit();
+ sqlsrv_close($connection);
+ }
- /**
- * DB disconnection
- * this method is private
- * @param resource $connection
- * @return void
- */
- function _close($connection) {
- $this->commit();
- sqlsrv_close($connection);
- }
+ /**
+ * Handles quatation of the string variables from the query
+ * @todo See what to do about this
+ * @param string $string
+ * @return string
+ */
+ function addQuotes($string)
+ {
+ if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
+ {
+ $string = stripslashes(str_replace("\\", "\\\\", $string));
+ }
+ //if(!is_numeric($string)) $string = str_replace("'","''",$string);
- /**
- * Handles quatation of the string variables from the query
- * @todo See what to do about this
- * @param string $string
- * @return string
- */
- function addQuotes($string) {
- if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
- //if(!is_numeric($string)) $string = str_replace("'","''",$string);
+ return $string;
+ }
- return $string;
- }
+ /**
+ * DB transaction start
+ * this method is private
+ * @return boolean
+ */
+ function _begin($transactionLevel)
+ {
+ $connection = $this->_getConnection('master');
- /**
- * DB transaction start
- * this method is private
- * @return boolean
- */
- function _begin() {
- $connection = $this->_getConnection('master');
- if(sqlsrv_begin_transaction($connection) === false) return;
- return true;
- }
+ if(!$transactionLevel)
+ {
+ if(sqlsrv_begin_transaction($connection) === false)
+ {
+ return;
+ }
+ }
+ else
+ {
+ $this->_query("SAVE TRANS SP" . $transactionLevel, $connection);
+ }
+ return true;
+ }
- /**
- * DB transaction rollback
- * this method is private
- * @return boolean
- */
- function _rollback() {
- $connection = $this->_getConnection('master');
- sqlsrv_rollback($connection);
- return true;
- }
+ /**
+ * DB transaction rollback
+ * this method is private
+ * @return boolean
+ */
+ function _rollback($transactionLevel)
+ {
+ $connection = $this->_getConnection('master');
- /**
- * DB transaction commit
- * this method is private
- * @return boolean
- */
- function _commit() {
- $connection = $this->_getConnection('master');
- sqlsrv_commit($connection);
- return true;
- }
+ $point = $transactionLevel - 1;
- /**
- * Execute the query
- * this method is private
- * @param string $query
- * @param resource $connection
- * @return resource|boolean Returns a statement resource on success and FALSE if an error occurred.
- */
- function __query($query, $connection) {
- $_param = array();
+ if($point)
+ {
+ $this->_query("ROLLBACK TRANS SP" . $point, $connection);
+ }
+ else
+ {
+ sqlsrv_rollback($connection);
+ }
+ return true;
+ }
- if(count($this->param)){
- foreach($this->param as $k => $o){
- if($o->isColumnName()) continue;
- if($o->getType() == 'number'){
- $value = $o->getUnescapedValue();
- if(is_array($value)) $_param = array_merge($_param, $value);
- else $_param[] = $o->getUnescapedValue();
- }else{
- $value = $o->getUnescapedValue();
- if(is_array($value)) {
- foreach($value as $v)
- $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
- }
- else $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
+ /**
+ * DB transaction commit
+ * this method is private
+ * @return boolean
+ */
+ function _commit()
+ {
+ $connection = $this->_getConnection('master');
+ sqlsrv_commit($connection);
+ return true;
+ }
+
+ /**
+ * Execute the query
+ * this method is private
+ * @param string $query
+ * @param resource $connection
+ * @return resource|boolean Returns a statement resource on success and FALSE if an error occurred.
+ */
+ function __query($query, $connection)
+ {
+ $_param = array();
+
+ if(count($this->param))
+ {
+ foreach($this->param as $k => $o)
+ {
+ if($o->isColumnName())
+ {
+ continue;
+ }
+ if($o->getType() == 'number')
+ {
+ $value = $o->getUnescapedValue();
+ if(is_array($value))
+ {
+ $_param = array_merge($_param, $value);
+ }
+ else
+ {
+ $_param[] = $o->getUnescapedValue();
+ }
+ }
+ else
+ {
+ $value = $o->getUnescapedValue();
+ if(is_array($value))
+ {
+ foreach($value as $v)
+ {
+ $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
}
- }
- }
-
- // Run the query statement
- $result = false;
- if(count($_param)){
- $args = $this->_getParametersByReference($_param);
- $stmt = sqlsrv_prepare($connection, $query, $args);
- }else{
- $stmt = sqlsrv_prepare($connection, $query);
+ }
+ else
+ {
+ $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
+ }
+ }
}
-
- if(!$stmt)
- {
- $result = false;
- }
- else
- {
- $result = sqlsrv_execute($stmt);
- }
-
- // Error Check
- if(!$result)
- $this->setError(print_r(sqlsrv_errors(),true));
+ }
- $this->param = array();
-
- return $stmt;
- }
-
- /**
- * Parameters to sqlsrv_prepare need to be references, and not literals
- * Parameters are sent as an array, where each parameter can be:
- * - a PHP variable (by reference)
- * - a PHP array (containng param value, type and direction) -> also needs to be sent by reference
- * @param array $_param
- * @return array
- */
- function _getParametersByReference($_param)
+ // Run the query statement
+ $result = false;
+ if(count($_param))
{
- $copy = array(); $args = array(); $i = 0;
- foreach($_param as $key => $value) {
- if(is_array($value))
- {
- $value_copy = $value;
- $value_arg = array();
- $value_arg[] = &$value_copy[0];
- $value_arg[] = $value_copy[1];
- $value_arg[] = $value_copy[2];
- }
- else
- {
- $value_arg = $value;
- }
- $copy[$key] = $value_arg;
- $args[$i++] = &$copy[$key];
- }
- return $args;
+ $args = $this->_getParametersByReference($_param);
+ $stmt = sqlsrv_prepare($connection, $query, $args);
+ }
+ else
+ {
+ $stmt = sqlsrv_prepare($connection, $query);
}
- /**
- * Fetch results
- * @param resource $result
- * @param int|NULL $arrayIndexEndValue
- * @return array
- */
- function _fetch($result, $arrayIndexEndValue = NULL) {
- $output = array();
- if(!$this->isConnected() || $this->isError() || !$result) return $output;
+ if(!$stmt)
+ {
+ $result = false;
+ }
+ else
+ {
+ $result = sqlsrv_execute($stmt);
+ }
- $c = sqlsrv_num_fields($result);
- $m = null;
+ // Error Check
+ if(!$result)
+ {
+ $this->setError(print_r(sqlsrv_errors(), true));
+ }
- while(sqlsrv_fetch($result)){
- if(!$m) $m = sqlsrv_field_metadata($result);
- unset($row);
- for($i=0;$i<$c;$i++){
- $row->{$m[$i]['Name']} = sqlsrv_get_field( $result, $i, SQLSRV_PHPTYPE_STRING( 'utf-8' ));
- }
- if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $row;
- else $output[] = $row;
+ $this->param = array();
+
+ return $stmt;
+ }
+
+ /**
+ * Parameters to sqlsrv_prepare need to be references, and not literals
+ * Parameters are sent as an array, where each parameter can be:
+ * - a PHP variable (by reference)
+ * - a PHP array (containng param value, type and direction) -> also needs to be sent by reference
+ * @param array $_param
+ * @return array
+ */
+ function _getParametersByReference($_param)
+ {
+ $copy = array();
+ $args = array();
+ $i = 0;
+ foreach($_param as $key => $value)
+ {
+ if(is_array($value))
+ {
+ $value_copy = $value;
+ $value_arg = array();
+ $value_arg[] = &$value_copy[0];
+ $value_arg[] = $value_copy[1];
+ $value_arg[] = $value_copy[2];
}
-
- if(count($output)==1) {
- if(isset($arrayIndexEndValue)) return $output;
- else return $output[0];
- }
- return $output;
-
- }
-
- /**
- * Return the sequence value incremented by 1
- * Auto_increment column only used in the sequence table
- * @return int
- */
- function getNextSequence() {
- $query = sprintf("insert into %ssequence (seq) values (ident_incr('%ssequence'))", $this->prefix, $this->prefix);
- $this->_query($query);
-
- $query = sprintf("select ident_current('%ssequence')+1 as sequence", $this->prefix);
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
-
-
- return $tmp->sequence;
- }
-
- /**
- * Check a table exists status
- * @param string $target_name
- * @return boolean
- */
- function isTableExists($target_name) {
- $query = sprintf("select name from sysobjects where name = '%s%s' and xtype='U'", $this->prefix, $this->addQuotes($target_name));
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
-
- if(!$tmp) return false;
- return true;
- }
-
- /**
- * Add a column to the table
- * @param string $table_name table name
- * @param string $column_name column name
- * @param string $type column type, default value is 'number'
- * @param int $size column size
- * @param string|int $default default value
- * @param boolean $notnull not null status, default value is false
- * @return void
- */
- function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
- if($this->isColumnExists($table_name, $column_name)) return;
- $type = $this->column_type[$type];
- if(strtoupper($type)=='INTEGER') $size = '';
-
- $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
- if($size) $query .= sprintf(" %s(%s) ", $type, $size);
- else $query .= sprintf(" %s ", $type);
- if($default) $query .= sprintf(" default '%s' ", $default);
- if($notnull) $query .= " not null ";
-
- return $this->_query($query);
- }
-
- /**
- * Drop a column from the table
- * @param string $table_name table name
- * @param string $column_name column name
- * @return void
- */
- function dropColumn($table_name, $column_name) {
- if(!$this->isColumnExists($table_name, $column_name)) return;
- $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
- $this->_query($query);
- }
-
- /**
- * Check column exist status of the table
- * @param string $table_name table name
- * @param string $column_name column name
- * @return boolean
- */
- function isColumnExists($table_name, $column_name) {
- $query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name);
- $result = $this->_query($query);
- if($this->isError()) return;
- $tmp = $this->_fetch($result);
- if(!$tmp->name) return false;
- return true;
- }
-
- /**
- * Add an index to the table
- * $target_columns = array(col1, col2)
- * $is_unique? unique : none
- * @param string $table_name table name
- * @param string $index_name index name
- * @param string|array $target_columns target column or columns
- * @param boolean $is_unique
- * @return void
- */
- function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
- if($this->isIndexExists($table_name, $index_name)) return;
- if(!is_array($target_columns)) $target_columns = array($target_columns);
-
- $query = sprintf("create %s index %s on %s%s (%s)", $is_unique?'unique':'', $index_name, $this->prefix, $table_name, implode(',',$target_columns));
- $this->_query($query);
- }
-
- /**
- * Drop an index from the table
- * @param string $table_name table name
- * @param string $index_name index name
- * @param boolean $is_unique
- * @return void
- */
- function dropIndex($table_name, $index_name, $is_unique = false) {
- if(!$this->isIndexExists($table_name, $index_name)) return;
- $query = sprintf("drop index %s%s.%s", $this->prefix, $table_name, $index_name);
- $this->_query($query);
- }
-
- /**
- * Check index status of the table
- * @param string $table_name table name
- * @param string $index_name index name
- * @return boolean
- */
- function isIndexExists($table_name, $index_name) {
- $query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name);
-
- $result = $this->_query($query);
- if($this->isError()) return;
- $tmp = $this->_fetch($result);
-
- if(!$tmp->name) return false;
- return true;
- }
-
- /**
- * Creates a table by using xml contents
- * @param string $xml_doc xml schema contents
- * @return void|object
- */
- function createTableByXml($xml_doc) {
- return $this->_createTable($xml_doc);
- }
-
- /**
- * Creates a table by using xml file path
- * @param string $file_name xml schema file path
- * @return void|object
- */
- function createTableByXmlFile($file_name) {
- if(!file_exists($file_name)) return;
- // read xml file
- $buff = FileHandler::readFile($file_name);
- return $this->_createTable($buff);
- }
-
- /**
- * Create table by using the schema xml
- *
- * type : number, varchar, tinytext, text, bigtext, char, date, \n
- * opt : notnull, default, size\n
- * index : primary key, index, unique\n
- * @param string $xml_doc xml schema contents
- * @return void|object
- */
- function _createTable($xml_doc) {
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
- if($this->isTableExists($table_name)) return;
-
- if($table_name == 'sequence') {
- $table_name = $this->prefix.$table_name;
- $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name);
- return $this->_query($query);
- } else {
- $table_name = $this->prefix.$table_name;
-
- if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
- else $columns = $xml_obj->table->column;
-
- $primary_list = array();
- $unique_list = array();
- $index_list = array();
-
- $typeList = array('number'=>1, 'text'=>1);
- foreach($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
- $auto_increment = $column->attrs->auto_increment;
-
- $column_schema[] = sprintf('[%s] %s%s %s %s %s',
- $name,
- $this->column_type[$type],
- !isset($typeList[$type])&&$size?'('.$size.')':'',
- isset($default)?"default '".$default."'":'',
- $notnull?'not null':'null',
- $auto_increment?'identity(1,1)':''
- );
-
- if($primary_key) $primary_list[] = $name;
- else if($unique) $unique_list[$unique][] = $name;
- else if($index) $index_list[$index][] = $name;
- }
-
- if(count($primary_list))
- {
- $column_schema[] = sprintf("primary key (%s)", '"'.implode($primary_list,'","').'"');
- }
-
- $schema = sprintf('create table [%s] (%s%s)', $this->addQuotes($table_name), "\n", implode($column_schema,",\n"));
- $output = $this->_query($schema);
- if(!$output) return false;
-
- if(count($unique_list)) {
- foreach($unique_list as $key => $val) {
- $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '['.implode('],[',$val).']');
- $this->_query($query);
- }
- }
-
- if(count($index_list)) {
- foreach($index_list as $key => $val) {
- $query = sprintf("create index %s on %s (%s);", $key, $table_name, '['.implode('],[',$val).']');
- $this->_query($query);
- }
- }
- return true;
- }
- }
-
-
-
- /**
- * Handles insertAct
- * @todo Lookup _filterNumber against sql injection - see if it is still needed and how to integrate
- * @param Object $queryObject
- * @return resource
- */
- function _executeInsertAct($queryObject) {
- $query = $this->getInsertSql($queryObject, false);
- $this->param = $queryObject->getArguments();
- return $this->_query($query);
- }
-
- /**
- * Handles updateAct
- * @param Object $queryObject
- * @return resource
- */
- function _executeUpdateAct($queryObject) {
- $query = $this->getUpdateSql($queryObject, false);
- $this->param = $queryObject->getArguments();
- return $this->_query($query);
- }
-
- /**
- * Return update query string
- * @param object $query
- * @param boolean $with_values
- * @param boolean $with_priority
- * @return string
- */
- function getUpdateSql($query, $with_values = true, $with_priority = false){
- $columnsList = $query->getUpdateString($with_values);
- if($columnsList == '') return new Object(-1, "Invalid query");
-
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
-
- $tables = $query->getTables();
- $alias_list = '';
- foreach($tables as $table)
- $alias_list .= $table->getAlias();
- implode(',', explode(' ', $alias_list));
-
- $where = $query->getWhereString($with_values);
- if($where != '') $where = ' WHERE ' . $where;
-
- $priority = $with_priority?$query->getPriority():'';
-
- return "UPDATE $priority $alias_list SET $columnsList FROM ".$from.$where;
- }
-
- /**
- * Handles deleteAct
- * @param Object $queryObject
- * @return resource
- */
- function _executeDeleteAct($queryObject) {
- $query = $this->getDeleteSql($queryObject, false);
- $this->param = $queryObject->getArguments();
- return $this->_query($query);
- }
-
- /**
- * Return select query string
- * @param object $query
- * @param boolean $with_values
- * @return string
- */
- function getSelectSql($query, $with_values = TRUE){
- $with_values = false;
-
- //$limitOffset = $query->getLimit()->getOffset();
- //if($limitOffset)
- // TODO Implement Limit with offset with subquery
- $limit = '';$limitCount = '';
- $limitQueryPart = $query->getLimit();
- if($limitQueryPart)
- $limitCount = $limitQueryPart->getLimit();
- if($limitCount != '') $limit = 'SELECT TOP ' . $limitCount;
-
- $select = $query->getSelectString($with_values);
- if($select == '') return new Object(-1, "Invalid query");
- if($limit != '')
- $select = $limit.' '.$select;
else
- $select = 'SELECT ' .$select;
+ {
+ $value_arg = $value;
+ }
+ $copy[$key] = $value_arg;
+ $args[$i++] = &$copy[$key];
+ }
+ return $args;
+ }
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
- $from = ' FROM '.$from;
-
- $where = $query->getWhereString($with_values);
- if($where != '') $where = ' WHERE ' . $where;
-
- $groupBy = $query->getGroupByString();
- if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
-
- $orderBy = $query->getOrderByString();
- if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
-
-
-
- return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy;
- }
-
- /**
- * Handle selectAct
- * In order to get a list of pages easily when selecting \n
- * it supports a method as navigation
- * @param Object $queryObject
- * @param resource $connection
- * @return Object
- */
- function _executeSelectAct($queryObject, $connection = null) {
- $query = $this->getSelectSql($queryObject);
-
- if(strpos($query, "substr")) $query = str_replace ("substr", "substring", $query);
-
- // TODO Decide if we continue to pass parameters like this
- $this->param = $queryObject->getArguments();
-
- $query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
- $result = $this->_query($query, $connection);
-
- if ($this->isError ()) return $this->queryError($queryObject);
- else return $this->queryPageLimit($queryObject, $result, $connection);
- }
-
- /**
- * Return the DBParser
- * @param boolean $force
- * @return DBParser
- */
- function getParser($force = FALSE){
- return new DBParser("[", "]", $this->prefix);
- }
-
- /**
- * If have a error, return error object
- * @param Object $queryObject
- * @return Object
- */
- function queryError($queryObject){
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()){
- $buff = new Object ();
- $buff->total_count = 0;
- $buff->total_page = 0;
- $buff->page = 1;
- $buff->data = array ();
- $buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
- return $buff;
- }else
- return;
+ /**
+ * Fetch results
+ * @param resource $result
+ * @param int|NULL $arrayIndexEndValue
+ * @return array
+ */
+ function _fetch($result, $arrayIndexEndValue = NULL)
+ {
+ $output = array();
+ if(!$this->isConnected() || $this->isError() || !$result)
+ {
+ return $output;
}
- /**
- * If select query execute, return page info
- * @param Object $queryObject
- * @param resource $result
- * @param resource $connection
- * @return Object Object with page info containing
- */
- function queryPageLimit($queryObject, $result, $connection) {
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()) {
- // Total count
- $temp_where = $queryObject->getWhereString(true, false);
- $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
+ $c = sqlsrv_num_fields($result);
+ $m = null;
- // Check for distinct query and if found update count query structure
- $temp_select = $queryObject->getSelectString(true);
- $uses_distinct = strpos(strtolower($temp_select), "distinct") !== false;
- $uses_groupby = $queryObject->getGroupByString() != '';
- if($uses_distinct || $uses_groupby) {
- $count_query = sprintf('select %s %s %s %s'
- , $temp_select
- , 'FROM ' . $queryObject->getFromString(true)
- , ($temp_where === '' ? '' : ' WHERE '. $temp_where)
- , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '')
- );
+ while(sqlsrv_fetch($result))
+ {
+ if(!$m)
+ {
+ $m = sqlsrv_field_metadata($result);
+ }
+ unset($row);
+ for($i = 0; $i < $c; $i++)
+ {
+ $row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8'));
+ }
+ if($arrayIndexEndValue)
+ {
+ $output[$arrayIndexEndValue--] = $row;
+ }
+ else
+ {
+ $output[] = $row;
+ }
+ }
- // If query uses grouping or distinct, count from original select
- $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
- }
+ if(count($output) == 1)
+ {
+ if(isset($arrayIndexEndValue))
+ {
+ return $output;
+ }
+ else
+ {
+ return $output[0];
+ }
+ }
+ return $output;
+ }
- $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- $this->param = $queryObject->getArguments();
- $result_count = $this->_query($count_query, $connection);
- $count_output = $this->_fetch($result_count);
- $total_count = (int) $count_output->count;
+ /**
+ * Return the sequence value incremented by 1
+ * Auto_increment column only used in the sequence table
+ * @return int
+ */
+ function getNextSequence()
+ {
+ $query = sprintf("insert into %ssequence (seq) values (ident_incr('%ssequence'))", $this->prefix, $this->prefix);
+ $this->_query($query);
- $list_count = $limit->list_count->getValue();
- if (!$list_count)
- $list_count = 20;
- $page_count = $limit->page_count->getValue();
- if (!$page_count)
- $page_count = 10;
- $page = $limit->page->getValue();
- if (!$page)
- $page = 1;
- // Total pages
- if ($total_count) {
- $total_page = (int) (($total_count - 1) / $list_count) + 1;
- } else
- $total_page = 1;
+ $query = sprintf("select ident_current('%ssequence')+1 as sequence", $this->prefix);
+ $result = $this->_query($query);
+ $tmp = $this->_fetch($result);
- // check the page variables
- if ($page > $total_page) {
- // If requested page is bigger than total number of pages, return empty list
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = array();
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- return $buff;
+ return $tmp->sequence;
+ }
+
+ /**
+ * Check a table exists status
+ * @param string $target_name
+ * @return boolean
+ */
+ function isTableExists($target_name)
+ {
+ $query = sprintf("select name from sysobjects where name = '%s%s' and xtype='U'", $this->prefix, $this->addQuotes($target_name));
+ $result = $this->_query($query);
+ $tmp = $this->_fetch($result);
+
+ if(!$tmp)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Add a column to the table
+ * @param string $table_name table name
+ * @param string $column_name column name
+ * @param string $type column type, default value is 'number'
+ * @param int $size column size
+ * @param string|int $default default value
+ * @param boolean $notnull not null status, default value is false
+ * @return void
+ */
+ function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
+ {
+ if($this->isColumnExists($table_name, $column_name))
+ {
+ return;
+ }
+ $type = $this->column_type[$type];
+ if(strtoupper($type) == 'INTEGER')
+ {
+ $size = '';
+ }
+
+ $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
+ if($size)
+ {
+ $query .= sprintf(" %s(%s) ", $type, $size);
+ }
+ else
+ {
+ $query .= sprintf(" %s ", $type);
+ }
+
+ if($default)
+ {
+ $query .= sprintf(" default '%s' ", $default);
+ }
+ if($notnull)
+ {
+ $query .= " not null ";
+ }
+
+ return $this->_query($query);
+ }
+
+ /**
+ * Drop a column from the table
+ * @param string $table_name table name
+ * @param string $column_name column name
+ * @return void
+ */
+ function dropColumn($table_name, $column_name)
+ {
+ if(!$this->isColumnExists($table_name, $column_name))
+ {
+ return;
+ }
+ $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
+ $this->_query($query);
+ }
+
+ /**
+ * Check column exist status of the table
+ * @param string $table_name table name
+ * @param string $column_name column name
+ * @return boolean
+ */
+ function isColumnExists($table_name, $column_name)
+ {
+ $query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name);
+ $result = $this->_query($query);
+ if($this->isError())
+ {
+ return;
+ }
+ $tmp = $this->_fetch($result);
+ if(!$tmp->name)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Add an index to the table
+ * $target_columns = array(col1, col2)
+ * $is_unique? unique : none
+ * @param string $table_name table name
+ * @param string $index_name index name
+ * @param string|array $target_columns target column or columns
+ * @param boolean $is_unique
+ * @return void
+ */
+ function addIndex($table_name, $index_name, $target_columns, $is_unique = false)
+ {
+ if($this->isIndexExists($table_name, $index_name))
+ {
+ return;
+ }
+ if(!is_array($target_columns))
+ {
+ $target_columns = array($target_columns);
+ }
+
+ $query = sprintf("create %s index %s on %s%s (%s)", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, implode(',', $target_columns));
+ $this->_query($query);
+ }
+
+ /**
+ * Drop an index from the table
+ * @param string $table_name table name
+ * @param string $index_name index name
+ * @param boolean $is_unique
+ * @return void
+ */
+ function dropIndex($table_name, $index_name, $is_unique = false)
+ {
+ if(!$this->isIndexExists($table_name, $index_name))
+ {
+ return;
+ }
+ $query = sprintf("drop index %s%s.%s", $this->prefix, $table_name, $index_name);
+ $this->_query($query);
+ }
+
+ /**
+ * Check index status of the table
+ * @param string $table_name table name
+ * @param string $index_name index name
+ * @return boolean
+ */
+ function isIndexExists($table_name, $index_name)
+ {
+ $query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name);
+
+ $result = $this->_query($query);
+ if($this->isError())
+ {
+ return;
+ }
+ $tmp = $this->_fetch($result);
+
+ if(!$tmp->name)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Creates a table by using xml contents
+ * @param string $xml_doc xml schema contents
+ * @return void|object
+ */
+ function createTableByXml($xml_doc)
+ {
+ return $this->_createTable($xml_doc);
+ }
+
+ /**
+ * Creates a table by using xml file path
+ * @param string $file_name xml schema file path
+ * @return void|object
+ */
+ function createTableByXmlFile($file_name)
+ {
+ if(!file_exists($file_name))
+ {
+ return;
+ }
+ // read xml file
+ $buff = FileHandler::readFile($file_name);
+ return $this->_createTable($buff);
+ }
+
+ /**
+ * Create table by using the schema xml
+ *
+ * type : number, varchar, tinytext, text, bigtext, char, date, \n
+ * opt : notnull, default, size\n
+ * index : primary key, index, unique\n
+ * @param string $xml_doc xml schema contents
+ * @return void|object
+ */
+ function _createTable($xml_doc)
+ {
+ // xml parsing
+ $oXml = new XmlParser();
+ $xml_obj = $oXml->parse($xml_doc);
+ // Create a table schema
+ $table_name = $xml_obj->table->attrs->name;
+ if($this->isTableExists($table_name))
+ {
+ return;
+ }
+
+ if($table_name == 'sequence')
+ {
+ $table_name = $this->prefix . $table_name;
+ $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name);
+ return $this->_query($query);
+ }
+ else
+ {
+ $table_name = $this->prefix . $table_name;
+
+ if(!is_array($xml_obj->table->column))
+ {
+ $columns[] = $xml_obj->table->column;
+ }
+ else
+ {
+ $columns = $xml_obj->table->column;
+ }
+
+ $primary_list = array();
+ $unique_list = array();
+ $index_list = array();
+
+ $typeList = array('number' => 1, 'text' => 1);
+ foreach($columns as $column)
+ {
+ $name = $column->attrs->name;
+ $type = $column->attrs->type;
+ $size = $column->attrs->size;
+ $notnull = $column->attrs->notnull;
+ $primary_key = $column->attrs->primary_key;
+ $index = $column->attrs->index;
+ $unique = $column->attrs->unique;
+ $default = $column->attrs->default;
+ $auto_increment = $column->attrs->auto_increment;
+
+ $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : '');
+
+ if($primary_key)
+ {
+ $primary_list[] = $name;
+ }
+ else if($unique)
+ {
+ $unique_list[$unique][] = $name;
+ }
+ else if($index)
+ {
+ $index_list[$index][] = $name;
+ }
+ }
+
+ if(count($primary_list))
+ {
+ $column_schema[] = sprintf("primary key (%s)", '"' . implode($primary_list, '","') . '"');
+ }
+
+ $schema = sprintf('create table [%s] (%s%s)', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"));
+ $output = $this->_query($schema);
+ if(!$output)
+ {
+ return false;
+ }
+
+ if(count($unique_list))
+ {
+ foreach($unique_list as $key => $val)
+ {
+ $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']');
+ $this->_query($query);
+ }
+ }
+
+ if(count($index_list))
+ {
+ foreach($index_list as $key => $val)
+ {
+ $query = sprintf("create index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']');
+ $this->_query($query);
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Handles insertAct
+ * @todo Lookup _filterNumber against sql injection - see if it is still needed and how to integrate
+ * @param Object $queryObject
+ * @return resource
+ */
+ function _executeInsertAct($queryObject)
+ {
+ $query = $this->getInsertSql($queryObject, false);
+ $this->param = $queryObject->getArguments();
+ return $this->_query($query);
+ }
+
+ /**
+ * Handles updateAct
+ * @param Object $queryObject
+ * @return resource
+ */
+ function _executeUpdateAct($queryObject)
+ {
+ $query = $this->getUpdateSql($queryObject, false);
+ $this->param = $queryObject->getArguments();
+ return $this->_query($query);
+ }
+
+ /**
+ * Return update query string
+ * @param object $query
+ * @param boolean $with_values
+ * @param boolean $with_priority
+ * @return string
+ */
+ function getUpdateSql($query, $with_values = true, $with_priority = false)
+ {
+ $columnsList = $query->getUpdateString($with_values);
+ if($columnsList == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+
+ $from = $query->getFromString($with_values);
+ if($from == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+
+ $tables = $query->getTables();
+ $alias_list = '';
+ foreach($tables as $table)
+ {
+ $alias_list .= $table->getAlias();
+ }
+ implode(',', explode(' ', $alias_list));
+
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $where = ' WHERE ' . $where;
+ }
+
+ $priority = $with_priority ? $query->getPriority() : '';
+
+ return "UPDATE $priority $alias_list SET $columnsList FROM " . $from . $where;
+ }
+
+ /**
+ * Handles deleteAct
+ * @param Object $queryObject
+ * @return resource
+ */
+ function _executeDeleteAct($queryObject)
+ {
+ $query = $this->getDeleteSql($queryObject, false);
+ $this->param = $queryObject->getArguments();
+ return $this->_query($query);
+ }
+
+ /**
+ * Return select query string
+ * @param object $query
+ * @param boolean $with_values
+ * @return string
+ */
+ function getSelectSql($query, $with_values = TRUE, $connection=NULL)
+ {
+ $with_values = false;
+
+ //$limitOffset = $query->getLimit()->getOffset();
+ //if($limitOffset)
+ // TODO Implement Limit with offset with subquery
+ $limit = '';
+ $limitCount = '';
+ $limitQueryPart = $query->getLimit();
+ if($limitQueryPart)
+ {
+ $limitCount = $limitQueryPart->getLimit();
+ }
+ if($limitCount != '')
+ {
+ $limit = 'SELECT TOP ' . $limitCount;
+ }
+
+ $select = $query->getSelectString($with_values);
+ if($select == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ if($limit != '')
+ {
+ $select = $limit . ' ' . $select;
+ }
+ else
+ {
+ $select = 'SELECT ' . $select;
+ }
+
+ $from = $query->getFromString($with_values);
+ if($from == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $from = ' FROM ' . $from;
+
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $where = ' WHERE ' . $where;
+ }
+
+ $groupBy = $query->getGroupByString();
+ if($groupBy != '')
+ {
+ $groupBy = ' GROUP BY ' . $groupBy;
+ }
+
+ $orderBy = $query->getOrderByString();
+ if($orderBy != '')
+ {
+ $orderBy = ' ORDER BY ' . $orderBy;
+ }
+
+ if($limitCount != '' && $query->limit->start > 0)
+ {
+ $order = $query->getOrder();
+ $first_columns = array();
+ foreach($order as $val)
+ {
+ $tmpColumnName = $val->getPureColumnName();
+ $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder()=='asc'?'max':'min', $tmpColumnName, $tmpColumnName);
+ $first_sub_columns[] = $tmpColumnName;
+ }
+
+ $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',',$first_columns), $query->limit->start, implode(',',$first_sub_columns), $from, $where, $groupBy, $orderBy);
+ $this->param = $query->getArguments();
+ $result = $this->__query($first_query, $connection);
+ $tmp = $this->_fetch($result);
+
+ $sub_cond = array();
+ foreach($order as $k => $v)
+ {
+ //for example... use Document
+ if(get_class($v->sort_order) == 'SortArgument')
+ {
+ $sort_order = $v->sort_order->value;
+ }
+ //for example... use comment, file
+ else
+ {
+ $sort_order = $v->sort_order;
}
- $start_count = ($page - 1) * $list_count;
- $this->param = $queryObject->getArguments();
- $virtual_no = $total_count - $start_count;
- $data = $this->_fetch($result, $virtual_no);
+ $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order=='asc'?'>':'<', $tmp->{$v->getPureColumnName()});
+ }
+
+ if(!$where)
+ {
+ $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )';
+ }
+ else
+ {
+ $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )';
+ }
+ }
+ return $select . ' ' . $from . ' ' . $where .$sub_condition. ' ' . $groupBy . ' ' . $orderBy;
+ }
+
+ /**
+ * Handle selectAct
+ * In order to get a list of pages easily when selecting \n
+ * it supports a method as navigation
+ * @param Object $queryObject
+ * @param resource $connection
+ * @return Object
+ */
+ function _executeSelectAct($queryObject, $connection = null)
+ {
+ $query = $this->getSelectSql($queryObject, true, $connection);
+
+ if(strpos($query, "substr"))
+ {
+ $query = str_replace("substr", "substring", $query);
+ }
+
+ // TODO Decide if we continue to pass parameters like this
+ $this->param = $queryObject->getArguments();
+
+ $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+ $result = $this->_query($query, $connection);
+
+ if($this->isError())
+ {
+ return $this->queryError($queryObject);
+ }
+ else
+ {
+ return $this->queryPageLimit($queryObject, $result, $connection);
+ }
+ }
+
+ /**
+ * Return the DBParser
+ * @param boolean $force
+ * @return DBParser
+ */
+ function getParser($force = FALSE)
+ {
+ return new DBParser("[", "]", $this->prefix);
+ }
+
+ /**
+ * If have a error, return error object
+ * @param Object $queryObject
+ * @return Object
+ */
+ function queryError($queryObject)
+ {
+ $limit = $queryObject->getLimit();
+ if($limit && $limit->isPageHandler())
+ {
+ $buff = new Object ();
+ $buff->total_count = 0;
+ $buff->total_page = 0;
+ $buff->page = 1;
+ $buff->data = array();
+ $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
+ return $buff;
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ /**
+ * If select query execute, return page info
+ * @param Object $queryObject
+ * @param resource $result
+ * @param resource $connection
+ * @return Object Object with page info containing
+ */
+ function queryPageLimit($queryObject, $result, $connection)
+ {
+ $limit = $queryObject->getLimit();
+ if($limit && $limit->isPageHandler())
+ {
+ // Total count
+ $temp_where = $queryObject->getWhereString(true, false);
+ $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
+
+ // Check for distinct query and if found update count query structure
+ $temp_select = $queryObject->getSelectString(true);
+ $uses_distinct = strpos(strtolower($temp_select), "distinct") !== false;
+ $uses_groupby = $queryObject->getGroupByString() != '';
+ if($uses_distinct || $uses_groupby)
+ {
+ $count_query = sprintf('select %s %s %s %s'
+ , $temp_select
+ , 'FROM ' . $queryObject->getFromString(true)
+ , ($temp_where === '' ? '' : ' WHERE ' . $temp_where)
+ , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '')
+ );
+
+ // If query uses grouping or distinct, count from original select
+ $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
+ }
+
+ $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+ $this->param = $queryObject->getArguments();
+ $result_count = $this->_query($count_query, $connection);
+ $count_output = $this->_fetch($result_count);
+ $total_count = (int) $count_output->count;
+
+ $list_count = $limit->list_count->getValue();
+ if(!$list_count)
+ {
+ $list_count = 20;
+ }
+ $page_count = $limit->page_count->getValue();
+ if(!$page_count)
+ {
+ $page_count = 10;
+ }
+ $page = $limit->page->getValue();
+ if(!$page || $page < 1)
+ {
+ $page = 1;
+ }
+ // Total pages
+ if($total_count)
+ {
+ $total_page = (int) (($total_count - 1) / $list_count) + 1;
+ }
+ else
+ {
+ $total_page = 1;
+ }
+
+ // check the page variables
+ if($page > $total_page)
+ {
+ // If requested page is bigger than total number of pages, return empty list
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $page;
- $buff->data = $data;
+ $buff->data = array();
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- }else {
- $data = $this->_fetch($result);
- $buff = new Object ();
- $buff->data = $data;
+ return $buff;
if($queryObject->usesClickCount())
{
@@ -736,8 +996,28 @@
$this->_executeUpdateAct($update_query);
}
}
- return $buff;
- }
- }
-?>
+ $start_count = ($page - 1) * $list_count;
+ $this->param = $queryObject->getArguments();
+ $virtual_no = $total_count - $start_count;
+ $data = $this->_fetch($result, $virtual_no);
+
+ $buff = new Object ();
+ $buff->total_count = $total_count;
+ $buff->total_page = $total_page;
+ $buff->page = $page;
+ $buff->data = $data;
+ $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
+ }
+ else
+ {
+ $data = $this->_fetch($result);
+ $buff = new Object ();
+ $buff->data = $data;
+ }
+ return $buff;
+ }
+
+}
+/* End of file DBMssql.class.php */
+/* Location: ./classes/db/DBMssql.class.php */
diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php
index 799f522d3..1e845a368 100644
--- a/classes/db/DBMysql.class.php
+++ b/classes/db/DBMysql.class.php
@@ -1,4 +1,5 @@
'bigint',
- 'number' => 'bigint',
- 'varchar' => 'varchar',
- 'char' => 'char',
- 'text' => 'text',
- 'bigtext' => 'longtext',
- 'date' => 'varchar(14)',
- 'float' => 'float',
- );
+ */
+ var $column_type = array(
+ 'bignumber' => 'bigint',
+ 'number' => 'bigint',
+ 'varchar' => 'varchar',
+ 'char' => 'char',
+ 'text' => 'text',
+ 'bigtext' => 'longtext',
+ 'date' => 'varchar(14)',
+ 'float' => 'float',
+ );
- /**
- * Constructor
+ /**
+ * Constructor
* @return void
- */
- function DBMysql() {
- $this->_setDBInfo();
- $this->_connect();
- }
+ */
+ function DBMysql()
+ {
+ $this->_setDBInfo();
+ $this->_connect();
+ }
/**
* Create an instance of this class
* @return DBMysql return DBMysql object instance
*/
- function create() {
- return new DBMysql;
- }
+ function create()
+ {
+ return new DBMysql;
+ }
/**
* Return if supportable
* Check 'mysql_connect' function exists.
* @return boolean
*/
- function isSupported() {
- if(!function_exists('mysql_connect')) return false;
- return true;
- }
+ function isSupported()
+ {
+ if(!function_exists('mysql_connect'))
+ {
+ return false;
+ }
+ return true;
+ }
/**
* DB Connect
@@ -69,32 +77,42 @@ class DBMysql extends DB {
* @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
* @return resource
*/
- function __connect($connection) {
- // Ignore if no DB information exists
- if (strpos($connection["db_hostname"], ':') === false && $connection["db_port"])
- $connection["db_hostname"] .= ':' . $connection["db_port"];
+ function __connect($connection)
+ {
+ // Ignore if no DB information exists
+ if(strpos($connection["db_hostname"], ':') === false && $connection["db_port"])
+ {
+ $connection["db_hostname"] .= ':' . $connection["db_port"];
+ }
- // Attempt to connect
- $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
+ // Attempt to connect
+ $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
+ if(!$result)
+ {
+ exit('XE cannot connect to DB.');
+ }
- if(mysql_error()) {
- $this->setError(mysql_errno(), mysql_error());
- return;
- }
- // Error appears if the version is lower than 4.1
- if(mysql_get_server_info($result)<"4.1") {
- $this->setError(-1, "XE cannot be installed under the version of mysql 4.1. Current mysql version is ".mysql_get_server_info());
- return;
- }
- // select db
- @mysql_select_db($connection["db_database"], $result);
- if(mysql_error()) {
- $this->setError(mysql_errno(), mysql_error());
- return;
- }
+ if(mysql_error())
+ {
+ $this->setError(mysql_errno(), mysql_error());
+ return;
+ }
+ // Error appears if the version is lower than 4.1
+ if(mysql_get_server_info($result) < "4.1")
+ {
+ $this->setError(-1, "XE cannot be installed under the version of mysql 4.1. Current mysql version is " . mysql_get_server_info());
+ return;
+ }
+ // select db
+ @mysql_select_db($connection["db_database"], $result);
+ if(mysql_error())
+ {
+ $this->setError(mysql_errno(), mysql_error());
+ return;
+ }
- return $result;
- }
+ return $result;
+ }
/**
* If have a task after connection, add a taks in this method
@@ -102,10 +120,11 @@ class DBMysql extends DB {
* @param resource $connection
* @return void
*/
- function _afterConnect($connection){
- // Set utf8 if a database is MySQL
- $this->_query("set names 'utf8'", $connection);
- }
+ function _afterConnect($connection)
+ {
+ // Set utf8 if a database is MySQL
+ $this->_query("set names 'utf8'", $connection);
+ }
/**
* DB disconnection
@@ -113,47 +132,58 @@ class DBMysql extends DB {
* @param resource $connection
* @return void
*/
- function _close($connection) {
- @mysql_close($connection);
- }
+ function _close($connection)
+ {
+ @mysql_close($connection);
+ }
/**
* Handles quatation of the string variables from the query
* @param string $string
* @return string
*/
- function addQuotes($string) {
- if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
- if(!is_numeric($string)) $string = @mysql_real_escape_string($string);
- return $string;
- }
+ function addQuotes($string)
+ {
+ if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
+ {
+ $string = stripslashes(str_replace("\\", "\\\\", $string));
+ }
+ if(!is_numeric($string))
+ {
+ $string = @mysql_real_escape_string($string);
+ }
+ return $string;
+ }
/**
* DB transaction start
* this method is private
* @return boolean
*/
- function _begin() {
- return true;
- }
+ function _begin()
+ {
+ return true;
+ }
/**
* DB transaction rollback
* this method is private
* @return boolean
*/
- function _rollback() {
- return true;
- }
+ function _rollback()
+ {
+ return true;
+ }
/**
* DB transaction commit
* this method is private
* @return boolean
*/
- function _commit() {
- return true;
- }
+ function _commit()
+ {
+ return true;
+ }
/**
* Execute the query
@@ -162,14 +192,22 @@ class DBMysql extends DB {
* @param resource $connection
* @return resource
*/
- function __query($query, $connection) {
- // Run the query statement
- $result = mysql_query($query, $connection);
- // Error Check
- if(mysql_error($connection)) $this->setError(mysql_errno($connection), mysql_error($connection));
- // Return result
- return $result;
- }
+ function __query($query, $connection)
+ {
+ if(!$connection)
+ {
+ exit('XE cannot handle DB connection.');
+ }
+ // Run the query statement
+ $result = mysql_query($query, $connection);
+ // Error Check
+ if(mysql_error($connection))
+ {
+ $this->setError(mysql_errno($connection), mysql_error($connection));
+ }
+ // Return result
+ return $result;
+ }
/**
* Fetch the result
@@ -177,37 +215,57 @@ class DBMysql extends DB {
* @param int|NULL $arrayIndexEndValue
* @return array
*/
- function _fetch($result, $arrayIndexEndValue = NULL) {
- $output = array();
- if(!$this->isConnected() || $this->isError() || !$result) return $output;
- while($tmp = $this->db_fetch_object($result)) {
- if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $tmp;
- else $output[] = $tmp;
- }
- if(count($output)==1){
- if(isset($arrayIndexEndValue)) return $output;
- else return $output[0];
- }
- $this->db_free_result($result);
- return $output;
- }
+ function _fetch($result, $arrayIndexEndValue = NULL)
+ {
+ $output = array();
+ if(!$this->isConnected() || $this->isError() || !$result)
+ {
+ return $output;
+ }
+ while($tmp = $this->db_fetch_object($result))
+ {
+ if($arrayIndexEndValue)
+ {
+ $output[$arrayIndexEndValue--] = $tmp;
+ }
+ else
+ {
+ $output[] = $tmp;
+ }
+ }
+ if(count($output) == 1)
+ {
+ if(isset($arrayIndexEndValue))
+ {
+ return $output;
+ }
+ else
+ {
+ return $output[0];
+ }
+ }
+ $this->db_free_result($result);
+ return $output;
+ }
/**
* Return the sequence value incremented by 1
* Auto_increment column only used in the sequence table
* @return int
*/
- function getNextSequence() {
- $query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix);
- $this->_query($query);
- $sequence = $this->db_insert_id();
- if($sequence % 10000 == 0) {
- $query = sprintf("delete from `%ssequence` where seq < %d", $this->prefix, $sequence);
- $this->_query($query);
- }
+ function getNextSequence()
+ {
+ $query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix);
+ $this->_query($query);
+ $sequence = $this->db_insert_id();
+ if($sequence % 10000 == 0)
+ {
+ $query = sprintf("delete from `%ssequence` where seq < %d", $this->prefix, $sequence);
+ $this->_query($query);
+ }
- return $sequence;
- }
+ return $sequence;
+ }
/**
* Function to obtain mysql old password(mysql only)
@@ -215,26 +273,34 @@ class DBMysql extends DB {
* @param string $saved_password saved password in DBMS
* @return boolean
*/
- function isValidOldPassword($password, $saved_password) {
- $query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password));
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
- if($tmp->password == $saved_password || $tmp->old_password == $saved_password) return true;
- return false;
- }
+ function isValidOldPassword($password, $saved_password)
+ {
+ $query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password));
+ $result = $this->_query($query);
+ $tmp = $this->_fetch($result);
+ if($tmp->password == $saved_password || $tmp->old_password == $saved_password)
+ {
+ return true;
+ }
+ return false;
+ }
/**
* Check a table exists status
* @param string $target_name
* @return boolean
*/
- function isTableExists($target_name) {
- $query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name));
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
- if(!$tmp) return false;
- return true;
- }
+ function isTableExists($target_name)
+ {
+ $query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name));
+ $result = $this->_query($query);
+ $tmp = $this->_fetch($result);
+ if(!$tmp)
+ {
+ return false;
+ }
+ return true;
+ }
/**
* Add a column to the table
@@ -246,18 +312,34 @@ class DBMysql extends DB {
* @param boolean $notnull not null status, default value is false
* @return void
*/
- function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
- $type = $this->column_type[$type];
- if(strtoupper($type)=='INTEGER') $size = '';
+ function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
+ {
+ $type = $this->column_type[$type];
+ if(strtoupper($type) == 'INTEGER')
+ {
+ $size = '';
+ }
- $query = sprintf("alter table `%s%s` add `%s` ", $this->prefix, $table_name, $column_name);
- if($size) $query .= sprintf(" %s(%s) ", $type, $size);
- else $query .= sprintf(" %s ", $type);
- if($default) $query .= sprintf(" default '%s' ", $default);
- if($notnull) $query .= " not null ";
+ $query = sprintf("alter table `%s%s` add `%s` ", $this->prefix, $table_name, $column_name);
+ if($size)
+ {
+ $query .= sprintf(" %s(%s) ", $type, $size);
+ }
+ else
+ {
+ $query .= sprintf(" %s ", $type);
+ }
+ if($default)
+ {
+ $query .= sprintf(" default '%s' ", $default);
+ }
+ if($notnull)
+ {
+ $query .= " not null ";
+ }
- return $this->_query($query);
- }
+ return $this->_query($query);
+ }
/**
* Drop a column from the table
@@ -265,10 +347,11 @@ class DBMysql extends DB {
* @param string $column_name column name
* @return void
*/
- function dropColumn($table_name, $column_name) {
- $query = sprintf("alter table `%s%s` drop `%s` ", $this->prefix, $table_name, $column_name);
- $this->_query($query);
- }
+ function dropColumn($table_name, $column_name)
+ {
+ $query = sprintf("alter table `%s%s` drop `%s` ", $this->prefix, $table_name, $column_name);
+ $this->_query($query);
+ }
/**
* Check column exist status of the table
@@ -276,20 +359,29 @@ class DBMysql extends DB {
* @param string $column_name column name
* @return boolean
*/
- function isColumnExists($table_name, $column_name) {
- $query = sprintf("show fields from `%s%s`", $this->prefix, $table_name);
- $result = $this->_query($query);
- if($this->isError()) return;
- $output = $this->_fetch($result);
- if($output) {
- $column_name = strtolower($column_name);
- foreach($output as $key => $val) {
- $name = strtolower($val->Field);
- if($column_name == $name) return true;
- }
- }
- return false;
- }
+ function isColumnExists($table_name, $column_name)
+ {
+ $query = sprintf("show fields from `%s%s`", $this->prefix, $table_name);
+ $result = $this->_query($query);
+ if($this->isError())
+ {
+ return;
+ }
+ $output = $this->_fetch($result);
+ if($output)
+ {
+ $column_name = strtolower($column_name);
+ foreach($output as $key => $val)
+ {
+ $name = strtolower($val->Field);
+ if($column_name == $name)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
/**
* Add an index to the table
@@ -301,12 +393,16 @@ class DBMysql extends DB {
* @param boolean $is_unique
* @return void
*/
- function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
- if(!is_array($target_columns)) $target_columns = array($target_columns);
+ function addIndex($table_name, $index_name, $target_columns, $is_unique = false)
+ {
+ if(!is_array($target_columns))
+ {
+ $target_columns = array($target_columns);
+ }
- $query = sprintf("alter table `%s%s` add %s index `%s` (%s);", $this->prefix, $table_name, $is_unique?'unique':'', $index_name, implode(',',$target_columns));
- $this->_query($query);
- }
+ $query = sprintf("alter table `%s%s` add %s index `%s` (%s);", $this->prefix, $table_name, $is_unique ? 'unique' : '', $index_name, implode(',', $target_columns));
+ $this->_query($query);
+ }
/**
* Drop an index from the table
@@ -315,11 +411,11 @@ class DBMysql extends DB {
* @param boolean $is_unique
* @return void
*/
- function dropIndex($table_name, $index_name, $is_unique = false) {
- $query = sprintf("alter table `%s%s` drop index `%s`", $this->prefix, $table_name, $index_name);
- $this->_query($query);
- }
-
+ function dropIndex($table_name, $index_name, $is_unique = false)
+ {
+ $query = sprintf("alter table `%s%s` drop index `%s`", $this->prefix, $table_name, $index_name);
+ $this->_query($query);
+ }
/**
* Check index status of the table
@@ -327,41 +423,60 @@ class DBMysql extends DB {
* @param string $index_name index name
* @return boolean
*/
- function isIndexExists($table_name, $index_name) {
- //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
- $query = sprintf("show indexes from `%s%s`", $this->prefix, $table_name);
- $result = $this->_query($query);
- if($this->isError()) return;
- $output = $this->_fetch($result);
- if(!$output) return;
- if(!is_array($output)) $output = array($output);
+ function isIndexExists($table_name, $index_name)
+ {
+ //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
+ $query = sprintf("show indexes from `%s%s`", $this->prefix, $table_name);
+ $result = $this->_query($query);
+ if($this->isError())
+ {
+ return;
+ }
+ $output = $this->_fetch($result);
+ if(!$output)
+ {
+ return;
+ }
+ if(!is_array($output))
+ {
+ $output = array($output);
+ }
- for($i=0;$iKey_name == $index_name) return true;
- }
- return false;
- }
+ for($i = 0; $i < count($output); $i++)
+ {
+ if($output[$i]->Key_name == $index_name)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Creates a table by using xml contents
* @param string $xml_doc xml schema contents
* @return void|object
*/
- function createTableByXml($xml_doc) {
- return $this->_createTable($xml_doc);
- }
+ function createTableByXml($xml_doc)
+ {
+ return $this->_createTable($xml_doc);
+ }
/**
* Creates a table by using xml file path
* @param string $file_name xml schema file path
* @return void|object
*/
- function createTableByXmlFile($file_name) {
- if(!file_exists($file_name)) return;
- // read xml file
- $buff = FileHandler::readFile($file_name);
- return $this->_createTable($buff);
- }
+ function createTableByXmlFile($file_name)
+ {
+ if(!file_exists($file_name))
+ {
+ return;
+ }
+ // read xml file
+ $buff = FileHandler::readFile($file_name);
+ return $this->_createTable($buff);
+ }
/**
* Create table by using the schema xml
@@ -372,68 +487,87 @@ class DBMysql extends DB {
* @param string $xml_doc xml schema contents
* @return void|object
*/
- function _createTable($xml_doc) {
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
- if($this->isTableExists($table_name)) return;
- $table_name = $this->prefix.$table_name;
+ function _createTable($xml_doc)
+ {
+ // xml parsing
+ $oXml = new XmlParser();
+ $xml_obj = $oXml->parse($xml_doc);
+ // Create a table schema
+ $table_name = $xml_obj->table->attrs->name;
+ if($this->isTableExists($table_name))
+ {
+ return;
+ }
+ $table_name = $this->prefix . $table_name;
- if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
- else $columns = $xml_obj->table->column;
+ if(!is_array($xml_obj->table->column))
+ {
+ $columns[] = $xml_obj->table->column;
+ }
+ else
+ {
+ $columns = $xml_obj->table->column;
+ }
- $primary_list = array();
- $unique_list = array();
- $index_list = array();
+ $primary_list = array();
+ $unique_list = array();
+ $index_list = array();
- foreach($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
- $auto_increment = $column->attrs->auto_increment;
+ foreach($columns as $column)
+ {
+ $name = $column->attrs->name;
+ $type = $column->attrs->type;
+ $size = $column->attrs->size;
+ $notnull = $column->attrs->notnull;
+ $primary_key = $column->attrs->primary_key;
+ $index = $column->attrs->index;
+ $unique = $column->attrs->unique;
+ $default = $column->attrs->default;
+ $auto_increment = $column->attrs->auto_increment;
- $column_schema[] = sprintf('`%s` %s%s %s %s %s',
- $name,
- $this->column_type[$type],
- $size?'('.$size.')':'',
- isset($default)?"default '".$default."'":'',
- $notnull?'not null':'',
- $auto_increment?'auto_increment':''
- );
+ $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : '');
- if($primary_key) $primary_list[] = $name;
- else if($unique) $unique_list[$unique][] = $name;
- else if($index) $index_list[$index][] = $name;
- }
+ if($primary_key)
+ {
+ $primary_list[] = $name;
+ }
+ else if($unique)
+ {
+ $unique_list[$unique][] = $name;
+ }
+ else if($index)
+ {
+ $index_list[$index][] = $name;
+ }
+ }
- if(count($primary_list)) {
- $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list,'`,`').'`');
- }
+ if(count($primary_list))
+ {
+ $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`');
+ }
- if(count($unique_list)) {
- foreach($unique_list as $key => $val) {
- $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val,'`,`').'`');
- }
- }
+ if(count($unique_list))
+ {
+ foreach($unique_list as $key => $val)
+ {
+ $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`');
+ }
+ }
- if(count($index_list)) {
- foreach($index_list as $key => $val) {
- $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val,'`,`').'`');
- }
- }
+ if(count($index_list))
+ {
+ foreach($index_list as $key => $val)
+ {
+ $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`');
+ }
+ }
- $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema,",\n"), "ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci");
+ $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci");
- $output = $this->_query($schema);
- if(!$output) return false;
- }
+ $output = $this->_query($schema);
+ if(!$output)
+ return false;
+ }
/**
* Handles insertAct
@@ -441,12 +575,16 @@ class DBMysql extends DB {
* @param boolean $with_values
* @return resource
*/
- function _executeInsertAct($queryObject, $with_values = true) {
- $query = $this->getInsertSql($queryObject, $with_values, true);
+ function _executeInsertAct($queryObject, $with_values = true)
+ {
+ $query = $this->getInsertSql($queryObject, $with_values, true);
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- if(is_a($query, 'Object')) return;
- return $this->_query($query);
- }
+ if(is_a($query, 'Object'))
+ {
+ return;
+ }
+ return $this->_query($query);
+ }
/**
* Handles updateAct
@@ -454,12 +592,16 @@ class DBMysql extends DB {
* @param boolean $with_values
* @return resource
*/
- function _executeUpdateAct($queryObject, $with_values = true) {
- $query = $this->getUpdateSql($queryObject, $with_values, true);
+ function _executeUpdateAct($queryObject, $with_values = true)
+ {
+ $query = $this->getUpdateSql($queryObject, $with_values, true);
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- if(is_a($query, 'Object')) return;
- return $this->_query($query);
- }
+ if(is_a($query, 'Object'))
+ {
+ return;
+ }
+ return $this->_query($query);
+ }
/**
* Handles deleteAct
@@ -467,12 +609,16 @@ class DBMysql extends DB {
* @param boolean $with_values
* @return resource
*/
- function _executeDeleteAct($queryObject, $with_values = true) {
- $query = $this->getDeleteSql($queryObject, $with_values, true);
+ function _executeDeleteAct($queryObject, $with_values = true)
+ {
+ $query = $this->getDeleteSql($queryObject, $with_values, true);
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- if(is_a($query, 'Object')) return;
- return $this->_query($query);
- }
+ if(is_a($query, 'Object'))
+ {
+ return;
+ }
+ return $this->_query($query);
+ }
/**
* Handle selectAct
@@ -483,24 +629,32 @@ class DBMysql extends DB {
* @param boolean $with_values
* @return Object
*/
- function _executeSelectAct($queryObject, $connection = null, $with_values = true) {
- $limit = $queryObject->getLimit();
- $result = NULL;
- if ($limit && $limit->isPageHandler())
- return $this->queryPageLimit($queryObject, $result, $connection, $with_values);
- else {
- $query = $this->getSelectSql($queryObject, $with_values);
- if (is_a($query, 'Object'))
- return;
- $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
+ function _executeSelectAct($queryObject, $connection = null, $with_values = true)
+ {
+ $limit = $queryObject->getLimit();
+ $result = NULL;
+ if($limit && $limit->isPageHandler())
+ {
+ return $this->queryPageLimit($queryObject, $result, $connection, $with_values);
+ }
+ else
+ {
+ $query = $this->getSelectSql($queryObject, $with_values);
+ if(is_a($query, 'Object'))
+ {
+ return;
+ }
+ $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
- $result = $this->_query($query, $connection);
- if ($this->isError())
- return $this->queryError($queryObject);
+ $result = $this->_query($query, $connection);
+ if($this->isError())
+ {
+ return $this->queryError($queryObject);
+ }
- $data = $this->_fetch($result);
- $buff = new Object ();
- $buff->data = $data;
+ $data = $this->_fetch($result);
+ $buff = new Object ();
+ $buff->data = $data;
if($queryObject->usesClickCount())
{
@@ -508,9 +662,9 @@ class DBMysql extends DB {
$this->_executeUpdateAct($update_query, $with_values);
}
- return $buff;
- }
- }
+ return $buff;
+ }
+ }
/**
* Get the ID generated in the last query
@@ -518,59 +672,66 @@ class DBMysql extends DB {
* This method use only mysql
* @return int
*/
- function db_insert_id()
- {
- $connection = $this->_getConnection('master');
- return mysql_insert_id($connection);
- }
+ function db_insert_id()
+ {
+ $connection = $this->_getConnection('master');
+ return mysql_insert_id($connection);
+ }
/**
* Fetch a result row as an object
* @param resource $result
* @return object
*/
- function db_fetch_object(&$result)
- {
- return mysql_fetch_object($result);
- }
+ function db_fetch_object(&$result)
+ {
+ return mysql_fetch_object($result);
+ }
/**
* Free result memory
* @param resource $result
* @return boolean Returns TRUE on success or FALSE on failure.
*/
- function db_free_result(&$result){
- return mysql_free_result($result);
- }
+ function db_free_result(&$result)
+ {
+ return mysql_free_result($result);
+ }
/**
* Return the DBParser
* @param boolean $force
* @return DBParser
*/
- function &getParser($force = FALSE){
- $dbParser = new DBParser('`', '`', $this->prefix);
- return $dbParser;
- }
+ function &getParser($force = FALSE)
+ {
+ $dbParser = new DBParser('`', '`', $this->prefix);
+ return $dbParser;
+ }
/**
* If have a error, return error object
* @param Object $queryObject
* @return Object
*/
- function queryError($queryObject){
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()){
- $buff = new Object ();
- $buff->total_count = 0;
- $buff->total_page = 0;
- $buff->page = 1;
- $buff->data = array ();
- $buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
- return $buff;
- }else
- return;
- }
+ function queryError($queryObject)
+ {
+ $limit = $queryObject->getLimit();
+ if($limit && $limit->isPageHandler())
+ {
+ $buff = new Object ();
+ $buff->total_count = 0;
+ $buff->total_page = 0;
+ $buff->page = 1;
+ $buff->data = array();
+ $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
+ return $buff;
+ }
+ else
+ {
+ return;
+ }
+ }
/**
* If select query execute, return page info
@@ -580,77 +741,95 @@ class DBMysql extends DB {
* @param boolean $with_values
* @return Object Object with page info containing
*/
- function queryPageLimit($queryObject, $result, $connection, $with_values = true){
- $limit = $queryObject->getLimit();
- // Total count
- $temp_where = $queryObject->getWhereString($with_values, false);
- $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '. $temp_where));
+ function queryPageLimit($queryObject, $result, $connection, $with_values = true)
+ {
+ $limit = $queryObject->getLimit();
+ // Total count
+ $temp_where = $queryObject->getWhereString($with_values, false);
+ $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
- // Check for distinct query and if found update count query structure
- $temp_select = $queryObject->getSelectString($with_values);
- $uses_distinct = strpos(strtolower($temp_select), "distinct") !== false;
- $uses_groupby = $queryObject->getGroupByString() != '';
- if($uses_distinct || $uses_groupby) {
- $count_query = sprintf('select %s %s %s %s'
- , $temp_select == '*' ? '1' : $temp_select
- , 'FROM ' . $queryObject->getFromString($with_values)
- , ($temp_where === '' ? '' : ' WHERE '. $temp_where)
- , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '')
- );
+ // Check for distinct query and if found update count query structure
+ $temp_select = $queryObject->getSelectString($with_values);
+ $uses_distinct = strpos(strtolower($temp_select), "distinct") !== false;
+ $uses_groupby = $queryObject->getGroupByString() != '';
+ if($uses_distinct || $uses_groupby)
+ {
+ $count_query = sprintf('select %s %s %s %s'
+ , $temp_select == '*' ? '1' : $temp_select
+ , 'FROM ' . $queryObject->getFromString($with_values)
+ , ($temp_where === '' ? '' : ' WHERE ' . $temp_where)
+ , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '')
+ );
- // If query uses grouping or distinct, count from original select
- $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
- }
+ // If query uses grouping or distinct, count from original select
+ $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
+ }
- $count_query .= (__DEBUG_QUERY__&1 && $queryObject->queryID)?sprintf (' '.$this->comment_syntax, $queryObject->queryID):'';
- $result_count = $this->_query($count_query, $connection);
- $count_output = $this->_fetch($result_count);
- $total_count = (int)(isset($count_output->count) ? $count_output->count : NULL);
+ $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
+ $result_count = $this->_query($count_query, $connection);
+ $count_output = $this->_fetch($result_count);
+ $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL);
- $list_count = $limit->list_count->getValue();
- if (!$list_count) $list_count = 20;
- $page_count = $limit->page_count->getValue();
- if (!$page_count) $page_count = 10;
- $page = $limit->page->getValue();
- if (!$page) $page = 1;
+ $list_count = $limit->list_count->getValue();
+ if(!$list_count)
+ {
+ $list_count = 20;
+ }
+ $page_count = $limit->page_count->getValue();
+ if(!$page_count)
+ {
+ $page_count = 10;
+ }
+ $page = $limit->page->getValue();
+ if(!$page || $page < 1)
+ {
+ $page = 1;
+ }
- // total pages
- if ($total_count)
- $total_page = (int) (($total_count - 1) / $list_count) + 1;
- else
- $total_page = 1;
+ // total pages
+ if($total_count)
+ {
+ $total_page = (int) (($total_count - 1) / $list_count) + 1;
+ }
+ else
+ {
+ $total_page = 1;
+ }
- // check the page variables
- if ($page > $total_page) {
- // If requested page is bigger than total number of pages, return empty list
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = array();
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- return $buff;
- }
- $start_count = ($page - 1) * $list_count;
+ // check the page variables
+ if($page > $total_page)
+ {
+ // If requested page is bigger than total number of pages, return empty list
+ $buff = new Object ();
+ $buff->total_count = $total_count;
+ $buff->total_page = $total_page;
+ $buff->page = $page;
+ $buff->data = array();
+ $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
+ return $buff;
+ }
+ $start_count = ($page - 1) * $list_count;
- $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count);
+ $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count);
- $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
- $result = $this->_query ($query, $connection);
- if ($this->isError ())
- return $this->queryError($queryObject);
+ $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
+ $result = $this->_query($query, $connection);
+ if($this->isError())
+ {
+ return $this->queryError($queryObject);
+ }
- $virtual_no = $total_count - ($page - 1) * $list_count;
- $data = $this->_fetch($result, $virtual_no);
+ $virtual_no = $total_count - ($page - 1) * $list_count;
+ $data = $this->_fetch($result, $virtual_no);
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = $data;
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- return $buff;
- }
+ $buff = new Object ();
+ $buff->total_count = $total_count;
+ $buff->total_page = $total_page;
+ $buff->page = $page;
+ $buff->data = $data;
+ $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
+ return $buff;
+ }
/**
* If select query execute, return paging sql
@@ -660,28 +839,49 @@ class DBMysql extends DB {
* @param int $list_count
* @return string select paging sql
*/
- function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) {
- $select = $query->getSelectString($with_values);
- if($select == '') return new Object(-1, "Invalid query");
- $select = 'SELECT ' .$select;
+ function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0)
+ {
+ $select = $query->getSelectString($with_values);
+ if($select == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $select = 'SELECT ' . $select;
- $from = $query->getFromString($with_values);
- if($from == '') return new Object(-1, "Invalid query");
- $from = ' FROM '.$from;
+ $from = $query->getFromString($with_values);
+ if($from == '')
+ {
+ return new Object(-1, "Invalid query");
+ }
+ $from = ' FROM ' . $from;
- $where = $query->getWhereString($with_values);
- if($where != '') $where = ' WHERE ' . $where;
+ $where = $query->getWhereString($with_values);
+ if($where != '')
+ {
+ $where = ' WHERE ' . $where;
+ }
- $groupBy = $query->getGroupByString();
- if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
+ $groupBy = $query->getGroupByString();
+ if($groupBy != '')
+ {
+ $groupBy = ' GROUP BY ' . $groupBy;
+ }
- $orderBy = $query->getOrderByString();
- if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
+ $orderBy = $query->getOrderByString();
+ if($orderBy != '')
+ {
+ $orderBy = ' ORDER BY ' . $orderBy;
+ }
- $limit = $query->getLimitString();
- if ($limit != '') $limit = sprintf (' LIMIT %d, %d', $start_count, $list_count);
+ $limit = $query->getLimitString();
+ if($limit != '')
+ {
+ $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count);
+ }
+
+ return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
+ }
- return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
- }
}
-?>
+/* End of file DBMysql.class.php */
+/* Location: ./classes/db/DBMysql.class.php */
diff --git a/classes/db/DBMysql_innodb.class.php b/classes/db/DBMysql_innodb.class.php
index 9adcd58fb..039c62305 100644
--- a/classes/db/DBMysql_innodb.class.php
+++ b/classes/db/DBMysql_innodb.class.php
@@ -1,162 +1,218 @@
_setDBInfo();
+ $this->_connect();
+ }
- /**
- * Constructor
- * @return void
- **/
- function DBMysql_innodb() {
- $this->_setDBInfo();
- $this->_connect();
- }
+ /**
+ * Create an instance of this class
+ * @return DBMysql_innodb return DBMysql_innodb object instance
+ */
+ function create()
+ {
+ return new DBMysql_innodb;
+ }
- /**
- * Create an instance of this class
- * @return DBMysql_innodb return DBMysql_innodb object instance
- */
- function create()
+ /**
+ * DB disconnection
+ * this method is private
+ * @param resource $connection
+ * @return void
+ */
+ function _close($connection)
+ {
+ $this->_query("commit", $connection);
+ @mysql_close($connection);
+ }
+
+ /**
+ * DB transaction start
+ * this method is private
+ * @return boolean
+ */
+ function _begin($transactionLevel)
+ {
+ $connection = $this->_getConnection('master');
+
+ if(!$transactionLevel)
{
- return new DBMysql_innodb;
+ $this->_query("START TRANSACTION", $connection);
+ }
+ else
+ {
+ $this->_query("SAVEPOINT SP" . $transactionLevel, $connection);
+ }
+ return true;
+ }
+
+ /**
+ * DB transaction rollback
+ * this method is private
+ * @return boolean
+ */
+ function _rollback($transactionLevel)
+ {
+ $connection = $this->_getConnection('master');
+
+ $point = $transactionLevel - 1;
+
+ if($point)
+ {
+ $this->_query("ROLLBACK TO SP" . $point, $connection);
+ }
+ else
+ {
+ $this->_query("ROLLBACK", $connection);
+ }
+ return true;
+ }
+
+ /**
+ * DB transaction commit
+ * this method is private
+ * @return boolean
+ */
+ function _commit()
+ {
+ $connection = $this->_getConnection('master');
+ $this->_query("commit", $connection);
+ return true;
+ }
+
+ /**
+ * Execute the query
+ * this method is private
+ * @param string $query
+ * @param resource $connection
+ * @return resource
+ */
+ function __query($query, $connection)
+ {
+ if(!$connection)
+ {
+ exit('XE cannot handle DB connection.');
+ }
+ // Run the query statement
+ $result = @mysql_query($query, $connection);
+ // Error Check
+ if(mysql_error($connection))
+ {
+ $this->setError(mysql_errno($connection), mysql_error($connection));
+ }
+ // Return result
+ return $result;
+ }
+
+ /**
+ * Create table by using the schema xml
+ *
+ * type : number, varchar, tinytext, text, bigtext, char, date, \n
+ * opt : notnull, default, size\n
+ * index : primary key, index, unique\n
+ * @param string $xml_doc xml schema contents
+ * @return void|object
+ */
+ function _createTable($xml_doc)
+ {
+ // xml parsing
+ $oXml = new XmlParser();
+ $xml_obj = $oXml->parse($xml_doc);
+ // Create a table schema
+ $table_name = $xml_obj->table->attrs->name;
+ if($this->isTableExists($table_name))
+ {
+ return;
+ }
+ $table_name = $this->prefix . $table_name;
+
+ if(!is_array($xml_obj->table->column))
+ {
+ $columns[] = $xml_obj->table->column;
+ }
+ else
+ {
+ $columns = $xml_obj->table->column;
}
- /**
- * DB disconnection
- * this method is private
- * @param resource $connection
- * @return void
- */
- function _close($connection) {
- $this->_query("commit", $connection);
- @mysql_close($connection);
- }
+ foreach($columns as $column)
+ {
+ $name = $column->attrs->name;
+ $type = $column->attrs->type;
+ $size = $column->attrs->size;
+ $notnull = $column->attrs->notnull;
+ $primary_key = $column->attrs->primary_key;
+ $index = $column->attrs->index;
+ $unique = $column->attrs->unique;
+ $default = $column->attrs->default;
+ $auto_increment = $column->attrs->auto_increment;
- /**
- * DB transaction start
- * this method is private
- * @return boolean
- */
- function _begin() {
- $connection = $this->_getConnection('master');
- $this->_query("begin", $connection);
- return true;
- }
+ $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : '');
- /**
- * DB transaction rollback
- * this method is private
- * @return boolean
- */
- function _rollback() {
- $connection = $this->_getConnection('master');
- $this->_query("rollback", $connection);
- return true;
- }
+ if($primary_key)
+ {
+ $primary_list[] = $name;
+ }
+ else if($unique)
+ {
+ $unique_list[$unique][] = $name;
+ }
+ else if($index)
+ {
+ $index_list[$index][] = $name;
+ }
+ }
- /**
- * DB transaction commit
- * this method is private
- * @return boolean
- */
- function _commit() {
- $connection = $this->_getConnection('master');
- $this->_query("commit", $connection);
- return true;
- }
+ if(count($primary_list))
+ {
+ $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`');
+ }
- /**
- * Execute the query
- * this method is private
- * @param string $query
- * @param resource $connection
- * @return resource
- */
- function __query($query, $connection) {
- // Run the query statement
- $result = @mysql_query($query, $connection);
- // Error Check
- if(mysql_error($connection)) $this->setError(mysql_errno($connection), mysql_error($connection));
- // Return result
- return $result;
- }
+ if(count($unique_list))
+ {
+ foreach($unique_list as $key => $val)
+ {
+ $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`');
+ }
+ }
- /**
- * Create table by using the schema xml
- *
- * type : number, varchar, tinytext, text, bigtext, char, date, \n
- * opt : notnull, default, size\n
- * index : primary key, index, unique\n
- * @param string $xml_doc xml schema contents
- * @return void|object
- */
- function _createTable($xml_doc) {
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
- if($this->isTableExists($table_name)) return;
- $table_name = $this->prefix.$table_name;
+ if(count($index_list))
+ {
+ foreach($index_list as $key => $val)
+ {
+ $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`');
+ }
+ }
- if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
- else $columns = $xml_obj->table->column;
+ $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci");
- foreach($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
- $auto_increment = $column->attrs->auto_increment;
+ $output = $this->_query($schema);
+ if(!$output)
+ {
+ return false;
+ }
+ }
- $column_schema[] = sprintf('`%s` %s%s %s %s %s',
- $name,
- $this->column_type[$type],
- $size?'('.$size.')':'',
- isset($default)?"default '".$default."'":'',
- $notnull?'not null':'',
- $auto_increment?'auto_increment':''
- );
-
- if($primary_key) $primary_list[] = $name;
- else if($unique) $unique_list[$unique][] = $name;
- else if($index) $index_list[$index][] = $name;
- }
-
- if(count($primary_list)) {
- $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list,'`,`').'`');
- }
-
- if(count($unique_list)) {
- foreach($unique_list as $key => $val) {
- $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val,'`,`').'`');
- }
- }
-
- if(count($index_list)) {
- foreach($index_list as $key => $val) {
- $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val,'`,`').'`');
- }
- }
-
- $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema,",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci");
-
- $output = $this->_query($schema);
- if(!$output) return false;
- }
- }
-?>
+}
+/* End of file DBMysql_innodb.class.php */
+/* Location: ./classes/db/DBMysql_innodb.class.php */
diff --git a/classes/db/DBMysqli.class.php b/classes/db/DBMysqli.class.php
index cb675f27b..2f4f4f723 100644
--- a/classes/db/DBMysqli.class.php
+++ b/classes/db/DBMysqli.class.php
@@ -1,386 +1,447 @@
_setDBInfo();
+ $this->_connect();
+ }
- /**
- * Constructor
- * @return void
- **/
- function DBMysqli() {
- $this->_setDBInfo();
- $this->_connect();
- }
-
- /**
- * Return if supportable
- * Check 'mysqli_connect' function exists.
- * @return boolean
- */
- function isSupported() {
- if(!function_exists('mysqli_connect')) return false;
- return true;
- }
-
- /**
- * Create an instance of this class
- * @return DBMysqli return DBMysqli object instance
- */
- function create()
+ /**
+ * Return if supportable
+ * Check 'mysqli_connect' function exists.
+ * @return boolean
+ */
+ function isSupported()
+ {
+ if(!function_exists('mysqli_connect'))
{
- return new DBMysqli;
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Create an instance of this class
+ * @return DBMysqli return DBMysqli object instance
+ */
+ function create()
+ {
+ return new DBMysqli;
+ }
+
+ /**
+ * DB Connect
+ * this method is private
+ * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
+ * @return resource
+ */
+ function __connect($connection)
+ {
+ // Attempt to connect
+ if($connection["db_port"])
+ {
+ $result = @mysqli_connect($connection["db_hostname"]
+ , $connection["db_userid"]
+ , $connection["db_password"]
+ , $connection["db_database"]
+ , $connection["db_port"]);
+ }
+ else
+ {
+ $result = @mysqli_connect($connection["db_hostname"]
+ , $connection["db_userid"]
+ , $connection["db_password"]
+ , $connection["db_database"]);
+ }
+ $error = mysqli_connect_errno();
+ if($error)
+ {
+ $this->setError($error, mysqli_connect_error());
+ return;
+ }
+ mysqli_set_charset($result, 'utf8');
+ return $result;
+ }
+
+ /**
+ * DB disconnection
+ * this method is private
+ * @param resource $connection
+ * @return void
+ */
+ function _close($connection)
+ {
+ mysqli_close($connection);
+ }
+
+ /**
+ * Handles quatation of the string variables from the query
+ * @param string $string
+ * @return string
+ */
+ function addQuotes($string)
+ {
+ if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
+ {
+ $string = stripslashes(str_replace("\\", "\\\\", $string));
+ }
+ if(!is_numeric($string))
+ {
+ $connection = $this->_getConnection('master');
+ $string = mysqli_escape_string($connection, $string);
+ }
+ return $string;
+ }
+
+ /**
+ * Execute the query
+ * this method is private
+ * @param string $query
+ * @param resource $connection
+ * @return resource
+ */
+ function __query($query, $connection)
+ {
+ if($this->use_prepared_statements == 'Y')
+ {
+ // 1. Prepare query
+ $stmt = mysqli_prepare($connection, $query);
+ if($stmt)
+ {
+ $types = '';
+ $params = array();
+ $this->_prepareQueryParameters($types, $params);
+
+ if(!empty($params))
+ {
+ $args[0] = $stmt;
+ $args[1] = $types;
+
+ $i = 2;
+ foreach($params as $key => $param)
+ {
+ $copy[$key] = $param;
+ $args[$i++] = &$copy[$key];
+ }
+
+ // 2. Bind parameters
+ $status = call_user_func_array('mysqli_stmt_bind_param', $args);
+ if(!$status)
+ {
+ $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
+ }
+ }
+
+ // 3. Execute query
+ $status = mysqli_stmt_execute($stmt);
+
+ if(!$status)
+ {
+ $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
+ }
+
+ // Return stmt for other processing - like retrieving resultset (_fetch)
+ return $stmt;
+ // mysqli_stmt_close($stmt);
+ }
+ }
+ // Run the query statement
+ $result = mysqli_query($connection, $query);
+ // Error Check
+ $error = mysqli_error($connection);
+ if($error)
+ {
+ $this->setError(mysqli_errno($connection), $error);
+ }
+ // Return result
+ return $result;
+ }
+
+ /**
+ * Before execute query, prepare statement
+ * this method is private
+ * @param string $types
+ * @param array $params
+ * @return void
+ */
+ function _prepareQueryParameters(&$types, &$params)
+ {
+ $types = '';
+ $params = array();
+ if(!$this->param)
+ {
+ return;
}
- /**
- * DB Connect
- * this method is private
- * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
- * @return resource
- */
- function __connect($connection) {
- // Attempt to connect
- if ($connection["db_port"]) {
- $result = @mysqli_connect($connection["db_hostname"]
- , $connection["db_userid"]
- , $connection["db_password"]
- , $connection["db_database"]
- , $connection["db_port"]);
- } else {
- $result = @mysqli_connect($connection["db_hostname"]
- , $connection["db_userid"]
- , $connection["db_password"]
- , $connection["db_database"]);
- }
- $error = mysqli_connect_errno();
- if($error) {
- $this->setError($error,mysqli_connect_error());
- return;
- }
- mysqli_set_charset($result,'utf8');
- return $result;
- }
+ foreach($this->param as $k => $o)
+ {
+ $value = $o->getUnescapedValue();
+ $type = $o->getType();
- /**
- * DB disconnection
- * this method is private
- * @param resource $connection
- * @return void
- */
- function _close($connection) {
- mysqli_close($connection);
- }
-
- /**
- * Handles quatation of the string variables from the query
- * @param string $string
- * @return string
- */
- function addQuotes($string) {
- if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
- if(!is_numeric($string)){
- $connection = $this->_getConnection('master');
- $string = mysqli_escape_string($connection,$string);
- }
- return $string;
- }
-
- /**
- * Execute the query
- * this method is private
- * @param string $query
- * @param resource $connection
- * @return resource
- */
- function __query($query, $connection) {
- if($this->use_prepared_statements == 'Y')
- {
- // 1. Prepare query
- $stmt = mysqli_prepare($connection, $query);
- if($stmt){
- $types = '';
- $params = array();
- $this->_prepareQueryParameters($types, $params);
-
- if(!empty($params))
- {
- $args[0] = $stmt;
- $args[1] = $types;
-
- $i = 2;
- foreach($params as $key => $param) {
- $copy[$key] = $param;
- $args[$i++] = &$copy[$key];
- }
-
- // 2. Bind parameters
- $status = call_user_func_array('mysqli_stmt_bind_param',$args);
- if(!$status)
- $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
- }
-
- // 3. Execute query
- $status = mysqli_stmt_execute($stmt);
-
- if(!$status)
- $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
-
- // Return stmt for other processing - like retrieving resultset (_fetch)
- return $stmt;
- // mysqli_stmt_close($stmt);
- }
-
+ // Skip column names -> this should be concatenated to query string
+ if($o->isColumnName())
+ {
+ continue;
}
- // Run the query statement
- $result = mysqli_query($connection,$query);
- // Error Check
- $error = mysqli_error($connection);
- if($error){
- $this->setError(mysqli_errno($connection), $error);
+
+ switch($type)
+ {
+ case 'number' :
+ $type = 'i';
+ break;
+ case 'varchar' :
+ $type = 's';
+ break;
+ default:
+ $type = 's';
}
- // Return result
- return $result;
- }
-
- /**
- * Before execute query, prepare statement
- * this method is private
- * @param string $types
- * @param array $params
- * @return void
- */
- function _prepareQueryParameters(&$types, &$params){
- $types = '';
- $params = array();
- if(!$this->param) return;
-
- foreach($this->param as $k => $o){
- $value = $o->getUnescapedValue();
- $type = $o->getType();
-
- // Skip column names -> this should be concatenated to query string
- if($o->isColumnName()) continue;
-
- switch($type)
+
+ if(is_array($value))
+ {
+ foreach($value as $v)
{
- case 'number' :
- $type = 'i';
- break;
- case 'varchar' :
- $type = 's';
- break;
- default:
- $type = 's';
- }
-
- if(is_array($value))
- {
- foreach($value as $v)
- {
- $params[] = $v;
- $types .= $type;
- }
- }
- else {
- $params[] = $value;
+ $params[] = $v;
$types .= $type;
}
-
-
-
- }
+ }
+ else
+ {
+ $params[] = $value;
+ $types .= $type;
+ }
}
-
- /**
- * Fetch the result
- * @param resource $result
- * @param int|NULL $arrayIndexEndValue
- * @return array
- */
- function _fetch($result, $arrayIndexEndValue = NULL) {
- if($this->use_prepared_statements != 'Y'){
- return parent::_fetch($result, $arrayIndexEndValue);
- }
- $output = array();
- if(!$this->isConnected() || $this->isError() || !$result) return $output;
-
- // Prepared stements: bind result variable and fetch data
- $stmt = $result;
- $meta = mysqli_stmt_result_metadata($stmt);
- $fields = mysqli_fetch_fields($meta);
+ }
- /**
- * Mysqli has a bug that causes LONGTEXT columns not to get loaded
- * Unless store_result is called before
- * MYSQLI_TYPE for longtext is 252
- */
- $longtext_exists = false;
- foreach($fields as $field)
- {
- if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails
- $field->name = 'repeat_' . $field->name;
-
- // Array passed needs to contain references, not values
- $row[$field->name] = "";
- $resultArray[$field->name] = &$row[$field->name];
-
- if($field->type == 252) $longtext_exists = true;
- }
- $resultArray = array_merge(array($stmt), $resultArray);
-
- if($longtext_exists)
- {
- mysqli_stmt_store_result($stmt);
- }
-
- call_user_func_array('mysqli_stmt_bind_result', $resultArray);
-
- $rows = array();
- while(mysqli_stmt_fetch($stmt))
- {
- $resultObject = new stdClass();
-
- foreach($resultArray as $key => $value)
- {
- if($key === 0) continue; // Skip stmt object
- if(strpos($key, 'repeat_')) $key = substr($key, 6);
- $resultObject->$key = $value;
- }
-
- $rows[] = $resultObject;
- }
-
- mysqli_stmt_close($stmt);
-
- if($arrayIndexEndValue)
- {
- foreach($rows as $row)
- {
- $output[$arrayIndexEndValue--] = $row;
- }
- }
- else
- {
- $output = $rows;
- }
-
- if(count($output)==1){
- if(isset($arrayIndexEndValue)) return $output;
- else return $output[0];
- }
-
- return $output;
- }
-
- /**
- * Handles insertAct
- * @param Object $queryObject
- * @param boolean $with_values
- * @return resource
- */
- function _executeInsertAct($queryObject, $with_values = false){
- if($this->use_prepared_statements != 'Y')
- {
- return parent::_executeInsertAct($queryObject);
- }
- $this->param = $queryObject->getArguments();
- $result = parent::_executeInsertAct($queryObject, $with_values);
- unset($this->param);
- return $result;
- }
-
- /**
- * Handles updateAct
- * @param Object $queryObject
- * @param boolean $with_values
- * @return resource
- */
- function _executeUpdateAct($queryObject, $with_values = false) {
- if($this->use_prepared_statements != 'Y')
- {
- return parent::_executeUpdateAct($queryObject);
- }
- $this->param = $queryObject->getArguments();
- $result = parent::_executeUpdateAct($queryObject, $with_values);
- unset($this->param);
- return $result;
- }
-
- /**
- * Handles deleteAct
- * @param Object $queryObject
- * @param boolean $with_values
- * @return resource
- */
- function _executeDeleteAct($queryObject, $with_values = false) {
- if($this->use_prepared_statements != 'Y')
- {
- return parent::_executeDeleteAct($queryObject);
- }
- $this->param = $queryObject->getArguments();
- $result = parent::_executeDeleteAct($queryObject, $with_values);
- unset($this->param);
- return $result;
- }
-
- /**
- * Handle selectAct
- * In order to get a list of pages easily when selecting \n
- * it supports a method as navigation
- * @param Object $queryObject
- * @param resource $connection
- * @param boolean $with_values
- * @return Object
- */
- function _executeSelectAct($queryObject, $connection = null, $with_values = false) {
- if($this->use_prepared_statements != 'Y')
- {
- return parent::_executeSelectAct($queryObject, $connection);
- }
- $this->param = $queryObject->getArguments();
- $result = parent::_executeSelectAct($queryObject, $connection, $with_values);
- unset($this->param);
- return $result;
- }
-
- /**
- * Get the ID generated in the last query
- * Return next sequence from sequence table
- * This method use only mysql
- * @return int
- */
- function db_insert_id()
+ /**
+ * Fetch the result
+ * @param resource $result
+ * @param int|NULL $arrayIndexEndValue
+ * @return array
+ */
+ function _fetch($result, $arrayIndexEndValue = NULL)
+ {
+ if($this->use_prepared_statements != 'Y')
{
- $connection = $this->_getConnection('master');
- return mysqli_insert_id($connection);
+ return parent::_fetch($result, $arrayIndexEndValue);
+ }
+ $output = array();
+ if(!$this->isConnected() || $this->isError() || !$result)
+ {
+ return $output;
}
+ // Prepared stements: bind result variable and fetch data
+ $stmt = $result;
+ $meta = mysqli_stmt_result_metadata($stmt);
+ $fields = mysqli_fetch_fields($meta);
+
/**
- * Fetch a result row as an object
- * @param resource $result
- * @return object
+ * Mysqli has a bug that causes LONGTEXT columns not to get loaded
+ * Unless store_result is called before
+ * MYSQLI_TYPE for longtext is 252
*/
- function db_fetch_object(&$result)
+ $longtext_exists = false;
+ foreach($fields as $field)
{
- return mysqli_fetch_object($result);
+ if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails
+ {
+ $field->name = 'repeat_' . $field->name;
+ }
+
+ // Array passed needs to contain references, not values
+ $row[$field->name] = "";
+ $resultArray[$field->name] = &$row[$field->name];
+
+ if($field->type == 252)
+ {
+ $longtext_exists = true;
+ }
}
-
- /**
- * Free result memory
- * @param resource $result
- * @return boolean Returns TRUE on success or FALSE on failure.
- */
- function db_free_result(&$result){
- return mysqli_free_result($result);
- }
- }
-?>
+ $resultArray = array_merge(array($stmt), $resultArray);
+
+ if($longtext_exists)
+ {
+ mysqli_stmt_store_result($stmt);
+ }
+
+ call_user_func_array('mysqli_stmt_bind_result', $resultArray);
+
+ $rows = array();
+ while(mysqli_stmt_fetch($stmt))
+ {
+ $resultObject = new stdClass();
+
+ foreach($resultArray as $key => $value)
+ {
+ if($key === 0)
+ {
+ continue; // Skip stmt object
+ }
+ if(strpos($key, 'repeat_'))
+ {
+ $key = substr($key, 6);
+ }
+ $resultObject->$key = $value;
+ }
+
+ $rows[] = $resultObject;
+ }
+
+ mysqli_stmt_close($stmt);
+
+ if($arrayIndexEndValue)
+ {
+ foreach($rows as $row)
+ {
+ $output[$arrayIndexEndValue--] = $row;
+ }
+ }
+ else
+ {
+ $output = $rows;
+ }
+
+ if(count($output) == 1)
+ {
+ if(isset($arrayIndexEndValue))
+ {
+ return $output;
+ }
+ else
+ {
+ return $output[0];
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Handles insertAct
+ * @param Object $queryObject
+ * @param boolean $with_values
+ * @return resource
+ */
+ function _executeInsertAct($queryObject, $with_values = false)
+ {
+ if($this->use_prepared_statements != 'Y')
+ {
+ return parent::_executeInsertAct($queryObject);
+ }
+ $this->param = $queryObject->getArguments();
+ $result = parent::_executeInsertAct($queryObject, $with_values);
+ unset($this->param);
+ return $result;
+ }
+
+ /**
+ * Handles updateAct
+ * @param Object $queryObject
+ * @param boolean $with_values
+ * @return resource
+ */
+ function _executeUpdateAct($queryObject, $with_values = false)
+ {
+ if($this->use_prepared_statements != 'Y')
+ {
+ return parent::_executeUpdateAct($queryObject);
+ }
+ $this->param = $queryObject->getArguments();
+ $result = parent::_executeUpdateAct($queryObject, $with_values);
+ unset($this->param);
+ return $result;
+ }
+
+ /**
+ * Handles deleteAct
+ * @param Object $queryObject
+ * @param boolean $with_values
+ * @return resource
+ */
+ function _executeDeleteAct($queryObject, $with_values = false)
+ {
+ if($this->use_prepared_statements != 'Y')
+ {
+ return parent::_executeDeleteAct($queryObject);
+ }
+ $this->param = $queryObject->getArguments();
+ $result = parent::_executeDeleteAct($queryObject, $with_values);
+ unset($this->param);
+ return $result;
+ }
+
+ /**
+ * Handle selectAct
+ * In order to get a list of pages easily when selecting \n
+ * it supports a method as navigation
+ * @param Object $queryObject
+ * @param resource $connection
+ * @param boolean $with_values
+ * @return Object
+ */
+ function _executeSelectAct($queryObject, $connection = null, $with_values = false)
+ {
+ if($this->use_prepared_statements != 'Y')
+ {
+ return parent::_executeSelectAct($queryObject, $connection);
+ }
+ $this->param = $queryObject->getArguments();
+ $result = parent::_executeSelectAct($queryObject, $connection, $with_values);
+ unset($this->param);
+ return $result;
+ }
+
+ /**
+ * Get the ID generated in the last query
+ * Return next sequence from sequence table
+ * This method use only mysql
+ * @return int
+ */
+ function db_insert_id()
+ {
+ $connection = $this->_getConnection('master');
+ return mysqli_insert_id($connection);
+ }
+
+ /**
+ * Fetch a result row as an object
+ * @param resource $result
+ * @return object
+ */
+ function db_fetch_object(&$result)
+ {
+ return mysqli_fetch_object($result);
+ }
+
+ /**
+ * Free result memory
+ * @param resource $result
+ * @return boolean Returns TRUE on success or FALSE on failure.
+ */
+ function db_free_result(&$result)
+ {
+ return mysqli_free_result($result);
+ }
+
+}
+/* End of file DBMysqli.class.php */
+/* Location: ./classes/db/DBMysqli.class.php */
diff --git a/classes/db/DBPostgresql.class.php b/classes/db/DBPostgresql.class.php
deleted file mode 100644
index ddab2eac8..000000000
--- a/classes/db/DBPostgresql.class.php
+++ /dev/null
@@ -1,600 +0,0 @@
- 'bigint',
- 'number' => 'integer',
- 'varchar' => 'varchar',
- 'char' => 'char',
- 'text' => 'text',
- 'bigtext' => 'text',
- 'date' => 'varchar(14)',
- 'float' => 'real',
- );
-
- /**
- * @brief constructor
- **/
- function DBPostgresql()
- {
- $this->_setDBInfo();
- $this->_connect();
- }
-
- /**
- * @brief create an instance of this class
- */
- function create()
- {
- return new DBPostgresql;
- }
-
- /**
- * @brief Return if it is installable
- **/
- function isSupported()
- {
- if (!function_exists('pg_connect'))
- return false;
- return true;
- }
-
- /**
- * @brief DB Connection
- **/
- function __connect($connection)
- {
- // the connection string for PG
- $conn_string = "";
- // Create connection string
- $conn_string .= ($connection["db_hostname"]) ? ' host='.$connection["db_hostname"] : "";
- $conn_string .= ($connection["db_userid"]) ? " user=" . $connection["db_userid"] : "";
- $conn_string .= ($connection["db_password"]) ? " password=" . $connection["db_password"] : "";
- $conn_string .= ($connection["db_database"]) ? " dbname=" . $connection["db_database"] : "";
- $conn_string .= ($connection["db_port"]) ? " port=" . $connection["db_port"] : "";
-
- // Attempt to connect
- $result = @pg_connect($conn_string);
- if (!$result || pg_connection_status($result) != PGSQL_CONNECTION_OK) {
- $this->setError(-1, "CONNECTION FAILURE");
- return;
- }
- return $result;
- }
-
- /**
- * @brief DB disconnection
- **/
- function _close($connection)
- {
- @pg_close($connection);
- }
-
- /**
- * @brief Add quotes on the string variables in a query
- **/
- function addQuotes($string)
- {
- if (version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
- $string = stripslashes(str_replace("\\", "\\\\", $string));
- if (!is_numeric($string))
- $string = @pg_escape_string($string);
- return $string;
- }
-
- /**
- * @brief Begin transaction
- **/
- function _begin()
- {
- $connection = $this->_getConnection('master');
- if (!$this->_query('BEGIN')) return false;
- return true;
- }
-
- /**
- * @brief Rollback
- **/
- function _rollback()
- {
- if (!$this->_query('ROLLBACK')) return false;
- return true;
- }
-
- /**
- * @brief Commits
- **/
- function _commit()
- {
- if (!$this->_query('COMMIT')) return false;
- return true;
- }
-
- /**
- * @brief : Run a query and fetch the result
- *
- * query: run a query and return the result \n
- * fetch: NULL if no value is returned \n
- * array object if rows are returned \n
- * object if a row is returned \n
- * return\n
- **/
- function __query($query, $connection)
- {
- if (!$this->isConnected())
- return;
-
- /*
- $l_query_array = explode(" ", $query);
- if ($l_query_array[0] = "update")
- {
- if (strtolower($l_query_array[2]) == "as")
- {
- $l_query_array[2] = "";
- $l_query_array[3] = "";
- $query = implode(" ",$l_query_array);
- }
- }
- else if ($l_query_array[0] = "delete")
- {
- if (strtolower($l_query_array[3]) == "as")
- {
- $l_query_array[3] = "";
- $l_query_array[4] = "";
- $query = implode(" ",$l_query_array);
- }
- }
- */
- // Notify to start a query execution
- // $arr = array('Hello', 'World!', 'Beautiful', 'Day!');
- // Run the query statement
- $result = @pg_query($connection, $query);
- // Error Check
- if (!$result) {
- // var_dump($l_query_array);
- //var_dump($query);
- //die("\nin query statement\n");
- //var_dump(debug_backtrace());
- $this->setError(1, pg_last_error($connection));
- }
- // Return result
- return $result;
- }
-
- /**
- * @brief Fetch results
- **/
- // TODO This is duplicate code - maybe we can find away to abastract the driver
- function _fetch($result, $arrayIndexEndValue = NULL)
- {
- if (!$this->isConnected() || $this->isError() || !$result)
- return;
- while ($tmp = pg_fetch_object($result)) {
- if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $tmp;
- else $output[] = $tmp;
- }
- if(count($output)==1){
- if(isset($arrayIndexEndValue)) return $output;
- else return $output[0];
- }
- return $output;
- }
-
- /**
- * @brief Return sequence value incremented by 1(in postgresql, auto_increment is used in the sequence table only)
- **/
- function getNextSequence()
- {
- $query = sprintf("select nextval('%ssequence') as seq", $this->prefix);
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
- return $tmp->seq;
- }
-
- /**
- * @brief Return if a table already exists
- **/
- function isTableExists($target_name)
- {
- if ($target_name == "sequence")
- return true;
- $query = sprintf("SELECT tablename FROM pg_tables WHERE tablename = '%s%s' AND schemaname = current_schema()",
- $this->prefix, $this->addQuotes($target_name));
-
- $result = $this->_query($query);
- $tmp = $this->_fetch($result);
- if (!$tmp)
- return false;
- return true;
- }
-
- /**
- * @brief Add a column to a table
- **/
- function addColumn($table_name, $column_name, $type = 'number', $size = '', $default =
- NULL, $notnull = false)
- {
- $type = $this->column_type[$type];
- if (strtoupper($type) == 'INTEGER' || strtoupper($type) == 'BIGINT')
- $size = '';
-
- $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
-
- if ($size)
- $query .= sprintf(" %s(%s) ", $type, $size);
- else
- $query .= sprintf(" %s ", $type);
-
- $this->_query($query);
-
- if (isset($default)) {
- $query = sprintf("alter table %s%s alter %s set default '%s' ", $this->prefix, $table_name, $column_name, $default);
- $this->_query($query);
- }
- if ($notnull) {
- $query = sprintf("update %s%s set %s = %s ", $this->prefix, $table_name, $column_name, $default);
- $this->_query($query);
- $query = sprintf("alter table %s%s alter %s set not null ", $this->prefix, $table_name, $column_name);
- $this->_query($query);
- }
- }
-
-
- /**
- * @brief Return column information of a table
- **/
- function isColumnExists($table_name, $column_name)
- {
- $query = sprintf("SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '%s%s') AND attname = '%s'",
- $this->prefix, strtolower($table_name), strtolower($column_name));
-
- // $query = sprintf("select column_name from information_schema.columns where table_schema = current_schema() and table_name = '%s%s' and column_name = '%s'", $this->prefix, $this->addQuotes($table_name), strtolower($column_name));
- $result = $this->_query($query);
- if ($this->isError()) {
- return;
- }
- $output = $this->_fetch($result);
- if ($output) {
- return true;
- }
- return false;
- }
-
- /**
- * @brief Add an index to a table
- * $target_columns = array(col1, col2)
- * $is_unique? unique : none
- **/
- function addIndex($table_name, $index_name, $target_columns, $is_unique = false)
- {
- if (!is_array($target_columns))
- $target_columns = array($target_columns);
-
- if (strpos($table_name, $this->prefix) === false)
- $table_name = $this->prefix . $table_name;
- // Use a tablename before an index name to avoid defining the same index
- $index_name = $table_name . $index_name;
-
- $query = sprintf("create %s index %s on %s (%s);", $is_unique ? 'unique' : '', $index_name,
- $table_name, implode(',', $target_columns));
- $this->_query($query);
- }
-
- /**
- * @brief Delete a column from a table
- **/
- function dropColumn($table_name, $column_name)
- {
- $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
- $this->_query($query);
- }
-
- /**
- * @brief Drop an index from a table
- **/
- function dropIndex($table_name, $index_name, $is_unique = false)
- {
- if (strpos($table_name, $this->prefix) === false)
- $table_name = $this->prefix . $table_name;
- // Use a tablename before an index name to avoid defining the same index
- $index_name = $table_name . $index_name;
-
- $query = sprintf("drop index %s", $index_name);
- $this->_query($query);
- }
-
-
- /**
- * @brief Return index information of a table
- **/
- function isIndexExists($table_name, $index_name)
- {
- if (strpos($table_name, $this->prefix) === false)
- $table_name = $this->prefix . $table_name;
- // Use a tablename before an index name to avoid defining the same index
- $index_name = $table_name . $index_name;
-
- //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
- $query = sprintf("select indexname from pg_indexes where schemaname = current_schema() and tablename = '%s' and indexname = '%s'",
- $table_name, strtolower($index_name));
- $result = $this->_query($query);
- if ($this->isError())
- return;
- $output = $this->_fetch($result);
-
- if ($output) {
- return true;
- }
- // var_dump($query);
- // die(" no index");
- return false;
- }
-
- /**
- * @brief Create a table by using xml file
- **/
- function createTableByXml($xml_doc)
- {
- return $this->_createTable($xml_doc);
- }
-
- /**
- * @brief Create a table by using xml file
- **/
- function createTableByXmlFile($file_name)
- {
- if (!file_exists($file_name))
- return;
- // read xml file
- $buff = FileHandler::readFile($file_name);
- return $this->_createTable($buff);
- }
-
- /**
- * @brief generate a query statement to create a table by using schema xml
- *
- * type : number, varchar, text, char, date, \n
- * opt : notnull, default, size\n
- * index : primary key, index, unique\n
- **/
- function _createTable($xml_doc)
- {
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
-
- if ($table_name == 'sequence') {
- $query = sprintf('create sequence %s', $this->prefix . $table_name);
- return $this->_query($query);
- }
-
- if ($this->isTableExists($table_name))
- return;
- $table_name = $this->prefix . $table_name;
-
- if (!is_array($xml_obj->table->column))
- $columns[] = $xml_obj->table->column;
- else
- $columns = $xml_obj->table->column;
-
- foreach ($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
- $auto_increment = $column->attrs->auto_increment;
-
- if ($type == "bignumber" || $type == "number")
- $size = 0;
-
- $column_schema[] = sprintf('%s %s%s %s %s', $name, $this->column_type[$type], $size ?
- '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ?
- 'not null' : '');
-
- if ($primary_key)
- $primary_list[] = $name;
- else
- if ($unique)
- $unique_list[$unique][] = $name;
- else
- if ($index)
- $index_list[$index][] = $name;
- }
-
- if (count($primary_list)) {
- $column_schema[] = sprintf("primary key (%s)", implode($primary_list, ','));
- }
-
- if (count($unique_list)) {
- foreach ($unique_list as $key => $val) {
- $column_schema[] = sprintf("unique (%s)", implode($val, ','));
- }
- }
-
-
- $schema = sprintf('create table %s (%s%s);', $this->addQuotes($table_name), "\n",
- implode($column_schema, ",\n"));
-
- $output = $this->_query($schema);
-
- if (count($index_list)) {
- foreach ($index_list as $key => $val) {
- if (!$this->isIndexExists($table_name, $key))
- $this->addIndex($table_name, $key, $val);
- }
- }
-
- if (!$output)
- return false;
-
- }
-
-
- /**
- * @brief Handle the insertAct
- **/
- function _executeInsertAct($queryObject)
- {
- $query = $this->getInsertSql($queryObject);
- if(is_a($query, 'Object')) return;
-
- return $this->_query($query);
- }
-
- /**
- * @brief Handle updateAct
- **/
- function _executeUpdateAct($queryObject)
- {
- $query = $this->getUpdateSql($queryObject);
- if(is_a($query, 'Object')) return;
- return $this->_query($query);
- }
-
- /**
- * @brief Handle deleteAct
- **/
- function _executeDeleteAct($queryObject)
- {
- $query = $this->getDeleteSql($queryObject);
-
- if(is_a($query, 'Object')) return;
- return $this->_query($query);
- }
-
- /**
- *
- * override
- * @param $queryObject
- */
- function getSelectSql($query){
- $select = $query->getSelectString();
- if($select == '') return new Object(-1, "Invalid query");
- $select = 'SELECT ' .$select;
-
- $from = $query->getFromString();
- if($from == '') return new Object(-1, "Invalid query");
- $from = ' FROM '.$from;
-
- $where = $query->getWhereString();
- if($where != '') $where = ' WHERE ' . $where;
-
- $groupBy = $query->getGroupByString();
- if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
-
- $orderBy = $query->getOrderByString();
- if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
-
- $limit = $query->getLimitString();
- $limitObject = $query->getLimit();
- if($limit != '') $limit = ' LIMIT ' . $limitObject->getLimit() . ' OFFSET ' . $limitObject->getOffset();
-
- return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
- }
-
- /**
- * @brief Handle selectAct
- *
- * In order to get a list of pages easily when selecting \n
- * it supports a method as navigation
- **/
- function _executeSelectAct($queryObject, $connection)
- {
- $query = $this->getSelectSql($queryObject);
-
- if(is_a($query, 'Object')) return;
-
- $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
-
- // TODO Add support for click count
- // TODO Add code for pagination
-
- $result = $this->_query ($query, $connection);
- if ($this->isError ()) {
- if ($limit && $output->limit->isPageHandler()){
- $buff = new Object ();
- $buff->total_count = 0;
- $buff->total_page = 0;
- $buff->page = 1;
- $buff->data = array ();
- $buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
- return $buff;
- }else
- return;
- }
-
- $limit = $queryObject->getLimit();
- if ($limit && $limit->isPageHandler()) {
- // Total count
- $temp_where = $queryObject->getWhereString(true, false);
- $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '. $temp_where));
- if ($queryObject->getGroupByString() != '') {
- $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
- }
-
- $count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
- $result_count = $this->_query($count_query, $connection);
- $count_output = $this->_fetch($result_count);
- $total_count = (int)$count_output->count;
-
- // Total pages
- if ($total_count) {
- $total_page = (int) (($total_count - 1) / $limit->list_count) + 1;
- } else $total_page = 1;
-
-
- $virtual_no = $total_count - ($limit->page - 1) * $limit->list_count;
- $data = $this->_fetch($result, $virtual_no);
-
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $limit->page->getValue();
- $buff->data = $data;
- $buff->page_navigation = new PageHandler($total_count, $total_page, $limit->page->getValue(), $limit->page_count);
- }else{
- $data = $this->_fetch($result);
- $buff = new Object ();
- $buff->data = $data;
- }
-
- return $buff;
- }
-
- function getParser(){
- return new DBParser('"', '"', $this->prefix);
- }
-}
-?>
diff --git a/classes/db/DBSqlite3_pdo.class.php b/classes/db/DBSqlite3_pdo.class.php
deleted file mode 100644
index e84a15b91..000000000
--- a/classes/db/DBSqlite3_pdo.class.php
+++ /dev/null
@@ -1,636 +0,0 @@
- 'INTEGER',
- 'number' => 'INTEGER',
- 'varchar' => 'VARCHAR',
- 'char' => 'CHAR',
- 'text' => 'TEXT',
- 'bigtext' => 'TEXT',
- 'date' => 'VARCHAR(14)',
- 'float' => 'REAL',
- );
-
- /**
- * @brief constructor
- **/
- function DBSqlite3_pdo() {
- $this->_setDBInfo();
- $this->_connect();
- }
-
- /**
- * @brief create an instance of this class
- */
- function create()
- {
- return new DBSqlite3_pdo;
- }
-
- /**
- * @brief Return if installable
- **/
- function isSupported() {
- return class_exists('PDO');
- }
-
- function isConnected() {
- return $this->is_connected;
- }
-
- /**
- * @brief DB settings and connect/close
- **/
- function _setDBInfo() {
- $db_info = Context::getDBInfo();
- $this->database = $db_info->master_db["db_database"];
- $this->prefix = $db_info->master_db["db_table_prefix"];
- //if(!substr($this->prefix,-1)!='_') $this->prefix .= '_';
- }
-
- /**
- * @brief DB Connection
- **/
- function _connect() {
- // override if db information not exists
- if(!$this->database) return;
-
- // Attempt to access the database file
- try {
- // PDO is only supported with PHP5,
- // so it is allowed to use try~catch statment in this class.
- $this->handler = new PDO('sqlite:'.$this->database);
- } catch (PDOException $e) {
- $this->setError(-1, 'Connection failed: '.$e->getMessage());
- $this->is_connected = false;
- return;
- }
-
- // Check connections
- $this->is_connected = true;
- $this->password = md5($this->password);
- }
-
- /**
- * @brief disconnect to DB
- **/
- function close() {
- if(!$this->is_connected) return;
- $this->commit();
- }
-
- /**
- * @brief Begin a transaction
- **/
- function begin() {
- if(!$this->is_connected || $this->transaction_started) return;
- if($this->handler->beginTransaction()) $this->transaction_started = true;
- }
-
- /**
- * @brief Rollback
- **/
- function rollback() {
- if(!$this->is_connected || !$this->transaction_started) return;
- $this->handler->rollBack();
- $this->transaction_started = false;
- }
-
- /**
- * @brief Commit
- **/
- function commit($force = false) {
- if(!$force && (!$this->is_connected || !$this->transaction_started)) return;
- try {
- $this->handler->commit();
- }
- catch(PDOException $e){
- // There was no transaction started, so just continue.
- error_log($e->getMessage());
- }
- $this->transaction_started = false;
- }
-
- /**
- * @brief Add or change quotes to the query string variables
- **/
- function addQuotes($string) {
- if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
- if(!is_numeric($string)) $string = str_replace("'","''",$string);
- return $string;
- }
-
- /**
- * @brief : Prepare a query statement
- **/
- function _prepare($query) {
- if(!$this->is_connected) return;
-
- // notify to start a query execution
- $this->actStart($query);
-
- $this->stmt = $this->handler->prepare($query);
-
- if($this->handler->errorCode() != '00000') {
- $this->setError($this->handler->errorCode(), print_r($this->handler->errorInfo(),true));
- $this->actFinish();
- }
- $this->bind_idx = 0;
- $this->bind_vars = array();
- }
-
- /**
- * @brief : Binding params in stmt
- **/
- function _bind($val) {
- if(!$this->is_connected || !$this->stmt) return;
-
- $this->bind_idx ++;
- $this->bind_vars[] = $val;
- $this->stmt->bindParam($this->bind_idx, $val);
- }
-
- /**
- * @brief : execute the prepared statement
- **/
- function _execute() {
- if(!$this->is_connected || !$this->stmt) return;
-
- $this->stmt->execute();
-
- if($this->stmt->errorCode() === '00000') {
- $output = null;
- while($tmp = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
- unset($obj);
- foreach($tmp as $key => $val) {
- $pos = strpos($key, '.');
- if($pos) $key = substr($key, $pos+1);
- $obj->{$key} = str_replace("''","'",$val);
- }
- $output[] = $obj;
- }
- } else {
- $this->setError($this->stmt->errorCode(),print_r($this->stmt->errorInfo(),true));
- }
-
- $this->stmt = null;
- $this->actFinish();
-
- if(is_array($output) && count($output)==1) return $output[0];
- return $output;
- }
-
- /**
- * @brief Return the sequence value incremented by 1
- **/
- function getNextSequence() {
- $query = sprintf("insert into %ssequence (seq) values (NULL)", $this->prefix);
- $this->_prepare($query);
- $result = $this->_execute();
- $sequence = $this->handler->lastInsertId();
- if($sequence % 10000 == 0) {
- $query = sprintf("delete from %ssequence where seq < %d", $this->prefix, $sequence);
- $this->_prepare($query);
- $result = $this->_execute();
- }
-
- return $sequence;
- }
-
- /**
- * @brief return if the table already exists
- **/
- function isTableExists($target_name) {
- $query = sprintf('pragma table_info(%s%s)', $this->prefix, $target_name);
- $this->_prepare($query);
- if(!$this->_execute()) return false;
- return true;
- }
-
- /**
- * @brief Add a column to a table
- **/
- function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
- $type = $this->column_type[$type];
- if(strtoupper($type)=='INTEGER') $size = '';
-
- $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
- if($size) $query .= sprintf(" %s(%s) ", $type, $size);
- else $query .= sprintf(" %s ", $type);
- if($default) $query .= sprintf(" default '%s' ", $default);
- if($notnull) $query .= " not null ";
-
- $this->_prepare($query);
- return $this->_execute();
- }
-
- /**
- * @brief Remove a column from a table
- **/
- function dropColumn($table_name, $column_name) {
- $query = sprintf("alter table %s%s drop column %s ", $this->prefix, $table_name, $column_name);
- $this->_query($query);
- }
-
- /**
- * @brief Return column information of a table
- **/
- function isColumnExists($table_name, $column_name) {
- $query = sprintf("pragma table_info(%s%s)", $this->prefix, $table_name);
- $this->_prepare($query);
- $output = $this->_execute();
-
- if($output) {
- $column_name = strtolower($column_name);
- foreach($output as $key => $val) {
- $name = strtolower($val->name);
- if($column_name == $name) return true;
- }
- }
- return false;
- }
-
- /**
- * @brief Add an index to a table
- * $target_columns = array(col1, col2)
- * $is_unique? unique : none
- **/
- function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
- if(!is_array($target_columns)) $target_columns = array($target_columns);
-
- $key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
-
- $query = sprintf('CREATE %s INDEX %s ON %s%s (%s)', $is_unique?'UNIQUE':'', $key_name, $this->prefix, $table_name, implode(',',$target_columns));
- $this->_prepare($query);
- $this->_execute();
- }
-
- /**
- * @brief Drop an index from a table
- **/
- function dropIndex($table_name, $index_name, $is_unique = false) {
- $key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
- $query = sprintf("DROP INDEX %s", $this->prefix, $table_name, $key_name);
- $this->_query($query);
- }
-
- /**
- * @brief Return index information of a table
- **/
- function isIndexExists($table_name, $index_name) {
- $key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
-
- $query = sprintf("pragma index_info(%s)", $key_name);
- $this->_prepare($query);
- $output = $this->_execute();
- if(!$output) return false;
- return true;
- }
-
- /**
- * @brief create a table from xml file
- **/
- function createTableByXml($xml_doc) {
- return $this->_createTable($xml_doc);
- }
-
- /**
- * @brief create a table from xml file
- **/
- function createTableByXmlFile($file_name) {
- if(!file_exists($file_name)) return;
- // read xml file
- $buff = FileHandler::readFile($file_name);
- return $this->_createTable($buff);
- }
-
- /**
- * @brief generate a query to create a table using the schema xml
- *
- * type : number, varchar, text, char, date, \n
- * opt : notnull, default, size\n
- * index : primary key, index, unique\n
- **/
- function _createTable($xml_doc) {
- // xml parsing
- $oXml = new XmlParser();
- $xml_obj = $oXml->parse($xml_doc);
- // Create a table schema
- $table_name = $xml_obj->table->attrs->name;
- if($this->isTableExists($table_name)) return;
- $table_name = $this->prefix.$table_name;
-
- if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
- else $columns = $xml_obj->table->column;
-
- foreach($columns as $column) {
- $name = $column->attrs->name;
- $type = $column->attrs->type;
- if(strtoupper($this->column_type[$type])=='INTEGER') $size = '';
- else $size = $column->attrs->size;
- $notnull = $column->attrs->notnull;
- $primary_key = $column->attrs->primary_key;
- $index = $column->attrs->index;
- $unique = $column->attrs->unique;
- $default = $column->attrs->default;
- $auto_increment = $column->attrs->auto_increment;
-
- if($auto_increment) {
- $column_schema[] = sprintf('%s %s PRIMARY KEY %s',
- $name,
- $this->column_type[$type],
- $auto_increment?'AUTOINCREMENT':''
- );
- } else {
- $column_schema[] = sprintf('%s %s%s %s %s %s',
- $name,
- $this->column_type[$type],
- $size?'('.$size.')':'',
- $notnull?'NOT NULL':'',
- $primary_key?'PRIMARY KEY':'',
- isset($default)?"DEFAULT '".$default."'":''
- );
- }
-
- if($unique) $unique_list[$unique][] = $name;
- else if($index) $index_list[$index][] = $name;
- }
-
- $schema = sprintf('CREATE TABLE %s (%s%s) ;', $table_name," ", implode($column_schema,", "));
- $this->_prepare($schema);
- $this->_execute();
- if($this->isError()) return;
-
- if(count($unique_list)) {
- foreach($unique_list as $key => $val) {
- $query = sprintf('CREATE UNIQUE INDEX %s_%s ON %s (%s)', $this->addQuotes($table_name), $key, $this->addQuotes($table_name), implode(',',$val));
- $this->_prepare($query);
- $this->_execute();
- if($this->isError()) $this->rollback();
- }
- }
-
- if(count($index_list)) {
- foreach($index_list as $key => $val) {
- $query = sprintf('CREATE INDEX %s_%s ON %s (%s)', $this->addQuotes($table_name), $key, $this->addQuotes($table_name), implode(',',$val));
- $this->_prepare($query);
- $this->_execute();
- if($this->isError()) $this->rollback();
- }
- }
- }
-
- function _getConnection($type = null){
- return null;
- }
-
- /**
- * @brief insertAct
- * */
- function _executeInsertAct($queryObject) {
- $query = $this->getInsertSql($queryObject);
- if (is_a($query, 'Object'))
- return;
-
- $this->_prepare($query);
-
- $val_count = count($val_list);
- for ($i = 0; $i < $val_count; $i++)
- $this->_bind($val_list[$i]);
-
- return $this->_execute();
- }
-
- /**
- * @brief updateAct
- * */
- function _executeUpdateAct($queryObject) {
- $query = $this->getUpdateSql($queryObject);
- if (is_a($query, 'Object'))
- return;
-
- $this->_prepare($query);
- return $this->_execute();
- }
-
- /**
- * @brief deleteAct
- * */
- function _executeDeleteAct($queryObject) {
- $query = $this->getDeleteSql($queryObject);
- if (is_a($query, 'Object'))
- return;
-
- $this->_prepare($query);
- return $this->_execute();
- }
-
- /**
- * @brief selectAct
- *
- * To fetch a list of the page conveniently when selecting, \n
- * navigation method supported
- * */
- function _executeSelectAct($queryObject) {
- $query = $this->getSelectSql($queryObject);
- if (is_a($query, 'Object'))
- return;
-
- $this->_prepare($query);
- $data = $this->_execute();
- // TODO isError is called twice
- if ($this->isError())
- return;
-
- if ($this->isError())
- return $this->queryError($queryObject);
- else
- return $this->queryPageLimit($queryObject, $data);
- }
-
- function queryError($queryObject) {
- if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
- $buff = new Object ();
- $buff->total_count = 0;
- $buff->total_page = 0;
- $buff->page = 1;
- $buff->data = array();
- $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
- return $buff;
- }else
- return;
- }
-
- function queryPageLimit($queryObject, $data) {
- if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
- // Total count
- $temp_where = $queryObject->getWhereString(true, false);
- $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
- if ($queryObject->getGroupByString() != '') {
- $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
- }
-
- $count_query .= ( __DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
- $this->_prepare($count_query);
- $count_output = $this->_execute();
- $total_count = (int) $count_output->count;
-
- $list_count = $queryObject->getLimit()->list_count->getValue();
- if (!$list_count) $list_count = 20;
- $page_count = $queryObject->getLimit()->page_count->getValue();
- if (!$page_count) $page_count = 10;
- $page = $queryObject->getLimit()->page->getValue();
- if (!$page) $page = 1;
- // Total pages
- if ($total_count) {
- $total_page = (int) (($total_count - 1) / $list_count) + 1;
- } else
- $total_page = 1;
-
- // check the page variables
- if ($page > $total_page) {
- // If requested page is bigger than total number of pages, return empty list
-
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = array();
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- return $buff;
- }
- $start_count = ($page - 1) * $list_count;
-
- $this->_prepare($this->getSelectPageSql($queryObject, true, $start_count, $list_count));
- $this->stmt->execute();
- if ($this->stmt->errorCode() != '00000') {
- $this->setError($this->stmt->errorCode(), print_r($this->stmt->errorInfo(), true));
- $this->actFinish();
- return $buff;
- }
-
- $output = null;
- $virtual_no = $total_count - ($page - 1) * $list_count;
- //$data = $this->_fetch($result, $virtual_no);
- while ($tmp = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
- unset($obj);
- foreach ($tmp as $key => $val) {
- $pos = strpos($key, '.');
- if ($pos)
- $key = substr($key, $pos + 1);
- $obj->{$key} = $val;
- }
- $datatemp[$virtual_no--] = $obj;
- }
-
- $this->stmt = null;
- $this->actFinish();
-
- $buff = new Object ();
- $buff->total_count = $total_count;
- $buff->total_page = $total_page;
- $buff->page = $page;
- $buff->data = $datatemp;
- $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
- }else {
- //$data = $this->_fetch($result);
- $buff = new Object ();
- $buff->data = $data;
- }
- return $buff;
- }
-
- function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) {
-
- $select = $query->getSelectString($with_values);
- if ($select == '')
- return new Object(-1, "Invalid query");
- $select = 'SELECT ' . $select;
-
- $from = $query->getFromString($with_values);
- if ($from == '')
- return new Object(-1, "Invalid query");
- $from = ' FROM ' . $from;
-
- $where = $query->getWhereString($with_values);
- if ($where != '')
- $where = ' WHERE ' . $where;
-
- $groupBy = $query->getGroupByString();
- if ($groupBy != '')
- $groupBy = ' GROUP BY ' . $groupBy;
-
- $orderBy = $query->getOrderByString();
- if ($orderBy != '')
- $orderBy = ' ORDER BY ' . $orderBy;
-
- $limit = $query->getLimitString();
- if ($limit != '' && $query->getLimit()) {
- $limit = sprintf(' LIMIT %d, %d',$start_count, $list_count);
- }
-
- return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
- }
-
- function getParser() {
- return new DBParser('"', '"', $this->prefix);
- }
-
- function getUpdateSql($query, $with_values = true, $with_priority = false){
- $columnsList = $query->getUpdateString($with_values);
- if($columnsList == '') return new Object(-1, "Invalid query");
-
- $tableName = $query->getFirstTableName();
- if($tableName == '') return new Object(-1, "Invalid query");
-
- $where = $query->getWhereString($with_values);
- if($where != '') $where = ' WHERE ' . $where;
-
- $priority = $with_priority?$query->getPriority():'';
-
- return "UPDATE $priority $tableName SET $columnsList ".$where;
- }
-
- function getDeleteSql($query, $with_values = true, $with_priority = false){
- $sql = 'DELETE ';
-
- $tables = $query->getTables();
- $from = $tables[0]->getName();
- $sql .= ' FROM '.$from;
-
- $where = $query->getWhereString($with_values);
- if($where != '') $sql .= ' WHERE ' . $where;
-
- return $sql;
- }
-}
-?>
diff --git a/classes/db/queryparts/Query.class.php b/classes/db/queryparts/Query.class.php
index 516fb3212..5d7448f02 100644
--- a/classes/db/queryparts/Query.class.php
+++ b/classes/db/queryparts/Query.class.php
@@ -1,519 +1,674 @@
queryID = $queryID;
- $this->action = $action;
- $this->priority = $priority;
+ /**
+ * condition list
+ * @var string|array
+ */
+ var $conditions;
- if(!isset($tables)) return;
- $this->columns = $this->setColumns($columns);
- $this->tables = $this->setTables($tables);
- $this->conditions = $this->setConditions($conditions);
- $this->groups = $this->setGroups($groups);
- $this->orderby = $this->setOrder($orderby);
- $this->limit = $this->setLimit($limit);
- }
+ /**
+ * group list
+ * @var string|array
+ */
+ var $groups;
- function show(){
- return TRUE;
- }
+ /**
+ * order list
+ * @var array
+ */
+ var $orderby;
- function setQueryId($queryID){
- $this->queryID = $queryID;
- }
+ /**
+ * limit count
+ * @var int
+ */
+ var $limit;
- function setAction($action){
- $this->action = $action;
- }
-
- function setPriority($priority){
- $this->priority = $priority;
- }
+ /**
+ * argument list
+ * @var array
+ */
+ var $arguments = NULL;
- function setColumnList($columnList){
- $this->columnList = $columnList;
- if(count($this->columnList) > 0) {
- $selectColumns = array();
- $dbParser = DB::getParser();
+ /**
+ * column list
+ * @var array
+ */
+ var $columnList = NULL;
- foreach($this->columnList as $columnName){
- $columnName = $dbParser->escapeColumn($columnName);
- $selectColumns[] = new SelectExpression($columnName);
- }
- unset($this->columns);
- $this->columns = $selectColumns;
- }
- }
+ /**
+ * order by text
+ * @var string
+ */
+ var $_orderByString;
- function setColumns($columns){
- if(!isset($columns) || count($columns) === 0){
- $this->columns = array(new StarExpression());
- return;
- }
+ /**
+ * constructor
+ * @param string $queryID
+ * @param string $action
+ * @param string|array $columns
+ * @param string|array $tables
+ * @param string|array $conditions
+ * @param string|array $groups
+ * @param string|array $orderby
+ * @param int $limit
+ * @param string $priority
+ * @return void
+ */
+ function Query($queryID = NULL
+ , $action = NULL
+ , $columns = NULL
+ , $tables = NULL
+ , $conditions = NULL
+ , $groups = NULL
+ , $orderby = NULL
+ , $limit = NULL
+ , $priority = NULL)
+ {
+ $this->queryID = $queryID;
+ $this->action = $action;
+ $this->priority = $priority;
- if(!is_array($columns)) $columns = array($columns);
-
- $this->columns = $columns;
- }
-
- function setTables($tables){
- if(!isset($tables) || count($tables) === 0){
- $this->setError(TRUE);
- $this->setMessage("You must provide at least one table for the query.");
- return;
- }
-
- if(!is_array($tables)) $tables = array($tables);
-
- $this->tables = $tables;
- }
-
- function setSubquery($subquery){
- $this->subquery = $subquery;
- }
-
- function setConditions($conditions){
- $this->conditions = array();
- if(!isset($conditions) || count($conditions) === 0) return;
- if(!is_array($conditions)) $conditions = array($conditions);
-
- foreach($conditions as $conditionGroup){
- if($conditionGroup->show()) $this->conditions[] = $conditionGroup;
- }
- }
-
- function setGroups($groups){
- if(!isset($groups) || count($groups) === 0) return;
- if(!is_array($groups)) $groups = array($groups);
-
- $this->groups = $groups;
- }
-
- function setOrder($order){
- if(!isset($order) || count($order) === 0) return;
- if(!is_array($order)) $order = array($order);
-
- $this->orderby = $order;
- }
-
- function setLimit($limit = NULL){
- if(!isset($limit)) return;
- $this->limit = $limit;
- }
-
- // START Fluent interface
- /**
- * seleect set
- * @param string|array $columns
- * @return Query return Query instance
- */
- function select($columns= NULL){
- $this->action = 'select';
- $this->setColumns($columns);
- return $this;
- }
-
- /**
- * from set
- * @param string|array $tables
- * @return Query return Query instance
- */
- function from($tables){
- $this->setTables($tables);
- return $this;
- }
-
- /**
- * where set
- * @param string|array $conditions
- * @return Query return Query instance
- */
- function where($conditions){
- $this->setConditions($conditions);
- return $this;
- }
-
- /**
- * groupBy set
- * @param string|array $groups
- * @return Query return Query instance
- */
- function groupBy($groups){
- $this->setGroups($groups);
- return $this;
- }
-
- /**
- * orderBy set
- * @param string|array $order
- * @return Query return Query instance
- */
- function orderBy($order){
- $this->setOrder($order);
- return $this;
- }
-
- /**
- * limit set
- * @param int $limit
- * @return Query return Query instance
- */
- function limit($limit){
- $this->setLimit($limit);
- return $this;
- }
- // END Fluent interface
-
- function getAction(){
- return $this->action;
- }
-
- function getPriority(){
- return $this->priority?'LOW_PRIORITY':'';
- }
-
- /**
- * Check if current query uses the click count attribute
- * For CUBRID, this statement uses the click count feature.
- * For the other databases, using this attribute causes a query
- * to produce both a select and an update
- */
- function usesClickCount()
+ if(!isset($tables))
{
- return count($this->getClickCountColumns()) > 0;
+ return;
}
- function getClickCountColumns()
+ $this->columns = $this->setColumns($columns);
+ $this->tables = $this->setTables($tables);
+ $this->conditions = $this->setConditions($conditions);
+ $this->groups = $this->setGroups($groups);
+ $this->orderby = $this->setOrder($orderby);
+ $this->limit = $this->setLimit($limit);
+ }
+
+ function show()
+ {
+ return TRUE;
+ }
+
+ function setQueryId($queryID)
+ {
+ $this->queryID = $queryID;
+ }
+
+ function setAction($action)
+ {
+ $this->action = $action;
+ }
+
+ function setPriority($priority)
+ {
+ $this->priority = $priority;
+ }
+
+ function setColumnList($columnList)
+ {
+ $this->columnList = $columnList;
+ if(count($this->columnList) > 0)
{
- $click_count_columns = array();
- foreach($this->columns as $column){
- if($column->show() && is_a($column, 'ClickCountExpression'))
- $click_count_columns[] = $column;
+ $selectColumns = array();
+ $dbParser = DB::getParser();
+
+ foreach($this->columnList as $columnName)
+ {
+ $columnName = $dbParser->escapeColumn($columnName);
+ $selectColumns[] = new SelectExpression($columnName);
}
- return $click_count_columns;
- }
-
- /**
- * Return select sql
- * @param boolean $with_values
- * @return string
- */
- function getSelectString($with_values = TRUE){
- $select = array();
- foreach($this->columns as $column){
- if($column->show())
- if($column->isSubquery()){
- $select[] = $column->toString($with_values) . ' as '. $column->getAlias();
- }
- else
- $select[] = $column->getExpression($with_values);
- }
- return trim(implode($select, ', '));
- }
-
- /**
- * Return update sql
- * @param boolean $with_values
- * @return string
- */
- function getUpdateString($with_values = TRUE){
- foreach($this->columns as $column){
- if($column->show())
- $update[] = $column->getExpression($with_values);
- }
- return trim(implode($update, ', '));
- }
-
- /**
- * Return insert sql
- * @param boolean $with_values
- * @return string
- */
- function getInsertString($with_values = TRUE){
- $columnsList = '';
- if($this->subquery){ // means we have insert-select
-
- foreach($this->columns as $column){
- $columnsList .= $column->getColumnName() . ', ';
- }
- $columnsList = substr($columnsList, 0, -2);
-
- $selectStatement = $this->subquery->toString($with_values);
- $selectStatement = substr($selectStatement, 1, -1);
-
- return "($columnsList) \n $selectStatement";
- }
-
-
- $valuesList = '';
- foreach($this->columns as $column){
- if($column->show()){
- $columnsList .= $column->getColumnName() . ', ';
- $valuesList .= $column->getValue($with_values) . ', ';
- }
- }
- $columnsList = substr($columnsList, 0, -2);
- $valuesList = substr($valuesList, 0, -2);
-
- return "($columnsList) \n VALUES ($valuesList)";
- }
-
- function getTables(){
- return $this->tables;
- }
-
- /**
- * from table_a
- * from table_a inner join table_b on x=y
- * from (select * from table a) as x
- * from (select * from table t) as x inner join table y on y.x
- * @param boolean $with_values
- * @return string
- */
- function getFromString($with_values = TRUE){
- $from = '';
- $simple_table_count = 0;
- foreach($this->tables as $table){
- if($table->isJoinTable() || !$simple_table_count) $from .= $table->toString($with_values) . ' ';
- else $from .= ', '.$table->toString($with_values) . ' ';
-
- if(is_a($table, 'Subquery')) $from .= $table->getAlias() ? ' as ' . $table->getAlias() . ' ' : ' ';
-
- $simple_table_count++;
- }
- if(trim($from) == '') return '';
- return $from;
- }
-
- /**
- * Return where sql
- * @param boolean $with_values
- * @param boolean $with_optimization
- * @return string
- */
- function getWhereString($with_values = TRUE, $with_optimization = TRUE){
- $where = '';
- $condition_count = 0;
-
- foreach ($this->conditions as $conditionGroup) {
- if ($condition_count === 0) {
- $conditionGroup->setPipe("");
- }
- $condition_string = $conditionGroup->toString($with_values);
- $where .= $condition_string;
- $condition_count++;
- }
-
- if ($with_optimization &&
- (strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order'))) {
-
- if ($condition_count !== 0)
- $where = '(' . $where . ') ';
-
- foreach ($this->orderby as $order) {
- $colName = $order->getColumnName();
- if (strstr($colName, 'list_order') || strstr($colName, 'update_order')) {
- $opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and');
- if ($condition_count === 0)
- $opt_condition->setPipe("");
- $where .= $opt_condition->toString($with_values) . ' ';
- $condition_count++;
- }
- }
- }
-
- return trim($where);
- }
-
- /**
- * Return groupby sql
- * @return string
- */
- function getGroupByString(){
- $groupBy = '';
- if($this->groups) if($this->groups[0] !== "")
- $groupBy = implode(', ', $this->groups);
- return $groupBy;
- }
-
- /**
- * Return orderby sql
- * @return string
- */
- function getOrderByString(){
- if(!$this->_orderByString){
- if(count($this->orderby) === 0) return '';
- $orderBy = '';
- foreach($this->orderby as $order){
- $orderBy .= $order->toString() .', ';
- }
- $orderBy = substr($orderBy, 0, -2);
- $this->_orderByString = $orderBy;
- }
- return $this->_orderByString;
- }
-
- function getLimit(){
- return $this->limit;
- }
-
- /**
- * Return limit sql
- * @return string
- */
- function getLimitString(){
- $limit = '';
- if(count($this->limit) > 0){
- $limit = '';
- $limit .= $this->limit->toString();
- }
- return $limit;
- }
-
- function getFirstTableName(){
- return $this->tables[0]->getName();
- }
-
- /**
- * Return argument list
- * @return array
- */
- function getArguments(){
- if(!isset($this->arguments)){
- $this->arguments = array();
-
- // Join table arguments
- if(count($this->tables) > 0)
- {
- foreach($this->tables as $table)
- {
- if($table->isJoinTable() || is_a($table, 'Subquery'))
- {
- $args = $table->getArguments();
- if($args) $this->arguments = array_merge($this->arguments, $args);
- }
- }
- }
-
- // Column arguments
- if(count($this->columns) > 0){ // The if is for delete statements, all others must have columns
- foreach($this->columns as $column){
- if($column->show()){
- $args = $column->getArguments();
- if($args) $this->arguments = array_merge($this->arguments, $args);
- }
- }
- }
-
- // Condition arguments
- if(count($this->conditions) > 0)
- foreach($this->conditions as $conditionGroup){
- $args = $conditionGroup->getArguments();
- if(count($args) > 0) $this->arguments = array_merge($this->arguments, $args);
- }
-
- // Navigation arguments
- if(count($this->orderby) > 0)
- foreach($this->orderby as $order){
- $args = $order->getArguments();
- if(count($args) > 0) $this->arguments = array_merge($this->arguments, $args);
- }
- }
- return $this->arguments;
+ unset($this->columns);
+ $this->columns = $selectColumns;
}
}
+ function setColumns($columns)
+ {
+ if(!isset($columns) || count($columns) === 0)
+ {
+ $this->columns = array(new StarExpression());
+ return;
+ }
+ if(!is_array($columns))
+ {
+ $columns = array($columns);
+ }
-?>
+ $this->columns = $columns;
+ }
+
+ function setTables($tables)
+ {
+ if(!isset($tables) || count($tables) === 0)
+ {
+ $this->setError(TRUE);
+ $this->setMessage("You must provide at least one table for the query.");
+ return;
+ }
+
+ if(!is_array($tables))
+ {
+ $tables = array($tables);
+ }
+
+ $this->tables = $tables;
+ }
+
+ function setSubquery($subquery)
+ {
+ $this->subquery = $subquery;
+ }
+
+ function setConditions($conditions)
+ {
+ $this->conditions = array();
+ if(!isset($conditions) || count($conditions) === 0)
+ {
+ return;
+ }
+ if(!is_array($conditions))
+ {
+ $conditions = array($conditions);
+ }
+
+ foreach($conditions as $conditionGroup)
+ {
+ if($conditionGroup->show())
+ {
+ $this->conditions[] = $conditionGroup;
+ }
+ }
+ }
+
+ function setGroups($groups)
+ {
+ if(!isset($groups) || count($groups) === 0)
+ {
+ return;
+ }
+ if(!is_array($groups))
+ {
+ $groups = array($groups);
+ }
+
+ $this->groups = $groups;
+ }
+
+ function setOrder($order)
+ {
+ if(!isset($order) || count($order) === 0)
+ {
+ return;
+ }
+ if(!is_array($order))
+ {
+ $order = array($order);
+ }
+
+ $this->orderby = $order;
+ }
+
+ function getOrder()
+ {
+ return $this->orderby;
+ }
+
+ function setLimit($limit = NULL)
+ {
+ if(!isset($limit))
+ {
+ return;
+ }
+ $this->limit = $limit;
+ }
+
+ // START Fluent interface
+ /**
+ * seleect set
+ * @param string|array $columns
+ * @return Query return Query instance
+ */
+ function select($columns = NULL)
+ {
+ $this->action = 'select';
+ $this->setColumns($columns);
+ return $this;
+ }
+
+ /**
+ * from set
+ * @param string|array $tables
+ * @return Query return Query instance
+ */
+ function from($tables)
+ {
+ $this->setTables($tables);
+ return $this;
+ }
+
+ /**
+ * where set
+ * @param string|array $conditions
+ * @return Query return Query instance
+ */
+ function where($conditions)
+ {
+ $this->setConditions($conditions);
+ return $this;
+ }
+
+ /**
+ * groupBy set
+ * @param string|array $groups
+ * @return Query return Query instance
+ */
+ function groupBy($groups)
+ {
+ $this->setGroups($groups);
+ return $this;
+ }
+
+ /**
+ * orderBy set
+ * @param string|array $order
+ * @return Query return Query instance
+ */
+ function orderBy($order)
+ {
+ $this->setOrder($order);
+ return $this;
+ }
+
+ /**
+ * limit set
+ * @param int $limit
+ * @return Query return Query instance
+ */
+ function limit($limit)
+ {
+ $this->setLimit($limit);
+ return $this;
+ }
+
+ // END Fluent interface
+
+ function getAction()
+ {
+ return $this->action;
+ }
+
+ function getPriority()
+ {
+ return $this->priority ? 'LOW_PRIORITY' : '';
+ }
+
+ /**
+ * Check if current query uses the click count attribute
+ * For CUBRID, this statement uses the click count feature.
+ * For the other databases, using this attribute causes a query
+ * to produce both a select and an update
+ */
+ function usesClickCount()
+ {
+ return count($this->getClickCountColumns()) > 0;
+ }
+
+ function getClickCountColumns()
+ {
+ $click_count_columns = array();
+ foreach($this->columns as $column)
+ {
+ if($column->show() && is_a($column, 'ClickCountExpression'))
+ {
+ $click_count_columns[] = $column;
+ }
+ }
+ return $click_count_columns;
+ }
+
+ /**
+ * Return select sql
+ * @param boolean $with_values
+ * @return string
+ */
+ function getSelectString($with_values = TRUE)
+ {
+ foreach($this->columns as $column)
+ {
+ if($column->show())
+ {
+ if($column->isSubquery())
+ {
+ $select[] = $column->toString($with_values) . ' as ' . $column->getAlias();
+ }
+ else
+ {
+ $select[] = $column->getExpression($with_values);
+ }
+ }
+ }
+ return trim(implode($select, ', '));
+ }
+
+ /**
+ * Return update sql
+ * @param boolean $with_values
+ * @return string
+ */
+ function getUpdateString($with_values = TRUE)
+ {
+ foreach($this->columns as $column)
+ {
+ if($column->show())
+ {
+ $update[] = $column->getExpression($with_values);
+ }
+ }
+ return trim(implode($update, ', '));
+ }
+
+ /**
+ * Return insert sql
+ * @param boolean $with_values
+ * @return string
+ */
+ function getInsertString($with_values = TRUE)
+ {
+ $columnsList = '';
+ // means we have insert-select
+ if($this->subquery)
+ {
+ foreach($this->columns as $column)
+ {
+ $columnsList .= $column->getColumnName() . ', ';
+ }
+ $columnsList = substr($columnsList, 0, -2);
+ $selectStatement = $this->subquery->toString($with_values);
+ $selectStatement = substr($selectStatement, 1, -1);
+ return "($columnsList) \n $selectStatement";
+ }
+
+ $valuesList = '';
+ foreach($this->columns as $column)
+ {
+ if($column->show())
+ {
+ $columnsList .= $column->getColumnName() . ', ';
+ $valuesList .= $column->getValue($with_values) . ', ';
+ }
+ }
+ $columnsList = substr($columnsList, 0, -2);
+ $valuesList = substr($valuesList, 0, -2);
+
+ return "($columnsList) \n VALUES ($valuesList)";
+ }
+
+ function getTables()
+ {
+ return $this->tables;
+ }
+
+ /**
+ * from table_a
+ * from table_a inner join table_b on x=y
+ * from (select * from table a) as x
+ * from (select * from table t) as x inner join table y on y.x
+ * @param boolean $with_values
+ * @return string
+ */
+ function getFromString($with_values = TRUE)
+ {
+ $from = '';
+ $simple_table_count = 0;
+ foreach($this->tables as $table)
+ {
+ if($table->isJoinTable() || !$simple_table_count)
+ {
+ $from .= $table->toString($with_values) . ' ';
+ }
+ else
+ {
+ $from .= ', ' . $table->toString($with_values) . ' ';
+ }
+
+ if(is_a($table, 'Subquery'))
+ {
+ $from .= $table->getAlias() ? ' as ' . $table->getAlias() . ' ' : ' ';
+ }
+
+ $simple_table_count++;
+ }
+ if(trim($from) == '')
+ {
+ return '';
+ }
+ return $from;
+ }
+
+ /**
+ * Return where sql
+ * @param boolean $with_values
+ * @param boolean $with_optimization
+ * @return string
+ */
+ function getWhereString($with_values = TRUE, $with_optimization = TRUE)
+ {
+ $where = '';
+ $condition_count = 0;
+
+ foreach($this->conditions as $conditionGroup)
+ {
+ if($condition_count === 0)
+ {
+ $conditionGroup->setPipe("");
+ }
+ $condition_string = $conditionGroup->toString($with_values);
+ $where .= $condition_string;
+ $condition_count++;
+ }
+
+ if($with_optimization &&
+ (strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order')))
+ {
+
+ if($condition_count !== 0)
+ {
+ $where = '(' . $where . ') ';
+ }
+
+ foreach($this->orderby as $order)
+ {
+ $colName = $order->getColumnName();
+ if(strstr($colName, 'list_order') || strstr($colName, 'update_order'))
+ {
+ $opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and');
+ if($condition_count === 0)
+ {
+ $opt_condition->setPipe("");
+ }
+ $where .= $opt_condition->toString($with_values) . ' ';
+ $condition_count++;
+ }
+ }
+ }
+
+ return trim($where);
+ }
+
+ /**
+ * Return groupby sql
+ * @return string
+ */
+ function getGroupByString()
+ {
+ $groupBy = '';
+ if($this->groups)
+ {
+ if($this->groups[0] !== "")
+ {
+ $groupBy = implode(', ', $this->groups);
+ }
+ }
+ return $groupBy;
+ }
+
+ /**
+ * Return orderby sql
+ * @return string
+ */
+ function getOrderByString()
+ {
+ if(!$this->_orderByString)
+ {
+ if(count($this->orderby) === 0)
+ {
+ return '';
+ }
+ $orderBy = '';
+ foreach($this->orderby as $order)
+ {
+ $orderBy .= $order->toString() . ', ';
+ }
+ $orderBy = substr($orderBy, 0, -2);
+ $this->_orderByString = $orderBy;
+ }
+ return $this->_orderByString;
+ }
+
+ function getLimit()
+ {
+ return $this->limit;
+ }
+
+ /**
+ * Return limit sql
+ * @return string
+ */
+ function getLimitString()
+ {
+ $limit = '';
+ if(count($this->limit) > 0)
+ {
+ $limit = '';
+ $limit .= $this->limit->toString();
+ }
+ return $limit;
+ }
+
+ function getFirstTableName()
+ {
+ return $this->tables[0]->getName();
+ }
+
+ /**
+ * Return argument list
+ * @return array
+ */
+ function getArguments()
+ {
+ if(!isset($this->arguments))
+ {
+ $this->arguments = array();
+
+ // Join table arguments
+ if(count($this->tables) > 0)
+ {
+ foreach($this->tables as $table)
+ {
+ if($table->isJoinTable() || is_a($table, 'Subquery'))
+ {
+ $args = $table->getArguments();
+ if($args)
+ {
+ $this->arguments = array_merge($this->arguments, $args);
+ }
+ }
+ }
+ }
+
+ // Column arguments
+ // The if is for delete statements, all others must have columns
+ if(count($this->columns) > 0)
+ {
+ foreach($this->columns as $column)
+ {
+ if($column->show())
+ {
+ $args = $column->getArguments();
+ if($args)
+ {
+ $this->arguments = array_merge($this->arguments, $args);
+ }
+ }
+ }
+ }
+
+ // Condition arguments
+ if(count($this->conditions) > 0)
+ {
+ foreach($this->conditions as $conditionGroup)
+ {
+ $args = $conditionGroup->getArguments();
+ if(count($args) > 0)
+ {
+ $this->arguments = array_merge($this->arguments, $args);
+ }
+ }
+ }
+
+ // Navigation arguments
+ if(count($this->orderby) > 0)
+ {
+ foreach($this->orderby as $order)
+ {
+ $args = $order->getArguments();
+ if(count($args) > 0)
+ {
+ $this->arguments = array_merge($this->arguments, $args);
+ }
+ }
+ }
+ }
+ return $this->arguments;
+ }
+
+}
+/* End of file Query.class.php */
+/* Location: ./classes/db/queryparts/Query.class.php */
diff --git a/classes/db/queryparts/Subquery.class.php b/classes/db/queryparts/Subquery.class.php
index 922b7f0b8..53c3b7bb0 100644
--- a/classes/db/queryparts/Subquery.class.php
+++ b/classes/db/queryparts/Subquery.class.php
@@ -1,65 +1,79 @@
alias = $alias;
+ /**
+ * join type
+ * @var string
+ */
+ var $join_type;
- $this->queryID = null;
- $this->action = "select";
+ /**
+ * constructor
+ * @param string $alias
+ * @param string|array $columns
+ * @param string|array $tables
+ * @param string|array $conditions
+ * @param string|array $groups
+ * @param string|array $orderby
+ * @param int $limit
+ * @param string $join_type
+ * @return void
+ */
+ function Subquery($alias, $columns, $tables, $conditions, $groups, $orderby, $limit, $join_type = null)
+ {
+ $this->alias = $alias;
- $this->columns = $columns;
- $this->tables = $tables;
- $this->conditions = $conditions;
- $this->groups = $groups;
- $this->orderby = $orderby;
- $this->limit = $limit;
- $this->join_type = $join_type;
- }
+ $this->queryID = null;
+ $this->action = "select";
- function getAlias(){
- return $this->alias;
- }
-
- function isJoinTable(){
- if($this->join_type) return true;
- return false;
- }
-
- function toString($with_values = true){
- $oDB = &DB::getInstance();
-
- return '(' .$oDB->getSelectSql($this, $with_values) . ')';
-
- }
-
- function isSubquery(){
- return true;
- }
+ $this->columns = $columns;
+ $this->tables = $tables;
+ $this->conditions = $conditions;
+ $this->groups = $groups;
+ $this->orderby = $orderby;
+ $this->limit = $limit;
+ $this->join_type = $join_type;
}
+
+ function getAlias()
+ {
+ return $this->alias;
+ }
+
+ function isJoinTable()
+ {
+ if($this->join_type)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ function toString($with_values = true)
+ {
+ $oDB = &DB::getInstance();
+
+ return '(' . $oDB->getSelectSql($this, $with_values) . ')';
+ }
+
+ function isSubquery()
+ {
+ return true;
+ }
+
+}
+/* End of file Subquery.class.php */
+/* Location: ./classes/db/queryparts/Subquery.class.php */
diff --git a/classes/db/queryparts/condition/Condition.class.php b/classes/db/queryparts/condition/Condition.class.php
index 4e4a2c634..211f8d59d 100644
--- a/classes/db/queryparts/condition/Condition.class.php
+++ b/classes/db/queryparts/condition/Condition.class.php
@@ -1,223 +1,257 @@
column_name = $column_name;
- $this->argument = $argument;
- $this->operation = $operation;
- $this->pipe = $pipe;
-
- }
-
- function getArgument(){
- return null;
- }
-
- /**
- * value to string
- * @param boolean $withValue
- * @return string
- */
- function toString($withValue = true){
- if (!isset($this->_value_to_string)) {
- if (!$this->show())
- {
- $this->_value_to_string = '';
- }
- else if ($withValue)
- {
- $this->_value_to_string = $this->toStringWithValue();
- }
- else
- {
- $this->_value_to_string = $this->toStringWithoutValue();
- }
- }
- return $this->_value_to_string;
- }
-
- /**
- * change string without value
- * @return string
- */
- function toStringWithoutValue(){
- return $this->pipe . ' ' . $this->getConditionPart($this->_value);
- }
-
- /**
- * change string with value
- * @return string
- */
- function toStringWithValue(){
- return $this->pipe . ' ' . $this->getConditionPart($this->_value);
- }
-
- function setPipe($pipe){
- $this->pipe = $pipe;
- }
-
- /**
- * @return boolean
- */
- function show(){
- if(!isset($this->_show)){
- if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') {
- $this->_show = false;
- }
- else {
- $this->_show = true;
- switch($this->operation) {
- case 'equal' :
- case 'more' :
- case 'excess' :
- case 'less' :
- case 'below' :
- case 'like_tail' :
- case 'like_prefix' :
- case 'like' :
- case 'notlike_tail' :
- case 'notlike_prefix' :
- case 'notlike' :
- case 'in' :
- case 'notin' :
- case 'not_in' :
- case 'and':
- case 'or':
- case 'xor':
- case 'not':
- case 'notequal' :
- // if variable is not set or is not string or number, return
- if(!isset($this->_value)) { $this->_show = false; break;}
- if($this->_value === '') { $this->_show = false; break; }
- $tmpArray = array('string'=>1, 'integer'=>1);
- if(!isset($tmpArray[gettype($this->_value)]))
- {
- $this->_show = false; break;
- }
- break;
- case 'between' :
- if(!is_array($this->_value)) { $this->_show = false; break;}
- if(count($this->_value)!=2) {$this->_show = false; break;}
- case 'null':
- case 'notnull':
- break;
- default:
- // If operation is not one of the above, means the condition is invalid
- $this->_show = false;
- }
- }
- }
- return $this->_show;
- }
-
- /**
- * Return condition string
- * @param int|string|array $value
- * @return string
- */
- function getConditionPart($value) {
- $name = $this->column_name;
- $operation = $this->operation;
-
- switch($operation) {
- case 'equal' :
- return $name.' = '.$value;
- break;
- case 'more' :
- return $name.' >= '.$value;
- break;
- case 'excess' :
- return $name.' > '.$value;
- break;
- case 'less' :
- return $name.' <= '.$value;
- break;
- case 'below' :
- return $name.' < '.$value;
- break;
- case 'like_tail' :
- case 'like_prefix' :
- case 'like' :
- if(defined('__CUBRID_VERSION__')
- && __CUBRID_VERSION__ >= '8.4.1')
- return $name.' rlike '.$value;
- else
- return $name.' like '.$value;
- break;
- case 'notlike_tail' :
- case 'notlike_prefix' :
- case 'notlike' :
- return $name.' not like '.$value;
- break;
- case 'in' :
- return $name.' in '.$value;
- break;
- case 'notin' :
- case 'not_in' :
- return $name.' not in '.$value;
- break;
- case 'notequal' :
- return $name.' <> '.$value;
- break;
- case 'notnull' :
- return $name.' is not null';
- break;
- case 'null' :
- return $name.' is null';
- break;
- case 'and' :
- return $name.' & '.$value;
- break;
- case 'or' :
- return $name.' | '.$value;
- break;
- case 'xor' :
- return $name.' ^ '.$value;
- break;
- case 'not' :
- return $name.' ~ '.$value;
- break;
- case 'between' :
- return $name.' between ' . $value[0] . ' and ' . $value[1];
- break;
- }
- }
+ /**
+ * constructor
+ * @param string $column_name
+ * @param mixed $argument
+ * @param string $operation
+ * @param string $pipe
+ * @return void
+ */
+ function Condition($column_name, $argument, $operation, $pipe)
+ {
+ $this->column_name = $column_name;
+ $this->argument = $argument;
+ $this->operation = $operation;
+ $this->pipe = $pipe;
}
-?>
+ function getArgument()
+ {
+ return null;
+ }
+
+ /**
+ * value to string
+ * @param boolean $withValue
+ * @return string
+ */
+ function toString($withValue = true)
+ {
+ if(!isset($this->_value_to_string))
+ {
+ if(!$this->show())
+ {
+ $this->_value_to_string = '';
+ }
+ else if($withValue)
+ {
+ $this->_value_to_string = $this->toStringWithValue();
+ }
+ else
+ {
+ $this->_value_to_string = $this->toStringWithoutValue();
+ }
+ }
+ return $this->_value_to_string;
+ }
+
+ /**
+ * change string without value
+ * @return string
+ */
+ function toStringWithoutValue()
+ {
+ return $this->pipe . ' ' . $this->getConditionPart($this->_value);
+ }
+
+ /**
+ * change string with value
+ * @return string
+ */
+ function toStringWithValue()
+ {
+ return $this->pipe . ' ' . $this->getConditionPart($this->_value);
+ }
+
+ function setPipe($pipe)
+ {
+ $this->pipe = $pipe;
+ }
+
+ /**
+ * @return boolean
+ */
+ function show()
+ {
+ if(!isset($this->_show))
+ {
+ if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '')
+ {
+ $this->_show = false;
+ }
+ else
+ {
+ $this->_show = true;
+ switch($this->operation)
+ {
+ case 'equal' :
+ case 'more' :
+ case 'excess' :
+ case 'less' :
+ case 'below' :
+ case 'like_tail' :
+ case 'like_prefix' :
+ case 'like' :
+ case 'notlike_tail' :
+ case 'notlike_prefix' :
+ case 'notlike' :
+ case 'in' :
+ case 'notin' :
+ case 'not_in' :
+ case 'and':
+ case 'or':
+ case 'xor':
+ case 'not':
+ case 'notequal' :
+ // if variable is not set or is not string or number, return
+ if(!isset($this->_value))
+ {
+ $this->_show = false;
+ break;
+ }
+ if($this->_value === '')
+ {
+ $this->_show = false;
+ break;
+ }
+ $tmpArray = array('string' => 1, 'integer' => 1);
+ if(!isset($tmpArray[gettype($this->_value)]))
+ {
+ $this->_show = false;
+ break;
+ }
+ break;
+ case 'between' :
+ if(!is_array($this->_value))
+ {
+ $this->_show = false;
+ break;
+ }
+ if(count($this->_value) != 2)
+ {
+ $this->_show = false;
+ break;
+ }
+ case 'null':
+ case 'notnull':
+ break;
+ default:
+ // If operation is not one of the above, means the condition is invalid
+ $this->_show = false;
+ }
+ }
+ }
+ return $this->_show;
+ }
+
+ /**
+ * Return condition string
+ * @param int|string|array $value
+ * @return string
+ */
+ function getConditionPart($value)
+ {
+ $name = $this->column_name;
+ $operation = $this->operation;
+
+ switch($operation)
+ {
+ case 'equal' :
+ return $name . ' = ' . $value;
+ break;
+ case 'more' :
+ return $name . ' >= ' . $value;
+ break;
+ case 'excess' :
+ return $name . ' > ' . $value;
+ break;
+ case 'less' :
+ return $name . ' <= ' . $value;
+ break;
+ case 'below' :
+ return $name . ' < ' . $value;
+ break;
+ case 'like_tail' :
+ case 'like_prefix' :
+ case 'like' :
+ if(defined('__CUBRID_VERSION__')
+ && __CUBRID_VERSION__ >= '8.4.1')
+ return $name . ' rlike ' . $value;
+ else
+ return $name . ' like ' . $value;
+ break;
+ case 'notlike_tail' :
+ case 'notlike_prefix' :
+ case 'notlike' :
+ return $name . ' not like ' . $value;
+ break;
+ case 'in' :
+ return $name . ' in ' . $value;
+ break;
+ case 'notin' :
+ case 'not_in' :
+ return $name . ' not in ' . $value;
+ break;
+ case 'notequal' :
+ return $name . ' <> ' . $value;
+ break;
+ case 'notnull' :
+ return $name . ' is not null';
+ break;
+ case 'null' :
+ return $name . ' is null';
+ break;
+ case 'and' :
+ return $name . ' & ' . $value;
+ break;
+ case 'or' :
+ return $name . ' | ' . $value;
+ break;
+ case 'xor' :
+ return $name . ' ^ ' . $value;
+ break;
+ case 'not' :
+ return $name . ' ~ ' . $value;
+ break;
+ case 'between' :
+ return $name . ' between ' . $value[0] . ' and ' . $value[1];
+ break;
+ }
+ }
+
+}
+/* End of file Condition.class.php */
+/* Location: ./classes/db/queryparts/condition/Condition.class.php */
diff --git a/classes/db/queryparts/condition/ConditionGroup.class.php b/classes/db/queryparts/condition/ConditionGroup.class.php
index daa90ad0a..1a0962dde 100644
--- a/classes/db/queryparts/condition/ConditionGroup.class.php
+++ b/classes/db/queryparts/condition/ConditionGroup.class.php
@@ -1,87 +1,119 @@
conditions = array();
- foreach($conditions as $condition){
- if($condition->show())
- $this->conditions[] = $condition;
- }
- if(count($this->conditions) === 0) $this->_show = false;
- else $this->_show = true;
-
- $this->pipe = $pipe;
+ /**
+ * constructor
+ * @param array $conditions
+ * @param string $pipe
+ * @return void
+ */
+ function ConditionGroup($conditions, $pipe = "")
+ {
+ $this->conditions = array();
+ foreach($conditions as $condition)
+ {
+ if($condition->show())
+ {
+ $this->conditions[] = $condition;
+ }
+ }
+ if(count($this->conditions) === 0)
+ {
+ $this->_show = false;
+ }
+ else
+ {
+ $this->_show = true;
}
- function show(){
- return $this->_show;
- }
+ $this->pipe = $pipe;
+ }
- function setPipe($pipe){
- if($this->pipe !== $pipe) $this->_group = null;
- $this->pipe = $pipe;
- }
+ function show()
+ {
+ return $this->_show;
+ }
- /**
- * value to string
- * @param boolean $with_value
- * @return string
- */
- function toString($with_value = true){
- if(!isset($this->_group)){
+ function setPipe($pipe)
+ {
+ if($this->pipe !== $pipe)
+ {
+ $this->_group = null;
+ }
+ $this->pipe = $pipe;
+ }
+
+ /**
+ * value to string
+ * @param boolean $with_value
+ * @return string
+ */
+ function toString($with_value = true)
+ {
+ if(!isset($this->_group))
+ {
$cond_indx = 0;
- $group = '';
+ $group = '';
- foreach($this->conditions as $condition){
- if($cond_indx === 0) $condition->setPipe("");
- $group .= $condition->toString($with_value) . ' ';
- $cond_indx++;
+ foreach($this->conditions as $condition)
+ {
+ if($cond_indx === 0)
+ {
+ $condition->setPipe("");
+ }
+ $group .= $condition->toString($with_value) . ' ';
+ $cond_indx++;
}
- if($this->pipe !== "" && trim($group) !== ''){
- $group = $this->pipe . ' (' . $group . ')';
- }
+ if($this->pipe !== "" && trim($group) !== '')
+ {
+ $group = $this->pipe . ' (' . $group . ')';
+ }
- $this->_group = $group;
- }
- return $this->_group;
- }
-
- /**
- * return argument list
- * @return array
- */
- function getArguments(){
- $args = array();
- foreach($this->conditions as $condition){
- $arg = $condition->getArgument();
- if($arg) $args[] = $arg;
- }
- return $args;
+ $this->_group = $group;
}
+ return $this->_group;
}
-?>
+
+ /**
+ * return argument list
+ * @return array
+ */
+ function getArguments()
+ {
+ $args = array();
+ foreach($this->conditions as $condition)
+ {
+ $arg = $condition->getArgument();
+ if($arg)
+ {
+ $args[] = $arg;
+ }
+ }
+ return $args;
+ }
+
+}
+/* End of file ConditionGroup.class.php */
+/* Location: ./classes/db/queryparts/condition/ConditionGroup.class.php */
diff --git a/classes/db/queryparts/condition/ConditionSubquery.class.php b/classes/db/queryparts/condition/ConditionSubquery.class.php
index 6d359914a..b286db23b 100644
--- a/classes/db/queryparts/condition/ConditionSubquery.class.php
+++ b/classes/db/queryparts/condition/ConditionSubquery.class.php
@@ -1,23 +1,27 @@
_value = $this->argument->toString();
- }
+/**
+ * @author NHN (developers@xpressengine.com)
+ * @package /classes/db/queryparts/condition
+ * @version 0.1
+ */
+class ConditionSubquery extends Condition
+{
+
+ /**
+ * constructor
+ * @param string $column_name
+ * @param mixed $argument
+ * @param string $operation
+ * @param string $pipe
+ * @return void
+ */
+ function ConditionSubquery($column_name, $argument, $operation, $pipe = "")
+ {
+ parent::Condition($column_name, $argument, $operation, $pipe);
+ $this->_value = $this->argument->toString();
}
-?>
+}
+/* End of file ConditionSubquery.class.php */
+/* Location: ./classes/db/queryparts/condition/ConditionSubquery.class.php */
diff --git a/classes/db/queryparts/condition/ConditionWithArgument.class.php b/classes/db/queryparts/condition/ConditionWithArgument.class.php
index 42bc86cd4..08366d64e 100644
--- a/classes/db/queryparts/condition/ConditionWithArgument.class.php
+++ b/classes/db/queryparts/condition/ConditionWithArgument.class.php
@@ -1,71 +1,98 @@
_show = false; return; }
- parent::Condition($column_name, $argument, $operation, $pipe);
- $this->_value = $argument->getValue();
- }
-
- function getArgument(){
- if(!$this->show()) return;
- return $this->argument;
- }
-
- /**
- * change string without value
- * @return string
- */
- function toStringWithoutValue(){
- $value = $this->argument->getUnescapedValue();
-
- if(is_array($value)){
- $q = '';
- foreach ($value as $v) $q .= '?,';
- if($q !== '') $q = substr($q, 0, -1);
- $q = '(' . $q . ')';
- }
- else
- {
- // Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
- if($this->argument->isColumnName())
- {
- $q = $value;
- }
- else
- {
- $q = '?';
- }
- }
- return $this->pipe . ' ' . $this->getConditionPart($q);
- }
-
- /**
- * @return boolean
- */
- function show(){
- if(!isset($this->_show)){
- if(!$this->argument->isValid()) $this->_show = false;
- if($this->_value === '\'\'') $this->_show = false;
- if(!isset($this->_show)){
- return parent::show();
- }
- }
- return $this->_show;
+ function ConditionWithArgument($column_name, $argument, $operation, $pipe = "")
+ {
+ if($argument === null)
+ {
+ $this->_show = false;
+ return;
}
+ parent::Condition($column_name, $argument, $operation, $pipe);
+ $this->_value = $argument->getValue();
}
-?>
+ function getArgument()
+ {
+ if(!$this->show())
+ return;
+ return $this->argument;
+ }
+
+ /**
+ * change string without value
+ * @return string
+ */
+ function toStringWithoutValue()
+ {
+ $value = $this->argument->getUnescapedValue();
+
+ if(is_array($value))
+ {
+ $q = '';
+ foreach($value as $v)
+ {
+ $q .= '?,';
+ }
+ if($q !== '')
+ {
+ $q = substr($q, 0, -1);
+ }
+ $q = '(' . $q . ')';
+ }
+ else
+ {
+ // Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
+ if($this->argument->isColumnName())
+ {
+ $q = $value;
+ }
+ else
+ {
+ $q = '?';
+ }
+ }
+ return $this->pipe . ' ' . $this->getConditionPart($q);
+ }
+
+ /**
+ * @return boolean
+ */
+ function show()
+ {
+ if(!isset($this->_show))
+ {
+ if(!$this->argument->isValid())
+ {
+ $this->_show = false;
+ }
+ if($this->_value === '\'\'')
+ {
+ $this->_show = false;
+ }
+ if(!isset($this->_show))
+ {
+ return parent::show();
+ }
+ }
+ return $this->_show;
+ }
+
+}
+/* End of file ConditionWithArgument.class.php */
+/* Location: ./classes/db/queryparts/condition/ConditionWithArgument.class.php */
diff --git a/classes/db/queryparts/condition/ConditionWithoutArgument.class.php b/classes/db/queryparts/condition/ConditionWithoutArgument.class.php
index 688b3e2df..a028f5b67 100644
--- a/classes/db/queryparts/condition/ConditionWithoutArgument.class.php
+++ b/classes/db/queryparts/condition/ConditionWithoutArgument.class.php
@@ -1,29 +1,39 @@
1, 'notin'=>1, 'not_in'=>1);
- if(isset($tmpArray[$operation])){
- if(is_array($argument)) $argument = implode($argument, ',');
- $this->_value = '('. $argument .')';
- }
- else
- $this->_value = $argument;
+/**
+ * @author NHN (developers@xpressengine.com)
+ * @package /classes/db/queryparts/condition
+ * @version 0.1
+ */
+class ConditionWithoutArgument extends Condition
+{
+
+ /**
+ * constructor
+ * @param string $column_name
+ * @param mixed $argument
+ * @param string $operation
+ * @param string $pipe
+ * @return void
+ */
+ function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "")
+ {
+ parent::Condition($column_name, $argument, $operation, $pipe);
+ $tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
+ if(isset($tmpArray[$operation]))
+ {
+ if(is_array($argument))
+ {
+ $argument = implode($argument, ',');
+ }
+ $this->_value = '(' . $argument . ')';
+ }
+ else
+ {
+ $this->_value = $argument;
}
}
-?>
+}
+/* End of file ConditionWithoutArgument.class.php */
+/* Location: ./classes/db/queryparts/condition/ConditionWithoutArgument.class.php */
diff --git a/classes/db/queryparts/expression/ClickCountExpression.class.php b/classes/db/queryparts/expression/ClickCountExpression.class.php
index 36b123bc8..50f48da5f 100644
--- a/classes/db/queryparts/expression/ClickCountExpression.class.php
+++ b/classes/db/queryparts/expression/ClickCountExpression.class.php
@@ -1,53 +1,61 @@
-click_count = false;
- }
- $this->click_count = $click_count;
+ var $click_count;
+
+ /**
+ * constructor
+ * @param string $column_name
+ * @param string $alias
+ * @param bool $click_count
+ * @return void
+ */
+ function ClickCountExpression($column_name, $alias = NULL, $click_count = false)
+ {
+ parent::SelectExpression($column_name, $alias);
+
+ if(!is_bool($click_count))
+ {
+ // error_log("Click_count value for $column_name was not boolean", 0);
+ $this->click_count = false;
}
-
- function show() {
- return $this->click_count;
+ $this->click_count = $click_count;
+ }
+
+ function show()
+ {
+ return $this->click_count;
+ }
+
+ /**
+ * Return column expression, ex) column = column + 1
+ * @return string
+ */
+ function getExpression()
+ {
+ $db_type = Context::getDBType();
+ if($db_type == 'cubrid')
+ {
+ return "INCR($this->column_name)";
}
-
- /**
- * Return column expression, ex) column = column + 1
- * @return string
- */
- function getExpression(){
- $db_type = Context::getDBType();
- if($db_type == 'cubrid')
- {
- return "INCR($this->column_name)";
- }
- else
- {
- return "$this->column_name";
- }
+ else
+ {
+ return "$this->column_name";
}
}
-?>
+}
+/* End of file ClickCountExpression.class.php */
+/* Location: ./classes/db/queryparts/expression/ClickCountExpression.class.php */
diff --git a/classes/db/queryparts/expression/DeleteExpression.class.php b/classes/db/queryparts/expression/DeleteExpression.class.php
index d304b1e1e..c86a4d4fb 100644
--- a/classes/db/queryparts/expression/DeleteExpression.class.php
+++ b/classes/db/queryparts/expression/DeleteExpression.class.php
@@ -1,50 +1,62 @@
-value = $value;
- }
-
- /**
- * Return column expression, ex) column = value
- * @return string
- */
- function getExpression(){
- return "$this->column_name = $this->value";
- }
-
- function getValue(){
- // TODO Escape value according to column type instead of variable type
- if(!is_numeric($this->value)) return "'".$this->value."'";
- return $this->value;
- }
-
- function show(){
- if(!$this->value) return false;
- return true;
- }
+/**
+ * DeleteExpression
+ *
+ * @author Arnia Software
+ * @package /classes/db/queryparts/expression
+ * @version 0.1
+ * @todo Fix this class
+ */
+class DeleteExpression extends Expression
+{
+
+ /**
+ * column value
+ * @var mixed
+ */
+ var $value;
+
+ /**
+ * constructor
+ * @param string $column_name
+ * @param mixed $value
+ * @return void
+ */
+ function DeleteExpression($column_name, $value)
+ {
+ parent::Expression($column_name);
+ $this->value = $value;
}
+ /**
+ * Return column expression, ex) column = value
+ * @return string
+ */
+ function getExpression()
+ {
+ return "$this->column_name = $this->value";
+ }
-?>
+ function getValue()
+ {
+ // TODO Escape value according to column type instead of variable type
+ if(!is_numeric($this->value))
+ {
+ return "'" . $this->value . "'";
+ }
+ return $this->value;
+ }
+
+ function show()
+ {
+ if(!$this->value)
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
+/* End of file DeleteExpression.class.php */
+/* Location: ./classes/db/queryparts/expression/DeleteExpression.class.php */
diff --git a/classes/db/queryparts/expression/Expression.class.php b/classes/db/queryparts/expression/Expression.class.php
index 09868c9cf..463f107ed 100644
--- a/classes/db/queryparts/expression/Expression.class.php
+++ b/classes/db/queryparts/expression/Expression.class.php
@@ -1,44 +1,55 @@
column_name = $column_name;
- }
-
- function getColumnName(){
- return $this->column_name;
- }
-
- function show() {
- return false;
- }
-
- /**
- * Return column expression, ex) column as alias
- * @return string
- */
- function getExpression() {
- }
+ var $column_name;
+
+ /**
+ * constructor
+ * @param string $column_name
+ * @return void
+ */
+ function Expression($column_name)
+ {
+ $this->column_name = $column_name;
}
+
+ function getColumnName()
+ {
+ return $this->column_name;
+ }
+
+ function show()
+ {
+ return false;
+ }
+
+ /**
+ * Return column expression, ex) column as alias
+ * @return string
+ */
+ function getExpression()
+ {
+
+ }
+
+}
+/* End of file Expression.class.php */
+/* Location: ./classes/db/queryparts/expression/Expression.class.php */
diff --git a/classes/db/queryparts/expression/InsertExpression.class.php b/classes/db/queryparts/expression/InsertExpression.class.php
index 3cf8d81ee..efd0e58f8 100644
--- a/classes/db/queryparts/expression/InsertExpression.class.php
+++ b/classes/db/queryparts/expression/InsertExpression.class.php
@@ -1,53 +1,73 @@
argument = $argument;
- }
+ /**
+ * constructor
+ * @param string $column_name
+ * @param object $argument
+ * @return void
+ */
+ function InsertExpression($column_name, $argument)
+ {
+ parent::Expression($column_name);
+ $this->argument = $argument;
+ }
- function getValue($with_values = true){
- if($with_values)
- return $this->argument->getValue();
- return '?';
- }
-
- function show(){
- if(!$this->argument) return false;
- $value = $this->argument->getValue();
- if(!isset($value)) return false;
- return true;
- }
-
- function getArgument(){
- return $this->argument;
- }
-
- function getArguments()
+ function getValue($with_values = true)
+ {
+ if($with_values)
{
- if ($this->argument)
- return array($this->argument);
- else
- return array();
+ return $this->argument->getValue();
+ }
+ return '?';
+ }
+
+ function show()
+ {
+ if(!$this->argument)
+ {
+ return false;
+ }
+ $value = $this->argument->getValue();
+ if(!isset($value))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ function getArgument()
+ {
+ return $this->argument;
+ }
+
+ function getArguments()
+ {
+ if($this->argument)
+ {
+ return array($this->argument);
+ }
+ else
+ {
+ return array();
}
}
-?>
+}
+/* End of file InsertExpression.class.php */
+/* Location: ./classes/db/queryparts/expression/InsertExpression.class.php */
diff --git a/classes/db/queryparts/expression/SelectExpression.class.php b/classes/db/queryparts/expression/SelectExpression.class.php
index ea3a5d22b..6ae36d52b 100644
--- a/classes/db/queryparts/expression/SelectExpression.class.php
+++ b/classes/db/queryparts/expression/SelectExpression.class.php
@@ -1,59 +1,69 @@
column_alias = $alias;
- }
-
- /**
- * Return column expression, ex) column as alias
- * @return string
- */
- function getExpression() {
- return sprintf("%s%s", $this->column_name, $this->column_alias ? " as ".$this->column_alias : "");
- }
-
- function show() {
- return true;
- }
-
- function getArgument(){
- return null;
- }
-
- function getArguments()
- {
- return array();
- }
-
- function isSubquery(){
- return false;
- }
+ /**
+ * constructor
+ * @param string $column_name
+ * @param string $alias
+ * @return void
+ */
+ function SelectExpression($column_name, $alias = NULL)
+ {
+ parent::Expression($column_name);
+ $this->column_alias = $alias;
}
-?>
+
+ /**
+ * Return column expression, ex) column as alias
+ * @return string
+ */
+ function getExpression()
+ {
+ return sprintf("%s%s", $this->column_name, $this->column_alias ? " as " . $this->column_alias : "");
+ }
+
+ function show()
+ {
+ return true;
+ }
+
+ function getArgument()
+ {
+ return null;
+ }
+
+ function getArguments()
+ {
+ return array();
+ }
+
+ function isSubquery()
+ {
+ return false;
+ }
+
+}
+/* End of file SelectExpression.class.php */
+/* Location: ./classes/db/queryparts/expression/SelectExpression.class.php */
diff --git a/classes/db/queryparts/expression/StarExpression.class.php b/classes/db/queryparts/expression/StarExpression.class.php
index 38a877322..f010c8593 100644
--- a/classes/db/queryparts/expression/StarExpression.class.php
+++ b/classes/db/queryparts/expression/StarExpression.class.php
@@ -1,28 +1,36 @@
-
+
+ function getArgument()
+ {
+ return null;
+ }
+
+ function getArguments()
+ {
+ // StarExpression has no arguments
+ return array();
+ }
+
+}
+/* End of file StarExpression.class.php */
+/* Location: ./classes/db/queryparts/expression/StarExpression.class.php */
diff --git a/classes/db/queryparts/expression/UpdateExpression.class.php b/classes/db/queryparts/expression/UpdateExpression.class.php
index 0f0324bc4..a942a9f9c 100644
--- a/classes/db/queryparts/expression/UpdateExpression.class.php
+++ b/classes/db/queryparts/expression/UpdateExpression.class.php
@@ -1,89 +1,118 @@
argument = $argument;
- }
+ /**
+ * constructor
+ * @param string $column_name
+ * @param object $argument
+ * @return void
+ */
+ function UpdateExpression($column_name, $argument)
+ {
+ parent::Expression($column_name);
+ $this->argument = $argument;
+ }
- /**
- * Return column expression, ex) column = value
- * @return string
- */
- function getExpression($with_value = true){
- if($with_value)
- return $this->getExpressionWithValue();
- return $this->getExpressionWithoutValue();
- }
-
- /**
- * Return column expression, ex) column = value
- * @return string
- */
- function getExpressionWithValue(){
- $value = $this->argument->getValue();
- $operation = $this->argument->getColumnOperation();
- if(isset($operation))
- return "$this->column_name = $this->column_name $operation $value";
- return "$this->column_name = $value";
- }
-
- /**
- * Return column expression, ex) column = ?
- * Can use prepare statement
- * @return string
- */
- function getExpressionWithoutValue(){
- $operation = $this->argument->getColumnOperation();
- if(isset($operation))
- return "$this->column_name = $this->column_name $operation ?";
- return "$this->column_name = ?";
- }
-
- function getValue(){
- // TODO Escape value according to column type instead of variable type
- $value = $this->argument->getValue();
- if(!is_numeric($value)) return "'".$value."'";
- return $value;
- }
-
- function show(){
- if(!$this->argument) return false;
- $value = $this->argument->getValue();
- if(!isset($value)) return false;
- return true;
- }
-
- function getArgument(){
- return $this->argument;
- }
-
- function getArguments()
+ /**
+ * Return column expression, ex) column = value
+ * @return string
+ */
+ function getExpression($with_value = true)
+ {
+ if($with_value)
+ {
+ return $this->getExpressionWithValue();
+ }
+ return $this->getExpressionWithoutValue();
+ }
+
+ /**
+ * Return column expression, ex) column = value
+ * @return string
+ */
+ function getExpressionWithValue()
+ {
+ $value = $this->argument->getValue();
+ $operation = $this->argument->getColumnOperation();
+ if(isset($operation))
+ {
+ return "$this->column_name = $this->column_name $operation $value";
+ }
+ return "$this->column_name = $value";
+ }
+
+ /**
+ * Return column expression, ex) column = ?
+ * Can use prepare statement
+ * @return string
+ */
+ function getExpressionWithoutValue()
+ {
+ $operation = $this->argument->getColumnOperation();
+ if(isset($operation))
+ {
+ return "$this->column_name = $this->column_name $operation ?";
+ }
+ return "$this->column_name = ?";
+ }
+
+ function getValue()
+ {
+ // TODO Escape value according to column type instead of variable type
+ $value = $this->argument->getValue();
+ if(!is_numeric($value))
+ {
+ return "'" . $value . "'";
+ }
+ return $value;
+ }
+
+ function show()
+ {
+ if(!$this->argument)
+ {
+ return false;
+ }
+ $value = $this->argument->getValue();
+ if(!isset($value))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ function getArgument()
+ {
+ return $this->argument;
+ }
+
+ function getArguments()
+ {
+ if($this->argument)
{
- if ($this->argument)
return array($this->argument);
- else
+ }
+ else
+ {
return array();
}
}
-
-?>
+}
+/* End of file UpdateExpression.class.php */
+/* Location: ./classes/db/queryparts/expression/UpdateExpression.class.php */
diff --git a/classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php b/classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php
index a8cd44495..38123f221 100644
--- a/classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php
+++ b/classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php
@@ -1,55 +1,73 @@
argument = $argument;
- }
-
- function getExpression($with_value = true){
- return "$this->column_name = $this->argument";
- }
-
- function getValue(){
- // TODO Escape value according to column type instead of variable type
- $value = $this->argument;
- if(!is_numeric($value)) return "'".$value."'";
- return $value;
- }
-
- function show(){
- if(!$this->argument) return false;
- $value = $this->argument;
- if(!isset($value)) return false;
- return true;
- }
-
- function getArgument(){
- return null;
- }
-
- function getArguments(){
- return array();
- }
+ /**
+ * constructor
+ * @param string $column_name
+ * @param object $argument
+ * @return void
+ */
+ function UpdateExpressionWithoutArgument($column_name, $argument)
+ {
+ parent::Expression($column_name);
+ $this->argument = $argument;
}
+ function getExpression($with_value = true)
+ {
+ return "$this->column_name = $this->argument";
+ }
-?>
+ function getValue()
+ {
+ // TODO Escape value according to column type instead of variable type
+ $value = $this->argument;
+ if(!is_numeric($value))
+ {
+ return "'" . $value . "'";
+ }
+ return $value;
+ }
+
+ function show()
+ {
+ if(!$this->argument)
+ {
+ return false;
+ }
+ $value = $this->argument;
+ if(!isset($value))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ function getArgument()
+ {
+ return null;
+ }
+
+ function getArguments()
+ {
+ return array();
+ }
+
+}
+/* End of file UpdateExpressionWithoutArgument.class.php */
+/* Location: ./classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php */
diff --git a/classes/db/queryparts/limit/Limit.class.php b/classes/db/queryparts/limit/Limit.class.php
index 256c42eb1..bce192d08 100644
--- a/classes/db/queryparts/limit/Limit.class.php
+++ b/classes/db/queryparts/limit/Limit.class.php
@@ -1,69 +1,95 @@
-list_count = $list_count;
- if ($page){
- $list_count_value = $list_count->getValue();
- $page_value = $page->getValue();
- $this->start = ($page_value - 1) * $list_count_value;
- $this->page_count = $page_count;
- $this->page = $page;
- }
- }
-
- /**
- * In case you choose to use query limit in other cases than page select
- * @return boolean
- */
- function isPageHandler(){
- if ($this->page)return true;
- else return false;
- }
-
- function getOffset(){
- return $this->start;
- }
-
- function getLimit(){
- return $this->list_count->getValue();
- }
-
- function toString(){
- if ($this->page) return $this->start . ' , ' . $this->list_count->getValue();
- else return $this->list_count->getValue();
+/**
+ * @author NHN (developers@xpressengine.com)
+ * @package /classes/db/queryparts/limit
+ * @version 0.1
+ */
+class Limit
+{
+
+ /**
+ * start number
+ * @var int
+ */
+ var $start;
+
+ /**
+ * list count
+ * @var int
+ */
+ var $list_count;
+
+ /**
+ * page count
+ * @var int
+ */
+ var $page_count;
+
+ /**
+ * current page
+ * @var int
+ */
+ var $page;
+
+ /**
+ * constructor
+ * @param int $list_count
+ * @param int $page
+ * @param int $page_count
+ * @return void
+ */
+ function Limit($list_count, $page = NULL, $page_count = NULL)
+ {
+ $this->list_count = $list_count;
+ if($page)
+ {
+ $list_count_value = $list_count->getValue();
+ $page_value = $page->getValue();
+ $this->start = ($page_value - 1) * $list_count_value;
+ $this->page_count = $page_count;
+ $this->page = $page;
}
}
-?>
+
+ /**
+ * In case you choose to use query limit in other cases than page select
+ * @return boolean
+ */
+ function isPageHandler()
+ {
+ if($this->page)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function getOffset()
+ {
+ return $this->start;
+ }
+
+ function getLimit()
+ {
+ return $this->list_count->getValue();
+ }
+
+ function toString()
+ {
+ if($this->page)
+ {
+ return $this->start . ' , ' . $this->list_count->getValue();
+ }
+ else
+ {
+ return $this->list_count->getValue();
+ }
+ }
+
+}
+/* End of file Limit.class.php */
+/* Location: ./classes/db/limit/Limit.class.php */
diff --git a/classes/db/queryparts/order/OrderByColumn.class.php b/classes/db/queryparts/order/OrderByColumn.class.php
index 3dfa8f949..bdfafd562 100644
--- a/classes/db/queryparts/order/OrderByColumn.class.php
+++ b/classes/db/queryparts/order/OrderByColumn.class.php
@@ -1,50 +1,73 @@
-column_name = $column_name;
- $this->sort_order = $sort_order;
+ var $column_name;
+
+ /**
+ * sort order
+ * @var string
+ */
+ var $sort_order;
+
+ /**
+ * constructor
+ * @param string $column_name
+ * @param string $sort_order
+ * @return void
+ */
+ function OrderByColumn($column_name, $sort_order)
+ {
+ $this->column_name = $column_name;
+ $this->sort_order = $sort_order;
+ }
+
+ function toString()
+ {
+ $result = $this->getColumnName();
+ $result .= ' ';
+ $result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
+ return $result;
+ }
+
+ function getColumnName()
+ {
+ return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
+ }
+
+ function getPureColumnName()
+ {
+ return is_a($this->column_name, 'Argument') ? $this->column_name->getPureValue() : $this->column_name;
+ }
+
+ function getPureSortOrder()
+ {
+ return is_a($this->sort_order, 'Argument') ? $this->sort_order->getPureValue() : $this->sort_order;
+ }
+
+ function getArguments()
+ {
+ $args = array();
+ if(is_a($this->column_name, 'Argument'))
+ {
+ $args[] = $this->column_name;
}
-
- function toString(){
- $result = $this->getColumnName();
- $result .= ' ';
- $result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
- return $result;
- }
-
- function getColumnName(){
- return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
- }
-
- function getArguments(){
- $args = array();
- if(is_a($this->column_name, 'Argument'))
- $args[]= $this->column_name;
- if(is_a($this->sort_order, 'Argument'))
- $args[] = $this->sort_order;
+ if(is_a($this->sort_order, 'Argument'))
+ {
+ $args[] = $this->sort_order;
}
}
-?>
+}
+/* End of file OrderByColumn.class.php */
+/* Location: ./classes/db/order/OrderByColumn.class.php */
diff --git a/classes/db/queryparts/table/CubridTableWithHint.class.php b/classes/db/queryparts/table/CubridTableWithHint.class.php
index 79d645234..d807891a5 100644
--- a/classes/db/queryparts/table/CubridTableWithHint.class.php
+++ b/classes/db/queryparts/table/CubridTableWithHint.class.php
@@ -1,62 +1,71 @@
index_hints_list = $index_hints_list;
- }
+ /**
+ * table alias
+ * @var string
+ */
+ var $alias;
- /**
- * Return index hint string
- * @return string
- */
- function getIndexHintString(){
- $result = '';
+ /**
+ * index hint list
+ * @var array
+ */
+ var $index_hints_list;
- // Retrieve table prefix, to add it to index name
- $db_info = Context::getDBInfo();
- $prefix = $db_info->master_db["db_table_prefix"];
-
- foreach($this->index_hints_list as $index_hint){
- $index_hint_type = $index_hint->getIndexHintType();
- if($index_hint_type !== 'IGNORE'){
- $result .= $this->alias . '.'
- . '"' . $prefix . substr($index_hint->getIndexName(), 1)
- . ($index_hint_type == 'FORCE' ? '(+)' : '')
- . ', ';
- }
-
- }
- $result = substr($result, 0, -2);
- return $result;
- }
+ /**
+ * constructor
+ * @param string $name
+ * @param string $alias
+ * @param array $index_hints_list
+ * @return void
+ */
+ function CubridTableWithHint($name, $alias = NULL, $index_hints_list)
+ {
+ parent::Table($name, $alias);
+ $this->index_hints_list = $index_hints_list;
}
-?>
+ /**
+ * Return index hint string
+ * @return string
+ */
+ function getIndexHintString()
+ {
+ $result = '';
+
+ // Retrieve table prefix, to add it to index name
+ $db_info = Context::getDBInfo();
+ $prefix = $db_info->master_db["db_table_prefix"];
+
+ foreach($this->index_hints_list as $index_hint)
+ {
+ $index_hint_type = $index_hint->getIndexHintType();
+ if($index_hint_type !== 'IGNORE')
+ {
+ $result .= $this->alias . '.'
+ . '"' . $prefix . substr($index_hint->getIndexName(), 1)
+ . ($index_hint_type == 'FORCE' ? '(+)' : '')
+ . ', ';
+ }
+ }
+ $result = substr($result, 0, -2);
+ return $result;
+ }
+
+}
+/* End of file CubridTableWithHint.class.php */
+/* Location: ./classes/db/queryparts/table/CubridTableWithHint.class.php */
diff --git a/classes/db/queryparts/table/IndexHint.class.php b/classes/db/queryparts/table/IndexHint.class.php
index 20e41f009..1772c7cda 100644
--- a/classes/db/queryparts/table/IndexHint.class.php
+++ b/classes/db/queryparts/table/IndexHint.class.php
@@ -1,39 +1,47 @@
index_name = $index_name;
- $this->index_hint_type = $index_hint_type;
- }
+ /**
+ * index hint type, ex) IGNORE, FORCE, USE...
+ * @var string
+ */
+ var $index_hint_type;
- function getIndexName(){
- return $this->index_name;
- }
-
- function getIndexHintType() {
- return $this->index_hint_type;
- }
+ /**
+ * constructor
+ * @param string $index_name
+ * @param string $index_hint_type
+ * @return void
+ */
+ function IndexHint($index_name, $index_hint_type)
+ {
+ $this->index_name = $index_name;
+ $this->index_hint_type = $index_hint_type;
}
-?>
+ function getIndexName()
+ {
+ return $this->index_name;
+ }
+
+ function getIndexHintType()
+ {
+ return $this->index_hint_type;
+ }
+
+}
+/* End of file IndexHint.class.php */
+/* Location: ./classes/db/queryparts/table/IndexHint.class.php */
diff --git a/classes/db/queryparts/table/JoinTable.class.php b/classes/db/queryparts/table/JoinTable.class.php
index 16818792f..da5f951ca 100644
--- a/classes/db/queryparts/table/JoinTable.class.php
+++ b/classes/db/queryparts/table/JoinTable.class.php
@@ -1,59 +1,70 @@
-join_type = $join_type;
- $this->conditions = $conditions;
- }
-
- function toString($with_value = true){
- $part = $this->join_type . ' ' . $this->name ;
- $part .= $this->alias ? ' as ' . $this->alias : '';
- $part .= ' on ';
- foreach($this->conditions as $conditionGroup)
- $part .= $conditionGroup->toString($with_value);
- return $part;
- }
-
- function isJoinTable(){
- return true;
- }
-
- function getArguments()
- {
- $args = array();
- foreach($this->conditions as $conditionGroup)
- $args = array_merge($args, $conditionGroup->getArguments());
- return $args;
- }
-
+ var $join_type;
+
+ /**
+ * condition list
+ * @var array
+ */
+ var $conditions;
+
+ /**
+ * constructor
+ * @param string $name
+ * @param string $alias
+ * @param string $join_type
+ * @param array $conditions
+ * @return void
+ */
+ function JoinTable($name, $alias, $join_type, $conditions)
+ {
+ parent::Table($name, $alias);
+ $this->join_type = $join_type;
+ $this->conditions = $conditions;
}
-?>
+ function toString($with_value = true)
+ {
+ $part = $this->join_type . ' ' . $this->name;
+ $part .= $this->alias ? ' as ' . $this->alias : '';
+ $part .= ' on ';
+ foreach($this->conditions as $conditionGroup)
+ {
+ $part .= $conditionGroup->toString($with_value);
+ }
+ return $part;
+ }
+
+ function isJoinTable()
+ {
+ return true;
+ }
+
+ function getArguments()
+ {
+ $args = array();
+ foreach($this->conditions as $conditionGroup)
+ {
+ $args = array_merge($args, $conditionGroup->getArguments());
+ }
+ return $args;
+ }
+
+}
+/* End of file JoinTable.class.php */
+/* Location: ./classes/db/queryparts/table/JoinTable.class.php */
diff --git a/classes/db/queryparts/table/MssqlTableWithHint.class.php b/classes/db/queryparts/table/MssqlTableWithHint.class.php
index 077456133..f33ba136f 100644
--- a/classes/db/queryparts/table/MssqlTableWithHint.class.php
+++ b/classes/db/queryparts/table/MssqlTableWithHint.class.php
@@ -1,53 +1,65 @@
index_hints_list = $index_hints_list;
- }
+ /**
+ * table alias
+ * @var string
+ */
+ var $alias;
- function toString(){
- $result = parent::toString();
+ /**
+ * index hint type, ex) IGNORE, FORCE, USE...
+ * @var array
+ */
+ var $index_hints_list;
- $index_hint_string = '';
- $indexTypeList = array('USE'=>1, 'FORCE'=>1);
- foreach($this->index_hints_list as $index_hint){
- $index_hint_type = $index_hint->getIndexHintType();
- if(isset($indexTypeList[$index_hint_type]))
- $index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
- }
- if($index_hint_string != ''){
- $result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
- }
- return $result;
- }
+ /**
+ * constructor
+ * @param string $name
+ * @param string $alias
+ * @param string $index_hints_list
+ * @return void
+ */
+ function MssqlTableWithHint($name, $alias = NULL, $index_hints_list)
+ {
+ parent::Table($name, $alias);
+ $this->index_hints_list = $index_hints_list;
}
-?>
+ function toString()
+ {
+ $result = parent::toString();
+
+ $index_hint_string = '';
+ $indexTypeList = array('USE' => 1, 'FORCE' => 1);
+ foreach($this->index_hints_list as $index_hint)
+ {
+ $index_hint_type = $index_hint->getIndexHintType();
+ if(isset($indexTypeList[$index_hint_type]))
+ {
+ $index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
+ }
+ }
+ if($index_hint_string != '')
+ {
+ $result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
+ }
+ return $result;
+ }
+
+}
+/* End of file MssqlTableWithHint.class.php */
+/* Location: ./classes/db/queryparts/table/MssqlTableWithHint.class.php */
diff --git a/classes/db/queryparts/table/MysqlTableWithHint.class.php b/classes/db/queryparts/table/MysqlTableWithHint.class.php
index 39c8c32b7..24ff7c51a 100644
--- a/classes/db/queryparts/table/MysqlTableWithHint.class.php
+++ b/classes/db/queryparts/table/MysqlTableWithHint.class.php
@@ -1,59 +1,82 @@
index_hints_list = $index_hints_list;
- }
+ /**
+ * table alias
+ * @var string
+ */
+ var $alias;
- function toString(){
- $result = parent::toString();
+ /**
+ * index hint type, ex) IGNORE, FORCE, USE...
+ * @var array
+ */
+ var $index_hints_list;
- $use_index_hint = ''; $force_index_hint = ''; $ignore_index_hint = '';
- foreach($this->index_hints_list as $index_hint){
- $index_hint_type = $index_hint->getIndexHintType();
- if($index_hint_type == 'USE') $use_index_hint .= $index_hint->getIndexName() . ', ';
- else if($index_hint_type == 'FORCE') $force_index_hint .= $index_hint->getIndexName() . ', ';
- else if($index_hint_type == 'IGNORE') $ignore_index_hint .= $index_hint->getIndexName() . ', ';
- }
- if($use_index_hint != ''){
- $result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
- }
- if($force_index_hint != ''){
- $result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
- }
- if($ignore_index_hint != ''){
- $result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
- }
- return $result;
- }
+ /**
+ * constructor
+ * @param string $name
+ * @param string $alias
+ * @param string $index_hints_list
+ * @return void
+ */
+ function MysqlTableWithHint($name, $alias = NULL, $index_hints_list)
+ {
+ parent::Table($name, $alias);
+ $this->index_hints_list = $index_hints_list;
}
-?>
+ function toString()
+ {
+ $result = parent::toString();
+
+ $use_index_hint = '';
+ $force_index_hint = '';
+ $ignore_index_hint = '';
+ foreach($this->index_hints_list as $index_hint)
+ {
+ $index_hint_type = $index_hint->getIndexHintType();
+ if($index_hint_type == 'USE')
+ {
+ $use_index_hint .= $index_hint->getIndexName() . ', ';
+ }
+ else if($index_hint_type == 'FORCE')
+ {
+ $force_index_hint .= $index_hint->getIndexName() . ', ';
+ }
+ else if($index_hint_type == 'IGNORE')
+ {
+ $ignore_index_hint .= $index_hint->getIndexName() . ', ';
+ }
+ }
+ if($use_index_hint != '')
+ {
+ $result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
+ }
+ if($force_index_hint != '')
+ {
+ $result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
+ }
+ if($ignore_index_hint != '')
+ {
+ $result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
+ }
+ return $result;
+ }
+
+}
+/* End of file MysqlTableWithHint.class.php */
+/* Location: ./classes/db/queryparts/table/MysqlTableWithHint.class.php */
diff --git a/classes/db/queryparts/table/Table.class.php b/classes/db/queryparts/table/Table.class.php
index 6092e10c7..05a3e084f 100644
--- a/classes/db/queryparts/table/Table.class.php
+++ b/classes/db/queryparts/table/Table.class.php
@@ -1,48 +1,58 @@
-name = $name;
- $this->alias = $alias;
- }
-
- function toString(){
- //return $this->name;
- return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : '');
- }
-
- function getName(){
- return $this->name;
- }
-
- function getAlias(){
- return $this->alias;
- }
-
- function isJoinTable(){
- return false;
- }
+ var $name;
+
+ /**
+ * table alias
+ * @var string
+ */
+ var $alias;
+
+ /**
+ * constructor
+ * @param string $name
+ * @param string $alias
+ * @return void
+ */
+ function Table($name, $alias = NULL)
+ {
+ $this->name = $name;
+ $this->alias = $alias;
}
-?>
+ function toString()
+ {
+ //return $this->name;
+ return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : '');
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+
+ function getAlias()
+ {
+ return $this->alias;
+ }
+
+ function isJoinTable()
+ {
+ return false;
+ }
+
+}
+/* End of file Table.class.php */
+/* Location: ./classes/db/queryparts/table/Table.class.php */
diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php
index d20acdfd6..7ace35e0c 100644
--- a/classes/display/DisplayHandler.class.php
+++ b/classes/display/DisplayHandler.class.php
@@ -1,276 +1,364 @@
gzhandler_enable
- ) $this->gz_enabled = true;
- // Extract contents to display by the request method
- if(Context::get('xeVirtualRequestMethod')=='xml') {
- require_once("./classes/display/VirtualXMLDisplayHandler.php");
- $handler = new VirtualXMLDisplayHandler();
- }
- else if(Context::getRequestMethod() == 'XMLRPC') {
- require_once("./classes/display/XMLDisplayHandler.php");
- $handler = new XMLDisplayHandler();
- if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
- }
- else if(Context::getRequestMethod() == 'JSON') {
- require_once("./classes/display/JSONDisplayHandler.php");
- $handler = new JSONDisplayHandler();
- }
- else {
- require_once("./classes/display/HTMLDisplayHandler.php");
- $handler = new HTMLDisplayHandler();
- }
+ )
+ {
+ $this->gz_enabled = TRUE;
+ }
- $output = $handler->toDoc($oModule);
- // call a trigger before display
- ModuleHandler::triggerCall('display', 'before', $output);
- // execute add-on
- $called_position = 'before_display_content';
- $oAddonController = &getController('addon');
- $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
- @include($addon_file);
+ // Extract contents to display by the request method
+ if(Context::get('xeVirtualRequestMethod') == 'xml')
+ {
+ require_once("./classes/display/VirtualXMLDisplayHandler.php");
+ $handler = new VirtualXMLDisplayHandler();
+ }
+ else if(Context::getRequestMethod() == 'XMLRPC')
+ {
+ require_once("./classes/display/XMLDisplayHandler.php");
+ $handler = new XMLDisplayHandler();
+ if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
+ {
+ $this->gz_enabled = FALSE;
+ }
+ }
+ else if(Context::getRequestMethod() == 'JSON')
+ {
+ require_once("./classes/display/JSONDisplayHandler.php");
+ $handler = new JSONDisplayHandler();
+ }
+ else if(Context::getRequestMethod() == 'JS_CALLBACK')
+ {
+ require_once("./classes/display/JSCallbackDisplayHandler.php");
+ $handler = new JSCallbackDisplayHandler();
+ }
+ else
+ {
+ require_once("./classes/display/HTMLDisplayHandler.php");
+ $handler = new HTMLDisplayHandler();
+ }
- if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
- // header output
- if($this->gz_enabled) header("Content-Encoding: gzip");
+ $output = $handler->toDoc($oModule);
- $httpStatusCode = $oModule->getHttpStatusCode();
- if($httpStatusCode && $httpStatusCode != 200) $this->_printHttpStatusCode($httpStatusCode);
+ // call a trigger before display
+ ModuleHandler::triggerCall('display', 'before', $output);
+
+ // execute add-on
+ $called_position = 'before_display_content';
+ $oAddonController = &getController('addon');
+ $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
+ @include($addon_file);
+
+ if(method_exists($handler, "prepareToPrint"))
+ {
+ $handler->prepareToPrint($output);
+ }
+ // header output
+ if($this->gz_enabled)
+ {
+ header("Content-Encoding: gzip");
+ }
+
+ $httpStatusCode = $oModule->getHttpStatusCode();
+ if($httpStatusCode && $httpStatusCode != 200)
+ {
+ $this->_printHttpStatusCode($httpStatusCode);
+ }
+ else
+ {
+ if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK')
+ {
+ $this->_printJSONHeader();
+ }
+ else if(Context::getResponseMethod() != 'HTML')
+ {
+ $this->_printXMLHeader();
+ }
else
{
- if(Context::getResponseMethod() == 'JSON') $this->_printJSONHeader();
- else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
- else $this->_printHTMLHeader();
+ $this->_printHTMLHeader();
+ }
+ }
+
+ // debugOutput output
+ $this->content_size = strlen($output);
+ $output .= $this->_debugOutput();
+
+ // results directly output
+ if($this->gz_enabled)
+ {
+ print ob_gzhandler($output, 5);
+ }
+ else
+ {
+ print $output;
+ }
+
+ // call a trigger after display
+ ModuleHandler::triggerCall('display', 'after', $content);
+ }
+
+ /**
+ * Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
+ * This method only functions when __DEBUG__ variable is set to 1.
+ * __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
+ * @return void
+ */
+ function _debugOutput()
+ {
+ if(!__DEBUG__)
+ {
+ return;
+ }
+
+ $end = getMicroTime();
+
+ // Firebug console output
+ if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
+ {
+ static $firephp;
+ if(!isset($firephp))
+ {
+ $firephp = FirePHP::getInstance(true);
}
- // debugOutput output
- $this->content_size = strlen($output);
- $output .= $this->_debugOutput();
- // results directly output
- if($this->gz_enabled) print ob_gzhandler($output, 5);
- else print $output;
- // call a trigger after display
- ModuleHandler::triggerCall('display', 'after', $content);
- }
+ if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
+ {
+ $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
+ return;
+ }
+ // display total execution time and Request/Response info
+ if(__DEBUG__ & 2)
+ {
+ $firephp->fb(
+ array(
+ 'Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(),
+ array(
+ array('Request URI', 'Request method', 'Response method', 'Response contents size'),
+ array(
+ sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']),
+ $_SERVER['REQUEST_METHOD'],
+ Context::getResponseMethod(),
+ $this->content_size . ' byte'
+ )
+ )
+ ),
+ 'TABLE'
+ );
+ $firephp->fb(
+ array(
+ 'Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__),
+ array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'),
+ array(
+ sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
+ sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']),
+ sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
+ sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']),
+ sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']),
+ sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']),
+ sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
+ )
+ )
+ ),
+ 'TABLE'
+ );
+ }
-
- /**
- * Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
- * This method only functions when __DEBUG__ variable is set to 1.
- * __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
- * @return void
- **/
- function _debugOutput() {
- if(!__DEBUG__) return;
-
- $end = getMicroTime();
- // Firebug console output
- if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) {
- static $firephp;
- if(!isset($firephp)) $firephp = FirePHP::getInstance(true);
-
- if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
- $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
- return;
- }
- // display total execution time and Request/Response info
- if(__DEBUG__ & 2) {
- $firephp->fb(
- array('Request / Response info >>> '.$_SERVER['REQUEST_METHOD'].' / '.Context::getResponseMethod(),
- array(
- array('Request URI', 'Request method', 'Response method', 'Response contents size'),
- array(
- sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']),
- $_SERVER['REQUEST_METHOD'],
- Context::getResponseMethod(),
- $this->content_size.' byte'
- )
- )
- ),
- 'TABLE'
- );
- $firephp->fb(
- array('Elapsed time >>> Total : '.sprintf('%0.5f sec', $end - __StartTime__),
- array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'),
- array(
- sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
- sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']),
- sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
- sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']),
- sprintf('%0.5f sec', $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']),
- sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']),
- sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
- )
- )
- ),
- 'TABLE'
- );
- }
- // display DB query history
- if((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) {
- $queries_output = array(array('Query', 'Elapsed time', 'Result'));
- foreach($GLOBALS['__db_queries__'] as $query) {
- array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
- }
- $firephp->fb(
- array(
- 'DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
- $queries_output
- ),
- 'TABLE'
- );
- }
- // dislpay the file and HTML comments
- } else {
- // display total execution time and Request/Response info
- if(__DEBUG__ & 2) {
- if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
- return;
- }
- // Request/Response information
- $buff .= "\n- Request/ Response info\n";
- $buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']);
- $buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
- $buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
- $buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
- // total execution time
- $buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end-__StartTime__);
-
- $buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
- $buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
- $buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
- $buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
- $buff .= sprintf("\tDB class elapsed time \t\t: %0.5f sec\n", $GLOBALS['__dbclass_elapsed_time__'] -$GLOBALS['__db_elapsed_time__']);
- // widget execution time
- $buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
- // layout execution time
- $buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
- // Widgets, the editor component replacement time
- $buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
- }
- // DB Logging
- if(__DEBUG__ & 4) {
- if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
- return;
- }
-
- if($GLOBALS['__db_queries__']) {
- $buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
- $num = 0;
-
- foreach($GLOBALS['__db_queries__'] as $query) {
- $buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
- if($query['result'] == 'Success') {
- $buff .= "Query Success\n";
- } else {
- $buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
- }
- $buff .= sprintf("\t\tConnection: %s\n", $query['connection']);
- }
- }
- }
- // Output in HTML comments
- if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
- $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
-
- if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
- $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
- }
-
- return "";
- }
- // Output to a file
- if($buff && __DEBUG_OUTPUT__ == 0) {
- $debug_file = _XE_PATH_.'files/_debug_message.php';
- $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
-
- $buff = str_repeat('=', 40)."\n".$buff.str_repeat('-', 40);
- $buff = "\n\n";
-
- if(@!$fp = fopen($debug_file, 'a')) return;
- fwrite($fp, $buff);
- fclose($fp);
- }
- }
- }
-
- /**
- * print a HTTP HEADER for XML, which is encoded in UTF-8
- * @return void
- **/
- function _printXMLHeader() {
- header("Content-Type: text/xml; charset=UTF-8");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
+ // display DB query history
+ if((__DEBUG__ & 4) && $GLOBALS['__db_queries__'])
+ {
+ $queries_output = array(array('Query', 'Elapsed time', 'Result'));
+ foreach($GLOBALS['__db_queries__'] as $query)
+ {
+ array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
+ }
+ $firephp->fb(
+ array(
+ 'DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
+ $queries_output
+ ),
+ 'TABLE'
+ );
+ }
+ // dislpay the file and HTML comments
}
+ else
+ {
+ // display total execution time and Request/Response info
+ if(__DEBUG__ & 2)
+ {
+ if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
+ {
+ return;
+ }
+ // Request/Response information
+ $buff .= "\n- Request/ Response info\n";
+ $buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']);
+ $buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
+ $buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
+ $buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
- /**
- * print a HTTP HEADER for HTML, which is encoded in UTF-8
- * @return void
- **/
- function _printHTMLHeader() {
- header("Content-Type: text/html; charset=UTF-8");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
+ // total execution time
+ $buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end - __StartTime__);
+
+ $buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
+ $buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
+ $buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
+ $buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']);
+ $buff .= sprintf("\tDB class elapsed time \t\t: %0.5f sec\n", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']);
+
+ // widget execution time
+ $buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
+
+ // layout execution time
+ $buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
+
+ // Widgets, the editor component replacement time
+ $buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
+ }
+ // DB Logging
+ if(__DEBUG__ & 4)
+ {
+ if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
+ {
+ return;
+ }
+
+ if($GLOBALS['__db_queries__'])
+ {
+ $buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
+ $num = 0;
+
+ foreach($GLOBALS['__db_queries__'] as $query)
+ {
+ $buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
+ if($query['result'] == 'Success')
+ {
+ $buff .= "Query Success\n";
+ }
+ else
+ {
+ $buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
+ }
+ $buff .= sprintf("\t\tConnection: %s\n", $query['connection']);
+ }
+ }
+ }
+
+ // Output in HTML comments
+ if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML')
+ {
+ $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
+
+ if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
+ {
+ $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
+ }
+
+ return "";
+ }
+
+ // Output to a file
+ if($buff && __DEBUG_OUTPUT__ == 0)
+ {
+ $debug_file = _XE_PATH_ . 'files/_debug_message.php';
+ $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
+
+ $buff = str_repeat('=', 40) . "\n" . $buff . str_repeat('-', 40);
+ $buff = "\n\n";
+
+ if(@!$fp = fopen($debug_file, 'a'))
+ {
+ return;
+ }
+
+ fwrite($fp, $buff);
+ fclose($fp);
+ }
}
+ }
+ /**
+ * print a HTTP HEADER for XML, which is encoded in UTF-8
+ * @return void
+ */
+ function _printXMLHeader()
+ {
+ header("Content-Type: text/xml; charset=UTF-8");
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Cache-Control: post-check=0, pre-check=0", false);
+ header("Pragma: no-cache");
+ }
- /**
- * print a HTTP HEADER for JSON, which is encoded in UTF-8
- * @return void
- **/
- function _printJSONHeader() {
- header("Content-Type: text/html; charset=UTF-8");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
- }
+ /**
+ * print a HTTP HEADER for HTML, which is encoded in UTF-8
+ * @return void
+ */
+ function _printHTMLHeader()
+ {
+ header("Content-Type: text/html; charset=UTF-8");
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Cache-Control: post-check=0, pre-check=0", false);
+ header("Pragma: no-cache");
+ }
+ /**
+ * print a HTTP HEADER for JSON, which is encoded in UTF-8
+ * @return void
+ */
+ function _printJSONHeader()
+ {
+ header("Content-Type: text/html; charset=UTF-8");
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Cache-Control: post-check=0, pre-check=0", false);
+ header("Pragma: no-cache");
+ }
- /**
- * print a HTTP HEADER for HTML, which is encoded in UTF-8
- * @return void
- **/
- function _printHttpStatusCode($code) {
- $statusMessage = Context::get('http_status_message');
- header("HTTP/1.0 $code $statusMessage");
- }
- }
-?>
+ /**
+ * print a HTTP HEADER for HTML, which is encoded in UTF-8
+ * @return void
+ */
+ function _printHttpStatusCode($code)
+ {
+ $statusMessage = Context::get('http_status_message');
+ header("HTTP/1.0 $code $statusMessage");
+ }
+
+}
+/* End of file DisplayHandler.class.php */
+/* Location: ./classes/display/DisplayHandler.class.php */
diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php
index 02fab5eff..d5c0b0942 100644
--- a/classes/display/HTMLDisplayHandler.php
+++ b/classes/display/HTMLDisplayHandler.php
@@ -1,48 +1,54 @@
getTemplatePath();
if(!is_dir($template_path))
{
- if ($oModule->module_info->module == $oModule->module)
- $skin = $oModule->origin_module_info->skin;
- else
- $skin = $oModule->module_config->skin;
-
- if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin') === false)
+ if($oModule->module_info->module == $oModule->module)
{
- if ($skin && is_string($skin))
+ $skin = $oModule->origin_module_info->skin;
+ }
+ else
+ {
+ $skin = $oModule->module_config->skin;
+ }
+
+ if(Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') === false)
+ {
+ if($skin && is_string($skin))
{
$theme_skin = explode('|@|', $skin);
$template_path = $oModule->getTemplatePath();
- if (count($theme_skin) == 2)
+ if(count($theme_skin) == 2)
{
- $theme_path = sprintf('./themes/%s',$theme_skin[0]);
- if(substr($theme_path,0,strlen($theme_path)) != $theme_path)
+ $theme_path = sprintf('./themes/%s', $theme_skin[0]);
+ if(substr($theme_path, 0, strlen($theme_path)) != $theme_path)
{
$template_path = sprintf('%s/modules/%s/', $theme_path, $theme_skin[1]);
}
- }
+ }
}
else
{
$template_path = $oModule->getTemplatePath();
}
}
- else
+ else
{
$template_path = $oModule->getTemplatePath();
}
@@ -53,11 +59,19 @@ class HTMLDisplayHandler {
$output = $oTemplate->compile($template_path, $tpl_file);
// add .x div for adminitration pages
- if(Context::getResponseMethod() == 'HTML') {
- if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = ''.$output.'
';
-
- if(Context::get('layout') != 'none') {
- if(__DEBUG__==3) $start = getMicroTime();
+ if(Context::getResponseMethod() == 'HTML')
+ {
+ if(Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') > 0)
+ {
+ $output = '' . $output . '
';
+ }
+
+ if(Context::get('layout') != 'none')
+ {
+ if(__DEBUG__ == 3)
+ {
+ $start = getMicroTime();
+ }
Context::set('content', $output, false);
@@ -67,15 +81,17 @@ class HTMLDisplayHandler {
$edited_layout_file = $oModule->getEditedLayoutFile();
// get the layout information currently requested
- $oLayoutModel = &getModel('layout');
+ $oLayoutModel = getModel('layout');
$layout_info = Context::get('layout_info');
$layout_srl = $layout_info->layout_srl;
// compile if connected to the layout
- if($layout_srl > 0){
+ if($layout_srl > 0)
+ {
// handle separately if the layout is faceoff
- if($layout_info && $layout_info->type == 'faceoff') {
+ if($layout_info && $layout_info->type == 'faceoff')
+ {
$oLayoutModel->doActivateFaceOff($layout_info);
Context::set('layout_info', $layout_info);
}
@@ -83,15 +99,43 @@ class HTMLDisplayHandler {
// search if the changes CSS exists in the admin layout edit window
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
- if(file_exists($edited_layout_css)) Context::loadFile(array($edited_layout_css,'all','',100));
+ if(file_exists($edited_layout_css))
+ {
+ Context::loadFile(array($edited_layout_css, 'all', '', 100));
+ }
+ }
+ if(!$layout_path)
+ {
+ $layout_path = './common/tpl';
+ }
+ if(!$layout_file)
+ {
+ $layout_file = 'default_layout';
}
- if(!$layout_path) $layout_path = './common/tpl';
- if(!$layout_file) $layout_file = 'default_layout';
$output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
- if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start;
+ // if popup_layout, remove admin bar.
+ $realLayoutPath = FileHandler::getRealPath($layout_path);
+ if(substr($realLayoutPath, -1) != '/')
+ {
+ $realLayoutPath .= '/';
+ }
- if(preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT']) && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always')) {
+ $pathInfo = pathinfo($layout_file);
+ $onlyLayoutFile = $pathInfo['filename'];
+
+ if($realLayoutPath === _XE_PATH_ . 'common/tpl/' && $onlyLayoutFile === 'popup_layout')
+ {
+ Context::set('admin_bar', 'false');
+ }
+
+ if(__DEBUG__ == 3)
+ {
+ $GLOBALS['__layout_compile_elapsed__'] = getMicroTime() - $start;
+ }
+
+ if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always'))
+ {
Context::addHtmlFooter('');
}
}
@@ -103,34 +147,46 @@ class HTMLDisplayHandler {
* when display mode is HTML, prepare code before print.
* @param string $output compiled template string
* @return void
- **/
- function prepareToPrint(&$output) {
- if(Context::getResponseMethod() != 'HTML') return;
+ */
+ function prepareToPrint(&$output)
+ {
+ if(Context::getResponseMethod() != 'HTML')
+ {
+ return;
+ }
- if(__DEBUG__==3) $start = getMicroTime();
+ if(__DEBUG__ == 3)
+ {
+ $start = getMicroTime();
+ }
// move in body to the header
- $output = preg_replace_callback('!';
+ $footer = '';
+ Context::addHtmlHeader($header);
+ Context::addHtmlFooter($footer);
+ }
+
+ if($type == "view" && $kind != 'admin')
+ {
+ $module_config = $oModuleModel->getModuleConfig('module');
+ if($module_config->htmlFooter)
{
- $rulesetModule = $forward->module ? $forward->module : $this->module;
- $rulesetFile = $oModuleModel->getValidatorFilePath($rulesetModule, $ruleset, $this->mid);
- if(!empty($rulesetFile))
+ Context::addHtmlFooter($module_config->htmlFooter);
+ }
+ if($module_config->siteTitle)
+ {
+ $siteTitle = Context::getBrowserTitle();
+ if(!$siteTitle)
{
- if($_SESSION['XE_VALIDATOR_ERROR_LANG'])
+ Context::setBrowserTitle($module_config->siteTitle);
+ }
+ }
+ }
+
+ // if failed message exists in session, set context
+ $this->_setInputErrorToContext();
+
+ $procResult = $oModule->proc();
+
+ $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
+ if(!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()]))
+ {
+ $error = $oModule->getError();
+ $message = $oModule->getMessage();
+ $messageType = $oModule->getMessageType();
+ $redirectUrl = $oModule->getRedirectUrl();
+
+ if(!$procResult)
+ {
+ $this->error = $message;
+ if(!$redirectUrl && Context::get('error_return_url'))
+ {
+ $redirectUrl = Context::get('error_return_url');
+ }
+ $this->_setInputValueToSession();
+ }
+ else
+ {
+
+ }
+
+ $_SESSION['XE_VALIDATOR_ERROR'] = $error;
+ $_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
+ if($message != 'success')
+ {
+ $_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
+ }
+ $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
+
+ if(Context::get('xeVirtualRequestMethod') != 'xml')
+ {
+ $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
+ }
+ }
+
+ unset($logged_info);
+ return $oModule;
+ }
+
+ /**
+ * set error message to Session.
+ * @return void
+ * */
+ function _setInputErrorToContext()
+ {
+ if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR'))
+ {
+ Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
+ }
+ if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE'))
+ {
+ Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']);
+ }
+ if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE'))
+ {
+ Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
+ }
+ if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL'))
+ {
+ Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']);
+ }
+ if($_SESSION['XE_VALIDATOR_ID'] && !Context::get('XE_VALIDATOR_ID'))
+ {
+ Context::set('XE_VALIDATOR_ID', $_SESSION['XE_VALIDATOR_ID']);
+ }
+ if(count($_SESSION['INPUT_ERROR']))
+ {
+ Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
+ }
+
+ $this->_clearErrorSession();
+ }
+
+ /**
+ * clear error message to Session.
+ * @return void
+ * */
+ function _clearErrorSession()
+ {
+ $_SESSION['XE_VALIDATOR_ERROR'] = '';
+ $_SESSION['XE_VALIDATOR_MESSAGE'] = '';
+ $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = '';
+ $_SESSION['XE_VALIDATOR_RETURN_URL'] = '';
+ $_SESSION['XE_VALIDATOR_ID'] = '';
+ $_SESSION['INPUT_ERROR'] = '';
+ }
+
+ /**
+ * occured error when, set input values to session.
+ * @return void
+ * */
+ function _setInputValueToSession()
+ {
+ $requestVars = Context::getRequestVars();
+ unset($requestVars->act, $requestVars->mid, $requestVars->vid, $requestVars->success_return_url, $requestVars->error_return_url);
+ foreach($requestVars AS $key => $value)
+ {
+ $_SESSION['INPUT_ERROR'][$key] = $value;
+ }
+ }
+
+ /**
+ * display contents from executed module
+ * @param ModuleObject $oModule module instance
+ * @return void
+ * */
+ function displayContent($oModule = NULL)
+ {
+ // If the module is not set or not an object, set error
+ if(!$oModule || !is_object($oModule))
+ {
+ $this->error = 'msg_module_is_not_exists';
+ $this->httpStatusCode = '404';
+ }
+
+ // If connection to DB has a problem even though it's not install module, set error
+ if($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE)
+ {
+ $this->error = 'msg_dbconnect_failed';
+ }
+
+ // Call trigger after moduleHandler proc
+ $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
+ if(!$output->toBool())
+ {
+ $this->error = $output->getMessage();
+ }
+
+ // Use message view object, if HTML call
+ $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
+ if(!isset($methodList[Context::getRequestMethod()]))
+ {
+
+ if($_SESSION['XE_VALIDATOR_RETURN_URL'])
+ {
+ $display_handler = new DisplayHandler();
+ $display_handler->_debugOutput();
+
+ header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
+ return;
+ }
+
+ // If error occurred, handle it
+ if($this->error)
+ {
+ // display content with message module instance
+ $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
+ $oMessageObject = ModuleHandler::getModuleInstance('message', $type);
+ $oMessageObject->setError(-1);
+ $oMessageObject->setMessage($this->error);
+ $oMessageObject->dispMessage();
+
+ if($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200')
+ {
+ $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
+ $oMessageObject->setTemplateFile('http_status_code');
+ }
+
+ // If module was called normally, change the templates of the module into ones of the message view module
+ if($oModule)
+ {
+ $oModule->setTemplatePath($oMessageObject->getTemplatePath());
+ $oModule->setTemplateFile($oMessageObject->getTemplateFile());
+ // Otherwise, set message instance as the target module
+ }
+ else
+ {
+ $oModule = $oMessageObject;
+ }
+
+ $this->_clearErrorSession();
+ }
+
+ // Check if layout_srl exists for the module
+ if(Mobile::isFromMobilePhone())
+ {
+ $layout_srl = $oModule->module_info->mlayout_srl;
+ }
+ else
+ {
+ $layout_srl = $oModule->module_info->layout_srl;
+ }
+
+ // if layout_srl is rollback by module, set default layout
+ if($layout_srl == -1)
+ {
+ $viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
+ $oLayoutAdminModel = getAdminModel('layout');
+ $layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
+ }
+
+ if($layout_srl && !$oModule->getLayoutFile())
+ {
+
+ // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
+ $oLayoutModel = getModel('layout');
+ $layout_info = $oLayoutModel->getLayout($layout_srl);
+ if($layout_info)
+ {
+
+ // Input extra_vars into $layout_info
+ if($layout_info->extra_var_count)
{
- $errorLang = $_SESSION['XE_VALIDATOR_ERROR_LANG'];
- foreach($errorLang as $key => $val)
+
+ foreach($layout_info->extra_var as $var_id => $val)
{
- Context::setLang($key, $val);
+ if($val->type == 'image')
+ {
+ if(preg_match('/^\.\/files\/attach\/images\/(.+)/i', $val->value))
+ {
+ $val->value = Context::getRequestUri() . substr($val->value, 2);
+ }
+ }
+ $layout_info->{$var_id} = $val->value;
}
- unset($_SESSION['XE_VALIDATOR_ERROR_LANG']);
}
-
- $Validator = new Validator($rulesetFile);
- $result = $Validator->validate();
- if(!$result)
+ // Set menus into context
+ if($layout_info->menu_count)
{
- $lastError = $Validator->getLastError();
- $returnUrl = Context::get('error_return_url');
- $errorMsg = $lastError['msg'] ? $lastError['msg'] : 'validation error';
+ foreach($layout_info->menu as $menu_id => $menu)
+ {
+ // set default menu set(included home menu)
+ if(!$menu->menu_srl || $menu->menu_srl == -1)
+ {
+ $oMenuAdminController = getAdminController('menu');
+ $homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
- //for xml response
- $oModule->setError(-1);
- $oModule->setMessage($errorMsg);
- //for html redirect
- $this->error = $errorMsg;
- $_SESSION['XE_VALIDATOR_ERROR'] = -1;
- $_SESSION['XE_VALIDATOR_MESSAGE'] = $this->error;
- $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error';
- $_SESSION['XE_VALIDATOR_RETURN_URL'] = $returnUrl;
- $this->_setInputValueToSession();
- return $oModule;
+ if(file_exists($homeMenuCacheFile))
+ {
+ @include($homeMenuCacheFile);
+ }
+
+ if(!$menu->menu_srl)
+ {
+ $menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file);
+ $menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file);
+ $layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl;
+ }
+ else
+ {
+ $menu->xml_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->xml_file);
+ $menu->php_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->php_file);
+ }
+ }
+ if(file_exists($menu->php_file))
+ {
+ @include($menu->php_file);
+ }
+ Context::set($menu_id, $menu);
+ }
+ }
+
+ // Set layout information into context
+ Context::set('layout_info', $layout_info);
+
+ $oModule->setLayoutPath($layout_info->path);
+ $oModule->setLayoutFile('layout');
+
+ // If layout was modified, use the modified version
+ $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
+ if(file_exists($edited_layout))
+ {
+ $oModule->setEditedLayoutFile($edited_layout);
}
}
}
-
- $oModule->setAct($this->act);
-
- $this->module_info->module_type = $type;
- $oModule->setModuleInfo($this->module_info, $xml_info);
-
- if($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent())
+ $isLayoutDrop = Context::get('isLayoutDrop');
+ if($isLayoutDrop)
{
- global $lang;
- $header = '';
- $footer = '';
- Context::addHtmlHeader($header);
- Context::addHtmlFooter($footer);
- }
-
- if($type == "view" && $kind != 'admin'){
- $module_config= $oModuleModel->getModuleConfig('module');
- if($module_config->htmlFooter){
- Context::addHtmlFooter($module_config->htmlFooter);
- }
- }
-
-
- // if failed message exists in session, set context
- $this->_setInputErrorToContext();
-
- $procResult = $oModule->proc();
-
- $methodList = array('XMLRPC'=>1, 'JSON'=>1);
- if(!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()]))
- {
- $error = $oModule->getError();
- $message = $oModule->getMessage();
- $messageType = $oModule->getMessageType();
- $redirectUrl = $oModule->getRedirectUrl();
-
- if (!$procResult)
+ $kind = strpos(strtolower($this->act), 'admin') !== FALSE ? 'admin' : '';
+ if($kind == 'admin')
{
- $this->error = $message;
- if (!$redirectUrl && Context::get('error_return_url')) $redirectUrl = Context::get('error_return_url');
- $this->_setInputValueToSession();
-
+ $oModule->setLayoutFile('popup_layout');
}
else
{
- if(count($_SESSION['INPUT_ERROR']))
- {
- Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
- $_SESSION['INPUT_ERROR'] = '';
- }
+ $oModule->setLayoutPath('common/tpl');
+ $oModule->setLayoutFile('default_layout');
}
-
- $_SESSION['XE_VALIDATOR_ERROR'] = $error;
- if ($message != 'success') $_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
- $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
-
- if(Context::get('xeVirtualRequestMethod') != 'xml')
- {
- $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
- }
- }
-
- unset($logged_info);
- return $oModule;
- }
-
- /**
- * set error message to Session.
- * @return void
- **/
- function _setInputErrorToContext()
- {
- if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR')) Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
- if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE')) Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']);
- if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE')) Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
- if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL')) Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']);
-
- $this->_clearErrorSession();
- }
-
- /**
- * clear error message to Session.
- * @return void
- **/
- function _clearErrorSession()
- {
- $_SESSION['XE_VALIDATOR_ERROR'] = '';
- $_SESSION['XE_VALIDATOR_MESSAGE'] = '';
- $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = '';
- $_SESSION['XE_VALIDATOR_RETURN_URL'] = '';
- }
-
- /**
- * occured error when, set input values to session.
- * @return void
- **/
- function _setInputValueToSession()
- {
- $requestVars = Context::getRequestVars();
- unset($requestVars->act, $requestVars->mid, $requestVars->vid, $requestVars->success_return_url, $requestVars->error_return_url);
- foreach($requestVars AS $key=>$value) $_SESSION['INPUT_ERROR'][$key] = $value;
- }
-
- /**
- * display contents from executed module
- * @param ModuleObject $oModule module instance
- * @return void
- **/
- function displayContent($oModule = NULL) {
- // If the module is not set or not an object, set error
- if(!$oModule || !is_object($oModule)) {
- $this->error = 'msg_module_is_not_exists';
- $this->httpStatusCode = '404';
- }
-
- // If connection to DB has a problem even though it's not install module, set error
- if($this->module != 'install' && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == false) {
- $this->error = 'msg_dbconnect_failed';
- }
-
- // Call trigger after moduleHandler proc
- $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
- if(!$output->toBool()) $this->error = $output->getMessage();
-
- // Use message view object, if HTML call
- $methodList = array('XMLRPC'=>1, 'JSON'=>1);
- if(!isset($methodList[Context::getRequestMethod()])) {
-
- if($_SESSION['XE_VALIDATOR_RETURN_URL'])
- {
- $display_handler = new DisplayHandler();
- $display_handler->_debugOutput();
-
- header('location:'.$_SESSION['XE_VALIDATOR_RETURN_URL']);
- return;
- }
-
- // If error occurred, handle it
- if($this->error) {
- // display content with message module instance
- $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
- $oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
- $oMessageObject->setError(-1);
- $oMessageObject->setMessage($this->error);
- $oMessageObject->dispMessage();
-
- if($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200')
- {
- $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
- $oMessageObject->setTemplateFile('http_status_code');
- }
-
- // If module was called normally, change the templates of the module into ones of the message view module
- if($oModule) {
- $oModule->setTemplatePath($oMessageObject->getTemplatePath());
- $oModule->setTemplateFile($oMessageObject->getTemplateFile());
- // Otherwise, set message instance as the target module
- } else {
- $oModule = $oMessageObject;
- }
-
- $this->_clearErrorSession();
- }
-
- // Check if layout_srl exists for the module
- if(Mobile::isFromMobilePhone())
- {
- $layout_srl = $oModule->module_info->mlayout_srl;
- }
- else
- {
- $layout_srl = $oModule->module_info->layout_srl;
- }
-
- if($layout_srl && !$oModule->getLayoutFile()) {
-
- // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
- $oLayoutModel = &getModel('layout');
- $layout_info = $oLayoutModel->getLayout($layout_srl);
- if($layout_info) {
-
- // Input extra_vars into $layout_info
- if($layout_info->extra_var_count) {
-
- foreach($layout_info->extra_var as $var_id => $val) {
- if($val->type == 'image') {
- if(preg_match('/^\.\/files\/attach\/images\/(.+)/i',$val->value)) $val->value = Context::getRequestUri().substr($val->value,2);
- }
- $layout_info->{$var_id} = $val->value;
- }
- }
- // Set menus into context
- if($layout_info->menu_count) {
- foreach($layout_info->menu as $menu_id => $menu) {
- if(file_exists($menu->php_file)) @include($menu->php_file);
- Context::set($menu_id, $menu);
- }
- }
-
- // Set layout information into context
- Context::set('layout_info', $layout_info);
-
- $oModule->setLayoutPath($layout_info->path);
- $oModule->setLayoutFile('layout');
-
- // If layout was modified, use the modified version
- $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
- if(file_exists($edited_layout)) $oModule->setEditedLayoutFile($edited_layout);
- }
- }
- }
-
- // Display contents
- $oDisplayHandler = new DisplayHandler();
- $oDisplayHandler->printContent($oModule);
- }
-
- /**
- * returns module's path
- * @param string $module module name
- * @return string path of the module
- **/
- function getModulePath($module) {
- return sprintf('./modules/%s/', $module);
- }
-
- /**
- * It creates a module instance
- * @param string $module module name
- * @param string $type instance type, (e.g., view, controller, model)
- * @param string $kind admin or svc
- * @return ModuleObject module instance (if failed it returns null)
- * @remarks if there exists a module instance created before, returns it.
- **/
- function &getModuleInstance($module, $type = 'view', $kind = '') {
-
- if(__DEBUG__==3) $start_time = getMicroTime();
-
- $parent_module = $module;
- $kind = strtolower($kind);
- $type = strtolower($type);
-
- $kinds = array('svc'=>1, 'admin'=>1);
- if(!isset($kinds[$kind])) $kind = 'svc';
-
- $key = $module.'.'.($kind!='admin'?'':'admin').'.'.$type;
-
- if(is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__']))
- {
- $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
}
+ }
- // if there is no instance of the module in global variable, create a new one
- if(!isset($GLOBALS['_loaded_module'][$module][$type][$kind]))
+ // Display contents
+ $oDisplayHandler = new DisplayHandler();
+ $oDisplayHandler->printContent($oModule);
+ }
+
+ /**
+ * returns module's path
+ * @param string $module module name
+ * @return string path of the module
+ * */
+ function getModulePath($module)
+ {
+ return sprintf('./modules/%s/', $module);
+ }
+
+ /**
+ * It creates a module instance
+ * @param string $module module name
+ * @param string $type instance type, (e.g., view, controller, model)
+ * @param string $kind admin or svc
+ * @return ModuleObject module instance (if failed it returns null)
+ * @remarks if there exists a module instance created before, returns it.
+ * */
+ function &getModuleInstance($module, $type = 'view', $kind = '')
+ {
+
+ if(__DEBUG__ == 3)
+ {
+ $start_time = getMicroTime();
+ }
+
+ $parent_module = $module;
+ $kind = strtolower($kind);
+ $type = strtolower($type);
+
+ $kinds = array('svc' => 1, 'admin' => 1);
+ if(!isset($kinds[$kind]))
+ {
+ $kind = 'svc';
+ }
+
+ $key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
+
+ if(is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__']))
+ {
+ $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
+ }
+
+ // if there is no instance of the module in global variable, create a new one
+ if(!isset($GLOBALS['_loaded_module'][$module][$type][$kind]))
+ {
+ ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
+
+ if($extend_module && (!is_readable($high_class_file) || !is_readable($class_file)))
{
+ $module = $parent_module;
ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
-
- if($extend_module && (!is_readable($high_class_file) || !is_readable($class_file)))
- {
- $module = $parent_module;
- ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
- }
-
- // Get base class name and load the file contains it
- if(!class_exists($module)) {
- $high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_,$class_path, $module);
- if(!file_exists($high_class_file)) return NULL;
- require_once($high_class_file);
- }
-
- // Get the name of the class file
- if(!is_readable($class_file)) return NULL;
-
- // Create an instance with eval function
- require_once($class_file);
- if(!class_exists($instance_name)) return NULL;
- $tmp_fn = create_function('', "return new {$instance_name}();");
- $oModule = $tmp_fn();
- if(!is_object($oModule)) return NULL;
-
- // Load language files for the class
- Context::loadLang($class_path.'lang');
- if($extend_module) {
- Context::loadLang(ModuleHandler::getModulePath($parent_module).'lang');
- }
-
- // Set variables to the instance
- $oModule->setModule($module);
- $oModule->setModulePath($class_path);
-
- // If the module has a constructor, run it.
- if(!isset($GLOBALS['_called_constructor'][$instance_name])) {
- $GLOBALS['_called_constructor'][$instance_name] = true;
- if(@method_exists($oModule, $instance_name)) $oModule->{$instance_name}();
- }
-
- // Store the created instance into GLOBALS variable
- $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
- }
-
- if(__DEBUG__==3) $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
-
- // return the instance
- return $GLOBALS['_loaded_module'][$module][$type][$kind];
- }
-
- function _getModuleFilePath($module, $type, $kind, &$classPath, &$highClassFile, &$classFile, &$instanceName)
- {
- $classPath = ModuleHandler::getModulePath($module);
-
- $highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_,$classPath, $module);
- $highClassFile = FileHandler::getRealPath($highClassFile);
-
- $types = explode(' ', 'view controller model api wap mobile class');
- if(!in_array($type, $types)) $type = $types[0];
- if($type == 'class') {
- $instanceName = '%s';
- $classFile = '%s%s.%s.php';
- } elseif($kind == 'admin' && array_search($type, $types) < 3) {
- $instanceName = '%sAdmin%s';
- $classFile = '%s%s.admin.%s.php';
- } else{
- $instanceName = '%s%s';
- $classFile = '%s%s.%s.php';
}
- $instanceName = sprintf($instanceName, $module, ucfirst($type));
- $classFile = sprintf($classFile, $classPath, $module, $type);
- $classFile = FileHandler::getRealPath($classFile);
+ // Get base class name and load the file contains it
+ if(!class_exists($module))
+ {
+ $high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
+ if(!file_exists($high_class_file))
+ {
+ return NULL;
+ }
+ require_once($high_class_file);
+ }
+
+ // Get the name of the class file
+ if(!is_readable($class_file))
+ {
+ return NULL;
+ }
+
+ // Create an instance with eval function
+ require_once($class_file);
+ if(!class_exists($instance_name))
+ {
+ return NULL;
+ }
+ $tmp_fn = create_function('', "return new {$instance_name}();");
+ $oModule = $tmp_fn();
+ if(!is_object($oModule))
+ {
+ return NULL;
+ }
+
+ // Load language files for the class
+ Context::loadLang($class_path . 'lang');
+ if($extend_module)
+ {
+ Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
+ }
+
+ // Set variables to the instance
+ $oModule->setModule($module);
+ $oModule->setModulePath($class_path);
+
+ // If the module has a constructor, run it.
+ if(!isset($GLOBALS['_called_constructor'][$instance_name]))
+ {
+ $GLOBALS['_called_constructor'][$instance_name] = TRUE;
+ if(@method_exists($oModule, $instance_name))
+ {
+ $oModule->{$instance_name}();
+ }
+ }
+
+ // Store the created instance into GLOBALS variable
+ $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
}
- /**
- * call a trigger
- * @param string $trigger_name trigger's name to call
- * @param string $called_position called position
- * @param object $obj an object as a parameter to trigger
- * @return Object
- **/
- function triggerCall($trigger_name, $called_position, &$obj) {
- // skip if not installed
- if(!Context::isInstalled()) return new Object();
-
- $oModuleModel = &getModel('module');
- $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
- if(!$triggers || !count($triggers)) return new Object();
-
- foreach($triggers as $item) {
- $module = $item->module;
- $type = $item->type;
- $called_method = $item->called_method;
-
- $oModule = null;
- $oModule = &getModule($module, $type);
- if(!$oModule || !method_exists($oModule, $called_method)) continue;
-
- $output = $oModule->{$called_method}($obj);
- if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) return $output;
- unset($oModule);
- }
-
- return new Object();
- }
-
- /**
- * get http status message by http status code
- * @param string $code
- * @return string
- **/
- function _setHttpStatusMessage($code) {
- $statusMessageList = array(
- '100'=>'Continue',
- '101'=>'Switching Protocols',
- '201'=>'OK',
- '201'=>'Created',
- '202'=>'Accepted',
- '203'=>'Non-Authoritative Information',
- '204'=>'No Content',
- '205'=>'Reset Content',
- '206'=>'Partial Content',
- '300'=>'Multiple Choices',
- '301'=>'Moved Permanently',
- '302'=>'Found',
- '303'=>'See Other',
- '304'=>'Not Modified',
- '305'=>'Use Proxy',
- '307'=>'Temporary Redirect',
- '400'=>'Bad Request',
- '401'=>'Unauthorized',
- '402'=>'Payment Required',
- '403'=>'Forbidden',
- '404'=>'Not Found',
- '405'=>'Method Not Allowed',
- '406'=>'Not Acceptable',
- '407'=>'Proxy Authentication Required',
- '408'=>'Request Timeout',
- '409'=>'Conflict',
- '410'=>'Gone',
- '411'=>'Length Required',
- '412'=>'Precondition Failed',
- '413'=>'Request Entity Too Large',
- '414'=>'Request-URI Too Long',
- '415'=>'Unsupported Media Type',
- '416'=>'Requested Range Not Satisfiable',
- '417'=>'Expectation Failed',
- '500'=>'Internal Server Error',
- '501'=>'Not Implemented',
- '502'=>'Bad Gateway',
- '503'=>'Service Unavailable',
- '504'=>'Gateway Timeout',
- '505'=>'HTTP Version Not Supported',
- );
- $statusMessage = $statusMessageList[$code];
- if(!$statusMessage) $statusMessage = 'OK';
-
- Context::set('http_status_code', $code);
- Context::set('http_status_message', $statusMessage);
+ if(__DEBUG__ == 3)
+ {
+ $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
}
- }
+
+ // return the instance
+ return $GLOBALS['_loaded_module'][$module][$type][$kind];
+ }
+
+ function _getModuleFilePath($module, $type, $kind, &$classPath, &$highClassFile, &$classFile, &$instanceName)
+ {
+ $classPath = ModuleHandler::getModulePath($module);
+
+ $highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_, $classPath, $module);
+ $highClassFile = FileHandler::getRealPath($highClassFile);
+
+ $types = explode(' ', 'view controller model api wap mobile class');
+ if(!in_array($type, $types))
+ {
+ $type = $types[0];
+ }
+ if($type == 'class')
+ {
+ $instanceName = '%s';
+ $classFile = '%s%s.%s.php';
+ }
+ elseif($kind == 'admin' && array_search($type, $types) < 3)
+ {
+ $instanceName = '%sAdmin%s';
+ $classFile = '%s%s.admin.%s.php';
+ }
+ else
+ {
+ $instanceName = '%s%s';
+ $classFile = '%s%s.%s.php';
+ }
+
+ $instanceName = sprintf($instanceName, $module, ucfirst($type));
+ $classFile = sprintf($classFile, $classPath, $module, $type);
+ $classFile = FileHandler::getRealPath($classFile);
+ }
+
+ /**
+ * call a trigger
+ * @param string $trigger_name trigger's name to call
+ * @param string $called_position called position
+ * @param object $obj an object as a parameter to trigger
+ * @return Object
+ * */
+ function triggerCall($trigger_name, $called_position, &$obj)
+ {
+ // skip if not installed
+ if(!Context::isInstalled())
+ {
+ return new Object();
+ }
+
+ $oModuleModel = getModel('module');
+ $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
+ if(!$triggers || !count($triggers))
+ {
+ return new Object();
+ }
+
+ foreach($triggers as $item)
+ {
+ $module = $item->module;
+ $type = $item->type;
+ $called_method = $item->called_method;
+
+ $oModule = NULL;
+ $oModule = getModule($module, $type);
+ if(!$oModule || !method_exists($oModule, $called_method))
+ {
+ continue;
+ }
+
+ $output = $oModule->{$called_method}($obj);
+ if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
+ {
+ return $output;
+ }
+ unset($oModule);
+ }
+
+ return new Object();
+ }
+
+ /**
+ * get http status message by http status code
+ * @param string $code
+ * @return string
+ * */
+ function _setHttpStatusMessage($code)
+ {
+ $statusMessageList = array(
+ '100' => 'Continue',
+ '101' => 'Switching Protocols',
+ '201' => 'OK',
+ '201' => 'Created',
+ '202' => 'Accepted',
+ '203' => 'Non-Authoritative Information',
+ '204' => 'No Content',
+ '205' => 'Reset Content',
+ '206' => 'Partial Content',
+ '300' => 'Multiple Choices',
+ '301' => 'Moved Permanently',
+ '302' => 'Found',
+ '303' => 'See Other',
+ '304' => 'Not Modified',
+ '305' => 'Use Proxy',
+ '307' => 'Temporary Redirect',
+ '400' => 'Bad Request',
+ '401' => 'Unauthorized',
+ '402' => 'Payment Required',
+ '403' => 'Forbidden',
+ '404' => 'Not Found',
+ '405' => 'Method Not Allowed',
+ '406' => 'Not Acceptable',
+ '407' => 'Proxy Authentication Required',
+ '408' => 'Request Timeout',
+ '409' => 'Conflict',
+ '410' => 'Gone',
+ '411' => 'Length Required',
+ '412' => 'Precondition Failed',
+ '413' => 'Request Entity Too Large',
+ '414' => 'Request-URI Too Long',
+ '415' => 'Unsupported Media Type',
+ '416' => 'Requested Range Not Satisfiable',
+ '417' => 'Expectation Failed',
+ '500' => 'Internal Server Error',
+ '501' => 'Not Implemented',
+ '502' => 'Bad Gateway',
+ '503' => 'Service Unavailable',
+ '504' => 'Gateway Timeout',
+ '505' => 'HTTP Version Not Supported',
+ );
+ $statusMessage = $statusMessageList[$code];
+ if(!$statusMessage)
+ {
+ $statusMessage = 'OK';
+ }
+
+ Context::set('http_status_code', $code);
+ Context::set('http_status_message', $statusMessage);
+ }
+
+}
?>
diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php
index 6134e3072..4b88844c9 100644
--- a/classes/module/ModuleObject.class.php
+++ b/classes/module/ModuleObject.class.php
@@ -1,386 +1,480 @@
module = $module;
+ }
- var $act = NULL; ///< a string value to contain the action name
+ /**
+ * setter to set the name of module path
+ * @param string $path the directory path to a module directory
+ * @return void
+ * */
+ function setModulePath($path)
+ {
+ if(substr($path, -1) != '/')
+ {
+ $path.='/';
+ }
+ $this->module_path = $path;
+ }
- var $template_path = NULL; ///< a path of directory where template files reside
- var $template_file = NULL; ///< name of template file
+ /**
+ * setter to set an url for redirection
+ * @param string $url url for redirection
+ * @remark redirect_url is used only for ajax requests
+ * @return void
+ * */
+ function setRedirectUrl($url = './', $output = NULL)
+ {
+ $ajaxRequestMethod = array_flip($this->ajaxRequestMethod);
+ if(!isset($ajaxRequestMethod[Context::getRequestMethod()]))
+ {
+ $this->add('redirect_url', $url);
+ }
- var $layout_path = ''; ///< a path of directory where layout files reside
- var $layout_file = ''; ///< name of layout file
- var $edited_layout_file = ''; ///< name of temporary layout files that is modified in an admin mode
+ if($output !== NULL && is_object($output))
+ {
+ return $output;
+ }
+ }
- var $stop_proc = false; ///< a flag to indicating whether to stop the execution of code.
+ /**
+ * get url for redirection
+ * @return string redirect_url
+ * */
+ function getRedirectUrl()
+ {
+ return $this->get('redirect_url');
+ }
- var $module_config = NULL;
- var $ajaxRequestMethod = array('XMLRPC', 'JSON');
+ /**
+ * set message
+ * @param string $message a message string
+ * @param string $type type of message (error, info, update)
+ * @return void
+ * */
+ function setMessage($message, $type = NULL)
+ {
+ parent::setMessage($message);
+ $this->setMessageType($type);
+ }
- var $gzhandler_enable = TRUE;
+ /**
+ * set type of message
+ * @param string $type type of message (error, info, update)
+ * @return void
+ * */
+ function setMessageType($type)
+ {
+ $this->add('message_type', $type);
+ }
- /**
- * setter to set the name of module
- * @param string $module name of module
- * @return void
- **/
- function setModule($module) {
- $this->module = $module;
- }
+ /**
+ * get type of message
+ * @return string $type
+ * */
+ function getMessageType()
+ {
+ $type = $this->get('message_type');
+ $typeList = array('error' => 1, 'info' => 1, 'update' => 1);
+ if(!isset($typeList[$type]))
+ {
+ $type = $this->getError() ? 'error' : 'info';
+ }
+ return $type;
+ }
- /**
- * setter to set the name of module path
- * @param string $path the directory path to a module directory
- * @return void
- **/
- function setModulePath($path) {
- if(substr($path,-1)!='/') $path.='/';
- $this->module_path = $path;
- }
+ /**
+ * sett to set the template path for refresh.html
+ * refresh.html is executed as a result of method execution
+ * Tpl as the common run of the refresh.html ..
+ * @return void
+ * */
+ function setRefreshPage()
+ {
+ $this->setTemplatePath('./common/tpl');
+ $this->setTemplateFile('refresh');
+ }
- /**
- * setter to set an url for redirection
- * @param string $url url for redirection
- * @remark redirect_url is used only for ajax requests
- * @return void
- **/
- function setRedirectUrl($url='./', $output = NULL) {
- $ajaxRequestMethod = array_flip($this->ajaxRequestMethod);
- if(!isset($ajaxRequestMethod[Context::getRequestMethod()]))
+ /**
+ * sett to set the action name
+ * @param string $act
+ * @return void
+ * */
+ function setAct($act)
+ {
+ $this->act = $act;
+ }
+
+ /**
+ * sett to set module information
+ * @param object $module_info object containing module information
+ * @param object $xml_info object containing module description
+ * @return void
+ * */
+ function setModuleInfo($module_info, $xml_info)
+ {
+ // The default variable settings
+ $this->mid = $module_info->mid;
+ $this->module_srl = $module_info->module_srl;
+ $this->module_info = $module_info;
+ $this->origin_module_info = $module_info;
+ $this->xml_info = $xml_info;
+ $this->skin_vars = $module_info->skin_vars;
+ // validate certificate info and permission settings necessary in Web-services
+ $is_logged = Context::get('is_logged');
+ $logged_info = Context::get('logged_info');
+ // module model create an object
+ $oModuleModel = getModel('module');
+ // permission settings. access, manager(== is_admin) are fixed and privilege name in XE
+ $module_srl = Context::get('module_srl');
+ if(!$module_info->mid && !is_array($module_srl) && preg_match('/^([0-9]+)$/', $module_srl))
+ {
+ $request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
+ if($request_module->module_srl == $module_srl)
{
- $this->add('redirect_url', $url);
+ $grant = $oModuleModel->getGrant($request_module, $logged_info);
}
-
- if($output !== NULL && is_object($output))
+ }
+ else
+ {
+ $grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
+ // have at least access grant
+ if(substr_count($this->act, 'Member') || substr_count($this->act, 'Communication'))
{
- return $output;
+ $grant->access = 1;
}
- }
-
- /**
- * get url for redirection
- * @return string redirect_url
- **/
- function getRedirectUrl(){
- return $this->get('redirect_url');
}
-
- /**
- * set message
- * @param string $message a message string
- * @param string $type type of message (error, info, update)
- * @return void
- **/
- function setMessage($message, $type = null){
- parent::setMessage($message);
- $this->setMessageType($type);
- }
-
- /**
- * set type of message
- * @param string $type type of message (error, info, update)
- * @return void
- **/
- function setMessageType($type){
- $this->add('message_type', $type);
- }
-
- /**
- * get type of message
- * @return string $type
- **/
- function getMessageType(){
- $type = $this->get('message_type');
- $typeList = array('error'=>1, 'info'=>1, 'update'=>1);
- if (!isset($typeList[$type])){
- $type = $this->getError()?'error':'info';
+ // display no permission if the current module doesn't have an access privilege
+ //if(!$grant->access) return $this->stop("msg_not_permitted");
+ // checks permission and action if you don't have an admin privilege
+ if(!$grant->manager)
+ {
+ // get permission types(guest, member, manager, root) of the currently requested action
+ $permission_target = $xml_info->permission->{$this->act};
+ // check manager if a permission in module.xml otherwise action if no permission
+ if(!$permission_target && substr_count($this->act, 'Admin'))
+ {
+ $permission_target = 'manager';
}
- return $type;
- }
-
- /**
- * sett to set the template path for refresh.html
- * refresh.html is executed as a result of method execution
- * Tpl as the common run of the refresh.html ..
- * @return void
- **/
- function setRefreshPage() {
- $this->setTemplatePath('./common/tpl');
- $this->setTemplateFile('refresh');
- }
-
-
- /**
- * sett to set the action name
- * @param string $act
- * @return void
- **/
- function setAct($act) {
- $this->act = $act;
- }
-
- /**
- * sett to set module information
- * @param object $module_info object containing module information
- * @param object $xml_info object containing module description
- * @return void
- **/
- function setModuleInfo($module_info, $xml_info) {
- // The default variable settings
- $this->mid = $module_info->mid;
- $this->module_srl = $module_info->module_srl;
- $this->module_info = $module_info;
- $this->origin_module_info = $module_info;
- $this->xml_info = $xml_info;
- $this->skin_vars = $module_info->skin_vars;
- // validate certificate info and permission settings necessary in Web-services
- $is_logged = Context::get('is_logged');
- $logged_info = Context::get('logged_info');
- // module model create an object
- $oModuleModel = &getModel('module');
- // permission settings. access, manager(== is_admin) are fixed and privilege name in XE
- $module_srl = Context::get('module_srl');
- if(!$module_info->mid && !is_array($module_srl) && preg_match('/^([0-9]+)$/',$module_srl)) {
- $request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
- if($request_module->module_srl == $module_srl) {
- $grant = $oModuleModel->getGrant($request_module, $logged_info);
- }
- } else {
- $grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
- // have at least access grant
- if( substr_count($this->act, 'Member') || substr_count($this->act, 'Communication'))
- $grant->access = 1;
- }
- // display no permission if the current module doesn't have an access privilege
- //if(!$grant->access) return $this->stop("msg_not_permitted");
- // checks permission and action if you don't have an admin privilege
- if(!$grant->manager) {
- // get permission types(guest, member, manager, root) of the currently requested action
- $permission_target = $xml_info->permission->{$this->act};
- // check manager if a permission in module.xml otherwise action if no permission
- if(!$permission_target && substr_count($this->act, 'Admin')) $permission_target = 'manager';
- // Check permissions
- switch($permission_target) {
- case 'root' :
- case 'manager' :
- $this->stop('msg_is_not_administrator');
+ // Check permissions
+ switch($permission_target)
+ {
+ case 'root' :
+ case 'manager' :
+ $this->stop('msg_is_not_administrator');
+ return;
+ case 'member' :
+ if(!$is_logged)
+ {
+ $this->stop('msg_not_permitted_act');
return;
- case 'member' :
- if(!$is_logged)
- {
- $this->stop('msg_not_permitted_act');
- return;
- }
- break;
- }
- }
- // permission variable settings
- $this->grant = $grant;
+ }
+ break;
+ }
+ }
+ // permission variable settings
+ $this->grant = $grant;
- Context::set('grant', $grant);
+ Context::set('grant', $grant);
- $this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
+ $this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
- if(method_exists($this, 'init')) $this->init();
- }
+ if(method_exists($this, 'init'))
+ {
+ $this->init();
+ }
+ }
- /**
- * set the stop_proc and approprate message for msg_code
- * @param string $msg_code an error code
- * @return ModuleObject $this
- **/
- function stop($msg_code) {
- // flag setting to stop the proc processing
- $this->stop_proc = true;
- // Error handling
- $this->setError(-1);
- $this->setMessage($msg_code);
- // Error message display by message module
- $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
- $oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
- $oMessageObject->setError(-1);
- $oMessageObject->setMessage($msg_code);
- $oMessageObject->dispMessage();
+ /**
+ * set the stop_proc and approprate message for msg_code
+ * @param string $msg_code an error code
+ * @return ModuleObject $this
+ * */
+ function stop($msg_code)
+ {
+ // flag setting to stop the proc processing
+ $this->stop_proc = TRUE;
+ // Error handling
+ $this->setError(-1);
+ $this->setMessage($msg_code);
+ // Error message display by message module
+ $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
+ $oMessageObject = ModuleHandler::getModuleInstance('message', $type);
+ $oMessageObject->setError(-1);
+ $oMessageObject->setMessage($msg_code);
+ $oMessageObject->dispMessage();
- $this->setTemplatePath($oMessageObject->getTemplatePath());
- $this->setTemplateFile($oMessageObject->getTemplateFile());
+ $this->setTemplatePath($oMessageObject->getTemplatePath());
+ $this->setTemplateFile($oMessageObject->getTemplateFile());
- return $this;
- }
+ return $this;
+ }
- /**
- * set the file name of the template file
- * @param string name of file
- * @return void
- **/
- function setTemplateFile($filename) {
- if(substr($filename,-5)!='.html') $filename .= '.html';
- $this->template_file = $filename;
- }
+ /**
+ * set the file name of the template file
+ * @param string name of file
+ * @return void
+ * */
+ function setTemplateFile($filename)
+ {
+ if(substr($filename, -5) != '.html')
+ {
+ $filename .= '.html';
+ }
+ $this->template_file = $filename;
+ }
- /**
- * retrieve the directory path of the template directory
- * @return string
- **/
- function getTemplateFile() {
- return $this->template_file;
- }
+ /**
+ * retrieve the directory path of the template directory
+ * @return string
+ * */
+ function getTemplateFile()
+ {
+ return $this->template_file;
+ }
- /**
- * set the directory path of the template directory
- * @param string path of template directory.
- * @return void
- **/
- function setTemplatePath($path) {
- if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
- if(substr($path,-1)!='/') $path .= '/';
- $this->template_path = $path;
- }
+ /**
+ * set the directory path of the template directory
+ * @param string path of template directory.
+ * @return void
+ * */
+ function setTemplatePath($path)
+ {
+ if(substr($path, 0, 1) != '/' && substr($path, 0, 2) != './')
+ {
+ $path = './' . $path;
+ }
+ if(substr($path, -1) != '/')
+ {
+ $path .= '/';
+ }
+ $this->template_path = $path;
+ }
- /**
- * retrieve the directory path of the template directory
- * @return string
- **/
- function getTemplatePath() {
- return $this->template_path;
- }
+ /**
+ * retrieve the directory path of the template directory
+ * @return string
+ * */
+ function getTemplatePath()
+ {
+ return $this->template_path;
+ }
- /**
- * set the file name of the temporarily modified by admin
- * @param string name of file
- * @return void
- **/
- function setEditedLayoutFile($filename) {
- if(substr($filename,-5)!='.html') $filename .= '.html';
- $this->edited_layout_file = $filename;
- }
+ /**
+ * set the file name of the temporarily modified by admin
+ * @param string name of file
+ * @return void
+ * */
+ function setEditedLayoutFile($filename)
+ {
+ if(substr($filename, -5) != '.html')
+ {
+ $filename .= '.html';
+ }
+ $this->edited_layout_file = $filename;
+ }
- /**
- * retreived the file name of edited_layout_file
- * @return string
- **/
- function getEditedLayoutFile() {
- return $this->edited_layout_file;
- }
+ /**
+ * retreived the file name of edited_layout_file
+ * @return string
+ * */
+ function getEditedLayoutFile()
+ {
+ return $this->edited_layout_file;
+ }
- /**
- * set the file name of the layout file
- * @param string name of file
- * @return void
- **/
- function setLayoutFile($filename) {
- if(substr($filename,-5)!='.html') $filename .= '.html';
- $this->layout_file = $filename;
- }
+ /**
+ * set the file name of the layout file
+ * @param string name of file
+ * @return void
+ * */
+ function setLayoutFile($filename)
+ {
+ if(substr($filename, -5) != '.html')
+ {
+ $filename .= '.html';
+ }
+ $this->layout_file = $filename;
+ }
- /**
- * get the file name of the layout file
- * @return string
- **/
- function getLayoutFile() {
- return $this->layout_file;
- }
+ /**
+ * get the file name of the layout file
+ * @return string
+ * */
+ function getLayoutFile()
+ {
+ return $this->layout_file;
+ }
- /**
- * set the directory path of the layout directory
- * @param string path of layout directory.
- **/
- function setLayoutPath($path) {
- if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
- if(substr($path,-1)!='/') $path .= '/';
- $this->layout_path = $path;
- }
+ /**
+ * set the directory path of the layout directory
+ * @param string path of layout directory.
+ * */
+ function setLayoutPath($path)
+ {
+ if(substr($path, 0, 1) != '/' && substr($path, 0, 2) != './')
+ {
+ $path = './' . $path;
+ }
+ if(substr($path, -1) != '/')
+ {
+ $path .= '/';
+ }
+ $this->layout_path = $path;
+ }
- /**
- * set the directory path of the layout directory
- * @return string
- **/
- function getLayoutPath() {
- return $this->layout_path;
- }
+ /**
+ * set the directory path of the layout directory
+ * @return string
+ * */
+ function getLayoutPath()
+ {
+ return $this->layout_path;
+ }
- /**
- * excute the member method specified by $act variable
- * @return boolean true : success false : fail
- **/
- function proc() {
- // pass if stop_proc is true
- if($this->stop_proc) return false;
+ /**
+ * excute the member method specified by $act variable
+ * @return boolean true : success false : fail
+ * */
+ function proc()
+ {
+ // pass if stop_proc is true
+ if($this->stop_proc)
+ {
+ return false;
+ }
- // trigger call
- $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
- if(!$triggerOutput->toBool()) {
- $this->setError($triggerOutput->getError());
- $this->setMessage($triggerOutput->getMessage());
- return false;
- }
+ // trigger call
+ $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
+ if(!$triggerOutput->toBool())
+ {
+ $this->setError($triggerOutput->getError());
+ $this->setMessage($triggerOutput->getMessage());
+ return false;
+ }
- // execute an addon(call called_position as before_module_proc)
- $called_position = 'before_module_proc';
- $oAddonController = &getController('addon');
- $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
- @include($addon_file);
+ // execute an addon(call called_position as before_module_proc)
+ $called_position = 'before_module_proc';
+ $oAddonController = getController('addon');
+ $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
+ @include($addon_file);
- if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
- // Check permissions
- if($this->module_srl && !$this->grant->access){
- $this->stop("msg_not_permitted_act");
- return FALSE;
+ if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act))
+ {
+ // Check permissions
+ if($this->module_srl && !$this->grant->access)
+ {
+ $this->stop("msg_not_permitted_act");
+ return FALSE;
+ }
+
+ // integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
+ $is_default_skin = ((!Mobile::isFromMobilePhone() && $this->module_info->is_skin_fix == 'N') || (Mobile::isFromMobilePhone() && $this->module_info->is_mskin_fix == 'N'));
+ $usedSkinModule = !($this->module == 'page' && ($this->module_info->page_type == 'OUTSIDE' || $this->module_info->page_type == 'WIDGET'));
+ if($usedSkinModule && $is_default_skin && $this->module != 'admin' && strpos($this->act, 'Admin') === false && $this->module == $this->module_info->module)
+ {
+ $dir = (Mobile::isFromMobilePhone()) ? 'm.skins' : 'skins';
+ $valueName = (Mobile::isFromMobilePhone()) ? 'mskin' : 'skin';
+ $oModuleModel = getModel('module');
+ $skinType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
+ $skinName = $oModuleModel->getModuleDefaultSkin($this->module, $skinType);
+ if($this->module == 'page')
+ {
+ $this->module_info->{$valueName} = $skinName;
}
- // integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
- $oModuleModel = &getModel('module');
- $oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
- Context::set('module_info', $this->module_info);
- // Run
- $output = $this->{$this->act}();
- }
- else {
+ else
+ {
+ $isTemplatPath = (strpos($this->getTemplatePath(), '/tpl/') !== FALSE);
+ if(!$isTemplatPath)
+ {
+ $this->setTemplatePath(sprintf('%s%s/%s/', $this->module_path, $dir, $skinName));
+ }
+ }
+ }
+
+ $oModuleModel = getModel('module');
+ $oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
+ Context::set('module_info', $this->module_info);
+ // Run
+ $output = $this->{$this->act}();
+ }
+ else
+ {
+ return false;
+ }
+
+ // trigger call
+ $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
+ if(!$triggerOutput->toBool())
+ {
+ $this->setError($triggerOutput->getError());
+ $this->setMessage($triggerOutput->getMessage());
+ return false;
+ }
+
+ // execute an addon(call called_position as after_module_proc)
+ $called_position = 'after_module_proc';
+ $oAddonController = getController('addon');
+ $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
+ @include($addon_file);
+
+ if(is_a($output, 'Object') || is_subclass_of($output, 'Object'))
+ {
+ $this->setError($output->getError());
+ $this->setMessage($output->getMessage());
+
+ if(!$output->toBool())
+ {
return false;
}
+ }
+ // execute api methos of the module if view action is and result is XMLRPC or JSON
+ if($this->module_info->module_type == 'view')
+ {
+ if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON')
+ {
+ $oAPI = getAPI($this->module_info->module, 'api');
+ if(method_exists($oAPI, $this->act))
+ {
+ $oAPI->{$this->act}($this);
+ }
+ }
+ }
+ return true;
+ }
- // trigger call
- $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
- if(!$triggerOutput->toBool()) {
- $this->setError($triggerOutput->getError());
- $this->setMessage($triggerOutput->getMessage());
- return false;
- }
-
- // execute an addon(call called_position as after_module_proc)
- $called_position = 'after_module_proc';
- $oAddonController = &getController('addon');
- $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
- @include($addon_file);
-
- if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
- $this->setError($output->getError());
- $this->setMessage($output->getMessage());
-
- if (!$output->toBool()) return false;
- }
- // execute api methos of the module if view action is and result is XMLRPC or JSON
- if($this->module_info->module_type == 'view'){
- if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
- $oAPI = getAPI($this->module_info->module, 'api');
- if(method_exists($oAPI, $this->act)) {
- $oAPI->{$this->act}($this);
- }
- }
- }
- return true;
- }
- }
+}
?>
diff --git a/classes/object/Object.class.php b/classes/object/Object.class.php
index 96db11478..fe5a0c78b 100644
--- a/classes/object/Object.class.php
+++ b/classes/object/Object.class.php
@@ -1,11 +1,12 @@
setError($error);
$this->setMessage($message);
}
-
/**
* Setter to set error code
*
* @param int $error error code
* @return void
*/
- function setError($error = 0) {
+ function setError($error = 0)
+ {
$this->error = $error;
}
@@ -60,7 +61,8 @@ class Object {
*
* @return int Returns an error code
*/
- function getError() {
+ function getError()
+ {
return $this->error;
}
@@ -91,12 +93,14 @@ class Object {
* @param string $message Error message
* @return bool Alaways returns true.
*/
- function setMessage($message = 'success') {
- if(Context::getLang($message)) $message = Context::getLang($message);
+ function setMessage($message = 'success')
+ {
+ if(Context::getLang($message))
+ $message = Context::getLang($message);
$this->message = $message;
// TODO This method always returns True. We'd better remove it
- return true;
+ return TRUE;
}
/**
@@ -104,7 +108,8 @@ class Object {
*
* @return string Returns message
*/
- function getMessage() {
+ function getMessage()
+ {
return $this->message;
}
@@ -115,7 +120,8 @@ class Object {
* @param mixed $val A value for the variable
* @return void
*/
- function add($key, $val) {
+ function add($key, $val)
+ {
$this->variables[$key] = $val;
}
@@ -130,11 +136,14 @@ class Object {
if(is_object($object))
{
$object = get_object_vars($object);
- }
+ }
if(is_array($object))
{
- foreach($object as $key => $val) $this->variables[$key] = $val;
+ foreach($object as $key => $val)
+ {
+ $this->variables[$key] = $val;
+ }
}
}
@@ -144,20 +153,22 @@ class Object {
* @param string $key
* @return string Returns value to a given key
*/
- function get($key) {
+ function get($key)
+ {
return $this->variables[$key];
}
-
/**
* Method to retrieve an object containing a key/value paris
*
* @return Object Returns an object containing key/value pairs
*/
- function gets() {
+ function gets()
+ {
$num_args = func_num_args();
$args_list = func_get_args();
- for($i=0;$i<$num_args;$i++) {
+ for($i = 0; $i < $num_args; $i++)
+ {
$key = $args_list[$i];
$output->{$key} = $this->get($key);
}
@@ -169,7 +180,8 @@ class Object {
*
* @return array
*/
- function getVariables() {
+ function getVariables()
+ {
return $this->variables;
}
@@ -178,8 +190,13 @@ class Object {
*
* @return Object
*/
- function getObjectVars() {
- foreach($this->variables as $key => $val) $output->{$key} = $val;
+ function getObjectVars()
+ {
+ $output = new stdClass();
+ foreach($this->variables as $key => $val)
+ {
+ $output->{$key} = $val;
+ }
return $output;
}
@@ -188,21 +205,22 @@ class Object {
*
* @return bool Retruns true : error isn't 0 or false : otherwise.
*/
- function toBool() {
+ function toBool()
+ {
// TODO This method is misleading in that it returns true if error is 0, which should be true in boolean representation.
- return $this->error==0?true:false;
+ return $this->error == 0 ? TRUE : FALSE;
}
-
/**
* Method to return either true or false depnding on the value in a 'error' variable
*
* @return bool
*/
- function toBoolean() {
- return $this->toBool();
+ function toBoolean()
+ {
+ return $this->toBool();
}
-}
+}
/* End of file Object.class.php */
/* Location: ./classes/object/Object.class.php */
diff --git a/classes/page/PageHandler.class.php b/classes/page/PageHandler.class.php
index d598b708d..b7123e522 100644
--- a/classes/page/PageHandler.class.php
+++ b/classes/page/PageHandler.class.php
@@ -1,68 +1,92 @@
total_count = $total_count;
- $this->total_page = $total_page;
- $this->cur_page = $cur_page;
- $this->page_count = $page_count;
- $this->point = 0;
+ /**
+ * constructor
+ * @param int $total_count number of total items
+ * @param int $total_page number of total pages
+ * @param int $cur_page current page number
+ * @param int $page_count number of page links displayed at one time
+ * @return void
+ */
- $first_page = $cur_page - (int)($page_count/2);
- if($first_page<1) $first_page = 1;
- $last_page = $total_page;
- if($last_page>$total_page) $last_page = $total_page;
+ function PageHandler($total_count, $total_page, $cur_page, $page_count = 10)
+ {
+ $this->total_count = $total_count;
+ $this->total_page = $total_page;
+ $this->cur_page = $cur_page;
+ $this->page_count = $page_count;
+ $this->point = 0;
- $this->first_page = $first_page;
- $this->last_page = $last_page;
-
- if($total_page < $this->page_count) $this->page_count = $total_page;
- }
-
- /**
- * request next page
- * @return int next page number
- **/
- function getNextPage() {
- $page = $this->first_page+$this->point++;
- if($this->point > $this->page_count || $page > $this->last_page) $page = 0;
- return $page;
- }
-
- /**
- * return number of page that added offset.
- * @param int $offset
- * @return int
- **/
- function getPage($offset)
+ $first_page = $cur_page - (int) ($page_count / 2);
+ if($first_page < 1)
{
- return max(min($this->cur_page + $offset, $this->total_page), '');
+ $first_page = 1;
}
- }
-?>
+
+ if($total_page > $page_count && $first_page + $page_count - 1 > $total_page)
+ {
+ $first_page -= $first_page + $page_count - 1 - $total_page;
+ }
+
+ $last_page = $total_page;
+ if($last_page > $total_page)
+ {
+ $last_page = $total_page;
+ }
+
+ $this->first_page = $first_page;
+ $this->last_page = $last_page;
+
+ if($total_page < $this->page_count)
+ {
+ $this->page_count = $total_page;
+ }
+ }
+
+ /**
+ * request next page
+ * @return int next page number
+ */
+ function getNextPage()
+ {
+ $page = $this->first_page + $this->point++;
+ if($this->point > $this->page_count || $page > $this->last_page)
+ {
+ $page = 0;
+ }
+ return $page;
+ }
+
+ /**
+ * return number of page that added offset.
+ * @param int $offset
+ * @return int
+ */
+ function getPage($offset)
+ {
+ return max(min($this->cur_page + $offset, $this->total_page), '');
+ }
+
+}
+/* End of file PageHandler.class.php */
+/* Location: ./classes/page/PageHandler.class.php */
diff --git a/classes/security/EmbedFilter.class.php b/classes/security/EmbedFilter.class.php
index f674bfbe5..0b5d5dd4f 100644
--- a/classes/security/EmbedFilter.class.php
+++ b/classes/security/EmbedFilter.class.php
@@ -1,13 +1,16 @@
1, 'application/applixware'=>1, 'application/atom+xml'=>1, 'application/atomcat+xml'=>1, 'application/atomsvc+xml'=>1,
- 'application/ccxml+xml'=>1, 'application/cdmi-capability'=>1, 'application/cdmi-container'=>1, 'application/cdmi-domain'=>1, 'application/cdmi-object'=>1,
- 'application/cdmi-queue'=>1, 'application/cu-seeme'=>1, 'application/davmount+xml'=>1, 'application/docbook+xml'=>1, 'application/dssc+der'=>1, 'application/dssc+xml'=>1,
- 'application/ecmascript'=>1, 'application/emma+xml'=>1, 'application/epub+zip'=>1, 'application/exi'=>1, 'application/font-tdpfr'=>1, 'application/gml+xml'=>1,
- 'application/gpx+xml'=>1, 'application/gxf'=>1, 'application/hyperstudio'=>1, 'application/inkml+xml'=>1, 'application/inkml+xml'=>1, 'application/ipfix'=>1,
- 'application/java-archive'=>1, 'application/java-serialized-object'=>1, 'application/java-vm'=>1, 'application/javascript'=>1, 'application/json'=>1,
- 'application/jsonml+json'=>1, 'application/lost+xml'=>1, 'application/mac-binhex40'=>1, 'application/mac-compactpro'=>1, 'application/mads+xml'=>1,
- 'application/marc'=>1, 'application/marcxml+xml'=>1, 'application/mathematica'=>1, 'application/mathematica'=>1, 'application/mathematica'=>1, 'application/mathml+xml'=>1,
- 'application/mbox'=>1, 'application/mediaservercontrol+xml'=>1, 'application/metalink+xml'=>1, 'application/metalink4+xml'=>1, 'application/mets+xml'=>1,
- 'application/mods+xml'=>1, 'application/mp21'=>1, 'application/mp4'=>1, 'application/msword'=>1, 'application/mxf'=>1, 'application/octet-stream'=>1,
- 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1,
- 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1,
- 'application/octet-stream'=>1, 'application/oda'=>1, 'application/oebps-package+xml'=>1, 'application/ogg'=>1, 'application/omdoc+xml'=>1, 'application/onenote'=>1,
- 'application/onenote'=>1, 'application/onenote'=>1, 'application/onenote'=>1, 'application/oxps'=>1, 'application/patch-ops-error+xml'=>1, 'application/pdf'=>1,
- 'application/pgp-encrypted'=>1, 'application/pgp-signature'=>1, 'application/pgp-signature'=>1, 'application/pics-rules'=>1, 'application/pkcs10'=>1,
- 'application/pkcs7-mime'=>1, 'application/pkcs7-mime'=>1, 'application/pkcs7-signature'=>1, 'application/pkcs8'=>1, 'application/pkix-attr-cert'=>1,
- 'application/pkix-cert'=>1, 'application/pkix-crl'=>1, 'application/pkix-pkipath'=>1, 'application/pkixcmp'=>1, 'application/pls+xml'=>1,
- 'application/postscript'=>1, 'application/postscript'=>1, 'application/postscript'=>1, 'application/prs.cww'=>1, 'application/pskc+xml'=>1,
- 'application/rdf+xml'=>1, 'application/reginfo+xml'=>1, 'application/relax-ng-compact-syntax'=>1, 'application/resource-lists+xml'=>1,
- 'application/resource-lists-diff+xml'=>1, 'application/rls-services+xml'=>1, 'application/rpki-ghostbusters'=>1, 'application/rpki-manifest'=>1,
- 'application/rpki-roa'=>1, 'application/rsd+xml'=>1, 'application/rss+xml'=>1, 'application/rtf'=>1, 'application/sbml+xml'=>1, 'application/scvp-cv-request'=>1,
- 'application/scvp-cv-response'=>1, 'application/scvp-vp-request'=>1, 'application/scvp-vp-response'=>1, 'application/sdp'=>1, 'application/set-payment-initiation'=>1,
- 'application/set-registration-initiation'=>1, 'application/shf+xml'=>1, 'application/smil+xml'=>1, 'application/smil+xml'=>1, 'application/sparql-query'=>1,
- 'application/sparql-results+xml'=>1, 'application/srgs'=>1, 'application/srgs+xml'=>1, 'application/sru+xml'=>1, 'application/ssdl+xml'=>1,
- 'application/ssml+xml'=>1, 'application/tei+xml'=>1, 'application/tei+xml'=>1, 'application/thraud+xml'=>1, 'application/timestamped-data'=>1,
- 'application/vnd.3gpp.pic-bw-large'=>1, 'application/vnd.3gpp.pic-bw-small'=>1, 'application/vnd.3gpp.pic-bw-var'=>1, 'application/vnd.3gpp2.tcap'=>1,
- 'application/vnd.3m.post-it-notes'=>1, 'application/vnd.accpac.simply.aso'=>1, 'application/vnd.accpac.simply.imp'=>1, 'application/vnd.acucobol'=>1,
- 'application/vnd.acucorp'=>1, 'application/vnd.acucorp'=>1, 'application/vnd.adobe.air-application-installer-package+zip'=>1, 'application/vnd.adobe.formscentral.fcdt'=>1,
- 'application/vnd.adobe.fxp'=>1, 'application/vnd.adobe.fxp'=>1, 'application/vnd.adobe.xdp+xml'=>1, 'application/vnd.adobe.xfdf'=>1, 'application/vnd.ahead.space'=>1,
- 'application/vnd.airzip.filesecure.azf'=>1, 'application/vnd.airzip.filesecure.azs'=>1, 'application/vnd.amazon.ebook'=>1, 'application/vnd.americandynamics.acc'=>1,
- 'application/vnd.amiga.ami'=>1, 'application/vnd.android.package-archive'=>1, 'application/vnd.anser-web-certificate-issue-initiation'=>1,
- 'application/vnd.anser-web-funds-transfer-initiation'=>1, 'application/vnd.antix.game-component'=>1, 'application/vnd.apple.installer+xml'=>1,
- 'application/vnd.apple.mpegurl'=>1, 'application/vnd.aristanetworks.swi'=>1, 'application/vnd.astraea-software.iota'=>1, 'application/vnd.audiograph'=>1,
- 'application/vnd.blueice.multipass'=>1, 'application/vnd.bmi'=>1, 'application/vnd.businessobjects'=>1, 'application/vnd.chemdraw+xml'=>1,
- 'application/vnd.chipnuts.karaoke-mmd'=>1, 'application/vnd.cinderella'=>1, 'application/vnd.claymore'=>1, 'application/vnd.cloanto.rp9'=>1,
- 'application/vnd.clonk.c4group'=>1, 'application/vnd.clonk.c4group'=>1, 'application/vnd.clonk.c4group'=>1, 'application/vnd.clonk.c4group'=>1,
- 'application/vnd.clonk.c4group'=>1, 'application/vnd.cluetrust.cartomobile-config'=>1, 'application/vnd.cluetrust.cartomobile-config-pkg'=>1,
- 'application/vnd.commonspace'=>1, 'application/vnd.contact.cmsg'=>1, 'application/vnd.cosmocaller'=>1, 'application/vnd.crick.clicker'=>1,
- 'application/vnd.crick.clicker.keyboard'=>1, 'application/vnd.crick.clicker.palette'=>1, 'application/vnd.crick.clicker.template'=>1,
- 'application/vnd.crick.clicker.wordbank'=>1, 'application/vnd.criticaltools.wbs+xml'=>1, 'application/vnd.ctc-posml'=>1, 'application/vnd.cups-ppd'=>1,
- 'application/vnd.curl.car'=>1, 'application/vnd.curl.pcurl'=>1, 'application/vnd.dart'=>1, 'application/vnd.data-vision.rdz'=>1, 'application/vnd.dece.data'=>1,
- 'application/vnd.dece.data'=>1, 'application/vnd.dece.data'=>1, 'application/vnd.dece.data'=>1, 'application/vnd.dece.ttml+xml'=>1, 'application/vnd.dece.ttml+xml'=>1,
- 'application/vnd.dece.unspecified'=>1, 'application/vnd.dece.unspecified'=>1, 'application/vnd.dece.zip'=>1, 'application/vnd.dece.zip'=>1,
- 'application/vnd.denovo.fcselayout-link'=>1, 'application/vnd.dna'=>1, 'application/vnd.dolby.mlp'=>1, 'application/vnd.dpgraph'=>1, 'application/vnd.dreamfactory'=>1,
- 'application/vnd.ds-keypoint'=>1, 'application/vnd.dvb.ait'=>1, 'application/vnd.dvb.service'=>1, 'application/vnd.dynageo'=>1, 'application/vnd.ecowin.chart'=>1,
- 'application/vnd.enliven'=>1, 'application/vnd.epson.esf'=>1, 'application/vnd.epson.msf'=>1, 'application/vnd.epson.quickanime'=>1, 'application/vnd.epson.salt'=>1,
- 'application/vnd.epson.ssf'=>1, 'application/vnd.eszigno3+xml'=>1, 'application/vnd.eszigno3+xml'=>1, 'application/vnd.ezpix-album'=>1, 'application/vnd.ezpix-package'=>1,
- 'application/vnd.fdf'=>1, 'application/vnd.fdsn.mseed'=>1, 'application/vnd.fdsn.seed'=>1, 'application/vnd.fdsn.seed'=>1, 'application/vnd.flographit'=>1,
- 'application/vnd.fluxtime.clip'=>1, 'application/vnd.framemaker'=>1, 'application/vnd.framemaker'=>1, 'application/vnd.framemaker'=>1, 'application/vnd.framemaker'=>1,
- 'application/vnd.frogans.fnc'=>1, 'application/vnd.frogans.ltf'=>1, 'application/vnd.fsc.weblaunch'=>1, 'application/vnd.fujitsu.oasys'=>1,
- 'application/vnd.fujitsu.oasys2'=>1, 'application/vnd.fujitsu.oasys3'=>1, 'application/vnd.fujitsu.oasysgp'=>1, 'application/vnd.fujitsu.oasysprs'=>1,
- 'application/vnd.fujixerox.ddd'=>1, 'application/vnd.fujixerox.docuworks'=>1, 'application/vnd.fujixerox.docuworks.binder'=>1, 'application/vnd.fuzzysheet'=>1,
- 'application/vnd.genomatix.tuxedo'=>1, 'application/vnd.geogebra.file'=>1, 'application/vnd.geogebra.tool'=>1, 'application/vnd.geometry-explorer'=>1,
- 'application/vnd.geometry-explorer'=>1, 'application/vnd.geonext'=>1, 'application/vnd.geoplan'=>1, 'application/vnd.geospace'=>1, 'application/vnd.gmx'=>1,
- 'application/vnd.google-earth.kml+xml'=>1, 'application/vnd.google-earth.kmz'=>1, 'application/vnd.grafeq'=>1, 'application/vnd.grafeq'=>1,
- 'application/vnd.groove-account'=>1, 'application/vnd.groove-help'=>1, 'application/vnd.groove-identity-message'=>1, 'application/vnd.groove-injector'=>1,
- 'application/vnd.groove-tool-message'=>1, 'application/vnd.groove-tool-template'=>1, 'application/vnd.groove-vcard'=>1, 'application/vnd.hal+xml'=>1,
- 'application/vnd.handheld-entertainment+xml'=>1, 'application/vnd.hbci'=>1, 'application/vnd.hhe.lesson-player'=>1, 'application/vnd.hp-hpgl'=>1,
- 'application/vnd.hp-hpid'=>1, 'application/vnd.hp-hps'=>1, 'application/vnd.hp-jlyt'=>1, 'application/vnd.hp-pcl'=>1, 'application/vnd.hp-pclxl'=>1,
- 'application/vnd.hydrostatix.sof-data'=>1, 'application/vnd.ibm.minipay'=>1, 'application/vnd.ibm.modcap'=>1, 'application/vnd.ibm.modcap'=>1, 'application/vnd.ibm.modcap'=>1,
- 'application/vnd.ibm.rights-management'=>1, 'application/vnd.ibm.secure-container'=>1, 'application/vnd.iccprofile'=>1, 'application/vnd.iccprofile'=>1,
- 'application/vnd.igloader'=>1, 'application/vnd.immervision-ivp'=>1, 'application/vnd.immervision-ivu'=>1, 'application/vnd.insors.igm'=>1, 'application/vnd.intercon.formnet'=>1,
- 'application/vnd.intercon.formnet'=>1, 'application/vnd.intergeo'=>1, 'application/vnd.intu.qbo'=>1, 'application/vnd.intu.qfx'=>1, 'application/vnd.ipunplugged.rcprofile'=>1,
- 'application/vnd.irepository.package+xml'=>1, 'application/vnd.is-xpr'=>1, 'application/vnd.isac.fcs'=>1, 'application/vnd.jam'=>1, 'application/vnd.jcp.javame.midlet-rms'=>1,
- 'application/vnd.jisp'=>1, 'application/vnd.joost.joda-archive'=>1, 'application/vnd.kahootz'=>1, 'application/vnd.kahootz'=>1, 'application/vnd.kde.karbon'=>1,
- 'application/vnd.kde.kchart'=>1, 'application/vnd.kde.kformula'=>1, 'application/vnd.kde.kivio'=>1, 'application/vnd.kde.kontour'=>1, 'application/vnd.kde.kpresenter'=>1,
- 'application/vnd.kde.kpresenter'=>1, 'application/vnd.kde.kspread'=>1, 'application/vnd.kde.kword'=>1, 'application/vnd.kde.kword'=>1, 'application/vnd.kenameaapp'=>1,
- 'application/vnd.kidspiration'=>1, 'application/vnd.kinar'=>1, 'application/vnd.kinar'=>1, 'application/vnd.koan'=>1, 'application/vnd.koan'=>1, 'application/vnd.koan'=>1,
- 'application/vnd.koan'=>1, 'application/vnd.kodak-descriptor'=>1, 'application/vnd.las.las+xml'=>1, 'application/vnd.llamagraphics.life-balance.desktop'=>1,
- 'application/vnd.llamagraphics.life-balance.exchange+xml'=>1, 'application/vnd.lotus-1-2-3'=>1, 'application/vnd.lotus-approach'=>1, 'application/vnd.lotus-freelance'=>1,
- 'application/vnd.lotus-notes'=>1, 'application/vnd.lotus-organizer'=>1, 'application/vnd.lotus-screencam'=>1, 'application/vnd.lotus-wordpro'=>1,
- 'application/vnd.macports.portpkg'=>1, 'application/vnd.mcd'=>1, 'application/vnd.medcalcdata'=>1, 'application/vnd.mediastation.cdkey'=>1, 'application/vnd.mfer'=>1,
- 'application/vnd.mfmp'=>1, 'application/vnd.micrografx.flo'=>1, 'application/vnd.micrografx.igx'=>1, 'application/vnd.mif'=>1, 'application/vnd.mobius.daf'=>1,
- 'application/vnd.mobius.dis'=>1, 'application/vnd.mobius.mbk'=>1, 'application/vnd.mobius.mqy'=>1, 'application/vnd.mobius.msl'=>1, 'application/vnd.mobius.plc'=>1,
- 'application/vnd.mobius.txf'=>1, 'application/vnd.mophun.application'=>1, 'application/vnd.mophun.certificate'=>1, 'application/vnd.mozilla.xul+xml'=>1,
- 'application/vnd.ms-artgalry'=>1, 'application/vnd.ms-cab-compressed'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1,
- 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel.addin.macroenabled.12'=>1,
- 'application/vnd.ms-excel.sheet.binary.macroenabled.12'=>1, 'application/vnd.ms-excel.sheet.macroenabled.12'=>1, 'application/vnd.ms-excel.template.macroenabled.12'=>1,
- 'application/vnd.ms-fontobject'=>1, 'application/vnd.ms-htmlhelp'=>1, 'application/vnd.ms-ims'=>1, 'application/vnd.ms-lrm'=>1, 'application/vnd.ms-officetheme'=>1,
- 'application/vnd.ms-pki.seccat'=>1, 'application/vnd.ms-pki.stl'=>1, 'application/vnd.ms-powerpoint'=>1, 'application/vnd.ms-powerpoint'=>1,
- 'application/vnd.ms-powerpoint'=>1, 'application/vnd.ms-powerpoint.addin.macroenabled.12'=>1, 'application/vnd.ms-powerpoint.presentation.macroenabled.12'=>1,
- 'application/vnd.ms-powerpoint.slide.macroenabled.12'=>1, 'application/vnd.ms-powerpoint.slideshow.macroenabled.12'=>1,
- 'application/vnd.ms-powerpoint.template.macroenabled.12'=>1, 'application/vnd.ms-project'=>1, 'application/vnd.ms-project'=>1,
- 'application/vnd.ms-word.document.macroenabled.12'=>1, 'application/vnd.ms-word.template.macroenabled.12'=>1, 'application/vnd.ms-works'=>1,
- 'application/vnd.ms-works'=>1, 'application/vnd.ms-works'=>1, 'application/vnd.ms-works'=>1, 'application/vnd.ms-wpl'=>1, 'application/vnd.ms-xpsdocument'=>1,
- 'application/vnd.mseq'=>1, 'application/vnd.musician'=>1, 'application/vnd.muvee.style'=>1, 'application/vnd.mynfc'=>1, 'application/vnd.neurolanguage.nlu'=>1,
- 'application/vnd.nitf'=>1, 'application/vnd.nitf'=>1, 'application/vnd.noblenet-directory'=>1, 'application/vnd.noblenet-sealer'=>1, 'application/vnd.noblenet-web'=>1,
- 'application/vnd.nokia.n-gage.data'=>1, 'application/vnd.nokia.n-gage.symbian.install'=>1, 'application/vnd.nokia.radio-preset'=>1, 'application/vnd.nokia.radio-presets'=>1,
- 'application/vnd.novadigm.edm'=>1, 'application/vnd.novadigm.edx'=>1, 'application/vnd.novadigm.ext'=>1, 'application/vnd.oasis.opendocument.chart'=>1,
- 'application/vnd.oasis.opendocument.chart-template'=>1, 'application/vnd.oasis.opendocument.database'=>1, 'application/vnd.oasis.opendocument.formula'=>1,
- 'application/vnd.oasis.opendocument.formula-template'=>1, 'application/vnd.oasis.opendocument.graphics'=>1, 'application/vnd.oasis.opendocument.graphics-template'=>1,
- 'application/vnd.oasis.opendocument.image'=>1, 'application/vnd.oasis.opendocument.image-template'=>1, 'application/vnd.oasis.opendocument.presentation'=>1,
- 'application/vnd.oasis.opendocument.presentation-template'=>1, 'application/vnd.oasis.opendocument.spreadsheet'=>1, 'application/vnd.oasis.opendocument.spreadsheet-template'=>1,
- 'application/vnd.oasis.opendocument.text'=>1, 'application/vnd.oasis.opendocument.text-master'=>1, 'application/vnd.oasis.opendocument.text-template'=>1,
- 'application/vnd.oasis.opendocument.text-web'=>1, 'application/vnd.olpc-sugar'=>1, 'application/vnd.oma.dd2+xml'=>1, 'application/vnd.openofficeorg.extension'=>1,
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation'=>1, 'application/vnd.openxmlformats-officedocument.presentationml.slide'=>1,
- 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'=>1, 'application/vnd.openxmlformats-officedocument.presentationml.template'=>1,
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'=>1, 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'=>1,
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'=>1, 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'=>1,
- 'application/vnd.osgeo.mapguide.package'=>1, 'application/vnd.osgi.dp'=>1, 'application/vnd.osgi.subsystem'=>1, 'application/vnd.palm'=>1, 'application/vnd.palm'=>1,
- 'application/vnd.palm'=>1, 'application/vnd.pawaafile'=>1, 'application/vnd.pg.format'=>1, 'application/vnd.pg.osasli'=>1, 'application/vnd.picsel'=>1, 'application/vnd.pmi.widget'=>1,
- 'application/vnd.pocketlearn'=>1, 'application/vnd.powerbuilder6'=>1, 'application/vnd.previewsystems.box'=>1, 'application/vnd.proteus.magazine'=>1,
- 'application/vnd.publishare-delta-tree'=>1, 'application/vnd.pvi.ptid1'=>1, 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1,
- 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1,
- 'application/vnd.realvnc.bed'=>1, 'application/vnd.recordare.musicxml'=>1, 'application/vnd.recordare.musicxml+xml'=>1, 'application/vnd.rig.cryptonote'=>1,
- 'application/vnd.rim.cod'=>1, 'application/vnd.rn-realmedia'=>1, 'application/vnd.rn-realmedia-vbr'=>1, 'application/vnd.route66.link66+xml'=>1, 'application/vnd.sailingtracker.track'=>1,
- 'application/vnd.seemail'=>1, 'application/vnd.sema'=>1, 'application/vnd.semd'=>1, 'application/vnd.semf'=>1, 'application/vnd.shana.informed.formdata'=>1,
- 'application/vnd.shana.informed.formtemplate'=>1, 'application/vnd.shana.informed.interchange'=>1, 'application/vnd.shana.informed.package'=>1, 'application/vnd.simtech-mindmapper'=>1,
- 'application/vnd.simtech-mindmapper'=>1, 'application/vnd.smaf'=>1, 'application/vnd.smart.teacher'=>1, 'application/vnd.solent.sdkm+xml'=>1, 'application/vnd.solent.sdkm+xml'=>1,
- 'application/vnd.spotfire.dxp'=>1, 'application/vnd.spotfire.sfs'=>1, 'application/vnd.stardivision.calc'=>1, 'application/vnd.stardivision.draw'=>1,
- 'application/vnd.stardivision.impress'=>1, 'application/vnd.stardivision.math'=>1, 'application/vnd.stardivision.writer'=>1, 'application/vnd.stardivision.writer'=>1,
- 'application/vnd.stardivision.writer-global'=>1, 'application/vnd.stepmania.package'=>1, 'application/vnd.stepmania.stepchart'=>1, 'application/vnd.sun.xml.calc'=>1,
- 'application/vnd.sun.xml.calc.template'=>1, 'application/vnd.sun.xml.draw'=>1, 'application/vnd.sun.xml.draw.template'=>1, 'application/vnd.sun.xml.impress'=>1,
- 'application/vnd.sun.xml.impress.template'=>1, 'application/vnd.sun.xml.math'=>1, 'application/vnd.sun.xml.writer'=>1, 'application/vnd.sun.xml.writer.global'=>1,
- 'application/vnd.sun.xml.writer.template'=>1, 'application/vnd.sus-calendar'=>1, 'application/vnd.sus-calendar'=>1, 'application/vnd.svd'=>1, 'application/vnd.symbian.install'=>1,
- 'application/vnd.symbian.install'=>1, 'application/vnd.syncml+xml'=>1, 'application/vnd.syncml.dm+wbxml'=>1, 'application/vnd.syncml.dm+xml'=>1,
- 'application/vnd.tao.intent-module-archive'=>1, 'application/vnd.tcpdump.pcap'=>1, 'application/vnd.tcpdump.pcap'=>1, 'application/vnd.tcpdump.pcap'=>1,
- 'application/vnd.tmobile-livetv'=>1, 'application/vnd.trid.tpt'=>1, 'application/vnd.triscape.mxs'=>1, 'application/vnd.trueapp'=>1, 'application/vnd.ufdl'=>1, 'application/vnd.ufdl'=>1,
- 'application/vnd.uiq.theme'=>1, 'application/vnd.umajin'=>1, 'application/vnd.unity'=>1, 'application/vnd.uoml+xml'=>1, 'application/vnd.vcx'=>1, 'application/vnd.visio'=>1,
- 'application/vnd.visio'=>1, 'application/vnd.visio'=>1, 'application/vnd.visio'=>1, 'application/vnd.visionary'=>1, 'application/vnd.vsf'=>1, 'application/vnd.wap.wbxml'=>1,
- 'application/vnd.wap.wmlc'=>1, 'application/vnd.wap.wmlscriptc'=>1, 'application/vnd.webturbo'=>1, 'application/vnd.wolfram.player'=>1, 'application/vnd.wordperfect'=>1,
- 'application/vnd.wqd'=>1, 'application/vnd.wt.stf'=>1, 'application/vnd.xara'=>1, 'application/vnd.xfdl'=>1, 'application/vnd.yamaha.hv-dic'=>1, 'application/vnd.yamaha.hv-script'=>1,
- 'application/vnd.yamaha.hv-voice'=>1, 'application/vnd.yamaha.openscoreformat'=>1, 'application/vnd.yamaha.openscoreformat.osfpvg+xml'=>1, 'application/vnd.yamaha.smaf-audio'=>1,
- 'application/vnd.yamaha.smaf-phrase'=>1, 'application/vnd.yellowriver-custom-menu'=>1, 'application/vnd.zul'=>1, 'application/vnd.zul'=>1, 'application/vnd.zzazz.deck+xml'=>1,
- 'application/voicexml+xml'=>1, 'application/widget'=>1, 'application/winhlp'=>1, 'application/wsdl+xml'=>1, 'application/wspolicy+xml'=>1, 'application/x-7z-compressed'=>1,
- 'application/x-abiword'=>1, 'application/x-ace-compressed'=>1, 'application/x-apple-diskimage'=>1, 'application/x-authorware-bin'=>1, 'application/x-authorware-bin'=>1,
- 'application/x-authorware-bin'=>1, 'application/x-authorware-bin'=>1, 'application/x-authorware-map'=>1, 'application/x-authorware-seg'=>1, 'application/x-bcpio'=>1,
- 'application/x-bittorrent'=>1, 'application/x-blorb'=>1, 'application/x-blorb'=>1, 'application/x-bzip'=>1, 'application/x-bzip2'=>1, 'application/x-bzip2'=>1, 'application/x-cbr'=>1,
- 'application/x-cbr'=>1, 'application/x-cbr'=>1, 'application/x-cbr'=>1, 'application/x-cbr'=>1, 'application/x-cdlink'=>1, 'application/x-cfs-compressed'=>1, 'application/x-chat'=>1,
- 'application/x-chess-pgn'=>1, 'application/x-conference'=>1, 'application/x-cpio'=>1, 'application/x-csh'=>1, 'application/x-debian-package'=>1, 'application/x-debian-package'=>1,
- 'application/x-dgc-compressed'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1,
- 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-doom'=>1, 'application/x-dtbncx+xml'=>1,
- 'application/x-dtbook+xml'=>1, 'application/x-dtbresource+xml'=>1, 'application/x-dvi'=>1, 'application/x-envoy'=>1, 'application/x-eva'=>1, 'application/x-font-bdf'=>1,
- 'application/x-font-ghostscript'=>1, 'application/x-font-linux-psf'=>1, 'application/x-font-otf'=>1, 'application/x-font-pcf'=>1, 'application/x-font-snf'=>1,
- 'application/x-font-ttf'=>1, 'application/x-font-ttf'=>1, 'application/x-font-type1'=>1, 'application/x-font-type1'=>1, 'application/x-font-type1'=>1, 'application/x-font-type1'=>1,
- 'application/x-font-woff'=>1, 'application/x-freearc'=>1, 'application/x-futuresplash'=>1, 'application/x-gca-compressed'=>1, 'application/x-glulx'=>1, 'application/x-gnumeric'=>1,
- 'application/x-gramps-xml'=>1, 'application/x-gtar'=>1, 'application/x-hdf'=>1, 'application/x-install-instructions'=>1, 'application/x-iso9660-image'=>1,
- 'application/x-java-jnlp-file'=>1, 'application/x-latex'=>1, 'application/x-lzh-compressed'=>1, 'application/x-lzh-compressed'=>1, 'application/x-mie'=>1,
- 'application/x-mobipocket-ebook'=>1, 'application/x-mobipocket-ebook'=>1, 'application/x-ms-application'=>1, 'application/x-ms-shortcut'=>1, 'application/x-ms-wmd'=>1,
- 'application/x-ms-wmz'=>1, 'application/x-ms-xbap'=>1, 'application/x-msaccess'=>1, 'application/x-msbinder'=>1, 'application/x-mscardfile'=>1, 'application/x-msclip'=>1,
- 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msmediaview'=>1,
- 'application/x-msmediaview'=>1, 'application/x-msmediaview'=>1, 'application/x-msmetafile'=>1, 'application/x-msmetafile'=>1, 'application/x-msmetafile'=>1, 'application/x-msmetafile'=>1,
- 'application/x-msmoney'=>1, 'application/x-mspublisher'=>1, 'application/x-msschedule'=>1, 'application/x-msterminal'=>1, 'application/x-mswrite'=>1, 'application/x-netcdf'=>1,
- 'application/x-netcdf'=>1, 'application/x-nzb'=>1, 'application/x-pkcs12'=>1, 'application/x-pkcs12'=>1, 'application/x-pkcs7-certificates'=>1, 'application/x-pkcs7-certificates'=>1,
- 'application/x-pkcs7-certreqresp'=>1, 'application/x-rar-compressed'=>1, 'application/x-research-info-systems'=>1, 'application/x-sh'=>1, 'application/x-shar'=>1,
- 'application/x-shockwave-flash'=>1, 'application/x-silverlight-app'=>1, 'application/x-silverlight-2'=>1, 'application/x-sql'=>1, 'application/x-stuffit'=>1, 'application/x-stuffitx'=>1,
- 'application/x-subrip'=>1, 'application/x-sv4cpio'=>1, 'application/x-sv4crc'=>1, 'application/x-t3vm-image'=>1, 'application/x-tads'=>1, 'application/x-tar'=>1, 'application/x-tcl'=>1,
- 'application/x-tex'=>1, 'application/x-tex-tfm'=>1, 'application/x-texinfo'=>1, 'application/x-texinfo'=>1, 'application/x-tgif'=>1, 'application/x-ustar'=>1, 'application/x-wais-source'=>1,
- 'application/x-x509-ca-cert'=>1, 'application/x-x509-ca-cert'=>1, 'application/x-xfig'=>1, 'application/x-xliff+xml'=>1, 'application/x-xpinstall'=>1, 'application/x-xz'=>1,
- 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1,
- 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/xaml+xml'=>1, 'application/xcap-diff+xml'=>1, 'application/xenc+xml'=>1, 'application/xhtml+xml'=>1,
- 'application/xhtml+xml'=>1, 'application/xml'=>1, 'application/xml'=>1, 'application/xml-dtd'=>1, 'application/xop+xml'=>1, 'application/xproc+xml'=>1, 'application/xslt+xml'=>1,
- 'application/xspf+xml'=>1, 'application/xv+xml'=>1, 'application/xv+xml'=>1, 'application/xv+xml'=>1, 'application/xv+xml'=>1, 'application/yang'=>1, 'application/yin+xml'=>1,
- 'application/zip'=>1, 'audio/adpcm'=>1, 'audio/basic'=>1, 'audio/basic'=>1, 'audio/midi'=>1, 'audio/midi'=>1, 'audio/midi'=>1, 'audio/midi'=>1, 'audio/mp4'=>1, 'audio/mpeg'=>1,
- 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/ogg'=>1, 'audio/ogg'=>1, 'audio/ogg'=>1, 'audio/s3m'=>1, 'audio/silk'=>1,
- 'audio/vnd.dece.audio'=>1, 'audio/vnd.dece.audio'=>1, 'audio/vnd.digital-winds'=>1, 'audio/vnd.dra'=>1, 'audio/vnd.dts'=>1, 'audio/vnd.dts.hd'=>1, 'audio/vnd.lucent.voice'=>1,
- 'audio/vnd.ms-playready.media.pya'=>1, 'audio/vnd.nuera.ecelp4800'=>1, 'audio/vnd.nuera.ecelp7470'=>1, 'audio/vnd.nuera.ecelp9600'=>1, 'audio/vnd.rip'=>1, 'audio/webm'=>1,
- 'audio/x-aac'=>1, 'audio/x-aiff'=>1, 'audio/x-aiff'=>1, 'audio/x-aiff'=>1, 'audio/x-caf'=>1, 'audio/x-flac'=>1, 'audio/x-matroska'=>1, 'audio/x-mpegurl'=>1, 'audio/x-ms-wax'=>1,
- 'audio/x-ms-wma'=>1, 'audio/x-pn-realaudio'=>1, 'audio/x-pn-realaudio'=>1, 'audio/x-pn-realaudio-plugin'=>1, 'audio/x-wav'=>1, 'audio/xm'=>1, 'chemical/x-cdx'=>1, 'chemical/x-cif'=>1,
- 'chemical/x-cmdf'=>1, 'chemical/x-cml'=>1, 'chemical/x-csml'=>1, 'chemical/x-xyz'=>1, 'image/bmp'=>1, 'image/cgm'=>1, 'image/g3fax'=>1, 'image/gif'=>1, 'image/ief'=>1, 'image/jpeg'=>1,
- 'image/jpeg'=>1, 'image/jpeg'=>1, 'image/ktx'=>1, 'image/png'=>1, 'image/prs.btif'=>1, 'image/sgi'=>1, 'image/svg+xml'=>1, 'image/svg+xml'=>1, 'image/tiff'=>1, 'image/tiff'=>1,
- 'image/vnd.adobe.photoshop'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dvb.subtitle'=>1,
- 'image/vnd.djvu'=>1, 'image/vnd.djvu'=>1, 'image/vnd.dwg'=>1, 'image/vnd.dxf'=>1, 'image/vnd.fastbidsheet'=>1, 'image/vnd.fpx'=>1, 'image/vnd.fst'=>1, 'image/vnd.fujixerox.edmics-mmr'=>1,
- 'image/vnd.fujixerox.edmics-rlc'=>1, 'image/vnd.ms-modi'=>1, 'image/vnd.ms-photo'=>1, 'image/vnd.net-fpx'=>1, 'image/vnd.wap.wbmp'=>1, 'image/vnd.xiff'=>1, 'image/webp'=>1,
- 'image/x-3ds'=>1, 'image/x-cmu-raster'=>1, 'image/x-cmx'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1,
- 'image/x-icon'=>1, 'image/x-mrsid-image'=>1, 'image/x-pcx'=>1, 'image/x-pict'=>1, 'image/x-pict'=>1, 'image/x-portable-anymap'=>1, 'image/x-portable-bitmap'=>1,
- 'image/x-portable-graymap'=>1, 'image/x-portable-pixmap'=>1, 'image/x-rgb'=>1, 'image/x-tga'=>1, 'image/x-xbitmap'=>1, 'image/x-xpixmap'=>1, 'image/x-xwindowdump'=>1,
- 'message/rfc822'=>1, 'message/rfc822'=>1, 'model/iges'=>1, 'model/iges'=>1, 'model/mesh'=>1, 'model/mesh'=>1, 'model/mesh'=>1, 'model/vnd.collada+xml'=>1, 'model/vnd.dwf'=>1,
- 'model/vnd.gdl'=>1, 'model/vnd.gtw'=>1, 'model/vnd.mts'=>1, 'model/vnd.vtu'=>1, 'model/vrml'=>1, 'model/vrml'=>1, 'model/x3d+binary'=>1, 'model/x3d+binary'=>1, 'model/x3d+vrml'=>1,
- 'model/x3d+vrml'=>1, 'model/x3d+xml'=>1, 'model/x3d+xml'=>1, 'video/3gpp'=>1, 'video/3gpp2'=>1, 'video/h261'=>1, 'video/h263'=>1, 'video/h264'=>1, 'video/jpeg'=>1, 'video/jpm'=>1,
- 'video/jpm'=>1, 'video/mj2'=>1, 'video/mj2'=>1, 'video/mp4'=>1, 'video/mp4'=>1, 'video/mp4'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1,
- 'video/ogg'=>1, 'video/quicktime'=>1, 'video/quicktime'=>1, 'video/vnd.dece.hd'=>1, 'video/vnd.dece.hd'=>1, 'video/vnd.dece.mobile'=>1, 'video/vnd.dece.mobile'=>1, 'video/vnd.dece.pd'=>1,
- 'video/vnd.dece.pd'=>1, 'video/vnd.dece.sd'=>1, 'video/vnd.dece.sd'=>1, 'video/vnd.dece.video'=>1, 'video/vnd.dece.video'=>1, 'video/vnd.dvb.file'=>1, 'video/vnd.fvt'=>1,
- 'video/vnd.mpegurl'=>1, 'video/vnd.mpegurl'=>1, 'video/vnd.ms-playready.media.pyv'=>1, 'video/vnd.uvvu.mp4'=>1, 'video/vnd.uvvu.mp4'=>1, 'video/vnd.vivo'=>1, 'video/webm'=>1,
- 'video/x-f4v'=>1, 'video/x-fli'=>1, 'video/x-flv'=>1, 'video/x-m4v'=>1, 'video/x-matroska'=>1, 'video/x-matroska'=>1, 'video/x-matroska'=>1, 'video/x-mng'=>1, 'video/x-ms-asf'=>1,
- 'video/x-ms-asf'=>1, 'video/x-ms-vob'=>1, 'video/x-ms-wm'=>1, 'video/x-ms-wmv'=>1, 'video/x-ms-wmx'=>1, 'video/x-ms-wvx'=>1, 'video/x-msvideo'=>1, 'video/x-sgi-movie'=>1,
- 'video/x-smv'=>1, 'x-conference/x-cooltalk'=>1
+ var $mimeTypeList = array('application/andrew-inset' => 1, 'application/applixware' => 1, 'application/atom+xml' => 1, 'application/atomcat+xml' => 1, 'application/atomsvc+xml' => 1,
+ 'application/ccxml+xml' => 1, 'application/cdmi-capability' => 1, 'application/cdmi-container' => 1, 'application/cdmi-domain' => 1, 'application/cdmi-object' => 1,
+ 'application/cdmi-queue' => 1, 'application/cu-seeme' => 1, 'application/davmount+xml' => 1, 'application/docbook+xml' => 1, 'application/dssc+der' => 1, 'application/dssc+xml' => 1,
+ 'application/ecmascript' => 1, 'application/emma+xml' => 1, 'application/epub+zip' => 1, 'application/exi' => 1, 'application/font-tdpfr' => 1, 'application/gml+xml' => 1,
+ 'application/gpx+xml' => 1, 'application/gxf' => 1, 'application/hyperstudio' => 1, 'application/inkml+xml' => 1, 'application/inkml+xml' => 1, 'application/ipfix' => 1,
+ 'application/java-archive' => 1, 'application/java-serialized-object' => 1, 'application/java-vm' => 1, 'application/javascript' => 1, 'application/json' => 1,
+ 'application/jsonml+json' => 1, 'application/lost+xml' => 1, 'application/mac-binhex40' => 1, 'application/mac-compactpro' => 1, 'application/mads+xml' => 1,
+ 'application/marc' => 1, 'application/marcxml+xml' => 1, 'application/mathematica' => 1, 'application/mathematica' => 1, 'application/mathematica' => 1, 'application/mathml+xml' => 1,
+ 'application/mbox' => 1, 'application/mediaservercontrol+xml' => 1, 'application/metalink+xml' => 1, 'application/metalink4+xml' => 1, 'application/mets+xml' => 1,
+ 'application/mods+xml' => 1, 'application/mp21' => 1, 'application/mp4' => 1, 'application/msword' => 1, 'application/mxf' => 1, 'application/octet-stream' => 1,
+ 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1,
+ 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1,
+ 'application/octet-stream' => 1, 'application/oda' => 1, 'application/oebps-package+xml' => 1, 'application/ogg' => 1, 'application/omdoc+xml' => 1, 'application/onenote' => 1,
+ 'application/onenote' => 1, 'application/onenote' => 1, 'application/onenote' => 1, 'application/oxps' => 1, 'application/patch-ops-error+xml' => 1, 'application/pdf' => 1,
+ 'application/pgp-encrypted' => 1, 'application/pgp-signature' => 1, 'application/pgp-signature' => 1, 'application/pics-rules' => 1, 'application/pkcs10' => 1,
+ 'application/pkcs7-mime' => 1, 'application/pkcs7-mime' => 1, 'application/pkcs7-signature' => 1, 'application/pkcs8' => 1, 'application/pkix-attr-cert' => 1,
+ 'application/pkix-cert' => 1, 'application/pkix-crl' => 1, 'application/pkix-pkipath' => 1, 'application/pkixcmp' => 1, 'application/pls+xml' => 1,
+ 'application/postscript' => 1, 'application/postscript' => 1, 'application/postscript' => 1, 'application/prs.cww' => 1, 'application/pskc+xml' => 1,
+ 'application/rdf+xml' => 1, 'application/reginfo+xml' => 1, 'application/relax-ng-compact-syntax' => 1, 'application/resource-lists+xml' => 1,
+ 'application/resource-lists-diff+xml' => 1, 'application/rls-services+xml' => 1, 'application/rpki-ghostbusters' => 1, 'application/rpki-manifest' => 1,
+ 'application/rpki-roa' => 1, 'application/rsd+xml' => 1, 'application/rss+xml' => 1, 'application/rtf' => 1, 'application/sbml+xml' => 1, 'application/scvp-cv-request' => 1,
+ 'application/scvp-cv-response' => 1, 'application/scvp-vp-request' => 1, 'application/scvp-vp-response' => 1, 'application/sdp' => 1, 'application/set-payment-initiation' => 1,
+ 'application/set-registration-initiation' => 1, 'application/shf+xml' => 1, 'application/smil+xml' => 1, 'application/smil+xml' => 1, 'application/sparql-query' => 1,
+ 'application/sparql-results+xml' => 1, 'application/srgs' => 1, 'application/srgs+xml' => 1, 'application/sru+xml' => 1, 'application/ssdl+xml' => 1,
+ 'application/ssml+xml' => 1, 'application/tei+xml' => 1, 'application/tei+xml' => 1, 'application/thraud+xml' => 1, 'application/timestamped-data' => 1,
+ 'application/vnd.3gpp.pic-bw-large' => 1, 'application/vnd.3gpp.pic-bw-small' => 1, 'application/vnd.3gpp.pic-bw-var' => 1, 'application/vnd.3gpp2.tcap' => 1,
+ 'application/vnd.3m.post-it-notes' => 1, 'application/vnd.accpac.simply.aso' => 1, 'application/vnd.accpac.simply.imp' => 1, 'application/vnd.acucobol' => 1,
+ 'application/vnd.acucorp' => 1, 'application/vnd.acucorp' => 1, 'application/vnd.adobe.air-application-installer-package+zip' => 1, 'application/vnd.adobe.formscentral.fcdt' => 1,
+ 'application/vnd.adobe.fxp' => 1, 'application/vnd.adobe.fxp' => 1, 'application/vnd.adobe.xdp+xml' => 1, 'application/vnd.adobe.xfdf' => 1, 'application/vnd.ahead.space' => 1,
+ 'application/vnd.airzip.filesecure.azf' => 1, 'application/vnd.airzip.filesecure.azs' => 1, 'application/vnd.amazon.ebook' => 1, 'application/vnd.americandynamics.acc' => 1,
+ 'application/vnd.amiga.ami' => 1, 'application/vnd.android.package-archive' => 1, 'application/vnd.anser-web-certificate-issue-initiation' => 1,
+ 'application/vnd.anser-web-funds-transfer-initiation' => 1, 'application/vnd.antix.game-component' => 1, 'application/vnd.apple.installer+xml' => 1,
+ 'application/vnd.apple.mpegurl' => 1, 'application/vnd.aristanetworks.swi' => 1, 'application/vnd.astraea-software.iota' => 1, 'application/vnd.audiograph' => 1,
+ 'application/vnd.blueice.multipass' => 1, 'application/vnd.bmi' => 1, 'application/vnd.businessobjects' => 1, 'application/vnd.chemdraw+xml' => 1,
+ 'application/vnd.chipnuts.karaoke-mmd' => 1, 'application/vnd.cinderella' => 1, 'application/vnd.claymore' => 1, 'application/vnd.cloanto.rp9' => 1,
+ 'application/vnd.clonk.c4group' => 1, 'application/vnd.clonk.c4group' => 1, 'application/vnd.clonk.c4group' => 1, 'application/vnd.clonk.c4group' => 1,
+ 'application/vnd.clonk.c4group' => 1, 'application/vnd.cluetrust.cartomobile-config' => 1, 'application/vnd.cluetrust.cartomobile-config-pkg' => 1,
+ 'application/vnd.commonspace' => 1, 'application/vnd.contact.cmsg' => 1, 'application/vnd.cosmocaller' => 1, 'application/vnd.crick.clicker' => 1,
+ 'application/vnd.crick.clicker.keyboard' => 1, 'application/vnd.crick.clicker.palette' => 1, 'application/vnd.crick.clicker.template' => 1,
+ 'application/vnd.crick.clicker.wordbank' => 1, 'application/vnd.criticaltools.wbs+xml' => 1, 'application/vnd.ctc-posml' => 1, 'application/vnd.cups-ppd' => 1,
+ 'application/vnd.curl.car' => 1, 'application/vnd.curl.pcurl' => 1, 'application/vnd.dart' => 1, 'application/vnd.data-vision.rdz' => 1, 'application/vnd.dece.data' => 1,
+ 'application/vnd.dece.data' => 1, 'application/vnd.dece.data' => 1, 'application/vnd.dece.data' => 1, 'application/vnd.dece.ttml+xml' => 1, 'application/vnd.dece.ttml+xml' => 1,
+ 'application/vnd.dece.unspecified' => 1, 'application/vnd.dece.unspecified' => 1, 'application/vnd.dece.zip' => 1, 'application/vnd.dece.zip' => 1,
+ 'application/vnd.denovo.fcselayout-link' => 1, 'application/vnd.dna' => 1, 'application/vnd.dolby.mlp' => 1, 'application/vnd.dpgraph' => 1, 'application/vnd.dreamfactory' => 1,
+ 'application/vnd.ds-keypoint' => 1, 'application/vnd.dvb.ait' => 1, 'application/vnd.dvb.service' => 1, 'application/vnd.dynageo' => 1, 'application/vnd.ecowin.chart' => 1,
+ 'application/vnd.enliven' => 1, 'application/vnd.epson.esf' => 1, 'application/vnd.epson.msf' => 1, 'application/vnd.epson.quickanime' => 1, 'application/vnd.epson.salt' => 1,
+ 'application/vnd.epson.ssf' => 1, 'application/vnd.eszigno3+xml' => 1, 'application/vnd.eszigno3+xml' => 1, 'application/vnd.ezpix-album' => 1, 'application/vnd.ezpix-package' => 1,
+ 'application/vnd.fdf' => 1, 'application/vnd.fdsn.mseed' => 1, 'application/vnd.fdsn.seed' => 1, 'application/vnd.fdsn.seed' => 1, 'application/vnd.flographit' => 1,
+ 'application/vnd.fluxtime.clip' => 1, 'application/vnd.framemaker' => 1, 'application/vnd.framemaker' => 1, 'application/vnd.framemaker' => 1, 'application/vnd.framemaker' => 1,
+ 'application/vnd.frogans.fnc' => 1, 'application/vnd.frogans.ltf' => 1, 'application/vnd.fsc.weblaunch' => 1, 'application/vnd.fujitsu.oasys' => 1,
+ 'application/vnd.fujitsu.oasys2' => 1, 'application/vnd.fujitsu.oasys3' => 1, 'application/vnd.fujitsu.oasysgp' => 1, 'application/vnd.fujitsu.oasysprs' => 1,
+ 'application/vnd.fujixerox.ddd' => 1, 'application/vnd.fujixerox.docuworks' => 1, 'application/vnd.fujixerox.docuworks.binder' => 1, 'application/vnd.fuzzysheet' => 1,
+ 'application/vnd.genomatix.tuxedo' => 1, 'application/vnd.geogebra.file' => 1, 'application/vnd.geogebra.tool' => 1, 'application/vnd.geometry-explorer' => 1,
+ 'application/vnd.geometry-explorer' => 1, 'application/vnd.geonext' => 1, 'application/vnd.geoplan' => 1, 'application/vnd.geospace' => 1, 'application/vnd.gmx' => 1,
+ 'application/vnd.google-earth.kml+xml' => 1, 'application/vnd.google-earth.kmz' => 1, 'application/vnd.grafeq' => 1, 'application/vnd.grafeq' => 1,
+ 'application/vnd.groove-account' => 1, 'application/vnd.groove-help' => 1, 'application/vnd.groove-identity-message' => 1, 'application/vnd.groove-injector' => 1,
+ 'application/vnd.groove-tool-message' => 1, 'application/vnd.groove-tool-template' => 1, 'application/vnd.groove-vcard' => 1, 'application/vnd.hal+xml' => 1,
+ 'application/vnd.handheld-entertainment+xml' => 1, 'application/vnd.hbci' => 1, 'application/vnd.hhe.lesson-player' => 1, 'application/vnd.hp-hpgl' => 1,
+ 'application/vnd.hp-hpid' => 1, 'application/vnd.hp-hps' => 1, 'application/vnd.hp-jlyt' => 1, 'application/vnd.hp-pcl' => 1, 'application/vnd.hp-pclxl' => 1,
+ 'application/vnd.hydrostatix.sof-data' => 1, 'application/vnd.ibm.minipay' => 1, 'application/vnd.ibm.modcap' => 1, 'application/vnd.ibm.modcap' => 1, 'application/vnd.ibm.modcap' => 1,
+ 'application/vnd.ibm.rights-management' => 1, 'application/vnd.ibm.secure-container' => 1, 'application/vnd.iccprofile' => 1, 'application/vnd.iccprofile' => 1,
+ 'application/vnd.igloader' => 1, 'application/vnd.immervision-ivp' => 1, 'application/vnd.immervision-ivu' => 1, 'application/vnd.insors.igm' => 1, 'application/vnd.intercon.formnet' => 1,
+ 'application/vnd.intercon.formnet' => 1, 'application/vnd.intergeo' => 1, 'application/vnd.intu.qbo' => 1, 'application/vnd.intu.qfx' => 1, 'application/vnd.ipunplugged.rcprofile' => 1,
+ 'application/vnd.irepository.package+xml' => 1, 'application/vnd.is-xpr' => 1, 'application/vnd.isac.fcs' => 1, 'application/vnd.jam' => 1, 'application/vnd.jcp.javame.midlet-rms' => 1,
+ 'application/vnd.jisp' => 1, 'application/vnd.joost.joda-archive' => 1, 'application/vnd.kahootz' => 1, 'application/vnd.kahootz' => 1, 'application/vnd.kde.karbon' => 1,
+ 'application/vnd.kde.kchart' => 1, 'application/vnd.kde.kformula' => 1, 'application/vnd.kde.kivio' => 1, 'application/vnd.kde.kontour' => 1, 'application/vnd.kde.kpresenter' => 1,
+ 'application/vnd.kde.kpresenter' => 1, 'application/vnd.kde.kspread' => 1, 'application/vnd.kde.kword' => 1, 'application/vnd.kde.kword' => 1, 'application/vnd.kenameaapp' => 1,
+ 'application/vnd.kidspiration' => 1, 'application/vnd.kinar' => 1, 'application/vnd.kinar' => 1, 'application/vnd.koan' => 1, 'application/vnd.koan' => 1, 'application/vnd.koan' => 1,
+ 'application/vnd.koan' => 1, 'application/vnd.kodak-descriptor' => 1, 'application/vnd.las.las+xml' => 1, 'application/vnd.llamagraphics.life-balance.desktop' => 1,
+ 'application/vnd.llamagraphics.life-balance.exchange+xml' => 1, 'application/vnd.lotus-1-2-3' => 1, 'application/vnd.lotus-approach' => 1, 'application/vnd.lotus-freelance' => 1,
+ 'application/vnd.lotus-notes' => 1, 'application/vnd.lotus-organizer' => 1, 'application/vnd.lotus-screencam' => 1, 'application/vnd.lotus-wordpro' => 1,
+ 'application/vnd.macports.portpkg' => 1, 'application/vnd.mcd' => 1, 'application/vnd.medcalcdata' => 1, 'application/vnd.mediastation.cdkey' => 1, 'application/vnd.mfer' => 1,
+ 'application/vnd.mfmp' => 1, 'application/vnd.micrografx.flo' => 1, 'application/vnd.micrografx.igx' => 1, 'application/vnd.mif' => 1, 'application/vnd.mobius.daf' => 1,
+ 'application/vnd.mobius.dis' => 1, 'application/vnd.mobius.mbk' => 1, 'application/vnd.mobius.mqy' => 1, 'application/vnd.mobius.msl' => 1, 'application/vnd.mobius.plc' => 1,
+ 'application/vnd.mobius.txf' => 1, 'application/vnd.mophun.application' => 1, 'application/vnd.mophun.certificate' => 1, 'application/vnd.mozilla.xul+xml' => 1,
+ 'application/vnd.ms-artgalry' => 1, 'application/vnd.ms-cab-compressed' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1,
+ 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel.addin.macroenabled.12' => 1,
+ 'application/vnd.ms-excel.sheet.binary.macroenabled.12' => 1, 'application/vnd.ms-excel.sheet.macroenabled.12' => 1, 'application/vnd.ms-excel.template.macroenabled.12' => 1,
+ 'application/vnd.ms-fontobject' => 1, 'application/vnd.ms-htmlhelp' => 1, 'application/vnd.ms-ims' => 1, 'application/vnd.ms-lrm' => 1, 'application/vnd.ms-officetheme' => 1,
+ 'application/vnd.ms-pki.seccat' => 1, 'application/vnd.ms-pki.stl' => 1, 'application/vnd.ms-powerpoint' => 1, 'application/vnd.ms-powerpoint' => 1,
+ 'application/vnd.ms-powerpoint' => 1, 'application/vnd.ms-powerpoint.addin.macroenabled.12' => 1, 'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 1,
+ 'application/vnd.ms-powerpoint.slide.macroenabled.12' => 1, 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 1,
+ 'application/vnd.ms-powerpoint.template.macroenabled.12' => 1, 'application/vnd.ms-project' => 1, 'application/vnd.ms-project' => 1,
+ 'application/vnd.ms-word.document.macroenabled.12' => 1, 'application/vnd.ms-word.template.macroenabled.12' => 1, 'application/vnd.ms-works' => 1,
+ 'application/vnd.ms-works' => 1, 'application/vnd.ms-works' => 1, 'application/vnd.ms-works' => 1, 'application/vnd.ms-wpl' => 1, 'application/vnd.ms-xpsdocument' => 1,
+ 'application/vnd.mseq' => 1, 'application/vnd.musician' => 1, 'application/vnd.muvee.style' => 1, 'application/vnd.mynfc' => 1, 'application/vnd.neurolanguage.nlu' => 1,
+ 'application/vnd.nitf' => 1, 'application/vnd.nitf' => 1, 'application/vnd.noblenet-directory' => 1, 'application/vnd.noblenet-sealer' => 1, 'application/vnd.noblenet-web' => 1,
+ 'application/vnd.nokia.n-gage.data' => 1, 'application/vnd.nokia.n-gage.symbian.install' => 1, 'application/vnd.nokia.radio-preset' => 1, 'application/vnd.nokia.radio-presets' => 1,
+ 'application/vnd.novadigm.edm' => 1, 'application/vnd.novadigm.edx' => 1, 'application/vnd.novadigm.ext' => 1, 'application/vnd.oasis.opendocument.chart' => 1,
+ 'application/vnd.oasis.opendocument.chart-template' => 1, 'application/vnd.oasis.opendocument.database' => 1, 'application/vnd.oasis.opendocument.formula' => 1,
+ 'application/vnd.oasis.opendocument.formula-template' => 1, 'application/vnd.oasis.opendocument.graphics' => 1, 'application/vnd.oasis.opendocument.graphics-template' => 1,
+ 'application/vnd.oasis.opendocument.image' => 1, 'application/vnd.oasis.opendocument.image-template' => 1, 'application/vnd.oasis.opendocument.presentation' => 1,
+ 'application/vnd.oasis.opendocument.presentation-template' => 1, 'application/vnd.oasis.opendocument.spreadsheet' => 1, 'application/vnd.oasis.opendocument.spreadsheet-template' => 1,
+ 'application/vnd.oasis.opendocument.text' => 1, 'application/vnd.oasis.opendocument.text-master' => 1, 'application/vnd.oasis.opendocument.text-template' => 1,
+ 'application/vnd.oasis.opendocument.text-web' => 1, 'application/vnd.olpc-sugar' => 1, 'application/vnd.oma.dd2+xml' => 1, 'application/vnd.openofficeorg.extension' => 1,
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 1, 'application/vnd.openxmlformats-officedocument.presentationml.slide' => 1,
+ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 1, 'application/vnd.openxmlformats-officedocument.presentationml.template' => 1,
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 1, 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 1,
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 1, 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 1,
+ 'application/vnd.osgeo.mapguide.package' => 1, 'application/vnd.osgi.dp' => 1, 'application/vnd.osgi.subsystem' => 1, 'application/vnd.palm' => 1, 'application/vnd.palm' => 1,
+ 'application/vnd.palm' => 1, 'application/vnd.pawaafile' => 1, 'application/vnd.pg.format' => 1, 'application/vnd.pg.osasli' => 1, 'application/vnd.picsel' => 1, 'application/vnd.pmi.widget' => 1,
+ 'application/vnd.pocketlearn' => 1, 'application/vnd.powerbuilder6' => 1, 'application/vnd.previewsystems.box' => 1, 'application/vnd.proteus.magazine' => 1,
+ 'application/vnd.publishare-delta-tree' => 1, 'application/vnd.pvi.ptid1' => 1, 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1,
+ 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1,
+ 'application/vnd.realvnc.bed' => 1, 'application/vnd.recordare.musicxml' => 1, 'application/vnd.recordare.musicxml+xml' => 1, 'application/vnd.rig.cryptonote' => 1,
+ 'application/vnd.rim.cod' => 1, 'application/vnd.rn-realmedia' => 1, 'application/vnd.rn-realmedia-vbr' => 1, 'application/vnd.route66.link66+xml' => 1, 'application/vnd.sailingtracker.track' => 1,
+ 'application/vnd.seemail' => 1, 'application/vnd.sema' => 1, 'application/vnd.semd' => 1, 'application/vnd.semf' => 1, 'application/vnd.shana.informed.formdata' => 1,
+ 'application/vnd.shana.informed.formtemplate' => 1, 'application/vnd.shana.informed.interchange' => 1, 'application/vnd.shana.informed.package' => 1, 'application/vnd.simtech-mindmapper' => 1,
+ 'application/vnd.simtech-mindmapper' => 1, 'application/vnd.smaf' => 1, 'application/vnd.smart.teacher' => 1, 'application/vnd.solent.sdkm+xml' => 1, 'application/vnd.solent.sdkm+xml' => 1,
+ 'application/vnd.spotfire.dxp' => 1, 'application/vnd.spotfire.sfs' => 1, 'application/vnd.stardivision.calc' => 1, 'application/vnd.stardivision.draw' => 1,
+ 'application/vnd.stardivision.impress' => 1, 'application/vnd.stardivision.math' => 1, 'application/vnd.stardivision.writer' => 1, 'application/vnd.stardivision.writer' => 1,
+ 'application/vnd.stardivision.writer-global' => 1, 'application/vnd.stepmania.package' => 1, 'application/vnd.stepmania.stepchart' => 1, 'application/vnd.sun.xml.calc' => 1,
+ 'application/vnd.sun.xml.calc.template' => 1, 'application/vnd.sun.xml.draw' => 1, 'application/vnd.sun.xml.draw.template' => 1, 'application/vnd.sun.xml.impress' => 1,
+ 'application/vnd.sun.xml.impress.template' => 1, 'application/vnd.sun.xml.math' => 1, 'application/vnd.sun.xml.writer' => 1, 'application/vnd.sun.xml.writer.global' => 1,
+ 'application/vnd.sun.xml.writer.template' => 1, 'application/vnd.sus-calendar' => 1, 'application/vnd.sus-calendar' => 1, 'application/vnd.svd' => 1, 'application/vnd.symbian.install' => 1,
+ 'application/vnd.symbian.install' => 1, 'application/vnd.syncml+xml' => 1, 'application/vnd.syncml.dm+wbxml' => 1, 'application/vnd.syncml.dm+xml' => 1,
+ 'application/vnd.tao.intent-module-archive' => 1, 'application/vnd.tcpdump.pcap' => 1, 'application/vnd.tcpdump.pcap' => 1, 'application/vnd.tcpdump.pcap' => 1,
+ 'application/vnd.tmobile-livetv' => 1, 'application/vnd.trid.tpt' => 1, 'application/vnd.triscape.mxs' => 1, 'application/vnd.trueapp' => 1, 'application/vnd.ufdl' => 1, 'application/vnd.ufdl' => 1,
+ 'application/vnd.uiq.theme' => 1, 'application/vnd.umajin' => 1, 'application/vnd.unity' => 1, 'application/vnd.uoml+xml' => 1, 'application/vnd.vcx' => 1, 'application/vnd.visio' => 1,
+ 'application/vnd.visio' => 1, 'application/vnd.visio' => 1, 'application/vnd.visio' => 1, 'application/vnd.visionary' => 1, 'application/vnd.vsf' => 1, 'application/vnd.wap.wbxml' => 1,
+ 'application/vnd.wap.wmlc' => 1, 'application/vnd.wap.wmlscriptc' => 1, 'application/vnd.webturbo' => 1, 'application/vnd.wolfram.player' => 1, 'application/vnd.wordperfect' => 1,
+ 'application/vnd.wqd' => 1, 'application/vnd.wt.stf' => 1, 'application/vnd.xara' => 1, 'application/vnd.xfdl' => 1, 'application/vnd.yamaha.hv-dic' => 1, 'application/vnd.yamaha.hv-script' => 1,
+ 'application/vnd.yamaha.hv-voice' => 1, 'application/vnd.yamaha.openscoreformat' => 1, 'application/vnd.yamaha.openscoreformat.osfpvg+xml' => 1, 'application/vnd.yamaha.smaf-audio' => 1,
+ 'application/vnd.yamaha.smaf-phrase' => 1, 'application/vnd.yellowriver-custom-menu' => 1, 'application/vnd.zul' => 1, 'application/vnd.zul' => 1, 'application/vnd.zzazz.deck+xml' => 1,
+ 'application/voicexml+xml' => 1, 'application/widget' => 1, 'application/winhlp' => 1, 'application/wsdl+xml' => 1, 'application/wspolicy+xml' => 1, 'application/x-7z-compressed' => 1,
+ 'application/x-abiword' => 1, 'application/x-ace-compressed' => 1, 'application/x-apple-diskimage' => 1, 'application/x-authorware-bin' => 1, 'application/x-authorware-bin' => 1,
+ 'application/x-authorware-bin' => 1, 'application/x-authorware-bin' => 1, 'application/x-authorware-map' => 1, 'application/x-authorware-seg' => 1, 'application/x-bcpio' => 1,
+ 'application/x-bittorrent' => 1, 'application/x-blorb' => 1, 'application/x-blorb' => 1, 'application/x-bzip' => 1, 'application/x-bzip2' => 1, 'application/x-bzip2' => 1, 'application/x-cbr' => 1,
+ 'application/x-cbr' => 1, 'application/x-cbr' => 1, 'application/x-cbr' => 1, 'application/x-cbr' => 1, 'application/x-cdlink' => 1, 'application/x-cfs-compressed' => 1, 'application/x-chat' => 1,
+ 'application/x-chess-pgn' => 1, 'application/x-conference' => 1, 'application/x-cpio' => 1, 'application/x-csh' => 1, 'application/x-debian-package' => 1, 'application/x-debian-package' => 1,
+ 'application/x-dgc-compressed' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1,
+ 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-doom' => 1, 'application/x-dtbncx+xml' => 1,
+ 'application/x-dtbook+xml' => 1, 'application/x-dtbresource+xml' => 1, 'application/x-dvi' => 1, 'application/x-envoy' => 1, 'application/x-eva' => 1, 'application/x-font-bdf' => 1,
+ 'application/x-font-ghostscript' => 1, 'application/x-font-linux-psf' => 1, 'application/x-font-otf' => 1, 'application/x-font-pcf' => 1, 'application/x-font-snf' => 1,
+ 'application/x-font-ttf' => 1, 'application/x-font-ttf' => 1, 'application/x-font-type1' => 1, 'application/x-font-type1' => 1, 'application/x-font-type1' => 1, 'application/x-font-type1' => 1,
+ 'application/x-font-woff' => 1, 'application/x-freearc' => 1, 'application/x-futuresplash' => 1, 'application/x-gca-compressed' => 1, 'application/x-glulx' => 1, 'application/x-gnumeric' => 1,
+ 'application/x-gramps-xml' => 1, 'application/x-gtar' => 1, 'application/x-hdf' => 1, 'application/x-install-instructions' => 1, 'application/x-iso9660-image' => 1,
+ 'application/x-java-jnlp-file' => 1, 'application/x-latex' => 1, 'application/x-lzh-compressed' => 1, 'application/x-lzh-compressed' => 1, 'application/x-mie' => 1,
+ 'application/x-mobipocket-ebook' => 1, 'application/x-mobipocket-ebook' => 1, 'application/x-ms-application' => 1, 'application/x-ms-shortcut' => 1, 'application/x-ms-wmd' => 1,
+ 'application/x-ms-wmz' => 1, 'application/x-ms-xbap' => 1, 'application/x-msaccess' => 1, 'application/x-msbinder' => 1, 'application/x-mscardfile' => 1, 'application/x-msclip' => 1,
+ 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msmediaview' => 1,
+ 'application/x-msmediaview' => 1, 'application/x-msmediaview' => 1, 'application/x-msmetafile' => 1, 'application/x-msmetafile' => 1, 'application/x-msmetafile' => 1, 'application/x-msmetafile' => 1,
+ 'application/x-msmoney' => 1, 'application/x-mspublisher' => 1, 'application/x-msschedule' => 1, 'application/x-msterminal' => 1, 'application/x-mswrite' => 1, 'application/x-netcdf' => 1,
+ 'application/x-netcdf' => 1, 'application/x-nzb' => 1, 'application/x-pkcs12' => 1, 'application/x-pkcs12' => 1, 'application/x-pkcs7-certificates' => 1, 'application/x-pkcs7-certificates' => 1,
+ 'application/x-pkcs7-certreqresp' => 1, 'application/x-rar-compressed' => 1, 'application/x-research-info-systems' => 1, 'application/x-sh' => 1, 'application/x-shar' => 1,
+ 'application/x-shockwave-flash' => 1, 'application/x-silverlight-app' => 1, 'application/x-silverlight-2' => 1, 'application/x-sql' => 1, 'application/x-stuffit' => 1, 'application/x-stuffitx' => 1,
+ 'application/x-subrip' => 1, 'application/x-sv4cpio' => 1, 'application/x-sv4crc' => 1, 'application/x-t3vm-image' => 1, 'application/x-tads' => 1, 'application/x-tar' => 1, 'application/x-tcl' => 1,
+ 'application/x-tex' => 1, 'application/x-tex-tfm' => 1, 'application/x-texinfo' => 1, 'application/x-texinfo' => 1, 'application/x-tgif' => 1, 'application/x-ustar' => 1, 'application/x-wais-source' => 1,
+ 'application/x-x509-ca-cert' => 1, 'application/x-x509-ca-cert' => 1, 'application/x-xfig' => 1, 'application/x-xliff+xml' => 1, 'application/x-xpinstall' => 1, 'application/x-xz' => 1,
+ 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1,
+ 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/xaml+xml' => 1, 'application/xcap-diff+xml' => 1, 'application/xenc+xml' => 1, 'application/xhtml+xml' => 1,
+ 'application/xhtml+xml' => 1, 'application/xml' => 1, 'application/xml' => 1, 'application/xml-dtd' => 1, 'application/xop+xml' => 1, 'application/xproc+xml' => 1, 'application/xslt+xml' => 1,
+ 'application/xspf+xml' => 1, 'application/xv+xml' => 1, 'application/xv+xml' => 1, 'application/xv+xml' => 1, 'application/xv+xml' => 1, 'application/yang' => 1, 'application/yin+xml' => 1,
+ 'application/zip' => 1, 'audio/adpcm' => 1, 'audio/basic' => 1, 'audio/basic' => 1, 'audio/midi' => 1, 'audio/midi' => 1, 'audio/midi' => 1, 'audio/midi' => 1, 'audio/mp4' => 1, 'audio/mpeg' => 1,
+ 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/ogg' => 1, 'audio/ogg' => 1, 'audio/ogg' => 1, 'audio/s3m' => 1, 'audio/silk' => 1,
+ 'audio/vnd.dece.audio' => 1, 'audio/vnd.dece.audio' => 1, 'audio/vnd.digital-winds' => 1, 'audio/vnd.dra' => 1, 'audio/vnd.dts' => 1, 'audio/vnd.dts.hd' => 1, 'audio/vnd.lucent.voice' => 1,
+ 'audio/vnd.ms-playready.media.pya' => 1, 'audio/vnd.nuera.ecelp4800' => 1, 'audio/vnd.nuera.ecelp7470' => 1, 'audio/vnd.nuera.ecelp9600' => 1, 'audio/vnd.rip' => 1, 'audio/webm' => 1,
+ 'audio/x-aac' => 1, 'audio/x-aiff' => 1, 'audio/x-aiff' => 1, 'audio/x-aiff' => 1, 'audio/x-caf' => 1, 'audio/x-flac' => 1, 'audio/x-matroska' => 1, 'audio/x-mpegurl' => 1, 'audio/x-ms-wax' => 1,
+ 'audio/x-ms-wma' => 1, 'audio/x-pn-realaudio' => 1, 'audio/x-pn-realaudio' => 1, 'audio/x-pn-realaudio-plugin' => 1, 'audio/x-wav' => 1, 'audio/xm' => 1, 'chemical/x-cdx' => 1, 'chemical/x-cif' => 1,
+ 'chemical/x-cmdf' => 1, 'chemical/x-cml' => 1, 'chemical/x-csml' => 1, 'chemical/x-xyz' => 1, 'image/bmp' => 1, 'image/cgm' => 1, 'image/g3fax' => 1, 'image/gif' => 1, 'image/ief' => 1, 'image/jpeg' => 1,
+ 'image/jpeg' => 1, 'image/jpeg' => 1, 'image/ktx' => 1, 'image/png' => 1, 'image/prs.btif' => 1, 'image/sgi' => 1, 'image/svg+xml' => 1, 'image/svg+xml' => 1, 'image/tiff' => 1, 'image/tiff' => 1,
+ 'image/vnd.adobe.photoshop' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dvb.subtitle' => 1,
+ 'image/vnd.djvu' => 1, 'image/vnd.djvu' => 1, 'image/vnd.dwg' => 1, 'image/vnd.dxf' => 1, 'image/vnd.fastbidsheet' => 1, 'image/vnd.fpx' => 1, 'image/vnd.fst' => 1, 'image/vnd.fujixerox.edmics-mmr' => 1,
+ 'image/vnd.fujixerox.edmics-rlc' => 1, 'image/vnd.ms-modi' => 1, 'image/vnd.ms-photo' => 1, 'image/vnd.net-fpx' => 1, 'image/vnd.wap.wbmp' => 1, 'image/vnd.xiff' => 1, 'image/webp' => 1,
+ 'image/x-3ds' => 1, 'image/x-cmu-raster' => 1, 'image/x-cmx' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1,
+ 'image/x-icon' => 1, 'image/x-mrsid-image' => 1, 'image/x-pcx' => 1, 'image/x-pict' => 1, 'image/x-pict' => 1, 'image/x-portable-anymap' => 1, 'image/x-portable-bitmap' => 1,
+ 'image/x-portable-graymap' => 1, 'image/x-portable-pixmap' => 1, 'image/x-rgb' => 1, 'image/x-tga' => 1, 'image/x-xbitmap' => 1, 'image/x-xpixmap' => 1, 'image/x-xwindowdump' => 1,
+ 'message/rfc822' => 1, 'message/rfc822' => 1, 'model/iges' => 1, 'model/iges' => 1, 'model/mesh' => 1, 'model/mesh' => 1, 'model/mesh' => 1, 'model/vnd.collada+xml' => 1, 'model/vnd.dwf' => 1,
+ 'model/vnd.gdl' => 1, 'model/vnd.gtw' => 1, 'model/vnd.mts' => 1, 'model/vnd.vtu' => 1, 'model/vrml' => 1, 'model/vrml' => 1, 'model/x3d+binary' => 1, 'model/x3d+binary' => 1, 'model/x3d+vrml' => 1,
+ 'model/x3d+vrml' => 1, 'model/x3d+xml' => 1, 'model/x3d+xml' => 1, 'video/3gpp' => 1, 'video/3gpp2' => 1, 'video/h261' => 1, 'video/h263' => 1, 'video/h264' => 1, 'video/jpeg' => 1, 'video/jpm' => 1,
+ 'video/jpm' => 1, 'video/mj2' => 1, 'video/mj2' => 1, 'video/mp4' => 1, 'video/mp4' => 1, 'video/mp4' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1,
+ 'video/ogg' => 1, 'video/quicktime' => 1, 'video/quicktime' => 1, 'video/vnd.dece.hd' => 1, 'video/vnd.dece.hd' => 1, 'video/vnd.dece.mobile' => 1, 'video/vnd.dece.mobile' => 1, 'video/vnd.dece.pd' => 1,
+ 'video/vnd.dece.pd' => 1, 'video/vnd.dece.sd' => 1, 'video/vnd.dece.sd' => 1, 'video/vnd.dece.video' => 1, 'video/vnd.dece.video' => 1, 'video/vnd.dvb.file' => 1, 'video/vnd.fvt' => 1,
+ 'video/vnd.mpegurl' => 1, 'video/vnd.mpegurl' => 1, 'video/vnd.ms-playready.media.pyv' => 1, 'video/vnd.uvvu.mp4' => 1, 'video/vnd.uvvu.mp4' => 1, 'video/vnd.vivo' => 1, 'video/webm' => 1,
+ 'video/x-f4v' => 1, 'video/x-fli' => 1, 'video/x-flv' => 1, 'video/x-m4v' => 1, 'video/x-matroska' => 1, 'video/x-matroska' => 1, 'video/x-matroska' => 1, 'video/x-mng' => 1, 'video/x-ms-asf' => 1,
+ 'video/x-ms-asf' => 1, 'video/x-ms-vob' => 1, 'video/x-ms-wm' => 1, 'video/x-ms-wmv' => 1, 'video/x-ms-wmx' => 1, 'video/x-ms-wvx' => 1, 'video/x-msvideo' => 1, 'video/x-sgi-movie' => 1,
+ 'video/x-smv' => 1, 'x-conference/x-cooltalk' => 1
);
- var $extList = array('ez'=>1, 'aw'=>1, 'atom'=>1, 'atomcat'=>1, 'atomsvc'=>1, 'ccxml'=>1, 'cdmia'=>1, 'cdmic'=>1, 'cdmid'=>1, 'cdmio'=>1, 'cdmiq'=>1, 'cu'=>1, 'davmount'=>1,
- 'dbk'=>1, 'dssc'=>1, 'xdssc'=>1, 'ecma'=>1, 'emma'=>1, 'epub'=>1, 'exi'=>1, 'pfr'=>1, 'gml'=>1, 'gpx'=>1, 'gxf'=>1, 'stk'=>1, 'ink'=>1, 'inkml'=>1, 'ipfix'=>1, 'jar'=>1,
- 'ser'=>1, 'class'=>1, 'js'=>1, 'json'=>1, 'jsonml'=>1, 'lostxml'=>1, 'hqx'=>1, 'cpt'=>1, 'mads'=>1, 'mrc'=>1, 'mrcx'=>1, 'ma'=>1, 'nb'=>1, 'mb'=>1, 'mathml'=>1, 'mbox'=>1,
- 'mscml'=>1, 'metalink'=>1, 'meta4'=>1, 'mets'=>1, 'mods'=>1, 'm21 mp21'=>1, 'mp4s'=>1, 'doc dot'=>1, 'mxf'=>1, 'bin'=>1, 'dms'=>1, 'lrf'=>1, 'mar'=>1, 'so'=>1, 'dist'=>1,
- 'distz'=>1, 'pkg'=>1, 'bpk'=>1, 'dump'=>1, 'elc'=>1, 'deploy'=>1, 'oda'=>1, 'opf'=>1, 'ogx'=>1, 'omdoc'=>1, 'onetoc'=>1, 'onetoc2'=>1, 'onetmp'=>1, 'onepkg'=>1, 'oxps'=>1,
- 'xer'=>1, 'pdf'=>1, 'pgp'=>1, 'asc'=>1, 'sig'=>1, 'prf'=>1, 'p10'=>1, 'p7m'=>1, 'p7c'=>1, 'p7s'=>1, 'p8'=>1, 'ac'=>1, 'cer'=>1, 'crl'=>1, 'pkipath'=>1, 'pki'=>1, 'pls'=>1,
- 'ai'=>1, 'eps'=>1, 'ps'=>1, 'cww'=>1, 'pskcxml'=>1, 'rdf'=>1, 'rif'=>1, 'rnc'=>1, 'rl'=>1, 'rld'=>1, 'rs'=>1, 'gbr'=>1, 'mft'=>1, 'roa'=>1, 'rsd'=>1, 'rss'=>1, 'rtf'=>1,
- 'sbml'=>1, 'scq'=>1, 'scs'=>1, 'spq'=>1, 'spp'=>1, 'sdp'=>1, 'setpay'=>1, 'setreg'=>1, 'shf'=>1, 'smi'=>1, 'smil'=>1, 'rq'=>1, 'srx'=>1, 'gram'=>1, 'grxml'=>1, 'sru'=>1,
- 'ssdl'=>1, 'ssml'=>1, 'tei'=>1, 'teicorpus'=>1, 'tfi'=>1, 'tsd'=>1, 'plb'=>1, 'psb'=>1, 'pvb'=>1, 'tcap'=>1, 'pwn'=>1, 'aso'=>1, 'imp'=>1, 'acu'=>1, 'atc'=>1, 'acutc'=>1,
- 'air'=>1, 'fcdt'=>1, 'fxp'=>1, 'fxpl'=>1, 'xdp'=>1, 'xfdf'=>1, 'ahead'=>1, 'azf'=>1, 'azs'=>1, 'azw'=>1, 'acc'=>1, 'ami'=>1, 'apk'=>1, 'cii'=>1, 'fti'=>1, 'atx'=>1, 'mpkg'=>1,
- 'm3u8'=>1, 'swi'=>1, 'iota'=>1, 'aep'=>1, 'mpm'=>1, 'bmi'=>1, 'rep'=>1, 'cdxml'=>1, 'mmd'=>1, 'cdy'=>1, 'cla'=>1, 'rp9'=>1, 'c4g'=>1, 'c4d'=>1, 'c4f'=>1, 'c4p'=>1, 'c4u'=>1,
- 'c11amc'=>1, 'c11amz'=>1, 'csp'=>1, 'cdbcmsg'=>1, 'cmc'=>1, 'clkx'=>1, 'clkk'=>1, 'clkp'=>1, 'clkt'=>1, 'clkw'=>1, 'wbs'=>1, 'pml'=>1, 'ppd'=>1, 'car'=>1, 'pcurl'=>1, 'dart'=>1,
- 'rdz'=>1, 'uvf'=>1, 'uvvf'=>1, 'uvd'=>1, 'uvvd'=>1, 'uvt'=>1, 'uvvt'=>1, 'uvx'=>1, 'uvvx'=>1, 'uvz'=>1, 'uvvz'=>1, 'fe_launch'=>1, 'dna'=>1, 'mlp'=>1, 'dpg'=>1, 'dfac'=>1,
- 'kpxx'=>1, 'ait'=>1, 'svc'=>1, 'geo'=>1, 'mag'=>1, 'nml'=>1, 'esf'=>1, 'msf'=>1, 'qam'=>1, 'slt'=>1, 'ssf'=>1, 'es3'=>1, 'et3'=>1, 'ez2'=>1, 'ez3'=>1, 'fdf'=>1, 'mseed'=>1,
- 'seed'=>1, 'dataless'=>1, 'gph'=>1, 'ftc'=>1, 'fm'=>1, 'frame'=>1, 'maker'=>1, 'book'=>1, 'fnc'=>1, 'ltf'=>1, 'fsc'=>1, 'oas'=>1, 'oa2'=>1, 'oa3'=>1, 'fg5'=>1, 'bh2'=>1, 'ddd'=>1,
- 'xdw'=>1, 'xbd'=>1, 'fzs'=>1, 'txd'=>1, 'ggb'=>1, 'ggt'=>1, 'gex'=>1, 'gre'=>1, 'gxt'=>1, 'g2w'=>1, 'g3w'=>1, 'gmx'=>1, 'kml'=>1, 'kmz'=>1, 'gqf'=>1, 'gqs'=>1, 'gac'=>1, 'ghf'=>1,
- 'gim'=>1, 'grv'=>1, 'gtm'=>1, 'tpl'=>1, 'vcg'=>1, 'hal'=>1, 'zmm'=>1, 'hbci'=>1, 'les'=>1, 'hpgl'=>1, 'hpid'=>1, 'hps'=>1, 'jlt'=>1, 'pcl'=>1, 'pclxl'=>1, 'sfd-hdstx'=>1, 'mpy'=>1,
- 'afp'=>1, 'listafp'=>1, 'list3820'=>1, 'irm'=>1, 'sc'=>1, 'icc'=>1, 'icm'=>1, 'igl'=>1, 'ivp'=>1, 'ivu'=>1, 'igm'=>1, 'xpw'=>1, 'xpx'=>1, 'i2g'=>1, 'qbo'=>1, 'qfx'=>1,
- 'rcprofile'=>1, 'irp'=>1, 'xpr'=>1, 'fcs'=>1, 'jam'=>1, 'rms'=>1, 'jisp'=>1, 'joda'=>1, 'ktz'=>1, 'ktr'=>1, 'karbon'=>1, 'chrt'=>1, 'kfo'=>1, 'flw'=>1, 'kon'=>1, 'kpr'=>1, 'kpt'=>1,
- 'ksp'=>1, 'kwd'=>1, 'kwt'=>1, 'htke'=>1, 'kia'=>1, 'kne'=>1, 'knp'=>1, 'skp'=>1, 'skd'=>1, 'skt'=>1, 'skm'=>1, 'sse'=>1, 'lasxml'=>1, 'lbd'=>1, 'lbe'=>1, '123'=>1, 'apr'=>1,
- 'pre'=>1, 'nsf'=>1, 'org'=>1, 'scm'=>1, 'lwp'=>1, 'portpkg'=>1, 'mcd'=>1, 'mc1'=>1, 'cdkey'=>1, 'mwf'=>1, 'mfm'=>1, 'flo'=>1, 'igx'=>1, 'mif'=>1, 'daf'=>1, 'dis'=>1, 'mbk'=>1,
- 'mqy'=>1, 'msl'=>1, 'plc'=>1, 'txf'=>1, 'mpn'=>1, 'mpc'=>1, 'xul'=>1, 'cil'=>1, 'cab'=>1, 'xls'=>1, 'xlm'=>1, 'xla'=>1, 'xlc'=>1, 'xlt'=>1, 'xlw'=>1, 'xlam'=>1, 'xlsb'=>1, 'xlsm'=>1,
- 'xltm'=>1, 'eot'=>1, 'chm'=>1, 'ims'=>1, 'lrm'=>1, 'thmx'=>1, 'cat'=>1, 'stl'=>1, 'ppt'=>1, 'pps'=>1, 'pot'=>1, 'ppam'=>1, 'pptm'=>1, 'sldm'=>1, 'ppsm'=>1, 'potm'=>1, 'mpp'=>1,
- 'mpt'=>1, 'docm'=>1, 'dotm'=>1, 'wps'=>1, 'wks'=>1, 'wcm'=>1, 'wdb'=>1, 'wpl'=>1, 'xps'=>1, 'mseq'=>1, 'mus'=>1, 'msty'=>1, 'taglet'=>1, 'nlu'=>1, 'nitf'=>1, 'nitf'=>1, 'nnd'=>1,
- 'nns'=>1, 'nnw'=>1, 'ngdat'=>1, 'n-gage'=>1, 'rpst'=>1, 'rpss'=>1, 'edm'=>1, 'edx'=>1, 'ext'=>1, 'odc'=>1, 'otc'=>1, 'odb'=>1, 'odf'=>1, 'odft'=>1, 'odg'=>1, 'otg'=>1, 'odi'=>1,
- 'oti'=>1, 'odp'=>1, 'otp'=>1, 'ods'=>1, 'ots'=>1, 'odt'=>1, 'odm'=>1, 'ott'=>1, 'oth'=>1, 'xo'=>1, 'dd2'=>1, 'oxt'=>1, 'pptx'=>1, 'sldx'=>1, 'ppsx'=>1, 'potx'=>1, 'xlsx'=>1, 'xltx'=>1,
- 'docx'=>1, 'dotx'=>1, 'mgp'=>1, 'dp'=>1, 'esa'=>1, 'pdb'=>1, 'pqa'=>1, 'oprc'=>1, 'paw'=>1, 'str'=>1, 'ei6'=>1, 'efif'=>1, 'wg'=>1, 'plf'=>1, 'pbd'=>1, 'box'=>1, 'mgz'=>1, 'qps'=>1,
- 'ptid'=>1, 'qxd'=>1, 'qxt'=>1, 'qwd'=>1, 'qwt'=>1, 'qxl'=>1, 'qxb'=>1, 'bed'=>1, 'mxl'=>1, 'musicxml'=>1, 'cryptonote'=>1, 'cod'=>1, 'rm'=>1, 'rmvb'=>1, 'link66'=>1, 'st'=>1, 'see'=>1,
- 'sema'=>1, 'semd'=>1, 'semf'=>1, 'ifm'=>1, 'itp'=>1, 'iif'=>1, 'ipk'=>1, 'twd'=>1, 'twds'=>1, 'mmf'=>1, 'teacher'=>1, 'sdkm'=>1, 'sdkd'=>1, 'dxp'=>1, 'sfs'=>1, 'sdc'=>1, 'sda'=>1,
- 'sdd'=>1, 'smf'=>1, 'sdw'=>1, 'vor'=>1, 'sgl'=>1, 'smzip'=>1, 'sm'=>1, 'sxc'=>1, 'stc'=>1, 'sxd'=>1, 'std'=>1, 'sxi'=>1, 'sti'=>1, 'sxm'=>1, 'sxw'=>1, 'sxg'=>1, 'stw'=>1, 'sus'=>1,
- 'susp'=>1, 'svd'=>1, 'sis'=>1, 'sisx'=>1, 'xsm'=>1, 'bdm'=>1, 'xdm'=>1, 'tao'=>1, 'pcap'=>1, 'cap'=>1, 'dmp'=>1, 'tmo'=>1, 'tpt'=>1, 'mxs'=>1, 'tra'=>1, 'ufd'=>1, 'ufdl'=>1, 'utz'=>1,
- 'umj'=>1, 'unityweb'=>1, 'uoml'=>1, 'vcx'=>1, 'vsd'=>1, 'vst'=>1, 'vss'=>1, 'vsw'=>1, 'vis'=>1, 'vsf'=>1, 'wbxml'=>1, 'wmlc'=>1, 'wmlsc'=>1, 'wtb'=>1, 'nbp'=>1, 'wpd'=>1, 'wqd'=>1,
- 'stf'=>1, 'xar'=>1, 'xfdl'=>1, 'hvd'=>1, 'hvs'=>1, 'hvp'=>1, 'osf'=>1, 'osfpvg'=>1, 'saf'=>1, 'spf'=>1, 'cmp'=>1, 'zir'=>1, 'zirz'=>1, 'zaz'=>1, 'vxml'=>1, 'wgt'=>1, 'hlp'=>1, 'wsdl'=>1,
- 'wspolicy'=>1, '7z'=>1, 'abw'=>1, 'ace'=>1, 'dmg'=>1, 'aab'=>1, 'x32'=>1, 'u32'=>1, 'vox'=>1, 'aam'=>1, 'aas'=>1, 'bcpio'=>1, 'torrent'=>1, 'blb'=>1, 'blorb'=>1, 'bz'=>1, 'bz2'=>1,
- 'boz'=>1, 'cbr'=>1, 'cba'=>1, 'cbt'=>1, 'cbz'=>1, 'cb7'=>1, 'vcd'=>1, 'cfs'=>1, 'chat'=>1, 'pgn'=>1, 'nsc'=>1, 'cpio'=>1, 'csh'=>1, 'deb'=>1, 'udeb'=>1, 'dgc'=>1, 'dir'=>1, 'dcr'=>1,
- 'dxr'=>1, 'cst'=>1, 'cct'=>1, 'cxt'=>1, 'w3d'=>1, 'fgd'=>1, 'swa'=>1, 'wad'=>1, 'ncx'=>1, 'dtb'=>1, 'res'=>1, 'dvi'=>1, 'evy'=>1, 'eva'=>1, 'bdf'=>1, 'gsf'=>1, 'psf'=>1, 'otf'=>1,
- 'pcf'=>1, 'snf'=>1, 'ttf'=>1, 'ttc'=>1, 'pfa'=>1, 'pfb'=>1, 'pfm'=>1, 'afm'=>1, 'woff'=>1, 'arc'=>1, 'spl'=>1, 'gca'=>1, 'ulx'=>1, 'gnumeric'=>1, 'gramps'=>1, 'gtar'=>1, 'hdf'=>1,
- 'install'=>1, 'iso'=>1, 'jnlp'=>1, 'latex'=>1, 'lzh'=>1, 'lha'=>1, 'mie'=>1, 'prc'=>1, 'mobi'=>1, 'application'=>1, 'lnk'=>1, 'wmd'=>1, 'wmz'=>1, 'xbap'=>1, 'mdb'=>1, 'obd'=>1,
- 'crd'=>1, 'clp'=>1, 'exe'=>1, 'dll'=>1, 'com'=>1, 'bat'=>1, 'msi'=>1, 'mvb'=>1, 'm13'=>1, 'm14'=>1, 'wmf'=>1, 'wmz'=>1, 'emf'=>1, 'emz'=>1, 'mny'=>1, 'pub'=>1, 'scd'=>1, 'trm'=>1,
- 'wri'=>1, 'nc'=>1, 'cdf'=>1, 'nzb'=>1, 'p12'=>1, 'pfx'=>1, 'p7b'=>1, 'spc'=>1, 'p7r'=>1, 'rar'=>1, 'ris'=>1, 'sh'=>1, 'shar'=>1, 'swf'=>1, 'xap'=>1, 'sql'=>1, 'sit'=>1, 'sitx'=>1,
- 'srt'=>1, 'sv4cpio'=>1, 'sv4crc'=>1, 't3'=>1, 'gam'=>1, 'tar'=>1, 'tcl'=>1, 'tex'=>1, 'tfm'=>1, 'texinfo'=>1, 'texi'=>1, 'obj'=>1, 'ustar'=>1, 'src'=>1, 'der'=>1, 'crt'=>1, 'fig'=>1,
- 'xlf'=>1, 'xpi'=>1, 'xz'=>1, 'z1'=>1, 'z2'=>1, 'z3'=>1, 'z4'=>1, 'z5'=>1, 'z6'=>1, 'z7'=>1, 'z8'=>1, 'xaml'=>1, 'xdf'=>1, 'xenc'=>1, 'xhtml'=>1, 'xht'=>1, 'xml'=>1, 'xsl'=>1, 'dtd'=>1,
- 'xop'=>1, 'xpl'=>1, 'xslt'=>1, 'xspf'=>1, 'mxml'=>1, 'xhvml'=>1, 'xvml'=>1, 'xvm'=>1, 'yang'=>1, 'yin'=>1, 'zip'=>1, 'adp'=>1, 'au'=>1, 'snd'=>1, 'mid'=>1, 'midi'=>1, 'kar'=>1, 'rmi'=>1,
- 'mp4a'=>1, 'mpga'=>1, 'mp2'=>1, 'mp2a'=>1, 'mp3'=>1, 'm2a'=>1, 'm3a'=>1, 'oga'=>1, 'ogg'=>1, 'spx'=>1, 's3m'=>1, 'sil'=>1, 'uva'=>1, 'uvva'=>1, 'eol'=>1, 'dra'=>1, 'dts'=>1, 'dtshd'=>1,
- 'lvp'=>1, 'pya'=>1, 'ecelp4800'=>1, 'ecelp7470'=>1, 'ecelp9600'=>1, 'rip'=>1, 'weba'=>1, 'aac'=>1, 'aif'=>1, 'aiff'=>1, 'aifc'=>1, 'caf'=>1, 'flac'=>1, 'mka'=>1, 'm3u'=>1, 'wax'=>1,
- 'wma'=>1, 'ram'=>1, 'ra'=>1, 'rmp'=>1, 'wav'=>1, 'xm'=>1, 'cdx'=>1, 'cif'=>1, 'cmdf'=>1, 'cml'=>1, 'csml'=>1, 'xyz'=>1, 'bmp'=>1, 'cgm'=>1, 'g3'=>1, 'gif'=>1, 'ief'=>1, 'jpeg'=>1,
- 'jpg'=>1, 'jpe'=>1, 'ktx'=>1, 'png'=>1, 'btif'=>1, 'sgi'=>1, 'svg'=>1, 'svgz'=>1, 'tiff'=>1, 'tif'=>1, 'psd'=>1, 'uvi'=>1, 'uvvi'=>1, 'uvg'=>1, 'uvvg'=>1, 'sub'=>1, 'djvu'=>1, 'djv'=>1,
- 'dwg'=>1, 'dxf'=>1, 'fbs'=>1, 'fpx'=>1, 'fst'=>1, 'mmr'=>1, 'rlc'=>1, 'mdi'=>1, 'wdp'=>1, 'npx'=>1, 'wbmp'=>1, 'xif'=>1, 'webp'=>1, '3ds'=>1, 'ras'=>1, 'cmx'=>1, 'fh'=>1, 'fhc'=>1,
- 'fh4'=>1, 'fh5'=>1, 'fh7'=>1, 'ico'=>1, 'sid'=>1, 'pcx'=>1, 'pic'=>1, 'pct'=>1, 'pnm'=>1, 'pbm'=>1, 'pgm'=>1, 'ppm'=>1, 'rgb'=>1, 'tga'=>1, 'xbm'=>1, 'xpm'=>1, 'xwd'=>1, 'eml'=>1,
- 'mime'=>1, 'igs'=>1, 'iges'=>1, 'msh'=>1, 'mesh'=>1, 'silo'=>1, 'dae'=>1, 'dwf'=>1, 'gdl'=>1, 'gtw'=>1, 'mts'=>1, 'vtu'=>1, 'wrl'=>1, 'vrml'=>1, 'x3db'=>1, 'x3dbz'=>1, 'x3dv'=>1,
- 'x3dvz'=>1, 'x3d'=>1, 'x3dz'=>1, '3gp'=>1, '3g2'=>1, 'h261'=>1, 'h263'=>1, 'h264'=>1, 'jpgv'=>1, 'jpm'=>1, 'jpgm'=>1, 'mj2'=>1, 'mjp2'=>1, 'mp4'=>1, 'mp4v'=>1, 'mpg4'=>1, 'mpeg'=>1,
- 'mpg'=>1, 'mpe'=>1, 'm1v'=>1, 'm2v'=>1, 'ogv'=>1, 'qt'=>1, 'mov'=>1, 'uvh'=>1, 'uvvh'=>1, 'uvm'=>1, 'uvvm'=>1, 'uvp'=>1, 'uvvp'=>1, 'uvs'=>1, 'uvvs'=>1, 'uvv'=>1, 'uvvv'=>1, 'dvb'=>1,
- 'fvt'=>1, 'mxu'=>1, 'm4u'=>1, 'pyv'=>1, 'uvu'=>1, 'uvvu'=>1, 'viv'=>1, 'webm'=>1, 'f4v'=>1, 'fli'=>1, 'flv'=>1, 'm4v'=>1, 'mkv'=>1, 'mk3d'=>1, 'mks'=>1, 'mng'=>1, 'asf'=>1, 'asx'=>1,
- 'vob'=>1, 'wm'=>1, 'wmv'=>1, 'wmx'=>1, 'wvx'=>1, 'avi'=>1, 'movie'=>1, 'smv'=>1, 'ice'=>1,
+ var $extList = array('ez' => 1, 'aw' => 1, 'atom' => 1, 'atomcat' => 1, 'atomsvc' => 1, 'ccxml' => 1, 'cdmia' => 1, 'cdmic' => 1, 'cdmid' => 1, 'cdmio' => 1, 'cdmiq' => 1, 'cu' => 1, 'davmount' => 1,
+ 'dbk' => 1, 'dssc' => 1, 'xdssc' => 1, 'ecma' => 1, 'emma' => 1, 'epub' => 1, 'exi' => 1, 'pfr' => 1, 'gml' => 1, 'gpx' => 1, 'gxf' => 1, 'stk' => 1, 'ink' => 1, 'inkml' => 1, 'ipfix' => 1, 'jar' => 1,
+ 'ser' => 1, 'class' => 1, 'js' => 1, 'json' => 1, 'jsonml' => 1, 'lostxml' => 1, 'hqx' => 1, 'cpt' => 1, 'mads' => 1, 'mrc' => 1, 'mrcx' => 1, 'ma' => 1, 'nb' => 1, 'mb' => 1, 'mathml' => 1, 'mbox' => 1,
+ 'mscml' => 1, 'metalink' => 1, 'meta4' => 1, 'mets' => 1, 'mods' => 1, 'm21 mp21' => 1, 'mp4s' => 1, 'doc dot' => 1, 'mxf' => 1, 'bin' => 1, 'dms' => 1, 'lrf' => 1, 'mar' => 1, 'so' => 1, 'dist' => 1,
+ 'distz' => 1, 'pkg' => 1, 'bpk' => 1, 'dump' => 1, 'elc' => 1, 'deploy' => 1, 'oda' => 1, 'opf' => 1, 'ogx' => 1, 'omdoc' => 1, 'onetoc' => 1, 'onetoc2' => 1, 'onetmp' => 1, 'onepkg' => 1, 'oxps' => 1,
+ 'xer' => 1, 'pdf' => 1, 'pgp' => 1, 'asc' => 1, 'sig' => 1, 'prf' => 1, 'p10' => 1, 'p7m' => 1, 'p7c' => 1, 'p7s' => 1, 'p8' => 1, 'ac' => 1, 'cer' => 1, 'crl' => 1, 'pkipath' => 1, 'pki' => 1, 'pls' => 1,
+ 'ai' => 1, 'eps' => 1, 'ps' => 1, 'cww' => 1, 'pskcxml' => 1, 'rdf' => 1, 'rif' => 1, 'rnc' => 1, 'rl' => 1, 'rld' => 1, 'rs' => 1, 'gbr' => 1, 'mft' => 1, 'roa' => 1, 'rsd' => 1, 'rss' => 1, 'rtf' => 1,
+ 'sbml' => 1, 'scq' => 1, 'scs' => 1, 'spq' => 1, 'spp' => 1, 'sdp' => 1, 'setpay' => 1, 'setreg' => 1, 'shf' => 1, 'smi' => 1, 'smil' => 1, 'rq' => 1, 'srx' => 1, 'gram' => 1, 'grxml' => 1, 'sru' => 1,
+ 'ssdl' => 1, 'ssml' => 1, 'tei' => 1, 'teicorpus' => 1, 'tfi' => 1, 'tsd' => 1, 'plb' => 1, 'psb' => 1, 'pvb' => 1, 'tcap' => 1, 'pwn' => 1, 'aso' => 1, 'imp' => 1, 'acu' => 1, 'atc' => 1, 'acutc' => 1,
+ 'air' => 1, 'fcdt' => 1, 'fxp' => 1, 'fxpl' => 1, 'xdp' => 1, 'xfdf' => 1, 'ahead' => 1, 'azf' => 1, 'azs' => 1, 'azw' => 1, 'acc' => 1, 'ami' => 1, 'apk' => 1, 'cii' => 1, 'fti' => 1, 'atx' => 1, 'mpkg' => 1,
+ 'm3u8' => 1, 'swi' => 1, 'iota' => 1, 'aep' => 1, 'mpm' => 1, 'bmi' => 1, 'rep' => 1, 'cdxml' => 1, 'mmd' => 1, 'cdy' => 1, 'cla' => 1, 'rp9' => 1, 'c4g' => 1, 'c4d' => 1, 'c4f' => 1, 'c4p' => 1, 'c4u' => 1,
+ 'c11amc' => 1, 'c11amz' => 1, 'csp' => 1, 'cdbcmsg' => 1, 'cmc' => 1, 'clkx' => 1, 'clkk' => 1, 'clkp' => 1, 'clkt' => 1, 'clkw' => 1, 'wbs' => 1, 'pml' => 1, 'ppd' => 1, 'car' => 1, 'pcurl' => 1, 'dart' => 1,
+ 'rdz' => 1, 'uvf' => 1, 'uvvf' => 1, 'uvd' => 1, 'uvvd' => 1, 'uvt' => 1, 'uvvt' => 1, 'uvx' => 1, 'uvvx' => 1, 'uvz' => 1, 'uvvz' => 1, 'fe_launch' => 1, 'dna' => 1, 'mlp' => 1, 'dpg' => 1, 'dfac' => 1,
+ 'kpxx' => 1, 'ait' => 1, 'svc' => 1, 'geo' => 1, 'mag' => 1, 'nml' => 1, 'esf' => 1, 'msf' => 1, 'qam' => 1, 'slt' => 1, 'ssf' => 1, 'es3' => 1, 'et3' => 1, 'ez2' => 1, 'ez3' => 1, 'fdf' => 1, 'mseed' => 1,
+ 'seed' => 1, 'dataless' => 1, 'gph' => 1, 'ftc' => 1, 'fm' => 1, 'frame' => 1, 'maker' => 1, 'book' => 1, 'fnc' => 1, 'ltf' => 1, 'fsc' => 1, 'oas' => 1, 'oa2' => 1, 'oa3' => 1, 'fg5' => 1, 'bh2' => 1, 'ddd' => 1,
+ 'xdw' => 1, 'xbd' => 1, 'fzs' => 1, 'txd' => 1, 'ggb' => 1, 'ggt' => 1, 'gex' => 1, 'gre' => 1, 'gxt' => 1, 'g2w' => 1, 'g3w' => 1, 'gmx' => 1, 'kml' => 1, 'kmz' => 1, 'gqf' => 1, 'gqs' => 1, 'gac' => 1, 'ghf' => 1,
+ 'gim' => 1, 'grv' => 1, 'gtm' => 1, 'tpl' => 1, 'vcg' => 1, 'hal' => 1, 'zmm' => 1, 'hbci' => 1, 'les' => 1, 'hpgl' => 1, 'hpid' => 1, 'hps' => 1, 'jlt' => 1, 'pcl' => 1, 'pclxl' => 1, 'sfd-hdstx' => 1, 'mpy' => 1,
+ 'afp' => 1, 'listafp' => 1, 'list3820' => 1, 'irm' => 1, 'sc' => 1, 'icc' => 1, 'icm' => 1, 'igl' => 1, 'ivp' => 1, 'ivu' => 1, 'igm' => 1, 'xpw' => 1, 'xpx' => 1, 'i2g' => 1, 'qbo' => 1, 'qfx' => 1,
+ 'rcprofile' => 1, 'irp' => 1, 'xpr' => 1, 'fcs' => 1, 'jam' => 1, 'rms' => 1, 'jisp' => 1, 'joda' => 1, 'ktz' => 1, 'ktr' => 1, 'karbon' => 1, 'chrt' => 1, 'kfo' => 1, 'flw' => 1, 'kon' => 1, 'kpr' => 1, 'kpt' => 1,
+ 'ksp' => 1, 'kwd' => 1, 'kwt' => 1, 'htke' => 1, 'kia' => 1, 'kne' => 1, 'knp' => 1, 'skp' => 1, 'skd' => 1, 'skt' => 1, 'skm' => 1, 'sse' => 1, 'lasxml' => 1, 'lbd' => 1, 'lbe' => 1, '123' => 1, 'apr' => 1,
+ 'pre' => 1, 'nsf' => 1, 'org' => 1, 'scm' => 1, 'lwp' => 1, 'portpkg' => 1, 'mcd' => 1, 'mc1' => 1, 'cdkey' => 1, 'mwf' => 1, 'mfm' => 1, 'flo' => 1, 'igx' => 1, 'mif' => 1, 'daf' => 1, 'dis' => 1, 'mbk' => 1,
+ 'mqy' => 1, 'msl' => 1, 'plc' => 1, 'txf' => 1, 'mpn' => 1, 'mpc' => 1, 'xul' => 1, 'cil' => 1, 'cab' => 1, 'xls' => 1, 'xlm' => 1, 'xla' => 1, 'xlc' => 1, 'xlt' => 1, 'xlw' => 1, 'xlam' => 1, 'xlsb' => 1, 'xlsm' => 1,
+ 'xltm' => 1, 'eot' => 1, 'chm' => 1, 'ims' => 1, 'lrm' => 1, 'thmx' => 1, 'cat' => 1, 'stl' => 1, 'ppt' => 1, 'pps' => 1, 'pot' => 1, 'ppam' => 1, 'pptm' => 1, 'sldm' => 1, 'ppsm' => 1, 'potm' => 1, 'mpp' => 1,
+ 'mpt' => 1, 'docm' => 1, 'dotm' => 1, 'wps' => 1, 'wks' => 1, 'wcm' => 1, 'wdb' => 1, 'wpl' => 1, 'xps' => 1, 'mseq' => 1, 'mus' => 1, 'msty' => 1, 'taglet' => 1, 'nlu' => 1, 'nitf' => 1, 'nitf' => 1, 'nnd' => 1,
+ 'nns' => 1, 'nnw' => 1, 'ngdat' => 1, 'n-gage' => 1, 'rpst' => 1, 'rpss' => 1, 'edm' => 1, 'edx' => 1, 'ext' => 1, 'odc' => 1, 'otc' => 1, 'odb' => 1, 'odf' => 1, 'odft' => 1, 'odg' => 1, 'otg' => 1, 'odi' => 1,
+ 'oti' => 1, 'odp' => 1, 'otp' => 1, 'ods' => 1, 'ots' => 1, 'odt' => 1, 'odm' => 1, 'ott' => 1, 'oth' => 1, 'xo' => 1, 'dd2' => 1, 'oxt' => 1, 'pptx' => 1, 'sldx' => 1, 'ppsx' => 1, 'potx' => 1, 'xlsx' => 1, 'xltx' => 1,
+ 'docx' => 1, 'dotx' => 1, 'mgp' => 1, 'dp' => 1, 'esa' => 1, 'pdb' => 1, 'pqa' => 1, 'oprc' => 1, 'paw' => 1, 'str' => 1, 'ei6' => 1, 'efif' => 1, 'wg' => 1, 'plf' => 1, 'pbd' => 1, 'box' => 1, 'mgz' => 1, 'qps' => 1,
+ 'ptid' => 1, 'qxd' => 1, 'qxt' => 1, 'qwd' => 1, 'qwt' => 1, 'qxl' => 1, 'qxb' => 1, 'bed' => 1, 'mxl' => 1, 'musicxml' => 1, 'cryptonote' => 1, 'cod' => 1, 'rm' => 1, 'rmvb' => 1, 'link66' => 1, 'st' => 1, 'see' => 1,
+ 'sema' => 1, 'semd' => 1, 'semf' => 1, 'ifm' => 1, 'itp' => 1, 'iif' => 1, 'ipk' => 1, 'twd' => 1, 'twds' => 1, 'mmf' => 1, 'teacher' => 1, 'sdkm' => 1, 'sdkd' => 1, 'dxp' => 1, 'sfs' => 1, 'sdc' => 1, 'sda' => 1,
+ 'sdd' => 1, 'smf' => 1, 'sdw' => 1, 'vor' => 1, 'sgl' => 1, 'smzip' => 1, 'sm' => 1, 'sxc' => 1, 'stc' => 1, 'sxd' => 1, 'std' => 1, 'sxi' => 1, 'sti' => 1, 'sxm' => 1, 'sxw' => 1, 'sxg' => 1, 'stw' => 1, 'sus' => 1,
+ 'susp' => 1, 'svd' => 1, 'sis' => 1, 'sisx' => 1, 'xsm' => 1, 'bdm' => 1, 'xdm' => 1, 'tao' => 1, 'pcap' => 1, 'cap' => 1, 'dmp' => 1, 'tmo' => 1, 'tpt' => 1, 'mxs' => 1, 'tra' => 1, 'ufd' => 1, 'ufdl' => 1, 'utz' => 1,
+ 'umj' => 1, 'unityweb' => 1, 'uoml' => 1, 'vcx' => 1, 'vsd' => 1, 'vst' => 1, 'vss' => 1, 'vsw' => 1, 'vis' => 1, 'vsf' => 1, 'wbxml' => 1, 'wmlc' => 1, 'wmlsc' => 1, 'wtb' => 1, 'nbp' => 1, 'wpd' => 1, 'wqd' => 1,
+ 'stf' => 1, 'xar' => 1, 'xfdl' => 1, 'hvd' => 1, 'hvs' => 1, 'hvp' => 1, 'osf' => 1, 'osfpvg' => 1, 'saf' => 1, 'spf' => 1, 'cmp' => 1, 'zir' => 1, 'zirz' => 1, 'zaz' => 1, 'vxml' => 1, 'wgt' => 1, 'hlp' => 1, 'wsdl' => 1,
+ 'wspolicy' => 1, '7z' => 1, 'abw' => 1, 'ace' => 1, 'dmg' => 1, 'aab' => 1, 'x32' => 1, 'u32' => 1, 'vox' => 1, 'aam' => 1, 'aas' => 1, 'bcpio' => 1, 'torrent' => 1, 'blb' => 1, 'blorb' => 1, 'bz' => 1, 'bz2' => 1,
+ 'boz' => 1, 'cbr' => 1, 'cba' => 1, 'cbt' => 1, 'cbz' => 1, 'cb7' => 1, 'vcd' => 1, 'cfs' => 1, 'chat' => 1, 'pgn' => 1, 'nsc' => 1, 'cpio' => 1, 'csh' => 1, 'deb' => 1, 'udeb' => 1, 'dgc' => 1, 'dir' => 1, 'dcr' => 1,
+ 'dxr' => 1, 'cst' => 1, 'cct' => 1, 'cxt' => 1, 'w3d' => 1, 'fgd' => 1, 'swa' => 1, 'wad' => 1, 'ncx' => 1, 'dtb' => 1, 'res' => 1, 'dvi' => 1, 'evy' => 1, 'eva' => 1, 'bdf' => 1, 'gsf' => 1, 'psf' => 1, 'otf' => 1,
+ 'pcf' => 1, 'snf' => 1, 'ttf' => 1, 'ttc' => 1, 'pfa' => 1, 'pfb' => 1, 'pfm' => 1, 'afm' => 1, 'woff' => 1, 'arc' => 1, 'spl' => 1, 'gca' => 1, 'ulx' => 1, 'gnumeric' => 1, 'gramps' => 1, 'gtar' => 1, 'hdf' => 1,
+ 'install' => 1, 'iso' => 1, 'jnlp' => 1, 'latex' => 1, 'lzh' => 1, 'lha' => 1, 'mie' => 1, 'prc' => 1, 'mobi' => 1, 'application' => 1, 'lnk' => 1, 'wmd' => 1, 'wmz' => 1, 'xbap' => 1, 'mdb' => 1, 'obd' => 1,
+ 'crd' => 1, 'clp' => 1, 'exe' => 1, 'dll' => 1, 'com' => 1, 'bat' => 1, 'msi' => 1, 'mvb' => 1, 'm13' => 1, 'm14' => 1, 'wmf' => 1, 'wmz' => 1, 'emf' => 1, 'emz' => 1, 'mny' => 1, 'pub' => 1, 'scd' => 1, 'trm' => 1,
+ 'wri' => 1, 'nc' => 1, 'cdf' => 1, 'nzb' => 1, 'p12' => 1, 'pfx' => 1, 'p7b' => 1, 'spc' => 1, 'p7r' => 1, 'rar' => 1, 'ris' => 1, 'sh' => 1, 'shar' => 1, 'swf' => 1, 'xap' => 1, 'sql' => 1, 'sit' => 1, 'sitx' => 1,
+ 'srt' => 1, 'sv4cpio' => 1, 'sv4crc' => 1, 't3' => 1, 'gam' => 1, 'tar' => 1, 'tcl' => 1, 'tex' => 1, 'tfm' => 1, 'texinfo' => 1, 'texi' => 1, 'obj' => 1, 'ustar' => 1, 'src' => 1, 'der' => 1, 'crt' => 1, 'fig' => 1,
+ 'xlf' => 1, 'xpi' => 1, 'xz' => 1, 'z1' => 1, 'z2' => 1, 'z3' => 1, 'z4' => 1, 'z5' => 1, 'z6' => 1, 'z7' => 1, 'z8' => 1, 'xaml' => 1, 'xdf' => 1, 'xenc' => 1, 'xhtml' => 1, 'xht' => 1, 'xml' => 1, 'xsl' => 1, 'dtd' => 1,
+ 'xop' => 1, 'xpl' => 1, 'xslt' => 1, 'xspf' => 1, 'mxml' => 1, 'xhvml' => 1, 'xvml' => 1, 'xvm' => 1, 'yang' => 1, 'yin' => 1, 'zip' => 1, 'adp' => 1, 'au' => 1, 'snd' => 1, 'mid' => 1, 'midi' => 1, 'kar' => 1, 'rmi' => 1,
+ 'mp4a' => 1, 'mpga' => 1, 'mp2' => 1, 'mp2a' => 1, 'mp3' => 1, 'm2a' => 1, 'm3a' => 1, 'oga' => 1, 'ogg' => 1, 'spx' => 1, 's3m' => 1, 'sil' => 1, 'uva' => 1, 'uvva' => 1, 'eol' => 1, 'dra' => 1, 'dts' => 1, 'dtshd' => 1,
+ 'lvp' => 1, 'pya' => 1, 'ecelp4800' => 1, 'ecelp7470' => 1, 'ecelp9600' => 1, 'rip' => 1, 'weba' => 1, 'aac' => 1, 'aif' => 1, 'aiff' => 1, 'aifc' => 1, 'caf' => 1, 'flac' => 1, 'mka' => 1, 'm3u' => 1, 'wax' => 1,
+ 'wma' => 1, 'ram' => 1, 'ra' => 1, 'rmp' => 1, 'wav' => 1, 'xm' => 1, 'cdx' => 1, 'cif' => 1, 'cmdf' => 1, 'cml' => 1, 'csml' => 1, 'xyz' => 1, 'bmp' => 1, 'cgm' => 1, 'g3' => 1, 'gif' => 1, 'ief' => 1, 'jpeg' => 1,
+ 'jpg' => 1, 'jpe' => 1, 'ktx' => 1, 'png' => 1, 'btif' => 1, 'sgi' => 1, 'svg' => 1, 'svgz' => 1, 'tiff' => 1, 'tif' => 1, 'psd' => 1, 'uvi' => 1, 'uvvi' => 1, 'uvg' => 1, 'uvvg' => 1, 'sub' => 1, 'djvu' => 1, 'djv' => 1,
+ 'dwg' => 1, 'dxf' => 1, 'fbs' => 1, 'fpx' => 1, 'fst' => 1, 'mmr' => 1, 'rlc' => 1, 'mdi' => 1, 'wdp' => 1, 'npx' => 1, 'wbmp' => 1, 'xif' => 1, 'webp' => 1, '3ds' => 1, 'ras' => 1, 'cmx' => 1, 'fh' => 1, 'fhc' => 1,
+ 'fh4' => 1, 'fh5' => 1, 'fh7' => 1, 'ico' => 1, 'sid' => 1, 'pcx' => 1, 'pic' => 1, 'pct' => 1, 'pnm' => 1, 'pbm' => 1, 'pgm' => 1, 'ppm' => 1, 'rgb' => 1, 'tga' => 1, 'xbm' => 1, 'xpm' => 1, 'xwd' => 1, 'eml' => 1,
+ 'mime' => 1, 'igs' => 1, 'iges' => 1, 'msh' => 1, 'mesh' => 1, 'silo' => 1, 'dae' => 1, 'dwf' => 1, 'gdl' => 1, 'gtw' => 1, 'mts' => 1, 'vtu' => 1, 'wrl' => 1, 'vrml' => 1, 'x3db' => 1, 'x3dbz' => 1, 'x3dv' => 1,
+ 'x3dvz' => 1, 'x3d' => 1, 'x3dz' => 1, '3gp' => 1, '3g2' => 1, 'h261' => 1, 'h263' => 1, 'h264' => 1, 'jpgv' => 1, 'jpm' => 1, 'jpgm' => 1, 'mj2' => 1, 'mjp2' => 1, 'mp4' => 1, 'mp4v' => 1, 'mpg4' => 1, 'mpeg' => 1,
+ 'mpg' => 1, 'mpe' => 1, 'm1v' => 1, 'm2v' => 1, 'ogv' => 1, 'qt' => 1, 'mov' => 1, 'uvh' => 1, 'uvvh' => 1, 'uvm' => 1, 'uvvm' => 1, 'uvp' => 1, 'uvvp' => 1, 'uvs' => 1, 'uvvs' => 1, 'uvv' => 1, 'uvvv' => 1, 'dvb' => 1,
+ 'fvt' => 1, 'mxu' => 1, 'm4u' => 1, 'pyv' => 1, 'uvu' => 1, 'uvvu' => 1, 'viv' => 1, 'webm' => 1, 'f4v' => 1, 'fli' => 1, 'flv' => 1, 'm4v' => 1, 'mkv' => 1, 'mk3d' => 1, 'mks' => 1, 'mng' => 1, 'asf' => 1, 'asx' => 1,
+ 'vob' => 1, 'wm' => 1, 'wmv' => 1, 'wmx' => 1, 'wvx' => 1, 'avi' => 1, 'movie' => 1, 'smv' => 1, 'ice' => 1,
);
/**
@@ -279,6 +282,16 @@ class EmbedFilter
return $GLOBALS['__EMBEDFILTER_INSTANCE__'];
}
+ public function getWhiteUrlList()
+ {
+ return $this->whiteUrlList;
+ }
+
+ public function getWhiteIframeUrlList()
+ {
+ return $this->whiteIframeUrlList;
+ }
+
/**
* Check the content.
* @return void
@@ -300,11 +313,11 @@ class EmbedFilter
*/
function checkObjectTag(&$content)
{
- preg_match_all('/<\s*object\s*[^>]+(?:\/?>)/is', $content, $m);
+ preg_match_all('/<\s*object\s*[^>]+(?:\/?>?)/is', $content, $m);
$objectTagList = $m[0];
if($objectTagList)
{
- foreach($objectTagList AS $key=>$objectTag)
+ foreach($objectTagList AS $key => $objectTag)
{
$isWhiteDomain = true;
$isWhiteMimetype = true;
@@ -316,12 +329,12 @@ class EmbedFilter
{
if(is_array($parser->iNodeAttributes))
{
- foreach($parser->iNodeAttributes AS $attrName=>$attrValue)
+ foreach($parser->iNodeAttributes AS $attrName => $attrValue)
{
// data url check
if($attrValue && strtolower($attrName) == 'data')
{
- $ext = strtolower(substr(strrchr($attrValue,"."),1));
+ $ext = strtolower(substr(strrchr($attrValue, "."), 1));
$isWhiteDomain = $this->isWhiteDomain($attrValue);
}
@@ -353,15 +366,15 @@ class EmbedFilter
*/
function checkEmbedTag(&$content)
{
- preg_match_all('/<\s*embed\s*[^>]+(?:\/?>)/is', $content, $m);
+ preg_match_all('/<\s*embed\s*[^>]+(?:\/?>?)/is', $content, $m);
$embedTagList = $m[0];
if($embedTagList)
{
- foreach($embedTagList AS $key=>$embedTag)
+ foreach($embedTagList AS $key => $embedTag)
{
- $isWhiteDomain = true;
- $isWhiteMimetype = true;
- $isWhiteExt = true;
+ $isWhiteDomain = TRUE;
+ $isWhiteMimetype = TRUE;
+ $isWhiteExt = TRUE;
$ext = '';
$parser = new HtmlParser($embedTag);
@@ -369,12 +382,12 @@ class EmbedFilter
{
if(is_array($parser->iNodeAttributes))
{
- foreach($parser->iNodeAttributes AS $attrName=>$attrValue)
+ foreach($parser->iNodeAttributes AS $attrName => $attrValue)
{
// src url check
if($attrValue && strtolower($attrName) == 'src')
{
- $ext = strtolower(substr(strrchr($attrValue,"."),1));
+ $ext = strtolower(substr(strrchr($attrValue, "."), 1));
$isWhiteDomain = $this->isWhiteDomain($attrValue);
}
@@ -406,13 +419,16 @@ class EmbedFilter
*/
function checkIframeTag(&$content)
{
- preg_match_all('/<\s*iframe\s*[^>]+(?:\/?>)/is', $content, $m);
+ // check in Purifier class
+ return;
+
+ preg_match_all('/<\s*iframe\s*[^>]+(?:\/?>?)/is', $content, $m);
$iframeTagList = $m[0];
if($iframeTagList)
{
- foreach($iframeTagList AS $key=>$iframeTag)
+ foreach($iframeTagList AS $key => $iframeTag)
{
- $isWhiteDomain = true;
+ $isWhiteDomain = TRUE;
$ext = '';
$parser = new HtmlParser($iframeTag);
@@ -420,12 +436,12 @@ class EmbedFilter
{
if(is_array($parser->iNodeAttributes))
{
- foreach($parser->iNodeAttributes AS $attrName=>$attrValue)
+ foreach($parser->iNodeAttributes AS $attrName => $attrValue)
{
// src url check
if(strtolower($attrName) == 'src' && $attrValue)
{
- $ext = strtolower(substr(strrchr($attrValue,"."),1));
+ $ext = strtolower(substr(strrchr($attrValue, "."), 1));
$isWhiteDomain = $this->isWhiteIframeDomain($attrValue);
}
}
@@ -446,14 +462,14 @@ class EmbedFilter
*/
function checkParamTag(&$content)
{
- preg_match_all('/<\s*param\s*[^>]+(?:\/?>)/is', $content, $m);
+ preg_match_all('/<\s*param\s*[^>]+(?:\/?>?)/is', $content, $m);
$paramTagList = $m[0];
if($paramTagList)
{
- foreach($paramTagList AS $key=>$paramTag)
+ foreach($paramTagList AS $key => $paramTag)
{
- $isWhiteDomain = true;
- $isWhiteExt = true;
+ $isWhiteDomain = TRUE;
+ $isWhiteExt = TRUE;
$ext = '';
$parser = new HtmlParser($paramTag);
@@ -464,7 +480,7 @@ class EmbedFilter
$name = strtolower($parser->iNodeAttributes['name']);
if($name == 'movie' || $name == 'src' || $name == 'href' || $name == 'url' || $name == 'source')
{
- $ext = strtolower(substr(strrchr($parser->iNodeAttributes['value'],"."),1));
+ $ext = strtolower(substr(strrchr($parser->iNodeAttributes['value'], "."), 1));
$isWhiteDomain = $this->isWhiteDomain($parser->iNodeAttributes['value']);
if(!$isWhiteDomain && $ext)
@@ -491,15 +507,15 @@ class EmbedFilter
{
if(is_array($this->whiteUrlList))
{
- foreach($this->whiteUrlList AS $key=>$value)
+ foreach($this->whiteUrlList AS $key => $value)
{
- if(preg_match('@^'.preg_quote($value).'@i', $urlAttribute))
+ if(preg_match('@^' . preg_quote($value) . '@i', $urlAttribute))
{
- return true;
+ return TRUE;
}
}
}
- return false;
+ return FALSE;
}
/**
@@ -510,15 +526,15 @@ class EmbedFilter
{
if(is_array($this->whiteIframeUrlList))
{
- foreach($this->whiteIframeUrlList AS $key=>$value)
+ foreach($this->whiteIframeUrlList AS $key => $value)
{
- if(preg_match('@^'.preg_quote($value).'@i', $urlAttribute))
+ if(preg_match('@^' . preg_quote($value) . '@i', $urlAttribute))
{
- return true;
+ return TRUE;
}
}
}
- return false;
+ return FALSE;
}
/**
@@ -529,18 +545,18 @@ class EmbedFilter
{
if(isset($this->mimeTypeList[$mimeType]))
{
- return true;
+ return TRUE;
}
- return false;
+ return FALSE;
}
function isWhiteExt($ext)
{
if(isset($this->extList[$ext]))
{
- return true;
+ return TRUE;
}
- return false;
+ return FALSE;
}
function _checkAllowScriptAccess($m)
@@ -559,7 +575,7 @@ class EmbedFilter
{
$m[0] .= '/';
}
- $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
+ $this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--;
}
}
else if($m[1] == 'embed')
@@ -580,7 +596,7 @@ class EmbedFilter
{
if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
{
- $m[0] = $m[0].' ';
+ $m[0] = $m[0] . ' ';
}
$this->allowscriptaccessKey++;
return $m[0];
@@ -600,7 +616,7 @@ class EmbedFilter
{
$isMake = true;
}
- if( file_exists($whiteUrlCacheFile) && filemtime($whiteUrlCacheFile)whiteurl->embed->domain;
$iframeDomainList = $domainListObj->whiteurl->iframe->domain;
- $buff = '$value)
+ foreach($embedDomainList AS $key => $value)
{
$patternList = $value->pattern;
if(is_array($patternList))
{
- foreach($patternList AS $key=>$value)
+ foreach($patternList AS $key => $value)
{
$buff .= sprintf('$whiteUrlList[] = \'%s\';', $value->body);
}
}
- else $buff .= sprintf('$whiteUrlList[] = \'%s\';', $patternList->body);
+ else
+ $buff .= sprintf('$whiteUrlList[] = \'%s\';', $patternList->body);
}
}
if(is_array($iframeDomainList))
{
- foreach($iframeDomainList AS $key=>$value)
+ foreach($iframeDomainList AS $key => $value)
{
$patternList = $value->pattern;
if(is_array($patternList))
{
- foreach($patternList AS $key=>$value)
+ foreach($patternList AS $key => $value)
{
$buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', $value->body);
}
}
- else $buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', $patternList->body);
+ else
+ $buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', $patternList->body);
}
}
+
+ if(Context::getDefaultUrl())
+ {
+ $buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', Context::getDefaultUrl());
+ }
$buff .= '?>';
FileHandler::writeFile($this->whiteUrlCacheFile, $buff);
}
}
+
}
/* End of file : EmbedFilter.class.php */
+/* Location: ./classes/security/EmbedFilter.class.php */
diff --git a/classes/security/Purifier.class.php b/classes/security/Purifier.class.php
new file mode 100644
index 000000000..10fb74708
--- /dev/null
+++ b/classes/security/Purifier.class.php
@@ -0,0 +1,180 @@
+_checkCacheDir();
+
+ // purifier setting
+ require_once _XE_PATH_ . 'classes/security/htmlpurifier/library/HTMLPurifier.auto.php';
+ require_once 'HTMLPurifier.func.php';
+
+ $this->_setConfig();
+ }
+
+ public function getInstance()
+ {
+ if(!isset($GLOBALS['__PURIFIER_INSTANCE__']))
+ {
+ $GLOBALS['__PURIFIER_INSTANCE__'] = new Purifier();
+ }
+ return $GLOBALS['__PURIFIER_INSTANCE__'];
+ }
+
+ private function _setConfig()
+ {
+ $whiteDomainRegex = $this->_getWhiteDomainRegx();
+ //$allowdClasses = array('emoticon');
+
+ $this->_config = HTMLPurifier_Config::createDefault();
+ $this->_config->set('HTML.TidyLevel', 'light');
+ $this->_config->set('Output.FlashCompat', TRUE);
+ $this->_config->set('HTML.SafeObject', TRUE);
+ $this->_config->set('HTML.SafeEmbed', TRUE);
+ $this->_config->set('HTML.SafeIframe', TRUE);
+ $this->_config->set('URI.SafeIframeRegexp', $whiteDomainRegex);
+ $this->_config->set('Cache.SerializerPath', $this->_cacheDir);
+ //$this->_config->set('Attr.AllowedClasses', $allowdClasses);
+
+ $this->_def = $this->_config->getHTMLDefinition(TRUE);
+ }
+
+ private function _setDefinition(&$content)
+ {
+ // add attribute for edit component
+ $editComponentAttrs = $this->_searchEditComponent($content);
+ if(is_array($editComponentAttrs))
+ {
+ foreach($editComponentAttrs AS $k => $v)
+ {
+ $this->_def->addAttribute('img', $v, 'CDATA');
+ $this->_def->addAttribute('div', $v, 'CDATA');
+ }
+ }
+
+ // add attribute for widget component
+ $widgetAttrs = $this->_searchWidget($content);
+ if(is_array($widgetAttrs))
+ {
+ foreach($widgetAttrs AS $k => $v)
+ {
+ $this->_def->addAttribute('img', $v, 'CDATA');
+ }
+ }
+ }
+
+ /**
+ * Search attribute of edit component tag
+ * @param string $content
+ * @return array
+ */
+ private function _searchEditComponent($content)
+ {
+ preg_match_all('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?) )!is', $content, $m);
+
+ $attributeList = array();
+ if(is_array($m[2]))
+ {
+ foreach($m[2] AS $key => $value)
+ {
+ unset($script, $m2);
+ $script = " {$m[2][$key]} editor_component={$m[3][$key]}";
+
+ preg_match_all('/([a-z0-9_-]+)="([^"]+)"/is', $script, $m2);
+ if(is_array($m2[1]))
+ {
+ foreach($m2[1] AS $key2 => $value2)
+ {
+ array_push($attributeList, $value2);
+ }
+ }
+ }
+ }
+ return array_unique($attributeList);
+ }
+
+ /**
+ * Search edit component tag
+ * @param string $content
+ * @return array
+ */
+ private function _searchWidget(&$content)
+ {
+ preg_match_all('!<(?:(div)|img)([^>]*)class="zbxe_widget_output"([^>]*)>(?(1)(.*?)