public function insert_envelopes ($data)
{
	$template   = $data['template'];
	$priority   = $data['priority'];
	$recipients = $data['recipients'];

	$db = coren::db('handle');
	$table_envelope = 'message_envelope';

	$template = "'" . mysql_real_escape_string($template, $db) . "'";
	$priority = (integer) $priority;
	$sql_values = array();
	foreach ($recipients as $recipient)
	{
		$recipient = "'" . mysql_real_escape_string($recipient, $db) . "'";
		$sql_values[] = "({$template},{$recipient},{$priority},0,0,now())";
	}
	$sql_values = implode(",", $sql_values);
	$sql =
	"
		insert into {$table_envelope} (
			 `template`
			,`recipient`
			,`priority`
			,`status`
			,`counter`
			,`injected`
		) values {$sql_values}
	";
//???	core::event('query', "Select page of articles from database.", array('query'=>$sql));
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));
}
Example #2
0
function __construct ($configs)
{
	parent::__construct($configs);

	coren::handler('on_redirect', null, null, null, 'redirect');
	coren::handler('on_shutdown', ''  , ''  , ''  , 'shutdown');
}
Example #3
0
public function check ($data)
{
	if (!is_null($this->stop_slot) && coren::slot_used($this->stop_slot)) return;
	if (!is_null($this->stop_name) && coren::name_used($this->stop_name)) return;
	$event_data = null;
	return coren::event($this->evaluate($data) ? $this->event_true : $this->event_false, $event_data);
}
function select_information ($data)
{
	$identifier = $data['identifier'];

	$db = coren::db('handle');
	$table_session = 'auth_session';

	$identifier = "'" . mysql_real_escape_string($identifier, $db) . "'";
	$sql =
	"
		select `session`, `account`, `remote`, `secure`, `period`, `status`, `started`, `touched`, `closed`
		  from {$table_session}
		 where `session` = {$identifier}
		 order by `started` desc
		 limit 1
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));

	$result = null;
	while ($row = mysql_fetch_row($res))
		$result = array(
			'session'	=> $row[0],
			'account'	=> $row[1],
			'remote'	=> $row[2],
			'secure'	=> $row[3],
			'period'	=> $row[4],
			'status'	=> $row[5],
			'started'	=> coren::db('split_date', array('value'=>$row[6])),
			'touched'	=> coren::db('split_date', array('value'=>$row[7])),
			'closed'	=> coren::db('split_date', array('value'=>$row[8])));
	mysql_free_result($res);
	return $result;
}
function select_privileges ($data)
{
	$identifier = $data['identifier'];

	$db = coren::db('handle');
	$table_privilege  = 'auth_privilege'         ;
	$table_membership = 'auth_account_membership';
	$table_assignment = 'auth_assignment'        ;

	$identifier = "'" . mysql_real_escape_string($identifier, $db) . "'";
	$sql =
	"
		select {$table_privilege}.`codename`
		  from {$table_privilege} join {$table_assignment} using (`privilege`) join {$table_membership} using (`rolegroup`)
		 where {$table_membership}.`account` = {$identifier}
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));

	$result = array();
	while ($row = mysql_fetch_row($res))
		$result[] = $row[0];
	mysql_free_result($res);
	return $result;
}
Example #6
0
public function check ($data)
{
	if (!is_null($this->stop_slot) && coren::slot_used($this->stop_slot)) return;
	if (!is_null($this->stop_name) && coren::name_used($this->stop_name)) return;
	$data = null;//??? make it configurable?
	return coren::event($this->event, $data);
}
Example #7
0
public function __construct ($configs)
{
	parent::__construct($configs);

	if (!coren::depend('_path_normalizer_0'))
		throw new exception("Tool '_path_normalizer_0' missed.");

	if(isset($configs['lock_relax'])) $this->lock_relax = $configs['lock_relax'];
	if(isset($configs['lock_count'])) $this->lock_count = $configs['lock_count'];
	if(isset($configs['lock_sleep'])) $this->lock_sleep = $configs['lock_sleep'];

	if(isset($configs['chunk_size'])) $this->chunk_size = $configs['chunk_size'];
	$this->chink_size = (integer) $this->chunk_size;
	if ($this->chunk_size <= 0) $this->chunk_size = 1024;

	if(isset($configs['dir_path'    ])) $this->dir_path     = $configs['dir_path'    ];
	if(isset($configs['dir_absolute'])) $this->dir_absolute = $configs['dir_absolute'];
	if(isset($configs['dir_required'])) $this->dir_required = $configs['dir_required'];
	if(isset($configs['dir_automake'])) $this->dir_automake = $configs['dir_automake'];
	if(isset($configs['dir_umask'   ])) $this->dir_umask    = $configs['dir_umask'   ];
	$this->dir = _path_normalizer_0::normalize_dir($this->dir_path, $this->dir_absolute ? null : SITEPATH);
	if ($this->dir_automake && !file_exists($this->dir))
	{
		$old_umask = umask(octdec($this->dir_umask));
		mkdir($this->dir, 0777, true);
		umask($old_umask);
	}
	if ($this->dir_required && !is_dir($this->dir))
	{
		throw new exception("Required directory '{$this->dir}' does not exist.");
	}
}
public function assign ($data)
{
	$identifier = isset($data['identifier']) ? $data['identifier'] : null;

	$privileges = coren::db('select_privileges', compact('identifier'));
	if (!is_null($this->identified_privilege)) $privileges[] = $this->identified_privilege;
	coren::grant($privileges);
}
Example #9
0
public function check ($data)
{
	if (!is_null($this->stop_slot) && coren::slot_used($this->stop_slot)) return;
	if (!is_null($this->stop_name) && coren::name_used($this->stop_name)) return;
	$event_data = null;
	$values = $this->evaluate($event_data);
	if (!is_null($values))//???
	return coren::event(vsprintf($this->event_mask, $values), $event_data);
}
Example #10
0
public function verify ($data)
{
	//NB: logname, passwords and other fields can be not set, because verifying by other criterias.
	$logname        = isset($data['logname'       ]) ? $data['logname'       ] : null;
	$password_plain = isset($data['password_plain']) ? $data['password_plain'] : (isset($data['password']) ? $data['password'] : null);
	$password_md5   = isset($data['password_md5'  ]) ? $data['password_md5'  ] : (md5($password_plain));
//...	$sslcert        = isset($data['sslcert'       ]) ? $data['sslcert'       ] : null;
	return coren::db('verify', compact('logname', 'password_plain', 'password_md5'));
}
Example #11
0
public function set ($data)
{
	if (!$this->wasset || !$this->autolock)
	{
		if (!$this->wasset) coren::handler('send', coren::event_for_stage_epiwork);
		$this->wasset = true;
		$this->value  = isset($data['value' ]) ? $data['value' ] : null;
		$this->expire = isset($data['expire']) ? $data['expire'] : null;
	}
}
function expire_sessions ($data)
{
	$db = coren::db('handle');
	$table_session = 'auth_session';

	$sql =
	"
		update {$table_session}
		   set `status` = 1, `closed` = now()
		 where `status` = 0 and `period` > 0
		   and (`touched` + interval `period` second) <= now()
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));
}
function touch_session ($data)
{
	$identifier = $data['identifier'];

	$db = coren::db('handle');
	$table_session = 'auth_session';

	$identifier = "'" . mysql_real_escape_string($identifier, $db) . "'";
	$sql =
	"
		update {$table_session}
		   set `touched` = now()
		 where `session` = {$identifier}
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));
}
function session_start ($data)
{
	$identifier  = $data['identifier'];
	$account  = $data['account'];
	$remote   = $data['remote' ];
	$secure   = $data['secure' ];
	$period   = $data['period' ];

	$db = coren::db('handle');
	$table_session = 'auth_session';

	$identifier = "'" . mysql_real_escape_string($identifier, $db) . "'";
	$account    = "'" . mysql_real_escape_string($account   , $db) . "'";
	$remote     = "'" . mysql_real_escape_string($remote    , $db) . "'";
	$secure     = $secure ? 1 : 0;
	$period     = (integer) $period;
	$sql =
	"
		insert into {$table_session} (
			 `session`
			,`account`
			,`remote`
			,`secure`
			,`period`
			,`status`
			,`started`
			,`touched`
			,`closed` 
		) values (
			 {$identifier}
			,{$account}
			,{$remote}
			,{$secure}
			,{$period}
			,default
			,now()
			,now()
			,null
		)
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) if (mysql_errno($db) === 1062) throw new identify_session_start_0_exception_duplicate(mysql_error($db), mysql_errno($db));
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));
}
function verify ($data)
{
	$logname        = $data['logname'       ];
	$password_plain = $data['password_plain'];
	$password_md5   = $data['password_md5'  ];

	$db = coren::db('handle');
	$table_account = 'auth_account';

	$sql_logname        = "'" . mysql_real_escape_string($logname       , $db) . "'";
	$sql_password_plain = "'" . mysql_real_escape_string($password_plain, $db) . "'";
	$sql_password_md5   = "'" . mysql_real_escape_string($password_md5  , $db) . "'";

	$whereclauses = array();
	if (!is_null($password_plain)) $whereclauses[] = "(`logname` = {$sql_logname} and `password_plain` = {$sql_password_plain})";
	if (!is_null($password_md5  )) $whereclauses[] = "(`logname` = {$sql_logname} and `password_md5`   = {$sql_password_md5  })";

	if (empty($whereclauses)) return null;
	else $whereclauses = implode(" or ", $whereclauses);

	$sql =
	"
		select `account`, `disabled`, `reason`
		  from {$table_account}
		 where {$whereclauses}
		 order by `created` asc
		 limit 1
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));

	$result = null;
	while ($row = mysql_fetch_row($res))
		$result = array(
			'account'	=> $row[0],
			'disabled'	=> $row[1],
			'reason'	=> $row[2]);
	mysql_free_result($res);
	return $result;
}
function select_information ($data)
{
	$identifiers = $data['identifiers'];
	if (empty($identifiers)) return array();

	$db = coren::db('handle');
	$table_account = 'auth_account';

	$sql_identifiers = array();
	foreach ($identifiers as $identifier)
		$sql_identifiers[] = "'" . mysql_real_escape_string($identifier, $db) . "'";
	$sql_identifiers = implode(",", $sql_identifiers);
	$sql =
	"
		select `account`, `created`, `entered`, `touched`, `disabled`, `reason`, `comment`, `logname`, `email`, `agreement`
		  from {$table_account}
		 where `account` in ({$sql_identifiers})
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));

	$result = array();
	while ($row = mysql_fetch_row($res))
		$result[$row[0]] = array(
			'account'	=> $row[0],
			'created'	=> coren::db('split_date', array('value'=>$row[1])),
			'entered'	=> coren::db('split_date', array('value'=>$row[2])),
			'touched'	=> coren::db('split_date', array('value'=>$row[3])),
			'disabled'	=> $row[4],
			'reason'	=> $row[5],
			'comment'	=> $row[6],
			'logname'	=> $row[7],
			'email'		=> $row[8],
			'agreement'	=> $row[9]);
	mysql_free_result($res);
	return $result;
}
Example #17
0
public function information ($data)
{
	$identifiers = isset($data['identifiers']) ? $data['identifiers'] : null;
	$identifier  = isset($data['identifier' ]) ? $data['identifier' ] : null;
	if ($singlemode = !is_null($identifier)) $identifiers = array(null => $identifier);
	if (!is_array($identifiers)) throw new exception("List of account identifiers must be an array.");
	$result = array();


	if (!is_null($this->event_for_cache_get))
	foreach ($identifiers as $index => $identifier)
	{
		if (!is_null($temp = coren::event($this->event_for_cache_get, compact('identifier'))))
		{
			$result[$index] = $temp;
			unset($identifiers[$index]);
		}
	}

	$information = empty($identifiers) ? array() : coren::db('select_information', compact('identifiers'));

	foreach ($identifiers as $index => $identifier)
	{
		if (array_key_exists($identifier, $information))
		{
			$result[$index] = $information[$identifier];
			if (!is_null($this->event_for_cache_set))
				coren::event($this->event_for_cache_set, array('identifier'=>$identifier, 'value'=>$information[$identifier]));
		} else
		{
			$result[$index] = null;
		}
	}

	return $singlemode ? $result[null] : $result;
}
Example #18
0
public function parameters ($data)
{
	$db = coren::db('handle');
	$table_parameter = '`coren_parameter`';

	$sql =
	"
		select `parameter`, `value`
		  from {$table_parameter}
	";
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));

	$result = array();
	while ($row = mysql_fetch_row($res))
		$result[] = array(
			'parameter'	=> $row[0],
			'value'		=> $row[1]);
	mysql_free_result($res);
	return $result;
}
public function mark_envelope_failure ($data)
{
	$envelope = $data['envelope'];
	$error    = $data['error'   ];
	$errno    = $data['errno'   ];
	$status   = $data['status'  ];

	$db = coren::db('handle');
	$table_envelope = 'message_envelope';

	$envelope = "'" . mysql_real_escape_string($envelope, $db) . "'";
	$error    = "'" . mysql_real_escape_string($error   , $db) . "'";
	$errno    = (integer) $errno;
	$status   = (integer) $status;
	$sql =
	"
		update {$table_envelope}
		   set `status`	    = {$status}
		     , `counter`    = `counter` + 1
		     , `last_stamp` = now()
		     , `last_error` = {$error}
		     , `last_errno` = {$errno}
		 where `envelope` = {$envelope}
	";
//???	core::event('query', "Insert article to database.", array('query'=>$sql));
	$res = @mysql_query($sql, $db);
	if ($res === false) throw new exception(mysql_error($db), mysql_errno($db));
}
Example #20
0
<?php defined('CORENINPAGE') or die('Hack!');
####################################################################################################
####################################################################################################
####################################################################################################
#
if (!coren::depend('generator_0')) return;
#
class generator_uniqid_0 extends generator_0
{
#
####################################################################################################
####################################################################################################
####################################################################################################
#
protected $prefix;
protected $entropy;
#
####################################################################################################
#
function __construct ($configs)
{
	parent::__construct($configs);

	if (isset($configs['prefix' ])) $this->prefix  = $configs['prefix' ];
	if (isset($configs['entropy'])) $this->entropy = $configs['entropy'];
}
#
####################################################################################################
####################################################################################################
####################################################################################################
#
<?php defined('CORENINPAGE') or die('Hack!');
####################################################################################################
####################################################################################################
####################################################################################################
#
if (!coren::depend('requisites_request_0')) return;
#
class requisites_request_mapped_0 extends requisites_request_0
{
#
####################################################################################################
####################################################################################################
####################################################################################################
#
protected $direct;
protected $map;
#
####################################################################################################
#
public function __construct ($configs)
{
	parent::__construct($configs);

	if (isset($configs['direct'])) $this->direct = $configs['direct'];

	$map = isset($configs['map']) ? $configs['map'] : null;
	$map_parts = explode(' ', $map); $map = array();
	foreach ($map_parts as $map_part)
	{
		$map_part = explode('=', $map_part, 2);
		$dstkey = isset($map_part[0]) ? trim($map_part[0]) : null;
Example #22
0
public function touch ($data)
{
	$identifier = isset($data['identifier']) ? $data['identifier'] : null;
	if (!is_null($identifier)) coren::db('touch_account', compact('identifier'));
}
Example #23
0
public function flush ($data)
{
	if (!coren::have($this->privilege_for_flush))
	{
		if (!$this->silent)
		{
			coren::event($this->event_for_not_authorized);
		}
		if (!$this->hidden)
		{
			if (!coren::depend('_dom_builder_0'))
				throw new exception("Tool '_dom_builder_0' missed.");

			$doc = coren::xml();
			$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'flush', null);
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'not-authorized', null));
			coren::slot(coren::name($doc->documentElement->appendChild($ele), $this->name_for_not_authorized), $this->slot_for_not_authorized);
		}
//???		do nto throw here. see file ...inject... for reasoning.
//???		throw new exception("Not authorized to flush queue of messages.");
		return;
	}

	$limit = max(1, $this->limit_per_call);//min(max(1, $this->limit_per_call)/*, max(1, $this->limit_per_*), ...*/);
	$envelopes = coren::db('select_envelopes', compact('limit'));

	$reports = array();
	if (is_array($envelopes) && !empty($envelopes))
	{
		$identifiers = array();
		foreach ($envelopes as $envelope) $identifiers[] = $envelope['template'];
		$identifiers = array_unique($identifiers);
		$templates = empty($identifiers) ? array() : coren::db('select_templates', compact('identifiers'));

		foreach ($envelopes as $index => $item)
		{
			$envelope    = $item['envelope'   ];
			$template    = $item['template'   ];
			$recipient   = $item['recipient'  ];
			$current_try = $item['current_try'];
			$current_age = $item['current_age'];
			$subject = isset($templates[$template]['subject']) ? $templates[$template]['subject'] : null;
			$message = isset($templates[$template]['message']) ? $templates[$template]['message'] : null;

			try
			{
				$status = +1;
				$error = $errno = null;
				coren::event($this->event_for_send_message, compact('recipient', 'subject', 'message', 'envelope', 'template'));
			}
			catch (exception $exception)
			{
				$status = (isset($this->max_age) && ($current_age >= $this->max_age))
					||(isset($this->max_try) && ($current_try >= $this->max_try))
					? -1 : 0;
				$error  = $exception->getMessage();
				$errno  = $exception->getCode();
			}
			$reports[] = compact('envelope', 'template', 'recipient', 'error', 'errno', 'status');

			if ($this->one_by_one)
			if ($status <= 0)
			{
				coren::db('mark_envelope_failure', compact('envelope', 'error', 'errno', 'status'));
			} else
			{
				coren::db('mark_envelope_success', compact('envelope', 'status'));
			}
		}
	}

	if (!$this->one_by_one)
	{
		$envelopes = array();//NB: this is a list of identifiers of envelopes, that were successfuly sent.
		foreach ($reports as $report)
		{
			$envelope = $report['envelope'];
			$status   = $report['status'  ];
			if ($status <= 0)
			{
				$error = $report['error'];
				$errno = $report['errno'];
				coren::db('mark_envelope_failure', compact('envelope', 'error', 'errno', 'status'));
			} else
			{
				$envelopes[] = $envelope;
			}
		}
		if (!empty($envelopes))
		{
			$status = +1;
			coren::db('mark_envelope_success', compact('envelopes', 'status'));
		}
	}

	if (!$this->silent)
	{
		//!!!??? trigger event about successful or failed send! or maybe it must be dependent
		//!!!??? on one_by_one: event one-by-one, or all at once?
		//coren::event($this->event_for_flush_success, compact(???!!!));
		coren::event($this->event_for_flush_success);
	}
	if (!$this->hidden)
	{
		if (!coren::depend('_dom_builder_0'))
			throw new exception("Tool '_dom_builder_0' missed.");

		$doc = coren::xml();
		$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'flush', null);
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'limit'  , $limit));
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'max-age', $this->max_age));
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'max-try', $this->max_try));

		$eler = $ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'reports', null));
		foreach ($reports as $report)
		$eler->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'report', $report));

		$elet = $ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'templates', null));
		foreach ($templates as $identifier => $template)
		$elet->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'template', $template))
		   ->setAttributeNodeNS(_dom_builder_0::build_attribute($doc, self::namespace, $this->prefix, 'id', $identifier));

		coren::slot(coren::name($doc->documentElement->appendChild($ele), $this->name_for_flush_success), $this->slot_for_flush_success);
	}
}
# в один единственный файл, который ссылается на ядро. При запросе таких ресурсов ядро будет
# все видеть так, будто оно получило запрос прямым обращением к файлу в соответствующем каталоге.
# И набор модулей данного класса могут решить какие данные генерировать на основании пути в запросе,
# хотя и существует один-единственный файл скрипта в корне сайта/каталога.
#
# Этот модуль также делает некоторые различия для главного и вспомогательного контента на странице.
# Если какой-то другой модуль через систему событий заявил что он сам будет генерировать главный
# контент, а в нашем модуле тоже предплагается главный контент, то мы его уже не будем генерировать.
# С другой стороны, если контент данного модуля помечен как вспомогательный, то он будет всегда
# генерироваться вне зависимости от наличия главного контента в других модулях.
#
####################################################################################################
####################################################################################################
####################################################################################################
#
if (!coren::depend('event_if_0')) return;
#
class event_if_http_path_regex_0 extends event_if_0
{
#
####################################################################################################
####################################################################################################
####################################################################################################
#
protected $regex;
#
####################################################################################################
#
public function __construct ($configs)
{
	parent::__construct($configs);
Example #25
0
private static function work_stage ($stagename)
{
/*rts*/	$stamp = microtime(true);
/*rts*/	self::$rts_time_for_stage[$stagename] = 0.0;
	self::$stage = $stagename;
	try
	{
		$method = "stage_{$stagename}";
		self::$method();
	}
	catch (coren_exception_abort_stage $exception) { $exception = null; }
	catch (exception $exception) {}
	self::$stage = null;
/*rts*/	self::$rts_time_for_stage[$stagename] += microtime(true) - $stamp;
	if (isset($exception)) throw $exception;
}
Example #26
0
public function inject ($data)
{
	if (!coren::have($this->privilege_for_inject))
	{
		if (!$this->silent)
		{
			coren::event($this->event_for_not_authorized);
		}
		if (!$this->hidden)
		{
			if (!coren::depend('_dom_builder_0'))
				throw new exception("Tool '_dom_builder_0' missed.");

			$doc = coren::xml();
			$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'inject', null);
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'not-authorized', null));
			coren::slot(coren::name($doc->documentElement->appendChild($ele), $this->name_for_not_authorized), $this->slot_for_not_authorized);
		}
//???		absence of authrization for some action is an error, but not an exception.
//???		exceptions are for unpredicted situations, and access violation is predicted.
//???		So this is an error, it has an event & data about error, and do nothing more,
//???		but it do not throw an exception, which breaks all workflow of the script
//???		and causes rollbacks in all databases.
//???		throw new exception("Not authorized to inject message into queue of messages.");
		return;
	}

	$priority = isset($data['priority']) ? $data['priority'] :  0; if (is_scalar($priority)) $priority = (integer) $priority; else throw new exception("Bad priority for message queue (must be integer).");
	$subject  = isset($data['subject' ]) ? $data['subject' ] : ''; if (is_scalar($subject )) $subject  = (string ) $subject ; else throw new exception("Bad subject for message queue (must be string).");
	$message  = isset($data['message' ]) ? $data['message' ] : ''; if (is_scalar($message )) $message  = (string ) $message ; else throw new exception("Bad message for message queue (must be string).");

	//??? if both [recipient] and [recipients] are set, should be send to both of them, or to [recipients] only?
	//??? now we use the second way: if [recipients] is set, then [recipient] is ignored.
	$recipient  = isset($data['recipient' ]) ? $data['recipient' ] : null;
	$recipients = isset($data['recipients']) ? $data['recipients'] : array($recipient);
	if (!is_array($recipients)) $recipients = array($recipients);//NB: $recipients will never be null here, so we don't recheck.
	$temp = array();
	foreach ($recipients as $recipient)
		if (is_null  ($recipient)) { continue; } else
		if (is_scalar($recipient)) { $temp[] = (string) $recipient; } else //NB: use recipient even if it is an empty string.
		throw new exception("Bad type of recipient in message queue (must be either null, or string).");
	$recipients = array_unique($temp);

	$template = coren::db('insert_template', compact('subject', 'message'));
	if (!empty($recipients)) coren::db('insert_envelopes', compact('template', 'priority', 'recipients'));

	if (!$this->silent)
	{
		coren::event($this->event_for_inject_success, compact('priority', 'subject', 'message', 'recipients'));
	}
	if (!$this->hidden)
	{
		if (!coren::depend('_dom_builder_0'))
			throw new exception("Tool '_dom_builder_0' missed.");

		$doc = coren::xml();
		$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'inject', compact('priority', 'subject', 'message'));
		foreach ($recipients as $recipient)
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'recipient', $recipient));
		coren::slot(coren::name($doc->documentElement->appendChild($ele), $this->name_for_inject_success), $this->slot_for_inject_success);
	}
}
Example #27
0
<?php defined('CORENINPAGE') or die('Hack!');

// Behavior.
#$event_errors = true;//???
#$print_errors = 'html';
#$print_rstats = 'text';

$rts_enable = true;
$rts_prefix = "\n<plaintext>\n";


coren::set_xsl_format('test1');

//	$dependency_search_root = '';
	$dependency_search_path = 'tools/;modules/;modules/event/;modules/identify/;modules/utility/;modules/database/';
	$dependency_search_dirs = 'tools/;modules/;modules/event/;modules/identify/;modules/utility/;modules/database/';
	$response_comes_first	= true;

	// Database.
//	$default_database = '__default_db__';
	$default_database_implementer = 'database_mysql_0';
	$default_database_configs = array(
		'host'		=> 'localhost',
		'port'		=>  null,
		'user'		=> 'coren-doy306',
		'pass'		=> 'iria',
		'base'		=> 'coren-doy306',
		'charset'	=> 'utf8',
		'tableprefix'	=> 'coren_',
		'persistent'	=> 1,
		'---!!!'	=> '!!!');
Example #28
0
public function identify ($data)
{
	$identifier = coren::event($this->event_for_account_detect_identifier, null);

	if (is_null($identifier))
	{
		if (!$this->silent)
		{
			coren::event($this->event_for_account_detect_skipped);
		}
		if (!$this->hidden)
		{
			if (!coren::depend('_dom_builder_0'))
				throw new exception("Tool '_dom_builder_0' missed.");

			$doc = coren::xml();
			$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'nothing', null);
			coren::slot(coren::name($doc->documentElement->appendChild($ele),
				$this->name_for_account_detect_skipped),
				$this->slot_for_account_detect_skipped);
		}
		return;
	}

	$information = coren::event($this->event_for_account_detect_information, compact('identifier'));

	$code =
		(is_null($information)    ? 'absent'   :
		($information['disabled'] ? 'disabled' :
		(null)));

	if (is_null($code))
	{
		$this->identifier  = $identifier ;
		$this->information = $information;

		if (!$this->silent)
		{
			coren::event($this->event_for_account_detect_successed, compact('identifier', 'information'));
		}
		if (!$this->hidden)
		{
			if (!coren::depend('_dom_builder_0'))
				throw new exception("Tool '_dom_builder_0' missed.");

			$doc = coren::xml();
			$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'account-detect-success', null);
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'identifier' , $identifier ));
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'information', $information));
			coren::slot(coren::name($doc->documentElement->appendChild($ele),
				$this->name_for_account_detect_successed),
				$this->slot_for_account_detect_successed);
		}
		return true;//NB: this stops futher handling of current event.
	} else
	{
		if (!$this->silent)
		{
			coren::event($this->event_for_account_detect_failed, compact('identifier', 'information', 'code'));
		}
		if (!$this->hidden)
		{
			if (!coren::depend('_dom_builder_0'))
				throw new exception("Tool '_dom_builder_0' missed.");

			$doc = coren::xml();
			$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'account-detect-failure', null);
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'code'       , $code       ));
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'identifier' , $identifier ));
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'information', $information));
			coren::slot(coren::name($doc->documentElement->appendChild($ele),
				$this->name_for_account_detect_failed),
				$this->slot_for_account_detect_failed);
		}
	}
}
Example #29
0
<?php defined('CORENINPAGE') or die('Hack!');
####################################################################################################
####################################################################################################
####################################################################################################
#
#...
#
####################################################################################################
####################################################################################################
####################################################################################################
#
if (!coren::depend('cache_directory_0')) return;
#
class cache_directory_string_0 extends cache_directory_0
{
#
####################################################################################################
####################################################################################################
####################################################################################################
#
public function __construct ($configs)
{
	parent::__construct($configs);
}
#
####################################################################################################
####################################################################################################
####################################################################################################
#
protected function _encode_ ($decoded)
{
Example #30
0
public function send ($data)
{
	if (!coren::have($this->privilege_for_send))
	{
		if (!$this->silent)
		{
			coren::event($this->event_for_not_authorized);
		}
		if (!$this->hidden)
		{
			if (!coren::depend('_dom_builder_0'))
				throw new exception("Tool '_dom_builder_0' missed.");

			$doc = coren::xml();
			$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'send', null);
			$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'not-authorized', null));
		}
//???		do nto throw here. see file ...inject... for reasoning.
//???		throw new exception("Not authorized to flush queue of messages.");
		return;
	}

	$recipient = isset($data['recipient']) ? $data['recipient'] : ''; if (is_scalar($recipient)) $recipient = (string ) $recipient; else throw new exception("Bad recipient for message mail (must be string).");
	$subject   = isset($data['subject'  ]) ? $data['subject'  ] : ''; if (is_scalar($subject  )) $subject   = (string ) $subject  ; else throw new exception("Bad subject for message mail (must be string).");
	$message   = isset($data['message'  ]) ? $data['message'  ] : ''; if (is_scalar($message  )) $message   = (string ) $message  ; else throw new exception("Bad message for message mail (must be string).");
	$headers   = (string) $this->headers;

	$recipient = trim(preg_replace("/(\\r|\\n)+/"   , " "      , $recipient));//NB: strip all newlines at all.
	$subject   = trim(preg_replace("/(\\r|\\n)+/"   , " "      , $subject  ));//NB: strip all newlines at all.
	$message   = trim(preg_replace("/(\\r(\\n?))/"  , "\n"     , $message  ));//NB: force   LF (  \n).
	$headers   = trim(preg_replace("/([^\\r]|^)\\n/", "\\1\r\n", $headers  ));//NB: force CRLF (\r\n).

	$result = @mail($recipient, $subject, $message, $headers);
	$errormsg = isset($php_errormsg) ? $php_errormsg : "Error in mail(); \$php_errormsg isn't set.";
	if (!$result) throw new exception($errormsg);

	if (!$this->silent)
	{
		coren::event($this->event_for_send_success);
	}
	if (!$this->hidden)
	{
		if (!coren::depend('_dom_builder_0'))
			throw new exception("Tool '_dom_builder_0' missed.");

		$doc = coren::xml();
		$ele = _dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'send', null);
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'recipient', $recipient));
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'subject'  , $subject  ));
		$ele->appendChild(_dom_builder_0::build_nodetree($doc, self::namespace, $this->prefix, 'message'  , $message  ));
		coren::slot(coren::name($doc->documentElement->appendChild($ele), $this->name), $this->slot);
	}
}