Exemplo n.º 1
0
<?php

// 28/02/13 - Add new article to a subtopic
require_once '../../../../../includes/classes/Db.php';
$link = DBCxn::get('../../../../../_db/help.php');
//die($link);
$r = $link->prepare("INSERT INTO content (stopicid, insert_date, controllerid) VALUES (?, NOW(), ?)");
//print_r($r->errorInfo());
$r->execute(array($_POST['id'], 4));
if ($r->rowCount() == 1) {
    // ID for new article | poster name | current date and time
    echo $link->lastInsertId() . '|Bashir|' . date('l jS M Y, H:i');
    // Get topic ID from subtopic ID:
    $r2 = $link->prepare("SELECT topicid FROM stopics WHERE stopic_id=?");
    $r2->execute(array($_POST['id']));
    list($topicid) = $r2->fetch(PDO::FETCH_NUM);
    // Finally update topic and subtopic tables
    $r2 = $link->prepare("UPDATE helptopics SET mod_datetime=NOW() WHERE topic_id=?");
    $r2->execute(array($topicid));
    $r2 = $link->prepare("UPDATE helpstopics SET mod_datetime=NOW() WHERE stopic_id=?");
    $r2->execute(array($_POST['id']));
}
// End if.
Exemplo n.º 2
0
<?php

$path = "../../../../../";
# public_html/apps/help/_inc/ajax/
//ini_set('display_errors', 1);
require_once "{$path}includes/classes/help.class.php";
$help = new Help();
require_once "{$path}{$help->CLASSES_PATH}Db.php";
$link = DBCxn::get("{$path}_db/help.php");
require "{$path}{$help->CLASSES_PATH}Login.php";
# Login class.
$login = new Login($help->sess_dir);
$login->startsession();
if (!isset($_SESSION[$help->sessname])) {
    die('It was a bright sunny morning in July ...');
}
///////////////////////////////////
//  AND topic LIKE '%{$_POST['q']}%'
$r = $link->prepare("SELECT t.topic, t.topic_id, t.hide, s.stopic_id, s.stopic, c.content_id, c.pintonav, c.title \n FROM topics AS t LEFT JOIN stopics AS s ON s.topicid = t.topic_id LEFT JOIN content AS c ON c.stopicid = s.stopic_id \n ORDER BY t.mod_datetime DESC, s.mod_datetime DESC");
$r->execute(array());
$arr_topicids = [];
$arr_stopicids = [];
$arr_contentds = [];
$currtid = 0;
$currstopicid = 0;
while (list($t, $tid, $thide, $stid, $st, $ncontentid, $pintonav, $ncontent) = $r->fetch(PDO::FETCH_NUM)) {
    //echo "$currtid - $tid - $st - $currstopicid - $stid<br>"; # TESTING
    if ($currtid != $tid) {
        $arr_stopicids = [];
    }
    $arr_stopicids[$stid] = array($stid, $st);
Exemplo n.º 3
0
function updateRSS()
{
    $db = DBCxn::get();
    $selectRSS = $db->query("SELECT id, rssLink, updateMd5 FROM rss");
    $selectRSS->setFetchMode(PDO::FETCH_ASSOC);
    $selectRSS = $selectRSS->fetchAll();
    //构建分析
    $feed = new SimplePie();
    $feed->enable_order_by_date(false);
    $feed->enable_cache(true);
    $feed->set_useragent('Mozilla/4.0 ' . SIMPLEPIE_USERAGENT);
    $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
    //拿出每个RSS调用分析函数
    foreach ($selectRSS as $rows) {
        $rssId = $rows['id'];
        //博客ID
        $updateMd5 = $rows['updateMd5'];
        //最后更新记录的md5值
        $feed->set_feed_url($rows['rssLink']);
        //feed地址做参数进行解析操作
        $feed->set_timeout(30);
        $feed->init();
        //如果feed出错,执行下一个
        if ($feed->error()) {
            continue;
        }
        readRSS($rssId, $updateMd5, $feed);
    }
    return true;
}
Exemplo n.º 4
0
 public function display()
 {
     $link = DBCxn::get($this->_DB);
     # Link to database.
     $r_topics = $link->prepare("SELECT topic_id, topic FROM topics WHERE hide!=1 ORDER BY mod_datetime DESC");
     $r_topics->execute(array());
     if ($r_topics->rowCount() == 0) {
         die('No topics');
     }
     // End if.
     require_once '../../../includes/classes/Document.php';
     require_once '../../../includes/classes/Forms.php';
     require_once '../../../includes/classes/Tables.php';
     $document = new Document('Help', '_inc/styles/styles.css', array('/scripts/jquery/js/jquery-1.8.3.min.js', '/scripts/tinymce/jscripts/tiny_mce/jquery.tinymce.js', '_inc/js/goup.js', '_inc/js/help.js'));
     echo '<a href="#" class="btnNav">Nav</a> <a href="#" class="scrollup">Scroll</a>
 <div class="logout"><a href="?act=signout">Logout</a></div>';
     $tables = new Tables(array('id' => 'helpsection'), "Topics: {$r_topics->rowCount()}");
     # ID and Caption for start table tag.
     // Need a counter for the table columns:
     $i = 0;
     $topic_counter = 1;
     $items = 3;
     // Display each topic:
     while (list($topicid, $topic) = $r_topics->fetch(PDO::FETCH_NUM)) {
         // Do we need to start a new row?
         if ($i == 0) {
             echo "<tr valign=\"top\">\n";
         }
         // End if.
         echo "<td>\n      <h2 id=\"topic_{$topic_counter}\">{$topic_counter} {$topic}<span title=\"{$topicid}\">Hide</span></h2>\n";
         //$stxt = '';
         // 04/08/13 - If search text is submitted, filter results:
         //if (isset($_POST['stxt'])) { $stxt = " AND stopic like '%{$_POST['stxt']}%'"; } // End if.
         // Sub-topics:
         $r_stopics = $link->prepare("SELECT stopic_id, stopic FROM stopics WHERE topicid=? and hide!=1 ORDER BY mod_datetime DESC");
         $r_stopics->execute(array($topicid));
         // Scroll through subtopics
         while (list($stopicid, $stopic) = $r_stopics->fetch(PDO::FETCH_NUM)) {
             // Sub topic
             echo "<h3 id=\"s_{$stopicid}\">\n        <a href=\"_inc/php/helpstopicren.php?stopicid={$stopicid}\" class=\"stopic_a\" title=\"Rename Sub topic\">{$stopic}</a></h3>\n";
             //$stxt2 = ''; $stxt2
             // 04/08/13 - If search text is submitted, filter results:
             //if (isset($_POST['stxt'])) { $stxt2 = " AND title LIKE '%{$_POST['stxt']}%'"; } // End if.
             // Get main articles in each subtopic:
             $r_articles = $link->prepare("SELECT\n        c.content_id,\n        c.mod_datetime,\n        c.controllerid,\n        c.title,\n        c.content, \n        c.pintonav, \n        DATE_FORMAT(c.insert_date,  '%a %D %b %Y, %H:%i') AS insert_dt,\n        DATE_FORMAT(c.mod_datetime, '%a %D %b %Y, %H:%i') AS insert_dt,\n        DATE_FORMAT(c.mod_datetime, '%a %D %b %Y')        AS insert_dt2,\n        u.name\n               \n        FROM content AS c \n        INNER JOIN users AS u ON c.controllerid = u.controller_id\n               \n        WHERE c.stopicid=? AND c.parentid=0 ORDER BY c.mod_datetime DESC");
             $r_articles->execute(array($stopicid));
             if (!$r_articles) {
                 print_r($r_articles->errorInfo());
             }
             // End if.
             // Display new article link for subtopics with no articles
             if ($r_articles->rowCount() == 0) {
                 echo "<p class=\"newarticle\" title2=\"{$stopicid}\"><a href=\"#\">New article</a></p>";
             }
             // End if.
             $artnum = 1;
             //$hightlighttitle = ' - IMPORTANT';
             while (list($acid, $amod, $acon, $atitle, $acontent, $pintonav, $ains, $aupd, $aupd3, $aposter) = $r_articles->fetch(PDO::FETCH_NUM)) {
                 // Article title
                 $aupd2 = "{$this->DaysAwayTo($aupd3)} days";
                 $aupdtxt = $aupd != '0000-00-00 00:00:00' ? "<br />Updated: [<strong>{$aupd}</strong> {$aupd2}]" : '';
                 //if (strpos($atitle, $hightlighttitle) != false) {
                 if ($pintonav == 1) {
                     //$atitle = str_replace( $hightlighttitle, '', $atitle);
                     $atitle = "<span class=\"highlighted\">{$atitle}</span>";
                 }
                 // End if.
                 echo "<li class=\"article_li\" id=\"li_art{$acid}\">\n          <a id=\"mainarticle{$acid}\" class=\"mainarticle\" title2=\"{$acid}\">{$artnum}. &nbsp;{$atitle}</a>\n          \n          <ul type=\"square\" id=\"replylist{$acid}\">";
                 // Get any replies:
                 $r_articlereplies = $link->prepare("SELECT\n              content.content_id,\n              content.controllerid,\n              content.title, \n              content.pintonav, \n              DATE_FORMAT(content.insert_date, '%a %D %b %Y, %H:%i') AS insert_dt,\n              DATE_FORMAT(content.mod_datetime, '%a %D %b %Y, %H:%i') AS insert_dt,\n              users.name\n              FROM content\n                \n              INNER JOIN users ON content.controllerid = users.controller_id\n                \n              WHERE parentid=? ORDER BY mod_datetime DESC");
                 $r_articlereplies->execute(array($acid));
                 while (list($rcontentid, $rposterid, $rtitle, $pintonav, $rins, $rupd, $rposter) = $r_articlereplies->fetch(PDO::FETCH_NUM)) {
                     $rupd2 = "{$this->DaysAwayTo($rupd)} days";
                     $updtxt = $rupd != '0000-00-00 00:00:00' ? "<br />Updated: [<strong>{$rupd}</strong> {$rupd2}]" : '';
                     // 31/05/15 - Highlight replies with 'Important in them.'
                     if ($pintonav == 1) {
                         //$rtitle = str_replace( $hightlighttitle, '', $rtitle);
                         $rtitle = "<span style=\"background:yellow;color:#000;\">{$rtitle}</span>";
                     }
                     // End if.
                     echo "<li>\n            <a id=\"subbarticle{$rcontentid}\" class=\"subbarticle\" title2=\"{$rcontentid}\">{$rtitle} ({$rupd2})</a>\n            <!--<span id=\"rposter{$rcontentid}\" class=\"rposter\">By [{$rposter}] on [{$rins}]{$updtxt}</span>-->\n            </li>";
                 }
                 // End while.
                 echo '' . "\n";
                 // What about replies to replies? does not work yet!
                 echo "<p class=\"articleoption article{$stopicid}option\">\n            <a id=\"reply{$acid}\" class=\"reply\" title2=\"{$acid}\">Reply</a>\n          </p>";
                 echo "\n          </ul></li>\n";
                 $artnum++;
             }
             // End while main articles
             // New article:
             echo "<p class=\"articleoption article{$stopicid}option newarticle\" title2=\"{$stopicid}\">\n        <a>New article</a></p>\n";
         }
         // End while stopics
         // New sub topic button
         echo "<p><a href=\"_inc/php/helpstopicnew.php?topicid={$topicid}\" class=\"newsubtopic\">New sub topic</a></p>\n";
         echo '
   </td>';
         // Close topic table cell
         $i++;
         if ($i == $items) {
             echo "</tr>\n";
             $i = 0;
             // Reset counter.
         }
         // End if.
         $topic_counter++;
     }
     // End while topics
     unset($tables);
     unset($document);
 }
Exemplo n.º 5
0
    {
    }
    private final function __clone()
    {
    }
    public static function get()
    {
        if (is_null(self::$db)) {
            self::$db = new PDO(self::$dsn, self::$user, self::$pass);
        }
        //返回连接
        self::$db->query('set names utf8');
        return self::$db;
    }
}
$db = DBCxn::get();
//根据当前用户查询阅读信息
$selectReadInfo = $db->prepare("SELECT DISTINCT readInfo FROM readinfo WHERE userName = ?");
$selectReadInfo->execute(array($user));
$readInfo = unserialize($selectReadInfo->fetchColumn());
$sql_1 = "SELECT * FROM articles WHERE rssId IN(SELECT DISTINCT rssId FROM readinfo WHERE userName=?) ORDER BY pubDate DESC, id LIMIT 0, 20";
$st1 = $db->prepare($sql_1);
$st1->execute(array($user));
//显示文章列表
foreach ($st1->fetchAll() as $row) {
    if (isset($readInfo[$row['id']])) {
        //查询是否已读
        echo '<li><a href="javaScript:" id="all-' . $row['id'] . '" class="readed" ><h3>' . $row['title'] . '</h3><p>作者:' . $row['author'] . '</p><span></span></a></li>';
    } else {
        echo '<li><a href="javaScript:" id="all-' . $row['id'] . '" class="unreaded" ><h3>' . $row['title'] . '</h3><p>作者:' . $row['author'] . '</p></a></li>';
    }
Exemplo n.º 6
0
function initRss($rssLink, $user)
{
    $db = DBCxn::get();
    //构建对象
    $feed = new SimplePie();
    $feed->set_feed_url($rssLink);
    //feed地址做参数进行解析操作
    $feed->set_timeout(30);
    $feed->enable_cache(false);
    $feed->init();
    if ($feed->error()) {
        //feed地址错误
        //echo $feed->error();
        return "error";
    }
    $blogName = $feed->get_title();
    $blogLink = $feed->get_link();
    $selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
    $selectOneRSS->execute(array($blogLink));
    $blogLinkId = $selectOneRSS->fetchColumn();
    //此RSS在数据库表中id
    //检查是否存在,如果不存在添加此feed
    if ($blogLinkId > 0) {
        //echo "此订阅源已经存在!";
        //检查用户是否已经订阅
        $checkSub = $db->prepare("SELECT count(*) FROM readinfo WHERE userName = ? AND rssId = ?");
        $checkSub->execute(array($user, $blogLinkId));
        $boolCheckSub = $checkSub->fetchColumn();
        if ($boolCheckSub != 1) {
            //用户没有订阅
            $insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
            $insertReadInfo->bindParam(':user', $user);
            $insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
            $insertReadInfo->execute();
            //"此源已经存在,你之前尚未订阅,现在已经订阅";
            //return "succeed1";
            return "rss-" . $blogLinkId;
        } else {
            //"此源已经存在,你之前已经订阅";
            return "succeed2";
        }
    } else {
        $sql = "INSERT INTO rss(blogName,blogLink,rssLink,updateMd5) VALUES(:blogName,:blogLink,:rssLink,:updateMd5)";
        $insertRSS = $db->prepare($sql);
        $insertRSS->bindParam(':blogName', $blogName);
        $insertRSS->bindParam(':blogLink', $blogLink);
        $insertRSS->bindParam(':rssLink', $rssLink);
        $insertRSS->bindParam(':updateMd5', $updateMd5);
        $updateMd5 = md5("123456");
        $insertRSS->execute();
        //查询该源的ID
        $selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
        $selectOneRSS->execute(array($blogLink));
        $blogLinkId = $selectOneRSS->fetchColumn();
        //订阅此源
        //$db->exec("INSERT INTO readinfo(userName,rssId) VALUES ($user, $blogLinkId)");
        $insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
        $insertReadInfo->bindParam(':user', $user);
        $insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
        $insertReadInfo->execute();
        //"此源不存在,现在已经订阅";
        return "rss-" . $blogLinkId;
    }
}
Exemplo n.º 7
0
function verifyUser($verifyStr)
{
    $db = DBCxn::get();
    $st = $db->prepare('UPDATE users SET verifed=1 WHERE verifyStr=?');
    $st->execute(array($verifyStr));
    $rowCount = $st->rowCount();
    //查询影响行
    if ($rowCount == 1) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 8
0
Arquivo: Diary.php Projeto: bas2/diary
 public function dbConn($creds)
 {
     $this->link = DBCxn::get($creds);
     # Link to database.
 }