1. <?php
  2. /***********************************************************************/
  3.  
  4. // This is the first installation of Another Private Messaging/Topic System
  5.  
  6. // Some info about your mod.
  7. $mod_title      = 'Another Private Messaging/Topic System';
  8. $mod_version    = '2.1.4';
  9. $release_date   = '2011-03-24';
  10. $author         = 'adaur';
  11. $author_email   = 'adaur.underground@gmail.com';
  12.  
  13. // Versions of FluxBB this mod was created for. A warning will be displayed, if versions do not match
  14. $fluxbb_versions= array('1.4.5');
  15.  
  16. // Set this to false if you haven't implemented the restore function (see below)
  17. $mod_restore    = false;
  18.  
  19. // Circumvent maintenance mode
  20. define('PUN_TURN_OFF_MAINT', 1);
  21. define('PUN_ROOT', './');
  22. require PUN_ROOT.'include/common.php';
  23.  
  24. // We want the complete error message if the script fails
  25. if (!defined('PUN_DEBUG'))
  26.     define('PUN_DEBUG', 1);
  27.  
  28. // This following function will be called when the user presses the "Install" button
  29. function install()
  30. {
  31.     global $db, $db_type, $pun_config;
  32.    
  33.     $db->add_field('users', 'use_pm', 'TINYINT(1)', false, '1', 'activate_key') or error('Unable to add column "use_pm" to table "users"', __FILE__, __LINE__, $db->error());
  34.    
  35.     $db->add_field('users', 'notify_pm', 'TINYINT(1)', false, '1', 'use_pm') or error('Unable to add column "notify_pm" to table "users"', __FILE__, __LINE__, $db->error());
  36.    
  37.     $db->add_field('users', 'num_pms', 'INT(10) UNSIGNED', false, '0', 'num_posts') or error('Unable to add column "num_pms" to table "users"', __FILE__, __LINE__, $db->error());
  38.    
  39.     // Regenerate the config cache
  40.     if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
  41.         require PUN_ROOT.'include/cache.php';
  42.  
  43.     generate_config_cache();
  44. }
  45.  
  46. // This following function will be called when the user presses the "Restore" button (only if $mod_restore is true (see above))
  47. function restore()
  48. {
  49.     global $db, $db_type, $pun_config;
  50.    
  51.     // Regenerate the config cache
  52.     if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
  53.         require PUN_ROOT.'include/cache.php';
  54.  
  55.     generate_config_cache();
  56. }
  57.  
  58. // Make sure we are running a FluxBB version that this mod works with
  59. $version_warning = !in_array($pun_config['o_cur_version'], $fluxbb_versions);
  60.  
  61. $style = (isset($pun_user)) ? $pun_user['style'] : $pun_config['o_default_style'];
  62.  
  63. ?>
  64. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  65. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  66. <head>
  67. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  68. <title><?php echo pun_htmlspecialchars($mod_title) ?> installation</title>
  69. <link rel="stylesheet" type="text/css" href="style/<?php echo $style.'.css' ?>" />
  70. </head>
  71. <body>
  72.  
  73. <div id="punwrap">
  74. <div id="puninstall" class="pun" style="margin: 10% 20% auto 20%">
  75.  
  76. <?php
  77.  
  78. if (isset($_POST['form_sent']))
  79. {
  80.     if (isset($_POST['install']))
  81.     {
  82.         // Run the install function (defined above)
  83.         install();
  84.  
  85. ?>
  86. <div class="block">
  87.     <h2><span>Installation successful</span></h2>
  88.     <div class="box">
  89.         <div class="inbox">
  90.             <p>Your database has been successfully prepared for <?php echo pun_htmlspecialchars($mod_title) ?>. See readme.txt for further instructions.</p>
  91.         </div>
  92.     </div>
  93. </div>
  94. <?php
  95.  
  96.     }
  97.     else
  98.     {
  99.         // Run the restore function (defined above)
  100.         restore();
  101.  
  102. ?>
  103. <div class="block">
  104.     <h2><span>Restore successful</span></h2>
  105.     <div class="box">
  106.         <div class="inbox">
  107.             <p>Your database has been successfully restored.</p>
  108.         </div>
  109.     </div>
  110. </div>
  111. <?php
  112.  
  113.     }
  114. }
  115. else
  116. {
  117.  
  118. ?>
  119. <div class="blockform">
  120.     <h2><span>Mod installation</span></h2>
  121.     <div class="box">
  122.         <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar">
  123.             <div><input type="hidden" name="form_sent" value="1" /></div>
  124.             <div class="inform">
  125.                 <p>This script will update your database to work with the following modification:</p>
  126.                 <p><strong>Mod title:</strong> <?php echo pun_htmlspecialchars($mod_title.' '.$mod_version) ?></p>
  127.                 <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>
  128.                 <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>
  129. <?php if ($mod_restore): ?>
  130.                 <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>
  131. <?php endif; ?>
  132. <?php if ($version_warning): ?>
  133.                 <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>
  134. <?php endif; ?>
  135.             </div>
  136.             <p class="buttons"><input type="submit" name="install" value="Install" /><?php if ($mod_restore): ?><input type="submit" name="restore" value="Restore" /><?php endif; ?></p>
  137.         </form>
  138.     </div>
  139. </div>
  140. <?php
  141.  
  142. }
  143.  
  144. ?>
  145.  
  146. </div>
  147. </div>
  148.  
  149. </body>
  150. </html>