144 lines
8.9 KiB
PHP
144 lines
8.9 KiB
PHP
<?php
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Copyright (c) SAIWEB Developement */
|
|
/* email : developper@saiweb.fr */
|
|
/* web : http://www.saiweb.fr */
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* 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 */
|
|
/* the Free Software Foundation; either version 2 of the License, or */
|
|
/* (at your option) any later version. */
|
|
/* */
|
|
/* This program is distributed in the hope that it will be useful, */
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
/* GNU General Public License for more details. */
|
|
/* */
|
|
/* You should have received a copy of the GNU General Public License */
|
|
/* along with this program; if not, write to the Free Software */
|
|
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
/* */
|
|
/*************************************************************************************/
|
|
include_once(realpath(dirname(__FILE__))."/../../../classes/PluginsClassiques.class.php");
|
|
include_once(realpath(dirname(__FILE__))."/../../../classes/Modulesdesc.class.php");
|
|
include_once(realpath(dirname(__FILE__))."/../../../classes/Variable.class.php");
|
|
|
|
class Captcha extends PluginsClassiques{
|
|
public $cap_id;
|
|
public $cap_libelle;
|
|
public $cap_image;
|
|
public $table = "ochju_captcha";
|
|
public $bddvars = array("cap_id", "cap_libelle","cap_image");
|
|
public $nom ="Captcha";
|
|
public $titre = "Plugin captcha";
|
|
public $chapo = "Anti-spam ";
|
|
public $description = "Anti-spam pour le formulaire de contact";
|
|
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->ajout_desc($this->nom, $this->titre, $this->chapo, $this->description);
|
|
|
|
}
|
|
public function init(){
|
|
$cnx = new Cnx();
|
|
$resultat = mysql_query("CREATE TABLE IF NOT EXISTS ".$this->table." (
|
|
cap_id int(11) NOT NULL auto_increment,
|
|
cap_libelle char(1) NOT NULL,
|
|
cap_image varchar(50) NOT NULL,
|
|
PRIMARY KEY (cap_id))
|
|
ENGINE=MyISAM;
|
|
",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'a','img1.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'b','img2.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'c','img3.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'d','img4.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'e','img5.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'f','img6.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'g','img7.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'h','img8.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'i','img9.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'j','img10.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'k','img11.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'l','img12.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'m','img13.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'n','img14.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'o','img15.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'p','img16.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'q','img17.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'r','img18.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'s','img19.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'t','img20.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'u','img21.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'v','img22.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'w','img23.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'x','img24.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'y','img25.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'z','img26.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'0','img27.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'1','img28.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'2','img29.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'3','img30.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'4','img31.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'5','img32.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'6','img33.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'7','img34.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'8','img35.png')",$cnx->link);
|
|
$resultat = mysql_query("INSERT INTO ".$this->table." (cap_id, cap_libelle,cap_image) VALUES(null,'9','img36.png')",$cnx->link);
|
|
|
|
}
|
|
|
|
public function destroy(){
|
|
$cnx = new Cnx();
|
|
$arr = mysql_fetch_array(mysql_query("SHOW TABLES LIKE '".$this->table."'",$cnx->link));
|
|
if ($arr[0] == $this->table) $resultat = mysql_query("DROP TABLE ".$this->table." ",$cnx->link);
|
|
}
|
|
|
|
public function ajout_desc($nom, $titre, $chapo, $description, $lang=1, $devise=""){
|
|
$modulesdesc = new Modulesdesc();
|
|
$res = $modulesdesc->verif($nom, $lang);
|
|
$modulesdesc->plugin = $nom;
|
|
$modulesdesc->titre = $titre;
|
|
$modulesdesc->chapo = $chapo;
|
|
$modulesdesc->description = $description;
|
|
$modulesdesc->lang = $lang;
|
|
$modulesdesc->devise = $devise;
|
|
if($res) $modulesdesc->maj();
|
|
else $modulesdesc->add();
|
|
}
|
|
|
|
public function crypte($nb_caratere=5){
|
|
$tableau = array();
|
|
$captcha = new Captcha();
|
|
$query="select * from ".$this->table." ";
|
|
if($resultat = mysql_query($query,$captcha->link)){
|
|
$compteur = mysql_num_rows($resultat);
|
|
if($compteur>0){
|
|
while ($row = mysql_fetch_object($resultat)){
|
|
$tableau[] = array($row->cap_libelle,$row->cap_image);
|
|
}
|
|
}
|
|
mysql_free_result($resultat);
|
|
}
|
|
shuffle($tableau);
|
|
for($j=0;$j<$nb_caratere;$j++){
|
|
$mot .= $tableau[$j][0];
|
|
$images[] = $tableau[$j][1];
|
|
}
|
|
$_SESSION["crypto"] = $mot;
|
|
$resultat = '<span>';
|
|
for($i=0;$i<count($images);$i++){
|
|
$resultat .= '<img src="client/plugins/captcha/images/'.$images[$i].'" />';
|
|
}
|
|
$resultat .= '</span>';
|
|
return $resultat;
|
|
}
|
|
|
|
|
|
public function captcha_img(){
|
|
$captcha = new Captcha();
|
|
$img = $captcha->crypte(5);
|
|
return $img;
|
|
}
|
|
|
|
}
|
|
?>
|