Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header ('Content-Type: text/plain; charset=utf-8');
- $q = $_GET['q'];
- $opts = explode('/',$q);
- function getmsg($t) {
- $t = preg_replace("/[^a-zA-Z0-9]+/", "", $t);
- return @file_get_contents ("msg/$t");
- }
- function getecho($t) {
- $t = preg_replace("/[^a-z0-9!_.-]+/", "", $t);
- return @file_get_contents ("echo/$t");
- }
- //======================================================
- function b64c($s,$us) {
- if($us) return base64_encode($s);
- else return rtrim(strtr(base64_encode($s), '+/', '-_'), '=');
- }
- function b64d($s) {
- //return base64_decode($s);
- return base64_decode(str_pad(strtr($s, '-_', '+/'), strlen($s) % 4, '=', STR_PAD_RIGHT));
- }
- function hsh($s) {
- $s1 = b64c(hash("sha256",$s,true), 0);
- $s1=str_replace("-","A",$s1);
- $s1=str_replace("_","z",$s1);
- return substr($s1,0,20);
- }
- //=============================================
- if ($opts[1] == 'e') {
- echo getecho($opts[2]);
- } # e
- if ($opts[1] == 'm') {
- echo getmsg($opts[2]);
- } # m
- if ($opts[1] == 'u' and $opts[2] == 'm') {
- for ($x=3;$x<count($opts);$x++) {
- $hash = base64_encode(getmsg($opts[$x]));
- echo "$opts[$x]:$hash\n";
- }
- } # um
- if ($opts[1] == 'u' and $opts[2] == 'e') {
- for ($x=3;$x<count($opts);$x++) {
- echo $opts[$x] . "\n";
- echo getecho($opts[$x]);
- }
- } # ue
- function parsePoints() {
- $arr=[
- ["123456","root"],
- ["78910","point1"]
- ];
- return $arr;
- }
- function pointSend($msg,$authname) {
- $goodmsg=explode("\n",b64d($msg));
- $msgid=hsh($msg);
- $echo=$goodmsg[0];
- $receiver=$goodmsg[1];
- $subj=$goodmsg[2];
- $rep=$goodmsg[4];
- $repto="";
- $time=time();
- $othermsg="";
- $msgwrite="";
- for($i=5;$i<count($goodmsg);$i++) {
- if($i==(count($goodmsg)-1)) {
- $othermsg.=$goodmsg[$i];
- } else {
- $othermsg.=$goodmsg[$i]."\n";
- }
- }
- if(substr($rep,0,7)=="@repto:") {
- $repto=substr($rep,7);
- dbg("|$repto|");
- }
- if($repto) {
- $msgwrite.="repto/$repto\n";
- } else {
- $msgwrite.="\n";
- $norep=1;
- }
- $msgwrite.="$echo
- $time
- $authname
- anonimous
- $receiver
- $subj\n\n";
- if(!$norep) {
- $msgwrite.=$othermsg;
- } else {
- $msgwrite.=$rep.$othermsg;
- }
- $echofile=fopen("echo/".$echo,"a");
- fputs($echofile,$msgid."\n"); fclose($echofile);
- $msgfile=fopen("msg/".$msgid,"w");
- fputs($msgfile,$msgwrite); fclose($msgfile);
- }
- $parr=parsePoints();
- $auth=0;
- $authname=0;
- if ($opts[1] == 'u' and $opts[2] == 'point') {
- if ($opts[3] && $opts[4]) {
- $au=$opts[3];
- $ms=$opts[4];
- } elseif($_POST['pauth'] && $_POST['tmsg']) {
- $au=$_POST['pauth'];
- $ms=$_POST['tmsg'];
- } else $error=1;
- if(!$error) {
- for($i=0;$i<count($parr);$i++) {
- if($parr[$i][0]==$au) {
- $auth=$au;
- $authname=$parr[$i][1];
- break;
- }
- }
- if($auth and $authname) {
- pointSend($ms,$authname);
- }
- else {
- die("|no auth|");
- }
- }
- else die('|error: unknown|');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement