Rev | Line | |
---|
[6] | 1 | <?php |
---|
| 2 | |
---|
| 3 | // |
---|
| 4 | // Generate smiley cache PHP array |
---|
| 5 | // |
---|
| 6 | function generate_smiley_cache() |
---|
| 7 | { |
---|
| 8 | global $db; |
---|
| 9 | |
---|
| 10 | $smiley_text = array(); |
---|
| 11 | $smiley_img = array(); |
---|
| 12 | |
---|
| 13 | $result = $db->query('SELECT image, text FROM '.$db->prefix.'smilies ORDER BY disp_position') or error('Impossible de retrouver les smilies', __FILE__, __LINE__, $db->error()); |
---|
| 14 | while ($db_smilies = $db->fetch_assoc($result)) |
---|
| 15 | { |
---|
| 16 | $smiley_text[] = $db_smilies['text']; |
---|
| 17 | $smiley_img[] = $db_smilies['image']; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | $smiley_text = array_map('addslashes', $smiley_text); |
---|
| 21 | $smiley_text = array_map('pun_htmlspecialchars', $smiley_text); |
---|
| 22 | |
---|
| 23 | $str = ''; |
---|
| 24 | |
---|
| 25 | $str .= '<?php'."\n\n"; |
---|
| 26 | $str .= '$smiley_text = array('."\n"; |
---|
| 27 | |
---|
| 28 | foreach ($smiley_text as $t) |
---|
| 29 | $str .= "'".$t."',"."\n"; |
---|
| 30 | |
---|
| 31 | $str .= ');'."\n\n"; |
---|
| 32 | $str .= '$smiley_img = array('."\n"; |
---|
| 33 | |
---|
| 34 | foreach ($smiley_img as $i) |
---|
| 35 | $str .= "'".$i."',"."\n"; |
---|
| 36 | |
---|
| 37 | $str .= ');'."\n\n"; |
---|
| 38 | $str .= 'define(\'PUN_CACHE_SMILEY\', 1);'."\n\n"; |
---|
| 39 | $str .= '?>'; |
---|
| 40 | |
---|
| 41 | $fh = @fopen(PUN_ROOT.'cache/cache_smilies.php', 'wb'); |
---|
| 42 | if (!$fh) |
---|
| 43 | error('Impossible d\'écrire le fichier cache de smileys dans le répertoire cache. Veuillez vous assurer que PHP a l\'accÚs en écrire au répertoire \'cache\'', __FILE__, __LINE__); |
---|
| 44 | |
---|
| 45 | fwrite($fh, $str); |
---|
| 46 | |
---|
| 47 | fclose($fh); |
---|
| 48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.