Guest User

Untitled

a guest
Jan 21st, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 KB | None | 0 0
  1. <?php
  2. /***********************************************************************/
  3.  
  4. // Some info about your mod.
  5. $mod_title = 'Poki BB ChatBox';
  6. $mod_version = '2.0';
  7. $release_date = '06-06-29';
  8. $author = 'Pokemon_JOJO';
  9. $author_email = '[email protected]';
  10. $traducteur = 'Patrice Bourgeois';
  11. $traducteur_site = 'http://portail.olympus.free.fr/';
  12.  
  13. // One or more versions of PunBB that this mod works on. The version names must match exactly!
  14. $punbb_versions = array('1.2', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.2.5', '1.2.6', '1.2.7', '1.2.8', '1.2.9', '1.2.10', '1.2.11', '1.2.12', '1.2.13', '1.2.14', '1.2.15', '1.2.16', '1.2.23');
  15.  
  16. // Set this to false if you haven't implemented the restore function (see below)
  17. $mod_restore = false;
  18.  
  19.  
  20. // This following function will be called when the user presses the "Install" button.
  21. function install()
  22. {
  23. global $db, $db_type, $pun_config;
  24.  
  25. $sql1 = 'CREATE TABLE '.$db->prefix."chatbox_msg (
  26. id int(10) NOT NULL AUTO_INCREMENT,
  27. poster VARCHAR(200) default NULL,
  28. poster_id INT(10) NOT NULL DEFAULT '1',
  29. poster_ip VARCHAR(15) default NULL,
  30. poster_email VARCHAR(50) default NULL,
  31. message TEXT,
  32. posted INT(10) NOT NULL default '0',
  33. PRIMARY KEY (id)
  34. ) TYPE=MyISAM;";
  35. $db->query($sql1) or error('Unable to create table '.$db->prefix.'chatbox_msg.', __FILE__, __LINE__, $db->error());
  36.  
  37. $sql2 = 'ALTER TABLE '.$db->prefix."groups
  38. ADD g_read_chatbox TINYINT(1) default '1' NOT NULL ,
  39. ADD g_post_chatbox TINYINT(1) default '1' NOT NULL ,
  40. ADD g_title_chatbox TEXT default NULL,
  41. ADD g_post_flood_chatbox SMALLINT(6) default '5' NOT NULL";
  42. $db->query($sql2) or error('Unable to add column to groups table.', __FILE__, __LINE__, $db->error());
  43.  
  44. $sql3 = 'ALTER TABLE '.$db->prefix."users
  45. ADD num_posts_chatbox INT(10) NOT NULL default '0',
  46. ADD last_post_chatbox INT(10) default NULL";
  47. $db->query($sql3) or error('Unable to add column to users table.', __FILE__, __LINE__, $db->error());
  48.  
  49. $chatbox_config = array(
  50. 'cb_height' => '400',
  51. 'cb_msg_maxlength' => '300',
  52. 'cb_max_msg' => '30',
  53. 'cb_disposition' => '<strong><pun_username></strong> - <pun_date> - [ <pun_nbpost><pun_nbpost_txt> ] <pun_admin><br /><pun_message>',
  54. 'cb_ajax_refresh' => '5',
  55. 'cb_ajax_errors' => '<strong>[<pun_error>]</strong> - <pun_date><br /><pun_error_text>',
  56. 'cb_space' => '<br />',
  57. 'cb_pbb_version' => '2.0'
  58. );
  59. foreach($chatbox_config AS $key => $value)
  60. {
  61. $db->query("INSERT INTO ".$db->prefix."config (conf_name, conf_value) VALUES ('$key', '".$db->escape($value)."')") or error('Unable to add column "'.$key.'" to config table', __FILE__, __LINE__, $db->error());
  62. }
  63.  
  64. $db->query('UPDATE '.$db->prefix.'groups SET g_title_chatbox=\'<strong>[Admin]</strong>&nbsp;-&nbsp;\', g_read_chatbox=1, g_post_chatbox=1, g_post_flood_chatbox=0 WHERE g_id=1') or error('Unable to update group', __FILE__, __LINE__, $db->error());
  65. $db->query('UPDATE '.$db->prefix.'groups SET g_title_chatbox=\'<strong>[Modo]</strong>&nbsp;-&nbsp;\', g_read_chatbox=1, g_post_chatbox=1, g_post_flood_chatbox=0 WHERE g_id=2') or error('Unable to update group', __FILE__, __LINE__, $db->error());
  66. $db->query('UPDATE '.$db->prefix.'groups SET g_read_chatbox=1, g_post_chatbox=0, g_post_flood_chatbox=10 WHERE g_id=3') or error('Unable to update group', __FILE__, __LINE__, $db->error());
  67. $db->query('UPDATE '.$db->prefix.'groups SET g_read_chatbox=1, g_post_chatbox=1, g_post_flood_chatbox=5 WHERE g_id=4') or error('Unable to update group', __FILE__, __LINE__, $db->error());
  68.  
  69. // and now, update the cache...
  70. require_once PUN_ROOT.'include/cache.php';
  71. generate_config_cache();
  72.  
  73. /*
  74. DO MOD INSTALLATION HERE
  75.  
  76. Here's an example showing how to run different queries depending on $db_type.
  77. NOTE: This is just an example! Replace it with whatever queries your mod needs to run.
  78.  
  79. switch ($db_type)
  80. {
  81. case 'mysql':
  82. case 'mysqli':
  83. $db->query("ALTER TABLE ".$db->prefix."some_table ADD some_column TINYINT(1) NOT NULL DEFAULT 1") or error('Unable to add column "some_column" to table "some_table"', __FILE__, __LINE__, $db->error());
  84. break;
  85.  
  86. default:
  87. $db->query('ALTER TABLE ".$db->prefix."some_table ADD some_column INT(10) NOT NULL DEFAULT 1') or error('Unable to add column "some_column" to table "some_table"', __FILE__, __LINE__, $db->error());
  88. break;
  89. }
  90. */
  91. }
  92.  
  93. // This following function will be called when the user presses the "Restore" button (only if $mod_uninstall is true (see above))
  94. function restore()
  95. {
  96. global $db, $db_type, $pun_config;
  97.  
  98. /*
  99. DO DATABASE RESTORE HERE
  100.  
  101. switch ($db_type)
  102. {
  103. default:
  104. $db->query("ALTER TABLE ".$db->prefix."some_table DROP some_column") or error('Unable to drop column "some_column" from table "some_table"', __FILE__, __LINE__, $db->error());
  105. break;
  106. }
  107. */
  108. }
  109.  
  110. /***********************************************************************/
  111. // DO NOT EDIT ANYTHING BELOW THIS LINE!
  112.  
  113.  
  114. // Circumvent maintenance mode
  115. define('PUN_TURN_OFF_MAINT', 1);
  116. define('PUN_ROOT', './');
  117. require PUN_ROOT.'include/common.php';
  118.  
  119. // We want the complete error message if the script fails
  120. if (!defined('PUN_DEBUG'))
  121. define('PUN_DEBUG', 1);
  122.  
  123. // Make sure we are running a PunBB version that this mod works with
  124. if(!in_array($pun_config['o_cur_version'], $punbb_versions))
  125. exit('You are running a version of PunBB ('.$pun_config['o_cur_version'].') that this mod does not support. This mod supports PunBB versions: '.implode(', ', $punbb_versions));
  126.  
  127. $style = (isset($cur_user)) ? $cur_user['style'] : $pun_config['o_default_style'];
  128.  
  129. ?>
  130. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  131.  
  132. <html dir="ltr">
  133. <head>
  134. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  135. <title><?php echo $mod_title ?> Installation</title>
  136. <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_config['o_default_style'].'.css' ?>" />
  137. </head>
  138. <body>
  139.  
  140. <div id="punwrap">
  141. <div id="puninstall" class="pun" style="margin: 10% 20% auto 20%">
  142.  
  143. <?php
  144.  
  145. if (isset($_POST['form_sent']))
  146. {
  147. if (isset($_POST['install']))
  148. {
  149. // Run the install function (defined above)
  150. install();
  151.  
  152. ?>
  153. <div class="block">
  154. <h2><span>Installation réussie</span></h2>
  155. <div class="box">
  156. <div class="inbox">
  157. <p>Votre base de données a été modifié avec succès <?php echo pun_htmlspecialchars($mod_title) ?>. Lire le fichier Lisez_moi.txt pour les informations de configuration.</p>
  158. </div>
  159. </div>
  160. </div>
  161. <?php
  162.  
  163. }
  164. else
  165. {
  166. // Run the restore function (defined above)
  167. restore();
  168.  
  169. ?>
  170. <div class="block">
  171. <h2><span>Restauration réussie</span></h2>
  172. <div class="box">
  173. <div class="inbox">
  174. <p>Votre base de données a été restaurée avec succès.</p>
  175. </div>
  176. </div>
  177. </div>
  178. <?php
  179.  
  180. }
  181. }
  182. else
  183. {
  184.  
  185. ?>
  186. <div class="blockform">
  187. <h2><span>Installation de la ChatBox</span></h2>
  188. <div class="box">
  189. <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar">
  190. <div><input type="hidden" name="form_sent" value="1" /></div>
  191. <div class="inform">
  192. <p>Ce script va apporter les modifications nécessaires à votre base de données:</p>
  193. <p><strong>Titre:</strong> <?php echo pun_htmlspecialchars($mod_title).' '.$mod_version ?></p>
  194. <p><strong>Auteur:</strong> <?php echo pun_htmlspecialchars($author) ?> (<a href="mailto:<?php echo pun_htmlspecialchars($author_email) ?>"><?php echo pun_htmlspecialchars($author_email) ?></a>)</p>
  195. <p><strong>Traduction française: </strong><?php echo pun_htmlspecialchars($traducteur) ?> (<a href="<?php echo pun_htmlspecialchars($traducteur_site) ?>"><?php echo pun_htmlspecialchars($traducteur_site) ?></a>)</p>
  196. <p><strong>Recommandations:</strong> Veuillez noter que ce plugin n'est pas officiellement supporté par PunBB.
  197. L'installation de ce plugin est à vos risques et périls.</p>
  198. <?php if ($mod_restore): ?> <p>Si vous avez précédemment installé ce plugin et voudriez le désinstaller, vous pouvez cliquer sur le bouton se restaurer ci-dessous pour rétablir la base de données.</p>
  199. <?php endif; ?> </div>
  200. <p><input type="submit" name="install" value="Installer" /><?php if ($mod_restore): ?><input type="submit" name="restore" value="Restaurer" /><?php endif; ?></p>
  201. </form>
  202. </div>
  203. </div>
  204. <?php
  205.  
  206. }
  207.  
  208. ?>
  209.  
  210. </div>
  211. </div>
  212.  
  213. </body>
  214. </html>
Advertisement
Add Comment
Please, Sign In to add comment