Automaticly Copy Zend/Symfony Library to Project

Zend Framework Batch file

@echo off
:MENU
ECHO Zend will be copied to "%CD%\library"
SET /P M=Type PRESS 1 to continue or any key to EXIT:
IF %M%==1 (	GOTO IMPORT ) ELSE ( GOTO :EOF )
:IMPORT
xcopy /E "ABSOLUTE_PATH_TO_Zend_Library" "%CD%\library"
GOTO :EOF

Symfony Framework Batch file

@echo off
:MENU
ECHO Symfony will be copied to "%CD%\lib\vendor"
SET /P M=Type PRESS 1 to continue or any key to EXIT:
IF %M%==1 (	GOTO IMPORT ) ELSE ( GOTO :EOF )
:IMPORT
xcopy /E "ABSOLUTE_PATH_TO_Symfony_Library" "%CD%\lib\vendor\"
GOTO :EOF

Read the rest of this entry »

Zend Framework : Create Modular Application [Part 2]

SQL Code

CREATE  DATABASE  `MyApp` ;

Then under `MyApp`

CREATE TABLE IF NOT EXISTS `guestbook` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`comment` text NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Using Zend_Tool configure Database

zf configure db-adapter "adapter=pdo_mysql&host=localhost&username=root&password=&dbname=MyApp"

Or add lines directly into application.ini

resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "MyApp"

Create a table (Model) for ‘MyApp.guestbook’ database

zf create db-table Guestbook guestbook Guestbook
/* zf create db-table Model-Name The-Table-Name Module-Name */

To Be continued

Recaptcha basic php class

See Demo
@ PhpClasses.org

<?php
/*
 *	Easy Recaptcha : Basic class
 *	Abdelkader ELKALIDI | contact@updel.com
 *	More infos : https://www.google.com/recaptcha
 */
class Recaptcha{
	public 		$theme		=	'clean';
	public 		$lang		=	'en';
	public		$publicKey;
	public 		$privateKey;
	public 		$messages	=	array(
									'invalid-site-private-key'	=>	'We weren\'t able to verify the private key.',
									'invalid-request-cookie'	=>	'The challenge parameter of the verify script was incorrect.',
									'incorrect-captcha-sol'		=>	'The CAPTCHA solution was incorrect.',
									'recaptcha-not-reachable'	=>	'reCAPTCHA never returns this error code. A plugin should manually return this code in the unlikely event that it is unable to contact the reCAPTCHA verify server.',
								);
	protected 	$error;
	protected 	$recaptchaServer 		= 	'http://www.google.com/recaptcha/api';
	protected 	$recaptchaSslServer 	= 	'https://www.google.com/recaptcha/api';
	protected 	$recaptchaCheckServer 	= 	'http://www.google.com/recaptcha/api/verify';

	/*
	 *	Nothing
	 */
	function __construct(){
	}

	/*
	 *	Debugger
	 */
	public function getError() {
		return !empty($this->error)	? $this->messages[$this->error] : false;
	}

	/*
	 *	Get Recaptcha
	 */
	public function getCaptcha($ssl = 0){
		$server	=	($ssl)	?	$this->recaptchaSslServer	:	$this->recaptchaServer;
		$error	=	(!$this->getError()) ? null : "&amp;error=" . $this->getError();
		$html	=	'
		<script type= "text/javascript">
			var RecaptchaOptions = {theme: \''.$this->theme.'\', lang : \''.$this->lang.'\'	};
		</script>
		<script type="text/javascript" src="'.$server.'/challenge?k='.$this->publicKey.$error.'"></script><noscript><iframe src="'.$server.'/noscript?k='.$this->publicKey.$error.'" height="300" width="500" frameborder="0"></iframe><br /><textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea><input type="hidden" name="recaptcha_response_field" value="manual_challenge"/></noscript>';
		return	$html;
	}

	/*
	 *	Check Recaptcha
	 */
	public function checkCaptcha(){
        $data 	= 	$this->getBySocket(
								$this->recaptchaCheckServer,
								array (
									'privatekey'	=> 	$this->privateKey,
									'remoteip'		=> 	$_SERVER["REMOTE_ADDR"],
									'challenge'		=> 	$_POST['recaptcha_challenge_field'],
									'response'		=> 	$_POST['recaptcha_response_field'],
								)
							);

        $array 			= 	explode("\n", $data);
		$this->error 	= 	(trim($array[0]) == 'false') ? trim($array[1]) : null;
	}

	/*
	 *	Send Data using Sockets
	 */
	private function getBySocket($url, $data) {
		$data		=	$this->concatData($data);
		$post	 	= 	curl_init();
		curl_setopt($post, CURLOPT_URL, $url);
		curl_setopt($post, CURLOPT_USERAGENT, $data);
		curl_setopt($post, CURLOPT_POST, 1);
		curl_setopt($post, CURLOPT_POSTFIELDS,$data);
		curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
		$response = curl_exec($post);
		curl_close($post);
		return $response;
	}

	/*
	 *	Concat Data
	 */
	private function concatData($data) {
		if(is_array($data)){
			foreach ($data as $key => $value){
				$var[]	= $key."=".$value;
			}
			return implode("&",$var);
		}
		else{
			return $data;
		}
	}
}

Example :

<form method="post" action="">
<?php
    require 'recaptcha.class.php';

    $captcha    =    new Recaptcha;
    $captcha->publicKey        =    'your public API key';
    $captcha->privateKey    =    'your private API key';

    if(isset($_POST) AND !empty($_POST)){
        $captcha->checkCaptcha();
        $debug    =    $captcha->getError();
        if(!$debug){
            echo 'All right';
        }
        else{
            echo $debug;
        }
    }

