Sondage du mois

Sondage du mois
 

  La connaissance ne vaut que si elle est partagée par tous




 
  Astuce Adobe Flash : Raccourci Exporter animation : Ctrl Alt Maj S




Infos de Igixcs

Voir sa Fiche Membre

  • Blog conçu le : 27 Juin 2008
  • Nombre d'articles : 9
  • Nombre de pages vues : 9452
  • Adresse Email :

Les articles du blog

Blog de Igixcs
IgiX le POURIS
Blog de Igixcs - FamFamFam flags>php
le 31/01/2009 à 17h04 - 6 commentaires   

FamFamFam flags>php

3/5 (1 votes)

Plop!
Voilà sur famfamfam j'ai trouvé sympa leurs icônes flags et du coups j'poste si y en a qui veulent le bout de code que j'me suis farci pour un traitement sur les flags :p
Clique ici pour afficher le message caché
CODE PHP


<?php

/* PHP by IgiX naabzoor
Flags : http://www.famfamfam.com/lab/icons/flags/ */
$flags = array('AD' => 'Andorra ',
'AE' => 'United Arab Emirates ',
'AF' => 'Afghanistan ',
'AG' => 'Antigua and Barbuda ',
'AI' => 'Anguilla ',
'AL' => 'Albania ',
'AM' => 'Armenia ',
'AN' => 'Netherlands Antilles ',
'AO' => 'Angola ',
'AR' => 'Argentina ',
'AS' => 'American Samoa ',
'AT' => 'Austria ',
'AU' => 'Australia ',
'AW' => 'Aruba ',
'AX' => 'Åland Islands ',
'AZ' => 'Azerbaijan ',
'BA' => 'Bosnia and Herzegovina ',
'BB' => 'Barbados ',
'BD' => 'Bangladesh ',
'BE' => 'Belgium ',
'BF' => 'Burkina Faso ',
'BG' => 'Bulgaria ',
'BH' => 'Bahrain ',
'BI' => 'Burundi ',
'BJ' => 'Benin ',
'BM' => 'Bermuda ',
'BN' => 'Brunei Darussalam ',
'BO' => 'Bolivia ',
'BR' => 'Brazil ',
'BS' => 'Bahamas ',
'BT' => 'Bhutan ',
'BV' => 'Bouvet Island ',
'BW' => 'Botswana ',
'BY' => 'Belarus ',
'BZ' => 'Belize ',
'CA' => 'Canada ',
'CC' => 'Cocos (Keeling) Islands ',
'CD' => 'The Democratic Republic of the Congo ',
'CF' => 'Central African Republic ',
'CG' => 'Congo ',
'CH' => 'Switzerland ',
'CI' => 'Cote d'Ivoire ',
'CK' => 'Cook Islands ',
'CL' => 'Chile ',
'CM' => 'Cameroon ',
'CN' => 'China ',
'CO' => 'Colombia ',
'CR' => 'Costa Rica ',
'CU' => 'Cuba ',
'CV' => 'Cape Verde ',
'CX' => 'Christmas Island ',
'CY' => 'Cyprus ',
'CZ' => 'Czech Republic ',
'DE' => 'Germany ',
'DJ' => 'Djibouti ',
'DK' => 'Denmark ',
'DM' => 'Dominica ',
'DO' => 'Dominican Republic ',
'DZ' => 'Algeria ',
'EC' => 'Ecuador ',
'EE' => 'Estonia ',
'EG' => 'Egypt ',
'EH' => 'Western Sahara ',
'ER' => 'Eritrea ',
'ES' => 'Spain ',
'ET' => 'Ethiopia ',
'FI' => 'Finland ',
'FJ' => 'Fiji ',
'FK' => 'Falkland Islands (Malvinas) ',
'FM' => 'Federated States of Micronesia ',
'FO' => 'Faroe Islands ',
'FR' => 'France ',
'GA' => 'Gabon ',
'GB' => 'United Kingdom ',
'GD' => 'Grenada ',
'GE' => 'Georgia ',
'GF' => 'French Guiana ',
'GG' => 'Guernsey ',
'GH' => 'Ghana ',
'GI' => 'Gibraltar ',
'GL' => 'Greenland ',
'GM' => 'Gambia ',
'GN' => 'Guinea ',
'GP' => 'Guadeloupe ',
'GQ' => 'Equatorial Guinea ',
'GR' => 'Greece ',
'GS' => 'South Georgia and the South Sandwich Islands ',
'GT' => 'Guatemala ',
'GU' => 'Guam ',
'GW' => 'Guinea-Bissau ',
'GY' => 'Guyana ',
'HK' => 'Hong Kong ',
'HM' => 'Heard Island and McDonald Islands ',
'HN' => 'Honduras ',
'HR' => 'Croatia ',
'HT' => 'Haiti ',
'HU' => 'Hungary ',
'ID' => 'Indonesia ',
'IE' => 'Ireland ',
'IL' => 'Israel ',
'IN' => 'India ',
'IO' => 'British Indian Ocean Territory ',
'IQ' => 'Iraq ',
'IR' => 'Islamic Republic of Iran ',
'IS' => 'Iceland ',
'IT' => 'Italy ',
'JM' => 'Jamaica ',
'JO' => 'Jordan ',
'JP' => 'Japan ',
'KE' => 'Kenya ',
'KG' => 'Kyrgyzstan ',
'KH' => 'Cambodia ',
'KI' => 'Kiribati ',
'KM' => 'Comoros ',
'KN' => 'Saint Kitts and Nevis ',
'KP' => 'Democratic People's Republic of Korea ',
'KR' => 'Republic of Korea ',
'KW' => 'Kuwait ',
'KY' => 'Cayman Islands ',
'KZ' => 'Kazakhstan ',
'LA' => 'Lao People's Democratic Republic ',
'LB' => 'Lebanon ',
'LC' => 'Saint Lucia ',
'LI' => 'Liechtenstein ',
'LK' => 'Sri Lanka ',
'LR' => 'Liberia ',
'LS' => 'Lesotho ',
'LT' => 'Lithuania ',
'LU' => 'Luxembourg ',
'LV' => 'Latvia ',
'LY' => 'Libyan Arab Jamahiriya ',
'MA' => 'Morocco ',
'MC' => 'Monaco ',
'MD' => 'Moldova ',
'ME' => 'Montenegro ',
'MG' => 'Madagascar ',
'MH' => 'Marshall Islands ',
'MK' => 'the former Yugoslav Republic of Macedonia ',
'ML' => 'Mali ',
'MM' => 'Myanmar ',
'MN' => 'Mongolia ',
'MO' => 'Macao ',
'MP' => 'Northern Mariana Islands ',
'MQ' => 'Martinique ',
'MR' => 'Mauritania ',
'MS' => 'Montserrat ',
'MT' => 'Malta ',
'MU' => 'Mauritius ',
'MV' => 'Maldives ',
'MW' => 'Malawi ',
'MX' => 'Mexico ',
'MY' => 'Malaysia ',
'MZ' => 'Mozambique ',
'NA' => 'Namibia ',
'NC' => 'New Caledonia ',
'NE' => 'Niger ',
'NF' => 'Norfolk Island ',
'NG' => 'Nigeria ',
'NI' => 'Nicaragua ',
'NL' => 'Netherlands ',
'NO' => 'Norway ',
'NP' => 'Nepal ',
'NR' => 'Nauru ',
'NU' => 'Niue ',
'NZ' => 'New Zealand ',
'OM' => 'Oman ',
'PA' => 'Panama ',
'PE' => 'Peru ',
'PF' => 'French Polynesia ',
'PG' => 'Papua New Guinea ',
'PH' => 'Philippines ',
'PK' => 'Pakistan ',
'PL' => 'Poland ',
'PM' => 'Saint Pierre and Miquelon ',
'PN' => 'Pitcairn ',
'PR' => 'Puerto Rico ',
'PS' => 'Occupied Palestinian Territory ',
'PT' => 'Portugal ',
'PW' => 'Palau ',
'PY' => 'Paraguay ',
'QA' => 'Qatar ',
'RE' => 'Réunion ',
'RO' => 'Romania ',
'RS' => 'Serbia ',
'RU' => 'Russian Federation ',
'RW' => 'Rwanda ',
'SA' => 'Saudi Arabia ',
'SB' => 'Solomon Islands ',
'SC' => 'Seychelles ',
'SD' => 'Sudan ',
'SE' => 'Sweden ',
'SG' => 'Singapore ',
'SH' => 'Saint Helena ',
'SI' => 'Slovenia ',
'SJ' => 'Svalbard and Jan Mayen ',
'SK' => 'Slovakia ',
'SL' => 'Sierra Leone ',
'SM' => 'San Marino ',
'SN' => 'Senegal ',
'SO' => 'Somalia ',
'SR' => 'Suriname ',
'ST' => 'Sao Tome and Principe ',
'SV' => 'El Salvador ',
'SY' => 'Syrian Arab Republic ',
'SZ' => 'Swaziland ',
'TC' => 'Turks and Caicos Islands ',
'TD' => 'Chad ',
'TF' => 'French Southern Territories ',
'TG' => 'Togo ',
'TH' => 'Thailand ',
'TJ' => 'Tajikistan ',
'TK' => 'Tokelau ',
'TL' => 'Timor-Leste ',
'TM' => 'Turkmenistan ',
'TN' => 'Tunisia ',
'TO' => 'Tonga ',
'TR' => 'Turkey ',
'TT' => 'Trinidad and Tobago ',
'TV' => 'Tuvalu ',
'TW' => 'Province of China Taiwan ',
'TZ' => 'United Republic of Tanzania ',
'UA' => 'Ukraine ',
'UG' => 'Uganda ',
'UM' => 'United States Minor Outlying Islands ',
'US' => 'United States ',
'UY' => 'Uruguay ',
'UZ' => 'Uzbekistan ',
'VA' => 'Holy See (Vatican City State) ',
'VC' => 'Saint Vincent and the Grenadines ',
'VE' => 'Venezuela ',
'VG' => 'British Virgin Islands ',
'VI' => 'Virgin Islands, U.S. ',
'VN' => 'Viet Nam ',
'VU' => 'Vanuatu ',
'WF' => 'Wallis and Futuna ',
'WS' => 'Samoa ',
'YE' => 'Yemen ',
'YT' => 'Mayotte ',
'ZA' => 'South Africa ',
'ZM' => 'Zambia ',
'ZW' => 'Zimbabwe');
foreach($flags as $flag => $pays)
echo '<img src="./'.strtolower($flag).'.png" alt="'.$pays.'"/> '.$pays."<br />n";
?>



en bonus une fonction bien pratique pour les formulaires :p
Clique ici pour afficher le message caché
CODE PHP


<?php
function liste_flag($select, $name='flag', $id='flag', $id_prev = 'flag_prev'){
/* PHP by IgiX naabzoor
Flags : http://www.famfamfam.com/lab/icons/flags/ */
$flags = array('AD' => 'Andorra ',
'AE' => 'United Arab Emirates ',
'AF' => 'Afghanistan ',
'AG' => 'Antigua and Barbuda ',
'AI' => 'Anguilla ',
'AL' => 'Albania ',
'AM' => 'Armenia ',
'AN' => 'Netherlands Antilles ',
'AO' => 'Angola ',
'AR' => 'Argentina ',
'AS' => 'American Samoa ',
'AT' => 'Austria ',
'AU' => 'Australia ',
'AW' => 'Aruba ',
'AX' => 'Åland Islands ',
'AZ' => 'Azerbaijan ',
'BA' => 'Bosnia and Herzegovina ',
'BB' => 'Barbados ',
'BD' => 'Bangladesh ',
'BE' => 'Belgium ',
'BF' => 'Burkina Faso ',
'BG' => 'Bulgaria ',
'BH' => 'Bahrain ',
'BI' => 'Burundi ',
'BJ' => 'Benin ',
'BM' => 'Bermuda ',
'BN' => 'Brunei Darussalam ',
'BO' => 'Bolivia ',
'BR' => 'Brazil ',
'BS' => 'Bahamas ',
'BT' => 'Bhutan ',
'BV' => 'Bouvet Island ',
'BW' => 'Botswana ',
'BY' => 'Belarus ',
'BZ' => 'Belize ',
'CA' => 'Canada ',
'CC' => 'Cocos (Keeling) Islands ',
'CD' => 'The Democratic Republic of the Congo ',
'CF' => 'Central African Republic ',
'CG' => 'Congo ',
'CH' => 'Switzerland ',
'CI' => 'Cote d'Ivoire ',
'CK' => 'Cook Islands ',
'CL' => 'Chile ',
'CM' => 'Cameroon ',
'CN' => 'China ',
'CO' => 'Colombia ',
'CR' => 'Costa Rica ',
'CU' => 'Cuba ',
'CV' => 'Cape Verde ',
'CX' => 'Christmas Island ',
'CY' => 'Cyprus ',
'CZ' => 'Czech Republic ',
'DE' => 'Germany ',
'DJ' => 'Djibouti ',
'DK' => 'Denmark ',
'DM' => 'Dominica ',
'DO' => 'Dominican Republic ',
'DZ' => 'Algeria ',
'EC' => 'Ecuador ',
'EE' => 'Estonia ',
'EG' => 'Egypt ',
'EH' => 'Western Sahara ',
'ER' => 'Eritrea ',
'ES' => 'Spain ',
'ET' => 'Ethiopia ',
'FI' => 'Finland ',
'FJ' => 'Fiji ',
'FK' => 'Falkland Islands (Malvinas) ',
'FM' => 'Federated States of Micronesia ',
'FO' => 'Faroe Islands ',
'FR' => 'France ',
'GA' => 'Gabon ',
'GB' => 'United Kingdom ',
'GD' => 'Grenada ',
'GE' => 'Georgia ',
'GF' => 'French Guiana ',
'GG' => 'Guernsey ',
'GH' => 'Ghana ',
'GI' => 'Gibraltar ',
'GL' => 'Greenland ',
'GM' => 'Gambia ',
'GN' => 'Guinea ',
'GP' => 'Guadeloupe ',
'GQ' => 'Equatorial Guinea ',
'GR' => 'Greece ',
'GS' => 'South Georgia and the South Sandwich Islands ',
'GT' => 'Guatemala ',
'GU' => 'Guam ',
'GW' => 'Guinea-Bissau ',
'GY' => 'Guyana ',
'HK' => 'Hong Kong ',
'HM' => 'Heard Island and McDonald Islands ',
'HN' => 'Honduras ',
'HR' => 'Croatia ',
'HT' => 'Haiti ',
'HU' => 'Hungary ',
'ID' => 'Indonesia ',
'IE' => 'Ireland ',
'IL' => 'Israel ',
'IN' => 'India ',
'IO' => 'British Indian Ocean Territory ',
'IQ' => 'Iraq ',
'IR' => 'Islamic Republic of Iran ',
'IS' => 'Iceland ',
'IT' => 'Italy ',
'JM' => 'Jamaica ',
'JO' => 'Jordan ',
'JP' => 'Japan ',
'KE' => 'Kenya ',
'KG' => 'Kyrgyzstan ',
'KH' => 'Cambodia ',
'KI' => 'Kiribati ',
'KM' => 'Comoros ',
'KN' => 'Saint Kitts and Nevis ',
'KP' => 'Democratic People's Republic of Korea ',
'KR' => 'Republic of Korea ',
'KW' => 'Kuwait ',
'KY' => 'Cayman Islands ',
'KZ' => 'Kazakhstan ',
'LA' => 'Lao People's Democratic Republic ',
'LB' => 'Lebanon ',
'LC' => 'Saint Lucia ',
'LI' => 'Liechtenstein ',
'LK' => 'Sri Lanka ',
'LR' => 'Liberia ',
'LS' => 'Lesotho ',
'LT' => 'Lithuania ',
'LU' => 'Luxembourg ',
'LV' => 'Latvia ',
'LY' => 'Libyan Arab Jamahiriya ',
'MA' => 'Morocco ',
'MC' => 'Monaco ',
'MD' => 'Moldova ',
'ME' => 'Montenegro ',
'MG' => 'Madagascar ',
'MH' => 'Marshall Islands ',
'MK' => 'the former Yugoslav Republic of Macedonia ',
'ML' => 'Mali ',
'MM' => 'Myanmar ',
'MN' => 'Mongolia ',
'MO' => 'Macao ',
'MP' => 'Northern Mariana Islands ',
'MQ' => 'Martinique ',
'MR' => 'Mauritania ',
'MS' => 'Montserrat ',
'MT' => 'Malta ',
'MU' => 'Mauritius ',
'MV' => 'Maldives ',
'MW' => 'Malawi ',
'MX' => 'Mexico ',
'MY' => 'Malaysia ',
'MZ' => 'Mozambique ',
'NA' => 'Namibia ',
'NC' => 'New Caledonia ',
'NE' => 'Niger ',
'NF' => 'Norfolk Island ',
'NG' => 'Nigeria ',
'NI' => 'Nicaragua ',
'NL' => 'Netherlands ',
'NO' => 'Norway ',
'NP' => 'Nepal ',
'NR' => 'Nauru ',
'NU' => 'Niue ',
'NZ' => 'New Zealand ',
'OM' => 'Oman ',
'PA' => 'Panama ',
'PE' => 'Peru ',
'PF' => 'French Polynesia ',
'PG' => 'Papua New Guinea ',
'PH' => 'Philippines ',
'PK' => 'Pakistan ',
'PL' => 'Poland ',
'PM' => 'Saint Pierre and Miquelon ',
'PN' => 'Pitcairn ',
'PR' => 'Puerto Rico ',
'PS' => 'Occupied Palestinian Territory ',
'PT' => 'Portugal ',
'PW' => 'Palau ',
'PY' => 'Paraguay ',
'QA' => 'Qatar ',
'RE' => 'Réunion ',
'RO' => 'Romania ',
'RS' => 'Serbia ',
'RU' => 'Russian Federation ',
'RW' => 'Rwanda ',
'SA' => 'Saudi Arabia ',
'SB' => 'Solomon Islands ',
'SC' => 'Seychelles ',
'SD' => 'Sudan ',
'SE' => 'Sweden ',
'SG' => 'Singapore ',
'SH' => 'Saint Helena ',
'SI' => 'Slovenia ',
'SJ' => 'Svalbard and Jan Mayen ',
'SK' => 'Slovakia ',
'SL' => 'Sierra Leone ',
'SM' => 'San Marino ',
'SN' => 'Senegal ',
'SO' => 'Somalia ',
'SR' => 'Suriname ',
'ST' => 'Sao Tome and Principe ',
'SV' => 'El Salvador ',
'SY' => 'Syrian Arab Republic ',
'SZ' => 'Swaziland ',
'TC' => 'Turks and Caicos Islands ',
'TD' => 'Chad ',
'TF' => 'French Southern Territories ',
'TG' => 'Togo ',
'TH' => 'Thailand ',
'TJ' => 'Tajikistan ',
'TK' => 'Tokelau ',
'TL' => 'Timor-Leste ',
'TM' => 'Turkmenistan ',
'TN' => 'Tunisia ',
'TO' => 'Tonga ',
'TR' => 'Turkey ',
'TT' => 'Trinidad and Tobago ',
'TV' => 'Tuvalu ',
'TW' => 'Province of China Taiwan ',
'TZ' => 'United Republic of Tanzania ',
'UA' => 'Ukraine ',
'UG' => 'Uganda ',
'UM' => 'United States Minor Outlying Islands ',
'US' => 'United States ',
'UY' => 'Uruguay ',
'UZ' => 'Uzbekistan ',
'VA' => 'Holy See (Vatican City State) ',
'VC' => 'Saint Vincent and the Grenadines ',
'VE' => 'Venezuela ',
'VG' => 'British Virgin Islands ',
'VI' => 'Virgin Islands, U.S. ',
'VN' => 'Viet Nam ',
'VU' => 'Vanuatu ',
'WF' => 'Wallis and Futuna ',
'WS' => 'Samoa ',
'YE' => 'Yemen ',
'YT' => 'Mayotte ',
'ZA' => 'South Africa ',
'ZM' => 'Zambia ',
'ZW' => 'Zimbabwe');
echo '<select name="'.$name.'" id="'.$id.'" >', "n";
foreach($flags as $flag => $pays){
$changement = 'document.getElementById(''.$id_prev.'').src='./images/flag/'.strtolower($flag).'.png'';
if($select == $flag) $selected='selected="selected"';
else $selected = '';
echo '<option onmouseover='.$changement.' onclick='.$changement.' onselect='.$changement.' '.$selected.' value="'.$flag.'">'.$pays."</option>n";
}
echo '</select>';
}





