Exemplo n.º 1
0
function error($description, $error_place='', $params=array())
{
  trigger_error('error', E_USER_WARNING);

  if(isset($GLOBALS['error_recursion']) && $GLOBALS['error_recursion'])
    die($description . ' - (error recursion!!!)');

  $description = $description . "\n\nback trace:\n" . get_trace_back();

  $GLOBALS['error_recursion'] = true;

  rollback_user_transaction();

  debug :: set_message_output(DEBUG_OUTPUT_MESSAGE_STORE | DEBUG_OUTPUT_MESSAGE_SEND);
  debug :: write_error($description, $error_place, $params);

  if (debug :: is_console_enabled())
  {
    debug :: write_error($description, $error_place, $params);
    echo debug :: parse_console();
  }

  ob_end_flush();

  exit();
}
 function run(&$filter_chain, &$request, &$response)
 {
     debug::add_timing_point('authentication filter started');
     if (!($object_data = fetch_requested_object($request))) {
         if (!($node = map_request_to_node($request))) {
             if (defined('ERROR_DOCUMENT_404')) {
                 $response->redirect(ERROR_DOCUMENT_404);
             } else {
                 $response->header("HTTP/1.1 404 Not found");
             }
             return;
         }
         $response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI']));
         return;
     }
     $object =& wrap_with_site_object($object_data);
     $site_object_controller =& $object->get_controller();
     if (($action = $site_object_controller->determine_action($request)) === false) {
         debug::write_error('"' . $action . '" action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         if (defined('ERROR_DOCUMENT_404')) {
             $response->redirect(ERROR_DOCUMENT_404);
         } else {
             $response->header("HTTP/1.1 404 Not found");
         }
         debug::add_timing_point('authentication filter finished');
         $filter_chain->next();
         return;
     }
     $actions = $object->get_attribute('actions');
     if (!isset($actions[$action])) {
         $response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI']));
     }
     debug::add_timing_point('authentication filter finished');
     $filter_chain->next();
 }
  function _valid_perform(&$request, &$response)
  {
    $data = $this->dataspace->export();

    $request->set_status(REQUEST_STATUS_FAILURE);

    if($request->has_attribute('popup'))
      $response->write(close_popup_response($request));

    if(!isset($data['ids']) || !is_array($data['ids']))
      return;

    $objects = $this->_get_objects_to_delete(array_keys($data['ids']));

    foreach($objects as $id => $item)
    {
      if($item['delete_status'] !== 0 )
        continue;

      $site_object =& wrap_with_site_object($item);

      if(!$site_object->delete())
      {
        debug :: write_error("object couldn't be deleted",
         __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
        array('node_id' => $id));

        return;
      }
    }
    $request->set_status(REQUEST_STATUS_SUCCESS);

    $response->write(close_popup_response($request));
  }
 function perform()
 {
     $tree =& limb_tree::instance();
     if (isset($_REQUEST['id'])) {
         $node_id = (int) $_REQUEST['id'];
     } else {
         $node_id = get_mapped_id();
     }
     if (!isset($_REQUEST['direction'])) {
         return false;
     }
     if (!($object_data = fetch_one_by_node_id($node_id))) {
         debug::write_error('Node is not accessible', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('node_id' => $node_id));
         return false;
     }
     $direction = $_REQUEST['direction'];
     if (!($direction == 'up' || $direction == 'down')) {
         debug::write_error('Direction is not correct', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('direction' => $direction));
         return false;
     }
     if ($tree->change_node_order($node_id, $direction)) {
         reload(PHP_SELF . '#' . $node_id);
     }
     return false;
 }
	function perform()
	{
		if ($this->is_first_time())
		{
			$this->_init_dataspace();
			
			return $this->_first_time_perform();
		} 
		else
		{
			$this->_transfer_dataspace();

			$this->_process_transfered_dataspace();
			
			if(!$this->validate())
			{
				$result =& new not_valid_response();

			  debug :: write_error('validation failed', 
				  __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__);
			}
			else	
				$result = $this->_valid_perform();
				
			if($this->view && $form =& $this->view->find_child($this->name))
				$form->set_valid_status($result->is_success());
			
			return $result;
		} 
	}
 function perform()
 {
     $tree =& limb_tree::instance();
     if (isset($_REQUEST['id'])) {
         $node_id = (int) $_REQUEST['id'];
     } else {
         $node_id = get_mapped_id();
     }
     if (!isset($_REQUEST['direction'])) {
         return new failed_response();
     }
     if (!($object_data = fetch_one_by_node_id($node_id))) {
         debug::write_error('Node is not accessible', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('node_id' => $node_id));
         return new close_popup_response(RESPONSE_STATUS_FAILURE);
     }
     $direction = $_REQUEST['direction'];
     if (!($direction == 'up' || $direction == 'down')) {
         debug::write_error('Direction is not correct', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('direction' => $direction));
         return new close_popup_response(RESPONSE_STATUS_FAILURE);
     }
     if ($tree->change_node_order($node_id, $direction)) {
         return new close_popup_response();
     } else {
         return new close_popup_response(RESPONSE_STATUS_FAILURE);
     }
 }
 function perform(&$request, &$response)
 {
     if (($t = $request->get_attribute('t')) && is_array($t) && sizeof($t) > 0) {
         $this->history = $t;
         $template_path = end($this->history);
     } else {
         $template_path = TEMPLATE_FOR_HACKERS;
     }
     if (substr($template_path, -5, 5) != '.html') {
         $template_path = TEMPLATE_FOR_HACKERS;
     }
     if (substr($template_path, -5, 5) != '.html') {
         $request->set_status(REQUEST_STATUS_FAILURE);
     }
     if (!($source_file_path = resolve_template_source_file_name($template_path))) {
         debug::write_error('template not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('template_path' => $this->template_path));
         $source_file_path = resolve_template_source_file_name(TEMPLATE_FOR_HACKERS);
     }
     $template_contents = file_get_contents($source_file_path);
     if (sizeof($this->history) > 1) {
         $tmp_history = $this->history;
         $from_template_path = $tmp_history[sizeof($tmp_history) - 2];
         $tmp_history = array_splice($tmp_history, 0, sizeof($tmp_history) - 1);
         $history_query = 't[]=' . implode('&t[]=', $tmp_history);
         $this->view->set('history_query', $history_query);
         $this->view->set('from_template_path', $from_template_path);
     }
     $this->view->set('template_path', $template_path);
     $this->view->set('template_content', $this->_process_template_content($template_contents));
 }
	function _set_order_parameters($order_string)
	{
		$order_items = explode(',', $order_string);
		$order_pairs = array();
		foreach($order_items as $order_pair)
		{
			$arr = explode('=', $order_pair);
			
			if(isset($arr[1]))
			{
			  if(strtolower($arr[1]) == 'asc' || strtolower($arr[1]) == 'desc'
			  	 || strtolower($arr[1]) == 'rand()')			  
			    $order_pairs[$arr[0]] = strtoupper($arr[1]);
			  else
			    debug :: write_error('wrong order type',
		      __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
		      array('order' => $arr[1]));

			}
			else
			  $order_pairs[$arr[0]] = 'ASC';
		}	
		
		if(sizeof($order_pairs))
			$this->parameters['order'] = $order_pairs;
	}
Exemplo n.º 9
0
 function write($log_file_data, $string)
 {
     $log_dir = $log_file_data[0];
     $log_name = $log_file_data[1];
     $file_name = $log_dir . $log_name;
     if (!is_dir($log_dir)) {
         fs::mkdir($log_dir, 0775, true);
     }
     $oldumask = @umask(0);
     $file_existed = @file_exists($file_name);
     $log_file = @fopen($file_name, 'a');
     if ($log_file) {
         $time = strftime("%b %d %Y %H:%M:%S", strtotime('now'));
         $notice = '[ ' . $time . " ]\n";
         $user =& user::instance();
         if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
             $notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] ';
         }
         $notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
         @fwrite($log_file, $notice);
         @fclose($log_file);
         if (!$file_existed) {
             @chmod($file_name, 0664);
         }
         @umask($oldumask);
         $result = true;
     } else {
         @umask($oldumask);
         $result = false;
         debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false);
     }
     return $result;
 }
Exemplo n.º 10
0
function error($description, $error_place = '', $params = array())
{
    if (defined('DEVELOPER_ENVIROMENT')) {
        trigger_error('error', E_USER_WARNING);
        echo $description . '<br>' . $error_place . '<br><pre>';
        print_r($params);
        echo '</pre>';
    }
    debug::write_error($description, $error_place, $params);
    rollback_user_transaction();
    if (debug::is_console_enabled()) {
        echo debug::parse_html_console();
    } else {
        $message = '';
        if ($user_id = user::get_id()) {
            $message .= "user id:\t{$user_id}\nlogin:\t\t" . user::get_login() . "\ne-mail:\t\t" . user::get_email() . "\n";
        }
        $message .= "ip:\t\t" . sys::client_ip() . "\nrequest:\t" . REQUEST_URI . "\nerror:\t\t{$title}\ndescription:\t{$msg}";
        $mail = new mime_mail();
        $mail->set_body($message);
        $mail->build_message();
        $mail->send('developer', DEVELOPER_EMAIL, '', WEBSITE_EMAIL, $_SERVER['HTTP_HOST'] . ' internal error!');
    }
    ob_end_flush();
    exit;
}
 function perform()
 {
     if (isset($_REQUEST['t']) && is_array($_REQUEST['t']) && sizeof($_REQUEST['t']) > 0) {
         $this->history = $_REQUEST['t'];
         $template_path = end($this->history);
     } else {
         $template_path = TEMPLATE_FOR_HACKERS;
     }
     if (substr($template_path, -5, 5) != '.html') {
         $template_path = TEMPLATE_FOR_HACKERS;
     }
     if (substr($template_path, -5, 5) != '.html') {
         return new failed_response();
     }
     if (!($source_file_path = resolve_template_source_file_name($template_path))) {
         debug::write_error('template not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('template_path' => $this->template_path));
         $source_file_path = resolve_template_source_file_name(TEMPLATE_FOR_HACKERS);
     }
     $template_contents = file_get_contents($source_file_path);
     if (sizeof($this->history) > 1) {
         $tmp_history = $this->history;
         $from_template_path = $tmp_history[sizeof($tmp_history) - 2];
         $tmp_history = array_splice($tmp_history, 0, sizeof($tmp_history) - 1);
         $history_query = 't[]=' . implode('&t[]=', $tmp_history);
         $this->view->set('history_query', $history_query);
         $this->view->set('from_template_path', $from_template_path);
     }
     $this->view->set('template_path', $template_path);
     $this->view->set('template_content', $this->_process_template_content($template_contents));
     return new response();
 }
Exemplo n.º 12
0
function error($description, $error_place='', $params=array()) 
{
	if(isset($GLOBALS['error_recursion']) && $GLOBALS['error_recursion'])
		die();
		
	$GLOBALS['error_recursion'] = true;
	
	if(defined('DEVELOPER_ENVIROMENT'))
	{
		trigger_error('error', E_USER_WARNING);
		
		echo(  $description . '<br>' . $error_place . '<br><pre>');
		print_r($params);
		echo('</pre>');
	}
	
	$description = $description . "\n\nback trace:\n" . get_trace_back();
		
	rollback_user_transaction();

	debug :: set_message_output(DEBUG_OUTPUT_MESSAGE_STORE | DEBUG_OUTPUT_MESSAGE_SEND);
	debug :: write_error($description, $error_place, $params);
	
	if (debug :: is_console_enabled())
	{
		debug :: write_error($description, $error_place, $params);
		echo debug :: parse_console();
	}
		
	ob_end_flush();
			
	exit;
}
 function _update_media_record($id, $tmp_file_path, $file_name, $mime_type)
 {
     if (!file_exists($tmp_file_path)) {
         debug::write_error('file doesnt exist', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('tmp' => $tmp_file_path));
         return false;
     }
     if (function_exists('md5_file')) {
         $etag = md5_file($tmp_file_path);
     } else {
         $fd = fopen($data['tmp_name'], 'rb');
         $contents = fread($fd, filesize($tmp_file_path));
         fclose($fd);
         $etag = md5($contents);
     }
     if (!is_dir(MEDIA_DIR)) {
         dir::mkdir(MEDIA_DIR, 777, true);
     }
     if (!copy($tmp_file_path, MEDIA_DIR . $id . '.media')) {
         debug::write_error('temporary file copy failed', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('src' => $tmp_file_path, 'dst' => MEDIA_DIR . $id . '.media'));
         return false;
     }
     $media_db_table = db_table_factory::instance('media');
     $media_db_table->update_by_id($id, array('file_name' => $file_name, 'mime_type' => $mime_type, 'size' => filesize($tmp_file_path), 'etag' => $etag));
     return true;
 }
	function _valid_perform()
	{
		$data = $this->dataspace->export();
		
		if(!isset($data['ids']) || !is_array($data['ids']))
			return new close_popup_response(RESPONSE_STATUS_FAILURE);
		
		$objects = $this->_get_objects_to_delete(array_keys($data['ids']));
		
		foreach($objects as $id => $item)
		{
			if($item['delete_status'] !== 0 )
				continue;
			
			$site_object =& wrap_with_site_object($item);
			
			if(!$site_object->delete())
			{
				debug :: write_error("object couldn't be deleted",
				 __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
				array('node_id' => $id));

				return new close_popup_response(RESPONSE_STATUS_FAILURE);
			}
		}	
		return new close_popup_response();
	}
Exemplo n.º 15
0
 function generate_contents(&$code)
 {
     parent::generate_contents($code);
     if (isset($this->attributes['navigator'])) {
         if ($navigator =& $this->parent->find_child($this->attributes['navigator'])) {
             $limit = $code->get_temp_variable();
             $code->write_php('$' . $limit . '= ' . $navigator->get_component_ref_code() . '->get_items_per_page();');
             $code->write_php($this->get_component_ref_code() . '->set_parameter("limit", $' . $limit . ');');
             $code->write_php('if(isset($_GET["page_' . $navigator->get_server_id() . '"])){');
             $code->write_php($this->get_component_ref_code() . '->set_parameter("offset", ($_GET["page_' . $navigator->get_server_id() . '"]-1)*$' . $limit . ');');
             $code->write_php('}');
         }
     }
     $targets = explode(',', $this->attributes['target']);
     foreach ($targets as $target) {
         if ($target_component =& $this->parent->find_child(trim($target))) {
             $code->write_php($target_component->get_component_ref_code() . '->register_dataset(' . $this->get_component_ref_code() . '->get_dataset());');
         } else {
             debug::write_error('component target not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('target' => $target));
         }
     }
     if (isset($this->attributes['navigator']) && $navigator) {
         $code->write_php($navigator->get_component_ref_code() . '->set_total_items(' . $this->get_component_ref_code() . '->get_total_count());');
     }
 }
  function run(&$filter_chain, &$request, &$response)
  {
    debug :: add_timing_point('authentication filter started');

    if(!$object_data = fetch_requested_object($request))
    {
      if(!$node = map_request_to_node($request))
      {
        if(defined('ERROR_DOCUMENT_404'))
          $response->redirect(ERROR_DOCUMENT_404);
        else
          $response->header("HTTP/1.1 404 Not found");
        return;
      }
      $response->redirect('/root/login?redirect='. urlencode($request->to_string()));
      return;
    }

    $object =& wrap_with_site_object($object_data);

    $site_object_controller =& $object->get_controller();

    if(($action = $site_object_controller->determine_action($request)) === false)
    {
      debug :: write_error('"'. $action . '" action not found', __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__);

      if(defined('ERROR_DOCUMENT_404'))
        $response->redirect(ERROR_DOCUMENT_404);
      else
        $response->header("HTTP/1.1 404 Not found");

      debug :: add_timing_point('authentication filter finished');

      $filter_chain->next();
      return;
    }

    $actions = $object->get_attribute('actions');

    if(!isset($actions[$action]))
    {
      $redirect_path = $site_object_controller->get_action_property($action, 'inaccessible_redirect');

      if(!$redirect_path)
        $redirect_path = '/root/login';

      $redirect_strategy =& $this->_get_redirect_strategy($site_object_controller, $action);

      $response->set_redirect_strategy($redirect_strategy);

      $response->redirect($redirect_path . '?redirect='. urlencode($request->to_string()));
    }

    debug :: add_timing_point('authentication filter finished');

    $filter_chain->next();
  }
 function &get_dataset()
 {
     $data_source =& $this->_get_data_source();
     if (!is_a($data_source, 'data_source')) {
         debug::write_error('data source not created', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('data_source_path' => $this->parameters['data_source_path']));
         return new empty_dataset();
     }
     $dataset =& $data_source->get_data_set($this->total_count, $this->_get_params_array());
     return $dataset;
 }
 function _can_parent_accept_node($parent_node_id, $node_id)
 {
     if (!($parent_object = wrap_with_site_object(fetch_one_by_node_id($parent_node_id)))) {
         debug::write_error('acceptor node is not accessible', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('parent_node_id' => $parent_node_id));
         return false;
     }
     if (!($target_data = fetch_one_by_node_id($node_id))) {
         debug::write_error('node is not accessible', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('node_id' => $node_id));
         return false;
     }
     return $parent_object->can_accept_child_class($target_data['class_name']);
 }
Exemplo n.º 19
0
 function get_component_ref_code()
 {
     if (isset($this->attributes['mirror_of'])) {
         if ($mirrored_pager =& $this->parent->find_child($this->attributes['mirror_of'])) {
             return $mirrored_pager->get_component_ref_code();
         } else {
             debug::write_error('mirror_of pager component not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('mirror_of' => $this->attributes['mirror_of']));
         }
     } else {
         return parent::get_component_ref_code();
     }
 }
Exemplo n.º 20
0
 function update_file()
 {
     $tmp_file_path = $this->get_attribute('tmp_file_path');
     $file_name = $this->get_attribute('file_name');
     $mime_type = $this->get_attribute('mime_type');
     if (!($media_id = $this->get_attribute('media_id'))) {
         debug::write_error('media id not set', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         return false;
     }
     if (!$this->_update_media_record($media_id, $tmp_file_path, $file_name, $mime_type)) {
         return false;
     }
     return true;
 }
 function &create($class_path)
 {
     $class_name = action_factory::get_class_name($class_path);
     if (file_exists(PROJECT_DIR . '/core/actions/' . $class_path . '.class.php')) {
         $full_path = PROJECT_DIR . '/core/actions/' . $class_path . '.class.php';
     } elseif (file_exists(LIMB_DIR . '/core/actions/' . $class_path . '.class.php')) {
         $full_path = LIMB_DIR . '/core/actions/' . $class_path . '.class.php';
     } else {
         debug::write_error('action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('class_path' => $class_path));
         return null;
     }
     include_once $full_path;
     $action =& new $class_name();
     return $action;
 }
Exemplo n.º 22
0
 function get_param($identifier, $type = '')
 {
     if (!empty($type) && !in_array($type, $this->_types)) {
         debug::write_error('trying to get undefined type in sys_param', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('type' => $type, 'param' => $identifier));
         return null;
     }
     $params = $this->_db_table->get_list("identifier='{$identifier}'", '', '', 0, 1);
     if (!is_array($params) || !count($params)) {
         return null;
     }
     $param = current($params);
     if (empty($type)) {
         $type = $param['type'];
     }
     return $param["{$type}_value"];
 }
 function &create($class_path)
 {
     $pos = strrpos($class_path, '/');
     if ($pos !== false) {
         $class_name = substr($class_path, $pos + 1);
     } else {
         $class_name = $class_path;
     }
     if (file_exists(PROJECT_DIR . '/core/actions/' . $class_path . '.class.php')) {
         $full_path = PROJECT_DIR . '/core/actions/' . $class_path . '.class.php';
     } elseif (file_exists(LIMB_DIR . '/core/actions/' . $class_path . '.class.php')) {
         $full_path = LIMB_DIR . '/core/actions/' . $class_path . '.class.php';
     } else {
         debug::write_error('action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('class_path' => $class_path));
         return null;
     }
     include_once $full_path;
     $action =& new $class_name();
     return $action;
 }
Exemplo n.º 24
0
function send_html_mail($recipients, $sender, $subject, $html, $text = null, $charset = 'windows-1251')
{
    $mail =& create_mailer();
    $mail->IsHTML(true);
    $mail->CharSet = $charset;
    $mail->Body = $html;
    if (!is_null($text)) {
        $mail->AltBody = $text;
    }
    $recipients = process_mail_recipients($recipients);
    foreach ($recipients as $recipient) {
        $mail->AddAddress($recipient['address'], $recipient['name']);
    }
    if (!($sender = process_mail_addressee($sender))) {
        return false;
    }
    $mail->From = $sender['address'];
    $mail->FromName = $sender['name'];
    $mail->Subject = $subject;
    if (!($res = $mail->Send())) {
        debug::write_error('mail send error', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, $recipient);
    }
    return $res;
}
  function & create($class_path)
  {
    $pos = strrpos($class_path, '/');

    if($pos !== false)
      $class_name = substr($class_path, $pos + 1);
    else
      $class_name = $class_path;

    if (file_exists(PROJECT_DIR . '/core/datasource/' . $class_path . '.class.php'))
      $full_path = PROJECT_DIR . '/core/datasource/' . $class_path . '.class.php';
    elseif(file_exists(LIMB_DIR . '/core/datasource/' . $class_path . '.class.php'))
      $full_path = LIMB_DIR . '/core/datasource/' . $class_path . '.class.php';
    else
    {
      debug :: write_error('datasource not found', __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__, array('class_path' => $class_path));
      return null;
    }

    include_once($full_path);
    $datasource =& new $class_name();

    return $datasource;
  }
Exemplo n.º 26
0
 function send_activate_password_email(&$user_data, $password)
 {
     require_once LIMB_DIR . 'core/lib/mail/send_plain_mail.inc.php';
     global $_SERVER;
     $http_host = $_SERVER['HTTP_HOST'];
     $filename = LIMB_DIR . '/design/default/templates/user/generated_password_mail.html';
     if (!file_exists($filename)) {
         error('template file for password notification email not found!', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file_name' => $filename));
     }
     $fd = fopen($filename, "r");
     $contents = fread($fd, filesize($filename));
     fclose($fd);
     $contents = str_replace('%website_name%', $http_host, $contents);
     $contents = str_replace('%user_name%', $user_data['name'] . ' ' . $user_data['lastname'], $contents);
     $contents = str_replace('%new_password%', $password, $contents);
     $contents = str_replace('%website_href%', $http_host, $contents);
     $contents = str_replace('%website_email%', ADMINISTRATOR_EMAIL, $contents);
     $activate_href = 'http://' . $http_host . '/root/activate_password?user='******'email'] . '&id=' . $user_data['password'];
     $contents = str_replace('%activate_href%', $activate_href, $contents);
     if (!send_plain_mail(array($user_data['email']), ADMINISTRATOR_EMAIL, strings::get('generate_password_theme', 'user'), $contents)) {
         debug::write_error('error while sending password notification email', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         return false;
     } else {
         return true;
     }
 }
  /**
  * Clean values from protected or unknown columns
  */
  function _verify_user_values(&$values)
  {
    if ($this->_dumb_mode)
      return true;

    foreach($values as $field => $value)
    {
      if (!isset($this->_params[$field]))
      {
        debug :: write_error(TREE_ERROR_NODE_WRONG_PARAM,
           __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
           array('param' => $field)
        );
        unset($values[$field]);
        continue;
      }

      if (in_array($this->_params[$field], $this->_required_params))
      {
        debug :: write_error(TREE_ERROR_NODE_WRONG_PARAM,
           __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
         array('value' => $field)
        );

        unset($values[$field]);
      }
    }
  }
Exemplo n.º 28
0
 function locale($locale_string = '')
 {
     $this->http_locale_code = '';
     $this->week_days = array(0, 1, 2, 3, 4, 5, 6);
     $this->months = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
     $locale = locale::get_locale_information($locale_string);
     $this->country_code = $locale['country'];
     $this->country_variation = $locale['country-variation'];
     $this->language_code = $locale['language'];
     $this->locale_code = $locale['locale'];
     $this->charset = $locale['charset'];
     $this->override_charset = $locale['charset'];
     // Figure out if we use one locale file or separate country/language file.
     $locale_ini =& $this->get_locale_ini();
     $country_ini =& $locale_ini;
     $language_ini =& $locale_ini;
     if ($locale_ini === null) {
         $country_ini =& $this->get_country_ini();
         $language_ini =& $this->get_language_ini();
     }
     $this->_reset();
     $this->is_valid = true;
     if ($country_ini !== null) {
         $this->_init_country_settings($country_ini);
     } else {
         $this->is_valid = false;
         debug::write_error('Could not load country settings for ' . $this->country_code, __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     if ($language_ini !== null) {
         $this->_init_language_settings($language_ini);
     } else {
         $this->is_valid = false;
         debug::write_error('Could not load language settings for ' . $this->language_code, __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     // load variation if any
     $locale_variation_ini =& $this->get_locale_ini(true);
     $country_variation_ini =& $locale_variation_ini;
     $language_variation_ini =& $locale_variation_ini;
     if ($locale_variation_ini === null) {
         $country_variation_ini =& $this->get_country_ini(true);
         $language_variation_ini =& $this->get_language_ini(true);
     }
     if ($country_variation_ini !== null && $country_variation_ini->get_original_file() != $country_ini->get_original_file()) {
         $this->_init_country_settings($country_variation_ini);
     }
     if ($language_variation_ini !== null && $language_variation_ini->get_original_file() != $language_ini->get_original_file()) {
         $this->_init_language_settings($language_variation_ini);
     }
 }
 function update($force_create_new_version = true)
 {
     if (!parent::update($force_create_new_version)) {
         return false;
     }
     if ($force_create_new_version) {
         if (!$this->_create_version_record()) {
             return false;
         }
         if ($this->_create_versioned_content_record() !== false) {
             return true;
         }
         debug::write_error('creation of versioned record failed', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         return false;
     }
     return $this->_update_versioned_content_record();
 }
 function _perform_action()
 {
     $action =& $this->get_action_object();
     if ($view =& $this->get_view()) {
         $action->set_view($view);
     }
     $this->_response = $action->perform();
     debug::add_timing_point('action performed');
     if ($this->_response->is_problem()) {
         debug::write_error('action failed', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
 }