if ($key != $theme && $value >= $results[$theme]) { $flag = true; for ($i = 0; $i < count($vector); $i++) { $w[$key][$i] -= $vector[$i]; } } if ($flag) { for ($i = 0; $i < count($vector); $i++) { $w[$theme][$i] += $vector[$i]; } } } } } $text = $_REQUEST['text']; $keys = getKeywords($text); $vector = array(); for ($i = 0; $i < count($keywords); $i++) { if (array_search($keywords[$i], $keys) !== FALSE) { $vector[$i] = 1; } else { $vector[$i] = 0; } } $results = array(); foreach ($w as $key => $value) { $results[$key] = 0; for ($i = 0; $i < count($vector); $i++) { $results[$key] += $value[$i] * $vector[$i]; } }
fclose($fh); echo 'cache size: ' . filesize($filePath) / 1024 . " kB<br />"; } ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> <?php if (!file_exists($filePath) || isset($_GET['force'])) { $ac = new AhoCorasick(); $ac->setCombineResults(false); memUsage($memoryWhole, "Memory (AC instantiated):"); $keywords = getKeywords(); memUsage($memoryWhole, "Memory (keywords loaded):"); $tree = $ac->buildTree($keywords); memUsage($memoryWhole, "Memory (tree built):"); unset($keywords); memUsage($memoryWhole, "Memory (keywords unset):"); saveToCache($ac, $filePath); memUsage($memoryWhole, "Memory (result cached):"); } else { $ac = unserialize(file_get_contents($filePath)); } $res = $ac->FindAll($inputText); memUsage($memoryWhole, "Memory (after find all):"); memUsage($memoryWhole, "Memory whole:"); unset($ac); echo "<b>Results: </b><pre>";
function updateArticle($mysqli, $articleId) { if (isset($_POST['send'])) { if (!empty($_POST['title']) && $_POST['category'] != "bitte auswählen" && !empty($_POST['article'])) { /* keywords */ $keywords = getKeywords($_POST['title'] . " " . $_POST['article']); $title = trim(htmlentities($_POST['title'], ENT_QUOTES, "UTF-8")); $title = $mysqli->real_escape_string($title); $category = trim(htmlentities($_POST['category'], ENT_QUOTES, "UTF-8")); $category = $mysqli->real_escape_string($category); $article = trim(htmlentities($_POST['article'], ENT_QUOTES, "UTF-8")); $article = $mysqli->real_escape_string($article); /* Bild Upload */ if (!empty($_FILES['image']['tmp_name'])) { $dateityp = GetImageSize($_FILES['image']['tmp_name']); if ($dateityp[2] != 0) { /* 300kB */ if ($_FILES['image']['size'] < 307200) { /* existiert Dateiname */ $fileName = str_replace(" ", "-", $_FILES['image']['name']); if (!file_exists("upload/" . $fileName)) { move_uploaded_file($_FILES['image']['tmp_name'], "upload/" . $fileName); $img = "upload/" . $fileName; } else { $fileType = strrchr($fileName, "."); while (file_exists($fileName)) { $endName = ""; for ($i = 0; $i < 20; $i++) { switch (rand(0, 2)) { case 0: //Großbuchstabe anfügen $endName = $endName . chr(rand(65, 90)); break; case 1: //Kleinbuchstabe $endName = $endName . chr(rand(97, 122)); break; case 2: //Ziffer $endName = $endName . rand(0, 9); break; } } $fileName = PROJECT_HTTP_ROOT . "/sites/Article/upload/" . $endName . $fileType; } move_uploaded_file($_FILES['image']['tmp_name'], $fileName); $img = $fileName; } } else { return 2; } } else { return 3; } } else { $img = ""; } $date = time(); /* wenn an image nichts geäendert wird */ if ($img == "") { $write = $mysqli->query("UPDATE articles SET title = '{$title}', category = '{$category}', article = '{$article}', keywords = '{$keywords}', modified = '{$modified}' WHERE id = '{$articleId}' "); } else { $write = $mysqli->query("UPDATE articles SET title = '{$title}', category = '{$category}', article = '{$article}', img = '{$img}', keywords = '{$keywords}', modified = '{$modified}' WHERE id = '{$articleId}' "); } header("Location: showArticle.php?article=" . $articleId); exit; } else { return 1; } } }
<html> <head> <meta name="Generator" content="CmsEasy 5_5_0_20140118_UTF8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta content="telephone=no" name="format-detection"> <meta http-equiv="x-rim-auto-match" content="none"> <title><?php echo getTitle($archive, $category, $catid, $type); ?> - Powered by CmsEasy</title> <meta name="keywords" content="<?php echo getKeywords($archive, $category, $catid, $type); ?> " /> <meta name="description" content="<?php echo getDescription($archive, $category, $catid, $type); ?> " /> <meta name="author" content="CmsEasy Team" /> <link href="<?php echo $skin_path; ?> /wap.css" rel="stylesheet" /> </head> <body> <div id="header">
die(header('Location: ' . $ref)); } $firstpost = FetchResult("SELECT pt.text FROM {posts} p LEFT JOIN {posts_text} pt ON pt.pid=p.id AND pt.revision=p.currentrevision WHERE p.thread={0} AND p.deleted=0 ORDER BY p.date ASC LIMIT 1", $tid); if ($firstpost && $firstpost != -1) { $firstpost = strip_tags($firstpost); $firstpost = preg_replace('@\\[.*?\\]@s', '', $firstpost); $firstpost = preg_replace('@\\s+@', ' ', $firstpost); $firstpost = explode(' ', $firstpost); if (count($firstpost) > 30) { $firstpost = array_slice($firstpost, 0, 30); $firstpost[29] .= '...'; } $firstpost = implode(' ', $firstpost); $metaStuff['description'] = htmlspecialchars($firstpost); } $metaStuff['tags'] = getKeywords(strip_tags($thread['title'])); Query("update {threads} set views=views+1 where id={0} limit 1", $tid); $isold = !$thread['sticky'] && Settings::get("oldThreadThreshold") > 0 && $thread['lastpostdate'] < time() - 2592000 * Settings::get("oldThreadThreshold"); $links = array(); if ($loguserid) { $notclosed = !$thread['closed'] || HasPermission('mod.closethreads', $fid); if (HasPermission('forum.postreplies', $fid)) { // allow the user to directly post in a closed thread if they have permission to open it if ($notclosed) { $links[] = actionLinkTag(__("Post reply"), "newreply", $tid, '', $urlname); } else { if ($thread['closed']) { $links[] = __("Thread closed"); } } }
require "enum.php"; $db = new mysql_db(SERVER, USERNAME, PASSWORD, DATABASE); // $_POST["keywords"] should be the search keyword $key = ""; if (!isset($_POST["keywords"])) { $words = $_POST["key"]; $key = $words; $type = $_POST["type"]; $category = $_POST["category"]; $time = $_POST["date"]; if ($time == 1) { $start = (new \DateTime())->modify('-24 hours'); $starttime = $start->format('Y-m-d H:i:s'); } else { if ($time == 2) { $start = (new \DateTime())->modify('-30 days'); $starttime = $start->format('Y-m-d H:i:s'); } else { $starttime = ""; } } $result = filterSearch($words, $type, $category, $starttime); } else { $key = $_POST["keywords"]; $result = search($_POST["keywords"]); } render("search_template.php", ["title" => "Search Result", "result" => $result, "key" => $key, "keywords" => getKeywords()]); $db->sql_close(); ?>
$links = array(); if ($loguserid) { $links[] = actionLinkTag(__("Mark forum read"), "forum", $fid, "action=markasread", $urlname); } if ($loguserid) { if ($isIgnored) { $links[] = actionLinkTag(__("Unignore forum"), "forum", $fid, "unignore", $urlname); } else { $links[] = actionLinkTag(__("Ignore forum"), "forum", $fid, "ignore", $urlname); } if (HasPermission('forum.postthreads', $fid)) { $links[] = actionLinkTag(__("Post thread"), "newthread", $fid, '', $urlname); } } $metaStuff['description'] = htmlspecialchars(strip_tags($forum['description'])); $metaStuff['tags'] = getKeywords(strip_tags($forum['title'])); $OnlineUsersFid = $fid; MakeCrumbs(forumCrumbs($forum), $links); makeAnncBar(); makeForumListing($fid); $total = $forum['numthreads']; $tpp = $loguser['threadsperpage']; if (isset($_GET['from'])) { $from = (int) $_GET['from']; } else { $from = 0; } if (!$tpp) { $tpp = 50; } $rThreads = Query("\tSELECT\n\t\t\t\t\t\tt.*,\n\t\t\t\t\t\t" . ($loguserid ? "tr.date readdate," : '') . "\n\t\t\t\t\t\tsu.(_userfields),\n\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{threads} t\n\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={3}" : '') . "\n\t\t\t\t\t\tLEFT JOIN {users} su ON su.id=t.user\n\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=t.lastposter\n\t\t\t\t\tWHERE forum={0}\n\t\t\t\t\tORDER BY sticky DESC, lastpostdate DESC LIMIT {1u}, {2u}", $fid, $from, $tpp, $loguserid);
$sids = 'lang=' . $LANGCODE . '&'; } else { $sids = ''; } } // found a article language? if (isset($_POST["artlang"]) && PMF_Init::isASupportedLanguage($_POST["artlang"])) { $lang = $_POST["artlang"]; } else { $lang = $LANGCODE; } // found a record ID? if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) === true) { $id = $_REQUEST['id']; $title = ' - ' . stripslashes(getThema($id, $lang)); $keywords = ' ' . stripslashes(getKeywords($id, $lang)); } else { $id = ''; //$title = ' - powered by phpMyFAQ '.$PMF_CONF['version']; $keywords = ''; } // found a solution ID? if (isset($_REQUEST['solution_id']) && is_numeric($_REQUEST['solution_id']) === true) { $solution_id = $_REQUEST['solution_id']; //$title = ' - powered by phpMyFAQ '.$PMF_CONF['version']; $keywords = ''; $a = getIdFromSolutionId($solution_id); if (is_array($a)) { $id = $a['id']; $lang = $a['lang']; }
function analyze($group, $category) { global $gDBHelper; global $gSession; /* * Setting keyword list. */ $this->setKeywordList(getKeywords($group)); if (count($this->keywordList) == 0) { $this->result->setResult(false, "No keywords present in particular group"); return; } /* * Setting domain list. */ $serpInfo = array(); $serpInfo['categoryName'] = $category; $serpInfo['userId'] = $gSession->userInfo['userId']; $res = $gDBHelper->selectInfo($serpInfo, 'domain_interests'); $domains = ""; if ($res[0]['domains']) { $domains = $res[0]['domains']; } if ($domains == '') { $this->result->setResult(false, "The Domain List is empty"); return; } $this->result->setDomains(explode("\n", $domains)); /* * getting the search info for particular group for the user. */ $serpInfo = array(); $serpInfo['groupName'] = $group; $serpInfo['userId'] = $gSession->userInfo['userId']; $res = $gDBHelper->selectInfo($serpInfo, 'search_info'); for ($idx = 0; $idx < count($res); $idx++) { $this->processForTimestamp($res[$idx]['timestamp'], $res[$idx]['engineId']); } $this->result->setResult(true, "Success"); }
function getKeywords($id = 0) { $this->loadExtension('DeprecatedAPI'); return getKeywords($id); }