Esempio n. 1
0
/**
 * Check for new messages from upstream
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function checkUpdateMessages()
{
    global $conf;
    global $INFO;
    global $updateVersion;
    if (!$conf['updatecheck']) {
        return;
    }
    if ($conf['useacl'] && !$INFO['ismanager']) {
        return;
    }
    $cf = $conf['cachedir'] . '/messages.txt';
    $lm = @filemtime($cf);
    // check if new messages needs to be fetched
    if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_INC . DOKU_SCRIPT)) {
        @touch($cf);
        dbglog("checkUpdatesMessages(): downloading messages.txt");
        $http = new DokuHTTPClient();
        $http->timeout = 12;
        $data = $http->get(DOKU_MESSAGEURL . $updateVersion);
        io_saveFile($cf, $data);
    } else {
        dbglog("checkUpdatesMessages(): messages.txt up to date");
        $data = io_readFile($cf);
    }
    // show messages through the usual message mechanism
    $msgs = explode("\n%\n", $data);
    foreach ($msgs as $msg) {
        if ($msg) {
            msg($msg, 2);
        }
    }
}
Esempio n. 2
0
 function debug($msg, $msgLevel)
 {
     // DEBUG
     // Write log on data/cache/debug.log
     if ($this->getConf('rc_debug_level') >= $msgLevel) {
         dbglog("RC:" . $msg);
     }
 }
Esempio n. 3
0
 public function handleError($errno, $message, $file, $line)
 {
     $aError = compact($errno, $message, $file, $line);
     Pico::cfg()->use_debug_mail and dbgmail(print_r($aError, true), Pico::cfg()->admin_email);
     Pico::cfg()->use_debug_log and dbglog(print_r($aError, true));
     header("HTTP/1.0 500 Server Error");
     PICOWA_DEBUG_MODE and print_r($aError);
     echo $this->render('500');
     die;
 }
 function plain($string)
 {
     $doku_inline_tags = array('**', '//', "''", '<del>', '</del>', ']]');
     $plain = str_replace($doku_inline_tags, '', $string);
     $req_link = '/\\[\\[(.*?\\|)?/';
     $plain = preg_replace($req_link, '', $plain);
     dbglog($string, 'alphalist helper::plain before');
     dbglog(trim($plain), 'alphalist helper::plain after');
     return trim($plain);
 }
Esempio n. 5
0
 /**
  * send an email to inform about a changed page
  *
  * @param $event
  * @param $param
  * @return bool false if the receiver is invalid or there was an error passing the mail to the MTA
  */
 function send_change_mail(&$event, $param)
 {
     global $ID;
     global $ACT;
     global $INFO;
     global $conf;
     $data = pageinfo();
     if ($ACT != 'save') {
         return true;
     }
     // IO_WIKIPAGE_WRITE is always called twice when saving a page. This makes sure to only send the mail once.
     if (!$event->data[3]) {
         return true;
     }
     // Does the publish plugin apply to this page?
     if (!$this->hlp->isActive($ID)) {
         return true;
     }
     //are we supposed to send change-mails at all?
     if ($this->getConf('apr_mail_receiver') === '') {
         return true;
     }
     // get mail receiver
     $receiver = $this->getConf('apr_mail_receiver');
     $validator = new EmailAddressValidator();
     $validator->allowLocalAddresses = true;
     if (!$validator->check_email_address($receiver)) {
         dbglog(sprintf($this->getLang('mail_invalid'), htmlspecialchars($receiver)));
         return false;
     }
     // get mail sender
     $ReplyTo = $data['userinfo']['mail'];
     if ($ReplyTo == $receiver) {
         return true;
     }
     if ($INFO['isadmin'] == '1') {
         return true;
     }
     // get mail subject
     $timestamp = dformat($data['lastmod'], $conf['dformat']);
     $subject = $this->getLang('apr_mail_subject') . ': ' . $ID . ' - ' . $timestamp;
     $body = $this->create_mail_body('change');
     $mail = new Mailer();
     $mail->to($receiver);
     $mail->subject($subject);
     $mail->setBody($body);
     $mail->setHeader("Reply-To", $ReplyTo);
     $returnStatus = $mail->send();
     return $returnStatus;
 }