Partager sur Twitter

Blog de Igixcs - [PHP/Funct] Upload images
le 13/11/2008 à 09h44 - 7 commentaires   

[PHP/Funct] Upload images

5/5 (1 votes)

Voilà quand on s'ennuir, ca ça donne ça :D

Dites moi s'ke vous en pensez :)

CODE PHP


<?php
function upload_img($nom_champ, $destination, $ext_auto, $taille_max, $nom, $largeur=false, $hauteur=false){
/*
by IgiX <hervet.geoffrey@gmail.com > 12/11/2oo8
@Return : mixed
> false en cas d'échec
> URL image en cas de succès
@$nom_champ => name du <input type="file" /> / 'image'
@destination => lien du dossier / './images' => non existance => false
@ext_autao => extensions autorisée / arrey('png', 'gif')
@taille_max => Poids max en octet / 100*1024 100Ko
@nom => nom de l'image / 'image'.mt_rand('0, 13371337').'_'
*/
//Verification existence
if(!isset($_FILES[$nom_champ]))
return false;
//Verification dossier
if(!is_dir($destination))
return false;
//Vérification erreurs
if($_FILES[$nom_champ]['error'] != 0)
return $_FILES[$nom_champ]['error'];
extract(pathinfo($GLOBALS['_FILES'][$nom_champ]['name']));
//Vérification extension
if(!in_array($extension, $ext_auto))
return false;
//Vérification poids
if($_FILES[$nom_champ]['size'] > $taille_max)
return false;
list($largeur_up, $hauteur_up, $constante_image_type, $width_height_html, $bits, $channles, $mime) = getimagesize($_FILES[$nom_champ]['tmp_name']);
//Vérification d'une largeur et d'une hauteur
if(($largeur_up * $hauteur_up) == 0)
return false;
//Si redimensionnement non demandé
$url_image = $destination.'/'.$nom.'.'.$extension;
if( !is_numeric($hauteur) OR !is_numeric($largeur) OR ($largeur * $hauteur) <1){
if(move_uploaded_file($_FILES[$nom_champ]['tmp_name'], $url_image))
return $url_image;
return false;
}
if($_FILES[$nom_champ]['type'] == 'image/jpeg')
$type = 'jpeg';
if($_FILES[$nom_champ]['type'] == 'image/gif')
$type = 'gif';
if($_FILES[$nom_champ]['type'] == 'image/png')
$type = 'png';
if(!isset($type))
return false;
$fonctioncreatfrom = 'imagecreatefrom'.$type;
$image_fonction = 'image'.$type;
$image_sourcee = $fonctioncreatfrom ($_FILES[$nom_champ]['tmp_name']);
$image_destination = imagecreatetruecolor($largeur, $hauteur);
imagecopyresampled($image_destination, $image_sourcee, 0, 0, 0, 0, $largeur, $hauteur, $largeur_up, $hauteur_up);
$image_fonction ($image_destination, $url_image);
return $url_image;
}





Partager sur Twitter

Blog de Igixcs - JS - mt_rand &quot;
le 14/09/2008 à 10h41 - 3 commentaires   

JS - mt_rand &quot;

0/5 (1 votes)

Si y en a qui cherchent a avoir un mt_rand en JS pour ceux que ça intéresser
CODE JAVASCRIPT



/*Powered by IgiX*/
function mt_rand(min, max)
{
var nb= min +(max-min+1)*Math.random();
return Math.floor(nb);
}



Explication :
Math.random() => renvoie un nombre aléatoire entre 0 et 1, ça pourrait être 0.012354912345
donc si min = 0 et max = 100 et random() le renvoi 0.123
nb = 0+(100-0+1)*0.123 = 101*0.123 = 12.423
donc en français c'est
On veut au moins min + la différence entre le max et le min + 1 qui est multiplié par un chiffre aléatoire compris entre 0 et 1

Donc là on obtient un chiffre compris entre min et max mais il est décimal! donc floor(x) nous renvoie l'entier inférieur ou égal à x (ici 12)
en maths c'est
floor(x) c'est la troncature à 1 de x
voilà la fonction
alert(mt_rand(12, 15));



Partager sur Twitter

Blog de Igixcs - Calcul de temps ameliore
le 27/06/2008 à 12h55 - 3 commentaires   

