function run_error_checks()
 {
     $name = trim($this->display_name);
     if (empty($name)) {
         $name = $this->name;
     }
     $name = prettify_string($name);
     $username = reason_require_authentication();
     $password = $this->grab_value();
     $dir = new directory_service();
     if (!$dir->authenticate($username, $password)) {
         $this->set_error($name . ':  Please check your password.');
     }
 }
 /**
  * Ensure that the user is an admin with access to the master admin site.
  */
 function authenticate()
 {
     if (!isset($this->authenticated)) {
         if (!empty($this->admin_page->user_id)) {
             $user_id = $this->admin_page->user_id;
             $user = new entity($user_id);
             $user_netid = $user->get_value('name');
         } else {
             $user_netid = reason_require_authentication();
             $user_id = get_user_id($user_netid);
         }
         if (reason_user_has_privs($user_id, 'manage_allowable_relationships')) {
             $user_man = new User();
             $this->authenticated = $user_man->is_site_user($user_netid, id_of('master_admin'));
         }
     }
     return $this->authenticated;
 }
Ejemplo n.º 3
0
    {
        $date_2 = date_create($date_2);
        $temp = date_create($date_1);
        $count = 0;
        while ($temp < $date_2 && $count < 500) {
            $temp->modify('+1 day');
            $count++;
        }
        return $count;
    }
}
// Checks for user, requires authentication for non-cli users.
if (PHP_SAPI == 'cli') {
    $user = '******';
} else {
    $user = reason_require_authentication();
    $reason_user_id = get_user_id($user);
    if (!reason_user_has_privs($reason_user_id, 'db_maintenance')) {
        die('Access denied.' . "\n");
    }
}
// Creates a list of the  publications with reminder_days set above 0.
$es = new entity_selector();
$es->add_type(id_of('publication_type'));
$es->add_relation('`reminder_days` > 0');
$publications = $es->run_one();
// For each publication, make sure the site owning it is live, then create a reminder, set pulication for that reminder, and run the remind function.
foreach ($publications as $pub_id => $pub) {
    $sites = $pub->get_right_relationship('site_owns_publication_type');
    $to_show = false;
    foreach ($sites as $index => $site) {
Ejemplo n.º 4
0
 function get_user_id()
 {
     static $user_id;
     if (!isset($user_id)) {
         $user_netid = reason_require_authentication();
         $user_id = get_user_id($user_netid);
     }
     return $user_id;
 }
Ejemplo n.º 5
0
 /** 
  * Sets up the authenticated_user_id class variable
  * @return authenticated_user_id
  */
 function authenticate()
 {
     if ($this->authenticated_user_id == false) {
         $user_netid = reason_require_authentication();
         $this->authenticated_user_id = empty($user_netid) ? false : get_user_id($user_netid);
     }
     return $this->authenticated_user_id;
 }
 *
 * This script will change the name of the event.repeat field to
 * event.recurrence so that Reason can be run under MySQL 5.x
 *
 * @package reason
 * @subpackage scripts
 */
/**
 * include dependencies
 */
include_once 'reason_header.php';
include_once CARL_UTIL_INC . '/db/db.php';
reason_include_once('classes/entity_selector.php');
reason_include_once('function_libraries/user_functions.php');
connectDB(REASON_DB);
$current_user = reason_require_authentication();
$cur_user_id = get_user_id($current_user);
if (empty($cur_user_id)) {
    die('valid Reason user required');
}
if (!reason_user_has_privs($cur_user_id, 'upgrade')) {
    die('You must have upgrade privileges to run this script');
}
$es = new entity_selector();
$es->add_type(id_of('content_table'));
$es->add_relation('entity.name = "event"');
$es->set_num(1);
$tables = $es->run_one();
if (empty($tables)) {
    $msg = 'Not able to find event entity table. Not able to proceed.';
    echo $msg;
Ejemplo n.º 7
0
 /**
  *
  */
 function get_user_netid()
 {
     if (!isset($this->_user_netid)) {
         $netid = reason_require_authentication();
         $requested_netid = THIS_IS_A_DEVELOPMENT_REASON_INSTANCE && isset($_REQUEST['netid']) ? $_REQUEST['netid'] : '';
         if (!empty($requested_netid) && !empty($netid) && $requested_netid != $netid) {
             $user_id = get_user_id($netid);
             if (reason_user_has_privs($user_id, 'pose_as_other_user')) {
                 $this->_user_netid = $requested_netid;
             }
         } else {
             $this->_user_netid = $netid;
         }
     }
     return $this->_user_netid;
 }
	function init($table_id = false, $table_name = false)
	{
		if ($table_id) $this->set_table_id($table_id);
		if ($table_name) $this->set_table_name($table_name);
		$this->user_id = get_user_id(reason_require_authentication());
	}
Ejemplo n.º 9
0
 /**
  * The old form module supported a force_login parameter - we will continue to support it though really the models
  * are probably a better place to force login.
  *
  * @access private
  */
 function _check_force_login_parameter()
 {
     if ($this->params['force_login']) {
         reason_require_authentication('form_login_msg');
     }
 }
Ejemplo n.º 10
0
 /**
  * determines whether or not authentication is necessary for a particular asset
  * and whether the current user is a member of the group that has access
  * @return boolean true if the user has access
  */
 function access_allowed()
 {
     $es = new entity_selector();
     $es->add_right_relationship($this->asset->id(), relationship_id_of('asset_access_permissions_to_group'));
     $es->add_type(id_of('group_type'));
     $es->set_num(1);
     $groups = $es->run_one();
     if (empty($groups)) {
         return true;
     }
     $group = current($groups);
     $gh = new group_helper();
     $gh->set_group_by_entity($group);
     $access = $gh->is_username_member_of_group("") ? true : $gh->is_username_member_of_group($this->get_username());
     // else discover and check username
     if ($access === NULL) {
         reason_require_authentication('login_to_access_file');
         die;
     }
     return $access;
     // true or false
 }
Ejemplo n.º 11
0
	function set_user_requested_admin($boolean)
	{
		if ($boolean == true)
		{
			if ($this->admin_requires_login()) reason_require_authentication();
		}
		$this->_user_requested_admin = $boolean;
	}
Ejemplo n.º 12
0
 * @todo remove fallback check to DISABLE_REASON_LOGIN by the release of RC 1
 */
//xdebug_start_trace();
//xdebug_start_profiling();
function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
$_page_timing_start = getmicrotime();
// admin site needs sessioning
// $reason_session = true;
include_once 'reason_header.php';
reason_include_once('function_libraries/user_functions.php');
force_secure_if_available();
$authenticated_user_netid = reason_require_authentication('admin_login');
$auth_user_id = get_user_id($authenticated_user_netid);
if ($auth_user_id && isset($_GET['do']) && ($_GET['do'] === 'moveup' || $_GET['do'] === 'movedown')) {
    if (reason_user_has_privs($auth_user_id, 'pose_as_other_user')) {
        if (!empty($_GET['user_id'])) {
            $user_id = (int) $_GET['user_id'];
            if (!empty($user_id)) {
                $e = new entity($user_id);
                if ($e->get_value('type') == id_of('user')) {
                    $user_netid = $e->get_value('name');
                }
            }
        }
    }
    $user_netid = isset($user_netid) ? $user_netid : $authenticated_user_netid;
    reason_include_once('classes/admin/rel_sort.php');
Ejemplo n.º 13
0
 * -- Updated 5/20/09 integration with table admin, report on #s, reduced false positives, uses entity selector API
 *
 * @author Nathan White 
 * @package reason
 * @subpackage scripts
 */
/**
 * include dependencies
 */
include_once 'reason_header.php';
reason_include_once('classes/entity_selector.php');
reason_include_once('function_libraries/user_functions.php');
reason_include_once('minisite_templates/page_types.php');
reason_include_once('classes/page_types.php');
include_once CARL_UTIL_INC . 'db/table_admin.php';
if (reason_require_authentication() && !reason_check_privs('view_sensitive_data')) {
    die('<h1>Sorry.</h1><p>You do not have permission to view page types.</p></body></html>');
}
echo '<!DOCTYPE html>' . "\n";
echo '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
echo '<head>' . "\n";
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
echo '<title>Reason Page Types</title>' . "\n";
echo '<link rel="stylesheet" type="text/css" href="' . REASON_HTTP_BASE_PATH . 'css/forms/form_data.css" />' . "\n";
echo '</head>' . "\n";
echo '<body>' . "\n";
echo '<h2>Page Type Information</h2>';
echo '<p>This table shows information about each page type defined in the Reason instance. For each page type that is assigned to a live page,
         a random url is generated. This module can help you verify that page types are working properly, or to identify page types that are
         not being used and should perhaps be deleted.</p>';
$es = new entity_selector();
include_once CARL_UTIL_INC . '/db/db.php';
reason_include_once('classes/entity_selector.php');
reason_include_once('function_libraries/user_functions.php');
connectDB(REASON_DB);
/**
*	9/1/2006
*
*   this script updates a reason 4 database for relationship sorting (if needed) and sets up relationship sorting for a particular allowable relationship
*
*	specifically, it does the following
*	- changes the name of the sort_order column in the relationship table to rel_sort_order (if this hasn't been done)
* 	- establishes an initial relationship sort order two related types
*	- makes the relationship sortable in the allowable relationships table
*	@author nathan white
*/
$current_user = $user_netID = reason_require_authentication();
$reason_user_id = get_user_id($user_netID);
if (empty($reason_user_id)) {
    die('valid Reason user required');
}
if (!reason_user_has_privs($reason_user_id, 'upgrade')) {
    die('You must have upgrade privileges to run this script');
}
ini_set('max_execution_time', 1800);
ini_set('mysql_connect_timeout', 1200);
ini_set("memory_limit", "256M");
//////////////////////////////////////////////
//////////////// CONFIGURATION ///////////////
//////////////////////////////////////////////
$test_mode = false;
// switch to true to actually make database changes
Ejemplo n.º 15
0
	/**
	 * Does the following:
	 *
	 * If a form_id has been provided, return true if the user has access to it.
	 *
	 * @todo how are forms that do not require login handled?
	 */
	function form_id_is_valid($form_id)
	{
		$user_netid = $this->get_user_netid();
		if ($form_id && $user_netid) // only attempt retrieval if user is logged in!
		{
			$qry = $this->get_select_by_key_sql($form_id, 'id');
			$result = $this->perform_query($qry);
			return true;
		}
		elseif ($form_id && !$user_netid && $this->is_editable()) reason_require_authentication();
		elseif ($form_id == "0") // a form_id of 0 is valid if the user is allowed to create new entries
		{
			if ($this->form_allows_multiple()) return true;
		}
		return false;
		// consider redirect cases
		$user_netid = $this->get_user_netid();
		$user_submissions = (!empty($user_netid)) ? $this->get_values_for_user($user_netid) : false;
		
		// redirect case 1 - user logged in, editable form, multiples not allowed, valid row exists
		if ($this->is_editable() && !$this->form_allows_multiple() && !empty($user_submissions))
		{
			$redirect_form_id = max(array_keys($user_submissions)); // highest id in the user submissions array
		}
		elseif ($form_id) // we have a form id but it was invalid
		{
			$redirect_form_id = '';
		}
		if (isset($redirect_form_id))
		{
			$redirect = carl_make_redirect(array('form_id' => $redirect_form_id));
			header("Location: " . $redirect);
			exit;
		}
	}
Ejemplo n.º 16
0
	/**
	 * init_issue_for_item checks the item and any issue id it was passed - if an issue does not exist or is
	 * invalid, the user is redirected to a url with the most recent valid issue for the item
	 */
	function init_issue()
	{
		$user_issue_keys = $all_issue_keys = array();
		$requested_issue = (!empty($this->request['issue_id'])) ? $this->request['issue_id'] : false;
		$requested_section = (!empty($this->request['section_id'])) ? $this->request['section_id'] : false;
		
		// if we have an item
		if ($this->current_item_id)
		{
			$issues =& $this->get_visible_issues_for_item();
			$user_issue_keys = (!empty($issues)) ? array_keys($issues) : false;
			$all_issues =& $this->get_all_issues();
			$all_issue_keys = array_keys($all_issues);
		}
		else
		{
			if ($requested_issue) 
			{
				$all_issues =& $this->get_all_issues();
				$user_issues =& $this->get_issues();
				$all_issue_keys = array_keys($all_issues);
				$user_issue_keys = array_keys($user_issues);
			}
			elseif ($this->_should_restrict_to_current_issue() ) // if no section requested set an issue_id
			{
				$most_recent_issue = $this->get_most_recent_issue();
				if ($most_recent_issue)
				{
					$this->issue_id = $most_recent_issue->id();
					$this->_add_css_urls_to_head($this->_get_issue_css($this->issue_id));
					return true;
				}
			}
		}	
		if ((!empty($user_issue_keys) || !empty($all_issue_keys))) // item is in an issue
		{
			if (!empty($user_issue_keys) && in_array($requested_issue, $user_issue_keys))
			{
				$this->issue_id = $requested_issue; // requested issue verified
				$this->_add_css_urls_to_head($this->_get_issue_css($this->issue_id));
				$issue_link = $this->get_links_to_issues();
				$issue = new entity($this->issue_id);
				$this->_add_crumb( $issue->get_value( 'name' ), $this->get_link_to_issue($issue) );
				if($requested_section)
				{
					$section = $this->get_current_section();
					if ($section)
					{
						$this->_add_crumb( $section->get_value( 'name' ), $this->get_link_to_section($section) );
					}
				}
				$this->item_specific_variables_to_pass['next_post'] = 'get_next_post';
				$this->item_specific_variables_to_pass['previous_post'] = 'get_previous_post';
				return true;
			}
			elseif (!empty($all_issue_keys) && in_array($requested_issue, $all_issue_keys))
			{
				if (!reason_check_authentication()) // person is not logged in, but could have access to a hidden issue - force login
				{
					reason_require_authentication();
				}
			}
			elseif (!empty($user_issue_keys))
			{
				$redirect = carl_make_redirect(array('issue_id' => array_shift($user_issue_keys)));
				header('Location: '.$redirect);
				exit;
			}
		}
	}
Ejemplo n.º 17
0
 *
 * @version alpha 1
 * @package reason
 * @subpackage scripts
 * @author Nathan White
 */
/**
 * Include dependencies
 */
include_once 'reason_header.php';
include_once DISCO_INC . 'controller.php';
reason_include_once('function_libraries/user_functions.php');
// Include the forms
reason_include_once('scripts/import/wordpress/SetupForm.php');
reason_include_once('scripts/import/wordpress/ConfirmForm.php');
$netid = reason_require_authentication();
// force login to a session
$reason_user_id = get_user_id($netid);
if (empty($reason_user_id)) {
    die('valid Reason user required');
} elseif (!reason_user_has_privs($reason_user_id, 'upgrade')) {
    die('You must have upgrade privileges to run this script');
} else {
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
    echo '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
    echo '<head>' . "\n";
    echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
    echo '</head>' . "\n";
    echo '<body>' . "\n";
    if (isset($_GET['report'])) {
        $link = carl_make_link(array('report' => ''));
Ejemplo n.º 18
0
// try to increase limits in case user chooses a really big chunk
set_time_limit(1800);
ini_set('max_execution_time', 1800);
ini_set('mysql_connect_timeout', 1200);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reason Upgrade: Miscellaneous 4.0b3 to 4.0b4 Updates</title>
</head>

<body>
<?php 
force_secure_if_available();
$GLOBALS['__cur_username__hack__'] = reason_require_authentication();
$usr = new user();
$user = $usr->get_user($GLOBALS['__cur_username__hack__']);
if ($user) {
    $GLOBALS['__cur_user_id_hack__'] = $user->id();
} else {
    echo 'You must be a valid reason user to run this script';
    die;
}
if (!reason_user_has_privs($GLOBALS['__cur_user_id_hack__'], 'upgrade')) {
    die('You must have upgrade privileges to run this script');
}
echo '<h2>Reason: Miscellaneous 4.0b3 to 4.0b4 Updates</h2>';
if (!isset($_POST['verify'])) {
    echo '<p>This script does a variety of minor updates to your Reason instance, including:</p>';
    echo '<ul>';
Ejemplo n.º 19
0
 * @subpackage scripts
 */
/**
 * include dependencies
 */
include_once 'reason_header.php';
reason_include_once('classes/page_types.php');
reason_include_once('minisite_templates/page_types.php');
reason_include_once('classes/session_php.php');
include_once DISCO_INC . 'controller.php';
if (!carl_is_php5()) {
    echo '<p>Sorry this requires php 5 for now</p>';
    die;
}
// Require that whomever is using the form have access.
reason_require_authentication('', 'session');
// Include all of the forms.
reason_include_once('scripts/developer_tools/page_type_wizard/SelectForm.php');
reason_include_once('scripts/developer_tools/page_type_wizard/EditForm.php');
reason_include_once('scripts/developer_tools/page_type_wizard/FormatForm.php');
//Initialize the controller and set a few options.
$controller = new FormController();
$controller->set_session_class('Session_PHP');
$controller->set_session_name('REASON_SESSION');
$controller->set_data_context('page_type_wizard');
$controller->show_back_button = true;
$controller->clear_form_data_on_finish = false;
$controller->allow_arbitrary_start = false;
// Set up the progression of forms.
$forms = array('SelectForm' => array('start_step' => true, 'next_steps' => array('EditForm' => array('label' => 'Select this page type')), 'step_decision' => array('type' => 'user')), 'EditForm' => array('next_steps' => array('FormatForm' => array('label' => 'Next')), 'step_decision' => array('type' => 'user')), 'FormatForm' => array('final_step' => array('label' => 'export')));
// Add, init, and run the forms.
Ejemplo n.º 20
0
        if ($this->mode == 'run') {
            $r_id = create_allowable_relationship(id_of('asset'), id_of('category_type'), 'asset_to_category', $this->asset_to_category_details);
            if ($r_id) {
                echo '<p>asset_to_category allowable relationship successfully created</p>' . "\n";
            } else {
                echo '<p>Unable to create asset_to_category allowable relationship</p>';
                echo '<p>You might try creating the relationship asset_to_category yourself in the reason administrative interface - it should include the following characteristics:</p>';
                pray($this->asset_to_category_details);
            }
        } else {
            echo '<p>Would have created asset_to_category allowable relationship.</p>' . "\n";
        }
    }
}
force_secure_if_available();
$user_netID = reason_require_authentication();
$reason_user_id = get_user_id($user_netID);
if (empty($reason_user_id)) {
    die('valid Reason user required');
}
if (!reason_user_has_privs($reason_user_id, 'upgrade')) {
    die('You must have Reason upgrade privileges to run this script');
}
?>
<h2>Reason: update assets for 4.0b6</h2>
<p>What will this update do?</p>
<ul>
<li>Change the page to asset relationship to bi-directional if it is not already.</li>
<li>Create an asset to category relationship if it does not exist.</li>
</ul>
<form method="post"><input type="submit" name="go" value="test" /><input type="submit" name="go" value="run" /></form>
function create_external_url_type($type_id, $type_name, $type_unique_name, $type_plural_name, $entity_table_fields)
{
    $user_id = get_user_id(reason_require_authentication());
    if ($type_id == 0) {
        $type_id = reason_create_entity(id_of('master_admin'), id_of('type'), $user_id, $type_name, array('unique_name' => $type_unique_name, 'plural_name' => $type_plural_name, 'new' => 0));
        if ($type_id != 0) {
            report($type_name . ' type created');
            if (@create_default_rels_for_new_type($type_id, $type_unique_name)) {
                report($type_name . ' default rels created');
            }
        } else {
            warn($type_name . ' not created - this is unexpected');
            return false;
        }
    }
    if (!empty($entity_table_fields)) {
        foreach ($entity_table_fields as $table_name => $table_fields) {
            $table_id = @create_reason_table($table_name, $type_id, $user_id);
            if ($table_id) {
                report('created entity table ' . $table_name . ' with id ' . $table_id);
            } else {
                report('did not create entity table ' . $table_name . ' - probably already exists - will try to add to type');
                add_entity_table_to_type($table_name, $type_id);
            }
            $updater = new FieldToEntityTable($table_name, $table_fields);
            $updater->update_entity_table();
            if ($updater->fields > 0) {
                ob_start();
                $updater->report();
                $updater_report = '<h3>Amputee Report - entity table ' . $table_name . '</h3><hr />' . ob_get_contents() . '<hr />';
                ob_end_clean();
                report($updater_report);
            }
        }
        $fixer = new AmputeeFixer();
        $fixer->fix_amputees($type_id);
        report('fixed amputees for type ' . $type_name);
    } else {
        report($type_name . ' requires no entity table(s) because it has no fields other than what is in the entity table');
    }
    return $type_id;
}