Example #1
1
 public static function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false)
 {
     global $mod, $pdo, $board;
     if ($mod_id === false) {
         $mod_id = isset($mod['id']) ? $mod['id'] : -1;
     }
     $range = self::parse_range($mask);
     $mask = self::range_to_string($range);
     $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
     $query->bindValue(':ipstart', $range[0]);
     if ($range[1] !== false && $range[1] != $range[0]) {
         $query->bindValue(':ipend', $range[1]);
     } else {
         $query->bindValue(':ipend', null, PDO::PARAM_NULL);
     }
     $query->bindValue(':mod', $mod_id);
     $query->bindValue(':time', time());
     if ($reason !== '') {
         $reason = escape_markup_modifiers($reason);
         markup($reason);
         $query->bindValue(':reason', $reason);
     } else {
         $query->bindValue(':reason', null, PDO::PARAM_NULL);
     }
     if ($length) {
         if (is_int($length) || ctype_digit($length)) {
             $length = time() + $length;
         } else {
             $length = self::parse_time($length);
         }
         $query->bindValue(':expires', $length);
     } else {
         $query->bindValue(':expires', null, PDO::PARAM_NULL);
     }
     if ($ban_board) {
         $query->bindValue(':board', $ban_board);
     } else {
         $query->bindValue(':board', null, PDO::PARAM_NULL);
     }
     if ($post) {
         $post['board'] = $board['uri'];
         $query->bindValue(':post', json_encode($post));
     } else {
         $query->bindValue(':post', null, PDO::PARAM_NULL);
     }
     $query->execute() or error(db_error($query));
     if (isset($mod['id']) && $mod['id'] == $mod_id) {
         modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : $mask) . ' (<small>#' . $pdo->lastInsertId() . '</small>)' . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
     }
     return $pdo->lastInsertId();
 }
Example #2
0
function ban($mask, $reason, $length, $board)
{
    global $mod, $pdo;
    $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board)");
    $query->bindValue(':ip', $mask);
    $query->bindValue(':mod', $mod['id']);
    $query->bindValue(':time', time());
    if ($reason !== '') {
        markup($reason);
        $query->bindValue(':reason', $reason);
    } else {
        $query->bindValue(':reason', null, PDO::PARAM_NULL);
    }
    if ($length > 0) {
        $query->bindValue(':expires', $length);
    } else {
        $query->bindValue(':expires', null, PDO::PARAM_NULL);
    }
    if ($board) {
        $query->bindValue(':board', $board);
    } else {
        $query->bindValue(':board', null, PDO::PARAM_NULL);
    }
    $query->execute() or error(db_error($query));
    modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban (<small>#' . $pdo->lastInsertId() . '</small>) for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : utf8tohtml($mask)) . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
}
Example #3
0
 /**
  * Show home page.
  * If the user is already logged in, show categories, otherwise show README.
  *
  * @return Response
  */
 public function showHomePage()
 {
     if (Auth::check()) {
         return redirect(route('category.index'));
     }
     $readme = markup(\File::get(base_path('readme.md')));
     return view('home')->withTitle(_('Home'))->withContent($readme);
 }
Example #4
0
 public static function boot()
 {
     // NOTE events cycle is as follows:
     // saving   -> creating -> created   -> saved
     // saving   -> updating -> updated   -> saved
     // deleting -> deleted  -> restoring -> restored
     parent::boot();
     static::saved(function ($page) {
         // Build markup
         $markup = markup($page->source);
         self::where([$page->getKeyName() => $page->getKey()])->limit(1)->update(['markup' => $markup]);
         // Backup version
         return Version::createFromPage($page);
     });
 }
Example #5
0
function rebuildPost($id)
{
    global $board, $mod;
    $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `id` = :id", $board['uri']));
    $query->bindValue(':id', $id, PDO::PARAM_INT);
    $query->execute() or error(db_error($query));
    if (!($post = $query->fetch(PDO::FETCH_ASSOC)) || !$post['body_nomarkup']) {
        return false;
    }
    markup($post['body'] =& $post['body_nomarkup']);
    $post = (object) $post;
    event('rebuildpost', $post);
    $post = (array) $post;
    $query = prepare(sprintf("UPDATE ``posts_%s`` SET `body` = :body WHERE `id` = :id", $board['uri']));
    $query->bindValue(':body', $post['body']);
    $query->bindValue(':id', $id, PDO::PARAM_INT);
    $query->execute() or error(db_error($query));
    buildThread($post['thread'] ? $post['thread'] : $id);
    return true;
}
Example #6
0
     $query->bindValue(':id', $id);
     $query->execute() or error(db_error($query));
     header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
 } elseif (preg_match('/^\\/IP\\/(\\d+\\.\\d+\\.\\d+\\.\\d+|' . $config['ipv6_regex'] . ')$/', $query, $matches)) {
     // View information on an IP address
     $ip = $matches[1];
     $host = $config['mod']['dns_lookup'] ? rDNS($ip) : false;
     if (hasPermission($config['mod']['unban']) && isset($_POST['unban']) && isset($_POST['ban_id'])) {
         removeBan($_POST['ban_id']);
         header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
     } elseif (hasPermission($config['mod']['create_notes']) && isset($_POST['note'])) {
         $query = prepare("INSERT INTO `ip_notes` VALUES(NULL, :ip, :mod, :time, :body)");
         $query->bindValue(':ip', $ip);
         $query->bindValue(':mod', $mod['id'], PDO::PARAM_INT);
         $query->bindValue(':time', time(), PDO::PARAM_INT);
         markup($_POST['note']);
         $query->bindValue(':body', $_POST['note']);
         $query->execute() or error(db_error($query));
         header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
     } else {
         $body = '';
         $boards = listBoards();
         foreach ($boards as &$_board) {
             openBoard($_board['uri']);
             $temp = '';
             $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` DESC LIMIT :limit", $_board['uri']));
             $query->bindValue(':ip', $ip);
             $query->bindValue(':limit', $config['mod']['ip_recentposts'], PDO::PARAM_INT);
             $query->execute() or error(db_error($query));
             while ($post = $query->fetch()) {
                 if (!$post['thread']) {
Example #7
0
     // Assume we're using the utf8mb4 charset
 } else {
     // MySQL's `utf8` charset only supports up to 3-byte symbols
     // Remove anything >= 0x010000
     $chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
     $post['body_nomarkup'] = '';
     foreach ($chars as $char) {
         $o = 0;
         $ord = ordutf8($char, $o);
         if ($ord >= 0x10000) {
             continue;
         }
         $post['body_nomarkup'] .= $char;
     }
 }
 $post['tracked_cites'] = markup($post['body'], true, $post['op']);
 if ($post['has_file']) {
     $allhashes = '';
     foreach ($post['files'] as $key => &$file) {
         if ($post['op'] && $config['allowed_ext_op']) {
             if (!in_array($file['extension'], $config['allowed_ext_op'])) {
                 error($config['error']['unknownext']);
             }
         } elseif (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files'])) {
             error($config['error']['unknownext']);
         }
         $file['is_an_image'] = !in_array($file['extension'], $config['allowed_ext_files']);
         // Truncate filename if it is too long
         $file['filename'] = mb_substr($file['filename'], 0, $config['max_filename_len']);
         $upload = $file['tmp_name'];
         if (!is_readable($upload)) {
Example #8
0
function printContent()
{
    if (isset($_GET['version']) && $_GET['version'] == '2.0') {
        $contents = file('inc/RELEASENOTES-2.0.txt');
    } else {
        if (isset($_GET['version']) && $_GET['version'] == '2.1') {
            $contents = file('inc/RELEASENOTES-2.1.txt');
        } else {
            if (isset($_GET['version']) && $_GET['version'] == '2.2') {
                $contents = file('inc/RELEASENOTES-2.2.txt');
            } else {
                if (isset($_GET['version']) && $_GET['version'] == '2.3') {
                    $contents = file('inc/RELEASENOTES-2.3.txt');
                } else {
                    if (isset($_GET['version']) && $_GET['version'] == '2.4') {
                        $contents = file('inc/RELEASENOTES-2.4.txt');
                    } else {
                        $contents = file('inc/RELEASENOTES.txt');
                    }
                }
            }
        }
    }
    for ($i = 0; $i < count($contents); $i++) {
        if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '===') {
            $id = trim(preg_replace('%Version (\\d+\\.\\d+\\.\\d+).*\\n?%', '$1', $contents[$i]));
            print '<h2 id="' . $id . '"><a href="#' . $id . '" name="' . $id . '">#</a> ';
            print $contents[$i];
            print '</h2>';
        } else {
            if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '---') {
                print '<h3>';
                print $contents[$i];
                print '</h3>';
            } else {
                if (substr($contents[$i], 0, 3) == '===') {
                    // Skip
                } else {
                    if (substr($contents[$i], 0, 3) == '---') {
                        // Skip
                    } else {
                        if (trim($contents[$i]) == '' && substr($contents[$i + 1], 0, 1) != '-') {
                            print '<p>';
                        } else {
                            if (substr($contents[$i], 0, 1) == '-') {
                                print '<ul>';
                                while (trim($contents[$i]) != '') {
                                    print '<li>';
                                    print preg_replace('%-\\s+(.*)%', '$1', markup($contents[$i]));
                                    while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '-') {
                                        print markup(htmlentities($contents[$i]));
                                    }
                                    print '</li>';
                                }
                                print '</ul><p>';
                            } else {
                                if (substr($contents[$i], 0, 1) == '#') {
                                    print '<table class="ticket-table">';
                                    while (trim($contents[$i]) != '') {
                                        $ticket = preg_replace('%#(\\d+).*%', '$1', $contents[$i]);
                                        print '<tr>';
                                        print '<td width="80">';
                                        print '<a href="https://github.com/jOOQ/jOOQ/issues/' . $ticket . '">#';
                                        print $ticket;
                                        print '</a>';
                                        print '</td>';
                                        print '<td>';
                                        print htmlentities(preg_replace('%#\\d+\\s+-\\s+(.*)%', '$1', $contents[$i]));
                                        while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '#') {
                                            print htmlentities($contents[$i]);
                                        }
                                        print '</td>';
                                        print '</tr>';
                                    }
                                    print '</table>';
                                } else {
                                    print markup($contents[$i]);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #9
0
     // Assume we're using the utf8mb4 charset
 } else {
     // MySQL's `utf8` charset only supports up to 3-byte symbols
     // Remove anything >= 0x010000
     $chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
     $post['body_nomarkup'] = '';
     foreach ($chars as $char) {
         $o = 0;
         $ord = ordutf8($char, $o);
         if ($ord >= 0x10000) {
             continue;
         }
         $post['body_nomarkup'] .= $char;
     }
 }
 $post['tracked_cites'] = markup($post['body'], true);
 if ($post['has_file']) {
     $fnarray = array();
     foreach ($post['files'] as $key => &$file) {
         if ($post['op'] && $config['allowed_ext_op']) {
             if (!in_array($file['extension'], $config['allowed_ext_op'])) {
                 error($config['error']['unknownext']);
             }
         } elseif (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files'])) {
             error($config['error']['unknownext']);
         }
         $file['is_an_image'] = !in_array($file['extension'], $config['allowed_ext_files']);
         // Truncate filename if it is too long
         $file['filename'] = mb_substr($file['filename'], 0, $config['max_filename_len']);
         if (!isset($filenames)) {
             $filenames = escapeshellarg($file['tmp_name']);
Example #10
0
function rebuildPost($id)
{
    global $board;
    $query = prepare(sprintf("SELECT `body_nomarkup`, `thread` FROM `posts_%s` WHERE `id` = :id", $board['uri']));
    $query->bindValue(':id', $id, PDO::PARAM_INT);
    $query->execute() or error(db_error($query));
    if (!($post = $query->fetch()) || !$post['body_nomarkup']) {
        return false;
    }
    markup($body =& $post['body_nomarkup']);
    $query = prepare(sprintf("UPDATE `posts_%s` SET `body` = :body WHERE `id` = :id", $board['uri']));
    $query->bindValue(':body', $body);
    $query->bindValue(':id', $id, PDO::PARAM_INT);
    $query->execute() or error(db_error($query));
    buildThread($post['thread'] ? $post['thread'] : $id);
    return true;
}
Example #11
0
function printContent()
{
    $contents = file('inc/RELEASENOTES.txt');
    for ($i = 0; $i < count($contents); $i++) {
        if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '===') {
            print '<h2>';
            print $contents[$i];
            print '</h2>';
        } else {
            if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '---') {
                print '<h3>';
                print $contents[$i];
                print '</h3>';
            } else {
                if (substr($contents[$i], 0, 3) == '===') {
                    // Skip
                } else {
                    if (substr($contents[$i], 0, 3) == '---') {
                        // Skip
                    } else {
                        if (trim($contents[$i]) == '' && substr($contents[$i + 1], 0, 1) != '-') {
                            print '<p>';
                        } else {
                            if (substr($contents[$i], 0, 1) == '-') {
                                print '<ul>';
                                while (trim($contents[$i]) != '') {
                                    print '<li>';
                                    print preg_replace('%-\\s+(.*)%', '$1', $contents[$i]);
                                    while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '-') {
                                        print htmlentities($contents[$i]);
                                    }
                                    print '</li>';
                                }
                                print '</ul><p>';
                            } else {
                                if (substr($contents[$i], 0, 1) == '#') {
                                    print '<table class="ticket-table">';
                                    while (trim($contents[$i]) != '') {
                                        $ticket = preg_replace('%#(\\d+).*%', '$1', $contents[$i]);
                                        print '<tr>';
                                        print '<td width="80">';
                                        print '<a href="https://sourceforge.net/apps/trac/jooq/ticket/' . $ticket . '">#';
                                        print $ticket;
                                        print '</a>';
                                        print '</td>';
                                        print '<td>';
                                        print htmlentities(preg_replace('%#\\d+\\s+-\\s+(.*)%', '$1', $contents[$i]));
                                        while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '#') {
                                            print htmlentities($contents[$i]);
                                        }
                                        print '</td>';
                                        print '</tr>';
                                    }
                                    print '</table>';
                                } else {
                                    print markup($contents[$i]);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #12
0
 public function __construct($post, $root = null, $mod = false, $hr = true)
 {
     global $config;
     if (!isset($root)) {
         $root =& $config['root'];
     }
     foreach ($post as $key => $value) {
         $this->{$key} = $value;
     }
     $this->subject = utf8tohtml($this->subject);
     $this->name = utf8tohtml($this->name);
     $this->mod = $mod;
     $this->root = $root;
     $this->hr = $hr;
     $this->posts = array();
     $this->omitted = 0;
     $this->omitted_images = 0;
     if ($this->embed) {
         $this->embed = embed_html($this->embed);
     }
     $this->modifiers = extract_modifiers($this->body_nomarkup);
     if ($config['always_regenerate_markup']) {
         $this->body = $this->body_nomarkup;
         markup($this->body);
     }
     if ($this->mod) {
         // Fix internal links
         // Very complicated regex
         $this->body = preg_replace('/<a((([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\\s)*)href="' . preg_quote($config['root'], '/') . '(' . sprintf(preg_quote($config['board_path'], '/'), $config['board_regex']) . ')/u', '<a $1href="?/$4', $this->body);
     }
 }
Example #13
0
function mod_edit_page($id)
{
    global $config, $mod, $board;
    $query = prepare('SELECT * FROM ``pages`` WHERE `id` = :id');
    $query->bindValue(':id', $id);
    $query->execute() or error(db_error($query));
    $page = $query->fetch();
    if (!$page) {
        error(_('Could not find the page you are trying to edit.'));
    }
    if (!$page['board'] && $mod['boards'][0] !== '*') {
        error($config['error']['noaccess']);
    }
    if (!hasPermission($config['mod']['edit_pages'], $page['board'])) {
        error($config['error']['noaccess']);
    }
    if ($page['board'] && !openBoard($page['board'])) {
        error($config['error']['noboard']);
    }
    if (isset($_POST['method'], $_POST['content'])) {
        $content = $_POST['content'];
        $method = $_POST['method'];
        $page['type'] = $method;
        if (!in_array($method, array('markdown', 'html', 'infinity'))) {
            error(_('Unrecognized page markup method.'));
        }
        switch ($method) {
            case 'markdown':
                $write = purify_html(markdown($content));
                break;
            case 'html':
                if (hasPermission($config['mod']['rawhtml'])) {
                    $write = $content;
                } else {
                    $write = purify_html($content);
                }
                break;
            case 'infinity':
                $c = $content;
                markup($content);
                $write = $content;
                $content = $c;
        }
        if (!isset($write) or !$write) {
            error(_('Failed to mark up your input for some reason...'));
        }
        $query = prepare('UPDATE ``pages`` SET `type` = :method, `content` = :content WHERE `id` = :id');
        $query->bindValue(':method', $method);
        $query->bindValue(':content', $content);
        $query->bindValue(':id', $id);
        $query->execute() or error(db_error($query));
        $fn = ($board['uri'] ? $board['uri'] . '/' : '') . $page['name'] . '.html';
        $body = "<div class='ban'>{$write}</div>";
        $html = Element('page.html', array('config' => $config, 'body' => $body, 'title' => utf8tohtml($page['title'])));
        file_write($fn, $html);
        modLog("Edited page {$page['name']} <span class='unimportant'>(#{$page['id']})</span>");
    }
    if (!isset($content)) {
        $query = prepare('SELECT `content` FROM ``pages`` WHERE `id` = :id');
        $query->bindValue(':id', $id);
        $query->execute() or error(db_error($query));
        $content = $query->fetchColumn();
    }
    mod_page(sprintf(_('Editing static page: %s'), $page['name']), 'mod/edit_page.html', array('page' => $page, 'token' => make_secure_link_token("edit_page/{$id}"), 'content' => prettify_textarea($content), 'board' => $board));
}
Example #14
0
 public static function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false)
 {
     global $config, $mod, $pdo, $board;
     if ($mod_id === false) {
         $mod_id = isset($mod['id']) ? $mod['id'] : -1;
     }
     if (!in_array($ban_board, $mod['boards']) && $mod['boards'][0] != '*') {
         error($config['error']['noaccess']);
     }
     $range = self::parse_range($mask);
     $mask = self::range_to_string($range);
     $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
     $query->bindValue(':ipstart', $range[0]);
     if ($range[1] !== false && $range[1] != $range[0]) {
         $query->bindValue(':ipend', $range[1]);
     } else {
         $query->bindValue(':ipend', null, PDO::PARAM_NULL);
     }
     $query->bindValue(':mod', $mod_id);
     $query->bindValue(':time', time());
     if ($reason !== '') {
         $reason = escape_markup_modifiers($reason);
         markup($reason);
         $query->bindValue(':reason', $reason);
     } else {
         $query->bindValue(':reason', null, PDO::PARAM_NULL);
     }
     if ($length) {
         if (is_int($length) || ctype_digit($length)) {
             $length = time() + $length;
         } else {
             $length = self::parse_time($length);
         }
         $query->bindValue(':expires', $length);
     } else {
         $query->bindValue(':expires', null, PDO::PARAM_NULL);
     }
     if ($ban_board) {
         $query->bindValue(':board', $ban_board);
     } else {
         $query->bindValue(':board', null, PDO::PARAM_NULL);
     }
     if ($post) {
         $post['board'] = $board['uri'];
         $match_urls = '(?xi)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))';
         $matched = array();
         preg_match_all("#{$match_urls}#im", $post['body_nomarkup'], $matched);
         if (isset($matched[0]) && $matched[0]) {
             $post['body'] = str_replace($matched[0], '###Link-Removed###', $post['body']);
             $post['body_nomarkup'] = str_replace($matched[0], '###Link-Removed###', $post['body_nomarkup']);
         }
         $query->bindValue(':post', json_encode($post));
     } else {
         $query->bindValue(':post', null, PDO::PARAM_NULL);
     }
     $query->execute() or error(db_error($query));
     if (isset($mod['id']) && $mod['id'] == $mod_id) {
         modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : $mask) . ' (<small>#' . $pdo->lastInsertId() . '</small>)' . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
     }
     if (!$config['cron_bans']) {
         rebuildThemes('bans');
     }
     return $pdo->lastInsertId();
 }
Example #15
0
    <?
    foreach($tabs as $t)
    {
      $title = "<a href='#{$t->element_id}' class='tab_clicker'>{$t->tab_title}</a>";
      $img = trim($t->image);
      if ($img !== false && strlen($img) && @file_exists($_SERVER['DOCUMENT_ROOT'].$img))
        $title = "<img src='$img' alt='' title=''> $title";
      echo "<div>$title</div>";
    }
    ?>
    </div>
    <div class='tab_content' style='float:left;position:relative;width:75%; min-height:200px; margin-left:-1px;'>
    <? 
        foreach($tabs as $t)
        {
          echo "<div id='{$t->element_id}' class='content'>";
          echo markup($t->content);
          echo "</div>";
        }
      ?>
   </div>
 </div>

</div>



</body>
</html>

Example #16
0
function mod_new_pm($username)
{
    global $config, $mod;
    if (!hasPermission($config['mod']['create_pm'])) {
        error($config['error']['noaccess']);
    }
    $query = prepare("SELECT `id` FROM ``mods`` WHERE `username` = :username");
    $query->bindValue(':username', $username);
    $query->execute() or error(db_error($query));
    if (!($id = $query->fetchColumn())) {
        // Old style ?/PM: by user ID
        $query = prepare("SELECT `username` FROM ``mods`` WHERE `id` = :username");
        $query->bindValue(':username', $username);
        $query->execute() or error(db_error($query));
        if ($username = $query->fetchColumn()) {
            header('Location: ?/new_PM/' . $username, true, $config['redirect_http']);
        } else {
            error($config['error']['404']);
        }
    }
    if (isset($_POST['message'])) {
        $_POST['message'] = escape_markup_modifiers($_POST['message']);
        markup($_POST['message']);
        $query = prepare("INSERT INTO ``pms`` VALUES (NULL, :me, :id, :message, :time, 1)");
        $query->bindValue(':me', $mod['id']);
        $query->bindValue(':id', $id);
        $query->bindValue(':message', $_POST['message']);
        $query->bindValue(':time', time());
        $query->execute() or error(db_error($query));
        if ($config['cache']['enabled']) {
            cache::delete('pm_unread_' . $id);
            cache::delete('pm_unreadcount_' . $id);
        }
        modLog('Sent a PM to ' . utf8tohtml($username));
        header('Location: ?/', true, $config['redirect_http']);
    }
    mod_page(sprintf('%s %s', _('New PM for'), $username), 'mod/new_pm.html', array('username' => $username, 'id' => $id, 'token' => make_secure_link_token('new_PM/' . $username)));
}
Example #17
0
		</div>
	</section>

	<!-- Screen Reader -->
	<section id="screen-reader" class="section">
		<div class="container">
			<h2 class="section-title">Screen Reader</h2>
			<p>Use the <code>screen-reader</code> class to display content only for screen readers, based from the A11y Project post: <a href="http://a11yproject.com/posts/how-to-hide-content/">How-to: Hide Content</a></p>
			<?php 
markup('<div class="screen-reader">...</div>');
?>

			<h3 class="section-block-title">Screen Reader Focusable</h3>
			<p>In conjunction with the <code>screen-reader</code> class, the <code>screen-reader-focusable</code> class can be added to only display content when it's focused. Useful for "Skip to main content" links.</p>
			<?php 
markup('<div class="screen-reader screen-reader-focusable">...</div>');
?>
		</div>
	</section>
	
	<!-- Aria Roles -->
	<section id="aria-roles" class="section">
		<div class="container">
			<h2 class="section-title">ARIA Roles</h2>
			<?php 
include 'includes/table-aria-roles.html';
?>
		</div>
	</section>
	
	<!-- Notes -->
Example #18
0
 $firephp->info($e->getTraceAsString(), "traceAsString");
 $firephp->info($e->getTrace(), "trace");
 try {
     $Page = new \Sintax\Pages\Error($objUsr);
     $Page->setMsg($e->getMessage());
     ob_clean();
     //limpiamos el buffer para eliminar lo que se haya podido meter antes de saltar la excepción
     markup($Page);
 } catch (Exception $ee) {
     //Excepción durante la representación del error usando la clase de página Error
     try {
         $Page = new Sintax\Pages\Error();
         $msg = 'Error recuperable durante el tratamiento de otro error recuperable.<ul><li>' . $ee->getMessage() . '</li><li>' . $e->getMessage() . '</li></ul>';
         $Page->setMsg($msg);
         ob_clean();
         markup($Page);
     } catch (Exception $eee) {
         //Excepción durante la representación del error usando la clase de página Error sin usuario
         $msg = 'Error no recuperable durante el tratamiento de un error recuperable.';
         $infoExc = "Excepcion de tipo: " . get_class($eee) . ". Mensaje: " . $eee->getMessage() . " en fichero " . $eee->getFile() . " en linea " . $eee->getLine();
         error_log($infoExc);
         //error_log ("TRACE: ".$eee->getTraceAsString());
         $firephp->group($msg, array('Collapsed' => false, 'Color' => '#FF6600'));
         $firephp->info($infoExc);
         $firephp->info($eee->getTraceAsString(), "traceAsString");
         $firephp->info($eee->getTrace(), "trace");
         $firephp->groupEnd();
         ob_clean();
         echo '<h1>' . date("YmdHis") . ': ' . $msg . '</h1>';
     }
 }