Archive for February, 2012

Generate a PDF and send as attachment in Email

by on Wednesday, February 29th, 2012

One way:

<?php

// download fpdf class (http://fpdf.org)
require("/fpd/fpdf.php");

// fpdf object
$pdf = new FPDF();

// generate a simple PDF (for more info, see http://fpdf.org/en/tutorial/)
$pdf->AddPage();
$pdf->SetFont("Arial","B",14);
$pdf->Cell(40,10, "this is a pdf example");

// email stuff (change data below)
$to = "target@domain.com";
$from = "me@domain.com";
$subject = "send email with pdf attachment";
$message = "<p>Please see the attachment.</p>";

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = "example.pdf";

// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));

// main header (multipart mandatory)
$headers  = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;

// message
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;

// attachment
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";

// send message
mail($to, $subject, "", $headers);

?>

Second way:

<?php

$pdf_name = str_replace(" ", "_", $employee_type).'_'.time();

$query_emi_form = "insert query";
$resultset_emi_queryform = mysql_query($query_emi_form);
$last_id = mysql_insert_id();
$saved = "Query Form Submitted Successfully";
$result1=mysql_query("select * from tbl where id=".$last_id);
$data = '<div align="center"><table width="500" border="1"><tr>
<th scope="col" width="240">&nbsp;Field Name</th>
<th scope="col" width="240">&nbsp;Value</th>
</tr>';
while($row=mysql_fetch_field($result1)){
$f[] = $row;
}
$rows = mysql_fetch_assoc($result1);
for($i=0;$i<count($f);$i++){
$fname = ucfirst(str_replace("_", " ", $f[$i]->name));
$fname_original = $f[$i]->name;
$ff[]=$rows;
$data .="<tr><td>$fname</td><td>$rows[$fname_original]</td></tr>";
}
$data .="</table></div>";
$stringData = '<html><body>'.$data.'</body></html>';

//use this http://www.macronimous.com/resources/Converting_HTML2PDF_using_PHP.asp
require('html2pdf_sample/html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();

$pdf->WriteHTML($stringData);
$pdf->Output("emi_pdf/".$pdf_name.".pdf");

if($emi_query_id){
$result2="select * from tbl_queries where query_id=".$emi_query_id;
$resultset_result = mysql_query($result2);

$resultset = mysql_fetch_array($resultset_result);

$query_no = $resultset['query_no'];

$message = '<html><body>';
$message .='Dear Sir/Mam,<br><br>';
$message .='Greetings from !!!<br><br><br>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Query No:</strong> </td><td>" .$query_no. "</td></tr>";
$message .= "</table>";
$message .='Sincerely,<br><br>';
$message .='Name<br>';
$message .= "</body></html>";

$to = 'email@gmail.com';
$from = "noreply@domainname.com";
$subject = "QUERY NO.-".$query_no;

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = $pdf_name.".pdf";
$fileatt ="emi_pdf/".$filename;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$attachment = chunk_split(base64_encode($data));

// main header (multipart mandatory)
$headers  = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;

// message
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;

// attachment
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
@mail($to, $subject, $message, $headers);
}

?>

jquery using confirm box

by on Tuesday, February 21st, 2012

$('.drop-cross-img').live("click", function(){
var cross_img = $(this);
var item_id = cross_img.attr('alt');
var item_tbl = cross_img.attr('rel');
//alert(item_tbl);
var confirmation = confirm('Are you sure, you want to delete it?');
if(confirmation){
jQuery.ajax({
type:'POST',
url: "common/function_outfits.php",
data: "ajax=true&activity=delete_item&itemID="+item_id+"&action="+item_tbl,
success: function(data){
if(data=='Item Deleted.'){
cross_img.parent().remove();
}
}
});
}
});

jquery validationEngine form submit with ajax [Solved]

by on Tuesday, February 21st, 2012

/*
 * Inline Form Validation Engine 1.7, jQuery plugin
 * 
 * Copyright(c) 2010, Cedric Dugas
 * http://www.position-relative.net
 *	
 * Form validation engine allowing custom regex rules to be added.
 * Thanks to Francois Duquette and Teddy Limousin 
 * and everyone helping me find bugs on the forum
 * Licenced under the MIT Licence
 */
$(document).ready(function() {
	// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 
	
	//$("#validate").validationEngine();
	$("#validate1").validationEngine();
	
	$("#validate").validationEngine({
		  ajaxSubmit: true,
		  ajaxSubmitFile: "receive.php",
		  //ajaxSubmitMessage: "We will get back to you with the quote. <br/> Should you require any further assistance, Please contact us on 1800 103 1139 / 09878733999 between 10:00 and 18:30 hours (Monday – Saturday)",
		  //ajaxSubmitExtraData: "securityCode=38709238423&name=john",
		  success : function(res){
			  Popup.showModal('modal33',null,null,{'screenColor':'#000000','screenOpacity':.6});
		  },
		  failure : function() {}  
	  })
});
 
(function($) {
	
	$.fn.validationEngine = function(settings) {
		
	if($.validationEngineLanguage){				// IS THERE A LANGUAGE LOCALISATION ?
		allRules = $.validationEngineLanguage.allRules;
	}else{
		$.validationEngine.debug("Validation engine rules are not loaded check your external file");
	}
 	settings = jQuery.extend({
		allrules:allRules,
		validationEventTriggers:"focusout",					
		inlineValidation: true,	
		returnIsValid:false,
		liveEvent:true,
		unbindEngine:true,
		containerOverflow:false,
		containerOverflowDOM:"",
		ajaxSubmit: false,
		scroll:true,
		promptPosition: "topRight",	// OPENNING BOX POSITION, IMPLEMENTED: topLeft, topRight, bottomLeft, centerRight, bottomRight
		success : false,
		beforeSuccess :  function() {},
		failure : function() {}
	}, settings);	
	$.validationEngine.settings = settings;
	$.validationEngine.ajaxValidArray = new Array();	// ARRAY FOR AJAX: VALIDATION MEMORY 
	
	if(settings.inlineValidation == true){ 		// Validating Inline ?
		if(!settings.returnIsValid){					// NEEDED FOR THE SETTING returnIsValid
			allowReturnIsvalid = false;
			if(settings.liveEvent){						// LIVE event, vast performance improvement over BIND
				$(this).find("[class*=validate][type!=checkbox]").live(settings.validationEventTriggers, function(caller){ _inlinEvent(this);})
				$(this).find("[class*=validate][type=checkbox]").live("click", function(caller){ _inlinEvent(this); })
			}else{
				$(this).find("[class*=validate]").not("[type=checkbox]").bind(settings.validationEventTriggers, function(caller){ _inlinEvent(this); })
				$(this).find("[class*=validate][type=checkbox]").bind("click", function(caller){ _inlinEvent(this); })
			}
			firstvalid = false;
		}
			function _inlinEvent(caller){
				$.validationEngine.settings = settings;
				if($.validationEngine.intercept == false || !$.validationEngine.intercept){		// STOP INLINE VALIDATION THIS TIME ONLY
					$.validationEngine.onSubmitValid=false;
					$.validationEngine.loadValidation(caller); 
				}else{
					$.validationEngine.intercept = false;
				}
			}
	}
	if (settings.returnIsValid){		// Do validation and return true or false, it bypass everything;
		if ($.validationEngine.submitValidation(this,settings)){
			return false;
		}else{
			return true;
		}
	}
	$(this).bind("submit", function(caller){   // ON FORM SUBMIT, CONTROL AJAX FUNCTION IF SPECIFIED ON DOCUMENT READY
		$.validationEngine.onSubmitValid = true;
		$.validationEngine.settings = settings;
		if($.validationEngine.submitValidation(this,settings) == false){
			if($.validationEngine.submitForm(this,settings) == true) return false;
		}else{
			settings.failure && settings.failure(); 
			return false;
		}		
	})
	$(".formError").live("click",function(){	 // REMOVE BOX ON CLICK
		$(this).fadeOut(150,function(){		$(this).remove()	}) 
	})
};	
$.validationEngine = {
	defaultSetting : function(caller) {		// NOT GENERALLY USED, NEEDED FOR THE API, DO NOT TOUCH
		if($.validationEngineLanguage){				
			allRules = $.validationEngineLanguage.allRules;
		}else{
			$.validationEngine.debug("Validation engine rules are not loaded check your external file");
		}	
		settings = {
			allrules:allRules,
			validationEventTriggers:"blur",					
			inlineValidation: true,	
			containerOverflow:false,
			containerOverflowDOM:"",
			returnIsValid:false,
			scroll:true,
			unbindEngine:true,
			ajaxSubmit: false,
			promptPosition: "topRight",	// OPENNING BOX POSITION, IMPLEMENTED: topLeft, topRight, bottomLeft, centerRight, bottomRight
			success : false,
			failure : function() {}
		}	
		$.validationEngine.settings = settings;
	},
	loadValidation : function(caller) {		// GET VALIDATIONS TO BE EXECUTED
		if(!$.validationEngine.settings) $.validationEngine.defaultSetting()
		rulesParsing = $(caller).attr('class');
		rulesRegExp = /\[(.*)\]/;
		getRules = rulesRegExp.exec(rulesParsing);
		if(getRules == null) return false;
		str = getRules[1];
		pattern = /\[|,|\]/;
		result= str.split(pattern);	
		var validateCalll = $.validationEngine.validateCall(caller,result)
		return validateCalll;
	},
	validateCall : function(caller,rules) {	// EXECUTE VALIDATION REQUIRED BY THE USER FOR THIS FIELD
		var promptText =""	
		
		if(!$(caller).attr("id")) $.validationEngine.debug("This field have no ID attribut( name & class displayed): "+$(caller).attr("name")+" "+$(caller).attr("class"))

		caller = caller;
		ajaxValidate = false;
		var callerName = $(caller).attr("name");
		$.validationEngine.isError = false;
		$.validationEngine.showTriangle = true;
		callerType = $(caller).attr("type");

		for (i=0; i<rules.length;i++){
			switch (rules[i]){
			case "optional": 
				if(!$(caller).val()){
					$.validationEngine.closePrompt(caller);
					return $.validationEngine.isError;
				}
			break;
			case "required": 
				_required(caller,rules);
			break;
			case "custom": 
				 _customRegex(caller,rules,i);
			break;
			case "exemptString": 
				 _exemptString(caller,rules,i);
			break;
			case "ajax": 
				if(!$.validationEngine.onSubmitValid) _ajax(caller,rules,i);	
			break;
			case "length": 
				 _length(caller,rules,i);
			break;
			case "maxCheckbox": 
				_maxCheckbox(caller,rules,i);
			 	groupname = $(caller).attr("name");
			 	caller = $("input[name='"+groupname+"']");
			break;
			case "minCheckbox": 
				_minCheckbox(caller,rules,i);
				groupname = $(caller).attr("name");
			 	caller = $("input[name='"+groupname+"']");
			break;
			case "confirm": 
				 _confirm(caller,rules,i);
			break;
			case "funcCall": 
		     	_funcCall(caller,rules,i);
			break;
			default :;
			};
		};
		radioHack();
		if ($.validationEngine.isError == true){
			var linkTofieldText = "." +$.validationEngine.linkTofield(caller);
			if(linkTofieldText != "."){
				if(!$(linkTofieldText)[0]){
					$.validationEngine.buildPrompt(caller,promptText,"error")
				}else{	
					$.validationEngine.updatePromptText(caller,promptText);
				}	
			}else{
				$.validationEngine.updatePromptText(caller,promptText);
			}
		}else{
			$.validationEngine.closePrompt(caller);
		}			
		/* UNFORTUNATE RADIO AND CHECKBOX GROUP HACKS */
		/* As my validation is looping input with id's we need a hack for my validation to understand to group these inputs */
		function radioHack(){
	      if($("input[name='"+callerName+"']").size()> 1 && (callerType == "radio" || callerType == "checkbox")) {        // Hack for radio/checkbox group button, the validation go the first radio/checkbox of the group
	          caller = $("input[name='"+callerName+"'][type!=hidden]:first");     
	          $.validationEngine.showTriangle = false;
	      }      
	    }
		/* VALIDATION FUNCTIONS */
		function _required(caller,rules){   // VALIDATE BLANK FIELD
			callerType = $(caller).attr("type");
			if (callerType == "text" || callerType == "password" || callerType == "textarea"){
								
				if(!$(caller).val()){
					$.validationEngine.isError = true;
					promptText += $.validationEngine.settings.allrules[rules[i]].alertText+"<br />";
				}	
			}	
			if (callerType == "radio" || callerType == "checkbox" ){
				callerName = $(caller).attr("name");
		
				if($("input[name='"+callerName+"']:checked").size() == 0) {
					$.validationEngine.isError = true;
					if($("input[name='"+callerName+"']").size() ==1) {
						promptText += $.validationEngine.settings.allrules[rules[i]].alertTextCheckboxe+"<br />"; 
					}else{
						 promptText += $.validationEngine.settings.allrules[rules[i]].alertTextCheckboxMultiple+"<br />";
					}	
				}
			}	
			if (callerType == "select-one") { // added by paul@kinetek.net for select boxes, Thank you		
				if(!$(caller).val()) {
					$.validationEngine.isError = true;
					promptText += $.validationEngine.settings.allrules[rules[i]].alertText+"<br />";
				}
			}
			if (callerType == "select-multiple") { // added by paul@kinetek.net for select boxes, Thank you	
				if(!$(caller).find("option:selected").val()) {
					$.validationEngine.isError = true;
					promptText += $.validationEngine.settings.allrules[rules[i]].alertText+"<br />";
				}
			}
		}
		function _customRegex(caller,rules,position){		 // VALIDATE REGEX RULES
			customRule = rules[position+1];
			pattern = eval($.validationEngine.settings.allrules[customRule].regex);
			
			if(!pattern.test($(caller).attr('value'))){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules[customRule].alertText+"<br />";
			}
		}
		function _exemptString(caller,rules,position){		 // VALIDATE REGEX RULES
			customString = rules[position+1];
			if(customString == $(caller).attr('value')){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules['required'].alertText+"<br />";
			}
		}
		
		function _funcCall(caller,rules,position){  		// VALIDATE CUSTOM FUNCTIONS OUTSIDE OF THE ENGINE SCOPE
			customRule = rules[position+1];
			funce = $.validationEngine.settings.allrules[customRule].nname;
			
			var fn = window[funce];
			if (typeof(fn) === 'function'){
				var fn_result = fn();
				if(!fn_result){
					$.validationEngine.isError = true;
				}
				
				promptText += $.validationEngine.settings.allrules[customRule].alertText+"<br />";
			}
		}
		function _ajax(caller,rules,position){				 // VALIDATE AJAX RULES
			
			customAjaxRule = rules[position+1];
			postfile = $.validationEngine.settings.allrules[customAjaxRule].file;
			fieldValue = $(caller).val();
			ajaxCaller = caller;
			fieldId = $(caller).attr("id");
			ajaxValidate = true;
			ajaxisError = $.validationEngine.isError;
			
			if($.validationEngine.settings.allrules[customAjaxRule].extraData){
				extraData = $.validationEngine.settings.allrules[customAjaxRule].extraData;
			}else{
				extraData = "";
			}
			/* AJAX VALIDATION HAS ITS OWN UPDATE AND BUILD UNLIKE OTHER RULES */	
			if(!ajaxisError){
				$.ajax({
				   	type: "POST",
				   	url: postfile,
				   	async: true,
				   	data: "validateValue="+fieldValue+"&validateId="+fieldId+"&validateError="+customAjaxRule+"&extraData="+extraData,
				   	beforeSend: function(){		// BUILD A LOADING PROMPT IF LOAD TEXT EXIST		   			
				   		if($.validationEngine.settings.allrules[customAjaxRule].alertTextLoad){
				   		
				   			if(!$("div."+fieldId+"formError")[0]){				   				
	 			 				return $.validationEngine.buildPrompt(ajaxCaller,$.validationEngine.settings.allrules[customAjaxRule].alertTextLoad,"load");
	 			 			}else{
	 			 				$.validationEngine.updatePromptText(ajaxCaller,$.validationEngine.settings.allrules[customAjaxRule].alertTextLoad,"load");
	 			 			}
			   			}
			  	 	},
			  	 	error: function(data,transport){ $.validationEngine.debug("error in the ajax: "+data.status+" "+transport) },
					success: function(data){					// GET SUCCESS DATA RETURN JSON
						data = eval( "("+data+")");				// GET JSON DATA FROM PHP AND PARSE IT
						ajaxisError = data.jsonValidateReturn[2];
						customAjaxRule = data.jsonValidateReturn[1];
						ajaxCaller = $("#"+data.jsonValidateReturn[0])[0];
						fieldId = ajaxCaller;
						ajaxErrorLength = $.validationEngine.ajaxValidArray.length;
						existInarray = false;
						
			 			 if(ajaxisError == "false"){			// DATA FALSE UPDATE PROMPT WITH ERROR;
			 			 	
			 			 	_checkInArray(false)				// Check if ajax validation alreay used on this field
			 			 	
			 			 	if(!existInarray){		 			// Add ajax error to stop submit		 		
				 			 	$.validationEngine.ajaxValidArray[ajaxErrorLength] =  new Array(2);
				 			 	$.validationEngine.ajaxValidArray[ajaxErrorLength][0] = fieldId;
				 			 	$.validationEngine.ajaxValidArray[ajaxErrorLength][1] = false;
				 			 	existInarray = false;
			 			 	}
				
			 			 	$.validationEngine.ajaxValid = false;
							promptText += $.validationEngine.settings.allrules[customAjaxRule].alertText+"<br />";
							$.validationEngine.updatePromptText(ajaxCaller,promptText,"",true);				
						 }else{	 
						 	_checkInArray(true);
						 	$.validationEngine.ajaxValid = true; 			
						 	if(!customAjaxRule)	{$.validationEngine.debug("wrong ajax response, are you on a server or in xampp? if not delete de ajax[ajaxUser] validating rule from your form ")}		   
						 	if($.validationEngine.settings.allrules[customAjaxRule].alertTextOk){	// NO OK TEXT MEAN CLOSE PROMPT	 			
	 			 				 				$.validationEngine.updatePromptText(ajaxCaller,$.validationEngine.settings.allrules[customAjaxRule].alertTextOk,"pass",true);
 			 				}else{
				 			 	ajaxValidate = false;		 	
				 			 	$.validationEngine.closePrompt(ajaxCaller);
 			 				}		
			 			 }
			 			function  _checkInArray(validate){
			 				for(x=0;x<ajaxErrorLength;x++){
			 			 		if($.validationEngine.ajaxValidArray[x][0] == fieldId){
			 			 			$.validationEngine.ajaxValidArray[x][1] = validate;
			 			 			existInarray = true;
			 			 		
			 			 		}
			 			 	}
			 			}
			 		}				
				});
			}
		}
		function _confirm(caller,rules,position){		 // VALIDATE FIELD MATCH
			confirmField = rules[position+1];
			
			if($(caller).attr('value') != $("#"+confirmField).attr('value')){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules["confirm"].alertText+"<br />";
			}
		}
		function _length(caller,rules,position){    	  // VALIDATE LENGTH
		
			startLength = eval(rules[position+1]);
			endLength = eval(rules[position+2]);
			feildLength = $(caller).attr('value').length;

			if(feildLength<startLength || feildLength>endLength){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules["length"].alertText+startLength+$.validationEngine.settings.allrules["length"].alertText2+endLength+$.validationEngine.settings.allrules["length"].alertText3+"<br />"
			}
		}
		function _maxCheckbox(caller,rules,position){  	  // VALIDATE CHECKBOX NUMBER
		
			nbCheck = eval(rules[position+1]);
			groupname = $(caller).attr("name");
			groupSize = $("input[name='"+groupname+"']:checked").size();
			if(groupSize > nbCheck){	
				$.validationEngine.showTriangle = false;
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules["maxCheckbox"].alertText+"<br />";
			}
		}
		function _minCheckbox(caller,rules,position){  	  // VALIDATE CHECKBOX NUMBER
		
			nbCheck = eval(rules[position+1]);
			groupname = $(caller).attr("name");
			groupSize = $("input[name='"+groupname+"']:checked").size();
			if(groupSize < nbCheck){	
			
				$.validationEngine.isError = true;
				$.validationEngine.showTriangle = false;
				promptText += $.validationEngine.settings.allrules["minCheckbox"].alertText+" "+nbCheck+" "+$.validationEngine.settings.allrules["minCheckbox"].alertText2+"<br />";
			}
		}
		return ($.validationEngine.isError) ? $.validationEngine.isError : false;
	},
	submitForm : function(caller){
		if($.validationEngine.settings.ajaxSubmit){		
			if($.validationEngine.settings.ajaxSubmitExtraData){
				extraData = $.validationEngine.settings.ajaxSubmitExtraData;
			}else{
				extraData = "";
			}
			$.ajax({
			   	type: "POST",
			   	url: $.validationEngine.settings.ajaxSubmitFile,
			   	async: true,
			   	data: $(caller).serialize()+"&"+extraData,
			   	error: function(data,transport){ $.validationEngine.debug("error in the ajax: "+data.status+" "+transport) },
			   	success: function(data){
			   		if(data == "true"){			// EVERYTING IS FINE, SHOW SUCCESS MESSAGE
			   			$(caller).css("opacity",1)
			   			//$(caller).animate({opacity: 0, height: 0}, function(){
			   				//$(caller).css("display","none");
			   				//$(caller).before("<div class='ajaxSubmit'>"+$.validationEngine.settings.ajaxSubmitMessage+"</div>");
			   				//$.validationEngine.closePrompt(".formError",true); 	
			   				//$(".ajaxSubmit").show("slow");
			   				if ($.validationEngine.settings.success){	// AJAX SUCCESS, STOP THE LOCATION UPDATE
								$.validationEngine.settings.success && $.validationEngine.settings.success(); 
								return false;
							}
			   			//});
						/*setTimeout(
							function(){
								$(caller).css("opacity",1).css("display","block");
								$(".ajaxSubmit").hide("slow");
							}
						,15000);*/
		   			}else{						// HOUSTON WE GOT A PROBLEM (SOMETING IS NOT VALIDATING)
			   			data = eval( "("+data+")");	
			   			if(!data.jsonValidateReturn){
			   				 $.validationEngine.debug("you are not going into the success fonction and jsonValidateReturn return nothing");
			   			}
			   			errorNumber = data.jsonValidateReturn.length	
			   			for(index=0; index<errorNumber; index++){	
			   				fieldId = data.jsonValidateReturn[index][0];
			   				promptError = data.jsonValidateReturn[index][1];
			   				type = data.jsonValidateReturn[index][2];
			   				$.validationEngine.buildPrompt(fieldId,promptError,type);
		   				}
	   				}
   				}
			})	
			return true;
		}
		// LOOK FOR BEFORE SUCCESS METHOD		
			if(!$.validationEngine.settings.beforeSuccess()){
				if ($.validationEngine.settings.success){	// AJAX SUCCESS, STOP THE LOCATION UPDATE
					if($.validationEngine.settings.unbindEngine){ $(caller).unbind("submit") }
					$.validationEngine.settings.success && $.validationEngine.settings.success(); 
					return true;
				}
			}else{
				return true;
			} 
		return false;
	},
	buildPrompt : function(caller,promptText,type,ajaxed) {			// ERROR PROMPT CREATION AND DISPLAY WHEN AN ERROR OCCUR
		if(!$.validationEngine.settings){
			$.validationEngine.defaultSetting()
		}
		deleteItself = "." + $(caller).attr("id") + "formError"
	
		if($(deleteItself)[0]){
			$(deleteItself).stop();
			$(deleteItself).remove();
		}
		var divFormError = document.createElement('div');
		var formErrorContent = document.createElement('div');
		linkTofield = $.validationEngine.linkTofield(caller)
		$(divFormError).addClass("formError")
		
		if(type == "pass") $(divFormError).addClass("greenPopup")
		if(type == "load") $(divFormError).addClass("blackPopup")
		if(ajaxed) $(divFormError).addClass("ajaxed")
		
		$(divFormError).addClass(linkTofield);
		$(formErrorContent).addClass("formErrorContent");
		
		if($.validationEngine.settings.containerOverflow){		// Is the form contained in an overflown container?
			$(caller).before(divFormError);
		}else{
			$("body").append(divFormError);
		}
		
		$(divFormError).append(formErrorContent);
			
		if($.validationEngine.showTriangle != false){		// NO TRIANGLE ON MAX CHECKBOX AND RADIO
			var arrow = document.createElement('div');
			$(arrow).addClass("formErrorArrow");
			$(divFormError).append(arrow);
			if($.validationEngine.settings.promptPosition == "bottomLeft" || $.validationEngine.settings.promptPosition == "bottomRight"){
			$(arrow).addClass("formErrorArrowBottom")
			$(arrow).html('<div class="line1"><!-- --></div><div class="line2"><!-- --></div><div class="line3"><!-- --></div><div class="line4"><!-- --></div><div class="line5"><!-- --></div><div class="line6"><!-- --></div><div class="line7"><!-- --></div><div class="line8"><!-- --></div><div class="line9"><!-- --></div><div class="line10"><!-- --></div>');
		}
			if($.validationEngine.settings.promptPosition == "topLeft" || $.validationEngine.settings.promptPosition == "topRight"){
				$(divFormError).append(arrow);
				$(arrow).html('<div class="line10"><!-- --></div><div class="line9"><!-- --></div><div class="line8"><!-- --></div><div class="line7"><!-- --></div><div class="line6"><!-- --></div><div class="line5"><!-- --></div><div class="line4"><!-- --></div><div class="line3"><!-- --></div><div class="line2"><!-- --></div><div class="line1"><!-- --></div>');
			}
		}
		$(formErrorContent).html(promptText)
		
		var calculatedPosition = $.validationEngine.calculatePosition(caller,promptText,type,ajaxed,divFormError)
		
		calculatedPosition.callerTopPosition +="px";
		calculatedPosition.callerleftPosition +="px";
		calculatedPosition.marginTopSize +="px"
		$(divFormError).css({
			"top":calculatedPosition.callerTopPosition,
			"left":calculatedPosition.callerleftPosition,
			"marginTop":calculatedPosition.marginTopSize,
			"opacity":0
		})
		return $(divFormError).animate({"opacity":0.87},function(){return true;});	
	},
	updatePromptText : function(caller,promptText,type,ajaxed) {	// UPDATE TEXT ERROR IF AN ERROR IS ALREADY DISPLAYED
		
		linkTofield = $.validationEngine.linkTofield(caller);
		var updateThisPrompt =  "."+linkTofield;
		
		if(type == "pass") { $(updateThisPrompt).addClass("greenPopup") }else{ $(updateThisPrompt).removeClass("greenPopup")};
		if(type == "load") { $(updateThisPrompt).addClass("blackPopup") }else{ $(updateThisPrompt).removeClass("blackPopup")};
		if(ajaxed) { $(updateThisPrompt).addClass("ajaxed") }else{ $(updateThisPrompt).removeClass("ajaxed")};
	
		$(updateThisPrompt).find(".formErrorContent").html(promptText);
		
		var calculatedPosition = $.validationEngine.calculatePosition(caller,promptText,type,ajaxed,updateThisPrompt)
		
		calculatedPosition.callerTopPosition +="px";
		calculatedPosition.callerleftPosition +="px";
		calculatedPosition.marginTopSize +="px"
		$(updateThisPrompt).animate({ "top":calculatedPosition.callerTopPosition,"marginTop":calculatedPosition.marginTopSize });
	},
	calculatePosition : function(caller,promptText,type,ajaxed,divFormError){
		
		if($.validationEngine.settings.containerOverflow){		// Is the form contained in an overflown container?
			callerTopPosition = 0;
			callerleftPosition = 0;
			callerWidth =  $(caller).width();
			inputHeight = $(divFormError).height();					// compasation for the triangle
			var marginTopSize = "-"+inputHeight;
		}else{
			callerTopPosition = $(caller).offset().top;
			callerleftPosition = $(caller).offset().left;
			callerWidth =  $(caller).width();
			inputHeight = $(divFormError).height();
			var marginTopSize = 0;
		}
		
		/* POSITIONNING */
		if($.validationEngine.settings.promptPosition == "topRight"){ 
			if($.validationEngine.settings.containerOverflow){		// Is the form contained in an overflown container?
				callerleftPosition += callerWidth -30;
			}else{
				callerleftPosition +=  callerWidth -30; 
				callerTopPosition += -inputHeight; 
			}
		}
		if($.validationEngine.settings.promptPosition == "topLeft"){ callerTopPosition += -inputHeight -10; }
		
		if($.validationEngine.settings.promptPosition == "centerRight"){ callerleftPosition +=  callerWidth +13; }
		
		if($.validationEngine.settings.promptPosition == "bottomLeft"){
			callerHeight =  $(caller).height();
			callerTopPosition = callerTopPosition + callerHeight + 15;
		}
		if($.validationEngine.settings.promptPosition == "bottomRight"){
			callerHeight =  $(caller).height();
			callerleftPosition +=  callerWidth -30;
			callerTopPosition +=  callerHeight +5;
		}
		return {
			"callerTopPosition":callerTopPosition,
			"callerleftPosition":callerleftPosition,
			"marginTopSize":marginTopSize
		}
	},
	linkTofield : function(caller){
		var linkTofield = $(caller).attr("id") + "formError";
		linkTofield = linkTofield.replace(/\[/g,""); 
		linkTofield = linkTofield.replace(/\]/g,"");
		return linkTofield;
	},
	closePrompt : function(caller,outside) {						// CLOSE PROMPT WHEN ERROR CORRECTED
		if(!$.validationEngine.settings){
			$.validationEngine.defaultSetting()
		}
		if(outside){
			$(caller).fadeTo("fast",0,function(){
				$(caller).remove();
			});
			return false;
		}
		if(typeof(ajaxValidate)=='undefined'){ajaxValidate = false}
		if(!ajaxValidate){
			linkTofield = $.validationEngine.linkTofield(caller);
			closingPrompt = "."+linkTofield;
			$(closingPrompt).fadeTo("fast",0,function(){
				$(closingPrompt).remove();
			});
		}
	},
	debug : function(error) {
		if(!$("#debugMode")[0]){
			$("body").append("<div id='debugMode'><div class='debugError'><strong>This is a debug mode, you got a problem with your form, it will try to help you, refresh when you think you nailed down the problem</strong></div></div>");
		}
		$(".debugError").append("<div class='debugerror'>"+error+"</div>");
	},			
	submitValidation : function(caller) {					// FORM SUBMIT VALIDATION LOOPING INLINE VALIDATION
		var stopForm = false;
		$.validationEngine.ajaxValid = true;
		var toValidateSize = $(caller).find("[class*=validate]").size();
		
		$(caller).find("[class*=validate]").each(function(){
			linkTofield = $.validationEngine.linkTofield(this);
			
			if(!$("."+linkTofield).hasClass("ajaxed")){	// DO NOT UPDATE ALREADY AJAXED FIELDS (only happen if no normal errors, don't worry)
				var validationPass = $.validationEngine.loadValidation(this);
				return(validationPass) ? stopForm = true : "";					
			};
		});
		ajaxErrorLength = $.validationEngine.ajaxValidArray.length;		// LOOK IF SOME AJAX IS NOT VALIDATE
		for(x=0;x<ajaxErrorLength;x++){
	 		if($.validationEngine.ajaxValidArray[x][1] == false) $.validationEngine.ajaxValid = false;
 		}
		if(stopForm || !$.validationEngine.ajaxValid){		// GET IF THERE IS AN ERROR OR NOT FROM THIS VALIDATION FUNCTIONS
			if($.validationEngine.settings.scroll){
				if(!$.validationEngine.settings.containerOverflow){
					var destination = $(".formError:not('.greenPopup'):first").offset().top;
					$(".formError:not('.greenPopup')").each(function(){
						testDestination = $(this).offset().top;
						if(destination>testDestination) destination = $(this).offset().top;
					})
					$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100);
				}else{
					var destination = $(".formError:not('.greenPopup'):first").offset().top;
					var scrollContainerScroll = $($.validationEngine.settings.containerOverflowDOM).scrollTop();
					var scrollContainerPos = - parseInt($($.validationEngine.settings.containerOverflowDOM).offset().top);
					var destination = scrollContainerScroll + destination + scrollContainerPos -5
					var scrollContainer = $.validationEngine.settings.containerOverflowDOM+":not(:animated)"
					
					$(scrollContainer).animate({ scrollTop: destination}, 1100);
				}
			}
			return true;
		}else{
			return false;
		}
	}
}
})(jQuery);

Simple viewer flickr

by on Monday, February 20th, 2012

This site automatically publishes the images of this set in my Flickr album, without any manual intervention on my part.

Ready to create your own? Here we go:

1 ° / Find a host

To host your site, you need a server.

If you want to use a free hosting, you can opt for Free, by following the indications of this article (How to create a free website at free.fr).

You can also opt for a hébergment paid for 10 or € 20 per year, for example at OVH at NFrance or 1 & 1.

Warning: you need the fopen function is activated on your server. Imperative to ask your provider if this feature is active on the accommodation you want to!
(if you have a free hosting on Free, this feature is enabled).

I will soon publish a way to circumvent this by changing the script, for those not on their server fopen (using cURL, for those who know).

It is not worth to take shelter with mysql database, you will not need in the case of the site that we create.

Your web space is functional? So go on …

2 ° / Equip yourself some free software

We will need three programs:

– A text editor to modify some files on the site.
The Windows notepad will do quite the case, or any other text editor of database you have on your computer.

– An FTP client to upload the files on your web server.
In this tutorial, we will use Filezilla, which is free and simple to use.

– A software to create your logo, for example Gimp or Inkscape.
It is not essential, but you’ll need if you want to create a logo for your site.

3 ° / Prepare files

1 – Download scripts

We will download the SimpleViewer FlickrViewer and which are free scripts that will be needed:

Download SimpleViewer 1.7
(watch, download this version and not another, otherwise it will not work).

Download FlickrViewer 1.1

2 – Preparation of files

– Unpack the downloaded archive (SimpleViewer and FlickrViewer) on your desktop for example.

– Open the folder SimpleViewer, and replace the file “index.html” with the file “index.html” that is contained in the archive FlickrViewer.

– Take the “flickrViewer.php” that is contained in the archive FlickrViewer and place it in the SimpleViewer.

There. SimpleViewer folder now contains everything we need.
We still have to set some preferences before sending it on the web server.

3 – Get a key to use the Flickr API

For your site to connect to Flickr, you need an API key.

Nothing complicated in there, just go to this address once you’ve logged into your Flickr account and follow these instructions:

Flickr needs to know who we are and for what purpose we wish to use from our Flickr site.

– We will complete the form by providing a name and an e-mail.

– Then, select “non-commercial use.

– In the “Describe the application you are planning to build, we will explain to Flickr what we want to make the API.
For example, copy the following:
Quote:
I need to have an API key to make use of the Flickr API with SimpleViewer and FlickrViewer (weeting.org / mark / flickrviewer /) on my website (address of your site here).
– We check the two boxes at the bottom to accept the terms of use, and valid.

– On the next page, a beautiful code looks: he is our precious key without which the site will not be able to access Flickr.
On the copy, and keeps carefully.

