Add some search option in the last paste list

This commit is contained in:
Némunaire 2012-11-05 19:45:20 +01:00
parent 7c15c88657
commit ca8b5a0c3e
6 changed files with 32 additions and 11 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
gen/*
files/*

View File

@ -23,12 +23,15 @@ function generate_latex($filein, $content)
\usepackage{hyperref} \usepackage{hyperref}
\usepackage{listings} \usepackage{listings}
\usepackage{color} \usepackage{color}
\usepackage{array}
\usepackage{tikz}
\definecolor{dkgreen}{rgb}{0,0.6,0} \definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5} \definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82} \definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{language=C++,keywordstyle=\color{blue},stringstyle=\color{mauve}} \lstset{language=C++,keywordstyle=\color{blue},stringstyle=\color{mauve}}
\usetikzlibrary{arrows}
\begin{document}".$content."\end{document}"; \begin{document}".$content."\end{document}";
@ -103,7 +106,7 @@ foreach ($_GET as $k => $t)
print "Je ne sais pas compiler ce code source :("; print "Je ne sais pas compiler ce code source :(";
$log = ob_get_clean(); $log = ob_get_clean();
ob_end_clean(); ob_end_clean();
if (isset($f) && is_file($f)) if (isset($f) && is_file($f))
{ {
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');

View File

@ -1,4 +1,6 @@
<!doctype html> <?php
header("Content-type: text/html; charset=UTF-8");
?><!doctype html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">

View File

@ -2,6 +2,14 @@
require_once("../common.php"); require_once("../common.php");
$srch_title = $srch_author = $srch_lang = "";
if (!empty($_GET["title"]))
$srch_title = $_GET["title"];
if (!empty($_GET["author"]))
$srch_author = $_GET["author"];
if (!empty($_GET["lang"]))
$srch_lang = $_GET["lang"];
if ($dh = opendir(DESTINATION)) if ($dh = opendir(DESTINATION))
{ {
$list = array(); $list = array();
@ -26,16 +34,23 @@ if ($dh = opendir(DESTINATION))
continue; continue;
} }
if ($i > 10) if ($i > 23)
{ {
print '<li><a href="./?s='.(intval($_GET["s"])+10).'#list">Plus anciens ...</a></li>'; $GT = $GA = $GL = "";
if (!empty($srch_title)) $GR = "&amp;title=".$srch;
if (!empty($srch_author)) $GR = "&amp;author=".$srch;
if (!empty($srch_lang)) $GR = "&amp;lang=".$srch;
print '<li><a href="./?s='.(intval($_GET["s"])+23).$GR.'#list">Plus anciens ...</a></li>';
break; break;
} }
if (preg_match("#^([a-zA-Z0-9]{".RGXP_NB."}).xml$#", $f[1], $fout)) if (preg_match("#^([a-zA-Z0-9]{".RGXP_NB."}).xml$#", $f[1], $fout))
{ {
$paste = new Paste($fout[1]); $paste = new Paste($fout[1]);
if ($paste->is_private ()) if ($paste->is_private ()
|| !preg_match("#".$srch_title."#i", $paste->title)
|| !preg_match("#".$srch_author."#i", $paste->author)
|| !preg_match("#".$srch_lang."#i", $paste->language))
continue; continue;
if (empty($paste->title)) if (empty($paste->title))

View File

@ -58,7 +58,8 @@ foreach ($_GET as $k => $t)
$paste->crypt($t); $paste->crypt($t);
} }
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/plain; charset=UTF-8");
header("Content-Disposition: inline; filename=\"".addslashes($paste->title)."\"");
echo ($paste->content); echo ($paste->content);
} }
} }

View File

@ -65,13 +65,11 @@ class Paste
$doc = new DOMDocument(); $doc = new DOMDocument();
$doc->load($this->filename); $doc->load($this->filename);
$this->title = utf8_decode( $this->title = $doc->getElementsByTagName("title")->item(0)->textContent;
$doc->getElementsByTagName("title")->item(0)->textContent);
$this->language = strtolower( $this->language = strtolower(
$doc->getElementsByTagName("language")->item(0)->textContent); $doc->getElementsByTagName("language")->item(0)->textContent);
$this->date = $doc->getElementsByTagName("date")->item(0)->textContent; $this->date = $doc->getElementsByTagName("date")->item(0)->textContent;
$this->author = utf8_decode( $this->author = $doc->getElementsByTagName("author")->item(0)->textContent;
$doc->getElementsByTagName("author")->item(0)->textContent);
$this->content = $doc->getElementsByTagName("content")->item(0)->textContent; $this->content = $doc->getElementsByTagName("content")->item(0)->textContent;
if ($doc->getElementsByTagName("ref")->length > 0) if ($doc->getElementsByTagName("ref")->length > 0)
$this->ref = $doc->getElementsByTagName("ref")->item(0)->textContent; $this->ref = $doc->getElementsByTagName("ref")->item(0)->textContent;
@ -119,7 +117,7 @@ class Paste
return ($hash == $doc->getElementsByTagName("hash")->item(0)->textContent); return ($hash == $doc->getElementsByTagName("hash")->item(0)->textContent);
} }
else else
return FALSE; return FALSE;
} }
/** /**