Esempio n. 1
0
 /**
  * @todo we do not want to reparse unless the file changes ...
  */
 function run_error_checks()
 {
     $xml = $this->get_value('wordpress_xml');
     $kill_all = $this->get_value('kill_all');
     $site_id = $this->get_value('reason_site');
     $blog_page_name = $this->get_value('blog_page_name');
     // this is too heavy handed we should allow space characters
     if ($blog_page_name && !check_against_regexp($blog_page_name, array('safechars'))) {
         $this->set_error('blog_page_name', 'You can only use basic alphanumeric characters for the blog page name');
     }
     if (empty($site_id) || !is_numeric($site_id)) {
         $this->set_error('reason_site', 'You have to choose a valid site in order to continue.');
     }
     if (empty($xml) && empty($kill_all)) {
         $this->set_error('wordpress_xml', 'You need to upload a wordpress extended RSS file to continue.');
     } elseif (!empty($xml)) {
         // lets parse the xml file to create our job set ... should do only if the job set does not exist probably ...
         $file = $this->get_value('wordpress_xml');
         $xml = file_get_contents($file['path']);
         $this->xml_parser = new XMLParser($xml);
         $this->xml_parser->Parse();
         if (empty($this->xml_parser->document)) {
             $this->set_error('wordpress_xml', 'The file you uploaded could not be parsed and may not be an xml file.');
         }
         $file_element = $this->get_value('wordpress_xml');
         $this->set_value('xml_file_name', 'work on this to make it accurate!');
     }
 }
Esempio n. 2
0
 /**
  * initialize request
  *
  * @param int $site_id id of the site from where the request originates
  * @param int $al_relationship_id the id of the allowable relationship
  * @param int $left_entity_id the id of the entity on the a site of the relationship
  * @param int $entity_id the id of the entity that is moving up or down
  * @param int $row_id the row number of the entity that is moving up or down
  * @param string $direction which direction the entity is moving
  * @param string $user_netID the netid of the user initiating the request
  * @param string $background set to 'yes' if the request comes via xmlhttp, 'no' if not
  */
 function init($site_id, $al_relationship_id, $left_entity_id, $entity_id, $row_id, $direction, $user_netID, $background)
 {
     $this->user_netID = check_against_regexp($user_netID, array('alphanumeric'));
     $this->direction = check_against_array($direction, array('moveup', 'movedown'));
     $this->left_entity_id = turn_into_int($left_entity_id);
     $this->entity_id = turn_into_int($entity_id);
     $this->row_id = turn_into_int($row_id);
     $this->al_relationship_id = turn_into_int($al_relationship_id);
     $this->site_id = turn_into_int($site_id);
     //$this->type_id = turn_into_int($type_id);
     $this->background = check_against_array($background, array('yes', 'no'));
     // consider passing this in earlier, or just use
 }
Esempio n. 3
0
 /**
  * Run error checks
  *
  * @todo make sure account is valid and unprotected via API
  */
 function social_account_run_error_checks($cm)
 {
     $account_id = $cm->get_value('account_id');
     if (!check_against_regexp($account_id, array('naturalnumber')) && !check_against_regexp($account_id, array('/^[a-z\\d.\\S]*$/i'))) {
         $cm->set_error('account_id', 'Invalid format for LinkedIn URL. Please enter a valid URL');
     }
     // if we have a problem with account_id lets remove the account_link field.
     if ($cm->has_error('account_id')) {
         if ($cm->is_element('account_link')) {
             $cm->remove_element('account_link');
         }
     }
 }
Esempio n. 4
0
 /**
  * Constructor allows specification of supported content types. The first listed type is considered the "default" content type.
  *
  * @param mixed support_types - optional param - string specifying content type or array specifying multiples content types.
  */
 function __construct($support_types = NULL)
 {
     if (isset($support_types)) {
         if (is_string($support_types)) {
             $support_types = array($support_types);
         }
         $this->set_supported_content_types($support_types);
     }
     if ($supported_types = $this->get_supported_content_types()) {
         $type = reset($supported_types);
         $this->set_content_type($type);
     }
     if ($this->get_content_type_request_key() && (isset($_REQUEST['format']) && check_against_regexp($_REQUEST['format'], array('safechars')))) {
         $this->set_content_type($_REQUEST['format']);
     }
     $this->setup_api();
 }
 /**
  * Basic classified error checks that apply to all views
  */
 function run_classified_default_error_checks()
 {
     if ($this->get_value('price') && $this->get_value('price') <= 0) {
         $this->set_error('price', 'Price is too low');
     }
     if ($this->get_value('classified_contact_email') && !check_against_regexp($this->get_value('classified_contact_email'), array('email'))) {
         $this->set_error('classified_contact_email', 'Malformed email address');
     }
     if (strlen($this->get_value('name')) > 50) {
         $this->set_error('name', 'Title exceeds maximum length of 50');
     }
 }
Esempio n. 6
0
 /**
  * Run error checks
  *
  * @todo make sure account is valid and unprotected via API
  */
 function social_account_run_error_checks($cm)
 {
     $account_id = $cm->get_value('account_id');
     if (!check_against_regexp($account_id, array('/^[a-z\\d._]*$/i'))) {
         $cm->set_error('account_id', 'Invalid format for YouTube username. Please enter a valid username');
     }
     // if we have a problem with account_id lets remove the account_link field.
     if ($cm->has_error('account_id')) {
         if ($cm->is_element('account_link')) {
             $cm->remove_element('account_link');
         }
     }
 }
Esempio n. 7
0
	/**
	 * Run error checks
	 *
	 * @todo make sure account is valid and unprotected via API
	 */
	function social_account_run_error_checks($cm)
	{
		$account_id = $cm->get_value('account_id');
		if ( !check_against_regexp($account_id, array('naturalnumber')) )
		{
			$cm->set_error('account_id', 'Invalid format for google account id - should be all numbers.');
		}
		// if we have a problem with account_id lets remove the account_link field.
		if ($cm->has_error('account_id'))
		{
			if ($cm->is_element('account_link'))
			{
				$cm->remove_element('account_link');
			}
		}
	}
Esempio n. 8
0
	/**
	 * Run error checks
	 *
	 * - validate the account id - autoconvert to id from username if possible.
	 * - populate account_details field so it is saved when process phase runs.
	 */
	function social_account_run_error_checks($cm)
	{
		$account_id = $cm->get_value('account_id');
		if ( !check_against_regexp($account_id, array('naturalnumber')) && !check_against_regexp($account_id, array('/^[a-z\d.]*$/i')) )
		{
			$cm->set_error('account_id', 'Invalid format for Facebook ID. Please enter a numeric ID or a valid Facebook username');
		}
		else
		{
			// lets actually look this up at graph search.
			if ($details = $this->get_graph_info($account_id))
			{
				if (isset($details['link']))
				{
					$existing_details = json_decode($cm->get_value('account_details'), true);
					$existing_details['link'] = $details['link'];
					$cm->set_value('account_details', json_encode($existing_details));
					if (isset($details['id']) && ($details['id'] != $account_id))
					{
						$cm->set_value('account_id', $details['id']);
					}
				}
				else
				{
					$cm->set_error('account_id', 'Facebook does have a public link associated with that Facebook ID. Make sure you entered the ID correctly.');
				}
			}
			else
			{
				$cm->set_error('account_id', 'Facebook does not recognize the ID that you entered.');
			}
		}
		
		// if we have a problem with account_id lets remove the account_link field.
		if ($cm->has_error('account_id'))
		{
			if ($cm->is_element('account_link'))
			{
				$cm->remove_element('account_link');
			}
		}
	}
 if ($cache->is_cached(get_current_url()) || ($site = get_validated_site($site_id, $page_id)) && $site->get_value('use_page_caching')) {
     $use_cache = true;
 } else {
     $use_cache = false;
     $no_cache_reasons[] = 'unsupported site';
 }
 //-----------------------------------------------------------
 // CONDITION UNDER WHICH WE SHOULD NOT USE PAGE CACHING
 //  - if visitor is a listed developer who is not testing the cache
 //  - if something was _POSTed
 //  - if there is an active reason session
 //  - ** future ** if a module tells us not to use caching
 //-----------------------------------------------------------
 $sess = get_reason_session();
 $requested_api = !empty($_REQUEST['module_api']) && check_against_regexp($_REQUEST['module_api'], array('safechars')) ? $_REQUEST['module_api'] : false;
 $requested_identifier = !empty($_REQUEST['module_identifier']) && check_against_regexp($_REQUEST['module_identifier'], array('safechars')) ? $_REQUEST['module_identifier'] : false;
 if (is_developer() && empty($_REQUEST['test_cache'])) {
     $use_cache = false;
     $no_cache_reasons[] = 'developer';
 }
 if (!empty($_POST)) {
     $use_cache = false;
     $no_cache_reasons[] = '_POST';
 }
 if ($requested_api) {
     $use_cache = false;
     $no_cache_reasons[] = 'api_request';
 }
 if ($sess->exists()) {
     $use_cache = false;
     $no_cache_reasons[] = 'session';
Esempio n. 10
0
/**
 * checks if the author field is an e-mail address and returns it if so
 */
function valid_rss_author($value)
{
    return check_against_regexp($value, array('email'));
}
 function run_error_checks()
 {
     if (!check_against_regexp($this->get_value('email'), array('email'))) {
         $this->set_error('email', 'You must enter a valid email address.');
     }
 }