Commit 12aca4a5 authored by changi67's avatar changi67
parent 8e1b8338
......@@ -6,7 +6,7 @@
// $Id$
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'],basename(__FILE__)) !== false) {
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
}
......@@ -43,7 +43,7 @@ try {
if ( isset( $client_charset ) ) {
$charset_query = "SET NAMES $client_charset";
if ( defined('PDO::MYSQL_ATTR_INIT_COMMAND' ) ) {
if ( defined('PDO::MYSQL_ATTR_INIT_COMMAND') ) {
$pdo_options[ PDO::MYSQL_ATTR_INIT_COMMAND ] = $charset_query;
} else {
$pdo_post_queries[] = $charset_query;
......@@ -52,11 +52,11 @@ try {
unset( $charset_query );
}
$dbTiki = new PDO( "$db_tiki:$db_hoststring;dbname=$dbs_tiki", $user_tiki, $pass_tiki, $pdo_options );
$dbTiki->setAttribute(PDO::ATTR_CASE,PDO::CASE_NATURAL);
$dbTiki->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
$dbTiki->setAttribute(PDO::ATTR_ORACLE_NULLS,PDO::NULL_EMPTY_STRING);
TikiDb::set( new TikiDb_Pdo( $dbTiki ) );
$dbTiki = new PDO("$db_tiki:$db_hoststring;dbname=$dbs_tiki", $user_tiki, $pass_tiki, $pdo_options);
$dbTiki->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
$dbTiki->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$dbTiki->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
TikiDb::set(new TikiDb_Pdo($dbTiki));
$tempDb = TikiDb::get();
if ( $api_tiki_forced || ( isset( $dbversion_tiki ) && $dbversion_tiki[0] >= 4 ) ) {
......@@ -65,23 +65,24 @@ try {
$previousApi = 'adodb';
}
foreach( $pdo_post_queries as $query ) {
$tempDb->query( $query );
foreach ( $pdo_post_queries as $query ) {
$tempDb->query($query);
}
unset( $tempDb, $pdo_options, $pdo_post_queries );
unset($tempDb, $pdo_options, $pdo_post_queries);
} catch( PDOException $e ) {
require_once 'lib/init/smarty.php';
$smarty->assign( 'msg', $e->getMessage() );
$smarty->assign( 'where', 'connection');
echo $smarty->fetch( 'database-connection-error.tpl' );
$smarty->assign('msg', $e->getMessage());
$smarty->assign('where', 'connection');
echo $smarty->fetch('database-connection-error.tpl');
exit;
}
if ( ! function_exists( 'close_connection' ) ) {
function close_connection() {
if ( ! function_exists('close_connection') ) {
function close_connection()
{
global $dbTiki;
$dbTiki= NULL;
}
......
......@@ -45,13 +45,10 @@ class Debugger extends ResultType
function rescan_for_commands()
{
$files = array();
if (is_dir(DBG_PLUGINS_DIR))
{
if ($dh = opendir(DBG_PLUGINS_DIR))
{
while (($file = readdir($dh)) !== false)
{
if (preg_match("/^debug-command_.*\.php$/",$file))
if (is_dir(DBG_PLUGINS_DIR)) {
if ($dh = opendir(DBG_PLUGINS_DIR)) {
while (($file = readdir($dh)) !== false) {
if (preg_match("/^debug-command_.*\.php$/", $file))
array_push($files, $file);
}
closedir($dh);
......@@ -59,15 +56,12 @@ class Debugger extends ResultType
}
// Refresh object in commands array
$this->commands = array();
foreach ($files as $file)
{
foreach ($files as $file) {
include_once(DBG_PLUGINS_DIR.'/'.$file);
$func_name = preg_replace(",debug-command_([A-Za-z0-9]+)\.php,","dbg_command_factory_\\1", $file);
if (function_exists($func_name))
{
$func_name = preg_replace(",debug-command_([A-Za-z0-9]+)\.php,", "dbg_command_factory_\\1", $file);
if (function_exists($func_name)) {
$obj = $func_name();
if (is_subclass_of($obj, "DebuggerCommand"))
{
if (is_subclass_of($obj, "DebuggerCommand")) {
// If command have name, insert in by name, else assume that
// it is interface only extension
if (strlen($obj->name()) > 0)
......@@ -89,37 +83,29 @@ class Debugger extends ResultType
$rawcmd = trim($rawcmd);
$result = '';
// Is smth else in command line 'cept spaces?
if (strlen($rawcmd))
{
if (strlen($rawcmd)) {
// Extract first word (possible the only) from command line...
$cmd = substr($rawcmd, 0, (($pos = strpos($rawcmd, ' ')) == false ? strlen($rawcmd) : $pos));
// Check for the only internal command: help :)
if (strcmp($cmd, 'help') !== 0)
{
if (strcmp($cmd, 'help') !== 0) {
// No this is smth other... Is assiciated handler present?
if (isset($this->commands[$cmd]))
{
if (isset($this->commands[$cmd])) {
// OK. May call external command...
$result = $this->commands[$cmd]->execute(str_replace($cmd, '', $rawcmd));
$this->set_result_type($this->commands[$cmd]->result_type());
if ($this->result_type() == TPL_RESULT)
$this->set_result_tpl($this->commands[$cmd]->result_tpl());
}
else
{
$result = $this->commands[$cmd]->execute(str_replace($cmd, '', $rawcmd));
$this->set_result_type($this->commands[$cmd]->result_type());
if ($this->result_type() == TPL_RESULT)
$this->set_result_tpl($this->commands[$cmd]->result_tpl());
} else {
// Command not found... Issue a spam!
$result = '<span class="dbgerror">No such command "'.$cmd.'"</span>';
$this->set_result_type(HTML_RESULT);
}
}
else
{
}
} else {
// Handle help command. Is help for some command needed?
$rawcmd = trim(str_replace($cmd, "", $rawcmd));
$result = array();
$result["action"] = 'none';
if (strlen($rawcmd) == 0)
{
if (strlen($rawcmd) == 0) {
$result["action"] = 'list';
// No. This is along help on command line. Append my help...
$result[0][] = array('cmd' => 'help',
......@@ -127,25 +113,20 @@ class Debugger extends ResultType
foreach ($this->commands as $cmdobj)
if (strlen(trim($cmdobj->name())) > 0)
$result[0][] = array('cmd' => $cmdobj->name(), 'description' => $cmdobj->description());
}
else
{
} else {
// What command help requested for??
if (isset($this->commands[$rawcmd]))
{
$result["action"] = 'one';
$cmdobj = $this->commands[$rawcmd];
$result['name'] = $cmdobj->name();
$result['description'] = $cmdobj->description();
$result['syntax'] = $cmdobj->syntax();
$result['example'] = $cmdobj->example();
}
else
{
$this->set_result_type(HTML_RESULT);
return '<tr><td><span class="dbgerror">No such command "'.$rawcmd.'"</span></td></tr>';
}
}
if (isset($this->commands[$rawcmd])) {
$result["action"] = 'one';
$cmdobj = $this->commands[$rawcmd];
$result['name'] = $cmdobj->name();
$result['description'] = $cmdobj->description();
$result['syntax'] = $cmdobj->syntax();
$result['example'] = $cmdobj->example();
} else {
$this->set_result_type(HTML_RESULT);
return '<tr><td><span class="dbgerror">No such command "'.$rawcmd.'"</span></td></tr>';
}
}
$this->set_result_type(TPL_RESULT);
$this->set_result_tpl('debug/tiki-debug_console_help.tpl');
}
......@@ -176,8 +157,7 @@ class Debugger extends ResultType
{
$result = '';
$v = trim($v);
if (strlen(str_replace("$", "", $v)) > 0)
{
if (strlen(str_replace("$", "", $v)) > 0) {
// Need to make var global... strip [] if needed
$global = (($pos = strpos($v, '[')) == false) ? $v : substr($v, 0, $pos);
//
......
......@@ -23,7 +23,8 @@
$charset = 'utf-8'; // What charset we do use in Tiki
$in_str = '';
function encode_headers($in_str, $charset) {
function encode_headers($in_str, $charset)
{
$out_str = $in_str;
if ($out_str && $charset) {
......@@ -51,59 +52,62 @@ function encode_headers($in_str, $charset) {
return $out_str;
}// end function encode_headers
function tiki_mail_setup() {
function tiki_mail_setup()
{
static $done = false;
if( $done ) {
if ( $done ) {
return;
}
global $prefs;
if( $prefs['zend_mail_handler'] == 'smtp' ) {
if ( $prefs['zend_mail_handler'] == 'smtp' ) {
$options = array();
if( $prefs['zend_mail_smtp_auth'] ) {
if ( $prefs['zend_mail_smtp_auth'] ) {
$options['auth'] = $prefs['zend_mail_smtp_auth'];
$options['username'] = $prefs['zend_mail_smtp_user'];
$options['password'] = $prefs['zend_mail_smtp_pass'];
}
if( $prefs['zend_mail_smtp_port'] ) {
if ( $prefs['zend_mail_smtp_port'] ) {
$options['port'] = $prefs['zend_mail_smtp_port'];
}
if( $prefs['zend_mail_smtp_security'] ) {
if ( $prefs['zend_mail_smtp_security'] ) {
$options['ssl'] = $prefs['zend_mail_smtp_security'];
}
$transport = new Zend_Mail_Transport_Smtp( $prefs['zend_mail_smtp_server'], $options );
Zend_Mail::setDefaultTransport( $transport );
$transport = new Zend_Mail_Transport_Smtp($prefs['zend_mail_smtp_server'], $options);
Zend_Mail::setDefaultTransport($transport);
}
$done = true;
}
function tiki_get_basic_mail() {
function tiki_get_basic_mail()
{
tiki_mail_setup();
return new Zend_Mail('UTF-8');
}
function tiki_get_admin_mail() {
function tiki_get_admin_mail()
{
global $prefs;
$mail = tiki_get_basic_mail();
$mail->setFrom( $prefs['sender_email'], $prefs['browsertitle'] );
$mail->setFrom($prefs['sender_email'], $prefs['browsertitle']);
return $mail;
}
function tiki_send_admin_mail( $email, $recipientName, $subject, $textBody ) {
function tiki_send_admin_mail( $email, $recipientName, $subject, $textBody )
{
$mail = tiki_get_admin_mail();
$mail->addTo( $email, $recipientName );
$mail->addTo($email, $recipientName);
$mail->setSubject( $subject );
$mail->setBodyText( $textBody );
$mail->setSubject($subject);
$mail->setBodyText($textBody);
$mail->send();
}
......@@ -6,29 +6,30 @@
// $Id$
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
exit;
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
class MailinLib extends TikiLib
{
function list_mailin_accounts($offset, $maxRecords, $sort_mode, $find) {
function list_mailin_accounts($offset, $maxRecords, $sort_mode, $find)
{
if ($find) {
$findesc = '%'.$find.'%';
$mid = " where `account` like ?";
$bindvars = array($findesc);
} else {
$mid = " ";
$mid = " ";
$bindvars = array();
}
$query = "select * from `tiki_mailin_accounts` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_mailin_accounts` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
$ret = array();
while ($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
......@@ -41,7 +42,8 @@ class MailinLib extends TikiLib
return $retval;
}
function list_active_mailin_accounts($offset, $maxRecords, $sort_mode, $find) {
function list_active_mailin_accounts($offset, $maxRecords, $sort_mode, $find)
{
if ($find) {
$findesc = '%'.$find.'%';
......@@ -54,8 +56,8 @@ class MailinLib extends TikiLib
$query = "select * from `tiki_mailin_accounts` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_mailin_accounts` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
$ret = array();
while ($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
......@@ -68,30 +70,33 @@ class MailinLib extends TikiLib
return $retval;
}
function replace_mailin_account($accountId, $account, $pop, $port, $username, $pass, $smtp, $useAuth, $smtpPort, $type, $active, $anonymous, $attachments, $article_topicId = NULL, $article_type = NULL, $discard_after=NULL) {
if ($accountId) {
$bindvars = array($account,$pop,(int)$port,(int)$smtpPort,$username,$pass,$smtp,$useAuth,$type,$active,$anonymous,$attachments,(int)$article_topicId,$article_type,$discard_after,(int)$accountId);
$query = "update `tiki_mailin_accounts` set `account`=?, `pop`=?, `port`=?, `smtpPort`=?, `username`=?, `pass`=?, `smtp`=?, `useAuth`=?, `type`=?, `active`=?, `anonymous`=?, `attachments`=?, `article_topicId`=?, `article_type`=? , `discard_after`=? where `accountId`=?";
$result = $this->query($query,$bindvars);
} else {
$bindvars = array($account,$pop,(int)$port,(int)$smtpPort,$username,$pass,$smtp,$useAuth,$type,$active,$anonymous,$attachments,(int)$article_topicId,$article_type);
$query = "delete from `tiki_mailin_accounts` where `account`=? and `pop`=? and `port`=? and `smtpPort`=? and `username`=? and `pass`=? and `smtp`=? and `useAuth`=? and `type`=? and `active`=? and `anonymous`=? and `attachments`=? and `article_topicId`=?, `article_type`=?";
$result = $this->query($query,$bindvars,-1,-1,false);
$query = "insert into `tiki_mailin_accounts`(`account`,`pop`,`port`,`smtpPort`,`username`,`pass`,`smtp`,`useAuth`,`type`,`active`,`anonymous`,`attachments`,`article_topicId`,`article_type`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$result = $this->query($query,$bindvars);
}
return true;
}
function replace_mailin_account($accountId, $account, $pop, $port, $username, $pass, $smtp, $useAuth, $smtpPort, $type, $active, $anonymous, $attachments, $article_topicId = NULL, $article_type = NULL, $discard_after=NULL)
{
if ($accountId) {
$bindvars = array($account,$pop,(int)$port,(int)$smtpPort,$username,$pass,$smtp,$useAuth,$type,$active,$anonymous,$attachments,(int)$article_topicId,$article_type,$discard_after,(int)$accountId);
$query = "update `tiki_mailin_accounts` set `account`=?, `pop`=?, `port`=?, `smtpPort`=?, `username`=?, `pass`=?, `smtp`=?, `useAuth`=?, `type`=?, `active`=?, `anonymous`=?, `attachments`=?, `article_topicId`=?, `article_type`=? , `discard_after`=? where `accountId`=?";
$result = $this->query($query, $bindvars);
} else {
$bindvars = array($account,$pop,(int)$port,(int)$smtpPort,$username,$pass,$smtp,$useAuth,$type,$active,$anonymous,$attachments,(int)$article_topicId,$article_type);
$query = "delete from `tiki_mailin_accounts` where `account`=? and `pop`=? and `port`=? and `smtpPort`=? and `username`=? and `pass`=? and `smtp`=? and `useAuth`=? and `type`=? and `active`=? and `anonymous`=? and `attachments`=? and `article_topicId`=?, `article_type`=?";
$result = $this->query($query, $bindvars, -1, -1, false);
$query = "insert into `tiki_mailin_accounts`(`account`,`pop`,`port`,`smtpPort`,`username`,`pass`,`smtp`,`useAuth`,`type`,`active`,`anonymous`,`attachments`,`article_topicId`,`article_type`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$result = $this->query($query, $bindvars);
}
return true;
}
function remove_mailin_account($accountId) {
function remove_mailin_account($accountId)
{
$query = "delete from `tiki_mailin_accounts` where `accountId`=?";
$result = $this->query($query,array((int)$accountId));
$result = $this->query($query, array((int)$accountId));
return true;
}
function get_mailin_account($accountId) {
function get_mailin_account($accountId)
{
$query = "select * from `tiki_mailin_accounts` where `accountId`=?";
$result = $this->query($query,array((int)$accountId));
$result = $this->query($query, array((int)$accountId));
if (!$result->numRows()) {
return false;
}
......
......@@ -8,7 +8,7 @@
// For documentation how to use this file please see the comment at the end of this file
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
......@@ -20,31 +20,32 @@ require_once('lib/categories/categlib.php');
class AreasLib extends CategLib
{
function HandleObjectCategories($objectCategoryIds){
function HandleObjectCategories($objectCategoryIds)
{
global $prefs, $perspectivelib, $_SESSION;
if (!empty($objectCategoryIds)){
if(!isset($_SESSION['current_perspective'])) $_SESSION['current_perspective'] = 0;
foreach($objectCategoryIds as $categId){
// If parent category has ID equal to value of $prefs['areas_root']
$foundPerspective = NULL;
if ($this->get_category_parent($categId) == $prefs['areas_root']){
$foundPerspective = $this->get_perspective_by_categid($categId);
// If the found perspective is different than the current perspective, update it.
if ($foundPerspective != $_SESSION['current_perspective']) {
$perspectivelib->set_perspective($foundPerspective);
//Reroute browser back to calling script after we have applied our hack.
header("Location: ". $_SERVER['REQUEST_URI']);
}
}else{ // If parent category id does not equal $prefs['areas_root'] set the default perspective (0)
if ($foundPerspective != $_SESSION['current_perspective']) {
$perspectivelib->set_perspective(0);
//Reroute browser back to calling script after we have applied our hack.
header("Location: ". $_SERVER['REQUEST_URI']);
if (!empty($objectCategoryIds)) {
if (!isset($_SESSION['current_perspective'])) $_SESSION['current_perspective'] = 0;
foreach ($objectCategoryIds as $categId) {
// If parent category has ID equal to value of $prefs['areas_root']
$foundPerspective = NULL;
if ($this->get_category_parent($categId) == $prefs['areas_root']) {
$foundPerspective = $this->get_perspective_by_categid($categId);
// If the found perspective is different than the current perspective, update it.
if ($foundPerspective != $_SESSION['current_perspective']) {
$perspectivelib->set_perspective($foundPerspective);
//Reroute browser back to calling script after we have applied our hack.
header("Location: ". $_SERVER['REQUEST_URI']);
}
} else { // If parent category id does not equal $prefs['areas_root'] set the default perspective (0)
if ($foundPerspective != $_SESSION['current_perspective']) {
$perspectivelib->set_perspective(0);
//Reroute browser back to calling script after we have applied our hack.
header("Location: ". $_SERVER['REQUEST_URI']);
}
}
}
}
}
}
/* else if ($_SESSION['current_perspective'] !== 0) // decomment this violates the category jail
{
$perspectivelib->set_perspective(0);
......@@ -56,8 +57,9 @@ class AreasLib extends CategLib
for the difference between should and is, first retrieve all perspectives given for any reason
and then choose one in the function below, namely the first.
*/
function get_perspectives_by_categid($categId){
$result = $this->query( "SELECT `categId`, `perspectives` FROM tiki_areas WHERE categId = ?", array($categId));
function get_perspectives_by_categid($categId)
{
$result = $this->query("SELECT `categId`, `perspectives` FROM tiki_areas WHERE categId = ?", array($categId));
while($row = $result->fetchRow()) return unserialize($row['perspectives']);
return false;
}
......@@ -65,36 +67,38 @@ class AreasLib extends CategLib
pick up the first or only perspective assigned to category with id categId
returns false if there is no entry for this category and returns 0 if it has no perspective
*/
function get_perspective_by_categid($categId){
function get_perspective_by_categid($categId)
{
$persp = $this->get_perspectives_by_categid($categId);
if($persp===false) return false;
if(count($persp)==0) return 0;
if ($persp===false) return false;
if (count($persp)==0) return 0;
return $persp[0];
}
function update_areas(){
function update_areas()
{
global $prefs;
$areas = array();
$descendants = $this->get_category_descendants($prefs['areas_root']);
if( is_array($descendants) ){
foreach($descendants as $item)
if ( is_array($descendants) ) {
foreach ($descendants as $item)
$areas[$item] = array(); // it only should be just one perspective assigned
$result = $this->fetchAll( "SELECT `perspectiveId`, `pref`, `value` FROM tiki_perspective_preferences WHERE pref = 'category_jail'", array());
if(count($result)!=0){
foreach( $result as $row ) {
$categs = unserialize( $row['value'] );
foreach($categs as $item) if(array_key_exists($item, $areas)) $areas[$item][] = $row['perspectiveId'];
}
// to get rid off probably old data
$this->query("DELETE FROM tiki_areas");
foreach($areas as $key=>$item){
$result = $this->query("INSERT INTO tiki_areas (categId, perspectives) VALUES(?,?)", array($key, serialize($item)));
$result = $this->fetchAll("SELECT `perspectiveId`, `pref`, `value` FROM tiki_perspective_preferences WHERE pref = 'category_jail'", array());
if (count($result)!=0) {
foreach ( $result as $row ) {
$categs = unserialize($row['value']);
foreach ($categs as $item) if (array_key_exists($item, $areas)) $areas[$item][] = $row['perspectiveId'];
}
// to get rid off probably old data
$this->query("DELETE FROM tiki_areas");
foreach ($areas as $key=>$item) {
$result = $this->query("INSERT INTO tiki_areas (categId, perspectives) VALUES(?,?)", array($key, serialize($item)));
}
}else return tra("No category jail set in any perspective.");
} else return tra("No category jail set in any perspective.");
return true;
}else return tra("Areas root category id")." ".tra("is invalid.");
} else return tra("Areas root category id")." ".tra("is invalid.");
}
} // class end
$areaslib = new AreasLib();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment