Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require 'head.php';?>
- <?php
- function uploadFile($fileToUpload,$targetDir,$num)
- {
- if(isset($_FILES[$fileToUpload])){
- $errors= array();
- $file_name = $_FILES[$fileToUpload]['name'];
- $file_tmp = $_FILES[$fileToUpload]['tmp_name'];
- $file_ext=strtolower(end(explode('.',$_FILES[$fileToUpload]['name'])));
- if(empty($errors)==true) {
- move_uploaded_file($file_tmp,$targetDir.$num.".".$file_ext);
- return true;
- }else{
- echo "no niestety ale nie";
- }
- }
- return false;
- }
- $username=$_POST[username];
- $password=md5($_POST[pass]);
- $found = false;
- $filepath = $strdata . $strhour[0] . $strhour[1];
- foreach (glob($dir."*",GLOB_ONLYDIR) as $dirname) {
- $info_file = fopen("$dirname/info", "r");
- // if (flock($info_file,LOCK_SH)) {
- $line = fgets($info_file);
- if(trim($line) == $username){
- $line = fgets($info_file);
- if(trim($line) == $password){
- $found = true;
- $strdata = str_replace("-","",$_POST[year]);
- $strhour = explode(":",$_POST[hour]);
- $filepath = $strdata.$strhour[0].$strhour[1].date('s');
- // $sem = sem_get(2);
- // sem_acquire($sem);
- $unique_num = "A00";
- while (file_exists("$dirname/$filepath".substr($unique_num),1,2)) {
- $unique_num++.PHP_EOL;
- }
- // sem_release($sem);
- $path = "$dirname/$filepath".substr($unique_num,1,2);
- $newfile = fopen($path, "w");
- if(flock($newfile,LOCK_EX)){
- fwrite($newfile,$_POST[content]);
- $filePom = 1;
- echo $path;
- while (true) {
- if (uploadFile("file" . $filePom,$path,$filePom)==false) break;
- $filePom = $filePom + 1;
- //uploadFile('file2',$path,"2");
- //uploadFile('file3',$path,"3");
- }
- flock($newfile,LOCK_UN);
- } else {
- echo "FLOCK ERROR";
- }
- fclose($newfile);
- echo "Wpis dodany";
- flock($info_file,LOCK_UN);
- }
- }
- // } else {
- // echo "ERROR FLOCK";
- // }
- fclose($info_file);
- }
- if($found==false){
- echo "Bledny uzytkownik/haslo";
- }
- ?>
- <?php require 'foot.php';?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement