diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 71dff2af5..92d4444ea 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -17,101 +17,6 @@ if (!getperms("Z")) exit; } -// Only tested Locally so far. -if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax -{ - $string = base64_decode($_GET['src']); - parse_str($string,$p); - $remotefile = $p['plugin_url']; - - $localfile = md5($remotefile.time()).".zip"; - $status = "Downloading..."; - - $fl = e107::getFile(); - $fl->setAuthKey($e107SiteUsername,$e107SiteUserpass); - $fl->download($remotefile,'plugin'); - - exit; - - /* - - - - - - if(!file_exists(e_TEMP.$localfile)) - { - echo 'There was a problem retrieving the file'; - exit; - } - else - { - $contents = file_get_contents(e_TEMP.$localfile); - if($contents == 'LOGIN') - { - echo "
Please login to your e107.org account and try again
"; - exit; - } - } - - echo "Disabed"; - exit; - -// chmod(e_PLUGIN,0777); - chmod(e_TEMP.$localfile,0755); - - require_once(e_HANDLER."pclzip.lib.php"); - $archive = new PclZip(e_TEMP.$localfile); - $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0755)); -// chmod(e_PLUGIN,0755); - $dir = basename($unarc[0]['filename']); -// chmod(e_UPLOAD.$localfile,0666); - - - */ - /* Cannot use this yet until 'folder' is included in feed. - if($dir != $p['plugin_folder']) - { - - echo "
There is a problem with the data submitted by the author of the plugin."; - echo "dir=".$dir; - echo "
pfolder=".$p['plugin_folder']; - exit; - } - */ - /* - if($unarc[0]['folder'] ==1 && is_dir($unarc[0]['filename'])) - { - $status = "Unzipping..."; - $dir = basename($unarc[0]['filename']); - $plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir)); - - e107::getSingleton('e107plugin')->update_plugins_table('update'); - e107::getDb()->gen("SELECT plugin_id FROM #plugin WHERE plugin_path = '".$plugPath."' LIMIT 1"); - $row = e107::getDb()->db_Fetch(MYSQL_ASSOC); - $status = e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']); - //unlink(e_UPLOAD.$localfile); - - } - else - { - // print_a($fileList); - $status = "Error:
Download Manually"; - //echo $archive->errorInfo(true); - // $status = "There was a problem"; - //unlink(e_UPLOAD.$localfile); - } - - echo $status; -// @unlink(e_TEMP.$localfile); - -// echo "file=".$file; - exit; - - */ - -} - e107::coreLan('plugin', true); $e_sub_cat = 'plug_manage'; @@ -123,7 +28,38 @@ global $user_pref; require_once(e_HANDLER.'plugin_class.php'); require_once(e_HANDLER.'file_class.php'); +$plugin = new e107plugin; +$pman = new pluginManager; +define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle); +if(e_AJAX_REQUEST && isset($_GET['action'])) // Ajax +{ + if($_GET['action'] == 'download') + { + $string = base64_decode($_GET['src']); + parse_str($string, $p); + + $mp = $pman->getMarketplace(); + $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); + // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) + echo "
Connecting...\n"; flush(); // FIXME change the modal default label, default is Loading...
+		// download and flush
+		$mp->download($p['plugin_id'], $p['plugin_mode'], 'plugin');
+		
+		echo "
"; flush(); + } + /*$string = base64_decode($_GET['src']); + parse_str($string,$p); + $remotefile = $p['plugin_url']; + + $localfile = md5($remotefile.time()).".zip"; + $status = "Downloading..."; + + $fl = e107::getFile(); + $fl->setAuthKey($e107SiteUsername,$e107SiteUserpass); + $fl->download($remotefile,'plugin');*/ + exit; +} if(isset($_POST['uninstall_cancel'])) { @@ -222,11 +158,6 @@ class pluginmanager_form extends e_form } - - -$plugin = new e107plugin; -$pman = new pluginManager; -define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle); require_once("auth.php"); $pman->pluginObserver(); $mes = e107::getMessage(); @@ -310,18 +241,6 @@ class pluginManager{ $keys = array_keys($this -> titlearray); $this->pagetitle = (in_array($this->action,$keys)) ? $this -> titlearray[$this->action] : $this -> titlearray['installed']; - - // temporary - create e_marketpalce instnace - // it'll be moved to e107::getMarketplace() soon - if($this->action == 'online') - { - // XXX force xmlrpc temporary - require_once(e_HANDLER.'e_marketplace.php'); - $this->mp = new e_marketplace('xmlrpc'); - } - - - /* if(isset($_POST['uninstall-selected'])) { foreach($_POST['checkboxes'] as $val) @@ -338,7 +257,19 @@ class pluginManager{ } - + /** + * Temporary, e107::getMarketplace() coming soon + * @return e_marketplace + */ + public function getMarketplace() + { + if(null === $this->mp) + { + require_once(e_HANDLER.'e_marketplace.php'); + $this->mp = new e_marketplace('xmlrpc'); // XXX temporary force xmplrpc + } + return $this->mp; + } @@ -479,11 +410,12 @@ class pluginManager{ $from = isset($_GET['frm']) ? intval($_GET['frm']) : 0; $srch = preg_replace('/[^\w]/','', vartrue($_GET['srch'])); + $mp = $this->getMarketplace(); // auth - $this->mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); + $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); // do the request, retrieve and parse data - $xdata = $this->mp->call('getList', array( + $xdata = $mp->call('getList', array( 'type' => 'plugin', 'params' => array('limit' => 10, 'search' => $srch, 'from' => $from) )); @@ -511,9 +443,11 @@ class pluginManager{ $price = ($row['price'] > 0) ? "".$row['price']." credits" : "Free"; $data[] = array( - 'plugin_id' => $c, + 'plugin_id' => $row['params']['id'], + 'plugin_mode' => $row['params']['mode'], 'plugin_icon' => vartrue($row['icon'],e_IMAGE."admin_images/plugins_32.png"), - 'plugin_name' => stripslashes($row['name']).$featured, + 'plugin_name' => stripslashes($row['name']), + 'plugin_featured' => $featured, 'plugin_folder' => $row['folder'], 'plugin_date' => vartrue($row['date']), 'plugin_category' => vartrue($row['category'], 'n/a'), @@ -523,7 +457,7 @@ class pluginManager{ 'plugin_compatible' => $badge, 'plugin_website' => vartrue($row['authorUrl']), - 'plugin_url' => $row['url'], + //'plugin_url' => $row['url'], 'plugin_notes' => '', 'plugin_price' => $price ); @@ -568,8 +502,11 @@ class pluginManager{ { continue; } + + $_value = $val[$v]; + if($v == 'plugin_name') $_value .= $val['plugin_featured']; // echo '
v='.$v; - $text .= "".$frm->renderValue($v, $val[$v], $this->fields[$v], $key)."\n"; + $text .= "".$frm->renderValue($v, $_value, $this->fields[$v], $key)."\n"; } $text .= "".$this->options($val).""; $text .= ""; @@ -613,10 +550,13 @@ class pluginManager{ $d = http_build_query($data,false,'&'); - $url = e_SELF."?src=".base64_encode($d); + //$url = e_SELF."?src=".base64_encode($d); + $url = e_SELF.'?action=download&src='.base64_encode($d);//$url.'&action=download'; $id = 'plug_'.$data['plugin_id']; + // + $dicon = " "; return "
- + {$dicon}
"; } diff --git a/e107_admin/theme.php b/e107_admin/theme.php index 348155a51..b43e28f63 100644 --- a/e107_admin/theme.php +++ b/e107_admin/theme.php @@ -75,11 +75,11 @@ if(e_AJAX_REQUEST) { case 'download': $string = base64_decode($_GET['src']); - parse_str($string,$p); + parse_str($string, $p); $mp = $themec->getMarketplace(); $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) - echo "
Connecting...
"; flush(); // FIXME change the modal default label, default is Loading... + echo "
Connecting...\n"; flush(); // FIXME change the modal default label, default is Loading...
 			// download and flush
 			$mp->download($p['id'], $p['mode'], $p['type']);
 			echo "
"; flush(); diff --git a/e107_handlers/e_marketplace.php b/e107_handlers/e_marketplace.php index 54fe2f2e2..56552b36d 100644 --- a/e107_handlers/e_marketplace.php +++ b/e107_handlers/e_marketplace.php @@ -223,7 +223,7 @@ abstract class e_marketplace_adapter_abstract if($dir && is_dir($destpath.$dir)) { - echo "(".ucfirst($type).") Already Installed".$destpath.$dir; flush(); + echo "(".ucfirst($type).") Already Downloaded - ".basename($destpath).'/'.$dir; flush(); @unlink(e_TEMP.$localfile); return; } diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index cffc8c889..1a59f1a54 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -555,7 +555,7 @@ class themeHandler 'date' => $r['date'], 'version' => $r['version'], 'thumbnail' => $r['thumbnail'], - 'url' => $r['url'], + //'url' => $r['url'], 'author' => $r['author'], 'website' => $r['authorUrl'], 'compatibility' => $r['compatibility'], @@ -1034,7 +1034,7 @@ class themeHandler $id = $frm->name2id($theme['name']); $LAN_DOWNLOAD = ($theme['price'] > 0) ? "Buy/Download" : "Download"; - $downloadUrl = e_SELF.'?'.(e_QUERY ? e_QUERY.'&' : '').'&action=download&src='.base64_encode($d);//$url.'&action=download'; + $downloadUrl = e_SELF.'?action=download&src='.base64_encode($d);//$url.'&action=download'; $infoUrl = $url.'&action=info'; //$main_icon = " ";