[ Index ]

PHP Cross Reference of MyBB 1.8.28

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'] = trim($plugininfo['codename']);
 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['vulnerable']['value'] = htmlspecialchars_uni($plugin['vulnerable']['value']);
 310              $plugin['version']['value'] = htmlspecialchars_uni($plugin['version']['value']);
 311  
 312              if($is_vulnerable)
 313              {
 314                  $table->construct_cell("<div class=\"error\" id=\"flash_message\">
 315                                          {$lang->error_vcheck_vulnerable} {$names[$plugin['attributes'][$compare_by]]['name']}
 316                                          </div>
 317                                          <p>    <b>{$lang->error_vcheck_vulnerable_notes}</b> <br /><br /> {$plugin['vulnerable']['value']}</p>");
 318              }
 319              else
 320              {
 321                  $table->construct_cell("<strong>{$names[$plugin['attributes'][$compare_by]]['name']}</strong>");
 322              }
 323              $table->construct_cell("{$names[$plugin['attributes'][$compare_by]]['version']}", array("class" => "align_center"));
 324              $table->construct_cell("<strong><span style=\"color: #C00\">{$plugin['version']['value']}</span></strong>", array("class" => "align_center"));
 325              if($is_vulnerable)
 326              {
 327                  $table->construct_cell("<a href=\"index.php?module=config-plugins\"><b>{$lang->deactivate}</b></a>", array("class" => "align_center", "width" => 150));
 328              }
 329              else
 330              {
 331                  $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"));
 332              }
 333              $table->construct_row();
 334          }
 335      }
 336  
 337      if($table->num_rows() == 0)
 338      {
 339          flash_message($lang->success_plugins_up_to_date, 'success');
 340          admin_redirect("index.php?module=config-plugins");
 341      }
 342  
 343      $page->add_breadcrumb_item($lang->plugin_updates);
 344  
 345      $page->output_header($lang->plugin_updates);
 346  
 347      $sub_tabs['plugins'] = array(
 348          'title' => $lang->plugins,
 349          'link' => "index.php?module=config-plugins",
 350      );
 351  
 352      $sub_tabs['update_plugins'] = array(
 353          'title' => $lang->plugin_updates,
 354          'link' => "index.php?module=config-plugins&amp;action=check",
 355          'description' => $lang->plugin_updates_desc
 356      );
 357  
 358      $sub_tabs['browse_plugins'] = array(
 359          'title' => $lang->browse_plugins,
 360          'link' => "index.php?module=config-plugins&amp;action=browse",
 361          'description' => $lang->browse_plugins_desc
 362      );
 363  
 364      $page->output_nav_tabs($sub_tabs, 'update_plugins');
 365  
 366      $table->output($lang->plugin_updates);
 367  
 368      $page->output_footer();
 369  }
 370  
 371  // Activates or deactivates a specific plugin
 372  if($mybb->input['action'] == "activate" || $mybb->input['action'] == "deactivate")
 373  {
 374      if(!verify_post_check($mybb->get_input('my_post_key')))
 375      {
 376          flash_message($lang->invalid_post_verify_key2, 'error');
 377          admin_redirect("index.php?module=config-plugins");
 378      }
 379  
 380      if($mybb->input['action'] == "activate")
 381      {
 382          $plugins->run_hooks("admin_config_plugins_activate");
 383      }
 384      else
 385      {
 386          $plugins->run_hooks("admin_config_plugins_deactivate");
 387      }
 388  
 389      $codename = $mybb->input['plugin'];
 390      $codename = str_replace(array(".", "/", "\\"), "", $codename);
 391      $file = basename($codename.".php");
 392  
 393      // Check if the file exists and throw an error if it doesn't
 394      if(!file_exists(MYBB_ROOT."inc/plugins/$file"))
 395      {
 396          flash_message($lang->error_invalid_plugin, 'error');
 397          admin_redirect("index.php?module=config-plugins");
 398      }
 399  
 400      $plugins_cache = $cache->read("plugins");
 401      $active_plugins = isset($plugins_cache['active']) ? $plugins_cache['active'] : array();
 402  
 403      require_once MYBB_ROOT."inc/plugins/$file";
 404  
 405      $installed_func = "{$codename}_is_installed";
 406      $installed = true;
 407      if(function_exists($installed_func) && $installed_func() != true)
 408      {
 409          $installed = false;
 410      }
 411  
 412      $install_uninstall = false;
 413  
 414      if($mybb->input['action'] == "activate")
 415      {
 416          $message = $lang->success_plugin_activated;
 417  
 418          // Plugin is compatible with this version?
 419          if($plugins->is_compatible($codename) == false)
 420          {
 421              flash_message($lang->sprintf($lang->plugin_incompatible, $mybb->version), 'error');
 422              admin_redirect("index.php?module=config-plugins");
 423          }
 424  
 425          // If not installed and there is a custom installation function
 426          if($installed == false && function_exists("{$codename}_install"))
 427          {
 428              call_user_func("{$codename}_install");
 429              $message = $lang->success_plugin_installed;
 430              $install_uninstall = true;
 431          }
 432  
 433          if(function_exists("{$codename}_activate"))
 434          {
 435              call_user_func("{$codename}_activate");
 436          }
 437  
 438          $active_plugins[$codename] = $codename;
 439          $executed[] = 'activate';
 440      }
 441      else if($mybb->input['action'] == "deactivate")
 442      {
 443          $message = $lang->success_plugin_deactivated;
 444  
 445          if(function_exists("{$codename}_deactivate"))
 446          {
 447              call_user_func("{$codename}_deactivate");
 448          }
 449  
 450          if($mybb->get_input('uninstall') == 1 && function_exists("{$codename}_uninstall"))
 451          {
 452              call_user_func("{$codename}_uninstall");
 453              $message = $lang->success_plugin_uninstalled;
 454              $install_uninstall = true;
 455          }
 456  
 457          unset($active_plugins[$codename]);
 458      }
 459  
 460      // Update plugin cache
 461      $plugins_cache['active'] = $active_plugins;
 462      $cache->update("plugins", $plugins_cache);
 463  
 464      // Log admin action
 465      log_admin_action($codename, $install_uninstall);
 466  
 467      if($mybb->input['action'] == "activate")
 468      {
 469          $plugins->run_hooks("admin_config_plugins_activate_commit");
 470      }
 471      else
 472      {
 473          $plugins->run_hooks("admin_config_plugins_deactivate_commit");
 474      }
 475  
 476      flash_message($message, 'success');
 477      admin_redirect("index.php?module=config-plugins");
 478  }
 479  
 480  if(!$mybb->input['action'])
 481  {
 482      $page->output_header($lang->plugins);
 483  
 484      $sub_tabs['plugins'] = array(
 485          'title' => $lang->plugins,
 486          'link' => "index.php?module=config-plugins",
 487          'description' => $lang->plugins_desc
 488      );
 489      $sub_tabs['update_plugins'] = array(
 490          'title' => $lang->plugin_updates,
 491          'link' => "index.php?module=config-plugins&amp;action=check",
 492          'description' => $lang->plugin_updates_desc
 493      );
 494  
 495      $sub_tabs['browse_plugins'] = array(
 496          'title' => $lang->browse_plugins,
 497          'link' => "index.php?module=config-plugins&amp;action=browse",
 498          'description' => $lang->browse_plugins_desc
 499      );
 500  
 501      $page->output_nav_tabs($sub_tabs, 'plugins');
 502  
 503      // Let's make things easier for our user - show them active
 504      // and inactive plugins in different lists
 505      $plugins_cache = $cache->read("plugins");
 506      $active_plugins = array();
 507      if(!empty($plugins_cache['active']))
 508      {
 509          $active_plugins = $plugins_cache['active'];
 510      }
 511  
 512      $plugins_list = get_plugins_list();
 513  
 514      $plugins->run_hooks("admin_config_plugins_plugin_list");
 515  
 516      if(!empty($plugins_list))
 517      {
 518          $a_plugins = $i_plugins = array();
 519  
 520          foreach($plugins_list as $plugin_file)
 521          {
 522              require_once MYBB_ROOT."inc/plugins/".$plugin_file;
 523              $codename = str_replace(".php", "", $plugin_file);
 524              $infofunc = $codename."_info";
 525  
 526              if(!function_exists($infofunc))
 527              {
 528                  continue;
 529              }
 530  
 531              $plugininfo = $infofunc();
 532              $plugininfo['codename'] = $codename;
 533  
 534              if(isset($active_plugins[$codename]))
 535              {
 536                  // This is an active plugin
 537                  $plugininfo['is_active'] = 1;
 538  
 539                  $a_plugins[] = $plugininfo;
 540              }
 541              else
 542              {
 543                  // Either installed and not active or completely inactive
 544                  $plugininfo['is_active'] = 0;
 545                  $i_plugins[] = $plugininfo;
 546              }
 547          }
 548  
 549          $table = new Table;
 550          $table->construct_header($lang->plugin);
 551          $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
 552  
 553          if(empty($a_plugins))
 554          {
 555              $table->construct_cell($lang->no_active_plugins, array('colspan' => 3));
 556              $table->construct_row();
 557          }
 558          else
 559          {
 560              build_plugin_list($a_plugins);
 561          }
 562  
 563          $table->output($lang->active_plugin);
 564  
 565          $table = new Table;
 566          $table->construct_header($lang->plugin);
 567          $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
 568  
 569          if(empty($i_plugins))
 570          {
 571              $table->construct_cell($lang->no_inactive_plugins, array('colspan' => 3));
 572              $table->construct_row();
 573          }
 574          else
 575          {
 576              build_plugin_list($i_plugins);
 577          }
 578  
 579          $table->output($lang->inactive_plugin);
 580      }
 581      else
 582      {
 583          // No plugins
 584          $table = new Table;
 585          $table->construct_header($lang->plugin);
 586          $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
 587  
 588          $table->construct_cell($lang->no_plugins, array('colspan' => 3));
 589          $table->construct_row();
 590  
 591          $table->output($lang->plugins);
 592      }
 593  
 594      $page->output_footer();
 595  }
 596  
 597  /**
 598   * @return array
 599   */
 600  function get_plugins_list()
 601  {
 602      // Get a list of the plugin files which exist in the plugins directory
 603      $dir = @opendir(MYBB_ROOT."inc/plugins/");
 604      if($dir)
 605      {
 606          while($file = readdir($dir))
 607          {
 608              $ext = get_extension($file);
 609              if($ext == "php")
 610              {
 611                  $plugins_list[] = $file;
 612              }
 613          }
 614          @sort($plugins_list);
 615      }
 616      @closedir($dir);
 617  
 618      return $plugins_list;
 619  }
 620  
 621  /**
 622   * @param array $plugin_list
 623   */
 624  function build_plugin_list($plugin_list)
 625  {
 626      global $lang, $mybb, $plugins, $table;
 627  
 628      foreach($plugin_list as $plugininfo)
 629      {
 630          if(!empty($plugininfo['website']))
 631          {
 632              $plugininfo['name'] = "<a href=\"".$plugininfo['website']."\">".$plugininfo['name']."</a>";
 633          }
 634  
 635          if(!empty($plugininfo['authorsite']))
 636          {
 637              $plugininfo['author'] = "<a href=\"".$plugininfo['authorsite']."\">".$plugininfo['author']."</a>";
 638          }
 639  
 640          if($plugins->is_compatible($plugininfo['codename']) == false)
 641          {
 642              $compatibility_warning = "<span style=\"color: red;\">".$lang->sprintf($lang->plugin_incompatible, $mybb->version)."</span>";
 643          }
 644          else
 645          {
 646              $compatibility_warning = "";
 647          }
 648  
 649          $installed_func = "{$plugininfo['codename']}_is_installed";
 650          $install_func = "{$plugininfo['codename']}_install";
 651          $uninstall_func = "{$plugininfo['codename']}_uninstall";
 652  
 653          $installed = true;
 654          $install_button = false;
 655          $uninstall_button = false;
 656  
 657          if(function_exists($installed_func) && $installed_func() != true)
 658          {
 659              $installed = false;
 660          }
 661  
 662          if(function_exists($install_func))
 663          {
 664              $install_button = true;
 665          }
 666  
 667          if(function_exists($uninstall_func))
 668          {
 669              $uninstall_button = true;
 670          }
 671  
 672          $table->construct_cell("<strong>{$plugininfo['name']}</strong> ({$plugininfo['version']})<br /><small>{$plugininfo['description']}</small><br /><i><small>{$lang->created_by} {$plugininfo['author']}</small></i>");
 673  
 674          // Plugin is not installed at all
 675          if($installed == false)
 676          {
 677              if($compatibility_warning)
 678              {
 679                  $table->construct_cell("{$compatibility_warning}", array("class" => "align_center", "colspan" => 2));
 680              }
 681              else
 682              {
 683                  $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));
 684              }
 685          }
 686          // Plugin is activated and installed
 687          else if($plugininfo['is_active'])
 688          {
 689              $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));
 690              if($uninstall_button)
 691              {
 692                  $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));
 693              }
 694              else
 695              {
 696                  $table->construct_cell("&nbsp;", array("class" => "align_center", "width" => 150));
 697              }
 698          }
 699          // Plugin is installed but not active
 700          else if($installed == true)
 701          {
 702              if($compatibility_warning && !$uninstall_button)
 703              {
 704                  $table->construct_cell("{$compatibility_warning}", array("class" => "align_center", "colspan" => 2));
 705              }
 706              else
 707              {
 708                  $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));
 709                  if($uninstall_button)
 710                  {
 711                      $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));
 712                  }
 713                  else
 714                  {
 715                      $table->construct_cell("&nbsp;", array("class" => "align_center", "width" => 150));
 716                  }
 717              }
 718          }
 719          $table->construct_row();
 720      }
 721  }


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