Author: frik85
Date: Sun Dec 16 02:04:19 2007
New Revision: 31264
URL:
http://svn.reactos.org/svn/reactos?rev=31264&view=rev
Log:
ReactOS paste service
* improved data-i/o code
* new features like word-wrap
* bug fixes
URI:
http://www.reactos.org/paste/
Modified:
trunk/web/reactos.org/htdocs/paste/inc/account.php
trunk/web/reactos.org/htdocs/paste/inc/header.php
trunk/web/reactos.org/htdocs/paste/inc/help.php
trunk/web/reactos.org/htdocs/paste/inc/highlight.php
trunk/web/reactos.org/htdocs/paste/inc/paste.php
trunk/web/reactos.org/htdocs/paste/inc/recent.php
trunk/web/reactos.org/htdocs/paste/index.php
Modified:
trunk/web/reactos.org/htdocs/paste/inc/account.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/inc/a…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/inc/account.php (original)
+++
trunk/web/reactos.org/htdocs/paste/inc/account.php Sun Dec 16 02:04:19 2007
@@ -24,7 +24,7 @@
require_once("/web/reactos.org/htdocs/roscms/inc/subsys_login.php"…php");
$RSDB_intern_user_id = roscms_subsys_login('', ROSCMS_LOGIN_OPTIONAL,
"/" . $RSDB_intern_path);
*/
- $RSDB_intern_user_id=0;
+ $RSDB_intern_user_id=2;
$RSDB_USER_name="Anonymous";
if($RSDB_intern_user_id != 0) {
@@ -40,5 +40,6 @@
else {
$RSDB_USER_name = "Anonymous";
}
+ //echo "<h1>!!!".$RSDB_USER_name."</h1>";
?>
Modified:
trunk/web/reactos.org/htdocs/paste/inc/header.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/inc/h…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/inc/header.php (original)
+++
trunk/web/reactos.org/htdocs/paste/inc/header.php Sun Dec 16 02:04:19 2007
@@ -18,6 +18,11 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
+function create_header() {
+
+global $ros_paste_SET_path;
+global $ros_paste_SET_path_ex;
?>
@@ -101,9 +106,30 @@
</ol>
</div>
<p></p>
-
+
+<!-- Google AdSense - start -->
+<script type="text/javascript"><!--
+google_ad_client = "pub-8424466656027272";
+google_ad_width = 120;
+google_ad_height = 600;
+google_ad_format = "120x600_as";
+google_ad_type = "text";
+google_ad_channel ="6475218909";
+google_color_border = "5984C3";
+google_color_bg = "EEEEEE";
+google_color_link = "000000";
+google_color_text = "000000";
+google_color_url = "006090";
+//--></script>
+<script type="text/javascript"
+
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+<!-- Google AdSense - end -->
</td>
<!-- End of Navigation Bar -->
<td id="content">
+<?php
+ }
+?>
Modified:
trunk/web/reactos.org/htdocs/paste/inc/help.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/inc/h…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/inc/help.php (original)
+++
trunk/web/reactos.org/htdocs/paste/inc/help.php Sun Dec 16 02:04:19 2007
@@ -28,5 +28,5 @@
<h2>What's different about this one? </h2>
<p> A lot of paste sites have appeared lately, and many of them are quite similar.
The ReactOS "Copy&Paste" paste service provide a unique list of
features and a broad range of code highlight support. It uses <a
href="http://rafb.net/paste/highlight.phps"
target="_blank">rafb.net's code highlight php library</a> which is
free available under BSD license. </p>
<h2>How long is the paste accessable? </h2>
-<p> The paste is accessable for 7 days. </p>
+<p> The paste is accessable for 7 days (default setting). The timeframe can be set
between 1 to 7 days as per paste setting. </p>
<p></p>
Modified:
trunk/web/reactos.org/htdocs/paste/inc/highlight.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/inc/h…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/inc/highlight.php (original)
+++
trunk/web/reactos.org/htdocs/paste/inc/highlight.php Sun Dec 16 02:04:19 2007
@@ -496,7 +496,60 @@
"varchar", "variable", "varying", "verbose",
"version", "view", "volatile", "when",
"whenever", "where", "with", "without",
- "work", "write", "year", "zone")
+ "work", "write", "year", "zone"),
+
+
+ "Bash" => array(
+ "alias", "break", "case", "continue",
+ "do", "done", "elif", "else",
+ "esac", "exit", "export", "fi",
+ "for", "if", "in", "return",
+ "set", "then", "unalias", "unset",
+ "while", "halt", "ifconfig", "lsmod",
+ "modprobe", "reboot", "rmmod", "route",
+ "shutdown", "traceroute", "awk", "basename",
+ "cat", "cp", "echo", "egrep",
+ "fgrep", "gawk", "grep", "gzip",
+ "kill", "killall", "less", "md",
+ "mkdir", "mv", "nice", "pidof",
+ "ps", "rd", "read", "rm",
+ "rmdir", "sed", "sleep", "test",
+ "touch", "ulimit", "uname", "usleep",
+ "zcat", "zless"
+ ),
+
+ "Batch" => array(
+ "do", "else", "end", "errorlevel",
+ "exist", "exit", "for", "goto",
+ "if", "not", "pause", "return",
+ "say", "select", "then", "when",
+ "ansi", "append", "assign", "attrib",
+ "autofail", "backup", "basedev", "boot",
+ "break", "buffers", "cache", "call",
+ "cd", "chcp", "chdir", "chkdsk",
+ "choice", "cls", "cmd", "codepage",
+ "command", "comp", "copy", "country",
+ "date", "ddinstal", "debug", "del",
+ "detach", "device", "devicehigh", "devinfo",
+ "dir", "diskcoache", "diskcomp", "diskcopy",
+ "doskey", "dpath", "dumpprocess", "eautil",
+ "endlocal", "erase", "exit_vdm", "extproc",
+ "fcbs", "fdisk", "fdiskpm", "files",
+ "find", "format", "fsaccess", "fsfilter",
+ "graftabl", "iopl", "join", "keyb",
"keys",
+ "label", "lastdrive", "libpath", "lh",
"loadhigh",
+ "makeini", "maxwait", "md", "mem",
"memman", "mkdir", "mode", "move",
+ "net", "patch", "path", "pauseonerror",
"picview", "pmrexx", "print",
+ "printmonbufsize", "priority", "priority_disk_io",
"prompt", "protectonly",
+ "protshell", "pstat", "rd", "recover",
"reipl", "ren", "rename", "replace",
+ "restore", "rmdir", "rmsize", "run",
"set", "setboot", "setlocal", "shell",
+ "shift", "sort", "spool", "start",
"subst", "suppresspopups", "swappath",
+ "syslevel", "syslog", "threads", "time",
"timeslice", "trace", "tracebuf",
+ "tracefmt", "trapdump", "tree",
"type", "undelete", "unpack", "use",
+ "ver", "verify", "view", "vmdisk",
"vol",
+ "xcopy", "xcopy32", "xdfcopy",
+ "echo", "off", "on"
+ )
);
@@ -751,7 +804,7 @@
$mirc[line_comment]["\n"] = normal_text;
$mirc[line_comment][0] = line_comment;
-
+
$ruby = $perl;
$python = $perl;
@@ -850,6 +903,9 @@
$xml[dq_escape][";"] = dq_literal;
$xml[dq_escape][0] = dq_escape;
+ $bash = $perl;
+ $batch = $c89;;
+
//
// Main state transition table
//
@@ -869,7 +925,9 @@
"PL/I" => $pli,
"SQL" => $sql,
"XML" => $xml,
- "Scheme" => $sch
+ "Scheme" => $sch,
+ "Bash" => $bash,
+ "Batch" => $batch
);
@@ -949,6 +1007,10 @@
$process["XML"][xml_tag][dq_literal] = "rtrim1";
$process["XML"][dq_literal][xml_tag] = "rtrim1";
$process["XML"][dq_literal][dq_escape] = "rtrim1";
+
+ $process["Bash"] = $process["Perl"];
+ $process["Batch"] = $process["C++"];
+
$process_end["C89"] = "syntax_highlight_helper";
$process_end["C++"] = $process_end["C89"];
@@ -965,7 +1027,8 @@
$process_end["PL/I"] = $process_end["C89"];
$process_end["SQL"] = $process_end["C89"];
$process_end["Scheme"] = "sch_syntax_helper";
-
+ $process_end["Bash"] = $process_end["C89"];
+ $process_end["Batch"] = $process_end["C89"];
$edges["C89"][normal_text .",". dq_literal] = '<span
class="literal">"';
$edges["C89"][normal_text .",". sq_literal] = '<span
class="literal">\'';
@@ -1049,6 +1112,10 @@
$edges["XML"][sq_literal . "," . xml_tag] =
'\'</span>';
$edges["XML"][sq_literal . "," . sq_escape] = '<span
class="html_entity">&';
$edges["XML"][sq_escape . "," . sq_literal] =
'</span>';
+
+ $edges["Bash"] = $edges["Perl"];
+ $edges["Batch"] = $edges["C89"];
+
//
// The State Machine
Modified:
trunk/web/reactos.org/htdocs/paste/inc/paste.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/inc/p…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/inc/paste.php (original)
+++
trunk/web/reactos.org/htdocs/paste/inc/paste.php Sun Dec 16 02:04:19 2007
@@ -29,94 +29,109 @@
}
if ($ros_paste_SET_pasteid) {
+ create_header();
+
$query_pasteid=mysql_query("SELECT *
FROM `paste_service`
- WHERE `paste_id` =
'".mysql_real_escape_string($ros_paste_SET_pasteid)."'
+ WHERE `paste_id` =
'".mysql_real_escape_string($ros_paste_SET_pasteid)."'
LIMIT 1 ;");
$result_pasteid = mysql_fetch_array($query_pasteid);
- echo '<link href="highlight.css" type="text/css"
rel="stylesheet" />';
- echo "<h1><a style=\"color:#FFFFFF ! important ;\"
href=\"http://www.reactos.org/\">Home</a> > <a
style=\"color:#FFFFFF ! important ;\"
href=\"".$ros_paste_SET_path."\">Paste Service</a> >
".$ros_paste_SET_pasteid."</h1>";
- echo "<h2>";
- if ($result_pasteid['paste_desc']) {
- echo $result_pasteid['paste_desc'];
+ if ($result_pasteid['paste_lines'] == "" ||
$result_pasteid['paste_lines'] <= 0 ||
compareDate((date('Y')."-".date('m')."-".date('d')),stripDate($result_pasteid['paste_datetime']))
> 7) {
+ echo "<p><b>No related paste exists.</b></p>";
+ } else if
(compareDate((date('Y')."-".date('m')."-".date('d')),stripDate($result_pasteid['paste_datetime']))
<= $result_pasteid['paste_days']) {
+
+ echo '<link href="highlight.css" type="text/css"
rel="stylesheet" />';
+ echo "<h1><a style=\"color:#FFFFFF ! important ;\"
href=\"http://www.reactos.org/\">Home</a> > <a
style=\"color:#FFFFFF ! important ;\"
href=\"".$ros_paste_SET_path."\">Paste Service</a> >
".$ros_paste_SET_pasteid."</h1>";
+ echo "<h2>";
+ if ($result_pasteid['paste_desc']) {
+ echo $result_pasteid['paste_desc'];
+ }
+ else {
+ echo "Paste #".$result_pasteid['paste_id'];
+ }
+ echo "</h2>";
+
+ ?>
+
+ <p>Pasted by: <b><?php echo $result_pasteid['paste_nick'];
?></b><br />
+ Language: <b><?php echo $result_pasteid['paste_lang'];
?></b><br />
+ Description: <b><?php echo $result_pasteid['paste_desc'];
?></b><br />
+ Pasted on: <b><?php echo $result_pasteid['paste_date'];
?></b><br />
+ Expire after: <b><?php echo $result_pasteid['paste_days']; ?> days
</b><br />
+ Paste history: <b><?php
+
+ if ($result_pasteid['paste_public'] == "1") {
+ echo "yes (public)";
}
else {
- echo $result_pasteid['paste_id'];
- }
- echo "</h2>";
-
-?>
-
-<p>Pasted by: <b><?php echo $result_pasteid['paste_nick'];
?></b><br />
-Language: <b><?php echo $result_pasteid['paste_lang'];
?></b><br />
-Description: <b><?php echo $result_pasteid['paste_desc'];
?></b><br />
-Pasted on: <b><?php echo $result_pasteid['paste_date'];
?></b><br />
-Expire after: <b><?php echo $result_pasteid['paste_days']; ?> days
</b><br />
-Paste history: <b><?php
-
- if ($result_pasteid['paste_public'] == "1") {
- echo "yes (public)";
- }
- else {
- echo "no (private)";
- }
-
-?></b></p>
-<p><?php
-
- if (@$ros_paste_SET_pasteflag == "nln") {
- echo '<a href="'. $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/">Add line numbers</a>';
- }
- else {
- echo '<a href="'. $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/nln/">Remove line
numbers</a>';
- }
-?> |
- <a href="<?php echo $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/text/'; ?>"
target="_blank">Download as Text</a> |
- <a href="<?php echo $ros_paste_SET_path_ex . 'recent/';
?>">Other recent pastes</a> |
- <a href="<?php echo $ros_paste_SET_path; ?>">Create new
paste</a> </p>
-<?php
-
-
- $ros_paste_SET_textcontent =
htmlspecialchars($result_pasteid['paste_content']);
- if ($result_pasteid['paste_tabs'] != "0") {
- $PASTE_var_tabs = "";
- for($xxx=0; $xxx<$result_pasteid['paste_tabs']; $xxx++){
- $PASTE_var_tabs .= " ";
- }
- $ros_paste_SET_textcontent =
str_replace("\t",$PASTE_var_tabs,$ros_paste_SET_textcontent);
- }
-
-
-
- // Content:
- $ros_paste_SET_textcontent = syntax_highlight($ros_paste_SET_textcontent,
$result_pasteid['paste_lang']);
-
-
-
+ echo "no (private)";
+ }
+
+ ?></b></p>
+ <p><?php
+
if (@$ros_paste_SET_pasteflag == "nln") {
- echo '<pre class="code" style="margin: 6px;">';
- echo $ros_paste_SET_textcontent;
- echo '</pre>';
+ echo '<a href="'. $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/">Add line numbers</a>';
}
else {
-?>
- <table cellspacing="5" cellpadding="1"
border="0">
- <tbody>
- <tr>
-
- <td align="right" valign="top"><pre
class="code"><?php
+ echo '<a href="'. $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/nln/">Remove line
numbers</a>';
+ }
+ ?> |
+ <a href="<?php echo $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/text/'; ?>"
target="_blank">Download as Text</a>
+ <a href="<?php echo $ros_paste_SET_path_ex .
$result_pasteid['paste_id'] .'/textw/'; ?>"
target="_blank">(word-warp)</a> |
+ <a href="<?php echo $ros_paste_SET_path_ex . 'recent/';
?>">Other recent pastes</a> |
+ <a href="<?php echo $ros_paste_SET_path; ?>">Create new
paste</a> </p>
+ <?php
+
+
+ $filename =
$ros_paste_SET_content."/".$result_pasteid['paste_id'].".txt";
+ $handle = @fopen($filename, "r");
+ $contents = @fread($handle, @filesize($filename));
+ @fclose($handle);
- for ($PASTE_linecount=1; $PASTE_linecount <=
$result_pasteid['paste_lines']; $PASTE_linecount++) {
- echo $PASTE_linecount."\n";
+ if ($contents == "") {
+ die("<b>paste expired</b>");
+ }
+
+ $ros_paste_SET_textcontent = htmlspecialchars($contents);
+ if ($result_pasteid['paste_tabs'] != "0") {
+ $PASTE_var_tabs = "";
+ for($xxx=0; $xxx<$result_pasteid['paste_tabs']; $xxx++){
+ $PASTE_var_tabs .= " ";
}
+ $ros_paste_SET_textcontent =
str_replace("\t",$PASTE_var_tabs,$ros_paste_SET_textcontent);
+ }
- ?></pre>
- </td>
- <td width="100%" valign="top"><pre
class="code"><?php echo $ros_paste_SET_textcontent;
?></pre></td></tr></tbody></table>
+
+ // Content:
+ $ros_paste_SET_textcontent = syntax_highlight($ros_paste_SET_textcontent,
$result_pasteid['paste_lang']);
+
+
+
+ if (@$ros_paste_SET_pasteflag == "nln") {
+ echo '<pre class="code" style="margin: 6px;">';
+ echo $ros_paste_SET_textcontent;
+ echo '</pre>';
+ }
+ else {
+ ?>
+ <table cellspacing="5" cellpadding="1"
border="0">
+ <tbody>
+ <tr>
+
+ <td align="right" valign="top"><pre
class="code"><?php
+
+ for ($PASTE_linecount=1; $PASTE_linecount <=
$result_pasteid['paste_lines']; $PASTE_linecount++) {
+ echo $PASTE_linecount."\n";
+ }
+
+ ?></pre>
+ </td>
+ <td width="100%" valign="top"><pre
class="code"><?php echo $ros_paste_SET_textcontent;
?></pre></td></tr></tbody></table>
<?php
- }
-
+ }
+ }
}
else {
if ($ros_paste_SET_cnp == "1") {
@@ -124,7 +139,8 @@
$ros_paste_SET_lang = "";
$ros_paste_SET_usrname = "";
$ros_paste_SET_nick = "";
- $ros_paste_SET_husrname = "";
+ //$ros_paste_SET_husrname = "";
+ //$ros_paste_SET_husrid = "";
$ros_paste_SET_desc = "";
$ros_paste_SET_cvt_tabs = "";
$ros_paste_SET_optday = "";
@@ -132,10 +148,12 @@
$ros_paste_SET_textcontent = "";
$ros_paste_SET_public = "";
+
if (array_key_exists("lang", $_POST))
$ros_paste_SET_lang=htmlspecialchars($_POST["lang"]);
if (array_key_exists("usrname", $_POST))
$ros_paste_SET_usrname=htmlspecialchars($_POST["usrname"]);
if (array_key_exists("nick", $_POST))
$ros_paste_SET_nick=htmlspecialchars($_POST["nick"]);
- if (array_key_exists("husrname", $_POST))
$ros_paste_SET_husrname=htmlspecialchars($_POST["husrname"]);
+ //if (array_key_exists("husrname", $_POST))
$ros_paste_SET_husrname=htmlspecialchars($_POST["husrname"]);
+ //if (array_key_exists("husrid", $_POST))
$ros_paste_SET_husrid=htmlspecialchars($_POST["husrid"]);
if (array_key_exists("desc", $_POST))
$ros_paste_SET_desc=htmlspecialchars($_POST["desc"]);
if (array_key_exists("cvt_tabs", $_POST))
$ros_paste_SET_cvt_tabs=htmlspecialchars($_POST["cvt_tabs"]);
if (array_key_exists("optday", $_POST))
$ros_paste_SET_optday=htmlspecialchars($_POST["optday"]);
@@ -144,11 +162,14 @@
if (array_key_exists("optpub", $_POST))
$ros_paste_SET_public=htmlspecialchars($_POST["optpub"]);
// Nick:
+ $ros_paste_SET_husrname = $RSDB_USER_name;
+ $ros_paste_SET_husrid = $RSDB_intern_user_id;
+
if ($ros_paste_SET_usrname == "1") {
$PASTE_var_nick = $ros_paste_SET_nick;
}
elseif ($ros_paste_SET_usrname == "2") {
- if ($PASTE_var_nick == "") {
+ if ($ros_paste_SET_husrname == "") {
$PASTE_var_nick = "Anonymous";
}
else {
@@ -174,7 +195,7 @@
$PASTE_var_public = $ros_paste_SET_public;
- // Paste ID:
+ /*// Paste ID:
$tmp_id_check = true;
while($tmp_id_check) {
mt_srand((double)microtime()*1000000);
@@ -189,7 +210,7 @@
if ($result_pasteid[0] <= 0) {
$tmp_id_check = false;
}
- }
+ }*/
/*if ($ros_paste_SET_cvt_tabs != "0") {
$PASTE_var_tabs = "";
@@ -210,15 +231,74 @@
$PASTE_var_lines = sizeof(explode("\n", $PASTE_var_content));
$PASTE_var_lang = $ros_paste_SET_lang;
+
+ $ip = @$_SERVER["HTTP_X_FORWARDED_FOR"];
+ $proxy = $_SERVER["REMOTE_ADDR"];
+ $host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]);
+
+ if ($ip == "") {
+ $ip = $proxy;
+ }
+
+ //echo "<p>$ip<br />$proxy<br />$host</p>";
+
// SQL Statement:
- $paste_sql="INSERT INTO `paste_service` ( `paste_id` , `paste_date` ,
`paste_days` , `paste_nick` , `paste_desc` , `paste_content` , `paste_lines` ,
`paste_tabs`, `paste_public` , `paste_lang` , `paste_datetime` )
- VALUES ( '".mysql_real_escape_string($PASTE_var_pasteid)."' ,
CURDATE( ) , '".mysql_real_escape_string($PASTE_var_days)."',
'".mysql_real_escape_string($PASTE_var_nick)."',
'".mysql_real_escape_string($PASTE_var_desc)."',
'".mysql_real_escape_string($PASTE_var_content)."',
'".mysql_real_escape_string($PASTE_var_lines)."',
'".mysql_real_escape_string($PASTE_var_tabs)."',
'".mysql_real_escape_string($PASTE_var_public)."',
'".mysql_real_escape_string($PASTE_var_lang)."', NOW( ) );";
+ $tmp_insert_date = date("Y-m-d H:i:s");
+ $paste_sql="INSERT INTO `paste_service` ( `paste_date` , `paste_days` ,
`paste_usrid` , `paste_nick` , `paste_desc` , `paste_lines` , `paste_tabs`, `paste_public`
, `paste_lang` , `paste_datetime` , `paste_ip` , `paste_proxy` , `paste_host` )
+ VALUES ( CURDATE( ) ,
'".mysql_real_escape_string($PASTE_var_days)."',
'".mysql_real_escape_string($ros_paste_SET_husrid)."',
'".mysql_real_escape_string($PASTE_var_nick)."',
'".mysql_real_escape_string($PASTE_var_desc)."',
'".mysql_real_escape_string($PASTE_var_lines)."',
'".mysql_real_escape_string($PASTE_var_tabs)."',
'".mysql_real_escape_string($PASTE_var_public)."',
'".mysql_real_escape_string($PASTE_var_lang)."',
'".$tmp_insert_date."',
'".mysql_real_escape_string($ip)."',
'".mysql_real_escape_string($proxy)."',
'".mysql_real_escape_string($host)."' );";
$paste_query=mysql_query($paste_sql);
+
+ $sql_inserted_entry = "SELECT paste_id
+ FROM paste_service
+ WHERE paste_datetime = '".$tmp_insert_date."'
+ LIMIT 1;";
+ $query_inserted_entry = mysql_query($sql_inserted_entry);
+ $result_inserted_entry = mysql_fetch_array($query_inserted_entry);
+
+ //echo $sql_inserted_entry;
+ //echo $result_inserted_entry['paste_id'];
+
+ if (!@is_dir($ros_paste_SET_content)) {
+ @mkdir($ros_paste_SET_content,"0493");
+ }
+
+ if ($result_inserted_entry['paste_id'] == "") {
+ die("");
+ }
+
+ $filename =
$ros_paste_SET_content."/".$result_inserted_entry['paste_id'].".txt";
+
+ // Let's make sure the file exists and is writable first.
+ if (!@is_writable($filename)) {
+
+ // In our example we're opening $filename in append mode.
+ // The file pointer is at the bottom of the file hence
+ // that's where $somecontent will go when we fwrite() it.
+ if (!$handle = @fopen($filename, 'a')) {
+ die("error: open file problem");
+ }
+
+ // Write $somecontent to our opened file.
+ if (@fwrite($handle, $PASTE_var_content) === FALSE) {
+ die("error: file write problem");
+ }
+
+ //echo "Success, wrote to file ($filename)";
+
+ @fclose($handle);
+
+ }
+
+ $update_entry = mysql_query("UPDATE `paste_service` SET `paste_size` =
'".mysql_real_escape_string((a)filesize($filename))."' WHERE
`paste_service`.`paste_id` = ".$result_inserted_entry['paste_id']."
LIMIT 1 ;");
+
+
// Redirect to paste result page:
- header("Location: ". $ros_paste_SET_path_ex . $PASTE_var_pasteid.
"/");
+ header("Location: ". $ros_paste_SET_path_ex .
$result_inserted_entry['paste_id']. "/");
}
else {
+ create_header();
+
?>
<h1><a
href="http://www.reactos.org/">Home</a> >
Paste Service</h1>
<h2>Copy & Paste - paste service</h2>
@@ -229,6 +309,8 @@
<td valign="top" bgcolor="#E2E2E2" style="padding-left:
0px; padding-right: 5px;"><b><font size="2" face="Verdana,
Arial, Helvetica, sans-serif">Language:</font></b></td>
<td bgcolor="#E2E2E2"><select name="lang"
id="lang">
<option value="Plain Text">Plain Text</option>
+ <option value="Bash">Bash *</option>
+ <option value="Batch">Batch *</option>
<option value="C89">C (C89)</option>
<option value="C" selected="selected">C (C99)</option>
<option value="C++">C++</option>
@@ -240,19 +322,18 @@
<option value="PL/I">PL/I</option>
<option value="Python">Python</option>
<option value="Ruby">Ruby</option>
- <option value="Scheme">Scheme (beta)</option>
+ <option value="Scheme">Scheme *</option>
<option value="SQL">SQL</option>
<option value="VB">Visual Basic</option>
- <option value="XML">XML (beta)</option>
- </select></td>
+ <option value="XML">XML *</option>
+ </select>
+ <font size="1">(* experimental syntax
highlighting)</font></td>
</tr>
<tr>
<td valign="top" bgcolor="#EEEEEE" style="padding-left:
0px; padding-right: 5px;"><b><font size="2" face="Verdana,
Arial, Helvetica, sans-serif">Nickname:</font></b></td>
<td bgcolor="#EEEEEE"><font size="2" face="Verdana,
Arial, Helvetica, sans-serif">
<input name="usrname" type="radio" id="usrname"
value="2" checked="checked" />
- <?php echo $RSDB_USER_name; ?>
- <input name="husrname" type="hidden" id="husrname"
value="<?php echo $RSDB_USER_name; ?>" />
- <br />
+ <?php echo $RSDB_USER_name; ?><br />
<input name="usrname" type="radio" id="usrname"
value="1" />
<input type="text" size="14" maxlength="9"
name="nick" id="nick" value=""/>
</font></td>
Modified:
trunk/web/reactos.org/htdocs/paste/inc/recent.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/inc/r…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/inc/recent.php (original)
+++
trunk/web/reactos.org/htdocs/paste/inc/recent.php Sun Dec 16 02:04:19 2007
@@ -23,13 +23,15 @@
?>
<h1>Recent Pastes</h1>
<h2>Recent Pastes</h2>
-<p>Pastes expire by default after 7 days, if desired even earlier. </p>
+<p>Pastes expire by default after 7 days, if desired even earlier. This page lists
the 50 most recent pastes. </p>
<table width="100%" border="0" cellpadding="1"
cellspacing="1">
<tr bgcolor="#5984C3">
- <td width="25%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Date</strong></font></div></td>
- <td width="10%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Language</strong></font></div></td>
- <td width="25%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Nick</strong></font></div></td>
- <td width="40%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Description</strong></font></div></td>
+ <td width="20%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Date</strong></font></div></td>
+ <td width="35%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Description</strong></font></div></td>
+ <td width="20%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Nick</strong></font></div></td>
+ <td width="10%"><div align="center"><font
color="#FFFFFF" face="Arial, Helvetica,
sans-serif"><strong>Language</strong></font></div></td>
+ <td width="5%"><div align="center"><font
color="#FFFFFF" face="Arial, Helvetica,
sans-serif"><strong>Lines</strong></font></div></td>
+ <td width="10%" bgcolor="#5984C3"><div
align="center"><font color="#FFFFFF" face="Arial,
Helvetica,
sans-serif"><strong>Size</strong></font></div></td>
</tr>
<?php
@@ -41,8 +43,9 @@
FROM `paste_service`
WHERE `paste_days` <=7
AND `paste_public` = 1
+ AND paste_size < 100000
ORDER BY `paste_datetime` DESC
- LIMIT 0 , 30 ;") ;
+ LIMIT 0 , 50 ;");
while($result_content = mysql_fetch_array($query_content)) {
//echo
"<p>".stripDate($result_content['paste_datetime'])."</p>";
@@ -65,12 +68,8 @@
echo $farbe2;
$farbe = $farbe2;
}
- ?>"><div align="left"><font size="2"
face="Verdana, Arial, Helvetica, sans-serif"><?php echo
$result_content['paste_datetime']; ?></font></div></td>
- <td valign="middle" bgcolor="<?php echo $farbe;
?>"><div align="left"><font size="2"
face="Verdana, Arial, Helvetica, sans-serif"><?php echo
$result_content['paste_lang']; ?></font></div></td>
- <td valign="middle" bgcolor="<?php echo $farbe;
?>"><font size="2" face="Verdana, Arial, Helvetica,
sans-serif">
- <div align="left"><?php echo
$result_content['paste_nick']; ?>
- </div></td>
- <td valign="middle" bgcolor="<?php echo $farbe; ?>"
><div align="left"><font size="2" face="Verdana,
Arial, Helvetica, sans-serif"><a href="<?php echo
$ros_paste_SET_path_ex . $result_content['paste_id']."/";
?>">
+ ?>"><div align="left"><font size="2"
face="Verdana, Arial, Helvetica, sans-serif"><a href="<?php echo
$ros_paste_SET_path_ex . $result_content['paste_id']."/";
?>"><?php echo
substr($result_content['paste_datetime'],0,strlen($result_content['paste_datetime'])-3);
?></a></font></div></td>
+ <td valign="middle" bgcolor="<?php echo $farbe; ?>"
><div align="left"><font size="2" face="Verdana,
Arial, Helvetica, sans-serif">
<?php
if ($result_content['paste_desc']) {
@@ -81,7 +80,11 @@
}
?>
- </a></font></div></td>
+ </font></div></td>
+ <td valign="middle" bgcolor="<?php echo $farbe;
?>"><font size="2" face="Verdana, Arial, Helvetica,
sans-serif"><div align="left"><?php echo
$result_content['paste_nick']; ?> </div></td>
+ <td valign="middle" bgcolor="<?php echo $farbe;
?>"><div align="left"><font size="2"
face="Verdana, Arial, Helvetica, sans-serif"><?php echo
$result_content['paste_lang']; ?></font></div></td>
+ <td valign="middle" bgcolor="<?php echo $farbe;
?>"><div align="right"><font size="2"
face="Verdana, Arial, Helvetica, sans-serif"><?php echo
$result_content['paste_lines']; ?></font></div></td>
+ <td valign="middle" bgcolor="<?php echo $farbe;
?>"><div align="right"><font size="2"
face="Verdana, Arial, Helvetica, sans-serif"><?php echo
$result_content['paste_size']; ?> byte</font></div></td>
</tr>
<?php
}
Modified:
trunk/web/reactos.org/htdocs/paste/index.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/index…
==============================================================================
---
trunk/web/reactos.org/htdocs/paste/index.php (original)
+++
trunk/web/reactos.org/htdocs/paste/index.php Sun Dec 16 02:04:19 2007
@@ -30,6 +30,7 @@
$ros_paste_SET_path = "http://localhost/reactos.org/paste/";
$ros_paste_SET_path_ex = "http://localhost/reactos.org/paste/index.php/";
$ros_paste_SET_dirs = "reactos.org/paste/";
+ $ros_paste_SET_content = "content";
@@ -82,10 +83,12 @@
}
}
+ include("inc/tools.php");
+
switch ($ros_paste_SET_page) {
default:
case "paste": // Paste Your Content
- if (@$ros_paste_SET_pasteflag == "text") {
+ if (@$ros_paste_SET_pasteflag == "text" || @$ros_paste_SET_pasteflag ==
"textw") {
include("inc/account.php");
$query_pasteid=mysql_query("SELECT *
FROM `paste_service`
@@ -94,8 +97,12 @@
$result_pasteid = mysql_fetch_array($query_pasteid);
header('Content-type: text/plain');
- //echo "ReactOS Paste Service -
http://www.reactos.org/paste/".$result_pasteid['paste_id'].&qu…
\n\n";
- $ros_paste_SET_textcontent = $result_pasteid['paste_content'];
+ //echo "<!-- ReactOS Paste Service -
http://www.reactos.org/paste/".$result_pasteid['paste_id'].&qu… -->
\n\n";
+ $filename =
$ros_paste_SET_content."/".$result_pasteid['paste_id'].".txt";
+ $handle = @fopen($filename, "r");
+ $contents = @fread($handle, @filesize($filename));
+ @fclose($handle);
+ $ros_paste_SET_textcontent = $contents;
//$ros_paste_SET_textcontent = str_replace(" ","
",$ros_paste_SET_textcontent);
if ($result_pasteid['paste_tabs'] != "0") {
$PASTE_var_tabs = "";
@@ -104,7 +111,11 @@
}
$ros_paste_SET_textcontent =
str_replace("\t",$PASTE_var_tabs,$ros_paste_SET_textcontent);
}
- echo $ros_paste_SET_textcontent;
+ if (@$ros_paste_SET_pasteflag == "textw") {
+ echo wordwrap($ros_paste_SET_textcontent, 80, "\n", true);
+ } else {
+ echo $ros_paste_SET_textcontent;
+ }
}
else {
include("inc/header.php");
@@ -116,18 +127,20 @@
break;
case "conditions": // Conditions
include("inc/header.php");
+ create_header();
include("inc/conditions.php");
include("inc/footer.php");
break;
case "help": // Help & FAQ
include("inc/header.php");
+ create_header();
include("inc/help.php");
include("inc/footer.php");
break;
case "recent": // Recent Pastes
include("inc/header.php");
+ create_header();
include("inc/account.php");
- include("inc/tools.php");
include("inc/recent.php");
include("inc/footer.php");
break;