From frik85@svn.reactos.org Sun Dec 16 00:04:33 2007 From: frik85@svn.reactos.org To: ros-diffs@reactos.org Subject: [ros-diffs] [frik85] 31264: ReactOS paste service * improved data-i/o code * new features like word-wrap * bug fixes URI: http://www.reactos.org/paste/ Date: Sat, 15 Dec 2007 23:04:21 +0000 Message-ID: <20071215230421.58A94FF03@mail.smartxx.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4828836663999086265==" --===============4828836663999086265== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: frik85 Date: Sun Dec 16 02:04:19 2007 New Revision: 31264 URL: http://svn.reactos.org/svn/reactos?rev=3D31264&view=3Drev 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/in= c/account.php?rev=3D31264&r1=3D31263&r2=3D31264&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 20= 07 @@ -24,7 +24,7 @@ require_once("/web/reactos.org/htdocs/roscms/inc/subsys_login.php"); $RSDB_intern_user_id =3D roscms_subsys_login('', ROSCMS_LOGIN_OPTIONAL, "/"= . $RSDB_intern_path); */ - $RSDB_intern_user_id=3D0; + $RSDB_intern_user_id=3D2; $RSDB_USER_name=3D"Anonymous"; =20 if($RSDB_intern_user_id !=3D 0) { @@ -40,5 +40,6 @@ else { $RSDB_USER_name =3D "Anonymous"; } + //echo "

!!!".$RSDB_USER_name."

"; =20 ?> Modified: trunk/web/reactos.org/htdocs/paste/inc/header.php URL: http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/in= c/header.php?rev=3D31264&r1=3D31263&r2=3D31264&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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; =20 =20 ?> @@ -101,9 +106,30 @@

- + =09 + + + + =20 =20 + Modified: trunk/web/reactos.org/htdocs/paste/inc/help.php URL: http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/in= c/help.php?rev=3D31264&r1=3D31263&r2=3D31264&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 @@

What's different about this one?

A lot of paste sites have appeared lately, and many of them are quite si= milar. The ReactOS "Copy&Paste" paste service provide a unique = list of features and a broad range of code highlight support. It uses rafb.net's code h= ighlight php library which is free available under BSD license.

How long is the paste accessable?

-

The paste is accessable for 7 days.

+

The paste is accessable for 7 days (default setting). The timeframe can = be set between 1 to 7 days as per paste setting.

Modified: trunk/web/reactos.org/htdocs/paste/inc/highlight.php URL: http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/in= c/highlight.php?rev=3D31264&r1=3D31263&r2=3D31264&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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"), +=09 +=09 + "Bash" =3D> 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" + ), +=09 + "Batch" =3D> 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",= =20 + "shift", "sort", "spool", "start", "subst", "suppresspopups", "swappath",=20 + "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" + ) =20 ); =20 @@ -751,7 +804,7 @@ =20 $mirc[line_comment]["\n"] =3D normal_text; $mirc[line_comment][0] =3D line_comment; - +=09 $ruby =3D $perl; =20 $python =3D $perl; @@ -850,6 +903,9 @@ $xml[dq_escape][";"] =3D dq_literal; =20 $xml[dq_escape][0] =3D dq_escape; =20 =20 + $bash =3D $perl; + $batch =3D $c89;; +=09 // // Main state transition table // @@ -869,7 +925,9 @@ "PL/I" =3D> $pli, "SQL" =3D> $sql, "XML" =3D> $xml, - "Scheme" =3D> $sch + "Scheme" =3D> $sch, + "Bash" =3D> $bash, + "Batch" =3D> $batch ); =20 =20 @@ -949,6 +1007,10 @@ $process["XML"][xml_tag][dq_literal] =3D "rtrim1"; $process["XML"][dq_literal][xml_tag] =3D "rtrim1"; $process["XML"][dq_literal][dq_escape] =3D "rtrim1"; +=09 + $process["Bash"] =3D $process["Perl"]; + $process["Batch"] =3D $process["C++"]; + =20 $process_end["C89"] =3D "syntax_highlight_helper"; $process_end["C++"] =3D $process_end["C89"]; @@ -965,7 +1027,8 @@ $process_end["PL/I"] =3D $process_end["C89"]; $process_end["SQL"] =3D $process_end["C89"]; $process_end["Scheme"] =3D "sch_syntax_helper"; - + $process_end["Bash"] =3D $process_end["C89"]; + $process_end["Batch"] =3D $process_end["C89"]; =20 $edges["C89"][normal_text .",". dq_literal] =3D '"'; $edges["C89"][normal_text .",". sq_literal] =3D '\''; @@ -1049,6 +1112,10 @@ $edges["XML"][sq_literal . "," . xml_tag] =3D '\''; $edges["XML"][sq_literal . "," . sq_escape] =3D '&';=20 $edges["XML"][sq_escape . "," . sq_literal] =3D '';=20 + + $edges["Bash"] =3D $edges["Perl"]; + $edges["Batch"] =3D $edges["C89"]; +=09 =20 // // 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/in= c/paste.php?rev=3D31264&r1=3D31263&r2=3D31264&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 @@ } =09 if ($ros_paste_SET_pasteid) { + create_header(); + $query_pasteid=3Dmysql_query("SELECT *=20 FROM `paste_service`=20 - WHERE `paste_id` =3D '".mysql_real_escape_string($ros_paste_SET_pas= teid)."'=20 + WHERE `paste_id` =3D '".mysql_real_escape_string($ros_paste_SET_pas= teid)."' =20 LIMIT 1 ;");=09 $result_pasteid =3D mysql_fetch_array($query_pasteid); =09 - echo '= '; - echo "

