function init($args = array())
 {
     if ($this->params['force_secure'] && HTTPS_AVAILABLE && !on_secure_page()) {
         header('Location: ' . get_current_url(securest_available_protocol()));
         exit(0);
     }
     // Check for an existing database connection so we can restore it when we're done
     $this->db_conn = get_current_db_connection_name();
 }
 function where_to()
 {
     $pass = array('site_id', 'type_id', 'creation_date_start', 'creation_date_end', 'name_contains');
     $params = array();
     foreach ($pass as $element) {
         if ($val = $this->get_value($element)) {
             $params[] = $element . '=' . urlencode($val);
         }
     }
     return securest_available_protocol() . '://' . REASON_HOST . REASON_HTTP_BASE_PATH . 'scripts/move/move_entities_among_sites_2.php' . '?' . join('&', $params);
 }
 function run($send_header = true)
 {
     $hit = false;
     if (!empty($this->request['url'])) {
         //echo $this->request['url'];
         $url = str_replace('"', '', $this->request['url']);
         $site_id = get_site_id_from_url($url);
         //echo $site_id;
         $type_feed_text = get_feed_as_text(array('site_id' => $site_id, 'type_id' => id_of('type'), 'feed' => 'editor_types'));
         //echo $type_feed_text;
         $type_links = get_links_from_rss_string($type_feed_text);
         foreach ($type_links as $link) {
             $parsed_url = parse_url($link);
             parse_str($parsed_url['query'], $parsed_query);
             $entity_feed_text = get_feed_as_text($parsed_query);
             $entity_links = get_links_from_rss_string($entity_feed_text);
             //pray($entity_links);
             if (in_array($this->request['url'], $entity_links) || in_array('http://' . REASON_HOST . $this->request['url'], $entity_links)) {
                 $hit = true;
                 break;
             }
         }
     }
     if ($send_header) {
         header('Content-type: text/xml');
     }
     echo '<?xml version="1.0" encoding="UTF-8"?>';
     echo '<rss version="2.0">' . "\n";
     echo '<channel>' . "\n";
     echo '<title>Reason Feed Finder</title>' . "\n";
     if ($hit) {
         echo '<item>' . "\n";
         echo '<title>site_feed</title>' . "\n";
         echo '<link>' . securest_available_protocol() . '://' . REASON_HOST . FEED_GENERATOR_STUB_PATH . '?type_id=' . id_of('type') . '&amp;site_id=' . $site_id . '&amp;feed=editor_types</link>' . "\n";
         echo '</item>' . "\n";
         echo '<item>' . "\n";
         echo '<title>type_feed</title>' . "\n";
         echo '<link>' . str_replace('&', '&amp;', $link) . '</link>' . "\n";
         echo '</item>' . "\n";
         echo '<item>' . "\n";
         echo '<title>url_requested</title>' . "\n";
         echo '<link>' . str_replace('&', '&amp;', $this->request['url']) . '</link>' . "\n";
         echo '</item>' . "\n";
     }
     echo '</channel>' . "\n";
     echo '</rss>' . "\n";
 }
Exemplo n.º 4
0
 /**
  * The destination page should only be on a host that this login page is allowed to serve
  * (defaults to local host).
  *
  */
 protected function localize_destination_page()
 {
     if ($this->dest_page) {
         $current_parts = parse_url(get_current_url());
         $parts = parse_url($this->dest_page);
         if ($parts['host'] != $current_parts['host'] && !in_array($parts['host'], $this->params['allowable_domains'])) {
             return '';
         }
         $host = $parts['host'];
         $port = isset($parts['port']) && !empty($parts['port']) ? ":" . $parts['port'] : '';
         $query = isset($parts['query']) && !empty($parts['query']) ? '?' . $parts['query'] : '';
         $fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
         return securest_available_protocol() . '://' . $host . $port . $parts['path'] . $query . $fragment;
     }
 }