4 – Set Preferences

With Notepad or any text editor, open the file flickrViewer.php (which is now in the SimpleViewer).

We will now change a few things:

1 – Change the key:

Line 22, you have this:
Quote:
$ apikey = ‘b4bb27c883f06aa4575c6c346c402749’;
Replace b4bb27c883f06aa4575c6c346c402749 your API key obtained above.
Make sure you keep the quotes around the key.

2 – Change the identifier of the set

Your site will not display all photos in your Flickr album, but only those of a particular set (one set on Flickr is a category of your album).

For example, you can create a set “Best of”, containing your favorite photos, which will also be published on your site.
Info: On Flickr, a photo can be placed in several sets.

If you have not created a set in your Flickr account, go to Flickr, go to “Organize> Your Sets” and click “create a new set at the top of the screen.
Drag a thumbnail in the case of the image at the top, and choose a name for your set.

Recover indentify the set:
Going on the main page of the set we choose.
For example, in my case: Romania (best) – a photoset on Flickr
The identifier of the set is simply the numbers that are at the end of this address, namely 72157594533186826 in my case.
Search this identifier, and write it down.

Now back to our text editor:
Line 65, you have this:
Quote:
$ setId =’72057594052387557 ‘;
72057594052387557 replace the identifier set, we have noted in the previous step.
Make sure you keep the quotes around that figure.

