/**
 * Process a Github issue comment.
 *
 * @param object $payload
 *   The received data.
 */
function handle_issue_comment($payload)
{
    // There is no pull request API URL in the issue, so we need to construct it
    // from the pattern.
    $pull_request_url = str_replace('{/number}', '/' . $payload->issue->number, $payload->repository->pulls_url);
    try {
        $pull_request = get_pull_request($pull_request_url);
    } catch (ClientErrorResponseException $e) {
        // Pull request does not exist, so we ignore this comment.
        exit;
    }
    $issue_number = get_issue_number($pull_request);
    if (!$issue_number) {
        exit;
    }
    $comment = '<a href="' . $payload->comment->user->html_url . '">' . $payload->comment->user->login . '</a> posted a <a href="' . $payload->comment->html_url . '">new comment</a> on ' . $payload->comment->html_url . ".\n\n";
    $comment .= $payload->comment->body;
    post_comment($issue_number, $comment);
}
:<?php 
    post_date('F j, Y');
    ?>
</span>
				<span><?php 
    _e('Category');
    ?>
:<?php 
    post_category(',');
    ?>
</span>
				<a href="<?php 
    post_link();
    ?>
#comments"><?php 
    post_comment('No Comments', '1 Comment', '%d Comments');
    ?>
</a>
			</p>
			<?php 
    post_content(500);
    ?>
		</div>
		<?php 
}
?>

		<?php 
post_nav();
?>
	</div><!-- end #content-->
