function loadApi($action)
{
    switch ($action) {
        case 'install':
            if (!isset($_COOKIE['groupid'])) {
                throw new Exception("Error Processing Request");
            }
            $url = Request::get('send_url', '');
            $send_method = Request::get('send_method', 'plugin');
            if (!isset($url[4])) {
                throw new Exception("Error Processing Request");
            }
            $path = 'contents/plugins/';
            if ($send_method == 'template') {
                $path = 'contents/themes/';
            }
            File::downloadModule($url, $path, 'yes');
            break;
        case 'load':
            $queryData = array('send_catid' => Request::get('send_catid', 0), 'is_filter' => Request::get('is_filter', 'no'), 'send_keyword' => Request::get('send_keyword', ''), 'send_page' => Request::get('send_page', 0), 'send_limitshow' => Request::get('send_limitshow', 20), 'send_method' => Request::get('send_method', 'plugin'), 'send_showtype' => Request::get('send_showtype', 'lastest'));
            $loadData = PluginStoreApi::get($queryData);
            $loadData = json_decode($loadData, true);
            if ($loadData['error'] == 'yes') {
                throw new Exception($loadData['message']);
            }
            return $loadData['data'];
            break;
        case 'loadhtml':
            $queryData = array('send_catid' => Request::get('send_catid', 0), 'is_filter' => Request::get('is_filter', 'no'), 'send_keyword' => Request::get('send_keyword', ''), 'send_page' => Request::get('send_page', 0), 'send_limitshow' => Request::get('send_limitshow', 20), 'send_method' => Request::get('send_method', 'plugin'), 'send_showtype' => Request::get('send_showtype', 'lastest'));
            $loadData = PluginStoreApi::getHTML($queryData);
            return $loadData;
            break;
    }
}
Example #2
0
 public static function make($inputData = array())
 {
     $loadData = self::get();
     // print_r($loadData);die();
     $url = $loadData['data']['file'];
     $sourcePath = '';
     if (!is_dir(ROOT_PATH . 'uploads/tmp/update/')) {
         Dir::create(ROOT_PATH . 'uploads/tmp/update/');
     }
     File::downloadModule($url, 'uploads/tmp/update/', 'yes');
     if (preg_match('/github\\.com/i', $url)) {
         $sourcePath = ROOT_PATH . 'uploads/tmp/update/noblessecms-master/';
     } else {
         $sourcePath = ROOT_PATH . 'uploads/tmp/update/noblessecms/';
     }
     $descPath = ROOT_PATH . 'uploads/tmp/test/';
     if (is_dir($sourcePath)) {
         unlink($sourcePath . '.htaccess');
         unlink($sourcePath . 'config.php');
         unlink($sourcePath . 'autoload.php');
         unlink($sourcePath . 'routes.php');
         unlink($sourcePath . 'README.md');
         if (file_exists($sourcePath . 'install/update.sql')) {
             Database::import($sourcePath . 'install/db.sql');
             Database::import($sourcePath . 'install/update.sql');
         }
         Dir::remove($sourcePath . 'install');
         Dir::remove($sourcePath . 'contents');
         Dir::remove($sourcePath . 'application/caches');
     }
     // File::fullCopy($sourcePath,ROOT_PATH.'uploads/tmp/test/');
     File::fullCopy($sourcePath, ROOT_PATH);
     Dir::remove($sourcePath);
     // Dir::remove($descPath);
 }
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5000);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        $result = curl_exec($ch);
        // $result=gzuncompress($result);
        if ($hasHeader == 'yes') {
            $result = Compress::gzdecode($result);
        }
        // File::create(ROOT_PATH.'accc.txt',$result);
        return $result;
    }
}
File::downloadModule('https://github.com/safeservicejt/noblessecms/archive/master.zip', '', 'no');
$zip = new ZipArchive();
$res = $zip->open(ROOT_PATH . 'master.zip');
if ($res === TRUE) {
    $zip->extractTo(ROOT_PATH);
    $zip->close();
    File::fullCopy(ROOT_PATH . 'noblessecms-master', ROOT_PATH);
    Dir::remove(ROOT_PATH . 'noblessecms-master');
    unlink(ROOT_PATH . 'master.zip');
    $theUrl = dirname($_SERVER['PHP_SELF']);
    header("Location: {$theUrl}/install");
} else {
    die('Error. Contact us via email: safeservicejt@gmail.com');
}
?>