Esempio n. 6
0
 /**
  * Render the output remotely at ditaa.org
  */
 function _remote($data, $in, $out)
 {
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such seqdia input file');
         }
         return false;
     }
     $http = new DokuHTTPClient();
     $http->timeout = 30;
     $pass = array();
     $pass['style'] = $data['style'];
     $pass['message'] = io_readFile($in);
     $result = $http->post('http://www.websequencediagrams.com/index.php', $pass);
     if (!$result) {
         return false;
     }
     $json = new JSON(JSON_LOOSE_TYPE);
     $json->skipnative = true;
     $json_data = $json->decode($result);
     $img = $http->get('http://www.websequencediagrams.com/index.php' . $json_data['img']);
     if (!$img) {
         return false;
     }
     return io_saveFile($out, $img);
 }
 /**
  * Log access to a media file
  *
  * called from action.php
  *
  * @param string $media the media ID
  * @param string $mime  the media's mime type
  * @param bool $inline is this displayed inline?
  * @param int $size size of the media file
  */
 public function log_media($media, $mime, $inline, $size)
 {
     // handle user agent
     $ua = addslashes($this->ua_agent);
     $ua_type = addslashes($this->ua_type);
     $ua_ver = addslashes($this->ua_version);
     $os = addslashes($this->ua_platform);
     $ua_info = addslashes($this->ua_name);
     $media = addslashes($media);
     list($mime1, $mime2) = explode('/', strtolower($mime));
     $mime1 = addslashes($mime1);
     $mime2 = addslashes($mime2);
     $inline = $inline ? 1 : 0;
     $size = (int) $size;
     $ip = addslashes(clientIP(true));
     $uid = addslashes($this->uid);
     $user = addslashes($_SERVER['REMOTE_USER']);
     $session = addslashes($this->getSession());
     $sql = "INSERT DELAYED INTO " . $this->hlp->prefix . "media\n                    SET dt       = NOW(),\n                        media    = '{$media}',\n                        ip       = '{$ip}',\n                        ua       = '{$ua}',\n                        ua_info  = '{$ua_info}',\n                        ua_type  = '{$ua_type}',\n                        ua_ver   = '{$ua_ver}',\n                        os       = '{$os}',\n                        user     = '******',\n                        session  = '{$session}',\n                        uid      = '{$uid}',\n                        size     = {$size},\n                        mime1    = '{$mime1}',\n                        mime2    = '{$mime2}',\n                        inline   = {$inline}\n                        ";
     $ok = $this->hlp->runSQL($sql);
     if (is_null($ok)) {
         global $MSG;
         dbglog($MSG);
     }
 }
Esempio n. 8
0
     $sModuleFileName = $sModuleName . '.php';
     if (!$bFlagStop) {
         if (file_exists(FLGR_MODULES . '/' . $sModuleFileName)) {
             $sModuleFileName = FLGR_MODULES . '/' . $sModuleFileName;
         } elseif (file_exists(FLGR_CMS_MODULES . '/' . $sModuleFileName)) {
             $sModuleFileName = FLGR_CMS_MODULES . '/' . $sModuleFileName;
         } else {
             dbglog('DBG_KRNL', 'Error: "Module not found" in index at line ' . __LINE__);
             $sModuleFileName = false;
         }
         if ($sModuleFileName !== false) {
             dbglog('DBG_KRNL', '===========================================', '===========================================');
             dbglog('DBG_KRNL', $nId, '$nId');
             dbglog('DBG_KRNL', $sTitle, '$sTitle');
             dbglog('DBG_KRNL', $bFlagLastModule, '$bFlagLastModule');
             dbglog('DBG_KRNL', $sModuleName, 'include');
             include $sModuleFileName;
         }
     }
 }
 // Обработка 404, 301
 if ($bFlag404) {
     // nat
     $sql = $Db->sqlGetSelect(DB_PREFIX . DB_TBL_NAT, array('to')) . $Db->sqlGetWhere(array('from' => $sRequest));
     $sql = $Db->queryRow($sql);
     if (!empty($sql)) {
         // 301
         //		cStat::bSaveEvent(EVENT_301);
         $nat = current($sql);
         header('301 Moved Permanently');
         header('Location: ' . $nat);
Esempio n. 9
0
 /**
  * Pings search engines with the sitemap url. Plugins can add or remove 
  * urls to ping using the SITEMAP_PING event.
  * 
  * @author Michael Hamann
  */
 public function pingSearchEngines()
 {
     //ping search engines...
     $http = new DokuHTTPClient();
     $http->timeout = 8;
     $encoded_sitemap_url = urlencode(wl('', array('do' => 'sitemap'), true, '&'));
     $ping_urls = array('google' => 'http://www.google.com/webmasters/sitemaps/ping?sitemap=' . $encoded_sitemap_url, 'yahoo' => 'http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=dokuwiki&url=' . $encoded_sitemap_url, 'microsoft' => 'http://www.bing.com/webmaster/ping.aspx?siteMap=' . $encoded_sitemap_url);
     $data = array('ping_urls' => $ping_urls, 'encoded_sitemap_url' => $encoded_sitemap_url);
     $event = new Doku_Event('SITEMAP_PING', $data);
     if ($event->advise_before(true)) {
         foreach ($data['ping_urls'] as $name => $url) {
             dbglog("Sitemapper::PingSearchEngines(): pinging {$name}");
             $resp = $http->get($url);
             if ($http->error) {
                 dbglog("Sitemapper:pingSearchengines(): {$http->error}");
             }
             dbglog('Sitemapper:pingSearchengines(): ' . preg_replace('/[\\n\\r]/', ' ', strip_tags($resp)));
         }
     }
     $event->advise_after();
     return true;
 }
Esempio n. 10
0
 /**
  * Run the ditaa Java program
  */
 function _run($data, $in, $out)
 {
     global $conf;
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such ditaa input file');
         }
         return false;
     }
     $cmd = $this->getConf('java');
     $cmd .= ' -Djava.awt.headless=true -Dfile.encoding=UTF-8 -jar';
     $cmd .= ' ' . escapeshellarg(dirname(__FILE__) . '/ditaa/ditaa0_9.jar');
     //ditaa jar
     $cmd .= ' --encoding UTF-8';
     $cmd .= ' ' . escapeshellarg($in);
     //input
     $cmd .= ' ' . escapeshellarg($out);
     //output
     $cmd .= ' -s ' . escapeshellarg($data['scale']);
     if (!$data['antialias']) {
         $cmd .= ' -A';
     }
     if (!$data['shadow']) {
         $cmd .= ' -S';
     }
     if ($data['round']) {
         $cmd .= ' -r';
     }
     if (!$data['edgesep']) {
         $cmd .= ' -E';
     }
     exec($cmd, $output, $error);
     if ($error != 0) {
         if ($conf['debug']) {
             dbglog(join("\n", $output), 'ditaa command failed: ' . $cmd);
         }
         return false;
     }
     return true;
 }
/**
 * Statistics plugin - data logger
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andreas Gohr <*****@*****.**>
 */
if (!defined('DOKU_INC')) {
    define('DOKU_INC', realpath(dirname(__FILE__) . '/../../../') . '/');
}
define('DOKU_DISABLE_GZIP_OUTPUT', 1);
require_once DOKU_INC . 'inc/init.php';
session_write_close();
// all features are brokered by the helper plugin
/** @var helper_plugin_statistics $plugin */
$plugin = plugin_load('helper', 'statistics');
dbglog('Log ' . $_SERVER['REQUEST_URI']);
switch ($_REQUEST['do']) {
    case 'v':
        $plugin->Logger()->log_access();
        $plugin->Logger()->log_session(1);
        break;
        /** @noinspection PhpMissingBreakStatementInspection */
    /** @noinspection PhpMissingBreakStatementInspection */
    case 'o':
        $plugin->Logger()->log_outgoing();
        //falltrough
    //falltrough
    default:
        $plugin->Logger()->log_session();
}
// fixme move to top
Esempio n. 12
0
    if (!$bFlagStop) {
        if (file_exists(FLGR_MODULES . '/' . $sModuleFileName)) {
            $sModuleFileName = FLGR_MODULES . '/' . $sModuleFileName;
        } elseif (file_exists(FLGR_CMS_MODULES . '/' . $sModuleFileName)) {
            $sModuleFileName = FLGR_CMS_MODULES . '/' . $sModuleFileName;
        } else {
            dbglog('Error: "Module not found" in index at line ' . __LINE__);
            $sModuleFileName = false;
        }
        if ($sModuleFileName !== false) {
            if (defined('KRNL')) {
                dbglog('===========================================', '===========================================');
                dbglog($nId, '$nId');
                dbglog($sTitle, '$sTitle');
                dbglog($bFlagLastModule, '$bFlagLastModule');
                dbglog($sModuleName, 'include');
            }
            include $sModuleFileName;
        }
    }
}
// Обработка 404, 301
if ($bFlag404) {
    // nat
    $sql = "SELECT `to` FROM `" . DB_PREFIX . DB_TBL_NAT . "` WHERE `from` = '" . $sRequest . "'";
    $sql = mysql_query($sql);
    $sql = mysql_fetch_assoc($sql);
    if (!empty($sql)) {
        // 301
        cStat::bSaveEvent(EVENT_301);
        $nat = current($sql);
Esempio n. 13
0
if (!$bFlagLastModule) {
    return;
}
// ---------------------------
// Если нет параметра в запросе - перебрасываем
// на профиль залогиненного пользователя
if (!$bFlag404) {
    header('Location: /user/' . $Permissions->getLoggedUserId());
    include_once FLGR_COMMON . '/exit.php';
}
// off
$off = $aRequest[$nLevel + 1];
if ((string) (int) $off != $off) {
    $errmess = 'WARN: Неверный id пользователя: ' . $off . ' !';
    Console::log($errmess);
    dbglog('DEBUG', $errmess);
    $off = (int) $off;
}
//Console::log($seg.':'.$off);
// Получаем данные
$aUser = $Users->getBaseData($off);
if (empty($aUser)) {
    //Console::log(__FILE_.' ('.__LINE__.') - Пользователь не найден');
    die('Пользователь не найден');
}
//Console::log('$aUser:'******'/user/' . $off, $aUser['family'] . ' ' . $aUser['name']);
// CSS
stylesheet('profile.css');
Esempio n. 14
0
 /**
  * Run the graphviz program
  */
 function _run($data, $in, $out)
 {
     global $conf;
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such graphviz input file');
         }
         return false;
     }
     $cmd = $this->getConf('path');
     if (isset($data['layer_n']) && isset($data['layer_cur'])) {
         $gvpath = dirname($this->getConf('path'));
         $script = 'BEG_G { char* larr[int]; int i; if (!isAttr($,"G","layers")) return; if (isAttr($,"G","layersep")) tokens($.layers,larr,$.layersep); else tokens($.layers,larr," :\\t"); for (larr[i]) { printf("%s\\n",larr[i]); } }';
         exec(sprintf("%s/gvpr %s %s", escapeshellarg($gvpath), escapeshellarg($script), escapeshellarg($in)), $exout, $retval);
         $cmd .= sprintf(" '-Glayerselect=%s'%s", $exout[$data['layer_cur']], (int) $data['layer_cur'] > 0 ? ' -Gbgcolor=#00000000' : '');
     }
     $cmd .= ' -Tpng';
     $cmd .= ' -K' . $data['layout'];
     $cmd .= ' -o' . escapeshellarg($out);
     //output
     $cmd .= ' ' . escapeshellarg($in);
     //input
     if (isset($data['dpi']) && $data['dpi'] > 0) {
         $cmd .= sprintf(" -Gdpi=%d", $data['dpi']);
     }
     $cmd .= ' 2>/dev/null';
     exec($cmd, $output, $error);
     if (isset($data['slicespace']) && $data['slicespace'] > 0) {
         $image = new Imagick($out);
         $trans = new ImagickPixel('transparent');
         $imageprops = $image->getImageGeometry();
         $w = $imageprops['width'];
         $h = $imageprops['height'];
         $draw = new ImagickDraw();
         $draw->setFillColor($trans);
         // Set up some colors to use for fill and outline
         $draw->setStrokeColor(new ImagickPixel('rgb(40,40,40)'));
         $draw->rectangle(0, 0, $w - 1, $h - 1);
         // Draw the rectangle
         $image->drawImage($draw);
         $image->resizeImage($w * 2, $h, imagick::FILTER_LANCZOS, 1.0);
         $image->shearImage($trans, 45, 0);
         $imageprops = $image->getImageGeometry();
         $w = $imageprops['width'];
         $image->resizeImage($w / 2, $h / 2, imagick::FILTER_LANCZOS, 1.0);
         $image->writeImage($out);
     }
     if ($error != 0) {
         if ($conf['debug']) {
             dbglog(join("\n", $output), 'graphviz command failed: ' . $cmd);
         }
         return false;
     }
     return true;
 }
Esempio n. 15
0
 public function retrieveGroups($start = 0, $limit = 0)
 {
     // connect to mysql
     $link = mysql_connect($this->phpbb3_dbhost, $this->phpbb3_dbuser, $this->phpbb3_dbpasswd);
     if (!$link) {
         dbglog("authphpbb3 error: can't connect to database server");
         msg("Database error. Contact wiki administrator", -1);
         return false;
     }
     // set codepage to utf-8
     mysql_set_charset("utf8", $link);
     // select forum database
     if (!mysql_select_db($this->phpbb3_dbname, $link)) {
         dbglog("authphpbb3 error: can't use database");
         msg("Database error. Contact wiki administrator", -1);
         mysql_close($link);
         return false;
     }
     if (limit > 0) {
         // get groups from db
         $query = "select *\n\t\t\t\t\tfrom {$this->phpbb3_table_prefix}groups \n\t\t\t\t\twhere 1 = 1\n                    order by group_name\n                    limit {$start}, {$limit}";
         $rs = mysql_query($query, $link);
         while ($row = mysql_fetch_array($rs)) {
             // fill array of groups names whith data from db
             $tmpvar[] = $row['group_name'];
         }
         mysql_close($link);
         return $tmpvar;
     } else {
         mysql_close($link);
         return false;
     }
 }
Esempio n. 16
0
    /**
     * prepare the cache object for default _useCache action
     */
    function _cache_prepare(Doku_Event &$event, $param) {
        global $conf;

        /* @var cache_renderer $cache */
        $cache =& $event->data;

        if(!isset($cache->page)) return;
        if(!isset($cache->mode) || !in_array($cache->mode, $this->supportedModes)) return;

        $depends = p_get_metadata($cache->page, 'plugin_include');
        
        if($conf['allowdebug']) {
            dbglog('---- PLUGIN INCLUDE CACHE DEPENDS START ----');
            dbglog($depends);
            dbglog('---- PLUGIN INCLUDE CACHE DEPENDS END ----');
        }

        if (!is_array($depends)) return; // nothing to do for us

        if (!is_array($depends['pages']) ||
            !is_array($depends['instructions']) ||
            $depends['pages'] != $this->helper->_get_included_pages_from_meta_instructions($depends['instructions']) ||
            // the include_content url parameter may change the behavior for included pages
            $depends['include_content'] != isset($_REQUEST['include_content'])) {

            $cache->depends['purge'] = true; // included pages changed or old metadata - request purge.
            if($conf['allowdebug']) {
                dbglog('---- PLUGIN INCLUDE: REQUESTING CACHE PURGE ----');
                dbglog('---- PLUGIN INCLUDE CACHE PAGES FROM META START ----');
                dbglog($depends['pages']);
                dbglog('---- PLUGIN INCLUDE CACHE PAGES FROM META END ----');
                dbglog('---- PLUGIN INCLUDE CACHE PAGES FROM META_INSTRUCTIONS START ----');
                dbglog($this->helper->_get_included_pages_from_meta_instructions($depends['instructions']));
                dbglog('---- PLUGIN INCLUDE CACHE PAGES FROM META_INSTRUCTIONS END ----');

            }
        } else {
            // add plugin.info.txt to depends for nicer upgrades
            $cache->depends['files'][] = dirname(__FILE__) . '/plugin.info.txt';
            foreach ($depends['pages'] as $page) {
                if (!$page['exists']) continue;
                $file = wikiFN($page['id']);
                if (!in_array($file, $cache->depends['files'])) {
                    $cache->depends['files'][] = $file;
                }
            }
        }
    }
Esempio n. 17
0
 static function debug($callback, $tag)
 {
     dbglog($tag);
     if (is_string($callback)) {
         dbglog($callback);
     } elseif (is_array($callback)) {
         if (is_object($callback[0])) {
             dbglog(get_class($callback[0]) . '->' . $callback[1]);
         } else {
             if (is_string($callback[0])) {
                 dbglog($callback[0] . '::' . $callback[1]);
             }
         }
     } else {
         if (is_object($callback)) {
             dbglog(get_class($callback));
         }
     }
 }
Esempio n. 18
0
 function dbglogr($array)
 {
     dbglog(print_r($array, true));
 }
 function handle($match, $state, $pos, &$handler)
 {
     global $ID;
     dbglog($match, 'alphalist syntax $match');
     $alphalist =& plugin_load('helper', 'alphalist');
     //remove [alphalist
     $match = substr($match, 10);
     //remove ]
     $match = substr($match, 0, -1);
     $match = trim($match);
     dbglog($match, 'alphalist syntax $match after processing');
     $pages = array();
     // [alphalist] sytax
     if (empty($match)) {
         $pages[0][] = '';
         $pages[1][] = '';
     } else {
         preg_match_all('/([a-zA-Z0-9:_\\-]*)(?:\\{([^\\}]+)\\})?/', $match, $matches);
         //remove empty matches
         $k = 0;
         for ($i = 0; $i < count($matches[0]); $i++) {
             if (!empty($matches[0][$i])) {
                 for ($j = 1; $j < count($matches); $j++) {
                     $pages[$j - 1][$k] = $matches[$j][$i];
                 }
                 $k++;
             }
         }
     }
     dbglog($pages, 'alphalist syntax $pages');
     $list = array();
     for ($i = 0; $i < count($pages[0]); $i++) {
         if (empty($pages[0][$i])) {
             $page = $ID;
         } else {
             $page = $pages[0][$i];
         }
         //Get section
         $section = $pages[1][$i];
         $file = wikiFN($page);
         if (file_exists($file)) {
             $content = file($file);
             if ($section == false) {
                 foreach ($content as $row) {
                     if (preg_match('/^  (\\-|\\*)(.*)/', $row, $match)) {
                         $list[$alphalist->plain($match[2])] = $match[2];
                     }
                 }
             } else {
                 //0 - waiting for header 1 - in header
                 $state = 0;
                 foreach ($content as $row) {
                     if ($state == 0) {
                         if (strstr($row, $section)) {
                             $state++;
                         }
                     } else {
                         if (preg_match('/==.*?==/', $row)) {
                             break;
                         }
                         if (preg_match('/^  (\\-|\\*)(.*)/', $row, $match)) {
                             $list[$alphalist->plain($match[2])] = $match[2];
                         }
                     }
                 }
             }
         }
     }
     dbglog($pages, 'alphalist syntax $list');
     return $list;
 }
 /**
  * Simple function to run a DB query
  */
 public function runSQL($sql_string)
 {
     $link = $this->dbLink();
     if (!$link) {
         return null;
     }
     $result = mysqli_query($link, $sql_string);
     if ($result === false) {
         dbglog('DB Error: ' . mysqli_error($link) . ' ' . hsc($sql_string), -1);
         msg('DB Error: ' . mysqli_error($link) . ' ' . hsc($sql_string), -1);
         return null;
     }
     $resultarray = array();
     //mysql_db_query returns 1 on a insert statement -> no need to ask for results
     if ($result !== true) {
         for ($i = 0; $i < mysqli_num_rows($result); $i++) {
             $temparray = mysqli_fetch_assoc($result);
             $resultarray[] = $temparray;
         }
         mysqli_free_result($result);
     }
     if (mysqli_insert_id($link)) {
         $resultarray = mysqli_insert_id($link);
         //give back ID on insert
     }
     return $resultarray;
 }
Esempio n. 21
0
/**
 * Log accesses to deprecated fucntions to the debug log
 *
 * @param string $alternative The function or method that should be used instead
 */
function dbg_deprecated($alternative = '')
{
    global $conf;
    if (!$conf['allowdebug']) {
        return;
    }
    $backtrace = debug_backtrace();
    array_shift($backtrace);
    $self = array_shift($backtrace);
    $call = array_shift($backtrace);
    $called = trim($self['class'] . '::' . $self['function'] . '()', ':');
    $caller = trim($call['class'] . '::' . $call['function'] . '()', ':');
    $msg = $called . ' is deprecated. It was called from ';
    $msg .= $caller . ' in ' . $call['file'] . ':' . $call['line'];
    if ($alternative) {
        $msg .= ' ' . $alternative . ' should be used instead!';
    }
    dbglog($msg);
}
Esempio n. 22
0
 /**
  * Render the output locally using the plantuml.jar
  */
 function _local($data, $in, $out)
 {
     if (!file_exists($in)) {
         dbglog($in, 'No such plantuml input file');
         return false;
     }
     $java = $this->getConf('java');
     $jar = $this->getConf('jar');
     $jar = realpath($jar);
     $jar = escapeshellarg($jar);
     // we are not specifying the output here, because plantuml will generate a file with the same
     // name as the input but with .png extension, which is exactly what we want
     $command = $java;
     $command .= ' -Djava.awt.headless=true';
     $command .= ' -Dfile.encoding=UTF-8';
     $command .= " -jar {$jar}";
     $command .= ' -charset UTF-8';
     $command .= ' ' . escapeshellarg($in);
     $command .= ' 2>&1';
     exec($command, $output, $return_value);
     if ($return_value == 0) {
         return true;
     } else {
         dbglog(join("\n", $output), "PlantUML execution failed: {$command}");
         return false;
     }
 }
Esempio n. 23
0
 /**
  * Handler to prepare matched data for the rendering process.
  *
  * This function can only pass data to render() via its return value - render()
  * may be not be run during the object's current life.
  *
  * Usually you should only need the $match param.
  *
  * @param   string       $match   The text matched by the patterns
  * @param   int          $state   The lexer state for the match
  * @param   int          $pos     The character position of the matched text
  * @param   Doku_Handler $handler Reference to the Doku_Handler object
  * @return  array Return an array with all data you want to use in render
  *
  * @see DokuWiki_Syntax_Plugin::handle()
  */
 function handle($match, $state, $pos, Doku_Handler &$handler)
 {
     global $conf;
     $match = str_replace(array(">", "{{", "}}"), array(":", "[", "]"), $match);
     $match = substr($match, 1, -1);
     $data = explode(":", $match);
     $this->_oauth_consumer_key = $this->getConf('oauth_consumer_key');
     $this->_oauth_consumer_secret = $this->getConf('oauth_consumer_secret');
     $this->_oauth_token = $this->getConf('oauth_token');
     $this->_oauth_token_secret = $this->getConf('oauth_token_secret');
     if (empty($this->_oauth_consumer_key) || empty($this->_oauth_consumer_secret) || empty($this->_oauth_token) || empty($this->_oauth_token_secret)) {
         msg($this->getLang('configerror'), -1, '', '', MSG_ADMINS_ONLY);
         dbglog($this->getLang('configerror'), "TWITTER PLUGIN");
     }
     $number = $this->getConf('maxresults');
     if (isset($data[3])) {
         $number = $data[3];
     }
     $data[2] = str_replace(" ", "%20", $data[2]);
     if (strtoupper($data[1]) == "SEARCH") {
         $json = $this->getData("https://api.twitter.com/1.1/search/tweets.json", array('q' => $data[2], 'count' => $number, 'include_entities' => false));
     } else {
         $json = $this->getData("https://api.twitter.com/1.1/statuses/user_timeline.json", array('screen_name' => $data[2], 'count' => $number));
     }
     $decode = json_decode($json);
     // dbglog($decode, "=======================decoded json from Twitter============================");
     if (isset($decode->search_metadata)) {
         return array($decode->statuses, $this->getLang('results') . ' <a class="urlextern" target="_blank" href="https://twitter.com/search?q=' . $data[2] . '">' . str_replace("%20", " and ", $data[2] . '</a>'));
     }
     return array($decode, $this->getLang('header') . ' <a class="urlextern" target="_blank" href="https://twitter.com/' . $data[2] . '">@' . $data[2] . '</a>');
 }
 protected function xrdTagContent($parser, $content)
 {
     dbglog("reading content of tag " . $this->tmpCurrTag . ": " . $content);
     if ($this->tmpCurrTag == "VENDOR") {
         $this->tmpCurrTarget->vendor = $content;
     } else {
         if ($this->tmpCurrTag == "NAME") {
             $this->tmpCurrTarget->name = $content;
         } else {
             if ($this->tmpCurrTag == "TITLE") {
                 $this->tmpCurrTarget->title = $content;
             } else {
                 if ($this->tmpCurrTag == "PROMPT") {
                     $this->tmpCurrTarget->prompt = $content;
                 } else {
                     if ($this->tmpCurrTag == "SUBJECT") {
                         $this->tmpCurrTarget->id = $content;
                     } else {
                         if ($this->tmpCurrTag == "PROPERTY") {
                             dbglog("Have property tag, type is " . $this->tmpCurrPropertyType);
                             if ($this->tmpCurrPropertyType == "http://www.oexchange.org/spec/0.8/prop/vendor") {
                                 $this->tmpCurrTarget->vendor = $content;
                             } else {
                                 if ($this->tmpCurrPropertyType == "http://www.oexchange.org/spec/0.8/prop/title") {
                                     $this->tmpCurrTarget->title = $content;
                                 } else {
                                     if ($this->tmpCurrPropertyType == "http://www.oexchange.org/spec/0.8/prop/name") {
                                         $this->tmpCurrTarget->name = $content;
                                     } else {
                                         if ($this->tmpCurrPropertyType == "http://www.oexchange.org/spec/0.8/prop/prompt") {
                                             $this->tmpCurrTarget->prompt = $content;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Run the graphviz program to generate the map
  * @Author: Michael Kling
  */
 function _map($data, $in, $out)
 {
     global $conf;
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such graphviz input file');
         }
         return false;
     }
     $cmd = $this->getConf('path');
     $cmd .= ' -Tcmap';
     $cmd .= ' -K' . $data['layout'];
     $cmd .= ' -o' . escapeshellarg($out);
     //output
     $cmd .= ' ' . escapeshellarg($in);
     //input
     $result = exec($cmd, $output, $error);
     if ($error != 0) {
         if ($conf['debug']) {
             dbglog(join("\n", $output), 'graphviz command failed: ' . $cmd);
         }
         return false;
     }
     return true;
 }
Esempio n. 26
0
 /**
  * Return a count of the number of user which meet $filter criteria
  *
  * @param array $filter  $filter array of field/pattern pairs, empty array for no filter
  * @return int number of users
  */
 public function getUserCount($filter = array())
 {
     $adldap = $this->_adldap(null);
     if (!$adldap) {
         dbglog("authad/auth.php getUserCount(): _adldap not set.");
         return -1;
     }
     if ($filter == array()) {
         $result = $adldap->user()->all();
     } else {
         $searchString = $this->_constructSearchString($filter);
         $result = $adldap->user()->all(false, $searchString);
         if (isset($filter['grps'])) {
             $this->users = array_fill_keys($result, false);
             $usermanager = plugin_load("admin", "usermanager", false);
             $usermanager->setLastdisabled(true);
             if (!isset($this->_grpsusers[$this->_filterToString($filter)])) {
                 $this->_fillGroupUserArray($filter, $usermanager->getStart() + 3 * $usermanager->getPagesize());
             } elseif (count($this->_grpsusers[$this->_filterToString($filter)]) < $usermanager->getStart() + 3 * $usermanager->getPagesize()) {
                 $this->_fillGroupUserArray($filter, $usermanager->getStart() + 3 * $usermanager->getPagesize() - count($this->_grpsusers[$this->_filterToString($filter)]));
             }
             $result = $this->_grpsusers[$this->_filterToString($filter)];
         } else {
             $usermanager = plugin_load("admin", "usermanager", false);
             $usermanager->setLastdisabled(false);
         }
     }
     if (!$result) {
         return 0;
     }
     return count($result);
 }
Esempio n. 27
0
 /**
  * Run the ditaa Go program
  *
  * @param array $data The config settings - currently not used because the Go relase supports no options
  * @param string $in Path to the ditaa input file (txt)
  * @param string $out Path to the output file (PNG)
  * @return bool true if the image was created, false otherwise
  */
 protected function _runGo($data, $in, $out)
 {
     global $conf;
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such ditaa input file');
         }
         return false;
     }
     $cmd = $this->getLocalBinary();
     if (!$cmd) {
         return false;
     }
     $cmd .= ' ' . escapeshellarg($in);
     //input
     $cmd .= ' ' . escapeshellarg($out);
     //output
     exec($cmd, $output, $error);
     if ($error != 0) {
         if ($conf['debug']) {
             dbglog(join("\n", $output), 'ditaa command failed: ' . $cmd);
         }
         return false;
     }
     return true;
 }
Esempio n. 28
0
 /**
  * Returns the content of a graphviz image.
  * 
  * @param data parameters.
  *           
  * @return PNG image.
  */
 function get_graphviz_image($data)
 {
     global $conf;
     $image = null;
     $gathered_data = $this->get_gathered_data($data);
     $dot_input = $this->get_dot($gathered_data);
     // See if a manual path was given for graphviz
     if ($this->getConf('graphviz_path')) {
         // Local build
         $cmd = $this->getConf('path');
         $cmd .= ' -Tpng';
         $cmd .= ' -K' . $data['layout'];
         $cmd .= ' -o' . escapeshellarg($image);
         //output
         $cmd .= ' ' . escapeshellarg($dot_input);
         //input
         exec($cmd, $image, $error);
         if ($error != 0) {
             if ($conf['debug']) {
                 dbglog(join("\n", $image), 'mindmap command failed: ' . $cmd);
             }
             return false;
         }
     } else {
         // Remote via google chart tools
         $http = new DokuHTTPClient();
         $http->timeout = 30;
         $pass = array();
         $pass['cht'] = 'gv:' . $data['format'];
         $pass['chl'] = $dot_input;
         $image = $http->post('http://chart.apis.google.com/chart', $pass, '&');
         if (!$image) {
             return false;
         }
     }
     return $image;
 }
Esempio n. 29
0
 /**
  * Запрос разрешения.
  * В качестве параметров получает идентификаторы
  * Действия, Объекта к которому осуществляется доступ, 
  * и Роли, которая осуществляет доступ. 
  *
  * @param id $idAction
  * @param id $idObject
  * @param string $sRole
  * 
  * @return boolean
  */
 function getAccess($idAction, $idObject, $idRole)
 {
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', 'getAccess', '-----------------------');
     }
     // Получаем Действие
     $aAction = $this->getEltForWhere('_Actions', "`id` = '{$idAction}'");
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', $aAction, '$aAction');
     }
     // Получаем Объект
     $aObject = $this->getEltForWhere('_Objects', "`id` = '{$idObject}'");
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', $aObject, '$aObject');
     }
     // Если класс Kласс Безопасности Действия и Объекта не совпадают
     if ($aAction['class_id'] != $aObject['class_id']) {
         my_die('Kласс Безопасности Действия и Объекта не совпадают');
     }
     // Получаем Kласс Безопасности
     $aClass = $this->getEltForWhere('_Classes', "`id` = '" . $aObject['class_id'] . "'");
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', $aClass, '$aClass');
     }
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', 'hierarchical', $aClass['hierarchical']);
     }
     // Если права не иерархичны
     if (0 == $aClass['hierarchical']) {
         $permission = $this->getPermission($idAction, $idObject, $idRole);
         if (defined('DBG_PERM')) {
             dbglog('DBG_PERM', $permission, 'Неиерархичный return');
         }
         if ($permission == 2) {
             // Если Разрешение, связывающее Действие, Объект и Роль не найдено
             // Вернуть значение `default` Класса  Безопасности.
             return $aClass['default'];
         }
         // Вернуть Разрешение
         return $permission;
     }
     // Если права иерархичны
     // Получить имя таблицы и id элемента
     $sReference = $aClass['reference'];
     if (!defined($sReference)) {
         my_die('Неверная ссылка');
     } else {
         $sReference = constant($sReference);
     }
     $idOffset = $aObject['offset_id'];
     // Получить ветвь иерархии
     $aElts = array($aObject['offset_id']);
     while ($idOffset > 0) {
         $sql = "SELECT `parent` FROM `" . DB_PREFIX . $sReference . "` \n\t\t\t\t\tWHERE (`id` = '{$idOffset}')";
         $sql = mysql_query($sql);
         if (false == $sql) {
             my_die();
         }
         if ($row = mysql_fetch_assoc($sql)) {
             $aElts[] = $idOffset = $row['parent'];
         } else {
             $idOffset = 0;
         }
     }
     array_pop($aElts);
     // удаляем нулевой элемент
     $aElts = array_reverse($aElts);
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', $aElts, 'BRANCH');
     }
     // Собрать результирующие права на Действие Роли над Объектом
     $bResult = $aClass['default'];
     foreach ($aElts as $v) {
         // Ищем Объект, управляющий доступом к этому узлу ветви
         $aNodeObject = $this->_Objects->get("*", "\n\t\t\t\t(`class_id` = '" . $aObject['class_id'] . "') AND\n\t\t\t\t(`offset_id` = '{$v}')\n\t\t\t");
         // Если не нашли - пропускаем итерацию
         if (empty($aNodeObject)) {
             continue;
         }
         // Если нашли более одного
         if (count($aNodeObject) > 1) {
             my_die('Более одного объекта узла');
         }
         $aNodeObject = $aNodeObject[0];
         if (defined('DBG_PERM')) {
             dbglog('DBG_PERM', $aNodeObject, '$aNodeObject');
         }
         // Ищем Разрешение Роли на Это Действие для этого Объекта
         $aNodePermission = $this->_Permissions->get("*", "\n\t\t\t\t(`role_id` = '{$idRole}') AND\n\t\t\t\t(`object_id` = '" . $aNodeObject['id'] . "') AND\n\t\t\t\t(`action_id` = '{$idAction}')\n\t\t\t");
         // Если не нашли - пропускаем итерацию
         if (empty($aNodePermission)) {
             continue;
         }
         // Если нашли более одного?
         if (count($aNodePermission) > 1) {
             my_die('Более одного разрешения узла');
         }
         $aNodePermission = $aNodePermission[0];
         if (defined('DBG_PERM')) {
             dbglog('DBG_PERM', $aNodePermission, '$aNodePermission');
         }
         // Осуществляем сложение прав в зависимости от политики
         if ($aClass['policy']) {
             $bResult = $bResult or $aNodePermission['access'];
         } else {
             $bResult = $bResult and $aNodePermission['access'];
         }
     }
     if (defined('DBG_PERM')) {
         dbglog('DBG_PERM', $bResult, 'bREsult');
     }
     // Вернуть результирующие права
     return $bResult;
 }