[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/admin/modules/config/ -> plugins.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  $page->add_breadcrumb_item($lang->plugins, "index.php?module=config-plugins");
  18  
  19  $plugins->run_hooks("admin_config_plugins_begin");
  20  
  21  if($mybb->input['action'] == "browse")
  22  {
  23      $page->add_breadcrumb_item($lang->browse_plugins);
  24  
  25      $page->output_header($lang->browse_plugins);
  26  
  27      $sub_tabs['plugins'] = array(
  28          'title' => $lang->plugins,
  29          'link' => "index.php?module=config-plugins",
  30          'description' => $lang->plugins_desc
  31      );
  32      $sub_tabs['update_plugins'] = array(
  33          'title' => $lang->plugin_updates,
  34          'link' => "index.php?module=config-plugins&amp;action=check",
  35          'description' => $lang->plugin_updates_desc
  36      );
  37  
  38      $sub_tabs['browse_plugins'] = array(
  39          'title' => $lang->browse_plugins,
  40          'link' => "index.php?module=config-plugins&amp;action=browse",
  41          'description' => $lang->browse_plugins_desc
  42      );
  43  
  44      $page->output_nav_tabs($sub_tabs, 'browse_plugins');
  45  
  46      // Process search requests
  47      $keywords = "";
  48      if($mybb->get_input('keywords'))
  49      {
  50          $keywords = "&keywords=".urlencode($mybb->input['keywords']);
  51      }
  52  
  53      if($mybb->get_input('page'))
  54      {
  55          $url_page = "&page=".$mybb->get_input('page', MyBB::INPUT_INT);
  56      }
  57      else
  58      {
  59          $mybb->input['page'] = 1;
  60          $url_page = "";
  61      }
  62  
  63      // Gets the major version code. i.e. 1410 -> 1400 or 121 -> 1200
  64      $major_version_code = round($mybb->version_code/100, 0)*100;
  65      // Convert to mods site version codes
  66      $search_version = ($major_version_code/100).'x';
  67  
  68      $contents = fetch_remote_file("https://community.mybb.com/xmlbrowse.php?api=2&type=plugins&version={$search_version}{$keywords}{$url_page}");
  69  
  70      if(!$contents)
  71      {
  72          $page->output_inline_error($lang->error_communication_problem);
  73          $page->output_footer();
  74          exit;
  75      }
  76  
  77      $table = new Table;
  78      $table->construct_header($lang->plugin);
  79      $table->construct_header($lang->latest_version, array("class" => "align_center", 'width' => 125));
  80      $table->construct_header($lang->controls, array("class" => "align_center", 'width' => 125));
  81  
  82      $parser = create_xml_parser($contents);
  83      $tree = $parser->get_tree();
  84  
  85      if(!is_array($tree) || !isset($tree['results']))
  86      {
  87          $page->output_inline_error($lang->error_communication_problem);
  88          $page->output_footer();
  89          exit;
  90      }
  91  
  92      if(!empty($tree['results']['result']))
  93      {
  94          if(array_key_exists("tag", $tree['results']['result']))
  95          {
  96              $only_plugin = $tree['results']['result'];
  97              unset($tree['results']['result']);
  98              $tree['results']['result'][0] = $only_plugin;
  99          }
 100  
 101          require_once  MYBB_ROOT . '/inc/class_parser.php';
 102          $post_parser = new postParser();
 103  
 104          foreach($tree['results']['result'] as $result)
 105          {
 106              $result['name']['value'] = htmlspecialchars_uni($result['name']['value']);
 107              $result['description']['value'] = htmlspecialchars_uni($result['description']['value']);
 108              $result['author']['url']['value'] = htmlspecialchars_uni($result['author']['url']['value']);
 109              $result['author']['name']['value'] = htmlspecialchars_uni($result['author']['name']['value']);
 110              $result['version']['value'] = htmlspecialchars_uni($result['version']['value']);
 111              $result['download_url']['value'] = htmlspecialchars_uni(html_entity_decode($result['download_url']['value']));
 112  
 113              $table->construct_cell("<strong>{$result['name']['value']}</strong><br /><small>{$result['description']['value']}</small><br /><i><small>{$lang->created_by} <a href=\"{$result['author']['url']['value']}\" target=\"_blank\" rel=\"noopener\">{$result['author']['name']['value']}</a></small></i>");
 114              $table->construct_cell($result['version']['value'], array("class" => "align_center"));
 115              $table->construct_cell("<strong><a href=\"https://community.mybb.com/{$result['download_url']['value']}\" target=\"_blank\" rel=\"noopener\">{$lang->download}</a></strong>", array("class" => "align_center"));
 116              $table->construct_row();
 117          }
 118      }
 119  
 120      $no_results = false;
 121      if($table->num_rows() == 0)
 122      {
 123          $table->construct_cell($lang->error_no_results_found, array("colspan" => 3));
 124          $table->construct_row();
 125          $no_results = true;
 126      }
 127  
 128      $search = new Form("index.php?module=config-plugins&amp;action=browse", 'post', 'search_form');
 129      echo "<div style=\"padding-bottom: 3px; margin-top: -9px; text-align: right;\">";
 130      if($mybb->get_input('keywords'))
 131      {
 132          $default_class = '';
 133          $value = htmlspecialchars_uni($mybb->input['keywords']);
 134      }
 135      else
 136      {
 137          $default_class = "search_default";
 138          $value = $lang->search_for_plugins;
 139      }
 140      echo $search->generate_text_box('keywords', $value, array('id' => 'search_keywords', 'class' => "{$default_class} field150 field_small"))."\n";
 141      echo "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />\n";
 142      echo "<script type=\"text/javascript\">
 143          var form = $(\"#search_form\");
 144          form.on('submit', function()
 145          {
 146              var search = $(\"#search_keywords\");
 147              if(search.val() == '' || search.val() == '{$lang->search_for_plugins}')
 148              {
 149                  search.trigger('focus');
 150                  return false;
 151              }
 152          });
 153  
 154          var search = $(\"#search_keywords\");
 155          search.on('focus', function()
 156          {
 157              var searched_focus = $(this);
 158              if(searched_focus.val() == '{$lang->search_for_plugins}')
 159              {
 160                  searched_focus.removeClass(\"search_default\");
 161                  searched_focus.val(\"\");
 162              }
 163          }).on('blur', function()
 164          {
 165              var searched_blur = $(this);
 166              if(searched_blur.val() == \"\")
 167              {
 168                  searched_blur.addClass('search_default');
 169                  searched_blur.val('{$lang->search_for_plugins}');
 170              }
 171          });
 172  
 173          // fix the styling used if we have a different default value
 174          if(search.val() != '{$lang->search_for_plugins}')
 175          {
 176              search.removeClass('search_default');
 177          }
 178          </script>\n";
 179      echo "</div>\n";
 180      echo $search->end();
 181  
 182      // Recommended plugins = Default; Otherwise search results & pagination
 183      if($mybb->request_method == "post")
 184      {
 185          $table->output("<span style=\"float: right;\"><small><a href=\"https://community.mybb.com/mods.php?action=browse&category=plugins\" target=\"_blank\" rel=\"noopener\">{$lang->browse_all_plugins}</a></small></span>".$lang->sprintf($lang->browse_results_for_mybb, $mybb->version));
 186      }
 187      else
 188      {
 189          $table->output("<span style=\"float: right;\"><small><a href=\"https://community.mybb.com/mods.php?action=browse&category=plugins\" target=\"_blank\" rel=\"noopener\">{$lang->browse_all_plugins}</a></small></span>".$lang->sprintf($lang->recommended_plugins_for_mybb, $mybb->version));
 190      }
 191  
 192      if(!$no_results)
 193      {
 194          echo "<br />".draw_admin_pagination($mybb->input['page'], 15, $tree['results']['attributes']['total'], "index.php?module=config-plugins&amp;action=browse{$keywords}&amp;page={page}");
 195      }
 196  
 197      $page->output_footer();
 198  }
 199  
 200  if($mybb->input['action'] == "check")
 201  {
 202      $plugins_list = get_plugins_list();
 203  
 204      $plugins->run_hooks("admin_config_plugins_check");
 205  
 206      $info = array();
 207  
 208      if($plugins_list)
 209      {
 210          $active_hooks = $plugins->hooks;
 211          foreach($plugins_list as $plugin_file)
 212          {
 213              require_once MYBB_ROOT."inc/plugins/".$plugin_file;
 214              $codename = str_replace(".php", "", $plugin_file);
 215              $infofunc = $codename."_info";
 216              if(!function_exists($infofunc))
 217              {
 218                  continue;
 219              }
 220              $plugininfo = $infofunc();
 221              $plugininfo['guid'] = isset($plugininfo['guid']) ? trim($plugininfo['guid']) : null;
 222              $plugininfo['codename'] = isset($plugininfo['codename']) ? trim($plugininfo['codename']) : null;
 223  
 224              if($plugininfo['codename'] != "")
 225              {
 226                  $info[]    = $plugininfo['codename'];
 227                  $names[$plugininfo['codename']] = array('name' => $plugininfo['name'], 'version' => $plugininfo['version']);
 228              }
 229              elseif($plugininfo['guid'] != "")
 230              {
 231                  $info[] =  $plugininfo['guid'];
 232                  $names[$plugininfo['guid']] = array('name' => $plugininfo['name'], 'version' => $plugininfo['version']);
 233              }
 234          }
 235          $plugins->hooks = $active_hooks;
 236      }
 237  
 238      if(empty($info))
 239      {
 240          flash_message($lang->error_vcheck_no_supported_plugins, 'error');
 241          admin_redirect("index.php?module=config-plugins");
 242      }
 243  
 244      $url = "https://community.mybb.com/version_check.php?";
 245      $url .= http_build_query(array("info" => $info))."&";
 246      $contents = fetch_remote_file($url);
 247  
 248      if(!$contents)
 249      {
 250          flash_message($lang->error_vcheck_communications_problem, 'error');
 251          admin_redirect("index.php?module=config-plugins");
 252      }
 253  
 254      $contents = trim($contents);
 255  
 256      $parser = create_xml_parser($contents);
 257      $tree = $parser->get_tree();
 258  
 259      if(!is_array($tree) || !isset($tree['plugins']))
 260      {
 261          flash_message($lang->error_communication_problem, 'error');
 262          admin_redirect("index.php?module=config-plugins");
 263      }
 264  
 265      if(array_key_exists('error', $tree['plugins']))
 266      {
 267          switch($tree['plugins'][0]['error'])
 268          {
 269              case "1":
 270                  $error_msg = $lang->error_no_input;
 271                  break;
 272              case "2":
 273                  $error_msg = $lang->error_no_pids;
 274                  break;
 275              default:
 276                  $error_msg = "";
 277          }
 278          flash_message($lang->error_communication_problem.$error_msg, 'error');
 279          admin_redirect("index.php?module=config-plugins");
 280      }
 281  
 282      $table = new Table;
 283      $table->construct_header($lang->plugin);
 284      $table->construct_header($lang->your_version, array("class" => "align_center", 'width' => 125));
 285      $table->construct_header($lang->latest_version, array("class" => "align_center", 'width' => 125));
 286      $table->construct_header($lang->controls, array("class" => "align_center", 'width' => 125));
 287  
 288      if(!is_array($tree['plugins']['plugin']))
 289      {
 290          flash_message($lang->success_plugins_up_to_date, 'success');
 291          admin_redirect("index.php?module=config-plugins");
 292      }
 293  
 294      if(array_key_exists("tag", $tree['plugins']['plugin']))
 295      {
 296          $only_plugin = $tree['plugins']['plugin'];
 297          unset($tree['plugins']['plugin']);
 298          $tree['plugins']['plugin'][0] = $only_plugin;
 299      }
 300  
 301      foreach($tree['plugins']['plugin'] as $plugin)
 302      {
 303          $compare_by = array_key_exists("codename", $plugin['attributes']) ? "codename" : "guid";
 304          $is_vulnerable = array_key_exists("vulnerable", $plugin) ? true : false;
 305  
 306          if(version_compare($names[$plugin['attributes'][$compare_by]]['version'], $plugin['version']['value'], "<"))
 307          {
 308              $plugin['download_url']['value'] = htmlspecialchars_uni($plugin['download_url']['value']);
 309              $plugin['version']['value'] = htmlspecialchars_uni($plugin['version']['value']);
 310  
 311              if(isset($plugin['vulnerable']['value']))
 312              {
 313                  $plugin['vulnerable']['value'] = htmlspecialchars_uni($plugin['vulnerable']['value']);
 314              }
 315  
 316              if($is_vulnerable)
 317              {
 318                  $table->construct_cell("<div class=\"error\" id=\"flash_message\">
 319                                          {$lang->error_vcheck_vulnerable} {$names[$plugin['attributes'][$compare_by]]['name']}
 320                                          </div>
 321                                          <p>    <b>{$lang->error_vcheck_vulnerable_notes}</b> <br /><br /> {$plugin['vulnerable']['value']}</p>");
 322              }
 323              else
 324              {
 325                  $table->construct_cell("<strong>{$names[$plugin['attributes'][$compare_by]]['name']}</strong>");
 326              }
 327              $table->construct_cell("{$names[$plugin['attributes'][$compare_by]]['version']}", array("class" => "align_center"));
 328              $table->construct_cell("<strong><span style=\"color: #C00\">{$plugin['version']['value']}</span></strong>", array("class" => "align_center"));
 329              if($is_vulnerable)
 330              {
 331                  $table->construct_cell("<a href=\"index.php?module=config-plugins\"><b>{$lang->deactivate}</b></a>", array("class" => "align_center", "width" => 150));
 332              }
 333              else
 334              {
 335                  $table->construct_cell("<strong><a href=\"https://community.mybb.com/{$plugin['download_url']['value']}\" target=\"_blank\" rel=\"noopener\">{$lang->download}</a></strong>", array("class" => "align_center"));
 336              }
 337              $table->construct_row();
 338          }
 339      }
 340  
 341      if($table->num_rows() == 0)
 342      {
 343          flash_message($lang->success_plugins_up_to_date, 'success');
 344          admin_redirect("index.php?module=config-plugins");
 345      }
 346  
 347      $page->add_breadcrumb_item($lang->plugin_updates);
 348  
 349      $page->output_header($lang->plugin_updates);
 350  
 351      $sub_tabs['plugins'] = array(
 352          'title' => $lang->plugins,
 353          'link' => "index.php?module=config-plugins",
 354      );
 355  
 356      $sub_tabs['update_plugins'] = array(
 357          'title' => $lang->plugin_updates,
 358          'link' => "index.php?module=config-plugins&amp;action=check",
 359          'description' => $lang->plugin_updates_desc
 360      );
 361  
 362      $sub_tabs['browse_plugins'] = array(
 363          'title' => $lang->browse_plugins,
 364          'link' => "index.php?module=config-plugins&amp;action=browse",
 365          'description' => $lang->browse_plugins_desc
 366      );
 367  
 368      $page->output_nav_tabs($sub_tabs, 'update_plugins');
 369  
 370      $table->output($lang->plugin_updates);
 371  
 372      $page->output_footer();
 373  }
 374  
 375  // Activates or deactivates a specific plugin
 376  if($mybb->input['action'] == "activate" || $mybb->input['action'] == "deactivate")
 377  {
 378      if(!verify_post_check($mybb->get_input('my_post_key')))
 379      {
 380          flash_message($lang->invalid_post_verify_key2, 'error');
 381          admin_redirect("index.php?module=config-plugins");
 382      }
 383  
 384      if($mybb->input['action'] == "activate")
 385      {
 386          $plugins->run_hooks("admin_config_plugins_activate");
 387      }
 388      else
 389      {
 390          $plugins->run_hooks("admin_config_plugins_deactivate");
 391      }
 392  
 393      $codename = $mybb->input['plugin'];
 394      $codename = str_replace(array(".", "/", "\\"), "", $codename);
 395      $file = basename($codename.".php");
 396  
 397      // Check if the file exists and throw an error if it doesn't
 398      if(!file_exists(MYBB_ROOT."inc/plugins/$file"))
 399      {
 400          flash_message($lang->error_invalid_plugin, 'error');
 401          admin_redirect("index.php?module=config-plugins");
 402      }
 403  
 404      $plugins_cache = $cache->read("plugins");
 405      $active_plugins = isset($plugins_cache['active']) ? $plugins_cache['active'] : array();
 406  
 407      require_once MYBB_ROOT."inc/plugins/$file";
 408  
 409      $installed_func = "{$codename}_is_installed";
 410      $installed = true;
 411      if(function_exists($installed_func) && $installed_func() != true)
 412      {
 413          $installed = false;
 414      }
 415  
 416      $install_uninstall = false;
 417  
 418      if($mybb->input['action'] == "activate")
 419      {
 420          $message = $lang->success_plugin_activated;
 421  
 422          // Plugin is compatible with this version?
 423          if($plugins->is_compatible($codename) == false)
 424          {
 425              flash_message($lang->sprintf($lang->plugin_incompatible, $mybb->version), 'error');
 426              admin_redirect("index.php?module=config-plugins");
 427          }
 428  
 429          // If not installed and there is a custom installation function
 430          if($installed == false && function_exists("{$codename}_install"))
 431          {
 432              call_user_func("{$codename}_install");
 433              $message = $lang->success_plugin_installed;
 434              $install_uninstall = true;
 435          }
 436  
 437          if(function_exists("{$codename}_activate"))
 438          {
 439              call_user_func("{$codename}_activate");
 440          }
 441  
 442          $active_plugins[$codename] = $codename;
 443          $executed[] = 'activate';
 444      }
 445      else if($mybb->input['action'] == "deactivate")
 446      {
 447          $message = $lang->success_plugin_deactivated;
 448  
 449          if(function_exists("{$codename}_deactivate"))
 450          {
 451              call_user_func("{$codename}_deactivate");
 452          }
 453  
 454          if($mybb->get_input('uninstall') == 1 && function_exists("{$codename}_uninstall"))
 455          {
 456              call_user_func("{$codename}_uninstall");
 457              $message = $lang->success_plugin_uninstalled;
 458              $install_uninstall = true;
 459          }
 460  
 461          unset($active_plugins[$codename]);
 462      }
 463  
 464      // Update plugin cache
 465      $plugins_cache['active'] = $active_plugins;
 466      $cache->update("plugins", $plugins_cache);
 467  
 468      // Log admin action
 469      log_admin_action($codename, $install_uninstall);
 470  
 471      if($mybb->input['action'] == "activate")
 472      {
 473          $plugins->run_hooks("admin_config_plugins_activate_commit");
 474      }
 475      else
 476      {
 477          $plugins->run_hooks("admin_config_plugins_deactivate_commit");
 478      }
 479  
 480      flash_message($message, 'success');
 481      admin_redirect("index.php?module=config-plugins");
 482  }
 483  
 484  if(!$mybb->input['action'])
 485  {
 486      $page->output_header($lang->plugins);
 487  
 488      $sub_tabs['plugins'] = array(
 489          'title' => $lang->plugins,
 490          'link' => "index.php?module=config-plugins",
 491          'description' => $lang->plugins_desc
 492      );
 493      $sub_tabs['update_plugins'] = array(
 494          'title' => $lang->plugin_updates,
 495          'link' => "index.php?module=config-plugins&amp;action=check",
 496          'description' => $lang->plugin_updates_desc
 497      );
 498  
 499      $sub_tabs['browse_plugins'] = array(
 500          'title' => $lang->browse_plugins,
 501          'link' => "index.php?module=config-plugins&amp;action=browse",
 502          'description' => $lang->browse_plugins_desc
 503      );
 504  
 505      $page->output_nav_tabs($sub_tabs, 'plugins');
 506  
 507      // Let's make things easier for our user - show them active
 508      // and inactive plugins in different lists
 509      $plugins_cache = $cache->read("plugins");
 510      $active_plugins = array();
 511      if(!empty($plugins_cache['active']))
 512      {
 513          $active_plugins = $plugins_cache['active'];
 514      }
 515  
 516      $plugins_list = get_plugins_list();
 517  
 518      $plugins->run_hooks("admin_config_plugins_plugin_list");
 519  
 520      if(!empty($plugins_list))
 521      {
 522          $a_plugins = $i_plugins = array();
 523  
 524          foreach($plugins_list as $plugin_file)
 525          {
 526              require_once MYBB_ROOT."inc/plugins/".$plugin_file;
 527              $codename = str_replace(".php", "", $plugin_file);
 528              $infofunc = $codename."_info";
 529  
 530              if(!function_exists($infofunc))
 531              {
 532                  continue;
 533              }
 534  
 535              $plugininfo = $infofunc();
 536              $plugininfo['codename'] = $codename;
 537  
 538              if(isset($active_plugins[$codename]))
 539              {
 540                  // This is an active plugin
 541                  $plugininfo['is_active'] = 1;
 542  
 543                  $a_plugins[] = $plugininfo;
 544              }
 545              else
 546              {
 547                  // Either installed and not active or completely inactive
 548                  $plugininfo['is_active'] = 0;
 549                  $i_plugins[] = $plugininfo;
 550              }
 551          }
 552  
 553          $table = new Table;
 554          $table->construct_header($lang->plugin);
 555          $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
 556  
 557          if(empty($a_plugins))
 558          {
 559              $table->construct_cell($lang->no_active_plugins, array('colspan' => 3));
 560              $table->construct_row();
 561          }
 562          else
 563          {
 564              build_plugin_list($a_plugins);
 565          }
 566  
 567          $table->output($lang->active_plugin);
 568  
 569          $table = new Table;
 570          $table->construct_header($lang->plugin);
 571          $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
 572  
 573          if(empty($i_plugins))
 574          {
 575              $table->construct_cell($lang->no_inactive_plugins, array('colspan' => 3));
 576              $table->construct_row();
 577          }
 578          else
 579          {
 580              build_plugin_list($i_plugins);
 581          }
 582  
 583          $table->output($lang->inactive_plugin);
 584      }
 585      else
 586      {
 587          // No plugins
 588          $table = new Table;
 589          $table->construct_header($lang->plugin);
 590          $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
 591  
 592          $table->construct_cell($lang->no_plugins, array('colspan' => 3));
 593          $table->construct_row();
 594  
 595          $table->output($lang->plugins);
 596      }
 597  
 598      $page->output_footer();
 599  }
 600  
 601  /**
 602   * @return array
 603   */
 604  function get_plugins_list()
 605  {
 606      // Get a list of the plugin files which exist in the plugins directory
 607      $dir = @opendir(MYBB_ROOT."inc/plugins/");
 608      if($dir)
 609      {
 610          while($file = readdir($dir))
 611          {
 612              $ext = get_extension($file);
 613              if($ext == "php")
 614              {
 615                  $plugins_list[] = $file;
 616              }
 617          }
 618          @sort($plugins_list);
 619      }
 620      @closedir($dir);
 621  
 622      return $plugins_list;
 623  }
 624  
 625  /**
 626   * @param array $plugin_list
 627   */
 628  function build_plugin_list($plugin_list)
 629  {
 630      global $lang, $mybb, $plugins, $table;
 631  
 632      foreach($plugin_list as $plugininfo)
 633      {
 634          if(!empty($plugininfo['website']))
 635          {
 636              $plugininfo['name'] = "<a href=\"".$plugininfo['website']."\">".$plugininfo['name']."</a>";
 637          }
 638  
 639          if(!empty($plugininfo['authorsite']))
 640          {
 641              $plugininfo['author'] = "<a href=\"".$plugininfo['authorsite']."\">".$plugininfo['author']."</a>";
 642          }
 643  
 644          if($plugins->is_compatible($plugininfo['codename']) == false)
 645          {
 646              $compatibility_warning = "<span style=\"color: red;\">".$lang->sprintf($lang->plugin_incompatible, $mybb->version)."</span>";
 647          }
 648          else
 649          {
 650              $compatibility_warning = "";
 651          }
 652  
 653          $installed_func = "{$plugininfo['codename']}_is_installed";
 654          $install_func = "{$plugininfo['codename']}_install";
 655          $uninstall_func = "{$plugininfo['codename']}_uninstall";
 656  
 657          $installed = true;
 658          $install_button = false;
 659          $uninstall_button = false;
 660  
 661          if(function_exists($installed_func) && $installed_func() != true)
 662          {
 663              $installed = false;
 664          }
 665  
 666          if(function_exists($install_func))
 667          {
 668              $install_button = true;
 669          }
 670  
 671          if(function_exists($uninstall_func))
 672          {
 673              $uninstall_button = true;
 674          }
 675  
 676          $table->construct_cell("<strong>{$plugininfo['name']}</strong> ({$plugininfo['version']})<br /><small>{$plugininfo['description']}</small><br /><i><small>{$lang->created_by} {$plugininfo['author']}</small></i>");
 677  
 678          // Plugin is not installed at all
 679          if($installed == false)
 680          {
 681              if($compatibility_warning)
 682              {
 683                  $table->construct_cell("{$compatibility_warning}", array("class" => "align_center", "colspan" => 2));
 684              }
 685              else
 686              {
 687                  $table->construct_cell("<a href=\"index.php?module=config-plugins&amp;action=activate&amp;plugin={$plugininfo['codename']}&amp;my_post_key={$mybb->post_code}\">{$lang->install_and_activate}</a>", array("class" => "align_center", "colspan" => 2));
 688              }
 689          }
 690          // Plugin is activated and installed
 691          else if($plugininfo['is_active'])
 692          {
 693              $table->construct_cell("<a href=\"index.php?module=config-plugins&amp;action=deactivate&amp;plugin={$plugininfo['codename']}&amp;my_post_key={$mybb->post_code}\">{$lang->deactivate}</a>", array("class" => "align_center", "width" => 150));
 694              if($uninstall_button)
 695              {
 696                  $table->construct_cell("<a href=\"index.php?module=config-plugins&amp;action=deactivate&amp;uninstall=1&amp;plugin={$plugininfo['codename']}&amp;my_post_key={$mybb->post_code}\">{$lang->uninstall}</a>", array("class" => "align_center", "width" => 150));
 697              }
 698              else
 699              {
 700                  $table->construct_cell("&nbsp;", array("class" => "align_center", "width" => 150));
 701              }
 702          }
 703          // Plugin is installed but not active
 704          else if($installed == true)
 705          {
 706              if($compatibility_warning && !$uninstall_button)
 707              {
 708                  $table->construct_cell("{$compatibility_warning}", array("class" => "align_center", "colspan" => 2));
 709              }
 710              else
 711              {
 712                  $table->construct_cell("<a href=\"index.php?module=config-plugins&amp;action=activate&amp;plugin={$plugininfo['codename']}&amp;my_post_key={$mybb->post_code}\">{$lang->activate}</a>", array("class" => "align_center", "width" => 150));
 713                  if($uninstall_button)
 714                  {
 715                      $table->construct_cell("<a href=\"index.php?module=config-plugins&amp;action=deactivate&amp;uninstall=1&amp;plugin={$plugininfo['codename']}&amp;my_post_key={$mybb->post_code}\">{$lang->uninstall}</a>", array("class" => "align_center", "width" => 150));
 716                  }
 717                  else
 718                  {
 719                      $table->construct_cell("&nbsp;", array("class" => "align_center", "width" => 150));
 720                  }
 721              }
 722          }
 723          $table->construct_row();
 724      }
 725  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref