예제 #1
0
/**
* getArticleByTitle
*   Searches for an article by title.
* @param string  $title   A URL Prepared title. @see prepareTitle
* @return string    The article handle on success, false if not found
**/
function getArticleByTitle($title)
{
    $articles = getArticles(getArticleCount(), 0, 'title');
    foreach ($articles as $articleTitle => $article) {
        if (prepareTitle($articleTitle) == $title) {
            return $article;
        }
    }
    return false;
}
예제 #2
0
파일: article.php 프로젝트: VecHK/pache
function listingArticleBy($by, $start, $limit, $arg)
{
    switch ($by) {
        case 'class':
            return getArticlesByClass($class, $start, $limit);
            break;
        case 'tag':
            break;
        default:
            return getArticles($start, $limit);
    }
}
/**
 * Generates navigation markup
 * @param  [array] $sections [Sections data array]
 * @param  [string] $lang    [Current language key]
 * @return [string]          [Navigation markup string]
 */
function generateNavigation($sections, $lang, $section_param)
{
    $html = '';
    foreach ($sections as $section_key => $section_dirname) {
        $section_json_file = dirname(__FILE__) . '/sections/' . $section_dirname . '/section.json';
        // Check if section json file exists
        if (file_exists($section_json_file)) {
            $section_string = file_get_contents($section_json_file);
            $current_section = json_decode($section_string, true);
            if (empty($current_section)) {
                echo "<i>Section {$section_dirname} JSON empty or formatted wrong</i>";
            }
            $section_id = $current_section['id'];
            $section_title = $current_section['translations'][$lang];
            $section_path = 'index.php?lang=' . $lang . '&section=' . $section_id;
            // Active class
            $active_class = '';
            if ($section_id == $_GET['section']) {
                $active_class = ' opened';
            }
            // Get Articles List
            $section_articles = getArticles($current_section);
            $html .= '<li class="section section__' . $section_id . '"><a class="section_link' . $active_class . '" href="' . $section_path . '" data-key="' . $section_key . '"  data-id="' . $section_id . '">' . $section_title . '</a>';
            // Generate articles navigation
            if (!empty($section_articles)) {
                $html .= '<ul>';
                foreach ($section_articles as $key => $article) {
                    $article_id = $article['id'];
                    $article_name = $article['translations'][$lang];
                    $article_path = '#' . $article_id;
                    // Update article path if first in article section
                    if ($key == 0) {
                        $article_path = 'index.php?lang=' . $lang . '&section=' . $section_id . '#';
                    } else {
                        if ($section_param != $section_id) {
                            $article_path = 'index.php?lang=' . $lang . '&section=' . $section_id . '#' . $article_id;
                        }
                    }
                    $html .= '<li class="article article__' . $article_id . '"><a class="article_link" href="' . $article_path . '" data-sectionId="' . $section_key . '" data-id="' . $article_id . '" data-section="' . $section_id . '">' . $article_name . '</a></li>';
                }
                $html .= '</ul>';
            }
            $html .= '</li>';
        } else {
            die("Section {$section_dirname} JSON file not found");
        }
    }
    return $html;
}
예제 #4
0
/**
 * Get Sub Category
 * @param cotegory $id
 * @return string
 */
function getSubCategory($id)
{
    $mysqli = connectBD();
    $sub = '';
    $query = "SELECT * FROM categories WHERE id_parent = {$id}";
    if ($result = $mysqli->query($query)) {
        $sub .= '<ul>';
        while ($obj = $result->fetch_object()) {
            $article = getArticles($obj->id) ? getArticles($obj->id) : '';
            $child = getSubCategory($obj->id) ? getSubCategory($obj->id) : '';
            $sub .= '<li>' . $obj->name . '' . $child . $article . '</li>';
        }
        $sub .= '</ul>';
    }
    return $sub;
}
예제 #5
0
function blocks_big_block($row)
{
    $pntable = pnDBGetTables();
    if (!pnSecAuthAction(0, 'Bigblock::', "{$row['title']}::", ACCESS_READ)) {
        return;
    }
    $today = getdate();
    $day = $today["mday"];
    if ($day < 10) {
        $day = "0{$day}";
    }
    $month = $today["mon"];
    if ($month < 10) {
        $month = "0{$month}";
    }
    $year = $today["year"];
    $tdate = "{$year}-{$month}-{$day}";
    $column =& $pntable['stories_column'];
    $articles = getArticles("{$column['time']} LIKE '%{$tdate}%'\n                             AND {$column['ihome']} = 0\n                             AND {$column['counter']} > 0", "{$column['counter']} DESC", "1");
    if (empty($articles)) {
        return;
    } else {
        $info = genArticleInfo($articles[0]);
        if (pnSecAuthAction(0, 'Stories::Story', "{$info['aid']}:{$info['cattitle']}:{$info['sid']}", ACCESS_READ) && pnSecAuthAction(0, 'Topics::Topic', "{$info['topicname']}::{$info['tid']}", ACCESS_READ)) {
            $links = genArticleLinks($articles[0]);
            $preformat = genArticlePreformat($info, $links);
            $content = '<span class="pn-normal">' . _BIGSTORY . '</span><br /><br />';
            $content .= $preformat['title'];
        } else {
            return;
        }
    }
    if (empty($row['title'])) {
        $row['title'] = _TODAYBIG;
    }
    if (empty($content)) {
        return;
    }
    $row['content'] = $content;
    return themesideblock($row);
}
예제 #6
0
파일: index.php 프로젝트: belqasmi/Microcms
<?php

// Data access
$bdd = new PDO('mysql:host=localhost;dbname=microcms;charset=utf8', 'microcms_user', 'secret');
$articles = $bdd->query('select * from t_article order by art_id desc');
?>

<?php 
require 'model.php';
$articles = getArticles();
require 'view.php';
예제 #7
0
파일: 2.php 프로젝트: eseawind/crawler
	
	
 
    var con = new Ext.Panel({
        region: 'center',
        margins:'3 3 3 0',
        defaults:{autoScroll:true},
	   layout: 'accordion',
		layoutConfig: {
			titleCollapse: true,
			animate: true,
			activeOnTop: false
		},
        items:[
		{title: '文章分析',html: '<?php 
$valuearray = getArticles();
foreach ($valuearray as $value) {
    echo "标题:" . $value[5] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;发表日期:" . $value[7] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;来源:" . getModelName($value[mc_id]) . "<br><br>正文:" . $value[1] . "<br><br><hr>";
}
?>
'},
		{title: '好友列表分析',contentEl:"grid"},
		{title: '状态分析',html: '<?php 
//print_r(getSays());
$valuearray = getSays();
foreach ($valuearray as $value) {
    echo "<strong>状态信息</strong>:" . $value[1] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>出处</strong>:" . getModelName($value[mc_id]) . "<br><br>";
}
?>
'}]
    });
예제 #8
0
파일: 1.php 프로젝트: eseawind/crawler
<?php

$article = getArticles();
//print_r($article);
?>




<html> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=gbk"> 
        <title>爬虫</title> 
        <link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css" /> 
        <script type="text/javascript" src="../js/jquery-1.5.1.min.js"></script> 
        <script type="text/javascript" src="../ext/adapter/jquery/ext-jquery-adapter.js"></script> 
        <script type="text/javascript" src="../ext/ext-all.js"></script> 
    
            
    <script type="text/javascript">     		
Ext.onReady(function(){
 
    var con = new Ext.Panel({
        region: 'center',
        margins:'3 3 3 0',
        defaults:{autoScroll:true},
	   layout: 'accordion',
		layoutConfig: {
			titleCollapse: true,
			animate: true,
			activeOnTop: false
예제 #9
0
					$data["messages"] = $messages; 

					if (count($messages) >0)
					{
						foreach($messages as $dataMessage)
						{
							$lastId = $dataMessage["id"];
						}
						$data["idLastMessage"] = $lastId;
					}	
				}
				break;
				
				case "getP" : 
					// Renvoie tous les articles de la base de données
					$res = getArticles();
					$data["feedback"] = "ok"; 
					$data["articles"] = $res;
				break;

				default : 				
					$data["action"] = "default";


			}

		}
	}
		
	 
	echo json_encode($data);
예제 #10
0
파일: index.php 프로젝트: qbitza/tinynews
 */
include_once $CONFIG['lib'] . '/tinynews.php';
?>
<html>
<head>
    <title>TinyNews</title>
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8" />
</head>
<body>
<h1><img src="images/knewsticker.png"> TinyNews<a></h1>
<div align="right"><?php 
echo getArticleCount();
?>
 articles <a href="rss.php">RSS Feed</a></div>
<?php 
foreach (getArticles(10) as $key => $article) {
    ?>
    <div class="title"><a href="article.php/<?php 
    echo prepareTitle(getArticleTitle($article));
    ?>
"><?php 
    echo getArticleTitle($article);
    ?>
</a></div>
    <div class="published">Published: <?php 
    echo date("F d Y H:i:s", getArticlePublished($article));
    ?>
</div>
    <div class="intro"><?php 
    echo getArticleIntro($article);
    ?>
예제 #11
0
function blocks_past_block($row)
{
    $catid = pnVarCleanFromInput('catid');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $oldnum = pnConfigGetVar('perpage');
    if (!pnSecAuthAction(0, 'Pastblock::', "{$row['title']}::", ACCESS_READ)) {
        return;
    }
    if (pnUserLoggedIn()) {
        $storyhome = pnUserGetVar('storynum');
    } else {
        $storyhome = pnConfigGetVar('storyhome');
    }
    // Break out options from our content field
    $vars = pnBlockVarsFromContent($row['content']);
    // Defaults
    if (empty($storynum)) {
        $storynum = 10;
    }
    if (empty($vars['limit'])) {
        $vars['limit'] = 10;
    }
    $storynum = $vars['limit'];
    $column =& $pntable['stories_column'];
    if (!isset($catid) || $catid == '') {
        $articles = getArticles("{$column['ihome']}=0", "{$column['time']} DESC", $storynum, $storyhome);
    } else {
        $articles = getArticles("{$column['catid']}={$catid}", "{$column['time']} DESC", $storynum, $storyhome);
    }
    $time2 = "";
    setlocale(LC_TIME, pnConfigGetVar('locale'));
    $boxstuff = "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\" class=\"pn-normal\">\n";
    $vari = 0;
    $see = 0;
    foreach ($articles as $article) {
        $info = genArticleInfo($article);
        $links = genArticleLinks($info);
        $preformat = genArticlePreformat($info, $links);
        // a little bit tricky to remove the bold property from link description
        // (2001-11-15, hdonner)
        $preformat['title'] = str_replace("pn-title", "pn-normal", $preformat['title']);
        if (!pnSecAuthAction(0, 'Stories::Story', "{$info['aid']}:{$info['cattitle']}:{$info['sid']}", ACCESS_READ) || !pnSecAuthAction(0, 'Topics::Topic', "{$info['topicname']}::{$info['tid']}", ACCESS_READ)) {
            continue;
        }
        $see = 1;
        ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $info['time'], $datetime2);
        $datetime2 = ml_ftime("" . _DATESTRING2 . "", mktime($datetime2[4], $datetime2[5], $datetime2[6], $datetime2[2], $datetime2[3], $datetime2[1]));
        $datetime2 = ucfirst($datetime2);
        if ($time2 == $datetime2) {
            $boxstuff .= "<tr><td valign=\"top\"><big><strong>&middot;</strong></big></td>" . "<td valign=\"top\" width=\"100%\"><span class=\"pn-normal\">" . $preformat['title'] . "&nbsp;({$info['comments']})</span></td></tr>\n";
        } else {
            $boxstuff .= "<tr><td colspan=\"2\"><b>{$datetime2}</b></td></tr>\n" . "<tr><td valign=\"top\"><big><strong>&middot;</strong></big></td>" . "<td valign=\"top\" width=\"100%\"><span class=\"pn-normal\">{$preformat['title']}&nbsp;({$info['comments']})</span></td></tr>\n";
            $time2 = $datetime2;
        }
        $vari++;
        if ($vari == $vars['limit']) {
            $usernum = pnUserGetVar('storynum');
            if (!empty($usernum)) {
                $storynum = $usernum;
            } else {
                $storynum = pnConfigGetVar('storyhome');
            }
            $min = $oldnum + $storynum;
            $boxstuff .= "<tr><td>&nbsp;</td><td valign=\"top\"><a class=\"pn-normal\"";
            if (!isset($catid)) {
                $boxstuff .= "href=\"modules.php?op=modload&amp;name=Search&amp;file=index&amp;action=search&amp;overview=1&amp;active_stories=1\"><b>" . _OLDERARTICLES . "</b></a></td></tr>\n";
            } else {
                $boxstuff .= "href=\"modules.php?op=modload&amp;name=Search&amp;file=index&amp;action=search&amp;overview=1&amp;active_stories=1&amp;stories_cat[0]={$catid}\"><b>" . _OLDERARTICLES . "</b></a></td></tr>\n";
            }
        }
    }
    $boxstuff .= "</table>";
    if ($see == 1) {
        if (empty($row['title'])) {
            $row['title'] = _PASTARTICLES;
        }
        $row['content'] = $boxstuff;
        return themesideblock($row);
    }
}
                $stringthrow1 .= '"></div>';
            }
            $stringthrow1 .= '<p style="color: #f8f8f8; text-shadow: 1px 1px 1px #000;">' . $text . '</p>';
            $stringthrow1 .= '<p class="pull-right"><a href="" data-toggle="modal" data-target="#';
            $stringthrow1 .= hash("sha1", $timestamp);
            $stringthrow1 .= '"><span class="label label-default">';
            $stringthrow1 .= " Click to Comment, Exp: {$expvalue}</span></a></p>";
            $stringthrow1 .= '<ul class="list-inline"><li><a href="#"><i class="glyphicon glyphicon-calendar"></i>';
            $stringthrow1 .= " {$timestamp}</a></li>";
            $stringthrow1 .= '</div><li><a href="#">';
            $stringthrow1 .= '<i class="glyphicon glyphicon-comment"></i>';
            $stringthrow1 .= " {$signature}</a></li></ul></div>";
            $stringthrow1 .= '<hr>';
            unset($image1, $image2, $image3);
            echo "Updated: {$quicker}";
            echo $stringthrow1;
            if ($tempp == "boot") {
            } else {
                file_put_contents($tmpfname, $stringthrow1, FILE_APPEND | LOCK_EX);
                file_put_contents($fil, $tmpfname, LOCK_EX);
            }
            $_SESSION['tmpfname'] = $tmpfname;
        }
    } else {
        $file = file_get_contents($_SESSION['tmpfname'], true);
        echo $file;
    }
}
$run = getArticles($dbh);
?>
 
예제 #13
0
파일: data.php 프로젝트: helquisson/jstree
<?php

require_once 'functions.php';
$mysqli = connectBD();
$query = "SELECT * FROM categories WHERE id_parent = 0";
if ($result = $mysqli->query($query)) {
    ?>
<ul>
	<?php 
    while ($obj = $result->fetch_object()) {
        $article = getArticles($obj->id) ? getArticles($obj->id) : '';
        $sub = getSubCategory($obj->id) ? getSubCategory($obj->id) : '';
        echo '<li>' . $obj->name . '' . $sub . $article . '</li>';
    }
    ?>
</ul>
<?php 
}
예제 #14
0
                $articleToEdit = getArticles($id)[0];
                $comments = getCommentsByArticle($id);
                if (!is_array($articleToEdit['date_article'])) {
                    $articleDate = explode('-', $articleToEdit['date_article']);
                } else {
                    $articleDate = $articleToEdit['date_article'];
                }
                $buttonText = "save";
            }
        } else {
            $buttonText = "add";
        }
    }
}
// Récupère les articles avec leurs commentaires
if (isset($_GET['search_article'])) {
    $articles = searchForArticle($_GET['search_article']);
} else {
    $articles = getArticles($id);
}
foreach ($articles as &$articleToAddComments) {
    $articleToAddComments['comments'] = getCommentsByArticle($articleToAddComments['id_article']);
    $articleToAddComments['content_article'] = nl2br($articleToAddComments['content_article']);
}
$itemperpage = 10;
// Définit les variables de parcours
$totalpage = intval(count($articles) / $itemperpage) + 1;
$startfrom = 0 + $itemperpage * $page - $itemperpage;
$finishto = $itemperpage * $page;
// Affiche les articles
require VIEW_DIR . 'articles.php';
예제 #15
0
파일: home.php 프로젝트: nef-cms/nef-cms
<?php

if (!defined('INDEX')) {
    die('INDEX:error');
}
// cfg must be global for theme to work
global $cfg;
/* get article items */
$articleItems = getArticles();
?>

{TPL:header}
<!-- // header -->

	<!-- left side bar -->
	{TPL:left_sidebar}
	<!-- // left side bar -->
	<div class="content">
		<?php 
// list article items
if (empty($articleItems)) {
    print 'There are currently no articles to display';
} else {
    foreach ($articleItems as $article) {
        if (!$article['article_catid']) {
            $category = '';
        } else {
            $category = 'in <strong><a href="#">' . $article['cat_name'] . '</a></strong>';
        }
        ?>
		<div class="item">
예제 #16
0
파일: list.php 프로젝트: qbitza/tinynews
<table width="100%">
    <tr>
        <th width="15%">Publishing date</td>
        <th width="75%">Title</th>
        <th width="10%">Action</th>
    </tr>
<?php 
foreach (getArticles(50) as $article) {
    ?>
    <tr>
        <td>
            <?php 
    echo date("F d Y H:i:s", getArticlePublished($article));
    ?>
        </td>
        <td>
            <?php 
    $title = getArticleTitle($article);
    echo $title ? $title : '(Untitled)';
    ?>
        </td>
        <td align="center">
            <a href="?action=edit&article=<?php 
    echo $article;
    ?>
"><img src="images/edit.png" width=16 height=16 alt="edit" /></a>
            <a href="?action=delete&article=<?php 
    echo $article;
    ?>
"><img src="images/delete.png" width=16 height=16 alt="delete" /></a>
        </td>
예제 #17
0
/**
 * get the user's theme
 * <br />
 * This function will return the current theme for the user.
 * Order of theme priority:
 *  - page-specific
 *  - category
 *  - user
 *  - system
 *
 * @public
 * @return string the name of the user's theme
 **/
function pnUserGetTheme()
{
    static $theme;
    if (isset($theme)) {
        return $theme;
    }
    // Page-specific theme
    $pagetheme = pnVarCleanFromInput('theme');
    if (!empty($pagetheme)) {
        $themeinfo = pnThemeInfo($pagetheme);
        if ($themeinfo && $themeinfo['active']) {
            $theme = $pagetheme;
            return $pagetheme;
        }
    }
    // set a new theme for the user
    $pagetheme = pnVarCleanFromInput('newtheme');
    if (!empty($pagetheme) && !pnConfigGetVar('theme_change')) {
        $themeinfo = pnThemeInfo($pagetheme);
        if ($themeinfo && $themeinfo['active']) {
            if (pnUserLoggedIn()) {
                $uid = pnUserGetVar('uid');
                $dbconn =& pnDBGetConn(true);
                $pntable =& pnDBGetTables();
                $column =& $pntable['users_column'];
                $sql = "UPDATE {$pntable['users']}\n                        SET {$column['theme']}='" . pnVarPrepForStore($pagetheme) . "'\n                        WHERE {$column['uid']}='" . pnVarPrepForStore($uid) . "'";
                $dbconn->Execute($sql);
            } else {
                pnSessionSetVar('theme', $pagetheme);
            }
            $theme = $pagetheme;
            return $pagetheme;
        }
    }
    // eugenio themeover 20020413
    // override the theme per category or story
    // precedence is story over category override
    list($sid, $file) = pnVarCleanFromInput('sid', 'file');
    if (pnModGetName() == 'News' && (!empty($sid) || strtolower($file) == 'article')) {
        $modinfo = pnModGetInfo(pnModGetIDFromName('News'));
        include_once 'modules/' . $modinfo['directory'] . '/funcs.php';
        $pntable =& pnDBGetTables();
        $results = getArticles("{$pntable['stories_column']['sid']}='" . (int) pnVarPrepForStore($sid) . "'", "", "");
        if (is_array($results) && count($results) > 0) {
            $info = genArticleInfo($results[0]);
            $themeinfo = pnThemeInfo($info['catthemeoverride']);
            if ($themeinfo && $themeinfo['active']) {
                $theme = $info['catthemeoverride'];
                return $theme;
            }
            $themeinfo = pnThemeInfo($info['themeoverride']);
            if ($themeinfo && $themeinfo['active']) {
                $theme = $info['themeoverride'];
                return $theme;
            }
        }
    }
    // User theme
    if (!pnConfigGetVar('theme_change')) {
        if (pnUserLoggedIn()) {
            $usertheme = pnUserGetVar('theme');
        } else {
            $usertheme = pnSessionGetVar('theme');
        }
        $themeinfo = pnThemeInfo($usertheme);
        if ($themeinfo && $themeinfo['active']) {
            $theme = $usertheme;
            return $usertheme;
        }
    }
    // default site theme
    $defaulttheme = pnConfigGetVar('Default_Theme');
    $themeinfo = pnThemeInfo($defaulttheme);
    if ($themeinfo && $themeinfo['active']) {
        $theme = $defaulttheme;
        return $theme;
    }
    return false;
}
예제 #18
0
<?php

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
include_once 'commons.php';
include_once 'db.php';
include_once 'log.php';
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    return getArticles();
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
    $json = file_get_contents('php://input');
    $data = json_decode($json, true);
    var_dump($data);
    $tinyurl = "";
    if (!empty($data["link"])) {
        get_tiny_url($data["link"]);
    }
    return insertArticle($data["title"], $data["body"], $tinyurl);
} elseif ($_SERVER["REQUEST_METHOD"] == "DELETE") {
    $json = file_get_contents('php://input');
    $data = json_decode($json, true);
    $articleID = $data["articleId"];
    if (empty($articleID)) {
        return;
    }
    deleteArticle($articleID);
    log_info("Delete Article: " . $articleID);
} else {
    error("unknown verb");
}
//Functions