Calcul de temps ameliore

0/5 (1 votes)

Bah voilà, j'avais envie de me faire une p'tite fonction utile pour les dates emotion
A la base J'avais trouvé le script de Percoman un peut trop piquant a mes petits yeux emotion donc je m'en suis vaguement inspiré emotion voici son code pour l'info :p
Clique ici pour afficher le message caché


CODE PHP


<?php
/**********************************
Script réalisé par Manuel Santisteban
manuel.santisteban@orange.fr
**********************************/
function date_day($date1)
{
$date1 = time()-$date1;

if($date1 < 60) {
$date = 'il y a '.$date1.'s';
}
else {
if($date1 > 60 && $date1 < 3600) {
$date1 = floor($date1 / 60);
$date = 'il y a '.$date1.'min';
}
else {
if($date1 > 3600 && $date1 < (3600 * 24)) {
$date1 = floor($date1 / 3600);
$date = 'il y a '.$date1.' '.pluriel('heure',$date1);
}
else {
if($date1 > (3600 * 24)) {
$date1 = floor($date1 / (3600 * 24));
$date = 'il y a '.$date1.' jours';
}
}
}
}

return $date;
}

echo 'Billet posté '.date_day(1203939416);
?>


CODE PHP


<?php
function pluriel($mot, $nb) {
if($nb > 1)
return $mot . 's';
else
return $mot;
}
function temps($date) {
$sec = time() - 60;
$min = time() - 60*60;
$heu = time() - 60*60*3;
$time = time() - $date;
//Recupère time de ce matin 0h00-hier matin meme heure
$time_matin = mktime(0, 0, 0, date('m'), date('d'), date('Y'));//Ce matin 0h0
$time_hier_matin = mktime(0, 0, 0, date('m'), date('d')-1, date('Y'));//hier matin 0h0
if($date > $sec) {//Si on $date moins de 1min
return 'Il y a '. $time . pluriel(' seconde', $time);
}
elseif($date > $min) {//si moins d'une heure
return 'Il y a '.floor($time/60) . pluriel(' minute', floor($time/60));
}
elseif($date > $heu){ //Moins de 3heure
$nb_heure = floor($time/3600);//nombre d'heures
$nb_min = floor(($time%3600)/60);//nombre de minutes
$nb_sec = $time%(3600/60);//nombre de secondes
$retour = 'Il y a ' .$nb_heure. 'h ';//valeur de return
if($nb_min != 0)
$retour .= $nb_min. 'min ';
if($nb_sec != 0)
$retour .= $nb_sec. 's';
return $retour;
}
elseif($date > $time_hier_matin) {//Si plus de 3heures, et hier
//intval pour enlever le 0 si < 10 (date('H') peut revoyer 09, là c'est 9 :p )
$nb_heure = intval(date('H', $date));//nombre d'heures
$nb_min = intval(date('i', $date));//nombre de minutes
$nb_sec = intval(date('s', $date));//nombre de secondes
if($date > $time_matin) //Si aujourd'hui
$retour = 'Aujourd'hui';
else
$retour = 'Hier';

$retour .=' &agrave; ' .$nb_heure. 'h ';
if($nb_min != 0)
$retour .= $nb_min. 'min ';
if($nb_sec != 0)
$retour .= $nb_sec. 's';
return $retour;
}
else {//Avant-hier ou avant
$nb_an = intval(date('y', $date));//numero d'anné
$nb_mois = intval(date('m', $date));//numero de mois
$nb_jour = intval(date('d', $date));//numero de jours
$nb_heure = intval(date('H', $date));//nombre d'heures
$nb_min = intval(date('i', $date));//nombre de minutes
$nb_sec = intval(date('s', $date));//nombre de secondes
$retour = 'Le ' .$nb_jour. '/' .$nb_mois. '/' .$nb_an. ' &agrave ' .$nb_heure. 'h ';
if($nb_min != 0)
$retour .= $nb_min. 'min ';
if($nb_sec != 0)
$retour .= $nb_sec. 's';
return $retour;
}
}





Partager sur Twitter

Blog de Igixcs - My personal captcha[MAJ]
le 27/06/2008 à 00h52 - 4 commentaires   

My personal captcha[MAJ]

0/5 (1 votes)

Bah voilà, j'me suis refais un p'tit captcha :p
CODE PHP


<?php
header ("content-type: image/png");
$largeur = 80;//Height
$hauteur = 18;//Width
$image = imagecreate($largeur, $hauteur);//Creation d'une image vide

imagecolorallocate($image, 255, 255, 255);//Couleur de fond FF/FF/FF blanc

$afficher_les_points = TRUE;//On active les points ^^
if($afficher_les_points) {
$nb_points = mt_rand(100, 150);//Nombre de points dans l'image
$num_point = 0;//Prmier point
while($num_point <= $nb_points) {
$num_point ++;//On incrément le nombre de points
$x = mt_rand(0, $largeur);//valeur aléatoire dans l'image de l'absice du point
$y = mt_rand(0, $hauteur);//valeur aléatoire dans l'image de l'ordonnée du point
$couleur_aleatoire = imagecolorallocate($image, mt_rand(0, 255), 0, mt_rand(0, 255));//Couleur du point aléatoire
ImageSetPixel ($image, $x, $y, $couleur_aleatoire);//On affichele point
}
}
//Fin du test pour les points
$caractere = array(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y','z','A', 'B','C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
// count($caractere) //Renvoi le nombre de lignes (62)
$nb_caracteres_max = mt_rand(3, 6);//Nombre de caractères max
if(isset($_GET['id'])) {//Si on vient de rafraichir la page, on fait une opération pour rafraichir tout l'image
$id = intval($_GET['id']);//Valeur type int
$id = floor($id); //on arrondi
if($id > 62)//Si supérieur a 62, on
$lettre = $caractere[mt_rand(0, 62)];
else
$lettre = $id;
}
else //Sinon, pas d'id
$lettre = $caractere[mt_rand(0, 62)];
$caractere_num = 1;//On a déjà un caractère ;)
while($caractere_num <= $nb_caracteres_max){//La flème d'un for()
$caractere_num ++;
$lettre .= $caractere[mt_rand(0, 61)];//$lettre vaut ce qui est dans l'image
}

//Correction bug tronquer le mot à 6lettres
if(strlen($lettre) > 6) {
$i = 6 - strlen($lettre); //Calcul nb de lettre en trop
$lettre = substr($lettre, 0, $i);
}

$couleur_aleatoire1 = imagecolorallocate($image, mt_rand(0,150), mt_rand(0,150), mt_rand(0,150));//on créé une couleur aléatoire pour le text
imagestring($image, 5, 10, 0, $lettre, $couleur_aleatoire1);//affichage du texte dans l'image

session_start();//ouverture de la session
$_SESSION['code'] = $lettre;
//Il n'y a plus qu'a comparer la valeur du champsanti robot avecla session

imagepng($image);//On créé une imae png
?>


et aussi pour les système anti-robot :

et pour recharger l'image
CODE HTML


<img onclick="this.src='images/image.php?id='+(Math.random()*100);" style="cursor: pointer" src="images/image.php" alt="Capcha" />



Ps : le bouton Apercu marche pas pour les blogs, viens de m'en rendre compte ^^

CORRECTION
//Correction bug tronquer le mot à 6lettres
if(strlen($lettre) > 6) {
$i = 6 - strlen($lettre); //Calcul nb de lettre en trop
$lettre = substr($lettre, 0, $i);
}
BUG LORS DU RAFRAICHISSEMENT : TROP DE CARACTRERES



Partager sur Twitter

Blog de Igixcs - Rejete par la communaute TTM
le 26/04/2008 à 21h55 - 26 commentaires   

Rejete par la communaute TTM

0/5 (1 votes)

On m'a dis sur msnexit("10km...Die"); dit :
bah dfacon TTM on diré ke c une secte carrement c cho..
exit("10km...Die"); dit :
il veule pa de nous xD
IgiX - Easy developpement - dit :
xd
IgiX - Easy developpement - dit :
screen


Voilà ce que m'a dit un ami a moi sur msn, si c'est le cas, soyez franc, dites le nous on s'en ira sans rien dire...

Une citaion
La Franchise peut etre la meilleure des choses comme la pire, mais soyez francs



Partager sur Twitter

Blog de Igixcs - [php]code verif
le 12/04/2008 à 21h33 - 13 commentaires   

[php]code verif

0/5 (1 votes)

Salut tout le monde, bah voilà le code Captcha (je sais pas comment on dit :p) que je me suis concocté!
Pour la page de traitement du formulaire, il vous suffit de tester la session...

Tout est commenté au maximum :)