Home > Paste Service > ".$ros_paste_SET_pastei= d."

"; - echo "

"; - if ($result_pasteid['paste_desc']) { - echo $result_pasteid['paste_desc']; + if ($result_pasteid['paste_lines'] =3D=3D "" || $result_pasteid['paste_lin= es'] <=3D 0 || compareDate((date('Y')."-".date('m')."-".date('d')),stripDate(= $result_pasteid['paste_datetime'])) > 7) { + echo "

No related paste exists.

"; + } else if (compareDate((date('Y')."-".date('m')."-".date('d')),stripDate($= result_pasteid['paste_datetime'])) <=3D $result_pasteid['paste_days']) { + =09 + echo ''; + echo "

Home > Paste Service > ".$ros_paste_SET_pastei= d."

"; + echo "

"; + if ($result_pasteid['paste_desc']) { + echo $result_pasteid['paste_desc']; + } + else { + echo "Paste #".$result_pasteid['paste_id']; + } + echo "

"; + =09 + ?> +=09 +

Pasted by:
+ Language:
+ Description:
+ Pasted on:
+ Expire after: days
+ Paste history: "; - =09 -?> - -

Pasted by:
-Language:
-Description:
-Pasted on:
-Expire after: days
-Paste history:

-

Add line numbers'; - } - else { - echo ' |=20 - " target=3D"_blank">Download as Text |=20 - ">Other recent= pastes |=20 - ">Create new paste

-

+

'; - echo $ros_paste_SET_textcontent; - echo ''; + echo 'Add line numbers'; } else { -?> - - - - =09 - -
Remove line numbers';
+		}
+	?> |=20
+	  " target=3D"_blank">Download as Text=20
+	  " target=3D"_blank">(word-warp)  |=20
+	  ">Other recen=
t pastes  |=20
+	  ">Create new paste 

+ paste expired"); + } +=09 + $ros_paste_SET_textcontent =3D htmlspecialchars($contents); + if ($result_pasteid['paste_tabs'] !=3D "0") { + $PASTE_var_tabs =3D ""; + for($xxx=3D0; $xxx<$result_pasteid['paste_tabs']; $xxx++){ + $PASTE_var_tabs .=3D " "; } + $ros_paste_SET_textcontent =3D str_replace("\t",$PASTE_var_tabs,$ros_pa= ste_SET_textcontent); + } =09 - ?>
-
+ =09 + // Content: + $ros_paste_SET_textcontent =3D syntax_highlight($ros_paste_SET_textconte= nt, $result_pasteid['paste_lang']); +=09 +=09 +=09 + if (@$ros_paste_SET_pasteflag =3D=3D "nln") { + echo '

';
+				echo $ros_paste_SET_textcontent;
+				echo '
'; + } + else { + ?> + + + + =09 + +
+
$ip
$proxy
$host

