<?php

require_once '../../../wp-config.php';
require_once '../../../wp-admin/admin.php';
include_once 'includes/wp-update-class.php';
include_once 'includes/wp-update-functions.php';
$wp_update = new WP_Update();
switch ($_GET['action']) {
    case 'checkPluginUpdate':
        echo $wp_update->getPluginUpdateText($_GET['file'], true, true, true);
        break;
    case 'themeSearch':
        $searchOptions = array();
        $searchOptions['searchOptions'] = explode(',', $_POST['searchOptions']);
        $searchOptions['order'] = $_POST['order'];
        $searchOptions['sortby'] = $_POST['sortby'];
        $searchOptions['andor'] = $_POST['andor'];
        $page = $_POST['page'];
        if (empty($page) || !is_numeric($page)) {
            $page = 1;
        }
        $searchResults = $wp_update->search('themes', $searchOptions, $page);
        if (!isset($searchResults['results']) || empty($searchResults['results'])) {
            die(__('no more results'));
        }
        foreach ($searchResults['results'] as $theme) {
            echo wpupdate_themeSearchHTML($theme);
        }
        break;
    case 'pluginSearch':
        $page = (int) $_POST['page'];
 if (current_user_can('edit_plugins')) {
     $forceupdate = '<a href="#" onclick="checkUpdate(\'' . $plugin_file . '\'); return false;" title="' . __('Check for Plugin Update') . '" class="edit">' . __('Check for Update') . '</a>';
 } else {
     $forceupdate = '';
 }
 $updateText = '';
 if (!get_option('update_notification_enable')) {
     $updateText = __('Not Checked');
 } else {
     //Check if the plugin is disabled:
     $updateStat = $wp_update->checkPluginUpdate($plugin_file, false, false);
     if (!get_option('update_check_inactive') && !in_array($plugin_file, $current_plugins) && !(isset($updateStat['Update']) || isset($updateStat['Errors']) && in_array('Not Found', $updateStat['Errors']))) {
         //Plugin is disabled, and set to not check inactive plugins
         $updateText = __('Not Checked');
     } else {
         $updateText = $wp_update->getPluginUpdateText($plugin_file);
         if (false !== $updateText) {
             $updateText = __($updateText);
         } else {
             $updateText = __('Please Wait');
             $updateText .= "<script type='text/javascript'>checkUpdate('{$plugin_file}');</script>";
         }
     }
 }
 echo "\r\n\t<tr {$style}>\r\n\t\t<td class='name'>{$plugin_data['Title']}</td>\r\n\t\t<td class='vers'>{$plugin_data['Version']}</td>\r\n\t\t<td class='vers' id='wpupdate-" . str_replace(array('/', '.'), '', $plugin_file) . "'>{$updateText}</td>\r\n\t\t<td class='desc'><p>{$plugin_data['Description']} <cite>" . sprintf(__('By %s'), $plugin_data['Author']) . ".</cite></p></td>\r\n\t\t<td class='togl'>{$toggle}</td>";
 if (current_user_can('edit_plugins')) {
     echo "\n\r\n\t\t\t";
     if ('' != $edit) {
         echo "<td>{$edit}</td>";
     }
     echo "<td>{$forceupdate}</td>";