Aller au contenu

jokerman

Actif
  • Compteur de contenus

    32
  • Inscrit(e) le

  • Dernière visite

Réputation sur la communauté

0 Neutre

À propos de jokerman

  • Date de naissance 15/03/1966

Information du profil

  • Genre
    Homme
  • Localisation
    Bordeaux
  • Société
    Smart Design Company
  1. Merci à toi, je connais ce script , il est en effet trés bien, masi il faut le traduire en Français, et je ne dispose pas de temps. je cherche un script (payant) en français.
  2. Bonjour à tous, je recherche un bon script php de support (ticket) en français pas trop cher (maxi 40), pas trop compliqué coté utilisateur, et fiable, merci pour vos suggestions. Amicalement, Jokerman
  3. Bonjour à tous, J'utilise depuis pas mal de temps, la classe template de phpbb, que j'ai modifiée afin d'envoyer des emails avec design+variables (de type {MA_VAR} etc..) je stocke les fichier de mon template (header.tpl et footer.tpl) dans un dossier "./emails" sur le site A. j'ai besoin maintenant d'envoyer des emails depuis un site B (sur un autre serveur) et de pourvoir recuperer dans la classes mes 2 fichiers qui sont sur le site A il semble que la classe n'autorise pas l'appel de fichier sur un serveur distant, comment puis-je résoudre ce probleme ? voici le code de la classe : <?php /*************************************************************************** * template.php * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : © 2001 The phpBB Group * email : support_AT_phpbb.com * * $Id: template.php,v 1.10 2002/04/02 21:13:47 the_systech Exp $ * * ***************************************************************************/ /*************************************************************************** * * 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. * ***************************************************************************/ /** * Template class. By Nathan Codding of the phpBB group. * The interface was originally inspired by PHPLib templates, * and the template file formats are quite similar. * */ if ( class_exists('Template') ) { return; } class Template { var $classname = "Template"; // variable that holds all the data we'll be substituting into // the compiled templates. // ... // This will end up being a multi-dimensional array like this: // $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variabl ename] == value // if it's a root-level variable, it'll be like this: // $this->_tpldata[.][0][varname] == value var $_tpldata = array(); // Hash of filenames for each template handle. var $files = array(); // Root template directory. var $root = "./"; // this will hash handle names to the compiled code for that handle. var $compiled_code = array(); // This will hold the uncompiled code for that handle. var $uncompiled_code = array(); /** * Constructor. Simply sets the root dir. * */ function Template($root = "./") { $this->set_rootdir($root); } /** * Destroys this template object. Should be called when you're done with it, in order * to clear out the template data so you can load/parse a new template set. */ function destroy() { $this->_tpldata = array(); } /** * Sets the template root directory for this Template object. */ function set_rootdir($dir) { if (!is_dir($dir)) { return false; } $this->root = $dir; return true; } /** * Sets the template filenames for handles. $filename_array * should be a hash of handle => filename pairs. */ function set_filenames($filename_array) { if (!is_array($filename_array)) { return false; } reset($filename_array); while(list($handle, $filename) = each($filename_array)) { $this->files[$handle] = $this->make_filename($filename); } return true; } /** * Load the file for the handle, compile the file, * and run the compiled code. This will print out * the results of executing the template. */ function pparse($handle) { if (!$this->loadfile($handle)) { die("Template->pparse(): Impossible de charger le fichier template pour le modèle $handle"); } // actually compile the template now. if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) { // Actually compile the code now. $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]); } // Run the compiled code. eval($this->compiled_code[$handle]); return true; } /** * Inserts the uncompiled code for $handle as the * value of $varname in the root-level. This can be used * to effectively include a template in the middle of another * template. * Note that all desired assignments to the variables in $handle should be done * BEFORE calling this function. */ function assign_var_from_handle($varname, $handle) { if (!$this->loadfile($handle)) { die("Template->assign_var_from_handle(): Impossible de charger le fichier template pour le modèle $handle"); } // Compile it, with the "no echo statements" option on. $_str = ""; $code = $this->compile($this->uncompiled_code[$handle], true, '_str'); // evaluate the variable assignment. eval($code); // assign the value of the generated variable to the given varname. $this->assign_var($varname, $_str); return true; } /** * Block-level variable assignment. Adds a new block iteration with the given * variable assignments. Note that this should only be called once per block * iteration. */ function assign_block_vars($blockname, $vararray) { if (strstr($blockname, '.')) { // Nested block. $blocks = explode('.', $blockname); $blockcount = sizeof($blocks) - 1; $str = '$this->_tpldata'; for ($i = 0; $i < $blockcount; $i++) { $str .= '[\'' . $blocks[$i] . '.\']'; eval('$lastiteration = sizeof(' . $str . ') - 1;'); $str .= '[' . $lastiteration . ']'; } // Now we add the block that we're actually assigning to. // We're adding a new iteration to this block with the given // variable assignments. $str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;'; // Now we evaluate this assignment we've built up. eval($str); } else { // Top-level block. // Add a new iteration to this block with the variable assignments // we were given. $this->_tpldata[$blockname . '.'][] = $vararray; } return true; } /** * Root-level variable assignment. Adds to current assignments, overriding * any existing variable assignment with the same name. */ function assign_vars($vararray) { reset ($vararray); while (list($key, $val) = each($vararray)) { $this->_tpldata['.'][0][$key] = $val; } return true; } /** * Root-level variable assignment. Adds to current assignments, overriding * any existing variable assignment with the same name. */ function assign_var($varname, $varval) { $this->_tpldata['.'][0][$varname] = $varval; return true; } /** * Generates a full path+filename for the given filename, which can either * be an absolute name, or a name relative to the rootdir for this Template * object. */ function make_filename($filename) { // Check if it's an absolute or relative path. if (substr($filename, 0, 1) != '/') { $filename = $this->root . '/' . $filename; } if (!file_exists($filename)) { die("Template->make_filename(): Erreur - Le fichier $filename est inexistant"); } return $filename; } /** * If not already done, load the file for the given handle and populate * the uncompiled_code[] hash with its code. Do not compile. */ function loadfile($handle) { // If the file for this handle is already loaded and compiled, do nothing. if (isset($this->uncompiled_code[$handle]) && !empty($this->uncompiled_code[$handle])) { return true; } // If we don't have a file assigned to this handle, die. if (!isset($this->files[$handle])) { die("Template->loadfile(): Aucun fichier spécifié pour le modèle $handle"); } $filename = $this->files[$handle]; $str = implode("", _AT_file($filename)); if (empty($str)) { die("Template->loadfile(): Le fichier $filename pour le modèle $handle est vide"); } $this->uncompiled_code[$handle] = $str; return true; } /** * Compiles the given string of code, and returns * the result in a string. * If "do_not_echo" is true, the returned code will not be directly * executable, but can be used as part of a variable assignment * for use in assign_code_from_handle(). */ function compile($code, $do_not_echo = false, $retvar = '') { // replace \ with \\ and then ' with \'. $code = str_replace('\\', '\\\\', $code); $code = str_replace('\'', '\\\'', $code); // change template varrefs into PHP varrefs // This one will handle varrefs WITH namespaces $varrefs = array(); preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs); $varcount = sizeof($varrefs[1]); for ($i = 0; $i < $varcount; $i++) { $namespace = $varrefs[1][$i]; $varname = $varrefs[3][$i]; $new = $this->generate_block_varref($namespace, $varname); $code = str_replace($varrefs[0][$i], $new, $code); } // This will handle the remaining root-level varrefs $code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'', $code); // Break it up into lines. $code_lines = explode("\n", $code); $block_nesting_level = 0; $block_names = array(); $block_names[0] = "."; // Second: prepend echo ', append ' . "\n"; to each line. $line_count = sizeof($code_lines); for ($i = 0; $i < $line_count; $i++) { $code_lines[$i] = chop($code_lines[$i]); if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m)) { $n[0] = $m[0]; $n[1] = $m[1]; // Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. if ( preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n) ) { $block_nesting_level++; $block_names[$block_nesting_level] = $m[1]; if ($block_nesting_level < 2) { // Block is not nested. $code_lines[$i] = '$_' . $a[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } else { // This block is nested. // Generate a namespace string for this block. $namespace = implode('.', $block_names); // strip leading period from root level.. $namespace = substr($namespace, 2); // Get a reference to the data array for this block that depends on the // current indices of all parent blocks. $varref = $this->generate_block_data_ref($namespace, false); // Create the for loop code to iterate over this block. $code_lines[$i] = '$_' . $a[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } // We have the end of a block. unset($block_names[$block_nesting_level]); $block_nesting_level--; $code_lines[$i] .= '} // END ' . $n[1]; $m[0] = $n[0]; $m[1] = $n[1]; } else { // We have the start of a block. $block_nesting_level++; $block_names[$block_nesting_level] = $m[1]; if ($block_nesting_level < 2) { // Block is not nested. $code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } else { // This block is nested. // Generate a namespace string for this block. $namespace = implode('.', $block_names); // strip leading period from root level.. $namespace = substr($namespace, 2); // Get a reference to the data array for this block that depends on the // current indices of all parent blocks. $varref = $this->generate_block_data_ref($namespace, false); // Create the for loop code to iterate over this block. $code_lines[$i] = '$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } } } else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m)) { // We have the end of a block. unset($block_names[$block_nesting_level]); $block_nesting_level--; $code_lines[$i] = '} // END ' . $m[1]; } else { // We have an ordinary line of code. if (!$do_not_echo) { $code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";'; } else { $code_lines[$i] = '$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";'; } } } // Bring it back into a single string of lines of code. $code = implode("\n", $code_lines); return $code ; } /** * Generates a reference to the given variable inside the given (possibly nested) * block namespace. This is a string of the form: * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' * It's ready to be inserted into an "echo" line in one of the templates. * NOTE: expects a trailing "." on the namespace. */ function generate_block_varref($namespace, $varname) { // Strip the trailing period. $namespace = substr($namespace, 0, strlen($namespace) - 1); // Get a reference to the data block for this namespace. $varref = $this->generate_block_data_ref($namespace, true); // Prepend the necessary code to stick this in an echo line. // Append the variable reference. $varref .= '[\'' . $varname . '\']'; $varref = '\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \''; return $varref; } /** * Generates a reference to the array of data values for the given * (possibly nested) block namespace. This is a string of the form: * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] * * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. * NOTE: does not expect a trailing "." on the blockname. */ function generate_block_data_ref($blockname, $include_last_iterator) { // Get an array of the blocks involved. $blocks = explode(".", $blockname); $blockcount = sizeof($blocks) - 1; $varref = '$this->_tpldata'; // Build up the string with everything but the last child. for ($i = 0; $i < $blockcount; $i++) { $varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]'; } // Add the block reference for the last child. $varref .= '[\'' . $blocks[$blockcount] . '.\']'; // Add the iterator for the last child if requried. if ($include_last_iterator) { $varref .= '[$_' . $blocks[$blockcount] . '_i]'; } return $varref; } } ?> je vous remercie d'avance, Jokerman
  4. Bonjour à tous, je viens de passer un bon moment à rechercher sur le forum, et je n'ai pas trouvé de réponse à ma question, que voici. je souhaites proposer a mes clients un petit script php (tous les scripts sont connectés à le même base de donnée), le client crée un compte, ce qui génère un sous-domaine virtuel je vois 2 stratégies possibles : 1/ je génère le sous-dossier, je copie le script, le script est alors accessible directement via toto.mondomaine.com/script.php Avantage : facile a mettre en place, pas de problèmes de chemin des fichiers (thèmes, includes etc ..) Inconvénient : beaucoup de fichiers à maintenir 2/ le client se connecte sur script.php?user=toto, je réécris l'url en toto.mondomaine.com/script.php Avantage : un seul script à maintenir Inconvénient : problèmes dans les chemin des fichiers (thèmes, includes etc ..), beaucoup de réécriture. mon htaccess fonctionne pour l'option 1 : Options +FollowSymlinks RewriteEngine on # redirection des sous-domaines RewriteCond %{REQUEST_URI} !^/sdoms RewriteCond %{HTTP_HOST} ^([^.]*)\.?([^.]+).([^.]+)$ [NC] RewriteCond %1 !^www$ [NC] RewriteRule ^(.*)$ /sdoms/%1/$1 # fix trailing slash RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+[^/])$ $1/ [L] Mes questions : 1 - que me conseillez vous ? l'option 1 ou l'option 2 2 - pour l'option 2 quelle est la syntaxe du htaccess que je dois utiliser ? je vous remercie d'avance, Jokerman
  5. Bonsoir, je te remercie pour ta réponse, j'ai essayé, ça ne marche pas. en fait , 1/ je dois verifier si le user ID possede des photos (au moins 1) si il a des photos -> true sinon, 2/ je dois verifier si il a un album (au moins 1) si il a un album -> true sinon, 3/ je dois verifier si il a une categorie (au moins 1) si il a une categorie -> true sinon -> false je dois en fait rechercher si l'utilisateur n'a ni photos, ni albums, ni catégories, est-ce plus clair comme cela ?
  6. je vais detailler ma question un petit peu : je cherche a savoir si le user '$id' possede des photos dans la table "photos" le probleme est que l'id du user n'est pas stocké dan la table "photos" l'id est stocké dans une table "category" (les catégories de photos) ensuite, l'id de la categorie est stocké dans une table "albums", et enfin, les photos sont dans la table "photos" ou est stocké l'id de l'album. la requete : $sql = "SELECT category.id_category,albums.id_album,photos.id_photo LEFT JOIN albums.id_category, photos.id_album WHERE category.id_user= '$id'"; ne donne rien (le serveur du client n'affiche pas les erreurs). jokerman
  7. jokerman

    Requête sur 3 tables

    Bonjour à tous, je vous soumet mon probleme du jour j'ai 4 tables mysql : ---------------- user ---------------- id_user ---------------- category ---------------- id_category id_user ---------------- albums ---------------- id_album id_category ---------------- photos ---------------- id_photo id_album 1/ je dois faire une requête afin de vérifier si un user possede des photos, en verifiant toute la chaine category/albums/photos 2/ je dois faire une requête afin de vérifier si un user possede des albums, en verifiant toute la chaine category/albums 2/ je dois faire une requête afin de vérifier si un user possede des category quel est le moyen le plus simple d'effectuer cette requête ? Merci de votre aide, et bonnes fetes à tous !
  8. Je reformule ma question : comment récuperer le résultat du formulaire sans passer par foreach $_POST, en effet j'ai d'autres variables dans mon formulaire, envoyées aussi en POST, que je dois enregistrer dans une table differente (produits).
  9. ha ha mdr ... c'est ma fonction, je fais deja l'enregistrement, je cherche juste a le faire proprement foreach($_POST as $key=>$val){ if( (is_numeric($key)) && (is_numeric($val)) ){ $sql = "INSERT INTO $produits_critere_Tbl SET id_type_critere='".$key."', id_critere='".$val."', id_produit='".$_POST["id_produit"]."', activer='1'"; mysql_query($sql) or die(mysql_error()); } } ...
  10. Bonjour à tous, voici mon probleme : j'ai une fonction qui génere un formulaire, qui contient plusieurs menus déroulants, je dois enregistrer le resultat dans une base mysql : les tables : type_criteres : ------------------- id_type_critere (key) titre activer criteres : ------------------- id_critere (key) id_type_critere valeur activer exemple de données : type_criteres : ------------------- 1 | couleur | 1 2 | taille | 1 criteres : ------------------- 1 | 1 | rouge | 1 2 | 1 | vert | 1 3 | 2 | XL | 1 la fonction : function Make_Criteria_Form($type_criteres,$criteres_Tbl){ $sql = "SELECT * FROM $type_criteres WHERE activer=1 ORDER BY id_type_critere ASC"; $result = mysql_query($sql) or die(mysql_error()); $total_row_type_critere = mysql_num_rows($result); $form =""; $form .="<table> \n"; if($total_row_type_critere>0){ while($row_type_critere = mysql_fetch_assoc($result)){ $form .="<tr><td> \n"; $form .= $row_type_critere["titre"]." : "; $form .="</td><td> \n"; $sql_criteria = "SELECT * FROM $criteres_Tbl WHERE id_type_critere='".$row_type_critere["id_type_critere"]."' AND activer=1 ORDER BY valeur ASC"; $result_criteria = mysql_query($sql_criteria) or die(mysql_error()); $total_row_criteria = mysql_num_rows($result_criteria); if($total_row_criteria>0){ $form .="<select name=\"".$row_type_critere["id_type_critere"]."\"> \n"; $form .="<option selected>Choisir</option> \n"; while($row_criteria = mysql_fetch_assoc($result_criteria)){ $form .="<option value=\"".$row_criteria["id_critere"]."\">".$row_criteria["valeur"]."</option> \n"; } $form .="</select> \n"; } $form .="</td></tr> \n"; } } $form .="</table> \n"; return $form; } l'affichage du formulaire : <form name="form1" method="post" action=""> <?php echo Make_Criteria_Form($Type_Criteres_Tbl,$Criteres_Tbl); ?> <input type="submit" name="Submit" value="Submit"> <input type="hidden" name="act" value="PostForm"> </form> foreach($_POST as $key=>$val){ echo 'POST : '.$key.'=>'.$val.'<br>'; } me donne : POST : 1=>1 POST : 2=>3 POST : 3=>5 ce qui est correct comme resultat. que dois-je faire pour récupere le résultat du formulaire, et le stocker dans ma base de donnée ?
  11. Bonjour à tous, je recherche un script de whois en php simple à mettre en oeuvre, pouvez vous m'aider ? Merci à tous
  12. jokerman

    Génération de codes

    Bonjour à tous voic mon probleme : je dois générer 21 000 codes (stockés dans mysql+txt) composés comme ceci : 0000178e1da2eef (15 car) décomposition : 00001 <-- séquence de comptage des codes (de 00001 à 21000) les zéros doivnet etres presents comme dans l'exemple (5 car) 78e1da2eef <-- séquance aléatoire (10 car). j'ai un probleme avec la premiere séquance, je n'arrive pas à l'obtenir avec les zeros avez vous une idée ?
  13. j'ai ajouté les portions de code, si cela peut aider merci à toi
  14. Bonjour, Voici mon probleme : - j'ai un petit outil dynamique php/mysql (saisie d'informations via un formulaire en ligne) - cet outil est utilisé par plusieurs employés. je souhaite enregistrés la durée de travail (saisie d'informations) pour chaque employé lorsqu'il utilise ce petit outil. j'ai une table staff_tbl --------------------------- id_staff username password j'ai une table staff_log_tbl --------------------------- id_log id_staff date_jour (date 0000-00-00) time_log_in (time 00:00:00) time_log_out (time 00:00:00) - a chaque connexion d'un employé (session) je crée une entrée dans la table staff_log_tbl (id_staff,date_jour,time_log_in). pour le champ date_jour je fais un date("Y-m-d"). pour le champ time_log_in je fais un date("H:m:i"). et j'enregistre dans la session l'id du log login.php /* aprés vérif username,pasword, je recup l'id du user dans la base, puis je crée le log */ $sql = "INSERT INTO $Staff_log_Tbl SET staff_id='".$rowUser['id']."', date_log='".date("Y-m-d")."', time_log_in='".date("H:m:i")."', what='in'"; mysql_query($sql, $link) or die(mysql_error()); $log_id = mysql_insert_id($link); $_SESSION['log_id'] = $log_id; /* redirection vers l'outil, ./folder/index.php */ - a chaque déconnexion d'un employé (session) je met à jour la table staff_log_tbl pour le champ time_log_out je fais un date("H:m:i"). Mon probleme, je me connecte a 14:00:00, j'ai bien dans la base : time_log_in = 14:00:00, je me déconnecte au bout de 10 mn, et la j'ai dans la base : time_log_in = 14:00:03 (c'est un exemple) la deconnection se fait par le biais d'un lien qui apelle la page de deconnection, dans laquelle je met a jour la table staff_log_tbl log_off.php /* mise à jour du log */ $sql = "UPDATE $Staff_log_Tbl SET time_log_out='".time("H:m:i")."' WHERE id='".$_SESSION['log_id']."'"; mysql_query($sql, $link) or die(mysql_error()); /* destruction de la session etc ... */ je n'arrive pas à enregistrer l'interval réel entre la connexion et la deconnexion merci de votre aide ! jokerman.
  15. Merci beaucoup à tous les deux j'ai pu réparer la base C nickel Une derniere petite question est t'il possible d'afficher a l'ecran (print) l'id des champs traités par une requette INSERT ou UPDATE ? (genre verbose de la requette) ? Merci encore jokerman
×
×
  • Créer...