Example #1
0
		$msg->addError('CURL_NOT_INSTALLED');
		header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
		exit; 
	}
	$app_url = urldecode(trim($_POST['app_url']));
	//grep the XML file out from any given URL
	preg_match('/url\=((http[s]?\:\/\/)?(.*)\.xml)/', $app_url, $matches);
	if ($matches[1]!=''){
		$app_url = $matches[1];
	}	
	//validate app_url to make sure it always has http:// on it 
	if (preg_match('/^http[s]?\:\/\//', $app_url)==0){
		$app_url = 'http://'.$app_url;
	}

	$gadget = $app->parseModulePrefs($app_url);
	$gadget = $gadget[0];

	if (empty($gadget->errors)){
		//add applicatoin to database
		$app->addApplication($gadget);
		$msg->addFeedback('GADGET_ADDED_SUCCESSFULLY');
		header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
		exit;
	} else {
		$msg->addError(array('GADGET_ADDED_FAILURE', implode(', ', $gadget->errors)));
		header('Location: '. url_rewrite(AT_SOCIAL_BASENAME.'applications.php', AT_PRETTY_URL_IS_HEADER));
		exit; 
	}
}