Browse files

1.2.6 changes

  • Loading branch information...
1 parent d97d8f9 commit 9789a769a8a253df5dbebf623d38d1c34b2d97ea @ericmmartin ericmmartin committed Feb 11, 2011
Showing with 444 additions and 419 deletions.
  1. +21 −4 js/jquery.simplemodal.js
  2. +243 −246 js/smcf.js
  3. +13 −13 lang/readme.txt
  4. +13 −18 smcf.php
  5. +140 −138 smcf_data.php
  6. +14 −0 uninstall.php
View
25 js/jquery.simplemodal.js
@@ -1,8 +1,25 @@
/*
- * SimpleModal 1.3.3 - jQuery Plugin
+ * SimpleModal 1.4.1 - jQuery Plugin
* http://www.ericmmartin.com/projects/simplemodal/
- * Copyright (c) 2009 Eric Martin (http://twitter.com/EricMMartin)
+ * Copyright (c) 2010 Eric Martin (http://twitter.com/ericmmartin)
* Dual licensed under the MIT and GPL licenses
- * Revision: $Id: jquery.simplemodal.js 228 2009-10-30 13:34:27Z emartin24 $
+ * Revision: $Id: jquery.simplemodal.js 259 2010-11-05 05:53:13Z emartin24 $
*/
-;(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},minHeight:200,minWidth:300,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:false,position:null,persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={o:null,d:{},init:function(data,options){var s=this;if(s.d.data){return false;}ieQuirks=$.browser.msie&&!$.boxModel;s.o=$.extend({},$.modal.defaults,options);s.zIndex=s.o.zIndex;s.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){s.d.parentNode=data.parent();if(!s.o.persist){s.d.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div></div>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return s;}s.create(data);data=null;s.open();if($.isFunction(s.o.onShow)){s.o.onShow.apply(s,[s.d]);}return s;},create:function(data){var s=this;w=s.getDimensions();if(ie6){s.d.iframe=$('<iframe src="javascript:false;"></iframe>').css($.extend(s.o.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:s.o.zIndex,top:0,left:0})).appendTo(s.o.appendTo);}s.d.overlay=$('<div></div>').attr('id',s.o.overlayId).addClass('simplemodal-overlay').css($.extend(s.o.overlayCss,{display:'none',opacity:s.o.opacity/100,height:w[0],width:w[1],position:'fixed',left:0,top:0,zIndex:s.o.zIndex+1})).appendTo(s.o.appendTo);s.d.container=$('<div></div>').attr('id',s.o.containerId).addClass('simplemodal-container').css($.extend(s.o.containerCss,{display:'none',position:'fixed',zIndex:s.o.zIndex+2})).append(s.o.close&&s.o.closeHTML?$(s.o.closeHTML).addClass(s.o.closeClass):'').appendTo(s.o.appendTo);s.d.wrap=$('<div></div>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(s.d.container);s.d.data=data.attr('id',data.attr('id')||s.o.dataId).addClass('simplemodal-data').css($.extend(s.o.dataCss,{display:'none'})).appendTo('body');data=null;s.setContainerDimensions();s.d.data.appendTo(s.d.wrap);if(ie6||ieQuirks){s.fixIE();}},bindEvents:function(){var s=this;$('.'+s.o.closeClass).bind('click.simplemodal',function(e){e.preventDefault();s.close();});if(s.o.close&&s.o.overlayClose){s.d.overlay.bind('click.simplemodal',function(e){e.preventDefault();s.close();});}$(document).bind('keydown.simplemodal',function(e){if(s.o.focus&&e.keyCode==9){s.watchTab(e);}else if((s.o.close&&s.o.escClose)&&e.keyCode==27){e.preventDefault();s.close();}});$(window).bind('resize.simplemodal',function(){w=s.getDimensions();s.setContainerDimensions(true);if(ie6||ieQuirks){s.fixIE();}else{s.d.iframe&&s.d.iframe.css({height:w[0],width:w[1]});s.d.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.o.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.d.overlay.unbind('click.simplemodal');},fixIE:function(){var s=this,p=s.o.position;$.each([s.d.iframe||null,s.d.overlay,s.d.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var s=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,s.d.wrap);input.length>0?input.focus():s.d.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:v.indexOf('%')>0?v:parseInt(v.replace(/px/,''));},setContainerDimensions:function(resize){var s=this;if(!resize||(resize&&s.o.autoResize)){var ch=s.getVal(s.d.container.css('height')),cw=s.getVal(s.d.container.css('width')),dh=s.d.data.outerHeight(true),dw=s.d.data.outerWidth(true);var mh=s.o.maxHeight&&s.o.maxHeight<w[0]?s.o.maxHeight:w[0],mw=s.o.maxWidth&&s.o.maxWidth<w[1]?s.o.maxWidth:w[1];if(!ch){if(!dh){ch=s.o.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<s.o.minHeight){ch=s.o.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=s.o.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<s.o.minWidth){cw=s.o.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}s.d.container.css({height:ch,width:cw});if(dh>ch||dw>cw){s.d.wrap.css({overflow:'auto'});}}if(s.o.autoPosition){s.setPosition();}},setPosition:function(){var s=this,top,left,hc=(w[0]/2)-(s.d.container.outerHeight(true)/2),vc=(w[1]/2)-(s.d.container.outerWidth(true)/2);if(s.o.position&&Object.prototype.toString.call(s.o.position)==="[object Array]"){top=s.o.position[0]||hc;left=s.o.position[1]||vc;}else{top=hc;left=vc;}s.d.container.css({left:left,top:top});},watchTab:function(e){var s=this;if($(e.target).parents('.simplemodal-container').length>0){s.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',s.d.data[0]);if((!e.shiftKey&&e.target==s.inputs[s.inputs.length-1])||(e.shiftKey&&e.target==s.inputs[0])||s.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){s.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){s.focus();},10);}},open:function(){var s=this;s.d.iframe&&s.d.iframe.show();if($.isFunction(s.o.onOpen)){s.o.onOpen.apply(s,[s.d]);}else{s.d.overlay.show();s.d.container.show();s.d.data.show();}s.focus();s.bindEvents();},close:function(){var s=this;if(!s.d.data){return false;}s.unbindEvents();if($.isFunction(s.o.onClose)&&!s.occb){s.occb=true;s.o.onClose.apply(s,[s.d]);}else{if(s.d.parentNode){if(s.o.persist){s.d.data.hide().appendTo(s.d.parentNode);}else{s.d.data.hide().remove();s.d.orig.appendTo(s.d.parentNode);}}else{s.d.data.hide().remove();}s.d.container.hide().remove();s.d.overlay.hide().remove();s.d.iframe&&s.d.iframe.hide().remove();s.d={};}}};})(jQuery);
+(function(d){var k=d.browser.msie&&parseInt(d.browser.version)===6&&typeof window.XMLHttpRequest!=="object",m=d.browser.msie&&parseInt(d.browser.version)===7,l=null,f=[];d.modal=function(a,b){return d.modal.impl.init(a,b)};d.modal.close=function(){d.modal.impl.close()};d.modal.focus=function(a){d.modal.impl.focus(a)};d.modal.setContainerDimensions=function(){d.modal.impl.setContainerDimensions()};d.modal.setPosition=function(){d.modal.impl.setPosition()};d.modal.update=function(a,b){d.modal.impl.update(a,
+b)};d.fn.modal=function(a){return d.modal.impl.init(this,a)};d.modal.defaults={appendTo:"body",focus:true,opacity:50,overlayId:"simplemodal-overlay",overlayCss:{},containerId:"simplemodal-container",containerCss:{},dataId:"simplemodal-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1E3,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:"simplemodal-close",escClose:true,overlayClose:false,position:null,
+persist:false,modal:true,onOpen:null,onShow:null,onClose:null};d.modal.impl={d:{},init:function(a,b){var c=this;if(c.d.data)return false;l=d.browser.msie&&!d.boxModel;c.o=d.extend({},d.modal.defaults,b);c.zIndex=c.o.zIndex;c.occb=false;if(typeof a==="object"){a=a instanceof jQuery?a:d(a);c.d.placeholder=false;if(a.parent().parent().size()>0){a.before(d("<span></span>").attr("id","simplemodal-placeholder").css({display:"none"}));c.d.placeholder=true;c.display=a.css("display");if(!c.o.persist)c.d.orig=
+a.clone(true)}}else if(typeof a==="string"||typeof a==="number")a=d("<div></div>").html(a);else{alert("SimpleModal Error: Unsupported data type: "+typeof a);return c}c.create(a);c.open();d.isFunction(c.o.onShow)&&c.o.onShow.apply(c,[c.d]);return c},create:function(a){var b=this;f=b.getDimensions();if(b.o.modal&&k)b.d.iframe=d('<iframe src="javascript:false;"></iframe>').css(d.extend(b.o.iframeCss,{display:"none",opacity:0,position:"fixed",height:f[0],width:f[1],zIndex:b.o.zIndex,top:0,left:0})).appendTo(b.o.appendTo);
+b.d.overlay=d("<div></div>").attr("id",b.o.overlayId).addClass("simplemodal-overlay").css(d.extend(b.o.overlayCss,{display:"none",opacity:b.o.opacity/100,height:b.o.modal?f[0]:0,width:b.o.modal?f[1]:0,position:"fixed",left:0,top:0,zIndex:b.o.zIndex+1})).appendTo(b.o.appendTo);b.d.container=d("<div></div>").attr("id",b.o.containerId).addClass("simplemodal-container").css(d.extend(b.o.containerCss,{display:"none",position:"fixed",zIndex:b.o.zIndex+2})).append(b.o.close&&b.o.closeHTML?d(b.o.closeHTML).addClass(b.o.closeClass):
+"").appendTo(b.o.appendTo);b.d.wrap=d("<div></div>").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(b.d.container);b.d.data=a.attr("id",a.attr("id")||b.o.dataId).addClass("simplemodal-data").css(d.extend(b.o.dataCss,{display:"none"})).appendTo("body");b.setContainerDimensions();b.d.data.appendTo(b.d.wrap);if(k||l)b.fixIE()},bindEvents:function(){var a=this;d("."+a.o.closeClass).bind("click.simplemodal",function(b){b.preventDefault();a.close()});
+a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.simplemodal",function(b){b.preventDefault();a.close()});d(document).bind("keydown.simplemodal",function(b){if(a.o.modal&&b.keyCode===9)a.watchTab(b);else if(a.o.close&&a.o.escClose&&b.keyCode===27){b.preventDefault();a.close()}});d(window).bind("resize.simplemodal",function(){f=a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();if(k||l)a.fixIE();else if(a.o.modal){a.d.iframe&&a.d.iframe.css({height:f[0],
+width:f[1]});a.d.overlay.css({height:f[0],width:f[1]})}})},unbindEvents:function(){d("."+this.o.closeClass).unbind("click.simplemodal");d(document).unbind("keydown.simplemodal");d(window).unbind("resize.simplemodal");this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var a=this,b=a.o.position;d.each([a.d.iframe||null,!a.o.modal?null:a.d.overlay,a.d.container],function(c,h){if(h){var g=h[0].style;g.position="absolute";if(c<2){g.removeExpression("height");g.removeExpression("width");g.setExpression("height",
+'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"');g.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"')}else{var e;if(b&&b.constructor===Array){c=b[0]?typeof b[0]==="number"?b[0].toString():b[0].replace(/px/,""):h.css("top").replace(/px/,"");c=c.indexOf("%")===-1?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':
+parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';if(b[1]){e=typeof b[1]==="number"?b[1].toString():b[1].replace(/px/,"");e=e.indexOf("%")===-1?e+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(e.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}}else{c=
+'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';e='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}g.removeExpression("top");g.removeExpression("left");g.setExpression("top",
+c);g.setExpression("left",e)}}})},focus:function(a){var b=this;a=a&&d.inArray(a,["first","last"])!==-1?a:"first";var c=d(":input:enabled:visible:"+a,b.d.wrap);setTimeout(function(){c.length>0?c.focus():b.d.wrap.focus()},10)},getDimensions:function(){var a=d(window);return[d.browser.opera&&d.browser.version>"9.5"&&d.fn.jquery<"1.3"||d.browser.opera&&d.browser.version<"9.5"&&d.fn.jquery>"1.2.6"?a[0].innerHeight:a.height(),a.width()]},getVal:function(a,b){return a?typeof a==="number"?a:a==="auto"?0:
+a.indexOf("%")>0?parseInt(a.replace(/%/,""))/100*(b==="h"?f[0]:f[1]):parseInt(a.replace(/px/,"")):null},update:function(a,b){var c=this;if(!c.d.data)return false;c.d.origHeight=c.getVal(a,"h");c.d.origWidth=c.getVal(b,"w");c.d.data.hide();a&&c.d.container.css("height",a);b&&c.d.container.css("width",b);c.setContainerDimensions();c.d.data.show();c.o.focus&&c.focus();c.unbindEvents();c.bindEvents()},setContainerDimensions:function(){var a=this,b=k||m,c=a.d.origHeight?a.d.origHeight:d.browser.opera?
+a.d.container.height():a.getVal(b?a.d.container[0].currentStyle.height:a.d.container.css("height"),"h");b=a.d.origWidth?a.d.origWidth:d.browser.opera?a.d.container.width():a.getVal(b?a.d.container[0].currentStyle.width:a.d.container.css("width"),"w");var h=a.d.data.outerHeight(true),g=a.d.data.outerWidth(true);a.d.origHeight=a.d.origHeight||c;a.d.origWidth=a.d.origWidth||b;var e=a.o.maxHeight?a.getVal(a.o.maxHeight,"h"):null,i=a.o.maxWidth?a.getVal(a.o.maxWidth,"w"):null;e=e&&e<f[0]?e:f[0];i=i&&i<
+f[1]?i:f[1];var j=a.o.minHeight?a.getVal(a.o.minHeight,"h"):"auto";c=c?a.o.autoResize&&c>e?e:c<j?j:c:h?h>e?e:a.o.minHeight&&j!=="auto"&&h<j?j:h:j;e=a.o.minWidth?a.getVal(a.o.minWidth,"w"):"auto";b=b?a.o.autoResize&&b>i?i:b<e?e:b:g?g>i?i:a.o.minWidth&&e!=="auto"&&g<e?e:g:e;a.d.container.css({height:c,width:b});a.d.wrap.css({overflow:h>c||g>b?"auto":"visible"});a.o.autoPosition&&a.setPosition()},setPosition:function(){var a=this,b,c;b=f[0]/2-a.d.container.outerHeight(true)/2;c=f[1]/2-a.d.container.outerWidth(true)/
+2;if(a.o.position&&Object.prototype.toString.call(a.o.position)==="[object Array]"){b=a.o.position[0]||b;c=a.o.position[1]||c}else{b=b;c=c}a.d.container.css({left:c,top:b})},watchTab:function(a){var b=this;if(d(a.target).parents(".simplemodal-container").length>0){b.inputs=d(":input:enabled:visible:first, :input:enabled:visible:last",b.d.data[0]);if(!a.shiftKey&&a.target===b.inputs[b.inputs.length-1]||a.shiftKey&&a.target===b.inputs[0]||b.inputs.length===0){a.preventDefault();b.focus(a.shiftKey?"last":
+"first")}}else{a.preventDefault();b.focus()}},open:function(){var a=this;a.d.iframe&&a.d.iframe.show();if(d.isFunction(a.o.onOpen))a.o.onOpen.apply(a,[a.d]);else{a.d.overlay.show();a.d.container.show();a.d.data.show()}a.o.focus&&a.focus();a.bindEvents()},close:function(){var a=this;if(!a.d.data)return false;a.unbindEvents();if(d.isFunction(a.o.onClose)&&!a.occb){a.occb=true;a.o.onClose.apply(a,[a.d])}else{if(a.d.placeholder){var b=d("#simplemodal-placeholder");if(a.o.persist)b.replaceWith(a.d.data.removeClass("simplemodal-data").css("display",
+a.display));else{a.d.data.hide().remove();b.replaceWith(a.d.orig)}}else a.d.data.hide().remove();a.d.container.hide().remove();a.d.overlay.hide();a.d.iframe&&a.d.iframe.hide().remove();setTimeout(function(){a.d.overlay.remove();a.d={}},10)}}}})(jQuery);
View
489 js/smcf.js
@@ -1,246 +1,243 @@
-// make sure jQuery and SimpleModal are loaded
-if (typeof jQuery !== "undefined" && typeof jQuery.modal !== "undefined") {
- jQuery(function ($) {
- $('.smcf_link, .smcf-link').click(function (e) { // added .smcf_link for previous version
- e.preventDefault();
- // display the contact form
- $('#smcf-content').modal({
- closeHTML: "<a href='#' title='Close' class='modalCloseX simplemodal-close'>x</a>",
- position: ["15%",],
- overlayId: 'smcf-overlay',
- containerId: 'smcf-container',
- onOpen: contact.open,
- onShow: contact.show,
- onClose: contact.close
- });
- });
-
- // preload images
- var img = ['cancel.png','form_bottom.gif','form_top.gif','loading.gif','send.png'];
- if ($('#smcf-content form').length > 0) {
- var url = $('#smcf-content form').attr('action').replace(/smcf_data\.php/, 'img/');
- $(img).each(function () {
- var i = new Image();
- i.src = url + this;
- });
- }
-
- var contact = {
- message: null,
- open: function (d) {
- // dynamically determine height
- var h = 280;
- if ($('#smcf-subject').length) {
- h += 26;
- }
- if ($('#smcf-cc').length) {
- h += 22;
- }
-
- // resize the textarea for safari
- if ($.browser.safari) {
- $('#smcf-container .smcf-input').css({
- 'font-size': '.9em'
- });
- }
-
- // add padding to the buttons in firefox/mozilla
- if ($.browser.mozilla) {
- $('#smcf-container .smcf-button').css({
- 'padding-bottom': '2px'
- });
- }
-
- var title = $('#smcf-container .smcf-title').html();
- $('#smcf-container .smcf-title').html(smcf_messages.loading);
- d.overlay.fadeIn(200, function () {
- d.container.fadeIn(200, function () {
- d.data.fadeIn(200, function () {
- $('#smcf-container .smcf-content').animate({
- height: h
- }, function () {
- $('#smcf-container .smcf-title').html(title);
- $('#smcf-container form').fadeIn(200, function () {
- $('#smcf-container #smcf-name').focus();
-
- $('#smcf-container .smcf-cc').click(function () {
- var cc = $('#smcf-container #smcf-cc');
- cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked');
- });
-
- // fix png's for IE 6
- if ($.browser.msie && $.browser.version < 7) {
- $('#smcf-container .smcf-button').each(function () {
- if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) {
- var src = RegExp.$1;
- $(this).css({
- backgroundImage: 'none',
- filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="crop")'
- });
- }
- });
- }
- });
- });
- });
- });
- });
- },
- show: function (d) {
- $('#smcf-container .smcf-send').click(function (e) {
- e.preventDefault();
- // validate form
- if (contact.validate()) {
- $('#smcf-container .smcf-message').fadeOut(function () {
- $('#smcf-container .smcf-message').removeClass('smcf-error').empty();
- });
- $('#smcf-container .smcf-title').html(smcf_messages.sending);
- $('#smcf-container form').fadeOut(200);
- $('#smcf-container .smcf-content').animate({
- height: '90px'
- }, function () {
- $('#smcf-container .smcf-loading').fadeIn(200, function () {
- $.ajax({
- url: $('#smcf-content form').attr('action'),
- data: $('#smcf-container form').serialize() + '&action=send',
- type: 'post',
- cache: false,
- dataType: 'html',
- success: function (data) {
- $('#smcf-container .smcf-loading').fadeOut(200, function () {
- $('#smcf-container .smcf-title').html(smcf_messages.thankyou);
- $('#smcf-container .smcf-message').html(data).fadeIn(200);
- });
- },
- error: function (xhr) {
- $('#smcf-container .smcf-loading').fadeOut(200, function () {
- $('#smcf-container .smcf-title').html(smcf_messages.error);
- $('#smcf-container .smcf-message').html(xhr.status + ': ' + xhr.statusText).fadeIn(200);
- });
- }
- });
- });
- });
- }
- else {
- if ($('#smcf-container .smcf-message:visible').length > 0) {
- var msg = $('#smcf-container .smcf-message div');
- msg.fadeOut(200, function () {
- msg.empty();
- contact.showError();
- msg.fadeIn(200);
- });
- }
- else {
- $('#smcf-container .smcf-message').animate({
- height: '30px'
- }, contact.showError);
- }
- }
- });
- },
- close: function (d) {
- $('#smcf-container .smcf-message').fadeOut();
- $('#smcf-container .smcf-title').html(smcf_messages.goodbye);
- $('#smcf-container form').fadeOut(200);
- $('#smcf-container .smcf-content').animate({
- height: '40px'
- }, function () {
- d.data.fadeOut(200, function () {
- d.container.fadeOut(200, function () {
- d.overlay.fadeOut(200, function () {
- $.modal.close();
- });
- });
- });
- });
- },
- validate: function () {
- contact.message = '';
- var req = [],
- invalid = "";
-
- if (!$('#smcf-container #smcf-name').val()) {
- req.push(smcf_messages.name);
- }
-
- var email = $('#smcf-container #smcf-email').val();
- if (!email) {
- req.push(smcf_messages.email);
- }
- else {
- if (!contact.validateEmail(email)) {
- invalid = smcf_messages.emailinvalid;
- }
- }
-
- if (!$('#smcf-container #smcf-message').val()) {
- req.push(smcf_messages.message);
- }
-
- if (req.length > 0) {
- var fields = req.join(', ');
- contact.message += req.length > 1 ?
- fields.replace(/(.*),/,'$1 ' + smcf_messages.and) + ' ' + smcf_messages.are :
- fields + ' ' + smcf_messages.is;
- contact.message += ' ' + smcf_messages.required;
- }
-
- if (invalid.length > 0) {
- contact.message += (req.length > 0 ? ' ' : '') + smcf_messages.emailinvalid;
- }
-
- if (contact.message.length > 0) {
- return false;
- }
- else {
- return true;
- }
- },
- validateEmail: function (email) {
- var at = email.lastIndexOf("@");
-
- // Make sure the at (@) sybmol exists and
- // it is not the first or last character
- if (at < 1 || (at + 1) === email.length)
- return false;
-
- // Make sure there aren't multiple periods together
- if (/(\.{2,})/.test(email))
- return false;
-
- // Break up the local and domain portions
- var local = email.substring(0, at);
- var domain = email.substring(at + 1);
-
- // Check lengths
- if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255)
- return false;
-
- // Make sure local and domain don't start with or end with a period
- if (/(^\.|\.$)/.test(local) || /(^\.|\.$)/.test(domain))
- return false;
-
- // Check for quoted-string addresses
- // Since almost anything is allowed in a quoted-string address,
- // we're just going to let them go through
- if (!/^"(.+)"$/.test(local)) {
- // It's a dot-string address...check for valid characters
- if (!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&'+=_\.]*$/.test(local))
- return false;
- }
-
- // Make sure domain contains only valid characters and at least one period
- if (!/^[-a-zA-Z0-9\.]*$/.test(domain) || domain.indexOf(".") === -1)
- return false;
-
- return true;
- },
- showError: function () {
- $('#smcf-container .smcf-message')
- .html($('<div/>').addClass('smcf-error').append(contact.message))
- .fadeIn(200);
- }
- };
- });
-}
+jQuery(function ($) {
+ $('.smcf_link, .smcf-link').click(function (e) { // added .smcf_link for previous version
+ e.preventDefault();
+ // display the contact form
+ $('#smcf-content').modal({
+ closeHTML: "<a href='#' title='Close' class='modalCloseX simplemodal-close'>x</a>",
+ position: ["15%",],
+ overlayId: 'smcf-overlay',
+ containerId: 'smcf-container',
+ onOpen: contact.open,
+ onShow: contact.show,
+ onClose: contact.close
+ });
+ });
+
+ // preload images
+ var img = ['cancel.png','form_bottom.gif','form_top.gif','loading.gif','send.png'];
+ if ($('#smcf-content form').length > 0) {
+ var url = $('#smcf-content form').attr('action').replace(/smcf_data\.php/, 'img/');
+ $(img).each(function () {
+ var i = new Image();
+ i.src = url + this;
+ });
+ }
+
+ var contact = {
+ message: null,
+ open: function (d) {
+ // dynamically determine height
+ var h = 280;
+ if ($('#smcf-subject').length) {
+ h += 26;
+ }
+ if ($('#smcf-cc').length) {
+ h += 22;
+ }
+
+ // resize the textarea for safari
+ if ($.browser.safari) {
+ $('#smcf-container .smcf-input').css({
+ 'font-size': '.9em'
+ });
+ }
+
+ // add padding to the buttons in firefox/mozilla
+ if ($.browser.mozilla) {
+ $('#smcf-container .smcf-button').css({
+ 'padding-bottom': '2px'
+ });
+ }
+
+ var title = $('#smcf-container .smcf-title').html();
+ $('#smcf-container .smcf-title').html(smcf_messages.loading);
+ d.overlay.fadeIn(200, function () {
+ d.container.fadeIn(200, function () {
+ d.data.fadeIn(200, function () {
+ $('#smcf-container .smcf-content').animate({
+ height: h
+ }, function () {
+ $('#smcf-container .smcf-title').html(title);
+ $('#smcf-container form').fadeIn(200, function () {
+ $('#smcf-container #smcf-name').focus();
+
+ $('#smcf-container .smcf-cc').click(function () {
+ var cc = $('#smcf-container #smcf-cc');
+ cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked');
+ });
+
+ // fix png's for IE 6
+ if ($.browser.msie && $.browser.version < 7) {
+ $('#smcf-container .smcf-button').each(function () {
+ if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) {
+ var src = RegExp.$1;
+ $(this).css({
+ backgroundImage: 'none',
+ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="crop")'
+ });
+ }
+ });
+ }
+ });
+ });
+ });
+ });
+ });
+ },
+ show: function (d) {
+ $('#smcf-container .smcf-send').click(function (e) {
+ e.preventDefault();
+ // validate form
+ if (contact.validate()) {
+ $('#smcf-container .smcf-message').fadeOut(function () {
+ $('#smcf-container .smcf-message').removeClass('smcf-error').empty();
+ });
+ $('#smcf-container .smcf-title').html(smcf_messages.sending);
+ $('#smcf-container form').fadeOut(200);
+ $('#smcf-container .smcf-content').animate({
+ height: '90px'
+ }, function () {
+ $('#smcf-container .smcf-loading').fadeIn(200, function () {
+ $.ajax({
+ url: $('#smcf-content form').attr('action'),
+ data: $('#smcf-container form').serialize() + '&action=send',
+ type: 'post',
+ cache: false,
+ dataType: 'html',
+ success: function (data) {
+ $('#smcf-container .smcf-loading').fadeOut(200, function () {
+ $('#smcf-container .smcf-title').html(smcf_messages.thankyou);
+ $('#smcf-container .smcf-message').html(data).fadeIn(200);
+ });
+ },
+ error: function (xhr) {
+ $('#smcf-container .smcf-loading').fadeOut(200, function () {
+ $('#smcf-container .smcf-title').html(smcf_messages.error);
+ $('#smcf-container .smcf-message').html(xhr.status + ': ' + xhr.statusText).fadeIn(200);
+ });
+ }
+ });
+ });
+ });
+ }
+ else {
+ if ($('#smcf-container .smcf-message:visible').length > 0) {
+ var msg = $('#smcf-container .smcf-message div');
+ msg.fadeOut(200, function () {
+ msg.empty();
+ contact.showError();
+ msg.fadeIn(200);
+ });
+ }
+ else {
+ $('#smcf-container .smcf-message').animate({
+ height: '30px'
+ }, contact.showError);
+ }
+ }
+ });
+ },
+ close: function (d) {
+ $('#smcf-container .smcf-message').fadeOut();
+ $('#smcf-container .smcf-title').html(smcf_messages.goodbye);
+ $('#smcf-container form').fadeOut(200);
+ $('#smcf-container .smcf-content').animate({
+ height: '40px'
+ }, function () {
+ d.data.fadeOut(200, function () {
+ d.container.fadeOut(200, function () {
+ d.overlay.fadeOut(200, function () {
+ $.modal.close();
+ });
+ });
+ });
+ });
+ },
+ validate: function () {
+ contact.message = '';
+ var req = [],
+ invalid = "";
+
+ if (!$('#smcf-container #smcf-name').val()) {
+ req.push(smcf_messages.name);
+ }
+
+ var email = $('#smcf-container #smcf-email').val();
+ if (!email) {
+ req.push(smcf_messages.email);
+ }
+ else {
+ if (!contact.validateEmail(email)) {
+ invalid = smcf_messages.emailinvalid;
+ }
+ }
+
+ if (!$('#smcf-container #smcf-message').val()) {
+ req.push(smcf_messages.message);
+ }
+
+ if (req.length > 0) {
+ var fields = req.join(', ');
+ contact.message += req.length > 1 ?
+ fields.replace(/(.*),/,'$1 ' + smcf_messages.and) + ' ' + smcf_messages.are :
+ fields + ' ' + smcf_messages.is;
+ contact.message += ' ' + smcf_messages.required;
+ }
+
+ if (invalid.length > 0) {
+ contact.message += (req.length > 0 ? ' ' : '') + smcf_messages.emailinvalid;
+ }
+
+ if (contact.message.length > 0) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ },
+ validateEmail: function (email) {
+ var at = email.lastIndexOf("@");
+
+ // Make sure the at (@) sybmol exists and
+ // it is not the first or last character
+ if (at < 1 || (at + 1) === email.length)
+ return false;
+
+ // Make sure there aren't multiple periods together
+ if (/(\.{2,})/.test(email))
+ return false;
+
+ // Break up the local and domain portions
+ var local = email.substring(0, at);
+ var domain = email.substring(at + 1);
+
+ // Check lengths
+ if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255)
+ return false;
+
+ // Make sure local and domain don't start with or end with a period
+ if (/(^\.|\.$)/.test(local) || /(^\.|\.$)/.test(domain))
+ return false;
+
+ // Check for quoted-string addresses
+ // Since almost anything is allowed in a quoted-string address,
+ // we're just going to let them go through
+ if (!/^"(.+)"$/.test(local)) {
+ // It's a dot-string address...check for valid characters
+ if (!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&'+=_\.]*$/.test(local))
+ return false;
+ }
+
+ // Make sure domain contains only valid characters and at least one period
+ if (!/^[-a-zA-Z0-9\.]*$/.test(domain) || domain.indexOf(".") === -1)
+ return false;
+
+ return true;
+ },
+ showError: function () {
+ $('#smcf-container .smcf-message')
+ .html($('<div/>').addClass('smcf-error').append(contact.message))
+ .fadeIn(200);
+ }
+ };
+});
View
26 lang/readme.txt
@@ -1,14 +1,14 @@
-If you are interested in translating SMCF, use smcf.pot as a template to create a po file for the new translation file.
-
-The resulting translated file should be named with the following format:
-- smcf-
-- ISO 639 language code (lowercase)
-- an underscore
-- ISO 3166-1 alpha-2 country code (uppercase)
-- .mo
-
-So for an Italian translation, the file name would be smcf-it_IT.mo
-
-Please send the translated file to simplemodal@ericmmartin.com.
-
+If you are interested in translating SMCF, use smcf.pot as a template to create a po file for the new translation file.
+
+The resulting translated file should be named with the following format:
+- smcf-
+- ISO 639 language code (lowercase)
+- an underscore
+- ISO 3166-1 alpha-2 country code (uppercase)
+- .mo
+
+So for an Italian translation, the file name would be smcf-it_IT.mo
+
+Please send the translated file to simplemodal@ericmmartin.com.
+
Thanks!
View
31 smcf.php
@@ -4,12 +4,12 @@
Plugin Name: SimpleModal Contact Form (SMCF)
Plugin URI: http://www.ericmmartin.com/projects/smcf/
Description: A modal Ajax contact form built on the SimpleModal jQuery plugin. Once Activated, go to "Options" or "Settings" and select "SimpleModal Contact Form".
-Version: 1.2.5
+Version: 1.2.6
Author: Eric Martin
Author URI: http://www.ericmmartin.com
*/
-/* Copyright 2009 Eric Martin (eric@ericmmartin.com)
+/* Copyright 2011 Eric Martin (eric@ericmmartin.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,27 +27,21 @@
*/
$smcf_dir = preg_replace("/^.*[\/\\\]/", "", dirname(__FILE__));
-define ("SMCF_DIR", "/wp-content/plugins/" . $smcf_dir);
+define("SMCF_DIR", "/wp-content/plugins/" . $smcf_dir);
class SimpleModalContactForm {
- var $version = "1.2.5";
+ var $version = "1.2.6";
function init() {
- if (function_exists("load_plugin_textdomain")) {
- load_plugin_textdomain("smcf", SMCF_DIR . "/lang/");
- }
-
- // add javascript files
- if (function_exists("wp_enqueue_script") && !is_admin()) {
- // load the jQuery version that comes with WordPress
- wp_enqueue_script("jquery");
- wp_enqueue_script("jquery-simplemodal", get_option("siteurl") . SMCF_DIR . "/js/jquery.simplemodal.js", "jquery", "1.3", true);
- wp_enqueue_script("smcf", get_option("siteurl") . SMCF_DIR . "/js/smcf.js", array("jquery", "jquery-simplemodal"), $this->version, true);
- }
-
- // add styling
- if (function_exists("wp_enqueue_style")) {
+ load_plugin_textdomain("smcf", false, SMCF_DIR . "/lang/");
+
+ if (!is_admin()) {
+ // add javascript files
+ wp_enqueue_script("jquery-simplemodal", get_option("siteurl") . SMCF_DIR . "/js/jquery.simplemodal.js", array("jquery"), "1.4.1", true);
+ wp_enqueue_script("smcf", get_option("siteurl") . SMCF_DIR . "/js/smcf.js", array("jquery-simplemodal"), $this->version, true);
+
+ // add styling
wp_enqueue_style("smcf", get_option("siteurl") . SMCF_DIR . "/css/smcf.css", false, $this->version, "screen");
}
}
@@ -261,6 +255,7 @@ function token() {
// Look for a contact link in the page menus/list
add_filter('wp_page_menu', array($smcf, "page_menu_list"));
add_filter('wp_list_pages', array($smcf, "page_menu_list"));
+add_filter('wp_nav_menu_items', array($smcf, "page_menu_list"));
/*
* Public function to create a link for the contact form
View
278 smcf_data.php
@@ -1,139 +1,141 @@
-<?php
-
-require_once("../../../wp-config.php");
-
-$smcf_dir = preg_replace("/^.*[\/\\\]/", "", dirname(__FILE__));
-define ("SMCF_DIR", "/wp-content/plugins/" . $smcf_dir);
-
-// process
-$action = isset($_POST["action"]) ? $_POST["action"] : "";
-if ($action == "send") {
- // send the email
- $name = isset($_POST["name"]) ? $_POST["name"] : "";
- $email = isset($_POST["email"]) ? $_POST["email"] : "";
- $subject = isset($_POST["subject"]) ? $_POST["subject"] : "";
- $message = isset($_POST["message"]) ? $_POST["message"] : "";
- $cc = isset($_POST["cc"]) ? $_POST["cc"] : "";
- $token = isset($_POST["token"]) ? $_POST["token"] : "";
-
- // make sure the token matches
- if ($token == SimpleModalContactForm::token()) {
- sendEmail($name, $email, $subject, $message, $cc);
- _e("Your message was successfully sent.", "smcf");
- }
- else {
- _e("Unfortunately, your message could not be verified.", "smcf");
- }
-}
-
-// validate and send email
-function sendEmail($name, $email, $subject, $message, $cc) {
- $to = get_option("smcf_to_email");
-
- // filter name and subject
- $name = filter($name);
- $subject = empty($subject) ? get_option("smcf_subject") : filter($subject);
-
- // remove escaping done by magic_quotes
- $message = stripslashes($message);
-
- // filter and validate email
- $email = filter($email);
- if (!validateEmail($email)) {
- $subject .= " - invalid email";
- $message .= "\n\nBad email: $email";
- $email = $to;
- $cc = 0; // do not CC "sender"
- }
-
- // Add additional info to the message
- if (get_option("smcf_ip")) {
- $message .= "\n\nIP: " . $_SERVER["REMOTE_ADDR"];
- }
- if (get_option("smcf_ua")) {
- $message .= "\n\nUSER AGENT: " . $_SERVER["HTTP_USER_AGENT"];
- }
-
- // Set and wordwrap message body
- $body = "From: $name\n\n";
- $body .= "Message: $message";
- $body = wordwrap($body); // default is 75 characters
-
- // Build header
- $headers = "From: $email\n";
- if ($cc == 1) {
- $headers .= "Cc: $email\n";
- }
- $headers .= "X-Mailer: PHP/SimpleModalContactForm";
-
- // UTF-8
- if (function_exists('mb_encode_mimeheader')) {
- $subject = mb_encode_mimeheader($subject, "UTF-8", "B", "\n");
- }
- else {
- // you need to enable mb_encode_mimeheader or risk
- // getting emails that are not UTF-8 encoded
- }
- $headers .= "MIME-Version: 1.0\n";
- $headers .= "Content-type: text/plain; charset=utf-8\n";
- $headers .= "Content-Transfer-Encoding: quoted-printable\n";
-
- // Send email - suppress errors
- @mail($to, $subject, $body, $headers) or
- die(__("Unfortunately, a server issue prevented delivery of your message.", "smcf"));
-}
-
-// Remove any un-safe values to prevent email injection
-function filter($value) {
- $pattern = array("/\n/", "/\r/", "/content-type:/i", "/to:/i", "/from:/i", "/cc:/i");
- $value = preg_replace($pattern, "", $value);
- return $value;
-}
-
-// Validate email address format in case client-side validation "fails"
-function validateEmail($email) {
- $at = strrpos($email, "@");
-
- // Make sure the at (@) sybmol exists and
- // it is not the first or last character
- if ($at && ($at < 1 || ($at + 1) == strlen($email)))
- return false;
-
- // Make sure there aren't multiple periods together
- if (preg_match("/(\.{2,})/", $email))
- return false;
-
- // Break up the local and domain portions
- $local = substr($email, 0, $at);
- $domain = substr($email, $at + 1);
-
-
- // Check lengths
- $locLen = strlen($local);
- $domLen = strlen($domain);
- if ($locLen < 1 || $locLen > 64 || $domLen < 4 || $domLen > 255)
- return false;
-
- // Make sure local and domain don't start with or end with a period
- if (preg_match("/(^\.|\.$)/", $local) || preg_match("/(^\.|\.$)/", $domain))
- return false;
-
- // Check for quoted-string addresses
- // Since almost anything is allowed in a quoted-string address,
- // we're just going to let them go through
- if (!preg_match('/^"(.+)"$/', $local)) {
- // It's a dot-string address...check for valid characters
- if (!preg_match('/^[-a-zA-Z0-9!#$%*\/?|^{}`~&\'+=_\.]*$/', $local))
- return false;
- }
-
- // Make sure domain contains only valid characters and at least one period
- if (!preg_match('/^[-a-zA-Z0-9\.]*$/', $domain) || !strpos($domain, "."))
- return false;
-
- return true;
-}
-
-exit;
-
+<?php
+
+require_once("../../../wp-config.php");
+
+$smcf_dir = preg_replace("/^.*[\/\\\]/", "", dirname(__FILE__));
+if (!defined("SMCF_DIR")) {
+ define("SMCF_DIR", "/wp-content/plugins/" . $smcf_dir);
+}
+
+// process
+$action = isset($_POST["action"]) ? $_POST["action"] : "";
+if ($action == "send") {
+ // send the email
+ $name = isset($_POST["name"]) ? $_POST["name"] : "";
+ $email = isset($_POST["email"]) ? $_POST["email"] : "";
+ $subject = isset($_POST["subject"]) ? $_POST["subject"] : "";
+ $message = isset($_POST["message"]) ? $_POST["message"] : "";
+ $cc = isset($_POST["cc"]) ? $_POST["cc"] : "";
+ $token = isset($_POST["token"]) ? $_POST["token"] : "";
+
+ // make sure the token matches
+ if ($token == SimpleModalContactForm::token()) {
+ sendEmail($name, $email, $subject, $message, $cc);
+ _e("Your message was successfully sent.", "smcf");
+ }
+ else {
+ _e("Unfortunately, your message could not be verified.", "smcf");
+ }
+}
+
+// validate and send email
+function sendEmail($name, $email, $subject, $message, $cc) {
+ $to = get_option("smcf_to_email");
+
+ // filter name and subject
+ $name = filter($name);
+ $subject = empty($subject) ? get_option("smcf_subject") : filter($subject);
+
+ // remove escaping done by magic_quotes
+ $message = stripslashes($message);
+
+ // filter and validate email
+ $email = filter($email);
+ if (!validateEmail($email)) {
+ $subject .= " - invalid email";
+ $message .= "\n\nBad email: $email";
+ $email = $to;
+ $cc = 0; // do not CC "sender"
+ }
+
+ // Add additional info to the message
+ if (get_option("smcf_ip")) {
+ $message .= "\n\nIP: " . $_SERVER["REMOTE_ADDR"];
+ }
+ if (get_option("smcf_ua")) {
+ $message .= "\n\nUSER AGENT: " . $_SERVER["HTTP_USER_AGENT"];
+ }
+
+ // Set and wordwrap message body
+ $body = "From: $name\n\n";
+ $body .= "Message: $message";
+ $body = wordwrap($body); // default is 75 characters
+
+ // Build header
+ $headers = "From: $email\n";
+ if ($cc == 1) {
+ $headers .= "Cc: $email\n";
+ }
+ $headers .= "X-Mailer: PHP/SimpleModalContactForm";
+
+ // UTF-8
+ if (function_exists('mb_encode_mimeheader')) {
+ $subject = mb_encode_mimeheader($subject, "UTF-8", "B", "\n");
+ }
+ else {
+ // you need to enable mb_encode_mimeheader or risk
+ // getting emails that are not UTF-8 encoded
+ }
+ $headers .= "MIME-Version: 1.0\n";
+ $headers .= "Content-type: text/plain; charset=utf-8\n";
+ $headers .= "Content-Transfer-Encoding: quoted-printable\n";
+
+ // Send email - suppress errors
+ @mail($to, $subject, $body, $headers) or
+ die(__("Unfortunately, a server issue prevented delivery of your message.", "smcf"));
+}
+
+// Remove any un-safe values to prevent email injection
+function filter($value) {
+ $pattern = array("/\n/", "/\r/", "/content-type:/i", "/to:/i", "/from:/i", "/cc:/i");
+ $value = preg_replace($pattern, "", $value);
+ return $value;
+}
+
+// Validate email address format in case client-side validation "fails"
+function validateEmail($email) {
+ $at = strrpos($email, "@");
+
+ // Make sure the at (@) sybmol exists and
+ // it is not the first or last character
+ if ($at && ($at < 1 || ($at + 1) == strlen($email)))
+ return false;
+
+ // Make sure there aren't multiple periods together
+ if (preg_match("/(\.{2,})/", $email))
+ return false;
+
+ // Break up the local and domain portions
+ $local = substr($email, 0, $at);
+ $domain = substr($email, $at + 1);
+
+
+ // Check lengths
+ $locLen = strlen($local);
+ $domLen = strlen($domain);
+ if ($locLen < 1 || $locLen > 64 || $domLen < 4 || $domLen > 255)
+ return false;
+
+ // Make sure local and domain don't start with or end with a period
+ if (preg_match("/(^\.|\.$)/", $local) || preg_match("/(^\.|\.$)/", $domain))
+ return false;
+
+ // Check for quoted-string addresses
+ // Since almost anything is allowed in a quoted-string address,
+ // we're just going to let them go through
+ if (!preg_match('/^"(.+)"$/', $local)) {
+ // It's a dot-string address...check for valid characters
+ if (!preg_match('/^[-a-zA-Z0-9!#$%*\/?|^{}`~&\'+=_\.]*$/', $local))
+ return false;
+ }
+
+ // Make sure domain contains only valid characters and at least one period
+ if (!preg_match('/^[-a-zA-Z0-9\.]*$/', $domain) || !strpos($domain, "."))
+ return false;
+
+ return true;
+}
+
+exit;
+
?>
View
14 uninstall.php
@@ -0,0 +1,14 @@
+<?php
+if( !defined( 'ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
+ exit();
+
+delete_option("smcf_link_url");
+delete_option("smcf_link_title");
+delete_option("smcf_form_subject");
+delete_option("smcf_form_cc_sender");
+delete_option("smcf_to_email");
+delete_option("smcf_subject");
+delete_option("smcf_ip");
+delete_option("smcf_ua");
+
+?>

0 comments on commit 9789a76

Please sign in to comment.