fanf73

Points par topic - install_mod.php

Jun 23rd, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.17 KB | None | 0 0
  1. <?php
  2. /***********************************************************************/
  3.  
  4. // Some info about your mod.
  5. $mod_title      = 'Point par discussion';
  6. $mod_version    = '1.0';
  7. $release_date   = '2011-06-23';
  8. $author         = 'François';
  9. $author_email   = '[email protected]';
  10.  
  11. // Versions of FluxBB this mod was created for. A warning will be displayed, if versions do not match
  12. $fluxbb_versions= array('1.4', '1.4.0', '1.4.1', '1.4.2', '1.4.3', '1.4.4', '1.4.5');
  13.  
  14. // Set this to false if you haven't implemented the restore function (see below)
  15. $mod_restore    = true;
  16.  
  17.  
  18. // This following function will be called when the user presses the "Install" button
  19. function install()
  20. {
  21.     global $db, $db_type, $pun_config;
  22.  
  23.     // Add fields for the rights
  24.     $db->add_field('forums', 'points', 'INT(11)', FALSE, '0') or error('Unable to add column "points" to table "forums"', __FILE__, __LINE__, $db->error());
  25.     $db->add_field('users', 'points', 'INT(11)', FALSE, '0') or error('Unable to add column "points" to table "users"', __FILE__, __LINE__, $db->error());
  26.        
  27. }
  28.  
  29. // This following function will be called when the user presses the "Restore" button (only if $mod_restore is true (see above))
  30. function restore()
  31. {
  32.     global $db, $db_type, $pun_config;
  33.  
  34.     $db->drop_field('forums', 'points') or error('Unable to drop column "points" from table "forums"', __FILE__, __LINE__, $db->error());
  35.     $db->drop_field('users', 'points') or error('Unable to drop column "points" from table "users"', __FILE__, __LINE__, $db->error());
  36.    
  37. }
  38.  
  39. /***********************************************************************/
  40.  
  41. // DO NOT EDIT ANYTHING BELOW THIS LINE!
  42.  
  43.  
  44. // Circumvent maintenance mode
  45. define('PUN_TURN_OFF_MAINT', 1);
  46. define('PUN_ROOT', './');
  47. require PUN_ROOT.'include/common.php';
  48.  
  49. // We want the complete error message if the script fails
  50. if (!defined('PUN_DEBUG'))
  51.     define('PUN_DEBUG', 1);
  52.  
  53. // Make sure we are running a FluxBB version that this mod works with
  54. $version_warning = !in_array($pun_config['o_cur_version'], $fluxbb_versions);
  55.  
  56. $style = (isset($pun_user)) ? $pun_user['style'] : $pun_config['o_default_style'];
  57.  
  58. ?>
  59. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  60. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  61. <head>
  62. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  63. <title><?php echo pun_htmlspecialchars($mod_title) ?> installation</title>
  64. <link rel="stylesheet" type="text/css" href="style/<?php echo $style.'.css' ?>" />
  65. </head>
  66. <body>
  67.  
  68. <div id="punwrap">
  69. <div id="puninstall" class="pun" style="margin: 10% 20% auto 20%">
  70.  
  71. <?php
  72.  
  73. if (isset($_POST['form_sent']))
  74. {
  75.     if (isset($_POST['install']))
  76.     {
  77.         // Run the install function (defined above)
  78.         install();
  79.  
  80. ?>
  81. <div class="block">
  82.     <h2><span>Installation successful</span></h2>
  83.     <div class="box">
  84.         <div class="inbox">
  85.             <p>Your database has been successfully prepared for <?php echo pun_htmlspecialchars($mod_title) ?>. See readme.txt for further instructions.</p>
  86.         </div>
  87.     </div>
  88. </div>
  89. <?php
  90.  
  91.     }
  92.     else
  93.     {
  94.         // Run the restore function (defined above)
  95.         restore();
  96.  
  97. ?>
  98. <div class="block">
  99.     <h2><span>Restore successful</span></h2>
  100.     <div class="box">
  101.         <div class="inbox">
  102.             <p>Your database has been successfully restored.</p>
  103.         </div>
  104.     </div>
  105. </div>
  106. <?php
  107.  
  108.     }
  109. }
  110. else
  111. {
  112.  
  113. ?>
  114. <div class="blockform">
  115.     <h2><span>Mod installation</span></h2>
  116.     <div class="box">
  117.         <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar">
  118.             <div><input type="hidden" name="form_sent" value="1" /></div>
  119.             <div class="inform">
  120.                 <p>This script will update your database to work with the following modification:</p>
  121.                 <p><strong>Mod title:</strong> <?php echo pun_htmlspecialchars($mod_title.' '.$mod_version) ?></p>
  122.                 <p><strong>Author:</strong> <?php echo pun_htmlspecialchars($author) ?> (<a href="mailto:<?php echo pun_htmlspecialchars($author_email) ?>"><?php echo pun_htmlspecialchars($author_email) ?></a>)</p>
  123.                 <p><strong>Disclaimer:</strong> Mods are not officially supported by FluxBB. Mods generally can't be uninstalled without running SQL queries manually against the database. Make backups of all data you deem necessary before installing.</p>
  124. <?php if ($mod_restore): ?>
  125.                 <p>If you've previously installed this mod and would like to uninstall it, you can click the Restore button below to restore the database.</p>
  126. <?php endif; ?>
  127. <?php if ($version_warning): ?>
  128.                 <p style="color: #a00"><strong>Warning:</strong> The mod you are about to install was not made specifically to support your current version of FluxBB (<?php echo $pun_config['o_cur_version']; ?>). This mod supports FluxBB versions: <?php echo pun_htmlspecialchars(implode(', ', $fluxbb_versions)); ?>. If you are uncertain about installing the mod due to this potential version conflict, contact the mod author.</p>
  129. <?php endif; ?>
  130.             </div>
  131.             <p class="buttons"><input type="submit" name="install" value="Install" /><?php if ($mod_restore): ?><input type="submit" name="restore" value="Restore" /><?php endif; ?></p>
  132.         </form>
  133.     </div>
  134. </div>
  135. <?php
  136.  
  137. }
  138.  
  139. ?>
  140.  
  141. </div>
  142. </div>
  143.  
  144. </body>
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment