+function admin_page_remoteupdate_post(&$a) {
+ // this function should be called via ajax post
+ if(!is_site_admin()) {
+ return login(false);
+ }
+
+
+ if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
+ $remotefile = $_POST['remotefile'];
+ $ftpdata = (x($_POST['ftphost'])?$_POST:false);
+ doUpdate($remotefile, $ftpdata);
+ } else {
+ echo "No remote file to download. Abort!";
+ }
+
+ killme();
+}
+
+function admin_page_remoteupdate(&$a) {
+ if(!is_site_admin()) {
+ return login(false);
+ }
+
+ $canwrite = canWeWrite();
+ $canftp = function_exists('ftp_connect');
+
+ $needupdate = true;
+ $u = checkUpdate();
+ if (!is_array($u)){
+ $needupdate = false;
+ $u = array('','','');
+ }
+
+ $tpl = get_markup_template("admin_remoteupdate.tpl");
+ return replace_macros($tpl, array(
+ '$baseurl' => $a->get_baseurl(),
+ '$submit' => t("Update now"),
+ '$close' => t("Close"),
+ '$localversion' => FRIENDIKA_VERSION,
+ '$remoteversion' => $u[1],
+ '$needupdate' => $needupdate,
+ '$canwrite' => $canwrite,
+ '$canftp' => $canftp,
+ '$ftphost' => array('ftphost', t("FTP Host"), '',''),
+ '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
+ '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
+ '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
+ '$remotefile'=>array('remotefile','', $u['2'],'')
+ ));
+
+}