Exemplo n.º 5
0
/**
 *	Get the URL of a page
 *
 *	This function will provide the URL of a page of a particular type or types on a site
 *
 *	@param entity $site The site to look in
 *	@param page_tree $tree the page tree object for the site; this must be already initialized
 *	@param mixed $page_types The array of page types or string indicating single page type that is/are acceptable
 *	@param boolean $as_uri Returns a fully qualified URI if true; otherwise returns a URL relative to web root
 *	@param boolean $secure Uses https if true. This parameter only has an effect if $as_uri is true.
 */
function get_page_link(&$site, &$tree, $page_types, $as_uri = false, $secure = false)
{
    if (empty($site) || empty($page_types)) {
        trigger_error('site and page types must all be passed to get_page_link', EMERGENCY);
    } elseif (is_string($page_types)) {
        $page_types = array($page_types);
    } elseif (!is_array($page_types)) {
        trigger_error('$page_types must be an array or string', EMERGENCY);
    }
    $relations = array();
    $es = new entity_selector($site->id());
    $es->add_type(id_of('minisite_page'));
    foreach ($page_types as $page_type) {
        $relations[] = 'page_node.custom_page = "' . $page_type . '"';
    }
    $es->add_relation('(' . implode(' or ', $relations) . ')');
    $es->set_num(1);
    $pages = $es->run_one();
    if (!empty($pages)) {
        $page = current($pages);
        if (!empty($tree)) {
            $ret = $tree->get_full_url($page->id(), $as_uri, $secure);
        } else {
            $ret = build_URL($page->id());
        }
    } else {
        $ret = $site->get_value('base_url');
    }
    if ($as_uri && empty($pages)) {
        if ($secure) {
            $ret = securest_available_protocol() . '://' . REASON_HOST . $ret;
        } else {
            $ret = 'http://' . REASON_HOST . $ret;
        }
    }
    return $ret;
}
Exemplo n.º 6
0
function created_admin_HTML($password)
{
    echo '<h3>Admin User Created</h3>';
    echo '<p>The reason user <strong>admin</strong> has been created with password <strong>' . $password . '</strong></p>';
    echo '<p><strong>Write down the password!</strong> This script will not create another admin user unless the original is deleted.</p>';
    echo '<p>You should now be able to login to the <a href="' . securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '">reason administrative interface</a>.</p>';
}
 function get_classified_entity_link_string()
 {
     $protocol = securest_available_protocol();
     $site_id = $this->get_site_id();
     $classified_id = $this->get_classified_id();
     $type_id = id_of('classified_type');
     $link = $protocol . '://' . REASON_WEB_ADMIN_PATH . '?' . 'site_id=' . $site_id . '&type_id=' . $type_id . '&id=' . $classified_id . '&cur_module=Editor';
     return $link;
 }
 /**
  * Creates and sends the notification that a file has been imported
  * Respects the following constants:
  * NOTIFY_WHEN_MEDIA_IS_IMPORTED, MEDIA_FILESIZE_NOTIFICATION_THRESHOLD, MEDIA_NOTIFICATION_EMAIL_ADDRESSES
  */
 function send_email_notification()
 {
     if (NOTIFY_WHEN_MEDIA_IS_IMPORTED && $this->manager->get_value('media_size_in_bytes') >= MEDIA_FILESIZE_NOTIFICATION_THRESHOLD) {
         if (defined('MEDIA_NOTIFICATION_EMAIL_ADDRESSES')) {
             $message = 'Media File Imported' . "\n\n";
             $message .= 'Name:' . "\n" . $this->manager->get_value('name') . "\n\n";
             $site = new entity($this->manager->get_value('site_id'));
             $message .= 'Site:' . "\n" . $site->get_value('name') . "\n\n";
             $user = new entity($this->manager->admin_page->user_id);
             $message .= 'Imported by:' . "\n" . $user->get_value('name') . "\n\n";
             $message .= 'URL:' . "\n" . $this->manager->get_value('url') . "\n\n";
             $message .= 'Metadata:' . "\n" . $this->manager->get_value('url') . '.txt' . "\n\n";
             $message .= 'Preview:' . "\n";
             $message .= securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '?site_id=' . $this->manager->get_value('site_id') . '&type_id=' . id_of('av_file') . '&id=' . $this->manager->get_value('id') . '&cur_module=Preview';
             mail(MEDIA_NOTIFICATION_EMAIL_ADDRESSES, '[Reason] Media file imported on ' . REASON_HOST, $message);
         } else {
             trigger_error('NOTIFY_WHEN_MEDIA_IS_IMPORTED set to true, but MEDIA_NOTIFICATION_EMAIL_ADDRESSES not provided. MEDIA_NOTIFICATION_EMAIL_ADDRESSES must be added as a constant in the settings file in order to receive media import notices');
         }
     }
 }
Exemplo n.º 9
0
	function do_notifications()
	{
		if($this->publication->get_value('notify_upon_post'))
		{
			$subject = 'New post on '.strip_tags($this->publication->get_value('name'));
			$message = 'A post has beeen added to '.strip_tags($this->publication->get_value('name'));
			$message .= ' on the site '.strip_tags($this->site_info->get_value('name')).'.';
			$message .= "\n\n";

			if($this->hold_posts_for_review)
			{
				$message .= 'This post is currently held for review. Review this post:'."\n\n";
				$message .= securest_available_protocol().'://'.REASON_WEB_ADMIN_PATH.'?site_id='.$this->site_info->id().'&type_id='.id_of('news').'&id='.$this->new_post_id."\n\n";
			}
			else
			{
				$message .= 'View post:'."\n\n";
				$message .= carl_construct_link(array('story_id'=>$this->new_post_id));
			}

			include_once(TYR_INC.'email.php');
			$e = new Email($this->publication->get_value('notify_upon_post'), WEBMASTER_EMAIL_ADDRESS, WEBMASTER_EMAIL_ADDRESS, $subject, $message);
			$e->send();
		}
	}
Exemplo n.º 10
0
$string = array();
$count = array();
$link = array();
$es = new entity_selector();
$es->add_type(id_of('type'));
$result = $es->run_one();
foreach ($result as $a_type) {
    $a_type_name = $a_type->get_value('name');
    $all_types[$a_type_name] = $a_type_name;
}
while ($row = mysql_fetch_assoc($r)) {
    $e1 = new entity($row['site']);
    $e2 = new entity($row['type']);
    $site_name = $e1->get_value('name');
    $type_name = $e2->get_value('name');
    $thelink = '<a href="' . securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '?site_id=' . $row['site'] . '&type_id=' . $row['type'] . '&user_id=' . $row['user'] . '">' . $type_name . '</a>';
    $string[$type_name][] = $site_name;
    $link[$type_name][] = $thelink;
    unset($all_types[$type_name]);
}
foreach ($string as $k => $v) {
    $proceed = false;
    $count = count($v);
    while ($proceed == false) {
        $num = rand(0, $count - 1);
        if ($v[$num] != 'MASTER ADMIN') {
            $proceed = true;
        } else {
            if ($count == 1) {
                $proceed = true;
            }
Exemplo n.º 11
0
 function make_link_to_site_feed($id)
 {
     return securest_available_protocol() . '://' . REASON_HOST . FEED_GENERATOR_STUB_PATH . '?type_id=' . id_of('type') . '&site_id=' . $id . '&feed=editor_types';
 }
Exemplo n.º 12
0
 function _test_and_copy()
 {
     if (filesize($this->test_file) > 0) {
         // here, we test to see if the .htaccess file is actually valid.
         // To do this, we copy the new file to a test directory, then hit
         // a file in that directory and see if the file loads or if there
         // is an Internal Server Error of type 500.  If we have a server
         // error, that means the file is not valid and someone needs to
         // look at it.
         $tmp_valid_file = REASON_TEMP_DIR . uniqid('htvalid');
         // create a quick test file to see if it shows up
         $test_file_name = 'testfile.txt';
         $tmp_test_file = $this->test_dir_name . '/' . $test_file_name;
         $fp = fopen($this->test_full_base_url . '/' . $tmp_test_file, 'w') or trigger_error('Unable to create test index file', HIGH);
         fputs($fp, 'test successful') or trigger_error('Unable to write to test index file', HIGH);
         fclose($fp) or trigger_error('Unable to close test index file', HIGH);
         $url = securest_available_protocol() . '://' . REASON_HOST . $this->test_web_base_url . $tmp_test_file;
         $url_contents = get_reason_url_contents($url);
         $fp2 = fopen($tmp_valid_file, 'w') or trigger_error('Unable to create file at ' . $tmp_valid_file, HIGH);
         fwrite($fp2, $url_contents) or trigger_error('Unable to write to file at ' . $tmp_valid_file, HIGH);
         fclose($fp2) or trigger_error('Unable to close file at ' . $tmp_valid_file, HIGH);
         // compare the test index page with the downloaded one
         $diff_cmd = 'diff --brief ' . $this->test_dir . '/' . $test_file_name . ' ' . $tmp_valid_file;
         exec($diff_cmd, $diff_result, $diff_return_var);
         if ($diff_return_var > 1) {
             trigger_error('Unable to determine if .htaccess validates or not - diff failed with return code ' . $diff_return_var, HIGH);
         }
         if (unlink($tmp_valid_file) === FALSE) {
             trigger_error('Unable to delete tmp ht valid file', WARNING);
         }
         // if empty, file did not validate
         if ($diff_result) {
             trigger_error('.htaccess file did not validate.', HIGH);
         }
         // make a backup of the original file
         if (!empty($orig)) {
             if (copy($this->orig_file, $this->orig_file . '.bak') === FALSE) {
                 trigger_error('Unable to make a backup of the current htaccess', WARNING);
             }
             // chmod so we can later write over the file
             if (chmod($this->orig_file . '.bak', 0666) === FALSE) {
                 trigger_error('Could not chmod the backup htaccess file', WARNING);
             }
         }
         // move the new file to the old position atomically
         // rename doesn't work right under windows PHP when the destination file exists ... so we use a fallback
         // added attempt to copy & unlink -cf 8/8/2007
         if (rename($this->test_file, $this->orig_file) === FALSE) {
             if (copy($this->test_file, $this->orig_file) === FALSE) {
                 trigger_error('Unable to rename new rewrites file over old file', HIGH);
             } else {
                 unlink($this->test_file);
             }
         }
         // make it world writable so anyone can add rules or other stuff if need be
         if (!chmod($this->orig_file, 0666)) {
             trigger_error('Unable to chmod htaccess file', WARNING);
         }
         // remove test temp index file
         if (!unlink($this->test_full_base_url . $tmp_test_file)) {
             trigger_error('Unable to remove temporary test file.', WARNING);
         }
     } else {
         trigger_error('New rewrite .htaccess file has size 0.  Aborting rewrite updates.', HIGH);
     }
     $this->debug('<strong>Updates complete.</strong>');
 }
// lets zap the nav cache if we are moving pages.
if ($type_name == 'minisite_page') {
    $job = new MoveEntitiesNavCacheJob();
    $job->config('site_ids', $site_ids);
    $job_stack->add_job($job);
}
$result = $job_stack->run();
echo '<!DOCTYPE html>';
echo '<html><head>';
echo '<title>Reason: Move Entities Among Sites: Done</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
if (defined('UNIVERSAL_CSS_PATH') && UNIVERSAL_CSS_PATH != '') {
    echo '<link rel="stylesheet" type="text/css" href="' . UNIVERSAL_CSS_PATH . '" />' . "\n";
}
echo '<link rel="stylesheet" type="text/css" href="' . REASON_HTTP_BASE_PATH . 'css/reason_admin/move_entities.css" />' . "\n";
echo '</head><body>';
echo '<h1>Move Entities Among Sites</h1>';
if ($result) {
    echo '<p>Successfully moved entities! Now, you may ' . '<a href="' . securest_available_protocol() . '://' . REASON_HOST . REASON_HTTP_BASE_PATH . 'scripts/move/move_entities_among_sites.php">' . 'move other entities among sites</a> ' . 'or <a href="' . securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '">return to Reason admin</a>.</p>';
    echo '<p><strong>Please note:</strong> This script has done the particulars outlined in the report. There may be more you have to do yourself. For instance,
	        if you moved page(s), you\'ll need to attach them to the new page tree before they will show up.</p>';
} else {
    echo '<p>Your move entities job was not completed successfully. Please look carefully at the report to see what you may need to change.</p>';
}
if (isset($_SESSION['move_entities_among_sites__http_referer'])) {
    unset($_SESSION['move_entities_among_sites__http_referer']);
}
echo '<h3>Full Report</h3>';
$report = $job_stack->get_report();
echo $report;
echo '</body></html>';
Exemplo n.º 14
0
 function make_link_to_feed_of_type($id)
 {
     $type = new entity($id);
     return securest_available_protocol() . '://' . REASON_HOST . FEED_GENERATOR_STUB_PATH . '?type_id=' . $id . '&site_id=' . $this->restricted_site_id . '&feed=editor_links_for_' . $type->get_value('unique_name');
 }
Exemplo n.º 15
0
<?php

/**
 * The Reason upgrade index page
 * @package reason
 * @subpackage scripts
 */
/** 
 * The old code for this produced an automatic listing, but not a pretty one - also not in the right order.
 * 
 * In any case, we now maintain an upgrade page manually ... lets just use it.
 */
include_once 'reason_header.php';
$path = securest_available_protocol() . '://' . REASON_HOST . REASON_HTTP_BASE_PATH . 'upgrade.php';
header("Location: " . $path);
exit;
Exemplo n.º 16
0
 function check_errors($user)
 {
     $error_messages = array('site_is_site' => 'You have requested an invalid site.', 'site_to_type' => 'This site does not have access to this type.', 'type_to_id' => 'The entity you have chosen does not match the type.', 'site_owns_id' => 'This site does not own this entity.');
     $message = '';
     $site = new entity($this->site_id);
     if (!reason_is_entity($site, 'site')) {
         $message = $error_messages['site_is_site'];
     } elseif (!$this->verify_user($user)) {
         header('Location: ' . securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '?cur_module=SiteAccessDenied&user_id=' . $user->id() . '&requested_url=' . urlencode(get_current_url()));
     } elseif (!$this->site_to_type()) {
         $message = $error_messages['site_to_type'];
     } elseif (!$this->type_to_id()) {
         $message = $error_messages['type_to_id'];
     } elseif (!$this->site_owns_id()) {
         $message = $error_messages['site_owns_id'];
     }
     if ($message) {
         ob_flush();
         $link = 'index.php';
         if ($this->user_id) {
             $link .= '?user_id=' . $this->user_id;
         }
         die($message . '  <a href="' . $link . '">Reason Home</a>.');
     }
 }
Exemplo n.º 17
0
 function get_edit_site_link()
 {
     $qs = carl_construct_query_string(array('site_id' => $this->site_id));
     return securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . $qs;
 }
Exemplo n.º 18
0
	function do_notifications()
	{
		if($this->publication->get_value('notify_upon_comment'))
		{
			$subject = 'New comment on '.strip_tags($this->publication->get_value('name'));
			$message = 'A comment has beeen added to the post '.strip_tags($this->news_item->get_value('name'));
			$message .= ' on '.strip_tags($this->publication->get_value('name'));
			$message .= ' (site: '.strip_tags($this->site_info->get_value('name')).'.)';
			$message .= "\n\n";
			if($this->hold_comments_for_review)
			{
				$message .= 'This comment is currently held for review.'."\n\n";
				$message .= 'Review comment:'."\n";
			}
			else
			{
				$message .= 'View this comment in context:'."\n";
				$message .= get_current_url().'#comment'.$this->comment_id."\n\n";
				$message .= 'Manage this comment:'."\n";
			}
			$message .= securest_available_protocol().'://'.REASON_WEB_ADMIN_PATH.'?site_id='.$this->site_info->id().'&type_id='.id_of('comment_type').'&id='.$this->comment_id."\n\n";
			
			include_once(TYR_INC.'email.php');
			$e = new Email($this->publication->get_value('notify_upon_comment'), WEBMASTER_EMAIL_ADDRESS, WEBMASTER_EMAIL_ADDRESS, $subject, $message);
			$e->send();
		}
	}
Exemplo n.º 19
0
 /**
  * Gets the full url of the page
  *
  * If the page is an external link, this method returns the page's url value.
  * 
  * Otherwise, it returns a url that conforms to the parameters given.
  * This method pays attention to the textonly value of the page tree object, and appends that value if it exists.
  *
  * @param integer $id The ID of the page
  * @param boolean $as_uri If true, provides a fully qualified URL (e.g. a URI, like: http://www.somesite.com/sitebase/page/path/) If false, provides a URL relative to the base of the server
  * @param boolean $secure If true, uses https; otherwise uses http. This param only has an effect if $as_uri is true
  * @return string The url of the page
  */
 function get_full_url($id, $as_uri = false, $secure = false)
 {
     if (empty($this->values[$id])) {
         return false;
     } else {
         $item =& $this->values[$id];
         if (!$item->get_value('url')) {
             $link = $this->get_url_from_base($id);
             if (!empty($this->textonly)) {
                 $link .= '?textonly=1';
             }
             if ($as_uri) {
                 if ($secure) {
                     $link = securest_available_protocol() . '://' . REASON_HOST . $link;
                 } else {
                     $link = 'http://' . REASON_HOST . $link;
                 }
             }
         } else {
             $link = $item->get_value('url');
         }
         return $link;
     }
 }
Exemplo n.º 20
0
 /**
  * The destination page should only be on the same server as the login page ... this function makes sure that is the case
  * @author Nathan White
  */
 function localize_destination_page()
 {
     if ($this->dest_page) {
         $current_parts = parse_url(get_current_url());
         $parts = parse_url($this->dest_page);
         $port = isset($parts['port']) && !empty($parts['port']) ? ":" . $parts['port'] : '';
         $query = isset($parts['query']) && !empty($parts['query']) ? '?' . $parts['query'] : '';
         $fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
         return securest_available_protocol() . '://' . $current_parts['host'] . $port . $parts['path'] . $query . $fragment;
     }
 }
Exemplo n.º 21
0
<?php

/**
 * This script used to do image importing.
 *
 * It is left in place so that people with bookmarks do not get a 404
 *
 * At some point it will probably be OK to remove
 *
 * @package reason
 * @subpackage scripts
 */
include_once 'reason_header.php';
echo '<!DOCTYPE html>' . "\n";
echo '<html>' . "\n" . '<head>' . "\n" . '<title>Import Images Into Reason</title>' . "\n";
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
if (defined('UNIVERSAL_CSS_PATH') && UNIVERSAL_CSS_PATH != '') {
    echo '<link rel="stylesheet" type="text/css" href="' . UNIVERSAL_CSS_PATH . '" />' . "\n";
}
echo '<style type="text/css">body { margin:1.5em; }</style>' . "\n";
echo '</head>' . "\n";
echo '<body>' . "\n";
echo '<h1>Batch Import Images Into Reason</h1>';
echo '<p>This tool has been moved. In Reason there is a link titled "Batch Import Images" under every "Add Image" link.</p>' . "\n";
echo '<p><a href="' . securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '">Go to Reason</a></p>' . "\n";
echo '</body>' . "\n" . '</html>';
Exemplo n.º 22
0
 function get_edit_project_link($item_id)
 {
     return '<p><a href="' . securest_available_protocol() . '://' . REASON_WEB_ADMIN_PATH . '?site_id=' . $this->parent->site_id . '&type_id=' . id_of('project') . '&id=' . $item_id . '">Edit this project</a></p>' . "\n";
 }