3 – Change the address of the Flickr album

Line 74, we have this:
Quote:
$ userurl = ‘http://www.flickr.com/photos/markymoo/’;
Replace your ID markymoo by Flickr.
Make sure you keep the “/” final and apostrophes.

4 – Definition of the temporary file

FlickrViewer needs a place where it can create a temporary file to store information.
This allows the site to be faster: it will not need to question when Flickr will have the requested information in memory.

Line 83, we have this:
Quote:
$ cache = “/ tmp / flickr.xml”;
Some shared servers (= accounts of public accommodation), do not write in / tmp of the server, for security reasons.

We will therefore create a specific folder, which we will give rights to write to store this temporary file.

To do this:

1 – open the software filezilla

2 – enter in the top bar of the Filezilla FTP connection information provided by our host.
In the case “port”, to 21.
Then click on “fast”.

3 – Create a folder for the temporary file:
In the right box, we can explore our hosting space.
We will go into the folder that contains the site (for example the folder “www”, this depends on your host) and with a right click, choose “create a directory”.
Call this directory “tmp”.

4 – Give rights to write to this directory.
To allow the site to save temporary files in the directory you just created:
– Let’s do this right click on new folder “tmp”
– Click “File attributes”
– In “value”, enter 777
This will open all access rights on this file.
Then validate.

Now back to our text editor:
Line 83, we have this:
Quote:
$ cache = “/ tmp / flickr.xml”;
We will simply remove the first “/” symbol to denote the tmp folder that is not the server root, but in our personal files to us
This gives:
Quote:
$ cache = “tmp / flickr.xml”;
(we simply removed the first “/”.)

5 – Choose Preferences:

– Hours Cache:

Line 102, we have this:
Quote:
$ ttl = 43200;
This corresponds to the period during which photographs are stored in memory (in the temporary folder that you just created ), In seconds.
Over this period is long, unless your site will have to use Flickr to go look for information.
But also, less your site will be updated regularly.

