Esempio n. 1
0
function tweet()
{
    global $APIsettings;
    $categoryCodes = array('w', 'n', 'b', 'tc', 'e', 's');
    $firstIdx = array_rand($categoryCodes);
    $firstCat = $categoryCodes[$firstIdx];
    unset($categoryCodes[$firstIdx]);
    $categoryCodes = array_values($categoryCodes);
    $topics = getTopics($firstCat);
    if (count($topics) > 0) {
        $firstTopic = $topics[array_rand($topics)];
        $headline = getHeadline($firstTopic);
        if ($headline != null && strstr($headline, $firstTopic->name) !== false) {
            $secondCat = $categoryCodes[array_rand($categoryCodes)];
            $newTopics = getTopics($secondCat);
            if (count($newTopics) > 0) {
                $secondTopic = $newTopics[array_rand($newTopics)];
                $newHeadline = str_replace($firstTopic->name, $secondTopic->name, $headline);
                if (strlen($newHeadline) < 141) {
                    // Post the tweet
                    $postfields = array('status' => $newHeadline);
                    $url = "https://api.twitter.com/1.1/statuses/update.json";
                    $requestMethod = "POST";
                    $twitter = new TwitterAPIExchange($APIsettings);
                    echo $twitter->buildOauth($url, $requestMethod)->setPostfields($postfields)->performRequest();
                } else {
                    tweet();
                }
            } else {
                tweet();
            }
        } else {
            tweet();
        }
    } else {
        tweet();
    }
}
Esempio n. 2
0
					</div>
				</div>
				<!--user timeline ends-->
				<!--Content timeline starts-->
				<div id="content_timeline">
					<form action="home.php?id=<?php 
    echo $user_id;
    ?>
" method="post" id="f">
					<h2>What's your question today? let's discuss!</h2>
					<input type="text" name="title" placeholder="Write a Title..." size="82" required="required"/><br/> 
					<textarea cols="83" rows="4" name="content" placeholder="Write description..."></textarea><br/>
					<select name="topic">
						<option>Select Topic</option>
						<?php 
    getTopics();
    ?>
					</select>
					<input type="submit" name="sub" value="Post to Timeline"/>
					</form>
					<?php 
    insertPost();
    ?>
					
						<h3>All Posts in this Category!</h3> 
						<?php 
    get_Cats();
    ?>
				</div>
				<!--Content timeline ends-->
			</div>
function theindex($catid)
{
    global $storyhome, $httpref, $httprefmax, $topicname, $topicimage, $topictext, $datetime, $user, $cookie, $nukeurl, $prefix, $multilingual, $currentlang, $db, $articlecomm, $module_name;
    if ($multilingual == 1) {
        $querylang = "AND (alanguage='{$currentlang}' OR alanguage='')";
        /* the OR is needed to display stories who are posted to ALL languages */
    } else {
        $querylang = "";
    }
    include "header.php";
    if (isset($cookie[3])) {
        $storynum = $cookie[3];
    } else {
        $storynum = $storyhome;
    }
    $catid = intval($catid);
    $db->sql_query("update " . $prefix . "_stories_cat set counter=counter+1 where catid='{$catid}'");
    $result = $db->sql_query("SELECT sid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes, acomm, score, ratings FROM " . $prefix . "_stories where catid='{$catid}' {$querylang} ORDER BY sid DESC limit {$storynum}");
    while ($row = $db->sql_fetchrow($result)) {
        $s_sid = intval($row['sid']);
        $aid = stripslashes($row['aid']);
        $title = stripslashes(check_html($row['title'], "nohtml"));
        $time = $row['time'];
        $hometext = stripslashes($row['hometext']);
        $bodytext = stripslashes($row['bodytext']);
        $comments = intval($row['comments']);
        $counter = intval($row['counter']);
        $topic = intval($row['topic']);
        $informant = stripslashes($row['informant']);
        $notes = stripslashes($row['notes']);
        $acomm = intval($row['acomm']);
        $score = intval($row['score']);
        $ratings = intval($row['ratings']);
        getTopics($s_sid);
        formatTimestamp($time);
        $subject = stripslashes(check_html($subject, "nohtml"));
        $introcount = strlen($hometext);
        $fullcount = strlen($bodytext);
        $totalcount = $introcount + $fullcount;
        $c_count = $comments;
        $r_options = "";
        if (isset($cookie[4])) {
            $r_options .= "&amp;mode={$cookie['4']}";
        }
        if (isset($cookie[5])) {
            $r_options .= "&amp;order={$cookie['5']}";
        }
        if (isset($cookie[6])) {
            $r_options .= "&amp;thold={$cookie['6']}";
        }
        $story_link = "<a href=\"modules.php?name=News&amp;file=article&amp;sid={$s_sid}{$r_options}\">";
        $morelink = "(";
        if ($fullcount > 0 or $c_count > 0 or $articlecomm == 0 or $acomm == 1) {
            $morelink .= "{$story_link}<b>" . _READMORE . "</b></a> | ";
        } else {
            $morelink .= "";
        }
        if ($fullcount > 0) {
            $morelink .= "{$totalcount} " . _BYTESMORE . " | ";
        }
        if ($articlecomm == 1 and $acomm == 0) {
            if ($c_count == 0) {
                $morelink .= "{$story_link}" . _COMMENTSQ . "</a>";
            } elseif ($c_count == 1) {
                $morelink .= "{$story_link}{$c_count} " . _COMMENT . "</a>";
            } elseif ($c_count > 1) {
                $morelink .= "{$story_link}{$c_count} " . _COMMENTS . "</a>";
            }
        }
        if ($score != 0) {
            $rated = substr($score / $ratings, 0, 4);
        } else {
            $rated = 0;
        }
        $morelink .= " | " . _SCORE . " {$rated}";
        $morelink .= ")";
        $morelink = str_replace(" |  | ", " | ", $morelink);
        $sid = intval($s_sid);
        $row2 = $db->sql_fetchrow($db->sql_query("select title from " . $prefix . "_stories_cat where catid='{$catid}'"));
        $title1 = stripslashes(check_html($row2['title'], "nohtml"));
        $title = "{$title1}: {$title}";
        themeindex($aid, $informant, $datetime, $title, $counter, $topic, $hometext, $notes, $morelink, $topicname, $topicimage, $topictext);
    }
    if ($httpref == 1) {
        $referer = $_SERVER["HTTP_REFERER"];
        if ($referer == "" or ereg("unknown", $referer) or eregi($nukeurl, $referer)) {
        } else {
            $db->sql_query("insert into " . $prefix . "_referer values (NULL, '{$referer}')");
        }
        $numrows = $db->sql_numrows($db->sql_query("select * from " . $prefix . "_referer"));
        if ($numrows == $httprefmax) {
            $db->sql_query("delete from " . $prefix . "_referer");
        }
    }
    include "footer.php";
}
Esempio n. 4
0
function topicsDropDown($uniqueId, $topics = false, $selected = false)
{
    /*
    $uniqueId = A unique Id for the select.
    $topics = An array for the options.
    $selected = A variable to match an option to be selected.
    Returns an html drop down list.
    */
    global $debug, $message;
    $output = '		<select id="' . $uniqueId . '">
					';
    if (empty($topics)) {
        $topics = getTopics();
    }
    foreach ($topics as $key => $value) {
        $output .= '<option value="' . $key . '"';
        if (!empty($selected) && $value == $selected) {
            $output .= ' selected="selected"';
        }
        $output .= '>' . $value . '</option>';
    }
    $output .= '
				</select>
';
    return $output;
}
Esempio n. 5
0
echo $currPage;
?>
" method="POST">
		Title:<br>
		<input type="text" name="title" ><br>
		Description:<br>
		<input type="text" name="description">
		<br><br>
		<input type="submit" value="Submit">
		</article>
		<article id="article2"> <!-- group similar information  -- articles can have headers and footers-->
	<?php 
if (isset($_GET['showTitle'])) {
    $input = urldecode($_GET['showTitle']);
    $id = getShowId($input);
    $result = getTopics($id);
    printThreads($result);
} else {
    header('Location: error.php');
}
?>
</article>
	</section>
	
	<aside id="trendingNow" class="sideRight side_news twitter feed trendingNow general"><!-- id was side_news-->
		<!-- More informaiton -- feeds ect-->
		<h4>News Story</h4>
		<?php 
$arr = getTwitterInfo();
//print_r($arr);
$handle = $arr[0];
Esempio n. 6
0
function prepa_aff_news($op, $catid, $marqeur)
{
    global $NPDS_Prefix, $storyhome, $topicname, $topicimage, $topictext, $datetime, $cookie;
    if (isset($cookie[3])) {
        $storynum = $cookie[3];
    } else {
        $storynum = $storyhome;
    }
    if ($op == "categories") {
        sql_query("UPDATE " . $NPDS_Prefix . "stories_cat SET counter=counter+1 WHERE catid='{$catid}'");
        settype($marqeur, "integer");
        if (!isset($marqeur)) {
            $marqeur = 0;
        }
        $xtab = news_aff("libre", "WHERE catid='{$catid}' AND archive='0' ORDER BY sid DESC LIMIT {$marqeur},{$storynum}", "", "-1");
        $storynum = sizeof($xtab);
    } elseif ($op == "topics") {
        settype($marqeur, "integer");
        if (!isset($marqeur)) {
            $marqeur = 0;
        }
        $xtab = news_aff("libre", "WHERE topic='{$catid}' AND archive='0' ORDER BY sid DESC LIMIT {$marqeur},{$storynum}", "", "-1");
        $storynum = sizeof($xtab);
    } elseif ($op == "news") {
        settype($marqeur, "integer");
        if (!isset($marqeur)) {
            $marqeur = 0;
        }
        $xtab = news_aff("libre", "WHERE ihome!='1' AND archive='0' ORDER BY sid DESC LIMIT {$marqeur},{$storynum}", "", "-1");
        $storynum = sizeof($xtab);
    } elseif ($op == "article") {
        $xtab = news_aff("index", "WHERE ihome!='1' AND sid='{$catid}'", 1, "");
    } else {
        $xtab = news_aff("index", "WHERE ihome!='1' AND archive='0'", $storynum, "");
    }
    $story_limit = 0;
    while ($story_limit < $storynum and $story_limit < sizeof($xtab)) {
        list($s_sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant, $notes) = $xtab[$story_limit];
        $story_limit++;
        // trop brutal faut faire plus fin et laisser la possibilité des images !!!!
        //       if (!$imgtmp=theme_image("box/print.gif")) { $imgtmp="images/print.gif"; }
        $printP = '<a href="print.php?sid=' . $s_sid . '" class="mr-1" title="' . translate("Printer Friendly Page") . '" data-toggle="tooltip" ><i class="fa fa-lg fa-print"></i></a>&nbsp;';
        //       if (!$imgtmp=theme_image("box/friend.gif")) { $imgtmp="images/friend.gif"; }
        $sendF = '<a href="friend.php?op=FriendSend&amp;sid=' . $s_sid . '" class="mr-1" title="' . translate("Send this Story to a Friend") . '" data-toggle="tooltip" ><i class="fa fa-lg fa-envelope-o"></i></a>';
        getTopics($s_sid);
        $title = aff_langue(stripslashes($title));
        $hometext = aff_langue(stripslashes($hometext));
        $notes = aff_langue(stripslashes($notes));
        $bodycount = strlen(strip_tags(aff_langue($bodytext), "<img>"));
        if ($bodycount > 0) {
            $bodycount = strlen(strip_tags(aff_langue($bodytext)));
            if ($bodycount > 0) {
                $morelink[0] = wrh($bodycount) . ' ' . translate("bytes more");
            } else {
                $morelink[0] = ' ';
            }
            $morelink[1] = ' <a href="article.php?sid=' . $s_sid . '" >' . translate("Read More...") . '</a>';
        } else {
            $morelink[0] = '';
            $morelink[1] = '';
        }
        if ($comments == 0) {
            $morelink[2] = 0;
            $morelink[3] = '<a href="article.php?sid=' . $s_sid . '" class="mr-1"><i class="fa fa-comment-o fa-lg" title="' . translate("comments?") . '" data-toggle="tooltip"></i></a>';
        } elseif ($comments == 1) {
            $morelink[2] = $comments;
            $morelink[3] = '<a href="article.php?sid=' . $s_sid . '" class="mr-1"><i class="fa fa-comment-o fa-lg" title="' . translate("comment") . '" data-toggle="tooltip"></i></a>';
        } else {
            $morelink[2] = $comments;
            $morelink[3] = '<a href="article.php?sid=' . $s_sid . '" class="mr-1" ><i class="fa fa-comment-o fa-lg" title="' . translate("comments") . '" data-toggle="tooltip"></i></a>';
        }
        $morelink[4] = $printP;
        $morelink[5] = $sendF;
        $sid = $s_sid;
        if ($catid != 0) {
            $resultm = sql_query("SELECT title FROM " . $NPDS_Prefix . "stories_cat WHERE catid='{$catid}'");
            list($title1) = sql_fetch_row($resultm);
            $title = "<a href=\"index.php?op=newcategory&amp;catid={$catid}\" class=\"\">" . aff_langue($title1) . "</a> : {$title}";
            // Attention à cela aussi
            $morelink[6] = "<a href=\"index.php?op=newcategory&amp;catid={$catid}\" class=\"\">" . aff_langue($title1) . "</a>";
        } else {
            $morelink[6] = '';
        }
        $news_tab[$story_limit]['aid'] = serialize($aid);
        $news_tab[$story_limit]['informant'] = serialize($informant);
        $news_tab[$story_limit]['datetime'] = serialize($time);
        $news_tab[$story_limit]['title'] = serialize($title);
        $news_tab[$story_limit]['counter'] = serialize($counter);
        $news_tab[$story_limit]['topic'] = serialize($topic);
        $news_tab[$story_limit]['hometext'] = serialize(meta_lang(aff_code($hometext)));
        $news_tab[$story_limit]['notes'] = serialize(meta_lang(aff_code($notes)));
        $news_tab[$story_limit]['morelink'] = serialize($morelink);
        $news_tab[$story_limit]['topicname'] = serialize($topicname);
        $news_tab[$story_limit]['topicimage'] = serialize($topicimage);
        $news_tab[$story_limit]['topictext'] = serialize($topictext);
        $news_tab[$story_limit]['id'] = serialize($s_sid);
    }
    return $news_tab;
}
Esempio n. 7
0
    <body>
      <div id="content">
        <h1>Le jeuxvideo.com de l'amour et du hasard</h1>