"; + =09 // SQL Statement: - $paste_sql=3D"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` )=20 - VALUES ( '".mysql_real_escape_string($PASTE_var_pasteid)."' , CURDATE(= ) , '".mysql_real_escape_string($PASTE_var_days)."', '".mysql_real_escape_st= ring($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)."', '".my= sql_real_escape_string($PASTE_var_public)."', '".mysql_real_escape_string($PA= STE_var_lang)."', NOW( ) );"; + $tmp_insert_date =3D date("Y-m-d H:i:s"); + $paste_sql=3D"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` )=20 + 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)."', '".m= ysql_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=3Dmysql_query($paste_sql); + =09 + $sql_inserted_entry =3D "SELECT paste_id=20 + FROM paste_service=20 + WHERE paste_datetime =3D '".$tmp_insert_date."' + LIMIT 1;"; + $query_inserted_entry =3D mysql_query($sql_inserted_entry); + $result_inserted_entry =3D mysql_fetch_array($query_inserted_entry); + =09 + //echo $sql_inserted_entry; + //echo $result_inserted_entry['paste_id']; + + if (!@is_dir($ros_paste_SET_content)) { + @mkdir($ros_paste_SET_content,"0493"); + } + =09 + if ($result_inserted_entry['paste_id'] =3D=3D "") { + die(""); + } + =09 + $filename =3D $ros_paste_SET_content."/".$result_inserted_entry['paste_id= '].".txt"; + =09 + // Let's make sure the file exists and is writable first. + if (!@is_writable($filename)) { + =09 + // 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 =3D @fopen($filename, 'a')) { + die("error: open file problem"); + } + =09 + // Write $somecontent to our opened file. + if (@fwrite($handle, $PASTE_var_content) =3D=3D=3D FALSE) { + die("error: file write problem"); + } + =09 + //echo "Success, wrote to file ($filename)"; + =09 + @fclose($handle); + =09 + } + =09 + $update_entry =3D mysql_query("UPDATE `paste_service` SET `paste_size` = =3D '".mysql_real_escape_string(@filesize($filename))."' WHERE `paste_service= `.`paste_id` =3D ".$result_inserted_entry['paste_id']." LIMIT 1 ;"); + + =09 =20 // 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['pas= te_id']. "/"); } else { + create_header(); + ?>

Home > Paste Service

Copy & Paste - paste service

@@ -229,6 +309,8 @@ Language: + + =20 +    (* experimental syntax highlighting) Nickname: - - " /> -
+
Modified: trunk/web/reactos.org/htdocs/paste/inc/recent.php URL: http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/paste/in= c/recent.php?rev=3D31264&r1=3D31263&r2=3D31264&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 @@ ?>

Recent Pastes

=20

Recent Pastes

-

Pastes expire by default after 7 days, if desired even earlier.

+

Pastes expire by default after 7 days, if desired even earlier. This page= lists the 50 most recent pastes.

- - - - + + + + + + ".stripDate($result_content['paste_datetime'])."

"; @@ -65,12 +68,8 @@ echo $farbe2; $farbe =3D $farbe2; } - ?>">
-
- - + + + + + + \n\n"; + $filename =3D $ros_paste_SET_content."/".$result_pasteid['paste_id'].".t= xt"; + $handle =3D @fopen($filename, "r"); + $contents =3D @fread($handle, @filesize($filename)); + @fclose($handle); + $ros_paste_SET_textcontent =3D $contents; //$ros_paste_SET_textcontent =3D str_replace(" "," ",$ros_paste_SET= _textcontent); if ($result_pasteid['paste_tabs'] !=3D "0") { $PASTE_var_tabs =3D ""; @@ -104,7 +111,11 @@ } $ros_paste_SET_textcontent =3D str_replace("\t",$PASTE_var_tabs,$ros_pa= ste_SET_textcontent); } - echo $ros_paste_SET_textcontent; + if (@$ros_paste_SET_pasteflag =3D=3D "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; --===============4828836663999086265==--
Date
Language<= /font>
Nick
Description
Date
Description
Nick
Language
Lines
Size
">
"> -
-
" >" >
-
">
">
">
">
byte