Add a list of answers for each answered message
This commit is contained in:
parent
4649253774
commit
aad5915892
@ -11,6 +11,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once("../common.php");
|
require_once("../common.php");
|
||||||
|
|
||||||
|
$view = 0;
|
||||||
foreach ($_GET as $k => $t)
|
foreach ($_GET as $k => $t)
|
||||||
{
|
{
|
||||||
if (preg_match("#^([a-zA-Z0-9]{".RGXP_NB."})(:([a-zA-Z0-9]{".RGXP_NB."}))?$#", $k, $kout)
|
if (preg_match("#^([a-zA-Z0-9]{".RGXP_NB."})(:([a-zA-Z0-9]{".RGXP_NB."}))?$#", $k, $kout)
|
||||||
@ -36,13 +37,14 @@ foreach ($_GET as $k => $t)
|
|||||||
echo $paste->get_diff($diff);
|
echo $paste->get_diff($diff);
|
||||||
else
|
else
|
||||||
echo $paste->get_code();
|
echo $paste->get_code();
|
||||||
|
echo $paste->show_answers();
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
$view = true;
|
$view++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<h1>Dernières publications</h1>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("../common.php");
|
require_once("../common.php");
|
||||||
@ -12,6 +11,7 @@ if ($dh = opendir(DESTINATION))
|
|||||||
|
|
||||||
array_multisort($list, SORT_DESC);
|
array_multisort($list, SORT_DESC);
|
||||||
?>
|
?>
|
||||||
|
<h1>Dernières publications</h1>
|
||||||
<ul id="list">
|
<ul id="list">
|
||||||
<?php
|
<?php
|
||||||
if (empty($_GET["s"]))
|
if (empty($_GET["s"]))
|
||||||
|
@ -34,6 +34,15 @@ p,ul
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#res {
|
||||||
|
font-size: 80%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
#res ul, #res ul li {
|
||||||
|
display: inline;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
color: #e9802c;
|
color: #e9802c;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -14,6 +14,7 @@ class Paste
|
|||||||
var $ip;
|
var $ip;
|
||||||
var $ref = NULL;
|
var $ref = NULL;
|
||||||
var $hash;
|
var $hash;
|
||||||
|
var $answers = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new paste or open a existing file
|
* Create a new paste or open a existing file
|
||||||
@ -57,6 +58,9 @@ class Paste
|
|||||||
else
|
else
|
||||||
$this->hash = NULL;
|
$this->hash = NULL;
|
||||||
|
|
||||||
|
for ($i = 0; $i < $doc->getElementsByTagName("answer")->length; $i++)
|
||||||
|
$this->answers[] = $doc->getElementsByTagName("answer")->item($i)->textContent;
|
||||||
|
|
||||||
//Check the lang exists
|
//Check the lang exists
|
||||||
if (empty($this->language) || !is_file(GESHI_DIR.$this->language.".php"))
|
if (empty($this->language) || !is_file(GESHI_DIR.$this->language.".php"))
|
||||||
$this->language = "text";
|
$this->language = "text";
|
||||||
@ -90,9 +94,7 @@ class Paste
|
|||||||
*/
|
*/
|
||||||
function save($filename=NULL)
|
function save($filename=NULL)
|
||||||
{
|
{
|
||||||
$this->date = time();
|
|
||||||
$this->hash = base64_encode(sha1($this->content, true));
|
$this->hash = base64_encode(sha1($this->content, true));
|
||||||
$this->ip = $_SERVER["REMOTE_ADDR"];
|
|
||||||
|
|
||||||
if (empty($filename))
|
if (empty($filename))
|
||||||
{
|
{
|
||||||
@ -129,9 +131,25 @@ class Paste
|
|||||||
$xml->createElement("content", $this->content));
|
$xml->createElement("content", $this->content));
|
||||||
|
|
||||||
if (!empty($this->ref))
|
if (!empty($this->ref))
|
||||||
|
{
|
||||||
|
//Also indicate in the parent file
|
||||||
|
$parent = new Paste($this->ref);
|
||||||
|
|
||||||
|
//Does the parent exist?
|
||||||
|
if ($parent->load())
|
||||||
|
{
|
||||||
$xml_paste->appendChild(
|
$xml_paste->appendChild(
|
||||||
$xml->createElement("ref", $this->ref));
|
$xml->createElement("ref", $this->ref));
|
||||||
|
|
||||||
|
if ($parent->add_answer($this->filename))
|
||||||
|
$parent->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->answers as $a)
|
||||||
|
$xml_paste->appendChild(
|
||||||
|
$xml->createElement("answer", $a));
|
||||||
|
|
||||||
$xml_paste->appendChild(
|
$xml_paste->appendChild(
|
||||||
$xml->createElement("hash", $this->hash));
|
$xml->createElement("hash", $this->hash));
|
||||||
|
|
||||||
@ -154,6 +172,8 @@ class Paste
|
|||||||
$this->title = $dict["title"];
|
$this->title = $dict["title"];
|
||||||
$this->author = $dict["author"];
|
$this->author = $dict["author"];
|
||||||
$this->language = $dict["lang"];
|
$this->language = $dict["lang"];
|
||||||
|
$this->date = time();
|
||||||
|
$this->ip = $_SERVER["REMOTE_ADDR"];
|
||||||
if (isset($dict["ref"]))
|
if (isset($dict["ref"]))
|
||||||
$this->ref = $dict["ref"];
|
$this->ref = $dict["ref"];
|
||||||
|
|
||||||
@ -222,6 +242,29 @@ class Paste
|
|||||||
str_replace("</del>", "</del>",
|
str_replace("</del>", "</del>",
|
||||||
$geshi->parse_code()))));
|
$geshi->parse_code()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function add_answer($ref)
|
||||||
|
{
|
||||||
|
if (!in_array($ref, $this->answers))
|
||||||
|
{
|
||||||
|
$this->answers[] = $ref;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_answers()
|
||||||
|
{
|
||||||
|
$nb = count($this->answers);
|
||||||
|
if ($nb > 0)
|
||||||
|
{
|
||||||
|
$ret = '<div id="res">Des réponses à ce paste ont été publiées : <ul>';
|
||||||
|
foreach($this->answers as $a)
|
||||||
|
$ret .= '<li><a href="?'.$a.'">'.$a.'</a></li>';
|
||||||
|
return $ret.'</ul></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user