function grab()
 {
     $http_vars = $this->get_request();
     if (isset($http_vars[$this->name])) {
         $val = tidy($http_vars[$this->name]);
         if (empty($val)) {
             $tidy_err = tidy_err($http_vars[$this->name]);
             if (!empty($tidy_err)) {
                 $tidy_err = nl2br(htmlentities($tidy_err, ENT_QUOTES, 'UTF-8'));
                 $this->set_error('Your HTML appears to be ill-formatted.  Here is what Tidy has to say about it: <br />' . $tidy_err);
                 $this->set($http_vars[$this->name]);
             } else {
                 $this->set($val);
             }
         } else {
             // this looks like a hack. We could look into removing it.
             // $val = eregi_replace("</table>\n\n<br />\n<br />\n","</table>\n", $val);
             $this->set($val);
         }
     }
     $length = strlen($this->value);
     if ($this->db_type == 'tinytext' and $length > 255 or $this->db_type == 'text' and $length > 65535 or $this->db_type == 'mediumtext' and $length > 16777215) {
         $this->set_error('There is more text in ' . $this->display_name . ' than can be stored ');
     }
 }
 function pre_show_form()
 {
     /* echo "<h1>Step Five &#8212; Send the Newsletter</h1>";
     		echo "<p>You may use Reason to send your newsletter. You may enter Carleton NetIDs or emails in the \"to\" field, separated by semicolons or commas. You may also review the body of the email below. To make any changes, press the button labeled \"Go Back\".</p><p>Alternatively, you can copy and paste the newsletter as you see it below into your preferred email client.</p>";
     		echo '<div id="tabList" class="haveJS"><ul><li><a href="#use_reason_tab">Send using Reason</a></li><li><a href="#use_client_tab">Send with your own email client</a></li></ul></div>';
     		echo '<div id="use_reason_tab">'; */
     echo '<div id="ComposeEmailStep">' . "\n";
     echo "<p class='basicInstructions'>Copy and paste the newsletter as you see it below into your preferred email client.</p>";
     $final_text = tidy(carl_get_safer_html($this->controller->get_form_data('newsletter_loki')));
     echo '<div id="html" class="previewDiv">' . $final_text . '</div>';
     echo '</div>';
 }
Exemple #3
0
/**
 * Turn a string or array into valid, standards-compliant (x)HTML
 *
 * Uses configuraton options in tidy.conf - which should minimally have show-body-only set to yes
 *
 * @param mixed $text The data to be tidied up
 * @return mixed $result Tidied data
 */
function tidy($text)
{
    static $tidy_funcs;
    static $tidy_conf;
    if (!isset($tidy_conf)) {
        $tidy_conf = SETTINGS_INC . 'tidy.conf';
    }
    if (is_array($text)) {
        $result = array();
        foreach (array_keys($text) as $key) {
            $result[$key] = tidy($text[$key]);
        }
        return $result;
    }
    // determine what tidy libraries are available
    if (empty($tidy_funcs)) {
        $tidy_funcs = get_extension_funcs('tidy');
    }
    $tidy_1_lib_available = !empty($tidy_funcs) && array_search('tidy_setopt', $tidy_funcs) !== false;
    $tidy_2_lib_available = !empty($tidy_funcs) && array_search('tidy_setopt', $tidy_funcs) === false;
    $tidy_command_line_available = TIDY_EXE ? file_exists(TIDY_EXE) : false;
    $text = protect_string_from_tidy($text);
    $text = '<html><body>' . $text . '</body></html>';
    if ($tidy_2_lib_available) {
        $tidy = new tidy();
        $tidy->parseString($text, $tidy_conf, 'utf8');
        $tidy->cleanRepair();
        $result = $tidy;
    } elseif ($tidy_1_lib_available) {
        tidy_load_config($tidy_conf);
        tidy_set_encoding('utf8');
        tidy_parse_string($text);
        tidy_clean_repair();
        $result = tidy_get_output();
    } elseif ($tidy_command_line_available) {
        $arg = escapeshellarg($text);
        // escape the bad stuff in the text
        $cmd = 'echo ' . $arg . ' | ' . TIDY_EXE . ' -q -config ' . $tidy_conf . ' 2> /dev/null';
        // the actual command - pipes the input to tidy which diverts its output to the random file
        $result = shell_exec($cmd);
        // execute the command
    } else {
        trigger_error('tidy does not appear to be available within php or at the command line - no tidying is taking place.');
        $result = $text;
    }
    return trim($result);
}
	function process()
	{	
		$description = trim(tidy($this->get_value('description')));
		$content = trim(get_safer_html(tidy($this->get_value('post_content'))));
		if(carl_empty_html($description))
		{
			$words = explode(' ', $content, 31);
			unset($words[count($words)-1]);
			$description = implode(' ', $words).'…';
			$description = trim(tidy($description)); // we're tidying it twice so that if we chop off a closing tag tidy will stitch it back up again
		}
		
		if(!empty($this->user_netID))
		{
			$user_id = make_sure_username_is_user($this->user_netID, $this->site_info->id());
		}
		else
		{
			$user_id = $this->site_info->id();
		}
		
		if($this->hold_posts_for_review)
		{
			$status = 'pending';
		}
		else
		{
			$status = 'published';
		}

		$values = array (
			'status' => $status,
			'release_title' => trim(strip_tags($this->get_value('title'))),
			'author' => trim(strip_tags($this->get_value('author'))),
			'content' => $content,
			'description' => $description,
			'datetime' => date('Y-m-d H:i:s', time()),
			'keywords' => implode(', ', array(strip_tags($this->get_value('title')), date('Y'), date('F'))),
			'show_hide' => 'show',
			'new' => 0
		);
				
		$this->new_post_id = reason_create_entity( 
			$this->site_info->id(), 
			id_of('news'), 
			$user_id, 
			$values['release_title'], 
			$values
		);
		
		create_relationship(
			$this->new_post_id,
			$this->publication->id(),
			relationship_id_of('news_to_publication')
		);

		if ($this->successfully_submitted())
		{
			
			if($this->hold_posts_for_review)
			{
				echo '<p>Posts are being held for review on this publication. Please check back later to see if your post has been published.</p>';
				echo '<a href="?">Back to main page</a>';
			
			}
			else
			{
				echo '<p>Your post has been published.</p>';
				echo '<a href="'.carl_construct_redirect(array('story_id'=>$this->new_post_id)).'">View it.</a>';
			}
		}
		
		if($this->get_value('issue'))
		{
			create_relationship($this->new_post_id, $this->get_value('issue'), relationship_id_of('news_to_issue'));
		}
		
		if($this->get_value('section'))
		{
			create_relationship($this->new_post_id, $this->get_value('section'), relationship_id_of('news_to_news_section'));
		}
		
		if($this->get_value('categories'))
		{
			foreach($this->get_value('categories') as $category_id)
			{
				// Check to make sure ids posted actually belong to categories in the site
				if(array_key_exists($category_id, $this->categories))
				{
					create_relationship(
						$this->new_post_id,
						$category_id,
						relationship_id_of('news_to_category')
					);
				}
			}
		}
		
		$this->show_form = false;

		$this->do_notifications();
	}
Exemple #5
0
		/**
		* Update the Reason entity that the user edited.
		*/
		function process_editable(&$disco)
		{
			$values = array();
			$values['release_title'] = trim(strip_tags($disco->get_value('title_of_story')));
			$values['content'] = trim(tidy($disco->get_value( 'editable_content' )));
			$values['description'] = trim(tidy($disco->get_value('description_of_story')));
			$archive = ($disco->get_chosen_action() == 'save_and_finish') ? true : false;
			reason_update_entity($this->current_item_id, get_user_id($this->get_user_netid()), $values, $archive );
		}
Exemple #6
0
		function _process_policy_metadata(&$disco)
		{
			$values['approvals'] = tidy($disco->get_value('approvals'));
			$values['last_revised_date'] = tidy($disco->get_value('last_revised_date'));
			$values['last_reviewed_date'] = carl_date('Y-m-d');
			$values['keywords'] = tidy($disco->get_value('keywords'));

			foreach ($this->all_audiences as $audience)
			{	
				// if the audience is checked
				if (in_array($this->audience_opts[$audience->get_value('name')], $disco->get_value('audiences')))
				{
					if (!in_array($audience, $this->related_audiences))
					{
						create_relationship($this->edit_policy->id(), $audience->id(), relationship_id_of('policy_to_relevant_audience'));
					}
				}
				// if the audience was unchecked by the user
				elseif (in_array($audience, $this->related_audiences))
				{
					$conditions = array(
						'entity_a'=> $this->edit_policy->id(),
						'entity_b'=> $audience->id(),
						'type'=> relationship_id_of('policy_to_relevant_audience'),
					);
					delete_relationships($conditions);
				}
			}
			$archive = ($disco->get_chosen_action() == 'save_and_finish') ? true : false;
			$succes = reason_update_entity( $this->request['policy_id'], $this->get_update_entity_user_id(), $values, $archive );
		}
 /**
  * An export function which displays title, intro, publication/event
  * titles and dates, with events grouped by month.
  * 
  * Output looks like:
  * <code>
  * <h1>A Newsletter Title</h1>
  * <p>A newsletter description blah blah</p>
  * <h2>Recent News</h2>
  * <h3>The name of a publication</h3>
  * <ul>
  * 	<li><a target="_blank" href="some_story_url">A post</a> (Wed, May 19 2010  9:23 am)</li>
  * 	<li><a target="_blank" href="some_story_url">A post</a> (Wed, May 19 2010  9:23 am)</li>
  * </ul>
  * <h2>Upcoming Events</h2>
  * <h3>April 2010</h3>
  * <ul>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Thu, Apr 15 2010)</li>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Fri, Apr 16 2010)</li>
  * </ul>
  * <h3>May 2010</h3>
  * <ul>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Thu, May 15 2010)</li>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Fri, May 16 2010)</li>
  * </ul>
  * </code>
  * 
  * @param array the data to be transformed.
  * @return array the transformed data
  */
 function _export_headings_only_events_by_month($data)
 {
     $output = "";
     if ($data['info']['title']) {
         $output = '<h1>' . $data['info']['title'] . '</h1>';
     }
     if ($data['info']['intro']) {
         $output .= '<p>' . $data['info']['intro'] . '</p>';
     }
     if (!empty($data['pubs'])) {
         $output .= "<h2>Recent News</h2>";
         foreach ($data['pubs'] as $pub_id => $pub_posts) {
             $pub_ent = new Entity($pub_id);
             $output .= '<h3>' . $pub_ent->get_value('name') . '</h3>';
             $output .= "<ul>";
             foreach ($pub_posts as $pub_post) {
                 $output .= '<li><a target="_blank" href="' . $data['info']['urls'][$pub_id] . "?story_id=" . $pub_post->get_value('id') . '">' . $pub_post->get_value('name') . '</a> (' . date("D, M j Y  g:i a", strtotime($pub_post->get_value('datetime'))) . ')</li>';
             }
             $output .= "</ul>";
         }
     }
     if (!empty($data['events'])) {
         $output .= "<h2>Upcoming Events</h2>";
         foreach ($data['events'] as $day => $events) {
             $events_by_month[date("M-Y", strtotime($day))][$day] = $events;
         }
         foreach ($events_by_month as $month => $day) {
             $output .= "<h3>" . date("F Y", strtotime($month)) . "</h3>";
             $output .= "<ul>";
             foreach ($day as $day => $events) {
                 foreach ($events as $event) {
                     $eHelper = new EventHelper();
                     @$eHelper->set_page_link($event);
                     $eventURL = $event->get_value('url') . date("Y-m-d", strtotime($day));
                     $output .= '<li><a target="_blank" href="' . $eventURL . '">' . $event->get_value('name') . '</a> (' . date("D, M j", strtotime($day)) . " at " . date("g:i a", strtotime(preg_replace('/^.*[^ ] /', '', $event->get_value('datetime')))) . ')</li>';
                 }
             }
             $output .= "</ul>";
         }
     }
     return tidy($output);
 }
 /**
  *
  * @todo populate descriptions intelligently
  */
 function process()
 {
     // lets parse the uploaded file and create a job set - we cache the job set so that if the browser times out we can recover.
     $stack = new ReasonJobStack();
     // kill All
     $kill_all = $this->get_value('kill_all');
     if ($kill_all == "true") {
         $cleanup_job = new WordPressImportCleanup();
         $cleanup_job->site_id = $this->get_value('reason_site');
         $cleanup_job->user_id = $this->controller->reason_user_id;
         $stack->add_job($cleanup_job);
     } else {
         // create a job for alerts that we'll add to the end of the stack.
         $report_preformatted_job = new WordPressRewriteRuleReportPreformattedJob();
         // ensure the news type is on the site
         $job = new WordPressEnsureTypeIsOnSite();
         $job->site_id = $this->get_value('reason_site');
         $job->type_id = id_of('news');
         $stack->add_job($job);
         // ensure publication type is on the site
         $job = new WordPressEnsureTypeIsOnSite();
         $job->site_id = $this->get_value('reason_site');
         $job->type_id = id_of('publication_type');
         $stack->add_job($job);
         // ensure category type is on the site
         $job = new WordPressEnsureTypeIsOnSite();
         $job->site_id = $this->get_value('reason_site');
         $job->type_id = id_of('category_type');
         $stack->add_job($job);
         // create the publication entity
         $job = new WordPressEntityCreationJob();
         $job->site_id = $this->get_value('reason_site');
         $job->type_id = id_of('publication_type');
         $job->user_id = $this->controller->reason_user_id;
         $job->entity_info = array('name' => $this->xml_parser->document->channel[0]->title[0]->tagData, 'description' => $this->xml_parser->document->channel[0]->description[0]->tagData, 'publication_type' => 'blog', 'blog_feed_string' => 'blog', 'hold_posts_for_review' => 'no', 'has_issues' => 'no', 'has_sections' => 'no');
         $pub_import_guid = $stack->add_job($job);
         $nobody_group_job = new WordPressEnsureNobodyGroupIsOnSite();
         $nobody_group_job->site_id = $this->get_value('reason_site');
         $stack->add_job($nobody_group_job);
         // relate publication to nobody group for front end posting and commenting
         $post_group_job = new WordPressRelateItemsJob();
         $post_group_job->rel_id = relationship_id_of('publication_to_authorized_posting_group');
         $post_group_job->left_import_guid = $pub_import_guid;
         $post_group_job->right_id = id_of('nobody_group');
         $stack->add_job($post_group_job);
         $comment_group_job = new WordPressRelateItemsJob();
         $comment_group_job->rel_id = relationship_id_of('publication_to_authorized_commenting_group');
         $comment_group_job->left_import_guid = $pub_import_guid;
         $comment_group_job->right_id = id_of('nobody_group');
         $stack->add_job($comment_group_job);
         $make_pub_page_job = new WordPressMakePublicationPageJob();
         $make_pub_page_job->site_id = $this->get_value('reason_site');
         // if we want a new page - create a publication page.
         if ($new_pub_page = $this->get_value('blog_page_name')) {
             $pub_page_name = trim(strip_tags($new_pub_page));
             $pub_page_url_fragment = strtolower(str_replace(array("-", " "), "_", $pub_page_name));
             $create_pub_page_job = new WordPressEntityCreationJob();
             $create_pub_page_job->type_id = id_of('minisite_page');
             $create_pub_page_job->site_id = $this->get_value('reason_site');
             $create_pub_page_job->user_id = $this->controller->reason_user_id;
             $create_pub_page_job->entity_info = array('name' => $pub_page_name, 'link_name' => $pub_page_name, 'url_fragment' => $pub_page_url_fragment, 'state' => 'Live', 'custom_page' => 'publication', 'content' => '', 'nav_display' => 'Yes');
             $create_pub_page_guid = $stack->add_job($create_pub_page_job);
             // we need to make a parent relationship with the root page_id
             $page_parent_job = new WordPressRelateItemsJob();
             $page_parent_job->rel_id = relationship_id_of('minisite_page_parent');
             $page_parent_job->left_import_guid = $create_pub_page_guid;
             $page_parent_job->right_id = $this->get_site_root($this->get_value('reason_site'));
             $page_parent_job_guid = $stack->add_job($page_parent_job);
             $make_pub_page_job->page_id_guid = $create_pub_page_guid;
         } else {
             $make_pub_page_job->page_id = $this->get_site_root($this->get_value('reason_site'));
         }
         $make_pub_page_job->user_id = $this->controller->reason_user_id;
         $make_pub_page_job->pub_import_guid = $pub_import_guid;
         $pub_page_guid = $stack->add_job($make_pub_page_job);
         // CATEGORIES
         if (!empty($this->xml_parser->document->channel[0]->wp_category)) {
             foreach ($this->xml_parser->document->channel[0]->wp_category as $k => $cat) {
                 $the_category['wp_cat_name'] = $cat->wp_cat_name[0]->tagData;
                 $the_category['wp_category_nicename'] = $cat->wp_category_nicename[0]->tagData;
                 $the_category['wp_category_parent'] = $cat->wp_category_parent[0]->tagData;
                 if (!empty($the_category['wp_category_parent'])) {
                     $parent_cat[$the_category['wp_cat_name']] = $the_category['wp_category_parent'];
                 }
                 // STUFF FOR OUR IMPORT
                 $cat_import_job = new WordPressEntityCreationJob();
                 $cat_import_job->type_id = id_of('category_type');
                 $cat_import_job->site_id = $this->get_value('reason_site');
                 $cat_import_job->user_id = $this->controller->reason_user_id;
                 $cat_import_job->entity_info = array('name' => $the_category['wp_cat_name'], 'slug' => $the_category['wp_category_nicename']);
                 $cat_import_guid[$the_category['wp_cat_name']] = $stack->add_job($cat_import_job);
             }
         }
         // TAGS - we also make these into categories since Reason does not have a meaningful distinction
         if (!empty($this->xml_parser->document->channel[0]->wp_tag)) {
             foreach ($this->xml_parser->document->channel[0]->wp_tag as $k => $cat) {
                 $the_category['wp_tag_name'] = $cat->wp_tag_name[0]->tagData;
                 $the_category['wp_tag_slug'] = $cat->wp_tag_slug[0]->tagData;
                 // STUFF FOR OUR IMPORT
                 $cat_import_job = new WordPressEntityCreationJob();
                 $cat_import_job->type_id = id_of('category_type');
                 $cat_import_job->site_id = $this->get_value('reason_site');
                 $cat_import_job->user_id = $this->controller->reason_user_id;
                 $cat_import_job->entity_info = array('name' => $the_category['wp_tag_name'], 'slug' => $the_category['wp_tag_slug']);
                 $cat_import_guid[$the_category['wp_tag_name']] = $stack->add_job($cat_import_job);
             }
         }
         if (!empty($this->xml_parser->document->channel[0]->item)) {
             foreach ($this->xml_parser->document->channel[0]->item as $k => $item) {
                 $the_item = array();
                 // STRAIGHT OUT OF WORDPRESS
                 $the_item['title'] = $item->title[0]->tagData;
                 $the_item['link'] = $item->link[0]->tagData;
                 $the_item['pubDate'] = $item->pubdate[0]->tagData;
                 $the_item['dc_creator'] = $item->dc_creator[0]->tagData;
                 // categories - how to handle??
                 $the_item['guid'] = $item->guid[0]->tagData;
                 // attribute isPermaLink?? - do we care?
                 $the_item['guid_is_permalink'] = $item->guid[0]->tagAttrs['ispermalink'];
                 $the_item['description'] = tidy(strip_tags($item->description[0]->tagData));
                 $the_item['content_encoded'] = trim(tidy(get_safer_html($this->wpautop($item->content_encoded[0]->tagData))));
                 //$the_item['excerpt_encoded'] = trim(tidy($this->wpautop($item->excerpt_encoded[0]->tagData)));
                 $the_item['wp_post_id'] = $item->wp_post_id[0]->tagData;
                 $the_item['wp_post_date'] = $item->wp_post_date[0]->tagData;
                 $the_item['wp_post_date_gmt'] = $item->wp_post_date_gmt[0]->tagData;
                 $the_item['wp_comment_status'] = $item->wp_comment_status[0]->tagData;
                 $the_item['wp_ping_status'] = $item->wp_ping_status[0]->tagData;
                 $the_item['wp_post_name'] = $item->wp_post_name[0]->tagData;
                 $the_item['wp_status'] = $item->wp_status[0]->tagData;
                 $the_item['wp_post_parent'] = $item->wp_post_parent[0]->tagData;
                 $the_item['wp_menu_order'] = $item->wp_menu_order[0]->tagData;
                 $the_item['wp_post_type'] = $item->wp_post_type[0]->tagData;
                 $the_item['wp_post_password'] = $item->wp_post_password[0]->tagData;
                 $the_item['is_sticky'] = $item->wp_post_password[0]->tagData;
                 $the_item['guid'] = $item->guid[0]->tagData;
                 // IF WE ARE A PAGE
                 if (strtolower($the_item['wp_post_type']) == 'page') {
                     //$the_item['link'] is the old URL
                     //$the_item['guid'] is the non friendly URL
                     // our new url fragment should be the last segment of the old URL - if it is an SEO friendly URL
                     $url = parse_url($the_item['link']);
                     if (!empty($url['query'])) {
                         $new_url_fragment = strtolower(str_replace(" ", "_", $the_item['title']));
                     } else {
                         $new_url_fragment = strtolower(str_replace(" ", "_", $the_item['wp_post_name']));
                         $new_url_fragment = strtolower(str_replace("-", "_", $new_url_fragment));
                     }
                     // should we have a description of some type?
                     $page_import_job = new WordPressEntityCreationJob();
                     $page_import_job->type_id = id_of('minisite_page');
                     $page_import_job->site_id = $this->get_value('reason_site');
                     $page_import_job->user_id = $this->controller->reason_user_id;
                     $page_import_job->entity_info = array('name' => $the_item['title'], 'link_name' => $the_item['title'], 'url_fragment' => $new_url_fragment, 'state' => $the_item['wp_status'] == 'publish' ? 'Live' : 'Pending', 'datetime' => $the_item['wp_post_date'], 'author' => $the_item['dc_creator'], 'sort_order' => $the_item['wp_menu_order'], 'custom_page' => 'default', 'content' => tidy($the_item['content_encoded']), 'nav_display' => 'Yes');
                     $page_import_job->id(md5('page_guid_' . $the_item['wp_post_id']));
                     $stack->add_job($page_import_job);
                     //page_to_category - these rels we need to do
                     if (!empty($item->category)) {
                         foreach ($item->category as $k => $category) {
                             $page_cat = array();
                             $cat_name = $category->tagData;
                             $page_cat[] = $cat_name;
                             while (isset($parent_cat[$cat_name])) {
                                 $cat_name = $parent_cat[$cat_name];
                                 $page_cat[] = $cat_name;
                             }
                             foreach ($page_cat as $cat_name) {
                                 // add a job to relate the post to the category
                                 $page_to_cat_job = new WordPressRelateItemsJob();
                                 $page_to_cat_job->rel_id = relationship_id_of('page_to_category');
                                 $page_to_cat_job->left_import_guid = md5('page_guid_' . $the_item['wp_post_id']);
                                 $page_to_cat_job->right_import_guid = $cat_import_guid[$cat_name];
                                 if (!isset($page_to_cat_keys[$cat_import_guid[$cat_name]])) {
                                     $stack->add_job($page_to_cat_job);
                                     // we don't give this one a guid ... doesn't need one
                                 }
                                 $page_to_cat_keys[$cat_import_guid[$cat_name]] = true;
                             }
                         }
                     }
                     //minisite_page_parent - these rels we need to do
                     $page_parent_job = new WordPressRelateItemsJob();
                     $page_parent_job->rel_id = relationship_id_of('minisite_page_parent');
                     $page_parent_job->left_import_guid = md5('page_guid_' . $the_item['wp_post_id']);
                     if (empty($the_item['wp_post_parent'])) {
                         $page_parent_job->right_id = $this->get_site_root($this->get_value('reason_site'));
                     } else {
                         $page_parent_job->right_import_guid = md5('page_guid_' . $the_item['wp_post_parent']);
                     }
                     $page_parent_job_guid = $stack->add_job($page_parent_job);
                     $url_history_job = new WordPressURLHistoryJob();
                     if ($the_item['guid'] && $the_item['guid_is_permalink'] == "true") {
                         $url_history_job->wp_permalink = $the_item['guid'];
                     }
                     $url_history_job->wp_link = $the_item['link'];
                     $url_history_job->rel_guid = $page_parent_job_guid;
                     $url_history_job->entity_guid = md5('page_guid_' . $the_item['wp_post_id']);
                     $stack->add_job($url_history_job);
                     $this->rewrites_needed = true;
                 } elseif (strtolower($the_item['wp_post_type']) == 'post') {
                     if (!empty($the_item['excerpt_encoded'])) {
                         $reason_description = $the_item['excerpt_encoded'];
                     } elseif (!empty($the_item['description'])) {
                         $reason_description = $the_item['description'];
                     } else {
                         $words = explode(' ', $the_item['content_encoded'], 50);
                         unset($words[count($words) - 1]);
                         $reason_description = implode(' ', $words) . '…';
                         $reason_description = trim(tidy($reason_description));
                     }
                     /**
                      * its not clear to me what the various dates represent but in my sample xml file post_date seems to be the only item consistently populated
                      * and so we are going to use it for the dated.datetime value.
                      */
                     // CREATE THE IMPORT JOB AND SAVE IF IT IS NOT ALREADY CACHED
                     $post_import_job = new WordPressEntityCreationJob();
                     $post_import_job->type_id = id_of('news');
                     $post_import_job->site_id = $this->get_value('reason_site');
                     $post_import_job->user_id = $this->controller->reason_user_id;
                     $post_import_job->entity_info = array('name' => $the_item['title'], 'release_title' => $the_item['title'], 'description' => tidy($reason_description), 'content' => tidy($the_item['content_encoded']), 'status' => $the_item['wp_status'] == 'publish' ? 'published' : 'pending', 'show_hide' => $the_item['wp_status'] == 'publish' ? 'show' : 'hide', 'datetime' => $the_item['wp_post_date'], 'commenting_state' => $the_item['wp_comment_status'] == 'open' ? 'on' : 'off', 'author' => $the_item['dc_creator']);
                     $import_guid = $stack->add_job($post_import_job);
                     // now we want to add a job that relates the post to the publication - we have to do this using our import_guids
                     $relationship_job = new WordPressRelateItemsJob();
                     $relationship_job->rel_id = relationship_id_of('news_to_publication');
                     $relationship_job->left_import_guid = $import_guid;
                     $relationship_job->right_import_guid = $pub_import_guid;
                     $stack->add_job($relationship_job);
                     // we don't give this one a guid ... doesn't need one
                     $news_rewrite_alert_job = new WordPressNewsRewriteAlertJob();
                     $news_rewrite_alert_job->page_id_guid = $pub_page_guid;
                     $news_rewrite_alert_job->story_id_guid = $import_guid;
                     $news_rewrite_alert_job->original_url = $the_item['link'];
                     $news_rewrite_alert_job->report_preformatted_job = $report_preformatted_job;
                     $stack->add_job($news_rewrite_alert_job);
                     // lets do category rels and test the stack mechanism at the same time!
                     if (!empty($item->category)) {
                         foreach ($item->category as $k => $category) {
                             $news_cat = array();
                             $cat_name = $category->tagData;
                             $news_cat[] = $cat_name;
                             while (isset($parent_cat[$cat_name])) {
                                 $cat_name = $parent_cat[$cat_name];
                                 $news_cat[] = $cat_name;
                             }
                             foreach ($news_cat as $cat_name) {
                                 // add a job to relate the post to the category
                                 $news_to_cat_job = new WordPressRelateItemsJob();
                                 $news_to_cat_job->rel_id = relationship_id_of('news_to_category');
                                 $news_to_cat_job->left_import_guid = $import_guid;
                                 // the news item
                                 $news_to_cat_job->right_import_guid = $cat_import_guid[$cat_name];
                                 if (!isset($news_to_cat_keys[$cat_import_guid[$cat_name]])) {
                                     $stack->add_job($news_to_cat_job);
                                     // we don't give this one a guid ... doesn't need one
                                 }
                                 $news_to_cat_keys[$cat_import_guid[$cat_name]] = true;
                             }
                         }
                     }
                     if (!empty($item->wp_comment)) {
                         // ensure comment type is on the site
                         if (!isset($make_sure_comments_are_on_site)) {
                             $job = new WordPressEnsureTypeIsOnSite();
                             $job->site_id = $this->get_value('reason_site');
                             $job->type_id = id_of('comment_type');
                             $stack->add_job($job);
                             $make_sure_comments_are_on_site = true;
                         }
                         foreach ($item->wp_comment as $k => $comment) {
                             $the_comment = array();
                             // STRAIGHT OUT OF WORDPRESS
                             $the_comment['id'] = $comment->wp_comment_id[0]->tagData;
                             $the_comment['author'] = strip_tags($comment->wp_comment_author[0]->tagData);
                             $the_comment['author_email'] = $comment->wp_comment_author_email[0]->tagData;
                             $the_comment['author_url'] = $comment->wp_comment_author_url[0]->tagData;
                             $the_comment['author_IP'] = $comment->wp_comment_author_ip[0]->tagData;
                             $the_comment['date'] = $comment->wp_comment_date[0]->tagData;
                             $the_comment['content'] = trim(tidy($this->wpautop($comment->wp_comment_content[0]->tagData)));
                             $the_comment['approved'] = $comment->wp_comment_approved[0]->tagData;
                             $should_import = !$this->only_import_approved_comments || $the_comment['approved'] == '1';
                             // WE MAKE THIS ONE IF IT HAS CONTENT
                             if (!empty($the_comment['content']) && $should_import) {
                                 $words = explode(' ', strip_tags($the_comment['content']), 10);
                                 unset($words[count($words) - 1]);
                                 $name = trim(implode(' ', $words)) . '…';
                                 $comment_import_guid = md5('comment_id_' . $the_comment['id']);
                                 $comment_import_job = new WordPressEntityCreationJob();
                                 $comment_import_job->type_id = id_of('comment_type');
                                 $comment_import_job->site_id = $this->get_value('reason_site');
                                 $comment_import_job->user_id = $this->controller->reason_user_id;
                                 $comment_import_job->entity_info = array('name' => $name, 'content' => $the_comment['content'], 'author' => strip_tags($the_comment['author']), 'show_hide' => $the_comment['approved'] == '1' ? 'show' : 'hide', 'datetime' => $the_comment['date'], 'new' => 0);
                                 $stack->add_job($comment_import_job, $comment_import_guid);
                                 // now we want to add a job that relates the comment to the post - we use import guids
                                 $comment_relationship_job = new WordPressRelateItemsJob();
                                 $comment_relationship_job->rel_id = relationship_id_of('news_to_comment');
                                 $comment_relationship_job->left_import_guid = $import_guid;
                                 $comment_relationship_job->right_import_guid = $comment_import_guid;
                                 $stack->add_job($comment_relationship_job);
                                 // we don't give this one a guid ... doesn't need one
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->rewrites_needed) {
         $rewrite_job = new WordPressSiteRewritesJob();
         $rewrite_job->site_id = $this->get_value('reason_site');
         $stack->add_job($rewrite_job);
     }
     if (isset($report_preformatted_job)) {
         $stack->add_job($report_preformatted_job);
     }
     // lets save the stack in a cache with our $uid
     $cache = new ReasonObjectCache($this->uid);
     $cache->set($stack);
 }
Exemple #9
0
$user_no = "";
$query = "SELECT user_no FROM usr WHERE username=LOWER('{$l}') and password=LOWER('{$p}')";
$result = pg_Exec($dbconn, $query);
if (pg_NumRows($result) > 0) {
    $user_no = pg_Result($result, 0, "user_no");
}
$requests = "<p><small>";
if ("{$user_no}" != "") {
    $query = "SELECT DISTINCT request.request_id, brief, last_activity, ";
    $query .= "lookup_desc AS status_desc, severity_code ";
    $query .= "FROM request, request_interested, lookup_code AS status ";
    $query .= "WHERE request.request_id=request_interested.request_id ";
    $query .= "AND status.source_table='request' ";
    $query .= "AND status.source_field='status_code' ";
    $query .= "AND status.lookup_code=request.last_status ";
    $query .= "AND request_interested.user_no={$user_no} ";
    $query .= "AND request.active ";
    $query .= "AND request.last_status~*'[AILNRQA]' ";
    $query .= "ORDER BY request.severity_code DESC LIMIT 20; ";
    $result = pg_Exec($dbconn, $query);
    if (!$result) {
        error_log("wrms wap/inc/getRequests.php query error: {$query}", 0);
    }
    for ($i = 0; $i < pg_NumRows($result); $i++) {
        $thisrequest = pg_Fetch_Object($result, $i);
        $requests .= "<a href=\"wrms.php?id={$thisrequest->request_id}\">" . tidy($thisrequest->brief) . "</a><br/>\n";
    }
} else {
    $requests .= "I'm sorry you must login first";
}
$requests .= "</small></p>";
Exemple #10
0
/**
 * Returns XHTML snippets filtered to remove XSS vectors using HTMLPurifier.
 *
 * This is expensive - best used before saving content as opposed to on display of content.
 *
 * Note we only run filters if the raw_html provided is a string - boolean, int, NULL, etc pass through untouched.
 * 
 * We also skip tidy and purification in any of these cases:
 *
 * - $raw_html is empty
 * - is_numeric($raw_html) is true
 *
 * @param string $raw_html
 * @param string $config string identifying key of HTMLPurifier config as setup in config/htmlpurifier/setup.php
 * @param boolean default true should we run the HTML through tidy before using HTMLPurifier
 * @return string XSS-filtered XHTML
 */
function reason_sanitize_html($raw_html, $config = 'default', $tidy = true)
{
    if (is_string($raw_html)) {
        if (!empty($raw_html) && !is_numeric($raw_html)) {
            $html = $tidy ? tidy($raw_html) : $raw_html;
            $purifier_config = reason_get_html_purifier_config($config);
            return get_safer_html_html_purifier($html, $purifier_config);
        }
    }
    return $raw_html;
}
Exemple #11
0
	function process_editable(&$disco)
	{
		$values['content'] = tidy($disco->get_value( 'editable_content' ));
		$archive = ($disco->get_chosen_action() == 'save_and_finish') ? true : false;
		reason_update_entity( $this->page_id, $this->get_update_entity_user_id(), $values, $archive );
	}
	function process()
	{
		if(!empty($this->username))
		{
			$user_id = make_sure_username_is_user($this->username, $this->site_id);
		}
		else
		{
			$user_id = $this->site_info->id();
		}

		if($this->hold_comments_for_review)
		{
			$show_hide = 'hide';
		}
		else
		{
			$show_hide = 'show';
		}
		$flat_values = array (
			'state' => 'Live',
			'author' => trim(get_safer_html(strip_tags($this->get_value('author')))),
			'content' => trim(get_safer_html(strip_tags(tidy($this->get_value('comment_content')), '<p><em><strong><a><ol><ul><li><blockquote><acronym><abbr><br><cite><code><pre>'))),
			'datetime' => date('Y-m-d H:i:s'),
			'show_hide' => $show_hide,
			'new'=>'0',
		);

		$this->comment_id = reason_create_entity( 
			$this->site_id, 
			id_of('comment_type'), 
			$user_id, 
			trim(substr(strip_tags($flat_values['content']),0,40)),
			$flat_values,
			$testmode = false
		);
		
		create_relationship(
			$this->news_item->_id,
			$this->comment_id,
			relationship_id_of('news_to_comment')
		);
		$this->do_notifications();
	}
Exemple #13
0
 /**
  * A standardized function for counting the number of characters in a string that might 
  * contain HTML that we don't want to include in our count. 
  *
  * @author Nick Jones
  * @param string $text - the text whose characters we want to count
  * @return int the number of characters in the string
  */
 function carl_util_count_html_text_characters($text)
 {
     $tidied_text = tidy($text);
     return carl_strlen(html_entity_decode(strip_tags($tidied_text), ENT_QUOTES, 'UTF-8'), 'UTF-8');
 }
Exemple #14
0
    $user_no = $session->user_no;
} else {
    $user_no = 0;
    echo "<h1>You need to log on to access this function</h1>";
    return;
}
if ("{$nodename}" == "" && !isset($node_id)) {
    echo "<h1>Default page goes here</h1>";
    return;
}
$query = "SELECT *, to_char(wu_on, 'YYYY-MM-DD at HH24:MI') AS nice_date ";
$query .= "FROM infonode, wu, usr WHERE ";
if (isset($node_id) && $node_id > 0) {
    $query .= "infonode.node_id = {$node_id} ";
} else {
    $query .= "LOWER(nodename) = '" . strtolower(tidy($nodename)) . "' ";
}
if (isset($by)) {
    $query .= "AND wu_by = " . intval($by) . " ";
}
$query .= "AND infonode.node_id = wu.node_id ";
$query .= "AND usr.user_no = wu.wu_by ";
$query .= "ORDER BY wu.node_id, wu_on;";
$rid = awm_pgexec($dbconn, $query, "wu", false, 7);
if (!$rid) {
    echo "<h1>Editorial about {$nodename}</h1>";
    echo "<h2 style=\"font-family: comic sans ms, verdana, fantasy; font-size: 200px; line-height: 80px; padding-top: 70px; font-weight: 700; text-align: center\">wu!!!</h2>\n";
} else {
    $rows = pg_NumRows($rid);
    if ($rows > 0) {
        // Read first row to get the infonode.nodename
Exemple #15
0
<?php

if ($logged_on) {
    $user_no = $session->user_no;
} else {
    $user_no = 0;
}
$query = "SELECT help_hit({$user_no}, '" . tidy($topic) . "');";
awm_pgexec($dbconn, $query, "help", true, 5);
$query = "SELECT * FROM help WHERE topic = '" . tidy($topic) . "' ";
if (isset($seq) && $action == "edit") {
    $query .= "AND seq = " . intval($seq) . " ";
}
$query .= "ORDER BY topic, seq;";
$rid = awm_pgexec($dbconn, $query, "help");
if (!$rid) {
    echo "<h1>Help about {$topic}</h1>";
    echo "<h2 style=\"font-family: comic sans ms, verdana, fantasy; font-size: 200px; line-height: 80px; padding-top: 70px; font-weight: 700; text-align: center\">HELP!!!</h2>\n";
} else {
    $rows = pg_NumRows($rid);
    if (0 == $rows || $action == "add" || $action == "edit" && $rows == 1) {
        // No rows!  Maybe they want to add it?
        if ("edit" == "{$action}") {
            $submitlabel = "Update Help";
            $help = pg_Fetch_Object($rid, 0);
        } else {
            if ("add" == "{$action}") {
                $submitlabel = "Add New Help";
                echo "<h1>Help about {$topic}</h1>";
                if ($rows > 0) {
                    echo "<p>Existing help on this topic includes:</p>";
Exemple #16
0
 function process()
 {
     // ignoring last_edited_by avoids the problem of updating entities by just viewing them.
     // i believe entities will only be updated when some of the actual CONTENT of the entity is changed.
     // phew.
     $this->_process_ignore[] = 'id';
     $this->_process_ignore[] = 'last_edited_by';
     $this->_process_ignore[] = 'last_modified';
     // collect values of entity
     $values = array();
     foreach ($this->get_element_names() as $element_name) {
         if (!in_array($element_name, $this->_process_ignore)) {
             $values[$element_name] = $this->get_value($element_name);
         }
     }
     /*foreach( $this->_elements AS $key => $element )
     		if( !in_array( $key, $this->_process_ignore ) )
     			$values[ $key ] = $element->get(); */
     foreach ($values as $key => $el) {
         if (!in_array($key, $this->_no_tidy)) {
             $values[$key] = tidy($el);
         }
     }
     // always reason_update_entity since we created when user clicks "Add"
     $this->has_changed = reason_update_entity($this->_id, $this->admin_page->user_id, $values, false);
     // the last argument determines whether or not to archive the entity.  if it's new, don't worry about it.  otherwise, archive
     // the $changed var grabs the result, true if changed, false if not
     // commented out nwhite 11-02-07
     // if a site is borrowing an item and the tiems sharing goes to private, the item is still borrowed by sites that had it ...
     // the owner will need to contact those sites and get them to manually remove the item from the list of those that are available.
     //
     //delete borrow relationships if no_share is true
     //if( $this->_elements[ 'no_share' ] )
     //if($this->_is_element('no_share'))
     //{
     //	if( $this->get_value( 'no_share' ) )
     //	{
     //		$d = new DBSelector;
     //		$d->add_table( 'ar' , 'allowable_relationship' );
     //		$d->add_table( 'r' , 'relationship' );
     //		$d->add_field( 'r' , 'id' , 'id' );
     //		$d->add_relation( 'r.type = ar.id' );
     //		$d->add_relation( 'ar.name = "borrows"' );
     //		$d->add_relation( 'ar.relationship_a = ' . id_of( 'site' ) );
     //		$d->add_relation( 'ar.relationship_b = ' . $this->admin_page->type_id );
     //		$d->add_relation( 'r.entity_b = ' . $this->admin_page->id );
     //		$x = $d->run();
     //		foreach( $x AS $rel )
     //			db_query( 'DELETE FROM relationship WHERE id = ' . $rel[ 'id' ] , 'Error deleting borrowed relationship' );
     //	}
     //}
     $this->_process_relationship_elements();
 }
Exemple #17
0
 function save_blurb_callback(&$form)
 {
     $values['content'] = tidy($form->get_value('blurb_edit_text'));
     $archive = $form->chosen_action == 'save_and_finish' ? true : false;
     reason_update_entity($this->request['blurb_id'], $this->get_html_editor_user_id(), $values, $archive);
 }
 function html_safe_truncate($count_limit = 10, $original_string, $href)
 {
     $output = "";
     // save our work
     // make sure our html is clean to begin with
     $original_string = trim(tidy($original_string));
     // make sure the parse doesn't confuse <a href="blah">foo for a single word (since it's splitting on spaces)
     $original_string = preg_replace('/\\n/', ' ', $original_string);
     $original_string = preg_replace('/>/', '> ', $original_string);
     $original_string = preg_replace('/</', ' <', $original_string);
     $original_string = preg_replace('/\\s+/', ' ', $original_string);
     // remove any HTML from the string
     $stripped_string = strip_tags($original_string);
     // remove any extra spaces between words
     $stripped_string = preg_replace('/\\s+/', ' ', $stripped_string);
     // split the string into an array
     $stripped_array = explode(' ', $stripped_string, $count_limit + 1);
     // truncate the stripped_array if it exceeds the count_limit, otherwise it's short enought already
     if (count($stripped_array) > $count_limit) {
         unset($stripped_array[count($stripped_array) - 1]);
     }
     // split the original_string into an array
     $original_array = explode(' ', $original_string);
     // a counter to keep track of how many words in the stripped_array we've matched from the original array
     $stripped_counter = 0;
     while ($stripped_counter < count($stripped_array)) {
         foreach ($original_array as $word) {
             // if we haven't reached the count limit, echo the word
             if ($stripped_counter < count($stripped_array) && $word != "") {
                 $output .= $word . " ";
             }
             // if the word in the original array matches a word from the stripped array, increment the counter
             if ($word == $stripped_array[$stripped_counter]) {
                 $stripped_counter++;
             }
             // escape this loop if we've reached the end of the stripped_array
             if ($stripped_counter == count($stripped_array)) {
                 break;
             }
         }
     }
     // compare the last 10 chars of the original string with the last 10 of the possibly truncated output.  If they match a truncation
     // probably hasn't happened and the "more" link isn't necessary.  If they don't match, add the more link.
     $more = "";
     if (strcmp(substr(trim($original_string), strlen(trim($original_string)) - 10, 10), substr(trim($output), strlen(trim($output)) - 10, 10))) {
         $more = " ... <a href=\"{$href}\">more</a>";
     }
     $output .= $more;
     // one final pass through tidy
     return trim(tidy($output));
 }
Exemple #19
0
function tidy_check()
{
    $html_string = '<html><body><h3>babababab</h3></body></html>';
    $string = tidy($html_string);
    if ($string == '') {
        return msg('<span class="error">tidy check failed</span> - make sure the constant TIDY_EXE in paths.php is set to the location of the tidy executable', false);
    } elseif (strpos($string, 'body') !== false) {
        return msg('<span class="error">tidy check failed</span> - tidy is not properly stripping body tags - make sure that the tidy.conf file in your settings directory includes "show-body-only: yes"', false);
    } else {
        return msg('<span class="success">tidy check passed</span>', true);
    }
}
 function process()
 {
     $site_id = $this->site_id;
     $counts = array();
     for ($i = 1; $i <= $this->max_upload_number; $i++) {
         $element = $this->get_element('upload_' . $i);
         if (!empty($element->tmp_full_path) and file_exists($element->tmp_full_path)) {
             $filename = $this->get_value('upload_' . $i . '_filename');
             if ($this->verify_image($element->tmp_full_path)) {
                 if (empty($counts[$filename])) {
                     $this->files[$filename] = $element->tmp_full_path;
                     $counts[$filename] = 1;
                 } else {
                     $counts[$filename]++;
                     $this->files[$filename . '.' . $counts[$filename]] = $element->tmp_full_path;
                 }
             } else {
                 $this->invalid_files[$filename] = $element->tmp_full_path;
             }
         }
     }
     if (count($this->files)) {
         $page_id = (int) $this->get_value('attach_to_page');
         $max_sort_order_value = 0;
         if ($page_id) {
             $max_sort_order_value = $this->_get_max_sort_order_value($page_id);
         }
         $sort_order_value = $max_sort_order_value;
         $tables = get_entity_tables_by_type(id_of('image'));
         $valid_file_html = '<ul>' . "\n";
         foreach ($this->files as $entry => $cur_name) {
             $sort_order_value++;
             $valid_file_html .= '<li><strong>' . $entry . ':</strong> processing ';
             $date = '';
             // get suffix
             $type = strtolower(substr($cur_name, strrpos($cur_name, '.') + 1));
             $ok_types = array('jpg');
             // get exif data
             if ($this->get_value('exif_override') && in_array($type, $ok_types) && function_exists('read_exif_data')) {
                 // read_exif_data() does not obey error supression
                 $exif_data = @read_exif_data($cur_name);
                 if ($exif_data) {
                     // some photos may have different fields filled in for dates - look through these until one is found
                     $valid_dt_fields = array('DateTimeOriginal', 'DateTime', 'DateTimeDigitized');
                     foreach ($valid_dt_fields as $field) {
                         // once we've found a valid date field, store that and break out of the loop
                         if (!empty($exif_data[$field])) {
                             $date = $exif_data[$field];
                             break;
                         }
                     }
                 }
             } else {
                 $date = $this->get_value('datetime');
             }
             $keywords = $entry;
             if ($this->get_value('keywords')) {
                 $keywords .= ', ' . $this->get_value('keywords');
             }
             // insert entry into DB with proper info
             $values = array('datetime' => $date, 'image_type' => $type, 'author' => $this->get_value('author'), 'state' => 'Pending', 'keywords' => $keywords, 'description' => $this->get_value('description'), 'name' => $this->get_value('name') ? $this->get_value('name') : $entry, 'content' => $this->get_value('content'), 'original_image_format' => $this->get_value('original_image_format'), 'new' => 0, 'no_share' => $this->get_value('no_share'));
             //tidy values
             $no_tidy = array('state', 'new');
             foreach ($values as $key => $val) {
                 if (!in_array($key, $no_tidy) && !empty($val)) {
                     $values[$key] = trim(get_safer_html(tidy($val)));
                 }
             }
             $id = reason_create_entity($site_id, id_of('image'), $this->user_id, $entry, $values);
             if ($id) {
                 //assign to categories
                 $categories = $this->get_value('assign_to_categories');
                 if (!empty($categories)) {
                     foreach ($categories as $category_id) {
                         create_relationship($id, $category_id, relationship_id_of('image_to_category'));
                     }
                 }
                 //assign to	gallery page
                 if ($page_id) {
                     create_relationship($page_id, $id, relationship_id_of('minisite_page_to_image'), array('rel_sort_order' => $sort_order_value));
                 }
                 // resize and move photos
                 $new_name = PHOTOSTOCK . $id . '.' . $type;
                 $orig_name = PHOTOSTOCK . $id . '_orig.' . $type;
                 $tn_name = PHOTOSTOCK . $id . '_tn.' . $type;
                 // Support for new fields; they should be set null by default, but will be
                 // changed below if a thumbnail/original image is created. This is very messy...
                 $thumbnail_image_type = null;
                 $original_image_type = null;
                 // atomic move the file if possible, copy if necessary
                 if (is_writable($cur_name)) {
                     rename($cur_name, $new_name);
                 } else {
                     copy($cur_name, $new_name);
                 }
                 // create a thumbnail if need be
                 list($width, $height, $type, $attr) = getimagesize($new_name);
                 if ($width > REASON_STANDARD_MAX_IMAGE_WIDTH || $height > REASON_STANDARD_MAX_IMAGE_HEIGHT) {
                     copy($new_name, $orig_name);
                     resize_image($new_name, REASON_STANDARD_MAX_IMAGE_WIDTH, REASON_STANDARD_MAX_IMAGE_HEIGHT);
                     $original_image_type = $this->image_types[$type];
                 }
                 $thumb_dimensions = get_reason_thumbnail_dimensions($site_id);
                 if ($width > $thumb_dimensions['width'] || $height > $thumb_dimensions['height']) {
                     copy($new_name, $tn_name);
                     resize_image($tn_name, $thumb_dimensions['width'], $thumb_dimensions['height']);
                     $thumbnail_image_type = $this->image_types[$type];
                 }
                 // real original
                 $my_orig_name = $this->add_name_suffix($cur_name, '-unscaled');
                 if (file_exists($my_orig_name)) {
                     // move the original image into the photostock directory
                     if (is_writable($my_orig_name)) {
                         rename($my_orig_name, $orig_name);
                     } else {
                         copy($my_orig_name, $orig_name);
                     }
                     $original_image_type = $this->image_types[$type];
                 }
                 $info = getimagesize($new_name);
                 $size = round(filesize($new_name) / 1024);
                 // now we have the size of the resized image.
                 $values = array('width' => $info[0], 'height' => $info[1], 'size' => $size, 'thumbnail_image_type' => $thumbnail_image_type, 'original_image_type' => $original_image_type);
                 // update with new info - don't archive since this is really just an extension of the creation of the item
                 // we needed that ID to do something
                 reason_update_entity($id, $this->user_id, $values, false);
                 $valid_file_html .= 'completed</li>';
             } else {
                 trigger_error('Unable to create image entity');
                 $valid_file_html .= '<li>Unable to import ' . $entry . '</li>';
             }
             sleep(1);
         }
         $valid_file_html .= '</ul>' . "\n";
         $num_image_string = count($this->files) == 1 ? '1 image has ' : count($this->files) . ' images have ';
         $valid_file_html .= '<p>' . $num_image_string . 'been successfully imported into Reason.</p>';
         $valid_file_html .= '<p>They are now pending.</p>';
         $next_steps[] = '<a href="?site_id=' . $site_id . '&amp;type_id=' . id_of('image') . '&amp;user_id=' . $this->user_id . '&amp;cur_module=Lister&amp;state=pending">review & approve imported images</a>';
     }
     if (isset($this->invalid_files)) {
         $invalid_files = array_keys($this->invalid_files);
         $invalid_file_html = '<p>The following could not be validated as image files and were not successfully imported.</p>';
         $invalid_file_html .= '<ul>';
         foreach ($invalid_files as $file) {
             $invalid_file_html .= '<li><strong>' . reason_htmlspecialchars($file) . '</strong></li>';
         }
         $invalid_file_html .= '</ul>';
     }
     $next_steps[] = '<a href="' . get_current_url() . '">Import another set of images</a>';
     if (!isset($this->invalid_files) && !isset($this->files)) {
         echo '<p>You did not select any files for upload</p>';
     }
     if (isset($valid_file_html)) {
         echo $valid_file_html;
     }
     if (isset($invalid_file_html)) {
         echo $invalid_file_html;
     }
     echo '<p>Next Steps:</p><ul><li>' . implode('</li><li>', $next_steps) . '</li></ul>';
     $this->show_form = false;
 }
Exemple #21
0
function login_data()
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookies']);
    curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['uagent']);
    curl_setopt($ch, CURLOPT_URL, "https://plus.google.com/");
    curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookies']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $buf = utf8_decode(html_entity_decode(curl_exec($ch)));
    curl_close($ch);
    echo "\n[+] Sending GET request to: https://plus.google.com/\n\n";
    $toreturn = '';
    $doc = new DOMDocument();
    $doc->loadxml($buf);
    $inputs = $doc->getElementsByTagName('input');
    foreach ($inputs as $input) {
        switch ($input->getAttribute('name')) {
            case 'Email':
                $toreturn .= 'Email=' . urlencode($GLOBALS['email']) . '&';
                break;
            case 'Passwd':
                $toreturn .= 'Passwd=' . urlencode($GLOBALS['pass']) . '&';
                break;
            default:
                $toreturn .= $input->getAttribute('name') . '=' . urlencode($input->getAttribute('value')) . '&';
        }
    }
    // return array (string postdata, string postaction)
    return array(tidy($toreturn), $doc->getElementsByTagName('form')->item(0)->getAttribute('action'));
}
Exemple #22
0
    }
    $query = substr($query, 2);
    $query = "UPDATE wu SET {$query} WHERE node_id = {$node_id} AND wu_by = {$session->user_no}; ";
} else {
    $fields = "";
    $values = "";
    if (!isset($node_id) || $node_id == 0) {
        $query = "SELECT nextval('infonode_node_id_seq');";
        $rid = awm_pgexec($dbconn, $query, "wu-action", false);
        if ($rid) {
            $node_id = pg_Result($rid, 0, 0);
            $query = "INSERT INTO infonode (node_id, nodename, created_by) ";
            $query .= "VALUES( {$node_id}, '" . tidy($nodename) . "', {$session->user_no} );";
            $rid = awm_pgexec($dbconn, $query, "wu-action", false);
        }
    }
    $new['node_id'] = $node_id;
    $new['wu_by'] = $session->user_no;
    reset($new);
    foreach ($new as $key => $value) {
        $fields .= ", {$key}";
        $values .= ", '" . tidy($value) . "' ";
    }
    $fields = substr($fields, 2);
    $values = substr($values, 2);
    $query = "INSERT INTO wu ({$fields}) VALUES({$values}); ";
}
$rid = awm_pgexec($dbconn, $query, "wu-action", false);
$rid = awm_pgexec($dbconn, "COMMIT", "wu-action", true);
$because .= "<H2>Writeup Details Changed</H2>";
$seq = intval($new['seq']);
----------------------------------------------------------- */
date_default_timezone_set("Europe/London");
define("SECOND", 1);
define("MINUTE", 60 * SECOND);
define("HOUR", 60 * MINUTE);
define("DAY", 24 * HOUR);
define("MONTH", 30 * DAY);
$epoch = time();
$json = file_get_contents("http://polling.bbc.co.uk/radio/realtime/bbc_6music.jsonp?cachebash={$epoch}");
$json = str_replace(array('realtimeCallback(', ')'), '', $json);
$np = json_decode($json, true);
$id = $np['realtime']['musicbrainz_artist']['id'];
$start = $np['realtime']['start'];
$end = $np['realtime']['end'];
$artist = tidy($np['realtime']['artist']);
$song = tidy($np['realtime']['title']);
function tidy($str)
{
    // return str_replace("'", "’", htmlspecialchars($str));
    return str_replace("'", "’", $str);
}
$img = "http://static.bbci.co.uk/music/images/artists/126x71/{$id}.jpg";
$timestamp = relativeTime($start, $end);
$growlnotifyinstalled = shell_exec("command -v /usr/local/bin/growlnotify >/dev/null 2>&1 || { echo 'nogrowlnotify'; exit 1; }");
$ql = '“';
$qr = '”';
$msg = "{$ql}{$song}{$qr}\n{$artist}\n\n{$timestamp}";
$pngs = glob('*.png');
$icon = getcwd() . '/' . $pngs[0];
// $growlnotifyinstalled = '';	//disable growlnotify
if ($growlnotifyinstalled) {