<?php 
$wordCount = 0;
$acte = 1;
$pageCounter = 1;
while ($wordCount < 50000) {
    $scene = 1;
    $changeForum = mt_rand() / mt_getrandmax() < 0.5;
    $forumUrl = $changeForum ? "/forums/0-50-0-1-0-" . $pageCounter . "-0-blabla-15-18-ans.htm" : "/forums/0-51-0-1-0-" . $pageCounter . "-0-blabla-18-25-ans.htm";
    $forumUrl = $baseUrl . $forumUrl;
    echo '<h2>Acte ' . $acte . '</h2>';
    while ($wordCount < 50000 && $scene < 6) {
        $topics = getTopics($forumUrl);
        if (count($topics) > 0) {
            $topic = $topics[array_rand($topics)];
            echo '<h3>Scène ' . $scene . ' : <a href="' . $topic->url . '">' . $topic->name . '</a></h3>';
            $wordCount += str_word_count($topic->name);
            echo '<div class="scene">';
            $posts = getPosts($topic->url);
            $posts = array_map("unserialize", array_unique(array_map("serialize", $posts)));
            echo '<div class="liste-personnages">';
            $users = array_map(function ($e) {
                return $e->user;
            }, $posts);
            $users = array_values(array_filter(array_unique($users)));
            foreach ($users as $key => $user) {
                if (!empty($user)) {
                    echo trim($user);
Esempio n. 8
0
function theindex($new_topic = 0)
{
    global $db, $storyhome, $topicname, $topicimage, $topictext, $datetime, $user, $cookie, $nukeurl, $prefix, $multilingual, $currentlang, $articlecomm, $sitename, $user_news;
    if ($multilingual == 1) {
        $querylang = "AND (alanguage='{$currentlang}' OR alanguage='')";
    } else {
        $querylang = "";
    }
    include "header.php";
    automated_news();
    if (isset($cookie[3]) and $user_news == 1) {
        $storynum = $cookie[3];
    } else {
        $storynum = $storyhome;
    }
    if ($new_topic == 0) {
        $qdb = "WHERE (ihome='0' OR catid='0')";
        $home_msg = "";
    } else {
        $qdb = "WHERE topic='{$new_topic}'";
        $result_a = $db->sql_query("SELECT topictext FROM " . $prefix . "_topics WHERE topicid='{$new_topic}'");
        $row_a = $db->sql_fetchrow($result_a);
        $numrows_a = $db->sql_numrows($result_a);
        $topic_title = stripslashes(check_html($row_a['topictext'], "nohtml"));
        OpenTable();
        if ($numrows_a == 0) {
            echo "<center><font class=\"title\">{$sitename}</font><br><br>" . _NOINFO4TOPIC . "<br><br>[ <a href=\"modules.php?name=News\">" . _GOTONEWSINDEX . "</a> | <a href=\"modules.php?name=Topics\">" . _SELECTNEWTOPIC . "</a> ]</center>";
        } else {
            echo "<center><font class=\"title\">{$sitename}: {$topic_title}</font><br><br>" . "<form action=\"modules.php?name=Search\" method=\"post\">" . "<input type=\"hidden\" name=\"topic\" value=\"{$new_topic}\">" . "" . _SEARCHONTOPIC . ": <input type=\"name\" name=\"query\" size=\"30\">&nbsp;&nbsp;" . "<input type=\"submit\" value=\"" . _SEARCH . "\">" . "</form>" . "[ <a href=\"index.php\">" . _GOTOHOME . "</a> | <a href=\"modules.php?name=Topics\">" . _SELECTNEWTOPIC . "</a> ]</center>";
        }
        CloseTable();
        echo "<br>";
    }
    $result = $db->sql_query("SELECT sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes, acomm, score, ratings FROM " . $prefix . "_stories {$qdb} {$querylang} ORDER BY sid DESC limit {$storynum}");
    while ($row = $db->sql_fetchrow($result)) {
        $s_sid = intval($row['sid']);
        $catid = intval($row['catid']);
        $aid = stripslashes($row['aid']);
        $title = stripslashes(check_html($row['title'], "nohtml"));
        $time = $row['time'];
        $hometext = stripslashes($row['hometext']);
        $bodytext = stripslashes($row['bodytext']);
        $comments = stripslashes($row['comments']);
        $counter = intval($row['counter']);
        $topic = intval($row['topic']);
        $informant = stripslashes($row['informant']);
        $notes = stripslashes($row['notes']);
        $acomm = intval($row['acomm']);
        $score = intval($row['score']);
        $ratings = intval($row['ratings']);
        if ($catid > 0) {
            $row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM " . $prefix . "_stories_cat WHERE catid='{$catid}'"));
            $cattitle = stripslashes(check_html($row2['title'], "nohtml"));
        }
        getTopics($s_sid);
        formatTimestamp($time);
        $subject = stripslashes(check_html($subject, "nohtml"));
        $introcount = strlen($hometext);
        $fullcount = strlen($bodytext);
        $totalcount = $introcount + $fullcount;
        $c_count = $comments;
        $r_options = "";
        if (isset($cookie[4])) {
            $r_options .= "&amp;mode={$cookie['4']}";
        }
        if (isset($cookie[5])) {
            $r_options .= "&amp;order={$cookie['5']}";
        }
        if (isset($cookie[6])) {
            $r_options .= "&amp;thold={$cookie['6']}";
        }
        $story_link = "<a href=\"modules.php?name=News&amp;file=article&amp;sid={$s_sid}{$r_options}\">";
        $morelink = "(";
        if ($fullcount > 0 or $c_count > 0 or $articlecomm == 0 or $acomm == 1) {
            $morelink .= "{$story_link}<b>" . _READMORE . "</b></a> | ";
        } else {
            $morelink .= "";
        }
        if ($fullcount > 0) {
            $morelink .= "{$totalcount} " . _BYTESMORE . " | ";
        }
        if ($articlecomm == 1 and $acomm == 0) {
            if ($c_count == 0) {
                $morelink .= "{$story_link}" . _COMMENTSQ . "</a>";
            } elseif ($c_count == 1) {
                $morelink .= "{$story_link}{$c_count} " . _COMMENT . "</a>";
            } elseif ($c_count > 1) {
                $morelink .= "{$story_link}{$c_count} " . _COMMENTS . "</a>";
            }
        }
        $sid = intval($s_sid);
        if ($catid != 0) {
            $row3 = $db->sql_fetchrow($db->sql_query("SELECT title FROM " . $prefix . "_stories_cat WHERE catid='{$catid}'"));
            $title1 = stripslashes(check_html($row3['title'], "nohtml"));
            $title = "<a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid={$catid}\"><font class=\"storycat\">{$title1}</font></a>: {$title}";
            $morelink .= " | <a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid={$catid}\">{$title1}</a>";
        }
        if ($score != 0) {
            $rated = substr($score / $ratings, 0, 4);
        } else {
            $rated = 0;
        }
        $morelink .= " | " . _SCORE . " {$rated}";
        $morelink .= ")";
        $morelink = str_replace(" |  | ", " | ", $morelink);
        themeindex($aid, $informant, $datetime, $title, $counter, $topic, $hometext, $notes, $morelink, $topicname, $topicimage, $topictext);
    }
    include "footer.php";
}
Esempio n. 9
0
 $title = aff_langue(stripslashes($title));
 $hometext = aff_code(aff_langue(stripslashes($hometext)));
 $bodytext = aff_code(aff_langue(stripslashes($bodytext)));
 $notes = aff_code(aff_langue(stripslashes($notes)));
 if ($notes != '') {
     $notes = '<div class="note">' . translate("Note") . ' : "' . $notes . '"</div>';
 }
 if ($bodytext == '') {
     $bodytext = meta_lang($hometext . '<br />' . $notes);
 } else {
     $bodytext = meta_lang($hometext . '<br />' . $bodytext . '<br />' . $notes);
 }
 if ($informant == '') {
     $informant = $anonymous;
 }
 getTopics($sid);
 if ($catid != 0) {
     $resultx = sql_query("SELECT title FROM " . $NPDS_Prefix . "stories_cat WHERE catid='{$catid}'");
     list($title1) = sql_fetch_row($resultx);
     $title = '<a href="index.php?op=newindex&amp;catid=' . $catid . '"><span class="noir">' . aff_langue($title1) . '</span></a> : ' . $title;
 }
 $boxtitle = translate("Related Links");
 $boxstuff = '
   <ul>';
 $result = sql_query("SELECT name, url FROM " . $NPDS_Prefix . "related WHERE tid='{$topic}'");
 while (list($name, $url) = sql_fetch_row($result)) {
     $boxstuff .= '
      <li><a href="' . $url . '" target="new"><span class="noir">' . $name . '</span></a></li>';
 }
 $boxstuff .= '
   </ul>
Esempio n. 10
0
echo benchmark(function () {
    //Get a new instance of $topics each time to avoid maphper caching
    $topics = getTopics();
    $template = new \CDS\Builder(file_get_contents('template.xml'), 'topics.cds', $topics);
    $output = $template->output();
});
echo "\n\n";
echo 'Benchmarking tpl:';
echo benchmark(function () {
    //Get a new instance of $topics each time to avoid maphper caching
    $topics = getTopics();
    $data = ['topics' => $topics];
    extract($data);
    ob_start();
    require 'template.php';
    $output = ob_get_clean();
});
echo "\n\n";
echo 'Bechmkaring cached output:';
echo benchmark(function () {
    //Get a new instance of $topics each time to avoid maphper caching
    if (is_file('tmp/template.cache')) {
        $output = file_get_contents('tmp/template.cache');
    } else {
        $topics = getTopics();
        $template = new \CDS\Builder(file_get_contents('template.xml'), 'topics.cds', $topics);
        $output = $template->output();
        file_put_contents('tmp/template.cache', $output);
    }
});
echo "\n\n";
Esempio n. 11
0
require_once "../users/user.class.php";
if (!User::isLogin()) {
    die("非法访问!");
}
if (!isset($_POST['mode'])) {
    die("未找到参数1!");
}
function getTopics()
{
    $ret = array();
    $result = mysql_query("select id,name from article_topic;");
    while ($row = mysql_fetch_array($result)) {
        $ret[] = array('id' => $row['id'], 'name' => $row['name']);
    }
    return json_encode($ret);
}
$mode = $_POST['mode'];
if ($mode == 'get') {
    echo getTopics();
} else {
    if ($mode = 'add') {
        if (!isset($_POST['topic'])) {
            die("未找到参数2!");
        }
        if (empty($_POST['topic'])) {
            die("要插入的类别为空!");
        }
        $topic = htmlspecialchars($_POST['topic']);
        mysql_query('insert into article_topic(name) values("' . $topic . '");');
    }
}