Add a new tag to hide a paste on the main page
This commit is contained in:
parent
47372cf211
commit
a6a87b6f8a
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// The directory where code will be stored
|
// The directory where code will be stored
|
||||||
define("DESTINATION", "../files/");
|
define("DESTINATION", __dir__."/files/");
|
||||||
if (!is_writable(DESTINATION))
|
if (!is_writable(DESTINATION))
|
||||||
die ("Destination folder not writable");
|
die ("Destination folder not writable");
|
||||||
|
|
||||||
// Path to the GeSHi languages
|
// Path to the GeSHi languages
|
||||||
define("GESHI_DIR", "../geshi/geshi/");
|
define("GESHI_DIR", __dir__."/geshi/geshi/");
|
||||||
|
|
||||||
|
|
||||||
// The size of the generated identifier
|
// The size of the generated identifier
|
||||||
|
@ -9,7 +9,7 @@ function generate_latex($filein, $content)
|
|||||||
if (is_file($fileout))
|
if (is_file($fileout))
|
||||||
return $fileout;
|
return $fileout;
|
||||||
|
|
||||||
if (!preg_match("#\\begin{document}#ui", $content))
|
if (!preg_match("#begin{document}#ui", $content))
|
||||||
$content = "\documentclass[10pt]{report}
|
$content = "\documentclass[10pt]{report}
|
||||||
|
|
||||||
\usepackage[utf8x]{inputenc}
|
\usepackage[utf8x]{inputenc}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon"/>
|
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a href="http://github.com/nemunaire/Paste-Manager"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/4c7dc970b89fd04b81c8e221ba88ff99a06c6b61/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub"></a>
|
<a href="http://github.com/nemunaire/Paste-Manager"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/c641758e06304bc53ae7f633269018169e7e5851/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f77686974655f6666666666662e706e67" alt="Fork me on GitHub"></a>
|
||||||
<?php
|
<?php
|
||||||
require_once("../common.php");
|
require_once("../common.php");
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ foreach ($_GET as $k => $t)
|
|||||||
<h2><?php echo $paste->get_subtitle(); ?></h2>
|
<h2><?php echo $paste->get_subtitle(); ?></h2>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div class="answer">
|
<div class="answer">
|
||||||
<a href="/?a=<?php echo $kout[1]; ?>">Répondre</a>
|
<a href="/?a=<?php echo $kout[1]; if (!empty($_POST["passwd"])) echo ":".$_POST["passwd"]; ?>">Répondre</a>
|
||||||
<?php echo $paste->get_ref(isset($diff)); ?>
|
<?php echo $paste->get_ref(isset($diff)); ?>
|
||||||
<?php echo $paste->get_gen(isset($diff)); ?>
|
<?php echo $paste->get_gen(isset($diff)); ?>
|
||||||
</div>
|
</div>
|
||||||
@ -79,7 +79,7 @@ if (!empty($view))
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
//Load answer paste
|
//Load answer paste
|
||||||
if (!empty($_GET["a"]) && preg_match("#^[a-zA-Z0-9]{".RGXP_NB."}$#", $_GET["a"])
|
if (!empty($_GET["a"]) && preg_match("#^([a-zA-Z0-9]{".RGXP_NB."})(:([a-zA-Z0-9]{".RGXP_NB."}))?$#", $_GET["a"], $kout)
|
||||||
&& is_file(Paste::get_path($k = $_GET["a"])))
|
&& is_file(Paste::get_path($k = $_GET["a"])))
|
||||||
$paste = new Paste($k);
|
$paste = new Paste($k);
|
||||||
else
|
else
|
||||||
|
@ -26,7 +26,7 @@ if ($dh = opendir(DESTINATION))
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i++ > 10)
|
if ($i > 10)
|
||||||
{
|
{
|
||||||
print '<li><a href="./?s='.(intval($_GET["s"])+10).'#list">Plus anciens ...</a></li>';
|
print '<li><a href="./?s='.(intval($_GET["s"])+10).'#list">Plus anciens ...</a></li>';
|
||||||
break;
|
break;
|
||||||
@ -35,6 +35,8 @@ if ($dh = opendir(DESTINATION))
|
|||||||
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 ())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (empty($paste->title))
|
if (empty($paste->title))
|
||||||
$title = "Sans titre";
|
$title = "Sans titre";
|
||||||
@ -47,7 +49,7 @@ if ($dh = opendir(DESTINATION))
|
|||||||
$author = htmlentities($paste->author);
|
$author = htmlentities($paste->author);
|
||||||
|
|
||||||
print '<li><a href="./?'.$paste->fileref.'">'.$title."</a> par ".$author.", le ".date("d/m/Y H:i:s", $paste->date)."</li>";
|
print '<li><a href="./?'.$paste->fileref.'">'.$title."</a> par ".$author.", le ".date("d/m/Y H:i:s", $paste->date)."</li>";
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -12,6 +12,7 @@ class Paste
|
|||||||
var $date;
|
var $date;
|
||||||
var $content;
|
var $content;
|
||||||
var $ip;
|
var $ip;
|
||||||
|
var $private = false;
|
||||||
var $ref = NULL;
|
var $ref = NULL;
|
||||||
var $hash;
|
var $hash;
|
||||||
var $crypt = NULL;
|
var $crypt = NULL;
|
||||||
@ -82,6 +83,9 @@ class Paste
|
|||||||
else
|
else
|
||||||
$this->hash = NULL;
|
$this->hash = NULL;
|
||||||
|
|
||||||
|
if ($doc->getElementsByTagName("private")->length > 0)
|
||||||
|
$this->private = true;
|
||||||
|
|
||||||
if ($doc->getElementsByTagName("crypt")->length > 0)
|
if ($doc->getElementsByTagName("crypt")->length > 0)
|
||||||
$this->crypt = base64_decode($doc->getElementsByTagName("crypt")->item(0)->textContent);
|
$this->crypt = base64_decode($doc->getElementsByTagName("crypt")->item(0)->textContent);
|
||||||
else
|
else
|
||||||
@ -186,6 +190,10 @@ class Paste
|
|||||||
$xml_paste->appendChild(
|
$xml_paste->appendChild(
|
||||||
$xml->createElement("hash", $this->hash));
|
$xml->createElement("hash", $this->hash));
|
||||||
|
|
||||||
|
if ($this->is_private ())
|
||||||
|
$xml_paste->appendChild(
|
||||||
|
$xml->createElement("private"));
|
||||||
|
|
||||||
$xml->appendChild($xml_paste);
|
$xml->appendChild($xml_paste);
|
||||||
|
|
||||||
if ($xml->save(Paste::get_path($this->filename)))
|
if ($xml->save(Paste::get_path($this->filename)))
|
||||||
@ -316,6 +324,11 @@ class Paste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_private()
|
||||||
|
{
|
||||||
|
return $this->private;
|
||||||
|
}
|
||||||
|
|
||||||
function export_to_file($fileto)
|
function export_to_file($fileto)
|
||||||
{
|
{
|
||||||
file_put_contents($fileto, $this->content);
|
file_put_contents($fileto, $this->content);
|
||||||
|
Reference in New Issue
Block a user