    echo $captcha->getCaptcha();
?>
<input type="submit" value="Check captcha" />
</form>

Lost your Dv lottery confirmation number ?

There’s no way to get your confirmation number after you’ve lost it.

However don’t worry, you will be sent a notification letter in the mail if you win.
This letter will also show what number in line you are, and you can check online

Zend Framework : Modular Application [Part 1]

Project description : A simple guestbook module using Zend Framework 1.11 .

Project

Create new project using Zend_Tool :

zf create project MyApp
cd MyApp

Create module :

zf create module Guestbook

Create controller for Guestbook (1 = index action included):

zf create controller Index 1 Guestbook

Now go to /MyApp/application/configs/application.ini and comment/delete the line :

;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

Then add the lines

;Modular suport
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =

And add this lines to set Guestbook as default module

resources.frontController.params.prefixDefaultModule = "1"
resources.frontController.defaultModule = "Guestbook"

Create php file “Bootstrap.php” under folder /MyApp/application/modules/Guestbook and past the code

<?php
class Guestbook_Bootstrap extends Zend_Application_Module_Bootstrap{}

Now test your app

Read the rest of this entry »

Windows plutôt que Mac OS sur votre Laptop

Billet  de survie !

Microsoft Windows plutôt que Mac OS sur mon Laptop pour la simple raison : C’est mon ordinateur Portable “multiple utilisations”, donc j’ai besoin d’un maximum d’outils, de logiciels et de jeux, et ça seule Windows peut me le garantir !

Ubuntu Desktop sur le PC maison afin de protéger la famille et de garder contact avec cette beauté gratuite, Ubuntu Netbook également sur une partition de mon Laptop.

Centos sur le serveur.

Drag2Crop mootools plugin : Drag picture inside a box

UPDATE 09/06/2010 : Start drag at “Top” and “Left” values.

facebook_thumbnail

Drag2Crop : This small mootools plugin extends “Drag plgin” allow to drag picture inside a small box to get a thumbnail showing the good part of the picture, and after Drag complete return values [Top, Left, Width, Height] of picture relative to the box (Like facebook).

The MooTools 1.2 JavaScript

var Drag2Crop = new Class({
    Extends: Drag,
    Implements:[Options,Events],
    initialize: function(picture, options) {
        this.setOptions({
            relative    :    'relative',
            modifiers   :    { x: 'scrollLeft', y: 'scrollTop' },
            style       :    false,
            invert      :    true,
            top  		:    0,
            left		:    0,
            onComplete  :    this.complete.bind(this),
            debug       :    false
        }, options);
		this.top        =     this.options.top.toInt();
        this.left       =     this.options.left.toInt();
        this.picture    =     $(picture);
        this.relative   =     $(this.options.relative).setStyles({cursor:'move'}).scrollTo(-this.left, -this.top);
 this.parent(this.relative);
 this.__construct();
 },
 __construct	:    function(){
 if(Browser.Engine.trident) document.ondragstart = function (){return false;}; // IE fix
 },
 coordinates	: function(){
 this.getCoordinates	=	this.relative.getScroll();
 this.getSize		=	this.relative.getSize();
 this.width  		=   this.relative.getSize().x.toInt();
 this.height  		=   this.relative.getSize().y.toInt();
 this.left  			=   -this.getCoordinates.x.toInt();
 this.top    		=   -this.getCoordinates.y.toInt();
 },
 complete    :    function(){
 this.coordinates();
 this.fireEvent("done",[this.top,this.left,this.width,this.height]);
 }
});

The Usage

window.addEvent('load', function(){
	new Drag2Crop('pictureId', {
		relative 	: 	'relative',
		top			:	-30, // Start at top : -30
		left		:	-60, // Start at left : -60
        onStart		:    function(){
            this.picture.setStyles({opacity:0.5});
        },
        onDone      :    function(top,left){
            this.picture.setStyles({opacity:1});
			$('test').set('text', 'Top : ' + top + ' | Left : ' + left);
        }
    });
});

See Demo

GitHub Repository

Projet @ Mootools Forge

Events :

beforeStart : Executed before the Drag instance attaches the events. Receives the dragged element as an argument.

start : Executed when the user starts to drag (on mousedown). Receives the dragged element as an argument.

snap : Executed when the user has dragged past the snap option. Receives the dragged element as an argument.

drag : Executed on every step of the drag. Receives the dragged element and the event as arguments.

complete : Executed when the user completes the drag. Receives the dragged element and the event as arguments.

cancel : Executed when the user has cancelled the drag. Receives the dragged element as an argument.

top: (number) start drag at top value.

left: (number) start drag at left value.

done : Executed when the user completes the drag.Receives the values [Top, Left, Width, Height] of picture relative to the box

Cloture d’un compte bancaire : Le service :D

Si vous cherchez un exemple de lettre de clôture d’un compte bancaire au Maroc essayez ma version téléchargeable ici .

Je peux vous dire que j’ai eu la pire “bureaucratique réception” de ma vie !!! Un service qui a rapidement écrasé mes bons vieux souvenirs avec la “BMCE CENTRE D’AFFAIRES SAFI” il y a quelques années déjà, le jour ou j’ai ouvert mon premier compte bancaire accompagné seulement de ma CIN, mais aussi le jour ou tout le personnel de la banque s’est échanger mon chèque électronique avant de se décider, c’était leur première fois !!!

Aujourd’hui la jeune dame au cheveux court et corps plein nommée N (haha) s’est donné la peine de me montrer combien je suis frivole.

Heureusement que j’ai pris l’habitude de s’en foutre de la façon dont le “citoyen basique” comme moi se traite parfois dans différents services par quelques employés, alors dès que j’ai rentré chez moi : une douche suivi par une sieste et sujet achevé !!

nb : Merci Simo

The thrilling potential of SixthSense technology

Smarty : {capture} to put code in your header page

If you are using Smarty to generate your templates, I strongly advice you to take advantage of the function: {capture}

This function is used to collect the output of the template between the tags {capture}{/capture} into a variable instead of displaying it.

Exemple  :

index.tpl

{capture name=header}
{literal}
<script type="text/javascript">
alert('Javascript in head');
</script>
{/literal}
{/capture}
<!-- Include Page Header using Smarty {include} -->
{include file="header.tpl"}
My index page content

header.tpl

<html>
<head>
<title>Page ttle</title>
{$smarty.capture.header}
</head>

Nb : “Javascript code” must be placed between {literal}{/literal}

Page 1 of 41234»