43200 seconds is 12 hours is a good choice. But you can change this value (0 = nothing is stored in memory.

– Title of site:

Line 107, we have this:
Quote:
$ title = “My Favorite Photos”;
Replace with the title of your site, in keeping with the quotation marks around it.

– Link to Flickr:

Line 120, we have this:
Quote:
$ showImageLink = true;
If you let true, then a link to the Flickr page containing the image will be placed on your site.
If you do not want to replace true by false

– Title of images:

Line 132, we have this:
Quote:
$ showImageCaption = true;
Let true if you want to display the title of the image (taken from Flickr), or make false if you do not wish to.

– Translation of the link that points to the Flickr page:

If you chose to display the link to the photo on Flickr (see step “link to flickr”, line 286 Replace the text
“View full size …”
by: “View actual size” or “See my album on Flickr or whatever you want. This is the text that appears on this link.

– Configuration page:

In your text editor, open the index.html file:

Line 5, you have this:
Quote:
SimpleViewer / Flickr interface in PHP
Replace with the title of your page, it will appear in the top bar of the browser (do not delete the title tags, simply change the text between the tags).

For those knowledgeable in html:
If you want to add a logo, text, links … It is also here that it happens.
You can add your content (logo, text, links …) between the body tags. The part between the tags is the script display images.
You can change the placement of the viewer by changing the style sheet included in the file index.html.

6 – is sent on the server!

First record of the files that we modified.

With Filezilla, then send the contents of the SimpleViewer folder on your web server.

(In the right pane, view the folder of your website, and from the left window, drag the files in the folder SimpleViewer towards the right window).

Add Lumis Gallery to your site

by on Monday, February 20th, 2012

The advantage of Lumis Gallery, is to propose a solution:

– All your Flickr sets are taken into account
– Comments are displayed directly on your site
– You also get a “blog” automatic, which displays the descriptions of your Flickr account you choose
– You have a page with a map of the world where you can see your photos geolocation

The disadvantage: your site is in English.
Yet it was a plus for those who want to do their work outside the Francophone world, without having the control necessary to design their own site in English.

1. Demonstration

Here is how your site if you follow this tutorial:

– Example home page (see the list of sets on the right, the effect in mouse …)

– Example of a display set

– Example of displaying a photo (see posting comments below)

2. Prerequisites

– Have an account on Flickr and use it.
Flickr is a site for sharing pictures easy to use. A comprehensive tutorial on using the service is available here (to make themselves known through Flickr: The user guide).

– Having a web hosting with mysql database.

3. Installation

– Download Lumis Gallery here.

– Unpack the archive on your PC.

– Inc_config.php Open the file in a text editor (Notepad …)

– In this file, make the following replacements:

– Line 12 ($ approot), enter the address where your site is available.

– Line 15 ($ FlickrAPIkey), enter your key to the Flickr API:

For your site to connect to Flickr, you need an API key.

Nothing complicated in there, just go to this address once you’ve logged into your Flickr account and follow these instructions:

Flickr needs to know who we are and for what purpose we wish to use from our Flickr site.

– We will complete the form by providing a name and an e-mail.

– Then, select “non-commercial use.

– In the “Describe the application you are planning to build, we will explain to Flickr what we want to make the API.
For example, copy the following:
Quote:
I need to have an API key to make use of the Flickr API with Lumis Gallery (lumis.com / lumisGallery /) on my website (address of your site here).
– We check the two boxes at the bottom to accept the terms of use, and valid.

– On the next page, a beautiful code looks: he is our precious key without which the site will not be able to access Flickr.
On the copy, and keeps carefully.

– Line 19 ($ gMapsApi): enter your API key for Google Map.

This key is used to display the world map to locate your photos, using the Google Map.

To get it, is simple:

– Go here

– At the bottom, select the check box and enter the address of your site.

– On the next page, the key appears below the text “Your key is”.

Copy it and paste it in your file.

– Line 23 ($ defaultUser), enter your Flickr username.
(Go here if you have not yet defined).

– Fill out the information in your mysql database:

This information is provided by your host:
– Line 31 ($ cachedbUsername): the identifier to access the mysql database
– Line 33 ($ cachedbpassword): the password to access the mysql database
– Line 35 ($ cachedbserver): mysql host (usually: localhost)
– Line 37 ($ cachedb): The name of the mysql database

– The rest of the file can be left unchanged.

However, if you want to change some options (number of images per page, etc …), in which case you should change the other variables.

– Save the file, then send the contents of the folder on your server, eg Filezilla (Learn how to use Filezilla).

4. Use Lumis Gallery

– Location of pages:

Your home page is available here: monsite.com / pictures.php

Another type of home page is available here (list of sets): monsite.com / sets.php? / Viewall /

The blog is available here: monsite.com / tblog.php? / Page1 /

The card for GSE is available here: monsite.com / map.php

– Use of the blog:

The blog displays descriptions of photos that you put a specific tag in Flickr.

This tag is as follows: lumisGallery: blog =*
(replace the * with a category name to be created automatically on your blog).

Nothing more to do!

– Using the card geolocation:

It is fully automatic. Just tagged photos to your Flickr account (see tutorial here (to make themselves known through Flickr: The user guide)).

– If you want the home page is displayed directly chosen when entering the address of the site:

If your server has mod rewrite enabled (ask your host), create a file where you specify:

Quote:
RewriteEngine on
RewriteRule ^ index.html $ pictures.php
(change pictures.php the page you want to host the site).

Name this file. Htaccess (with a. Before) and place it at the root of the site.

– Customize the design of your site:

To personalize the top of the page: edit inc_header.php
To customize the bottom of the page: edit inc_footer.php
To change the CSS styles: edit lumisGallery.css

Get Lat Long on google map

by on Monday, February 20th, 2012

You can get the latitude and longitude of any location on google map by just clicking on that location. Check this out:
But please make sure you have your own google api..

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″/>
<title>
Google Visualization API Sample
</title>
<!–<script type=”text/javascript” src=”http://www.google.com/jsapi”></script>–>
<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA_pv6r9wQUcY29kuVsKu_WRQNER5ay7E813Acg9jrQ4QegGSv

oxQtPvukQA-F6gkLXexTdocP127B3g” type=”text/javascript”></script>

<script type=”text/javascript”>

//<![CDATA[
var marca;
var latinput;
var loninput;
var mapleveli;
testing = function load() {
if (GBrowserIsCompatible()) {

var map = new GMap2(document.getElementById(“map”));
//map.setCenter(new GLatLng(8.984868485653589, -79.51179027557373), 15);
map.setCenter(new GLatLng(37.4419, -122.1419), 15);
var point = new GLatLng(37.4419, -122.1419);

map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());

latinput=document.getElementById(“latinput”);
loninput=document.getElementById(“loninput”);
mapleveli=document.getElementById(“maplevel”);

GEvent.addListener(map,”click”, function(overlay,point) {
//alert(point.x+” “+point.y);
//alert(point);
if(marca){
marca.hide();
marca=new GMarker(point,{“clickable”:false});
map.addOverlay(marca);
latinput.value=point.y;
loninput.value=point.x;
mapleveli.value=map.getZoom()
}
else{
marca=new GMarker(point,{“clickable”:false});
map.addOverlay(marca);
latinput.value=point.y;
loninput.value=point.x;
mapleveli.value=map.getZoom()
}
});
}
}
window.onload=testing;
//]]>
</script>
</head>
<body style=”font-family: Arial;border: 0 none;”>

<label>Property Map Location</label>
<div id=”map” style=”width: 920px; height: 500px”>Loading…</div>

Latitude: <input name=”data[Property][latitude]” id=”latinput” value=”8.984868485653589″>
Longitude: <input name=”data[Property][longitude]” id=”loninput” value=”-79.51179027557373″>
Map level <input name=”data[Property][maplevel]” id=”maplevel” value=”15″>

</body>
</html>

Union Query in Mysql

by on Monday, February 20th, 2012

$query = “(
SELECT DATE_FORMAT( Date, ‘%m/%d/%Y’ ) AS date_time, id, type, ‘notes’ as table_name
FROM notes
WHERE p_id ='”.$pid.”‘
)
UNION (
SELECT DATE_FORMAT( DOS, ‘%m/%d/%Y’ ) AS date_time, id, type, ‘mt_d’ as table_name
FROM mt_d
WHERE p_id ='”.$pid.”‘
)
UNION (
SELECT DATE_FORMAT( created, ‘%m/%d/%Y’ ) AS date_time, id, type, ‘docs’ as table_name
FROM docs
WHERE p_id ='”.$pid.”‘
)
ORDER BY date_time DESC
limit “.$_POST[‘start’].’,’.$_POST[‘limit’];

And the reslut is:

Code:
{“notes_list”:[{“date_time”:”07\/13\/2010″,”id”:”9″,”type”:”Chart Note”,”table_name”:”notes”},{“date_time”:”07\/13\/2010″,”id”:”10″,”type”:”Chart Note”,”table_name”:”notes”},{“date_time”:”07\/13\/2010″,”id”:”3″,”type”:”Chart Note”,”table_name”:”notes”}],”totalRows”:12}

[solved] Mailer Error: Could not instantiate mail function

by on Monday, February 20th, 2012

Error is:
Test emails work fine and so do small batches, but full lists (50+ users) report the following error in the eventlog shortly after queueing a batch:

Quote:
Mailer Error: Could not instantiate mail function

The Reason:

Bluehost limits email to 50 messages per hour by default. Once this limit has been exceeded, the above error is produced in the PHPlist eventlog after each individual message is sent. You can verify this by looking at your server error logs; it will likely state that the hourly email limit has been reached.

The Solution:

You’ve got two choices:

Throttle your email below the acceptable limit (50/hour). Keep in mind that your regular email traffic must be considered as well. If you send 50 list messages per hour, you won’t be able to send your normal email for another hour either.

The other solution is to contact Bluehost and request that the limit be increased–there’s no guarantee that they will, but it could be worth a try. Don’t bother doing this if you are using PHPList to spam unsolicited messages–it will just get your account terminated.

Although my experience with this issue has been limited to Bluehost, there’s no reason why this error wouldn’t apply to other hosts. When in doubt, check your server’s error logs for more details.

Change Text on XP Start Button

by on Monday, February 20th, 2012

I’ve read a number of articles on the internet about changing the text on the Start button in XP. On more than one occasion I’ve seen references to a five (5) letter limitation when the button is renamed. I always wondered if this was true or just an assumption someone made because the default ‘start’ just happened to fit the button size. So, I decided to run a test and see if there really was a five character limit.

As you can see from the screen capture above it would seem that the five character limit isn’t etched in stone. The button expanded to accept the text I entered with no problem. I’ve been using the system for a few weeks now with no adverse effects. That’s not to say I won’t discover something down the road a bit, but for now I feel comfortable with the changes. If you’d like to try the procedure I used, the instructions follow.
Step 1 – Modify Explorer.exe File

In order to make the changes, the file explorer.exe located at C:\Windows needs to be edited. Since explorer.exe is a binary file it requires a special editor. For purposes of this article I have used Resource Hacker. Resource HackerTM is a freeware utility to view, modify, rename, add, delete and extract resources in 32bit Windows executables and resource files (*.res). It incorporates an internal resource script compiler and decompiler and works on Win95, Win98, WinME, WinNT, Win2000 and WinXP operating systems. Navigate here to download Resource Hacker.

The first step is to make a backup copy of the file explorer.exe located at C:\Windows\explorer. Place it in a folder somewhere on your hard drive where it will be safe. Start Resource Hacker and open explorer.exe located at C:\Windows\explorer.exe

The category we are going to be using is String Table. Expand it by clicking the plus sign then navigate down to and expand string 37 followed by highlighting 1033. If you are using the Classic Layout rather than the XP Layout, use number 38. The right hand pane will display the stringtable . We’re going to modify item 578, currently showing the word “start” just as it displays on the current Start button.

There is no magic here. Just double click on the word “start” so that it’s highlighted, making sure the quotation marks are not part of the highlight. They need to remain in place, surrounding the new text that you’ll type. Go ahead and type your new entry. In my case I used ElderGeek .

You’ll notice that after the new text string has been entered the Compile Script button that was grayed out is now active . I won’t get into what’s involved in compiling a script, but suffice it to say it’s going to make this exercise worthwhile. Click Compile Script and then save the altered file using the Save As command on the File Menu. Do not use the Save command – Make sure to use the Save As command and choose a name for the file. Save the newly named file to C:\Windows.

Step 2 – Modify the Registry

Now that the modified explorer.exe has been created it’s necessary to modify the registry so the file will be recognized when the user logs on to the system. If you don’t know how to access the registry I’m not sure this article is for you, but just in case it’s a temporary memory lapse, go to Start (soon to be something else) Run and type regedit in the Open: field. Navigate to:

HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon

In the right pane , double click the Shell entry to open the Edit String dialog box . In Value data: line, enter the name that was used to save the modified explorer.exe file. Click OK.

Close Registry Editor and either log off the system and log back in, or reboot the entire system if that’s your preference. If all went as planned you should see your new Start button with the revised text.

solution for wamp and Skype istallation confliction

by on Monday, February 20th, 2012

Skype can use ports other than the default so that it has a “work anywhere” configuration. To set the ports do the following:

* From the “File” menu select “Options”
* Select the “Connection” tab
* Change the port to 443
* Select the box for “Use port 80 as an alternative for incoming connections”

This will set Skype to use two well known ports, 80 HTTP and 443 HTTPS which are open in virtually all environments.