From: Florent Bruneau
\n',mb_strlen('$1'))", "str_repeat('\n',mb_strlen('$1'))", "ligne1\\\\\nligne2");
-
- // * unordered list
- MiniWiki::Markup("/(^|\n)\*(([^\n]*(\n|$))(\*[^\n]*(\n|$))*)/se",
- "'
'", - "'$1 -' . str_replace(\"\\n*\", \"\\n -\", '$2')", - "* element1\n* element2\n* element3"); - // # unordered list - MiniWiki::Markup("/(^|\n)#(([^\n]*(\n|$))(#[^\n]*(\n|$))*)/se", "'
', "\n\n", "paragraphe1\n\nparagraphe2"); - MiniWiki::Markup("/\n/", ' ', "\n"); - MiniWiki::Markup("/^.*<\/p>.*
.*$/s", "
$0
", "$0"); - - // french typo rules, unbreakable spaces - MiniWiki::Markup("/ +([!?:;])/", " $1", "$0"); - } - - public static function WikiToHTML($wiki, $title = false) - { - if (!$title) { - $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index]; - MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'"; - } - $html = preg_replace(MiniWiki::$patternsWiki, - MiniWiki::$replacementHTML, - htmlentities(trim($wiki), ENT_COMPAT, 'UTF-8')); - if (!$title) { - MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12; - } - return $html; - } - - private static function justify($text, $n) - { - $arr = explode("\n", wordwrap($text, $n)); - $arr = array_map('trim', $arr); - $res = ''; - foreach ($arr as $key => $line) { - $nxl = isset($arr[$key+1]) ? trim($arr[$key+1]) : ''; - $nxl_split = preg_split('! +!u', $nxl); - $nxw_len = count($nxl_split) ? mb_strlen($nxl_split[0]) : 0; - $line = trim($line); - - if (mb_strlen($line)+1+$nxw_len < $n) { - $res .= "$line\n"; - continue; - } - - if (preg_match('![.:;]$!u',$line)) { - $res .= "$line\n"; - continue; - } - - $tmp = preg_split('! +!u', trim($line)); - $words = count($tmp); - if ($words <= 1) { - $res .= "$line\n"; - continue; - } - - $len = array_sum(array_map('mb_strlen', $tmp)); - $empty = $n - $len; - $sw = floatval($empty) / floatval($words-1); - - $cur = 0; - $l = ''; - foreach ($tmp as $word) { - $l .= $word; - $cur += $sw + strlen($word); // Use strlen here instead of mb_strlen because it is used by str_pad - // which is not multibyte compatible - $l = str_pad($l, intval($cur + 0.5)); - } - $res .= trim($l)."\n"; - } - return trim($res); - } - - - public static function WikiToText($wiki, $just=false, $indent=0, $width=68, $title=false) - { - if (!$title) { - $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index]; - MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'"; - } - //$text = trim($wiki); - //foreach (MiniWiki::$patternsWiki as $key=>$pattern) { - // echo $key . " - " . $pattern . "\n"; - // $text = preg_replace($pattern, MiniWiki::$replacementText[$key], $text); - //} - $text = preg_replace(MiniWiki::$patternsWiki, MiniWiki::$replacementText, trim($wiki)); - if (!$title) { - MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12; - } - $text = $just ? MiniWiki::justify($text, $width - $indent) : wordwrap($text, $width - $indent); - if($indent) { - $ind = str_pad('',$indent); - $text = $ind.str_replace("\n","\n$ind",$text); - } - return $text; - } - - static public function help($with_title = false) - { - if (!$with_title) { - $info12 = MiniWiki::$info[MiniWiki::$title_index]; - unset(MiniWiki::$info[MiniWiki::$title_index]); - } - - $res = array(); - foreach (MiniWiki::$info as $value) { - $res[$value] = MiniWiki::wikiToHtml($value, true); - } - - if (!$with_title) { - MiniWiki::$info[MiniWiki::$title_index] = $info12; - } - return $res; - } -} - -MiniWiki::init(); - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/mmlist.php b/core/classes/mmlist.php deleted file mode 100644 index a16b1c6..0000000 --- a/core/classes/mmlist.php +++ /dev/null @@ -1,38 +0,0 @@ -mail->domain : $fqdn; - $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom"; - parent::__construct($url); - if ($globals->debug & DEBUG_BT) { - $this->bt = new PlBacktrace('MMList'); - } - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/platal.php b/core/classes/platal.php deleted file mode 100644 index 2a69b72..0000000 --- a/core/classes/platal.php +++ /dev/null @@ -1,354 +0,0 @@ -startAvailableAuth()) { - Platal::page()->trigError('Données d\'authentification invalide.'); - } - - $modules = func_get_args(); - if (is_array($modules[0])) { - $modules = $modules[0]; - } - $this->path = trim(Get::_get('n', null), '/'); - - $this->__mods = array(); - $this->__hooks = array(); - - array_unshift($modules, 'core'); - foreach ($modules as $module) { - $module = strtolower($module); - $this->__mods[$module] = $m = PLModule::factory($module); - $this->__hooks += $m->handlers(); - } - - if ($globals->mode == '') { - pl_redirect('index.html'); - } - } - - public function pl_self($n = null) - { - if (is_null($n)) - return $this->path; - - if ($n >= 0) - return join('/', array_slice($this->argv, 0, $n + 1)); - - if ($n <= -count($this->argv)) - return $this->argv[0]; - - return join('/', array_slice($this->argv, 0, $n)); - } - - protected function find_hook() - { - $p = $this->path; - - while ($p) { - if (array_key_exists($p, $this->__hooks)) - break; - - $p = substr($p, 0, strrpos($p, '/')); - } - - if (empty($this->__hooks[$p])) { - return null; - } - - $hook = $this->__hooks[$p]; - - if (!is_callable($hook['hook'])) { - return null; - } - - $this->https = ($hook['type'] & NO_HTTPS) ? false : true; - $this->argv = explode('/', substr($this->path, strlen($p))); - $this->argv[0] = $p; - - return $hook; - } - - protected function find_nearest_key($key, array &$array) - { - $keys = array_keys($array); - if (in_array($key, $keys)) { - return $key; - } - - if (($pos = strpos($key, '.php')) !== false) { - $key = substr($key, 0, $pos); - } - - $has_end = in_array("#final#", $keys); - if (strlen($key) > 24 && $has_end) { - return "#final#"; - } - - foreach ($keys as $k) { - if ($k == "#final#") { - continue; - } - $lev = levenshtein($key, $k); - - if ((!isset($val) || $lev < $val) - && ($lev <= strlen($k)/2 || strpos($k, $key) !== false || strpos($key, $k) !== false)) { - $val = $lev; - $best = $k; - } - } - if (!isset($best) && $has_end) { - return "#final#"; - } else if (isset($best)) { - return $best; - } - return null; - } - - public function near_hook() - { - $hooks = array(); - $leafs = array(); - foreach ($this->__hooks as $hook=>$handler) { - if (!$this->check_perms($handler['perms'])) { - continue; - } - $parts = split('/', $hook); - $place =& $hooks; - foreach ($parts as $part) { - if (!isset($place[$part])) { - $place[$part] = array(); - } - $place =& $place[$part]; - } - $leaf = $parts[count($parts)-1]; - if (!isset($leafs[$leaf])) { - $leafs[$leaf] = $hook; - } else if (is_array($leafs[$leaf])) { - $leafs[$leaf][] = $hook; - } else { - $leafs[$leaf] = array($hook, $leafs[$leaf]); - } - $place["#final#"] = array(); - } - - // search for the nearest full path - $p = split('/', $this->path); - $place =& $hooks; - $link = ''; - foreach ($p as $k) { - if (!isset($ended)) { - $key = $this->find_nearest_key($k, $place); - } else { - $key = $k; - } - if ($key == "#final#") { - if (!array_key_exists($link, $this->__hooks)) { - $link = ''; - break; - } - $key = $k; - $ended = true; - } - if (!is_null($key)) { - if (!empty($link)) { - $link .= '/'; - } - $link .= $key; - $place =& $place[$key]; - } else { - $link = ''; - break; - } - } - if ($link == $this->path) { - $link = ''; - } - if ($link && levenshtein($link, $this->path) < strlen($link)/3) { - return $link; - } - - // search for missing namespace (the given name is a leaf) - $leaf = array_shift($p); - $args = count($p) ? '/' . implode('/', $p) : ''; - if (isset($leafs[$leaf]) && !is_array($leafs[$leaf]) && $leafs[$leaf] != $this->path) { - return $leafs[$leaf] . $args; - } - unset($val); - $best = null; - foreach ($leafs as $k=>&$path) { - if (is_array($path)) { - continue; - } - $lev = levenshtein($leaf, $k); - - if ((!isset($val) || $lev < $val) - && ($lev <= strlen($k)/2 || strpos($k, $leaf) !== false || strpos($leaf, $k) !== false)) { - $val = $lev; - $best = $path; - } - } - return $best == null ? ( $link ? $link : null ) : $best . $args; - } - - protected function check_perms($perms) - { - if (!$perms) { // No perms, no check - return true; - } - $s_perms = S::v('perms'); - return $s_perms->hasFlagCombination($perms); - } - - private function call_hook(PlPage &$page) - { - $hook = $this->find_hook(); - if (empty($hook)) { - return PL_NOT_FOUND; - } - global $globals, $session; - if ($this->https && !$_SERVER['HTTPS'] && $globals->core->secure_domain) { - http_redirect('https://' . $globals->core->secure_domain . $_SERVER['REQUEST_URI']); - } - - $args = $this->argv; - $args[0] =& $page; - - if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) { - if ($hook['type'] & DO_AUTH) { - if (!$session->start($hook['auth'])) { - $this->force_login($page); - } - } else { - return PL_FORBIDDEN; - } - } - if ($hook['auth'] != AUTH_PUBLIC && !$this->check_perms($hook['perms'])) { - return PL_FORBIDDEN; - } - - $val = call_user_func_array($hook['hook'], $args); - if ($val == PL_DO_AUTH) { - // The handler need a better auth with the current args - if (!$session->start($hook['auth'])) { - $this->force_login($page); - } - $val = call_user_func_array($hook['hook'], $args); - } - return $val; - } - - public function force_login(PlPage &$page) - { - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); - if (S::logged()) { - $page->changeTpl('core/password_prompt_logged.tpl'); - $page->addJsLink('do_challenge_response_logged.js'); - } else { - $page->changeTpl('core/password_prompt.tpl'); - $page->addJsLink('do_challenge_response.js'); - } - $page->assign('platal', $this); - $page->run(); - } - - public function run() - { - $page =& self::page(); - - if (empty($this->path)) { - $this->path = 'index'; - } - - $page->assign('platal', $this); - switch ($this->call_hook($page)) { - case PL_FORBIDDEN: - $this->__mods['core']->handler_403($page); - break; - - case PL_NOT_FOUND: - $this->__mods['core']->handler_404($page); - break; - } - - $page->assign('platal', $this); - $page->run(); - } - - public function on_subscribe($forlife, $uid, $promo, $pass) - { - $args = func_get_args(); - foreach ($this->__mods as $mod) { - if (!is_callable($mod, 'on_subscribe')) - continue; - call_user_func_array(array($mod, 'on_subscribe'), $args); - } - } - - static public function &page() - { - global $platal; - if (is_null(self::$_page)) { - $pageclass = PL_PAGE_CLASS; - self::$_page = new $pageclass(); - } - return self::$_page; - } - - static public function &session() - { - global $session; - return $session; - } - - static public function &globals() - { - global $globals; - return $globals; - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/plbacktrace.php b/core/classes/plbacktrace.php deleted file mode 100644 index 9fb80ec..0000000 --- a/core/classes/plbacktrace.php +++ /dev/null @@ -1,116 +0,0 @@ -add($entry, $sizef, $timef, $errorf); - } - } - - private function fixCharset($action) - { - if (!is_string($action)) { - return $action; - } else { - return is_utf8($action) ? $action : utf8_encode($action); - } - } - - private function add(array &$entry, $sizef = 'rows', $timef = 'exectime', $errorf = 'error') - { - $trace = array(); - $trace['action'] = $this->fixCharset($entry['action']); - unset($entry['action']); - $trace['exectime'] = @$entry[$timef]; - $this->totaltime += $trace['exectime']; - unset($entry[$timef]); - $trace['rows'] = @$entry[$sizef]; - unset($entry[$sizef]); - $trace['error'] = $this->fixCharset(@$entry[$errorf]); - unset($entry[$errorf]); - if ($trace['error']) { - $this->error = true; - } - $trace['data'] = array($this->fixCharset($entry)); - $this->traces[] =& $trace; - } - - public function newEvent($action, $rows = 0, $error = null, array $userdata = array()) - { - $trace = array('action' => $this->fixCharset($action), 'time' => 0); - $this->traces[] =& $trace; - $this->update($rows, $error, $userdata); - } - - public function start($action) - { - $this->traces[] = array('action' => $this->fixCharset($action), 'starttime' => microtime(true));; - } - - public function stop($rows = 0, $error = null, array $userdata = array()) - { - $time = microtime(true); - if (!$this->traces) { - return; - } - $trace =& $this->traces[count($this->traces) - 1]; - $trace['exectime'] = $time - $trace['starttime']; - unset($trace['starttime']); - $this->totaltime += $trace['exectime']; - $this->update($rows, $error, $userdata); - } - - public function update($rows = 0, $error = null, array $userdata = array()) - { - $trace =& $this->traces[count($this->traces) - 1]; - $trace['rows'] = $rows; - $trace['error'] = $this->fixCharset($error); - array_walk_recursive($userdata, array($this, 'fixCharset')); - $trace['data'] = $userdata; - if ($trace['error']) { - $this->error = true; - } - } - - public static function clean() - { - foreach (PlBacktrace::$bt as $name=>&$entry) { - if (!$entry->traces) { - unset(PlBacktrace::$bt[$name]); - } - } - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/plflagset.php b/core/classes/plflagset.php deleted file mode 100644 index 1971751..0000000 --- a/core/classes/plflagset.php +++ /dev/null @@ -1,123 +0,0 @@ -sep = $sep; - $splitted = explode($sep, $flags); - foreach ($splitted as $part) { - $this->values[$part] = true; - } - } - - - /** add flag - * @param $flag XXX - * @return VOID - */ - public function addFlag($flag) - { - if (empty($flag)) { - return; - } - $this->values[$flag] = true; - } - - - /** test si flag ou pas - * @param $flag XXX - * @return 1 || 0 - */ - public function hasFlag($flag) - { - return !empty($flag) && isset($this->values[$flag]) && $this->values[$flag]; - } - - /** test flag combination - */ - public function hasFlagCombination($flag) - { - $perms = explode(',', $flag); - foreach ($perms as $perm) - { - $ok = true; - $rights = explode(':', $perm); - foreach ($rights as $right) { - if (($right{0} == '!' && $this->hasFlag(substr($right, 1))) || !$this->hasFlag($right)) { - $ok = false; - } - } - if ($ok) { - return true; - } - } - return false; - } - - /** remove flag - * @param $flag XXX - * @return VOID - */ - public function rmFlag($flag) - { - if (empty($flag)) { - return; - } - if (isset($this->values[$flag])) { - unset($this->values[$flag]); - } - } - - - /** return the PlFlagSet - */ - public function flags() - { - $flags = ''; - foreach ($this->values as $key=>$value) { - if (!empty($flags)) { - $flags .= $this->sep; - } - if ($value) { - $flags .= $key; - } - } - return $flags; - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/plglobals.php b/core/classes/plglobals.php deleted file mode 100644 index 2636890..0000000 --- a/core/classes/plglobals.php +++ /dev/null @@ -1,243 +0,0 @@ - - * [SectionName] - * fieldname = value - * - * - * With this configuration file, you'll be able to access 'value' via - * $globals->sectionname->fieldname. Let say 'sectionname' is a namespace - * - * - * You should derivate this class into a local Globals class. In this class - * you can specify configuration variables that belongs to the 'global' namespace - * (accessible via $global->fieldname). To do so, just define the fieldname - * in your class and set its value in the [Core] section of you ini file. - */ -class PlGlobals -{ - public $coreVersion = '0.9.17'; - - /** Debug level. - * This is a combination of the DEBUG_ flags. As soon as at least - * one flag is set, the debug mode is activated, this means: - * - debug panel on the top of the pages - * - don't hide php notices - * - recompile templates when they have been changed - */ - public $debug = 0; - - /** Access mode. - */ - public $mode = 'rw'; // 'rw' => read/write, - // 'r' => read/only - // '' => site down - - /** BaseURL of the site. - * This is read from the HTTP headers if available but you MUST give a - * default value for this field in you configuration file (because, this - * can be used in CLI scripts that has no access no HTTP headers...) - * - * [Core] - * baseurl = "https//www.mysite.org/" - */ - public $baseurl; - - /** In case your base url is https-based, this provied an HTTP-based value - * for the URL. - */ - public $baseurl_http; - - /** paths */ - public $spoolroot; - - /** Localization configuration. - */ - public $locale; - public $timezone; - - /** You must give a list of file to load. - * The filenames given are relatives to the config path of your plat/al installation. - */ - public function __construct(array $files) - { - $this->spoolroot = dirname(dirname(dirname(__FILE__))); - - $this->readConfig($files); - if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) { - $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; - $this->baseurl = @trim($base .$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/'); - $this->baseurl_http = @trim('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/'); - } - - $this->setLocale(); - } - - private function readIniFile($filename) - { - $array = parse_ini_file($filename, true); - if (!is_array($array)) { - return; - } - foreach ($array as $cat => $conf) { - $c = strtolower($cat); - foreach ($conf as $k => $v) { - if ($c == 'core' && property_exists($this, $k)) { - $this->$k=$v; - } else { - if (!isset($this->$c)) { - $this->$c = new stdClass; - } - $this->$c->$k = $v; - } - } - } - } - - private function readConfig(array $files) - { - foreach ($files as $file) { - $this->readIniFile($this->spoolroot . '/configs/' . $file); - } - if (file_exists($this->spoolroot.'/spool/conf/platal.dynamic.conf')) { - $this->readIniFile($this->spoolroot.'/spool/conf/platal.dynamic.conf'); - } - } - - /** Writes an ini file separated in categories - * @param filename the name of the file to write (overwrite existing) - * @param categories an array of categories (array of keys and values) - */ - private function writeIniFile($filename, &$categories) - { - // [category] - // key = value - $f = fopen($filename, 'w'); - foreach ($categories as $cat => $conf) { - fwrite($f, '; {{{ '.$cat."\n\n"); - fwrite($f, '['.$cat.']'."\n\n"); - foreach ($conf as $k => $v) { - fwrite($f, $k.' = "'.str_replace('"','\\"',$v).'"'."\n"); - } - fwrite($f, "\n".'; }}}'."\n"); - } - fwrite($f, '; vim:set syntax=dosini foldmethod=marker:'."\n"); - fclose($f); - } - - /** Change dynamic config file - * @param conf array of keys and values to add or replace - * @param category name of category to change - * - * Opens the dynamic conf file and set values from conf in specified - * category. Updates config vars too. - */ - public function changeDynamicConfig($conf, $category = 'Core') - { - $dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf'; - if (file_exists($dynamicfile)) { - $array = parse_ini_file($dynamicfile, true); - } else { - $array = null; - } - if (!is_array($array)) { - // dynamic conf is empty - $array = array($category => $conf); - } else { - // looks for a category that looks the same (case insensitive) - $same = false; - foreach ($array as $m => &$c) { - if (strtolower($m) == strtolower($category)) { - $same = $m; - break; - } - } - if (!$same) { - // this category doesn't exist yet - $array[$category] = $conf; - } else { - // this category already exists - $conflower = array(); - foreach ($conf as $k => $v) { - $conflower[strtolower($k)] = $v; - } - // $conflower is now same as $conf but with lower case keys - // replaces values of keys that already exists - foreach ($array[$same] as $k => $v) { - if (isset($conflower[strtolower($k)])) { - $array[$same][$k] = $conflower[strtolower($k)]; - unset($conflower[strtolower($k)]); - } - } - // add new keys - foreach ($conf as $k => $v) { - if (isset($conflower[strtolower($k)])) { - $array[$same][$k] = $v; - } - } - } - } - // writes the file over - $this->writeIniFile($dynamicfile, $array); - // rereads the new config to correctly set vars - $this->readIniFile($dynamicfile); - } - - public function bootstrap($conf, $callback, $category = 'Core') - { - $bootstrap = false; - $category = strtolower($category); - foreach ($conf as $key) { - if (!isset($this->$category->$key)) { - $bootstrap = true; - break; - } - } - if ($bootstrap) { - call_user_func($callback); - } - } - - private function setLocale() - { - setlocale(LC_MESSAGES, $this->locale); - setlocale(LC_TIME, $this->locale); - setlocale(LC_CTYPE, $this->locale); - date_default_timezone_set($this->timezone); - mb_internal_encoding("UTF-8"); - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/pliterator.php b/core/classes/pliterator.php deleted file mode 100644 index 0b5f254..0000000 --- a/core/classes/pliterator.php +++ /dev/null @@ -1,31 +0,0 @@ - diff --git a/core/classes/pllogger.php b/core/classes/pllogger.php deleted file mode 100644 index 0381926..0000000 --- a/core/classes/pllogger.php +++ /dev/null @@ -1,114 +0,0 @@ -uid = $uid; - $this->session = $this->writeSession($uid, $suid); - - // retrieve available actions - $res = XDB::iterRow("SELECT id, text FROM logger.actions"); - - while (list($action_id, $action_text) = $res->next()) { - $this->actions[$action_text] = $action_id; - } - } - - /** Creates a new session entry in database and return its ID. - * - * @param $uid the id of the logged user - * @param $suid the id of the administrator who has just su'd to the user - * @return session the session id - */ - private function writeSession($uid, $suid = 0) - { - $ip = $_SERVER['REMOTE_ADDR']; - $host = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR'])); - $browser = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''); - - @list($forward_ip,) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); - $forward_host = $forward_ip; - if ($forward_host) { - $forward_host = strtolower(gethostbyaddr($forward_host)); - } - $proxy = ''; - if ($forward_ip || @$_SERVER['HTTP_VIA']) { - $proxy = 'proxy'; - } - - XDB::execute("INSERT INTO logger.sessions - SET uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}", - $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy); - if ($forward_ip) { - $this->proxy_ip = $ip; - $this->proxy_host = $host; - $this->ip = $forward_ip; - $this->host = $forward_host; - } else { - $this->ip = $ip; - $this->host = $host; - } - - return XDB::insertId(); - } - - - /** Logs an action and its related data. - * - * @param $action le type d'action - * @param $data les données (id de liste, etc.) - * @return VOID - */ - public function log($action, $data = null) - { - if (isset($this->actions[$action])) { - XDB::execute("INSERT INTO logger.events - SET session={?}, action={?}, data={?}", - $this->session, $this->actions[$action], $data); - } else { - trigger_error("PlLogger: unknown action, $action", E_USER_WARNING); - } - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/core/classes/plmailer.php b/core/classes/plmailer.php deleted file mode 100644 index 2106d50..0000000 --- a/core/classes/plmailer.php +++ /dev/null @@ -1,336 +0,0 @@ -tpl = $tpl; - $this->caching = false; - $this->compile_check = true; - - $this->template_dir = $globals->spoolroot . "/templates/"; - $this->compile_dir = $globals->spoolroot . "/spool/mails_c/"; - $this->config_dir = $globals->spoolroot . "/configs/"; - array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/"); - - $this->register_outputfilter(Array($this, 'mail_format')); - $this->register_function('from', Array($this, 'setFrom')); - $this->register_function('to', Array($this, 'addTo')); - $this->register_function('cc', Array($this, 'addCc')); - $this->register_function('bcc', Array($this, 'addBcc')); - $this->register_function('subject', Array($this, 'setSubject')); - $this->register_function('add_header', Array($this, 'addHeader')); - $this->assign_by_ref('globals', $globals); - } - - public static function &get(&$mailer, $tpl) - { - static $plmail; - if (!isset($plmail) || $plmail->tpl != $tpl) { - $plmail = new PlMail($tpl); - } - $plmail->mailer =& $mailer; - return $plmail; - } - - public function run($version) - { - $this->assign('mail_part', $version); - $text = $this->fetch($this->tpl); - if ($version == 'text') { - return wordwrap($text, 78); - } - return $text; - } - - /** used to remove the empty lines due to {from ...}, {to ...} ... functions */ - static public function mail_format($output, &$smarty) - { - return "\n".trim($output)."\n"; - } - - static protected function format_addr(&$params) - { - if (isset($params['full'])) { - return $params['full']; - } elseif (empty($params['text'])) { - return $params['addr']; - } else { - return $params['text'].' <'.$params['addr'].'>'; - } - } - - /** template function : from. - * {from full=...} for an already formatted address - * {from addr=... [text=...]} else - */ - public function setFrom($params, &$smarty) - { - $smarty->mailer->setFrom(PlMail::format_addr($params)); - } - - /** template function : to. - * {to full=...} for an already formatted address - * {to addr=... [text=...]} else - */ - public function addTo($params, &$smarty) - { - $smarty->mailer->addTo(PlMail::format_addr($params)); - } - - /** template function : cc. - * {cc full=...} for an already formatted address - * {cc addr=... [text=...]} else - */ - public function addCc($params, &$smarty) - { - $smarty->mailer->addCc(PlMail::format_addr($params)); - } - - /** template function : bcc. - * {bcc full=...} for an already formatted address - * {bcc addr=... [text=...]} else - */ - public function addBcc($params, &$smarty) - { - $smarty->mailer->addBcc(PlMail::format_addr($params)); - } - - /** template function : subject. - * {subject text=...} - */ - public function setSubject($params, &$smarty) - { - $smarty->mailer->setSubject($params['text']); - } - - /** template function : add_header. - * {add_header name=... value=...} - */ - public function addHeader($params, &$smarty) - { - $smarty->mailer->addHeader($params['name'], $params['value']); - } -} - -require_once('Mail.php'); -require_once('Mail/mime.php'); - -/** Class for sending inline or multipart-emails. - * Based on Diogenes' HermesMailer - */ -class PlMailer extends Mail_Mime { - - private $mail; - private $page = null; - private $charset; - private $wiki = null; - - function __construct($tpl = null, $charset = "UTF-8") - { - $this->charset = $charset; - $this->Mail_Mime("\n"); - $this->mail = Mail::factory('sendmail', Array('sendmail_args' => '-oi')); - if (!is_null($tpl)) { - $this->page =& PlMail::get($this, $tpl); - } - } - - /** - * converts all : Foo Bar Baz