Exemple #3
0
// Initialize message array if it doesn't exist
if (!isset($_SESSION['success'])) {
    $_SESSION['success'] = array();
}
if (isset($_POST['action'])) {
    // This is registration
    if ($_POST['action'] == 'register') {
        register_user($_POST);
    } else {
        if ($_POST['action'] == 'login') {
            login_user($_POST);
        } else {
            if ($_POST['action'] == 'message') {
                post_message($_POST);
            } else {
                post_comment($_POST);
            }
        }
    }
} else {
    session_destroy();
    header('Location: index.php');
}
function register_user($post)
{
    //--------------being of validation checks-----------------------//
    $_SESSION['errors'] = array();
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "First name can't be blank";
    }
    if (empty($post['last_name'])) {
Exemple #4
0
/**
 * Article Box
 */
function display_article_box($row)
{
    global $cfg, $lang, $cd, $session_status, $id, $admin_dir, $article_addition;
    // Permanent Link
    if (empty($id)) {
        $permalink = '<a href="' . $cd . '/article.php?id=' . $row['id'] . '" title="' . $lang['permalink_title_1'] . htmlspecialchars(strip_tags($row['name'])) . $lang['permalink_title_2'] . '" rel="Bookmark">Permalink</a> ';
        $read_more = '<p class="read-more"><a href="' . $cd . '/article.php?id=' . $row['id'] . '" title="' . $row['name'] . '">' . $lang['more'] . '</a></p>';
        $row['comment'] = preg_replace('/<!-- ?more ?-->.*<!-- ?\\/more ?-->/is', $read_more, $row['comment']);
        $row['comment'] = preg_replace('/<!-- ?more ?-->.*/is', $read_more, $row['comment']);
    } else {
        $permalink = '';
    }
    if (file_exists($cd . '/include/user_include/plugins/plg_isbn.inc.php')) {
        include_once $cd . '/include/user_include/plugins/plg_isbn.inc.php';
        $FKMM_isbn = new FKMM_isbn();
        $row['comment'] = $FKMM_isbn->convert_isbn($row['comment']);
    }
    // Convert Text to XHTML
    if (file_exists($cd . '/include/user_include/plugins/plg_markdown.inc.php')) {
        include_once $cd . '/include/user_include/plugins/plg_markdown.inc.php';
        $FKMM_markdown = new FKMM_markdown();
        $row['comment'] = $FKMM_markdown->convert($row['comment']);
    } else {
        $row['comment'] = xhtml_auto_markup($row['comment']);
    }
    // Convert Enclosure
    if (file_exists($cd . '/rss/include/P_BLOG_RSS.class.php')) {
        include_once $cd . '/rss/include/P_BLOG_RSS.class.php';
        $p_rss = new P_BLOG_RSS();
        $row['comment'] = $p_rss->convertEnclosure($row['comment']);
    }
    $row['comment'] = preg_replace('/src="\\./', 'src="' . $cd, $row['comment']);
    // Smiley
    $row = smiley($row);
    // Article title
    if ($row['href'] == "http://") {
        $article_title = $row['name'];
    } else {
        $article_title = '<a href="' . $row['href'] . '">' . $row['name'] . "</a>\n";
    }
    // Time format
    if ($cfg['show_date_title'] == 'yes') {
        switch ($cfg['date_style']) {
            case '1':
                $df = 'Y/m/d';
                break;
            case '2':
                $df = 'M d, Y';
                break;
            default:
                $df = 'Y-m-d';
                break;
        }
        $row['date'] = date($df . ' G:i:s', strtotime($row['date']));
        $row['mod'] = date($df . ' G:i:s', strtotime($row['mod']));
    }
    if ($row['date'] != $row['mod']) {
        $row['date'] = date('G:i:s', strtotime($row['date']));
        $mod_str = ', ' . $lang['mod'] . ' @ ' . $row['mod'];
    } else {
        $row['date'] = date('G:i:s', strtotime($row['date']));
        $mod_str = '';
    }
    // Category
    $category_title = $lang['cat_title_1'] . $row['category'] . $lang['cat_title_2'];
    $category = '<a href="' . $cd . '/category.php?k=' . urlencode($row['category']) . '" title="' . $category_title . '">' . $row['category'] . '</a>';
    // Show date time
    if ($cfg['show_date_time'] == 'yes') {
        $date_time = '<div class="date">' . $lang['post'] . ' @ ' . $row['date'] . ' ' . $mod_str . ' | ' . $category . "</div>\n";
    } else {
        $date_time = '';
    }
    // Show e-mail link
    if ($cfg['use_email_link'] == 'yes') {
        $via_email_title = $lang['via_email_title_1'] . htmlspecialchars(strip_tags($row['name'])) . $lang['via_email_title_2'];
        $email_link = '<a href="' . $cd . '/var/feedback/index.php?id=feedback&amp;a_id=' . $row['id'] . '" title="' . $via_email_title . '">Email</a>';
    } else {
        $email_link = '';
    }
    // Show comment link
    if ($cfg['use_comment_link'] == 'yes' && @file_exists('./forum/index.php')) {
        switch ($cfg['comment_style']) {
            case '2':
                $comment = post_comment();
                // "Comment" style
                break;
            case '1':
                $comment = post_comment_forum();
                // "Forum" style
                break;
            default:
                $comment = post_comment();
                break;
        }
    } else {
        $comment = '';
    }
    // Show trackbacks
    if ($cfg['trackback'] == 'on') {
        $trackback = display_trackback($row);
    } else {
        $trackback = '';
    }
    // Show "Modify or Delete" button when Admin mode.
    if ($session_status == 'on') {
        if ($row['draft'] == '1') {
            $update_target = 'draft_update';
        } else {
            $update_target = 'update';
        }
        $admin_button = <<<EOD
<form action="{$cd}/{$admin_dir}/{$update_target}.php" method="post">
<div class="submit-button">
<input type="hidden" name="id" value="{$row['id']}" />
<input type="hidden" name="mode" value="log" />
<input type="hidden" name="post_username" value="" />
<input type="hidden" name="post_password" value="" />
<input type="submit" tabindex="1" accesskey="m" value="{$lang['mod_del']}" />
</div>
</form>
EOD;
    } else {
        $admin_button = '';
    }
    // Article footer
    if (!empty($id)) {
        // When Permalink
        if ($email_link != '') {
            $email_link = <<<EOD
<div class="a-footer">
{$email_link}
</div>
EOD;
        } else {
            $email_link = '';
        }
        $article_footer = <<<EOD
{$email_link}{$article_addition}
{$trackback}
{$comment}
{$admin_button}
EOD;
    } else {
        // When Index
        $article_footer = <<<EOD
<div class="a-footer">
{$permalink}{$email_link}
{$trackback}
{$comment}{$admin_button}
</div>
EOD;
    }
    //////////////// Presentation! /////////////////
    $article_box = <<<EOD
<div class="section">
<h3 class="article-title">{$article_title}</h3>
{$date_time}<div class="comment">
{$row['comment']}
</div>
{$article_footer}
</div><!-- End .section -->

EOD;
    return $article_box;
}
    post_id();
    ?>
');return false;"><?php 
    post_title();
    ?>
</a></td>
					<td><?php 
    post_author();
    ?>
</td>
					<td><?php 
    post_category();
    ?>
</td>
					<td><?php 
    post_comment();
    ?>
</td>
					<td><?php 
    post_date();
    ?>
</td>
				</tr>
			<?php 
    $i++;
}
?>
			</tbody>
		</table>
		<?php 
$nav = post_nav(FALSE);
Exemple #6
0
 $postId = (int) $_POST['post_id'];
 $chk = single_post($postId);
 $uid = (int) $var['uid'];
 if ($chk) {
     $json = array();
     $json['message'] = "Posts found!";
     $json['success'] = 1;
     $json['data'] = json_decode($chk, true);
     $arr = json_decode($json['data'][0]['post_like']);
     if (in_array($uid, $arr)) {
         $json['data'][0]['liked'] = 1;
     } else {
         $json['data'][0]['liked'] = 0;
     }
     $json['data'][0]['post_like'] = count($arr);
     $com = post_comment($postId);
     $json['data'][0]['comments'] = json_decode($com, true);
     $len = count($json['data'][0]['comments']);
     $json['data'][0]['total_comment'] = $len;
     if ($len == 0) {
         $json['data'][0]['comments'] = array();
     } else {
         for ($i = 0; $i < $len; $i++) {
             $tmp = $json['data'][0]['comments'][$i]['comment_id'];
             $json['data'][0]['comments'][$i]['subcomment'] = sub_comments($postId, $tmp);
             if ($json['data'][0]['comments'][$i]['subcomment'] == null) {
                 $json['data'][0]['comments'][$i]['subcomment'] = array();
             }
         }
     }
     echo json_encode($json);
<script>
// @ 回复
function comment_reply( cid ) {
	document.getElementById('comment_content').value = "@comment-" + cid + "\n" + document.getElementById('comment_content').value;
	setTimeout( 'document.getElementById("comment_content").focus();', 50 );
}
</script>
<div id="comments">
	<?php 
echo plugin_call('preComment');
?>

	<h4><?php 
post_comment(_t('No Comments'), _t('Only One Comment &raquo;'), _t('%d Comments &raquo;'));
?>
</h4>

	<ol class="comment-list">
	<?php 
while (comment_next()) {
    ?>
		<li id="comment-<?php 
    comment_id();
    ?>
" class="comment-body"> 
			<div class="comment-author"> 
				<img class="avatar" src="<?php 
    comment_avatar();
    ?>
" alt="<?php 
    comment_author();
/**
 ** Read the log message for this revision
 **/
// Run git show to get the log message for this revision
$log_message = shell_exec(implode(' ', array(escapeshellcmd($git), '--git-dir=' . escapeshellarg($repo), 'show', '--stat', escapeshellarg($rev))));
if (!empty($log_message)) {
    $tickets = find_tickets($log_message);
    $kolab_tickets = find_kolab_tickets($log_message);
    foreach ($kolab_tickets as $ticket) {
        $log_message .= "\nThis ticket also references kolab issue: http://issues.kolab.org/issue{$ticket}\n\n";
    }
    if (count($tickets)) {
        $log_message = "Changes have been made in Git (" . $refname . "):\n\n" . $log_message . "\n" . $links;
        foreach ($tickets as $ticket) {
            fputs(STDERR, "Updating Ticket #" . $ticket . "...\n");
            post_comment($ticket, $log_message);
        }
    }
}
exit(0);
/**
 ** Functions
 **/
function abort($msg)
{
    fputs(STDERR, $msg . "\n");
    exit(1);
}
function usage()
{
    abort("usage: whups-git-hook.php PATH_TO_REPO REVISION REFNAME LINKS");
Exemple #9
0
        $chk = post_list();
        $uid = (int) $var['uid'];
        if ($chk) {
            $json['message'] = "Posts found!";
            $json['success'] = 1;
            $json['data'] = json_decode($chk, true);
            $counter = count($json['data']);
            for ($post = 0; $post < $counter; $post++) {
                $arr = json_decode($json['data'][$post]['post_like']);
                $json['data'][$post]['post_like'] = count($arr);
                if (in_array($uid, $arr)) {
                    $json['data'][$post]['liked'] = 1;
                } else {
                    $json['data'][$post]['liked'] = 0;
                }
                $com = post_comment($json['data'][$post]['post_id']);
                $arr = json_decode($com, true);
                $len = count($arr);
                $json['data'][$post]['post_comment'] = $len;
            }
            echo json_encode($json);
        } else {
            echo err_json('No posts found!');
        }
    } else {
        echo err_json('Please login!');
    }
    //
} else {
    echo err_json('Wrong API Key.');
}
if (isset($_POST['add_comment']) && $_POST['add_comment']) {
    if (is_file($cmm)) {
        $comments = @file_get_contents($cmm);
        $comments = @unserialize($comments);
        if (!is_array($comments)) {
            $comments = array();
        }
        $newId = (count($keys = array_keys($comments)) ? intval(max($keys)) : 0) + 1;
        $txt = isset($_POST['text']) ? trim($_POST['text']) : '';
        if ($txt) {
            $comments[$newId] = array('user' => isset($_POST['user']) ? $_POST['user'] : '******', 'date' => date('Y-m-d'), 'time' => date('H:i'), 'text' => htmlspecialchars($txt));
            $old = umask(0);
            @chmod($cmm, 0777);
            umask($old);
            @file_put_contents($cmm, serialize($comments));
            $out = post_comment($postId, $comments[$newId]['user'], $comments[$newId]['text']);
            //wf_log(print_r($out, true));
        }
    }
    header('Location: ./?view=blog&postId=' . $postId);
    exit;
}
if ($postId !== false) {
    $post = $base_dir . '/blog.' . $postId . '.php';
    if (is_file($post)) {
        $post = file_get_contents($post);
        ob_start();
        eval("\n ?" . ">" . $post . "<" . "?php \n");
        $post = ob_get_clean();
        $post = preg_replace('#<!-- .* -->#ismU', '', $post);
        echo $post;