function crea_XML($parola, $FileNameXml, $checked, $lingua) { $string = ''; foreach ($checked as $key => $value) { extract(array($value => $value)); } extract(array($lingua => $lingua)); //bisogna creare il file "file.xml" e dare i permessi con chmod 0777 file.xml a mano se no ci sono problemi di permessi file_put_contents($FileNameXml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); file_put_contents($FileNameXml, "<?xml-stylesheet type=\"text/xsl\" href=\"form.xsl\"?>\n", FILE_APPEND); file_put_contents($FileNameXml, "<dati parola=\"" . $parola . "\">\n", FILE_APPEND); if (isset($italiano)) { if (isset($sinonimi) || isset($contrari)) { sinonimi_contrari($parola, $FileNameXml, @check($sinonimi, $contrari)); } if (isset($rime)) { rime($parola, $FileNameXml); } if (isset($contesti)) { contesto($parola, $FileNameXml); } if (isset($dialetti)) { dialetti($parola, $FileNameXml); } if (isset($traduzioni)) { traduci($parola, "it", "en", $FileNameXml); } if (isset($modi)) { modi_di_dire($parola, $FileNameXml); } if (isset($wikipedia)) { wiki($parola, "it", $FileNameXml); } } else { if (isset($overviews)) { wordnet_overview($parola, $FileNameXml); } if (isset($synonyms)) { wordnet_synsn($parola, $FileNameXml); } if (isset($traduzioni)) { traduci($parola, "en", "it", $FileNameXml); } if (isset($wikipedia)) { wiki($parola, "en", $FileNameXml); } } file_put_contents($FileNameXml, "</dati>", FILE_APPEND); }
function importer_wordpress($xml) { /* transforms some HTML elements to Blogotext's BBCode */ function reverse_wiki($texte) { $tofind = array(array('#<blockquote>(.*)</blockquote>#s', '[quote]$1[/quote]'), array('#<code>(.*)</code>#s', '[code]$1[/code]'), array('#<a href="(.*)">(.*)</a>#', '[$2|$1]'), array('#<strong>(.*)</strong>#', '[b]$1[/b]'), array('#<em>(.*)</em>#', '[i]$1[/i]'), array('#<u>(.*)</u>#', '[u]$1[/u]')); for ($i = 0, $length = sizeof($tofind); $i < $length; $i++) { $texte = preg_replace($tofind["{$i}"][0], $tofind["{$i}"][1], $texte); } return $texte; } /* Transforms Blogotext's BBCode tags to HTML elements. */ function wiki($texte) { $texte = " " . $texte; $tofind = array(array('#\\[quote\\](.+?)\\[/quote\\]#s', '<blockquote>$1</blockquote>'), array('#\\[code\\](.+?)\\[/code\\]#s', '<code>$1</code>'), array('`\\[([^[]+)\\|([^[]+)\\]`', '<a href="$2">$1</a>'), array('`\\[b\\](.*?)\\[/b\\]`s', '<span style="font-weight: bold;">$1</span>'), array('`\\[i\\](.*?)\\[/i\\]`s', '<span style="font-style: italic;">$1</span>'), array('`\\[u\\](.*?)\\[/u\\]`s', '<span style="text-decoration: underline;">$1</span>')); for ($i = 0, $length = sizeof($tofind); $i < $length; $i++) { $texte = preg_replace($tofind["{$i}"][0], $tofind["{$i}"][1], $texte); } return $texte; } $xml = simplexml_load_string($xml); $xml = $xml->channel; $data = array('liens' => NULL, 'articles' => NULL, 'commentaires' => NULL); foreach ($xml->item as $value) { $new_article = array(); $new_article['bt_type'] = 'article'; $new_article['bt_date'] = date('YmdHis', strtotime($value->pubDate)); $new_article['bt_id'] = $new_article['bt_date']; $new_article['bt_title'] = (string) $value[0]->title; $new_article['bt_notes'] = ''; $new_article['bt_link'] = (string) $value[0]->link; $new_article['bt_wiki_content'] = reverse_wiki($value->children("content", true)->encoded); $new_article['bt_content'] = wiki($new_article['bt_wiki_content']); $new_article['bt_abstract'] = ''; // get categories $new_article['bt_categories'] = ''; foreach ($value->category as $tag) { $new_article['bt_categories'] .= (string) $tag . ','; } $new_article['bt_categories'] = trim($new_article['bt_categories'], ','); $new_article['bt_keywords'] = ''; $new_article['bt_nb_comments'] = 0; $new_article['bt_allow_comments'] = $value->children("wp", true)->comment_status == 'open' ? 1 : 0; $new_article['bt_statut'] = $value->children("wp", true)->status == 'publish' ? 1 : 0; // parse comments foreach ($value->children('wp', true)->comment as $comment) { $new_comment = array(); $new_comment['bt_author'] = (string) $comment[0]->comment_author; $new_comment['bt_link'] = ''; $new_comment['bt_webpage'] = (string) $comment[0]->comment_author_url; $new_comment['bt_email'] = (string) $comment[0]->comment_author_email; $new_comment['bt_subscribe'] = '0'; $new_comment['bt_type'] = 'comment'; $new_comment['bt_id'] = date('YmdHis', strtotime($comment->comment_date)); $new_comment['bt_article_id'] = $new_article['bt_id']; $new_comment['bt_wiki_content'] = reverse_wiki($comment->comment_content); $new_comment['bt_content'] = '<p>' . wiki($new_comment['bt_wiki_content']) . '</p>'; $new_comment['bt_statut'] = $comment->comment_approved == '1' ? '1' : '0'; $data['commentaires'][] = $new_comment; } $data['articles'][] = $new_article; } $return = array(); // importer les articles if (!empty($data['articles'])) { $return['articles'] = insert_table_articles($data['articles']); } // importer les commentaires if (!empty($data['commentaires'])) { $return['commentaires'] = insert_table_commentaires($data['commentaires']); } // recompter les commentaires if (!empty($data['commentaires']) or !empty($data['articles'])) { recompte_commentaires(); } return $return; }
<?php header("content-Type: text/html; charset=utf-8"); //url=>http://zh.wikipedia.org/wiki/title //China:zh;English:en function wiki($srsearch, $lng) { $wiki_api_url = 'http://' . $lng . '.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&srsearch=' . $srsearch; $result = file_get_contents($wiki_api_url); $xmldata = simplexml_load_string($result); $arr = array(); foreach ($xmldata->query->search->p as $value) { $value['snippet'] = str_replace(array('<span class=\'searchmatch\'>', '</span>', ' '), '', $value['snippet']); array_push($arr, array('title' => $value['title'], 'snippet' => $value['snippet'])); } return $arr; } print_r(wiki('人人', 'zh'));
<?php require_once 'config.php'; $session->requireLoggedIn(); if (empty($_GET['id']) || !is_numeric($_GET['id'])) { die; } //invalid request $itemId = $_GET['id']; require 'design_head.php'; wiki('Forum abuse reporting'); reportForumPost($itemId); echo '<a href="javascript:history.go(-1);">Return</a>'; require 'design_foot.php';
debug("User page blank, going for frontPage"); } // get Wiki Entry if ($_CONFIG['newwikis'] != true) { debug("No new Wikis allowed, checking"); #if ( array_key_exists($request[0], getWikis(true) ) ){ if (striarray($request[0], $dataSource->listOfWikis(true))) { $content = wiki($request[0], $_EXTRAS['current']); debug("...that's fine."); } else { debug("...not allowing"); $content = array("page", "Not a valid Wiki", "That (" . $request[0] . ") not a Wiki I am aware of, and current config forbids creation of arbitrary new wikis", "Aquarion (Admin)", date("r")); } } else { debug("Loading wikipage " . $_EXTRAS['current']); $content = wiki($request[0], $_EXTRAS['current']); } } else { debug("Listing wikis"); $listOfwikis = $dataSource->listOfWikis(); foreach ($listOfwikis as $row) { $out .= "# <a href=\"" . $row[0] . "\">" . $row[0] . "</a>, " . $row[1] . " pages\n"; } $content = array("page", "Index of Wikis", $out, "Aquarion (Admin)", date("r")); } if (isset($_EXTRAS['reqUser'])) { debug("Requiring auth " . $_EXTRAS['reqAuth']); doAuth($_EXTRAS['reqUser'], "enter"); } if (isset($_EXTRAS['reqAuth'])) { debug("Requiring auth " . $_EXTRAS['reqAuth']);
<?php require_once 'config.php'; $meta_rss[] = array("title" => "All RSS News feeds", "name" => "news", "category" => 0); //all news from all categories require 'design_head.php'; wiki('Home'); require 'design_foot.php';
<?php require_once 'config.php'; require_once 'functions_faq.php'; require 'design_head.php'; echo '<h1>Frequently Asked Questions</h1>'; showFAQ(); echo '<br/>'; wiki('FAQ info'); require 'design_foot.php';
<?php require_once 'config.php'; require 'design_head.php'; wiki(); require 'design_foot.php';
array_push($data, array('title' => $news[title][$i] . "\n" . '------------------------------------------', 'note' => $news[resrc][$i], 'link' => $news[url][$i])); } } elseif (preg_match('/^(梦到)(.+)/i', $content, $matches)) { $data = dream($matches[2]); } elseif (preg_match('/^(#)(.+)/i', $content, $matches)) { $data = translateAPI($matches[2]); } elseif (preg_match('/^(%)(.+)/i', $content, $matches)) { $bingweb = bing($matches[2], 'Web'); $bingimage = bing($matches[2], 'Image'); $data = array(array('title' => $matches[2], 'note' => '', 'cover' => $bingimage[0], 'link' => '')); //max:7 for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => $bingweb[$i]['title'] . "\n" . '------------------------------------------', 'note' => $bingweb[$i]['description'], 'cover' => '', 'link' => $bingweb[$i]['url'])); } } elseif (preg_match('/^(&)(.+)/i', $content, $matches)) { $wiki = wiki($matches[2]); if (is_array($wiki)) { $data = array(); for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => '# ' . $wiki[$i]['title'] . "\n" . '------------------------------------------', 'note' => $wiki[$i]['snippet'], 'cover' => '', 'link' => $wiki[$i]['link'])); } } else { $data = $wiki; } } elseif (preg_match('/^(\\*)(.+)/i', $content, $matches)) { $qrcode = 'http://chart.apis.google.com/chart?cht=qr&chs=400x400&choe=UTF-8&chl=' . $matches[2]; $data = array(array('title' => $matches[2], 'cover' => $qrcode, 'link' => $qrcode)); } elseif (preg_match('/^(vs:)(.+)/i', $content, $matches)) { $m = doubanMovies($matches[2]); $data = array(array('title' => $m[0]['title'], 'note' => $m[0]['year'] . ' ' . $m[0]['average'], 'cover' => $m[0]['images']->large, 'link' => $m[0]['alt'])); for ($i = 1; $i <= 5; $i++) {
<?php require_once 'config.php'; $session->requireLoggedIn(); require 'design_head.php'; echo xhtmlMenu($profile_menu, 'blog_menu'); wiki('Settings'); echo '<br/>'; editSettings(); require 'design_foot.php';
</ul> </div> <div id='tabpage'> <div id='contentbody'> <h1 class='titlepage'><?php wiki('page_title', '/'); ?> </h1> <!-- CONTENT BEGIN --> <?php wiki_page_content(); ?> <!-- CONTENT END --> <div class="error"><?php wiki('wiki_errors'); ?> </div> <!-- EDIT BEGIN --> <div class="edit"> <?php wiki_page_editor(); ?> <a name="___edit___" /> <script type="text/javascript"> showhide('edit'); if(/[\?\&]edit\=true($|\&|\?)/ .exec(location.search)){ showhide('edit'); } </script> </div> <!-- EDIT END -->
function matchEngine($content) { global $reg_arr, $biaoqing; foreach ($reg_arr as $key => $value) { if (preg_match($key, $content, $matches)) { switch ($value) { case 'dream': $data = dream($matches[2]); break; case 'translate': $data = translateAPI($matches[2]); break; case 'biaoqing': $data = $biaoqing[rand(0, count($biaoqing) - 1)]; break; case 'changeSimsimiKey': $s = new SaeStorage(); $s->write('simsimi', 'simi.txt', $matches[2]); $data = '更改成功!'; break; case 'md5': $data = md5($matches[2]); break; case 'qrcode': $qrcode = 'http://chart.apis.google.com/chart?cht=qr&chs=400x400&choe=UTF-8&chl=' . $matches[2]; $data = array(array('title' => $matches[2], 'cover' => $qrcode, 'link' => $qrcode)); break; case 'bingSearch': $bingweb = bing($matches[2], 'Web'); $bingimage = bing($matches[2], 'Image'); $data = array(array('title' => $matches[2], 'note' => '', 'cover' => $bingimage[0], 'link' => '')); //max:7 for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => $bingweb[$i]['title'] . "\n" . '------------------------------------------', 'note' => $bingweb[$i]['description'], 'cover' => '', 'link' => $bingweb[$i]['url'])); } break; case 'wiki': $wiki = wiki($matches[2], $lng); $data = array(); for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => $wiki[$i]['title'] . "\n" . '------------------------------------------', 'note' => $wiki[$i]['snippet'], 'cover' => '', 'link' => 'http://zh.wikipedia.org/wiki/' . $wiki[$i]['title'])); } break; case 'doubanMovie1': $m = doubanMovies($matches[2]); $data = array(array('title' => $m[0]['title'], 'note' => $m[0]['year'] . ' ' . $m[0]['average'], 'cover' => $m[0]['images']->large, 'link' => $m[0]['alt'])); for ($i = 1; $i <= 5; $i++) { array_push($data, array('title' => $m[$i]['title'], 'note' => '又名:' . $m[$i]['original_title'] . "\n" . '上映日期:' . $m[$i]['year'] . "\n" . '评价:' . $m[$i]['average'], 'cover' => $m[$i]['images']->small, 'link' => $m[$i]['alt'])); } break; case 'doubanMovie2': $m = doubanMovies($matches[2]); $movie = doubanMovie($m[0]['id']); $xinxi = '又名:'; foreach ($movie['aka'] as $value) { $xinxi .= $value . '/'; } $xinxi .= "\n" . '上映日期:' . $movie['year'] . "\n" . '制片国家:'; foreach ($movie['countries'] as $value) { $xinxi .= $value . '/'; } $xinxi .= "\n" . '类型:'; foreach ($movie['genres'] as $value) { $xinxi .= $value . '/'; } $xinxi .= "\n" . '评价:' . $movie['average']; $data = array(array('title' => $movie['title'], 'cover' => $movie['images'], 'link' => $movie['mobile_url']), array('note' => $xinxi, 'link' => $movie['mobile_url']), array('title' => '简介', 'note' => $movie['summary'], 'link' => $movie['mobile_url']), array('title' => '导演', 'note' => $movie['directors'][0]->name, 'cover' => $movie['directors'][0]->avatars->small, 'link' => $movie['directors'][0]->alt), array('title' => '主演', 'note' => $movie['casts'][0]->name, 'cover' => $movie['casts'][0]->avatars->small, 'link' => $movie['casts'][0]->alt)); break; case 'doubanBook1': $b = doubanBooks($matches[2]); $data = array(array('title' => $b[0]['title'], 'note' => $b[0]['author'][0] . ' ' . $b[0]['average'], 'cover' => $b[0]['images']->large, 'link' => $b[0]['alt'])); for ($i = 1; $i <= 4; $i++) { array_push($data, array('title' => $b[$i]['title'], 'note' => '作者:' . $b[$i]['author'][0] . "\n" . '出版社:' . $b[$i]['publisher'] . "\n" . '出版日期:' . $b[$i]['pubdate'] . "\n" . '价格:' . $b[$i]['price'] . "\n" . '评价:' . $b[$i]['average'] . "\n" . '导言:' . $b[$i]['summary'], 'cover' => $b[$i]['images']->small, 'link' => $b[$i]['alt'])); } break; case 'doubanBook2': $b = doubanBooks($matches[2]); $bk = doubanBook($b[0]['id']); $data = array(array('title' => $bk['title'], 'cover' => $bk['images'], 'link' => $bk['alt']), array('note' => '作者:' . $bk['author'][0] . "\n" . '出版社:' . $bk['publisher'] . "\n" . '出版日期:' . $bk['pubdate'] . "\n" . '价格:' . $bk['price'] . "\n" . '评价:' . $bk['average'], 'link' => $bk['alt']), array('title' => '导言:', 'note' => $bk['summary'], 'link' => $bk['alt'])); break; case 'doubanMusic1': $m = doubanMusics($matches[2]); $data = array(array('title' => $m[0]['title'], 'note' => $m[0]['average'], 'cover' => $m[0]['image'], 'link' => $m[0]['alt'])); for ($i = 1; $i <= 4; $i++) { array_push($data, array('title' => $m[$i]['title'], 'note' => '作者:' . $m[$i]['author'][0]->name . "\n" . '出版社:' . $m[$i]['publisher'][0] . "\n" . '出版日期:' . $m[$i]['pubdate'][0] . "\n" . '表演者:' . $m[$i]['singer'][0] . "\n" . '评价:' . $m[$i]['average'] . "\n" . '类型:' . $m[$i]['version'][0], 'cover' => $m[$i]['image'], 'link' => $m[$i]['alt'])); } break; case 'doubanMusic2': $m = doubanMusics($matches[2]); $mu = doubanMusic($m[0]['id']); $data = array(array('title' => $mu['title'], 'cover' => $mu['image'], 'link' => $mu['mobile_link']), array('note' => '表演者:' . $mu['singer'][0] . "\n" . '专辑类型:' . $mu['version'][0] . "\n" . '发行时间:' . $mu['pubdate'][0] . "\n" . '作者:' . $mu['author'][0]->name . "\n" . '出版者:' . $mu['publisher'][0] . "\n" . '评价:' . $mu['average'], 'link' => $mu['mobile_link']), array('title' => '简介:', 'note' => $mu['summary'], 'link' => $mu['mobile_link'])); break; case 'moments1': $moment = $matches[2]; $time = time(); $date = date("Y-m-d H:i:s", time()); $mysql = new SaeMysql(); $res = $mysql->getData("SELECT alias FROM info WHERE FromUserName='******'"); $alias = $res[0]['alias']; if (!$alias) { $data = '由于你是第一次发送动态,请按照以下格式回复基本信息:' . "\n" . '昵称:+你的昵称'; } else { $mysql->runSql("INSERT INTO moments(FromUserName,alias,moment,time,date) VALUES ('{$openid}','{$alias}','{$moment}',{$time},'{$date}')"); $data = "发送成功,你可以现在上传一张图片作为配图,当然也可以不上传啦。回复[动态]查看"; } break; case 'moments2': $alias = $matches[2]; $mysql = new SaeMysql(); $res = $mysql->getData("SELECT * FROM info"); $num = 0; while ($res[$num]) { if ($alias == $res[$num]['alias'] || $alias == '小u' || $alias == 'urinx') { $t = 1; } elseif ($openid == $res[$num]['FromUserName']) { $u = 1; } $num++; } if ($t) { $data = '该用户名已被注册,请重新输入'; } else { if ($u) { $mysql->runSql("UPDATE info SET alias='{$alias}' WHERE FromUserName='******'"); $data = '更改成功!'; } else { $mysql->runSql("INSERT INTO info(FromUserName,alias) VALUES ('{$openid}','{$alias}')"); $data = '注册成功!'; } } break; default: # code... break; } } } return $data; }
<?php require_once 'config.php'; require 'design_head.php'; wiki('Feedback'); echo '<br/>'; if (!empty($_POST['feedback_q'])) { saveFeedback(FEEDBACK_SUBMIT, $_POST['feedback_q']); echo 'Thank you - your question will be answered as soon as possible.<br/><br/>'; } else { echo '<form method="post" action="">'; echo '<textarea name="feedback_q" rows="8" cols="40"></textarea><br/>'; echo '<input type="submit" class="button" value="Submit question"/>'; echo '</form>'; } require 'design_foot.php';
<!-- PAGE CONTENT ITSELF ------------------------------------------------------------- --> <?php wiki_page_content(); ?> <?php $hide_errors = '<a onclick="showhide(\'errors\');" href="#" style="float:right;color:red">[X]</a>'; wiki('wiki_errors', '<div class="errors" id="errors">' . $hide_errors, '</div>'); ?> <!-- EDITOR -------------------------------------------------------------------------- --> <div class="edit" id="edit"> <?php wiki('editor'); ?> <a name="___edit___" /> <script type="text/javascript"> showhide('edit'); if(/[\?\&]edit\=true($|\&|\?)/ .exec(location.search)){ showhide('edit'); } </script> </div> </div> <div class="info"><small><?php wiki('info'); ?> </small></div> </div> </body> </html>
array_push($data, array('title' => $news[title][$i] . "\n" . '------------------------------------------', 'note' => $news[resrc][$i], 'link' => $news[url][$i])); } } elseif (preg_match('/^(梦到)(.+)/i', $content, $matches)) { $data = dream($matches[2]); } elseif (preg_match('/^(#)(.+)/i', $content, $matches)) { $data = translateAPI($matches[2]); } elseif (preg_match('/^(%)(.+)/i', $content, $matches)) { $bingweb = bing($matches[2], 'Web'); $bingimage = bing($matches[2], 'Image'); $data = array(array('title' => $matches[2], 'note' => '', 'cover' => $bingimage[0], 'link' => '')); //max:7 for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => $bingweb[$i]['title'] . "\n" . '------------------------------------------', 'note' => $bingweb[$i]['description'], 'cover' => '', 'link' => $bingweb[$i]['url'])); } } elseif (preg_match('/^(&)(.+)/i', $content, $matches)) { $wiki = wiki($matches[2], $lng); $data = array(); for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => $wiki[$i]['title'] . "\n" . '------------------------------------------', 'note' => $wiki[$i]['snippet'], 'cover' => '', 'link' => 'http://zh.wikipedia.org/wiki/' . $wiki[$i]['title'])); } } elseif (preg_match('/^(\\*)(.+)/i', $content, $matches)) { $qrcode = 'http://chart.apis.google.com/chart?cht=qr&chs=400x400&choe=UTF-8&chl=' . $matches[2]; $data = array(array('title' => $matches[2], 'cover' => $qrcode, 'link' => $qrcode)); } elseif (preg_match('/^(vs:)(.+)/i', $content, $matches)) { $m = doubanMovies($matches[2]); $data = array(array('title' => $m[0]['title'], 'note' => $m[0]['year'] . ' ' . $m[0]['average'], 'cover' => $m[0]['images']->large, 'link' => $m[0]['alt'])); for ($i = 1; $i <= 5; $i++) { array_push($data, array('title' => $m[$i]['title'], 'note' => '又名:' . $m[$i]['original_title'] . "\n" . '上映日期:' . $m[$i]['year'] . "\n" . '评价:' . $m[$i]['average'], 'cover' => $m[$i]['images']->small, 'link' => $m[$i]['alt'])); } } elseif (preg_match('/^(v:)(.+)/i', $content, $matches)) { $m = doubanMovies($matches[2]);
<?php require_once 'config.php'; require 'design_head.php'; wiki('Index'); require 'design_foot.php';