Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18290 > unrolled thread
| Started by | kristjan1291983@gmail.com |
|---|---|
| First post | 2020-06-24 10:41 -0700 |
| Last post | 2020-06-24 23:34 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.php
Chatting portal with pictures. kristjan1291983@gmail.com - 2020-06-24 10:41 -0700
Re: Chatting portal with pictures. "J.O. Aho" <user@example.net> - 2020-06-24 23:34 +0200
| From | kristjan1291983@gmail.com |
|---|---|
| Date | 2020-06-24 10:41 -0700 |
| Subject | Chatting portal with pictures. |
| Message-ID | <cdde608a-8a67-484c-b7c7-123db2105555o@googlegroups.com> |
Files:
1index.php
<!DOCTYPE html>
<html>
<body>
<form action="1upload.php" method="post" enctype="multipart/form-data">
File to upload:
<p></p>
<input type="file" name="fileToUpload" id="fileToUpload"/>
<p></p>
<input type="submit" value="Upload file" name="submit" />
</form>
<p></p>
<p></p>
<p>Files in /files :</p>
<?php
$dirs = array_filter(glob('*'), 'is_dir');
$fexists=false;
foreach ($dirs as $k=>$v) {
if($v=="files") $fexists=true;
}
if($fexists==false) {
mkdir("files", 0755);
}
$files1 = scandir("files");
if(count($files1)==2) {
echo "None";
}
for($i=2; $i<count($files1); $i++) {
echo "<p>".$files1[$i]."</p>";
}
?>
</body>
</html>
1upload.php
<?php
include("func.php");
$array = explode('.', $_FILES["fileToUpload"]["name"]);
$extension = end($array);
if($extension=="php") {
echo "Cannot add that type of file";
exit(0);
}
$dirs = array_filter(glob('*'), 'is_dir');
if(count($dirs)<1) {
mkdir("files", 0755);
}
$files1 = scandir("files");
if(count($files1)>1000) {
rrmdir("files");
mkdir("files", 0755);
}
if(empty($_FILES)) {
exit(0);
}
$target_dir = "files/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
if (file_exists($target_file)) {
echo "File already exists.";
$uploadOk = 0;
}
if ($_FILES["fileToUpload"]["size"] > 5000000) {
echo "Your file is too large.";
$uploadOk = 0;
}
if ($uploadOk == 0) {
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
chmod($target_file, 0777);
echo "Uploaded.";
} else {
echo "There was an error uploading your file.";
}
}
?>
2index.php
<?php
include("func.php");
rrmdir('files2');
mkdir("files2", 0755);
?>
<!DOCTYPE html>
<html>
<body>
<form action="2krypto.php" method="post" enctype="multipart/form-data">
File to crypt:
<p></p>
<input type="file" name="fileToUpload" id="fileToUpload"/>
<p></p>
Text with to crypt: <input type="text" name="passphrase"/>
<p></p>
<input type="hidden" name="method" value="crypt" />
<input type="submit" value="Upload file" name="submit" />
</form>
<p></p>
<p></p>
<form action="2krypto.php" method="post" enctype="multipart/form-data">
File to decrypt:
<p></p>
<input type="file" name="fileToUpload" id="fileToUpload">
<p></p>
Text with to decrypt: <input type="text" name="passphrase"/>
<p></p>
<input type="hidden" name="method" value="decrypt"/>
<input type="submit" value="Upload file" name="submit"/>
</form>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</body>
</html>
2krypto.php
<?php
if(empty($_REQUEST['method'])||empty($_REQUEST['passphrase'])) {
exit(0);
}
$passphrase=$_REQUEST['passphrase'];
if(strlen($passphrase)<1) exit(0);
$target_dir = "files2/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
if (file_exists($target_file)) {
echo "File already exists.";
$uploadOk = 0;
}
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Your file is too large.";
$uploadOk = 0;
}
if ($uploadOk == 0) {
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
} else {
echo "There was an error uploading your file.";
}
}
$inputt = file_get_contents($target_file, true);
if($_REQUEST['method']=='crypt') {
$inputt = file_get_contents($target_file, true);
unlink($target_file);
$cindex=0;
$outputt="";
while(true) {
if($cindex==strlen($inputt)) {
break;
}
$char=chr((ord($inputt[$cindex])+ord($passphrase[($cindex)%strlen($passphrase)]))%256);
$outputt.=$char;
$cindex++;
}
if (file_exists($newf)) {
echo "File already exists.";
exit(0);
}
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$url2=$url;
$url .= $_SERVER['REQUEST_URI'];
$info = parse_url($url);
$info["path"]=dirname($info["path"]);
$newf=$target_dir . basename($_FILES["fileToUpload"]["name"]).'c';
file_put_contents($newf, $outputt);
$newurl=$info["path"].$newf;
echo "<a href='".$url2.$newurl."'>Download</a>";
chmod($newf, 0777);
} else if($_REQUEST['method']=='decrypt') {
$inputt = file_get_contents($target_file, true);
$cindex=0;
$outputt="";
while(true) {
if($cindex==strlen($inputt)) {
break;
}
$char=chr((ord($inputt[$cindex])-ord($passphrase[($cindex)%strlen($passphrase)]))%256);
$outputt.=$char;
$cindex++;
}
$newf=$target_dir . basename($_FILES["fileToUpload"]["name"]).'decry';
if (file_exists($newf)) {
echo "File already exists.";
exit(0);
}
file_put_contents($newf, $outputt);
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$url2=$url;
$url .= $_SERVER['REQUEST_URI'];
$info = parse_url($url);
$info["path"]=dirname($info["path"]);
$newurl=$info["path"].$newf;
echo "<a href='".$url2.$newurl."'>Download</a>";
chmod($newf, 0777);
}
?>
databasesystem.php
<?php
class Dbobj {
function getNameOfClass()
{
return static::class;
}
}
class Easydbsystem {
var $dbtables;
function gettime() {
return date("d.m.Y H:i:s");
}
function saveobjecttables() {
$tabls=$this->dbtables;
for($i=0; $i<count($tabls); $i++) {
$oc=$tabls[$i][0]->getNameOfClass();
if (file_exists($oc.".edb")) {
unlink($oc.".edb");
}
$b=serialize($tabls[$i]);
$fh = fopen($oc.".edb", "a");
fwrite($fh, $b);
fclose($fh);
chmod($oc.".edb", 0700);
}
return true;
}
function saveobjecttable($objcl) {
$tabls=$this->dbtables;
$obclindex=-1;
for($i=0; $i<count($tabls); $i++) {
if($tabls[$i][0]->getNameOfClass()==$objcl) {
$obclindex=$i;
break;
}
}
if (file_exists($objcl.".edb")) {
unlink($objcl.".edb");
}
$b=serialize($tabls[$obclindex]);
$fh = fopen($objcl.".edb", "a");
fwrite($fh, $b);
fclose($fh);
chmod($objcl.".edb", 0700);
return true;
}
function makearrayunique($array){
$duplicate_keys = array();
$tmp = array();
foreach ($array as $key => $val){
if (is_object($val))
$val = (array)$val;
if (!in_array($val, $tmp))
$tmp[] = $val;
else $duplicate_keys[] = $key;
}
foreach ($duplicate_keys as $key)
unset($array[$key]);
return $array;
}
function deleteduplicates() {
$ob=$this->dbtables;
for($i=0; $i<count($ob); $i++) {
$o12=$this->makearrayunique($ob[$i]);
$ob[$i]=$o12;
}
$this->saveobjecttables();
}
function deleteduplicatescl($objcl) {
$ob=$this->dbtables;
$obclindex=-1;
for($i=0; $i<count($ob); $i++) {
if($ob[$i][0]->getNameOfClass()==$objcl) {
$obclindex=$i;
break;
}
}
$o12=$this->makearrayunique($ob[$obclindex]);
$ob[$obclindex]=$o12;
$this->dbtables=$ob;
$this->saveobjecttable($objcl);
}
function loadobjecttables() {
$dbtables = array();
foreach (glob("*.edb") as $file) {
$path_parts = pathinfo($file);
if(!class_exists($path_parts['filename'])) {
continue;
}
$file1 = file_get_contents($file, true);
$dbtables[] = unserialize($file1);
}
$this->dbtables=$dbtables;
}
function deleteotable($otabname) {
if (file_exists($otabname.".edb")) {
unlink($otabname.".edb");
}
$this->loadobjecttables();
}
function insertobject($obj) {
$this->loadobjecttables();
$oclass=$obj->getNameOfClass();
$tabls=$this->dbtables;
$oarridx=-1;
for($i=0; $i<count($tabls); $i++) {
if($tabls[$i][0]->getNameOfClass()==$oclass) {
$oarridx=$i;
}
}
if($oarridx==-1) return false;
$tabls[$oarridx][]=$obj;
unlink($oclass.".edb");
$b=serialize($tabls[$oarridx]);
$fh = fopen($oclass.".edb", "a");
fwrite($fh, $b);
fclose($fh);
chmod($oclass.".edb", 0700);
}
function objectClassestoarray($objectA,
$objectB) {
$new_object = array();
foreach($objectA as $property => $value) {
$new_object[$property]=$value;
}
foreach($objectB as $property => $value) {
$new_object[$property]=$value;
}
return $new_object;
}
function query($query) {
$this->loadobjecttables();
$ovars=array();
$objects=$this->dbtables;
for($i=0; $i<count($objects); $i++) {
$ovars[]=array_keys(get_object_vars($objects[$i][0]));
}
$mches=array();
$results=null;
$exitf=false;
for($i=0; $i<count($objects); $i++) {
if($exitf) break;
for($j=0; $j<count($ovars); $j++) {
if($exitf) break;
if(!class_exists($objects[$i][0]->getNameOfClass())) continue;
if(preg_match("/^get \* from ".$objects[$i][0]->getNameOfClass().";$/",$query)) {
$objectsList = [];
foreach ($objects[$i] as $obj) {
$objectsList[] = (array)$obj;
}
return $objectsList;
$exitf=true;
}
}
}
for($i=0; $i<count($objects); $i++) {
if($exitf) break;
for($j=0; $j<count($ovars); $j++) {
if($exitf) break;
if(!class_exists($objects[$i][0]->getNameOfClass())) continue;
if(preg_match("/^get ".$ovars[$i][$j]." from ".$objects[$i][0]->getNameOfClass().";$/",$query)) {
return array_column($objects[$i], $ovars[$i][$j]);
$exitf=true;
}
}
}
$outp=array();
for($i=0; $i<count($objects); $i++) {
if($exitf) break;
for($j=0; $j<count($ovars[$i]); $j++) {
if($exitf) break;
for($k=0; $k<count($objects); $k++) {
if($exitf) break;
for($l=0; $l<count($ovars[$k]); $l++) {
if($exitf) break;
if(!class_exists($objects[$i][0]->getNameOfClass())) continue;
if(!class_exists($objects[$k][0]->getNameOfClass())) continue;
if(preg_match("/^get \* from ".$objects[$i][0]->getNameOfClass()." join ".$objects[$k][0]->getNameOfClass().
" on \(".$objects[$i][0]->getNameOfClass()."\.".$ovars[$i][$j]."\=".$objects[$k][0]->getNameOfClass().
"\.".$ovars[$k][$l]."\);$/",$query)) {
for($ii=0; $ii<count($objects[$i]); $ii++) {
for($ii2=0; $ii2<count($objects[$k]); $ii2++) {
if($objects[$i][$ii]->{$ovars[$i][$j]}==$objects[$k][$ii2]->{$ovars[$k][$l]}) {
$oobj = $this->objectClassestoarray($objects[$i][$ii], $objects[$k][$ii2]);
$outp[]=$oobj;
}
}
}
$exitf=true;
}
}
}
}
}
for($k=0; $k<count($objects); $k++) {
if($exitf) break;
for($l=0; $l<count($ovars[$k]); $l++) {
if($exitf) break;
for($l2=0; $l2<count($ovars[$k]); $l2++) {
if($exitf) break;
if(!class_exists($objects[$k][0]->getNameOfClass())) continue;
if(preg_match("/^get \* from ".$objects[$k][0]->getNameOfClass()." where ".$ovars[$k][$l]."\=(.*) and ".$ovars[$k][$l2]."\=(.*);$/",$query, $matches)) {
for($ii2=0; $ii2<count($objects[$k]); $ii2++) {
if($objects[$k][$ii2]->{$ovars[$k][$l]}==$matches[1]&&$objects[$k][$ii2]->{$ovars[$k][$l2]}==$matches[2]) {
$oobj = (array)$objects[$k][$ii2];
$outp[]=$oobj;
}
}
$exitf=true;
}
}
}
}
for($k=0; $k<count($objects); $k++) {
if($exitf) break;
for($l=0; $l<count($ovars[$k]); $l++) {
if($exitf) break;
if(!class_exists($objects[$k][0]->getNameOfClass())) continue;
if(preg_match("/^get \* from ".$objects[$k][0]->getNameOfClass()." where ".$ovars[$k][$l]."\=(.*);$/",$query, $matches)) {
for($ii2=0; $ii2<count($objects[$k]); $ii2++) {
if($objects[$k][$ii2]->{$ovars[$k][$l]}==$matches[1]) {
$oobj = (array)$objects[$k][$ii2];
$outp[]=$oobj;
}
}
$exitf=true;
}
}
}
if(count($outp)>0) {
return $outp;
}
return $mches;
}
}
?>
findlastmdate.php
<?php
include("dbref.php");
class Msg extends Dbobj{
var $text;
}
$mydb=new Easydbsystem();
$mydb->loadobjecttables();
$texists=false;
$t1=$mydb->dbtables;
$mdates=array();
for($i=0; $i<count($t1);$i++) {
if($t1[$i][0]->getNameOfClass()=="Msg") {
$texists=true;
break;
}
}
if($texists==true) {
$t2=$mydb->query("get text from Msg;");
for($i=0; $i<count($t2);$i++) {
$date12=date("d.m.Y H:i:s", strtotime(substr($t2[$i], 0, 19)));
$d_start = new DateTime($date12);
$mdates[]=$d_start;
}
echo $mdates[count($mdates)-1]->format('d.m.Y H:i:s');;
} else {
echo "";
}
?>
func.php
<?php
function rrmdir($dir) {
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? rrmdir("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
?>
ilist.php
<?php
include("dbref.php");
class Msg extends Dbobj{
var $text;
}
class Inimene extends Dbobj{
var $name;
var $time;
}
$mydb=new Easydbsystem();
$mydb->loadobjecttables();
$texists=false;
$t1=$mydb->dbtables;
$ilist=array();
$itidx=-1;
for($i=0; $i<count($t1);$i++) {
if($t1[$i][0]->getNameOfClass()=="Inimene") {
$texists=true;
$itidx=$i;
break;
}
}
$newi=array();
if($itidx>-1) {
for($i=0; $i<count($t1[$itidx]);$i++) {
$date12=date("d.m.Y H:i:s", strtotime($t1[$itidx][$i]->time));
$dtime = new DateTime($date12);
$datenow=date("d.m.Y H:i:s");
$datenow=date( 'd.m.Y H:i:s', strtotime( '+3 hour' , strtotime($datenow) ) );
$dtimenow = new DateTime($datenow);
$diff = $dtimenow->getTimestamp() - $dtime->getTimestamp();
if($diff<60*15) {
$newi[]=$t1[$itidx][$i];
}
}
if(count($newi)==0) {
unset($t1[$itidx]);
unlink("Inimene.edb");
$itidx=-1;
} else {
$t1[$itidx]=$newi;
$mydb->dbtables=$t1;
$mydb->saveobjecttable("Inimene");
}
}
if($texists==true) {
$t2=$mydb->query("get name from Inimene;");
for($i=0; $i<count($t2);$i++) {
$ilist[]=$t2[$i];
}
} else {
}
$result = array_unique($ilist);
$List = implode(', ', $result);
if(substr($List,strlen($List)-2, 2)==", ") {
$List=substr($List, 0, strlen($List)-2);
}
echo $List;
?>
index.php
<html>
<head>
<style>
input {
color: blue;
}
body {
background-color: #3a4dff;
background-repeat: repeat-y;
}
.main12 {
text-decoration:none;
color: blue;
background-color: white;
border: 1px solid white;
border-radius: 10px 10px;
padding: 5px;
font-weight:bold;
}
.main1 {
text-decoration:none;
color: blue;
background-color: white;
border: 1px solid white;
border-radius: 5px 5px;
padding: 5px;
font-weight:bold;
width:275px;
}
.main2 {
color: white;
}
.main3 {
text-decoration:none;
color: blue;
background-color: white;
border: 1px solid white;
border-radius: 5px 5px;
padding: 5px;
font-weight:bold;
width:100px;
}
</style>
</head>
<body>
<h1 class="main1">The place for all people.</h1>
<?php
include("func.php");
$dirs = array_filter(glob('*'), 'is_dir');
$cannotcreate=false;
/*
if(count($dirs)>60) {
$cannotcreate=true;
}
*/
if(!empty($_POST['rname'])&$cannotcreate==false) {
$_POST['rname'] = str_replace(' ', 'space21326', $_POST['rname']);
$_POST['rname'] = str_replace(',', 'comma21326', $_POST['rname']);
mkdir($_POST['rname'], 0755);
$file = 'index2.php';
$newfile = 'index.php';
if (!copy($file, $_POST['rname'].'/'.$newfile)) {
echo "Error\n";
}
chmod($_POST['rname'].'/'.$newfile, 0744);
$file = 'refofdbsys.php';
$newfile = 'dbref.php';
if (!copy($file, $_POST['rname'].'/'.$newfile)) {
echo "Error\n";
}
$file = 'renewing.php';
$newfile = 'renewing.php';
if (!copy($file, $_POST['rname'].'/'.$newfile)) {
echo "Error\n";
}
chmod($_POST['rname'].'/'.$newfile, 0744);
$file = 'ilist.php';
$newfile = 'ilist.php';
if (!copy($file, $_POST['rname'].'/'.$newfile)) {
echo "Error\n";
}
chmod($_POST['rname'].'/'.$newfile, 0744);
$file = 'findlastmdate.php';
$newfile = 'findlastmdate.php';
if (!copy($file, $_POST['rname'].'/'.$newfile)) {
echo "Error\n";
}
chmod($_POST['rname'].'/'.$newfile, 0744);
$file = 'func.php';
$newfile = 'func.php';
if (!copy($file, $_POST['rname'].'/'.$newfile)) {
echo "Error\n";
}
chmod($_POST['rname'].'/'.$newfile, 0744);
}
$dirs = array_filter(glob('*'), 'is_dir');
if(count($dirs)>0) {
echo "<h2 class='main2'>Topics</h2>";
}
$dirs = array_filter(glob('*'), 'is_dir');
foreach ($dirs as $file) {
$file2= str_replace('space21326', ' ', $file);
$file2= str_replace('comma21326', ',', $file2);
if($file=="files") continue;
if($file=="files2") continue;
$dir1='//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$output = file_get_contents('http:'.$dir1.$file.'/findlastmdate.php');
if($output!="") {
$date12=date("d.m.Y H:i:s", strtotime($output));
$d_start = new DateTime($date12);
$currentdate = date('d.m.Y H:i:s', time());
$d_end = new DateTime($currentdate);
$diff = $d_start->diff($d_end);
$delete1=false;
if(!($diff->format('%d')<1000||$diff->format('%d')==1000&&$diff->format('%h')<1)) $delete1=true;
if($delete1) {
rrmdir('/'.$file);
continue;
}
}
echo '<a class="main12" href=\'http:'.$dir1.$file.'\'>'.$file2.'</a>';
echo "<p></p>";
$path_parts = pathinfo($file.'/Msg.edb');
if(!class_exists($path_parts['filename'])) {
continue;
}
}
?>
<p style="height:50px;"> </p>
<form method="POST">
<input name="rname"/>
<input type="submit" class="main3" value="Make a topic"/>
</form>
<p style="color: white; width: 438px;">
In addition, it is possible to share files under */1index.php. Files go to /files.
If you want to share a picture file, then change extension to other file type.
And it's possible also to crypt files with passphrase under /2index.php.
</p>
</body>
</html>
index2.php
<html>
<head>
<style>
input {
color: blue;
}
body {
background-color: #3a4dff;
background-repeat: repeat-y;
color: blue;
}
.main1 {
text-decoration:none;
color: blue;
background-color: white;
border: 1px solid white;
border-radius: 5px 5px;
padding: 5px;
font-weight:bold;
width:100px;
}
.main2 {
color: blue;
margin-top:-15px;
}
.main3 {
text-decoration:none;
color: blue;
background-color: white;
border: 1px solid white;
border-radius: 5px 5px;
padding: 5px;
font-weight:bold;
width:100px;
}
.main4 {
color: blue;
width: 140px;
}
.main5 {
color: blue;
margin-top:-15px;
margin-bottom:1px;
}
.main6 {
color: blue;
margin-top:15px;
width:600px;
overflow-wrap: break-word;
}
.main7 {
margin-bottom:1px;
}
.k12 {
width: 538px;
height: 33px;
margin-top:-15px;
overflow-wrap: break-word;
}
textarea {
color: blue;
}
form {
line-height: 0.95;
}
.a1 {
line-height: 0.95;
width: 561px;
height: 357px;
overflow-y: auto;
overflow-x: hidden;
background-color: white;
overflow-wrap: break-word;
}
.a1 p {
height:0.001%;
margin-bottom:-15px;
}
#nameslist {
margin-bottom:15px;
}
</style>
</head>
<body>
<?php
include("func.php");
include("dbref.php");
class Msg extends Dbobj{
var $text;
}
class Inimene extends Dbobj{
var $name;
var $time;
}
class Picture extends Dbobj{
var $name;
var $time;
}
$mydb=new Easydbsystem();
$mydb->loadobjecttables();
$itime2=$mydb->gettime();
$itime2=date( 'd.m.Y H:i:s', strtotime( '+3 hour' , strtotime($itime2) ) );
if(!is_dir("uploads")) {
mkdir("uploads", 0777);
}
$files1 = scandir("uploads");
if(count($files1)>27) {
rrmdir("uploads");
mkdir("uploads", 0777);
}
$pic_uploaded=false;
if(isset($_POST["submit"])&&$_FILES["fileToUpload"]['error']==0) {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
$uploadOk = 1;
} else {
$uploadOk = 0;
}
}
if (file_exists($target_file)) {
$uploadOk = 0;
}
if ($_FILES["fileToUpload"]["size"] > 6500000) {
$uploadOk = 0;
}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
$uploadOk = 0;
}
if ($uploadOk == 0) {
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
$pic_uploaded=true;
} else {
}
}
$newpic=null;
$tabls0=null;
if($pic_uploaded==true) {
$tabls0=$mydb->dbtables;
$picstidx=-1;
if($tabls0!=null) {
for($i=0; $i<count($tabls0); $i++) {
$oc0=$tabls0[$i][0]->getNameOfClass();
if ($oc0=="Picture") {
$picstidx=$i;
}
}
if($picstidx==-1) {
$picstidx=count($tabls0);
$tabls0[]=array();
}
} else {
$tabls0=array();
$tabls0[]=array();
$picstidx=0;
}
$newpic=new Picture();
$newpic->name=basename( $_FILES["fileToUpload"]["name"]);
$newpic->time=$itime2;
$tabls0[$picstidx][]=$newpic;
$mydb->dbtables=$tabls0;
$mydb->saveobjecttable("Picture");
}
}
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$url .= $_SERVER['REQUEST_URI'];
$info = parse_url($url);
$info["path"]=dirname($info["path"]);
$new_url = $info["scheme"]."://".$info["host"].$info["path"];
if(!empty($info["query"])) $new_url .= "?".$info["query"];
$new_url=substr($new_url,0,strlen($new_url)-1);
if(!empty($_SERVER["SERVER_PORT"])) $new_url .=":".$_SERVER["SERVER_PORT"];
if(!empty($info["fragment"])) $new_url .= "#".$info["fragment"];
echo "<a class='main1' href='".$new_url."'>Return to main page</a><p></p>";
function strip($var) {
$allowed = '<font>';
return strip_tags($var, $allowed);
}
function closetags ( $html )
{
preg_match_all ( "#<([a-z]+)( .*)?(?!/)>#iU", $html, $result );
$openedtags = $result[1];
preg_match_all ( "#</([a-z]+)>#iU", $html, $result );
$closedtags = $result[1];
$len_opened = count ( $openedtags );
if( count ( $closedtags ) == $len_opened )
{
return $html;
}
$openedtags = array_reverse ( $openedtags );
for( $i = 0; $i < $len_opened; $i++ )
{
if ( !in_array ( $openedtags[$i], $closedtags ) )
{
$html .= "</" . $openedtags[$i] . ">";
}
else
{
unset ( $closedtags[array_search ( $openedtags[$i], $closedtags)] );
}
}
return $html;
}
$msg=new Msg();
$name1 = strip_tags($_POST['text0']);
if($name1!="") {
$name1=substr($name1,0, 39);
}
$addline=true;
$tabls=$mydb->dbtables;
$time=null;
$tidx=-1;
$nooutput=false;
if($tabls!=null) {
$foundtime=false;
for($i=0; $i<count($tabls); $i++) {
$oc=$tabls[$i][0]->getNameOfClass();
if ($oc=="Inimene") {
$times1=array();
for($ii=0; $ii<count($tabls[$i]); $ii++) {
$times1[]=$tabls[$i][$ii]->time;
}
$latestt=max(array_map('strtotime', $times1));
$time=date('d.m.Y H:i:s', $latestt);
$foundtime=true;
}
}
if($foundtime) {
$dtimenow = new DateTime($itime2);
$dtime = new DateTime($time);
$diff = $dtimenow->getTimestamp() - $dtime->getTimestamp();
if($diff<1) {
$nooutput=true;
}
}
if(!$foundtime) {
$time=$itime2;
}
} else {
$time=$itime2;
}
$ind=array();
$itidx=-1;
if($tabls!=null) {
for($i=0; $i<count($tabls); $i++) {
$oc=$tabls[$i][0]->getNameOfClass();
if ($oc=="Inimene") {
$ind=$tabls[$i];
$itidx=$i;
}
}
}
if($ind!=null) {
if(count($ind)>199) {
echo "Topic full(200).";
exit(0);
}
}
$itime=$_POST['itime'];
if($itime==""||$itime==null) {
$itime=$mydb->gettime();
$itime=date( 'd.m.Y H:i:s', strtotime( '+3 hour' , strtotime($itime) ) );
$time=$itime;
}
if($nooutput==false) {
$currenti=null;
$iexists=false;
for($i=0; $i<count($ind); $i++) {
if($ind[$i]->time==$itime) {
$currenti=$ind[$i];
}
}
for($i=0; $i<count($ind); $i++) {
if($ind[$i]->name==$name1) {
$iexists=true;
}
}
if(count($ind)>0) {
if($name1!=""&&$currenti==null&&$iexists==false) {
$curi=new Inimene();
$curi->name=$name1;
$curi->time=$itime;
$ind[]=$curi;
$tabls[$itidx]=$ind;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Inimene");
$currenti=$curi;
} if($name1!=""&&$currenti==null&&$iexists==true) {
$name1="";
$addline=false;
} else if($name1!=""&&$currenti->name!=""&&$name1!=$currenti->name&&$iexists==false) {
$currenti->name=$name1;
$currenti->time=$itime2;
$itime=$itime2;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Inimene");
} else if($name1!=""&&$currenti->name!=""&&$name1!=$currenti->name&&$iexists==true) {
$name1=$currenti->name;
$addline=false;
} else if($name1!=""&&$currenti->name!=""&&$name1==$currenti->name) {
$currenti->time=$itime2;
$itime=$itime2;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Inimene");
} else {
$addline=false;
}
} else {
if($name1!=""&&$iexists==false&&$currenti!=null) {
$curi=new Inimene();
$curi->name=$name1;
$curi->time=$itime2;
$itime=$itime2;
$ind12=array();
$ind12[]=$curi;
$tabls[]=$ind12;
$mydb->dbtables=$tabls;
$mydb->saveobjecttables();
} if($name1!=""&&$iexists==false&&$currenti==null) {
$curi=new Inimene();
$curi->name=$name1;
$curi->time=$itime2;
$itime=$curi->time;
$ind12=array();
$ind12[]=$curi;
$tabls[]=$ind12;
$mydb->dbtables=$tabls;
$mydb->saveobjecttables();
}
else if($name1!=""&&$iexists==true) {
$name1="";
$addline=false;
} else {
$addline=false;
}
}
$msg1=strip($_POST['text1']);
$msg1 = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $msg1);
$msg12=$msg1;
$msg->text=$itime2." ".$name1.": ".$msg1;
$msg->text=substr($msg->text,0, 216345);
$msg->text=closetags($msg->text);
$texists=false;
$msgtidx=0;
$t1=$mydb->dbtables;
for($i=0; $i<count($t1);$i++) {
if($t1[$i][0]->getNameOfClass()=="Msg") {
$msgtidx=$i;
$texists=true;
if(count($t1[$i])>165) {
$arr12 = array_slice($t1[$i], -165);
$t1[$i]=$arr12;
$mydb->dbtables=$t1;
$mydb->saveobjecttable("Msg");
break;
}
break;
}
}
$oput="";
$tabls=$mydb->dbtables;
if(!empty($_POST['text1'])&&$addline==true) {
if (strlen(trim($msg1)) != 0&&$pic_uploaded==true) {
if($texists==false) {
$aone=array();
$imgsize = getimagesize("uploads/".$newpic->name);
$width=$imgsize[0];
$height=$imgsize[1];
if($width>380) {
$multip=$width/380;
$width=380;
$height=$height/$multip;
}
$msg->text.="<p></p><img src='uploads/".$newpic->name."' style='width: ".$width."px; height: ".$height."px;'/>";
$aone[]=$msg;
$tabls[]=$aone;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Msg");
} else {
$imgsize = getimagesize("uploads/".$newpic->name);
$width=$imgsize[0];
$height=$imgsize[1];
if($width>380) {
$multip=$width/380;
$width=380;
$height=$height/$multip;
}
$msg->text.="<p></p><img src='uploads/".$newpic->name."' style='width: ".$width."px; height: ".$height."px;'/>";
$tabls[$msgtidx][]=$msg;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Msg");
}
} else if (strlen(trim($msg1)) != 0&&$pic_uploaded==false) {
if($texists==false) {
$aone=array();
$aone[]=$msg;
$tabls[]=$aone;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Msg");
} else {
$tabls[$msgtidx][]=$msg;
$mydb->dbtables=$tabls;
$mydb->saveobjecttable("Msg");
}
}
$t2=$mydb->query("get text from Msg;");
for($i=0; $i<count($t2);$i++) {
$oput.=$t2[$i]."<p></p>";
}
} else {
if($texists==true) {
$t2=$mydb->query("get text from Msg;");
for($i=0; $i<count($t2);$i++) {
$oput.=$t2[$i]."<p></p>";
}
}
}
}
?>
<div class="a1" spellcheck="false">
<?php echo $oput;
?>
</div>
<p></p>
<form method="POST" enctype="multipart/form-data">
<input name="itime" id="itime" type="hidden" value="<?php echo $itime; ?>"/>
<p class="main2">Name: <input name="text0" id="text0" type="text" style="width: 114px;" value="<?php echo $name1; ?>"> </p>
<p class="main2">Text:</p>
<textarea class="k12" name="text1" id="text1" type="text">
<?php
if($nooutput==true) {
echo $msg12;
}
?>
</textarea>
<p></p>
<p class="main5">Photo:</p>
<input type="file" class="main4" name="fileToUpload" id="fileToUpload">
<input type="submit" name="submit" class="main3" value="Send"/>
</form>
<p></p>
<p class="main2">In:</p>
<div class="main2" id="ilist">
</div>
<script>
function nl2br (str, is_xhtml) {
if (typeof str === 'undefined' || str === null) {
return '';
}
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
if (!String.prototype.unescapeHTML) {
String.prototype.unescapeHTML = function() {
return this.replace(/&[#\w]+;/g, function (s) {
var entityMap = {
"&": "&",
"<": "<",
">": ">",
'"': '"',
''': "'",
'/': "/",
' ': " "
};
return entityMap[s];
});
};
}
function renewing() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
if (xmlhttp.status == 200) {
xmlhttp.responseText=nl2br(xmlhttp.responseText);
var a111=xmlhttp.responseText;
a111=a111.unescapeHTML();
document.getElementsByClassName("a1")[0].innerHTML = a111;
}
else if (xmlhttp.status == 400) {
alert('Error 400');
}
else {
alert('Not 200 returned');
}
}
};
xmlhttp.open("GET", "renewing.php", false);
xmlhttp.setRequestHeader('Cache-Control', 'no-cache');
xmlhttp.send();
}
function renewingilist() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
if (xmlhttp.status == 200) {
document.getElementById("ilist").innerHTML = xmlhttp.responseText;
}
else if (xmlhttp.status == 400) {
alert('Error 400');
}
else {
alert('Not 200 returned');
}
}
};
xmlhttp.open("GET", "ilist.php", false);
xmlhttp.setRequestHeader('Cache-Control', 'no-cache');
xmlhttp.send();
}
var textarea = document.getElementsByClassName("a1")[0];
setInterval(function(){
renewing();
}, 1578);
setInterval(function(){
renewingilist();
}, 3953);
textarea.scrollTop = textarea.scrollHeight;
setInterval(function(){
textarea.scrollTop = textarea.scrollHeight;
}, 3125);
setInterval(function(){
var namearea = document.getElementById("text0");
var isFocused = (document.activeElement === namearea);
if(isFocused) {
} else {
document.getElementById('text1').focus();
}
}, 6871);
</script>
</body>
</html>
refofdbsys.php
<?php
include("../databasesystem.php");
?>
renewing.php
<?php
include("dbref.php");
class Msg extends Dbobj{
var $text;
}
$mydb=new Easydbsystem();
$mydb->loadobjecttables();
$texists=false;
$t1=$mydb->dbtables;
for($i=0; $i<count($t1);$i++) {
if($t1[$i][0]->getNameOfClass()=="Msg") {
$texists=true;
break;
}
}
if($texists==true) {
$t2=$mydb->query("get text from Msg;");
for($i=0; $i<count($t2);$i++) {
echo $t2[$i]."<p></p>";
}
} else {
}
?>
A man ahead of time a.k.a. Kristjan Robam
372 6861327
kristjan 12 9 19 83 @ g mai l . c o m
[toc] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2020-06-24 23:34 +0200 |
| Message-ID | <hlhv7hF67icU1@mid.individual.net> |
| In reply to | #18290 |
On 24/06/2020 19.41, kristjan1291983@gmail.com wrote:
> Files:
Please register a free account at github.com and store your projects
there, all you need to do is give the link to the repository in question
and then people will always manage to see the latest version of your
project instead of having to go through a million posts.
> 1index.php
>
> <!DOCTYPE html>
> <html>
> <body>
>
> <form action="1upload.php" method="post" enctype="multipart/form-data">
> File to upload:
> <p></p>
> <input type="file" name="fileToUpload" id="fileToUpload"/>
> <p></p>
> <input type="submit" value="Upload file" name="submit" />
>
> </form>
>
> <p></p>
> <p></p>
>
> <p>Files in /files :</p>
> <?php
>
> $dirs = array_filter(glob('*'), 'is_dir');
> $fexists=false;
> foreach ($dirs as $k=>$v) {
> if($v=="files") $fexists=true;
> }
don't keep on looping when you have found what you were looking for,
break as soon as you have found the directory, but you should ensure
it's a directory and not a file/symlink/socket/...
I do think you can do this faster just by checking if the directory
exists in first place, you know it's in the same directory and it's
called files.
> if(count($files1)>1000) {
> rrmdir("files");
> mkdir("files", 0755);
> }
So anyone can delete all the files, just spam your upload script 1000
times. Most filesystems do handle far more files than just 1000, sure
your system has performance issues.
> if(empty($_REQUEST['method'])||empty($_REQUEST['passphrase'])) {
> exit(0);
> }
>
> $passphrase=$_REQUEST['passphrase'];
>
> if(strlen($passphrase)<1) exit(0);
You already checked that it was empty, so why do it again here?
By the way, exit(0) is an ugly way to stop, you should always provide
information of some kind to the user, for example missing pass phrase.
> $target_dir = "files2/";
> $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
> $uploadOk = 1;
>
> if (file_exists($target_file)) {
> echo "File already exists.";
> $uploadOk = 0;
> }
> if ($_FILES["fileToUpload"]["size"] > 500000) {
> echo "Your file is too large.";
> $uploadOk = 0;
> }
> if ($uploadOk == 0) {
> } else {
> if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
>
> } else {
> echo "There was an error uploading your file.";
> }
> }
>
>
> $inputt = file_get_contents($target_file, true);
>
>
> if($_REQUEST['method']=='crypt') {
There is support for encryption/decryption in php, see
openssl_encrypt/openssl_decrypt. To make the encryption better, add a salt.
> $url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
you should prevent the code working on insecure connections, otherwise
anyone can get hold of the pass phrase by sniffing the traffic.
...
--
//Aho
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web