CODE PHP


<?php
// On veut afficher une image type png
header ("content-type: image/png");
/*
------> 1ere etape : Taille de l'image + fond
*/
// dimension de l'image : 175*50
$largeur = 80;
$hauteur = 40;
$image = imagecreate($largeur, $hauteur);

//Fond de l'image : blanc
imagecolorallocate($image, 255, 255, 255);

/*
------> 2e etape : Affichage des points
*/

//on choisi le nombre de points min, max
$nb_points = mt_rand(100, 150);

//Point numéro 0
$num_point = 0;

//boucle pour afficher tout les point en fonction du nombre de points aleatoires
while($num_point <= $nb_points)
{
//On incrémente la valeur du point (son numero)
$num_point ++;
// on lui defini une valeur aleatoire en x
$x = mt_rand(0, $largeur);
// on lui defini une valeur aleatoire en y
$y = mt_rand(0, $hauteur);

// definition d'un couleur aleatoire
$couleur_aleatoire = imagecolorallocate($image, mt_rand(0, 165), mt_rand(0, 165), mt_rand(0, 165));


// on affiche le point
ImageSetPixel ($image, $x, $y, $couleur_aleatoire);
}
/*
------> 3e etape : Affichage des traits
*/
//nombres de traits max
$nb_max_lignes = mt_rand(10, 30);
$ligne_numero = 0;
while($ligne_numero <= $nb_max_lignes)
{
// incremention nombre de lignes
$ligne_numero ++;

// valeurs aleatoire de x et y
$x1 = mt_rand(0, $largeur);
$y1 = mt_rand(0, $hauteur);
$x2 = mt_rand(0, $largeur);
$y2 = mt_rand(0, $hauteur);

//couleur aleatoire
$couleur_aleatoire = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));

//affichage de la ligne
ImageLine ($image, $x1, $y1, $x2, $y2, $couleur_aleatoire);
}
/*
------> 4e etape : Affichage du texte
*/

//on cree un array ou on stock les lette pour le code de securite (61 + 1 cases)
$caractere = array("a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "q", "d", "f", "g", "h", "j", "k", "l", "m",
"w", "x", "c", "v", "b", "n", "1", "2", "3", "4", "5", "5", "6", "7", "8", "9", "0","A", "Z", "E", "R", "T", "Y",
"U", "I", "O", "P", "Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "W", "C", "V", "B", "N", "X", );

//definition aleatoire nombre de caracteres
$nb_caracteres_max = mt_rand(3, 6);

//lettre numero 1
$lettre = $caractere[mt_rand(0, 61)];
$caractere_num = 1;

//Creation de la boucle pour afficher les autres caracteres
while($caractere_num <= $nb_caracteres_max)
{
$caractere_num ++;
$lettre .= $caractere[mt_rand(0, 61)];
}

// On cree une couleur aleatoire pour tout le texte
$couleur_aleatoire1 = imagecolorallocate($image, 0,0,0);
// Affichage du code
imagestring($image, 5, 10, 10, $lettre, $couleur_aleatoire1);

/*
------> 5e etape : Affichage de l'image + SESSION
*/
// ouverture de la session
session_start();
// $_SESSION['code'] vaut le code aleatoire
$_SESSION['code'] = $lettre;

//affichage de l'image
imagepng($image);
?>



Clique ici pour afficher le message caché
CODE PHP


<?php
header ("content-type: image/png");

$largeur = 80;
$hauteur = 40;
$image = imagecreate($largeur, $hauteur);

imagecolorallocate($image, 255, 255, 255);

$nb_points = mt_rand(100, 150);
$num_point = 0;
while($num_point <= $nb_points)
{
$num_point ++;
$x = mt_rand(0, $largeur);
$y = mt_rand(0, $hauteur);
$couleur_aleatoire = imagecolorallocate($image, mt_rand(0, 255), 0, mt_rand(0, 255));
ImageSetPixel ($image, $x, $y, $couleur_aleatoire);
}

$nb_max_lignes = mt_rand(5, 14);
$ligne_numero = 0;
while($ligne_numero <= $nb_max_lignes)
{
$ligne_numero ++;
$x1 = mt_rand(0, $largeur);
$y1 = mt_rand(0, $hauteur);
$x2 = mt_rand(0, $largeur);
$y2 = mt_rand(0, $hauteur);
$couleur_aleatoire = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 12), mt_rand(0, 200));
ImageLine ($image, $x1, $y1, $x2, $y2, $couleur_aleatoire);
}

$caractere = array("a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "q", "d", "f", "g", "h", "j", "k", "l", "m", "w", "x", "c", "v", "b", "n", "1", "2", "3", "4", "5", "5", "6", "7", "8", "9", "0","A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "W", "C", "V", "B", "N", "X", );
$nb_caracteres_max = mt_rand(3, 6);
$lettre = $caractere[mt_rand(0, 61)];
$caractere_num = 1;
while($caractere_num <= $nb_caracteres_max)
{
$caractere_num ++;
$lettre .= $caractere[mt_rand(0, 61)];
}
$couleur_aleatoire1 = imagecolorallocate($image, 0,0,0);
imagestring($image, 5, 10, 10, $lettre, $couleur_aleatoire1);

session_start();
$_SESSION['code'] = $lettre;

imagepng($image);
?>

voilà j'ai refais le code mais sans commentaires, moins compréhensible mais plus lisible :p



Partager sur Twitter

Blog de Igixcs - Verifier date naissance
le 05/04/2008 à 00h40 - 3 commentaires   

Verifier date naissance

0/5 (1 votes)

CODE PHP


<?php
$date = '01/02/1990';
if(preg_match("#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#", $date))
{
$arr_date = explode("/", $date);
if(checkdate($arr_date['1'], $arr_date['0'], $arr_date['2']))
echo 'ok';

else
echo 'Erreur';
}
else
{
echo 'Erreur';
}
?>



Voilà tout est dans le code! :)

m'ont servi
http://fr.php.net/manual/fr/function.checkdate.php
http://fr.php.net/manual/fr/function.explode.php

[pour le fun]

-- mettre en fonction --
CODE PHP


<?php
function verif_naissance($date)
{

if(preg_match("#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#", $date))
{
$arr_date = explode("/", $date);
if(checkdate($arr_date['1'], $arr_date['0'], $arr_date['2']))
$valeur = TRUE;

else
$valeur = FALSE;
}
else
{
$valeur = FALSE;
}
return $valeur;
}


if(verif_naissance('08/95/1990'))
{
mysql_query('INSERT INTO naissance_a_la_noix VALUES("08/95/1990")');
}





Partager sur Twitter

Blog de Igixcs - fontion match_win oupas!
le 26/03/2008 à 19h41 - 2 commentaires   

fontion match_win oupas!

0/5 (1 votes)

Donc voilà ma première fonction que j'ai utilisée et que je trouve vraiment utile!
Elle indique en fonction de deux scrore, si c'est gagné, perdu, ou égalité avec les class css!
Donc voilà !

CODE PHP


<?php

function fction_match($score1, $score2)
{
if(isset($score1) AND isset($score2) AND is_numeric($score1) AND is_numeric($score2))
// Si les champs sont bien rentrés et qu'il sont des chiffres
{
$score = $score1.'-'.$score2; // pôur utiliser moins de place xD
if($score1 > $score2) // Si $score est plus grand que $score2
{
echo '<span class="match_win">'.$score.'</span>';
}
elseif($score1 < $score2) // Si $score est plus petit que $score2
{
echo '<span class="match_loose">'.$score.'</span>';
}
elseif($score1 == $score2) // Si $score est égale à $score2
{
echo '<span class="match_draw">'.$score.'</span>';
}
}
}
//Exemple d'utilisation
fction_match($mon_score, $leur_score);
fction_match(15, 13);
?>





Partager sur Twitter

DERNIÈRES PUBLICATIONS DE OPEN-MOUTHED

En direct de open-mouthed.com