. * * home.php * * Home of Puzzleu. * * @author Daniele Bonini * @copyrights (c) 2016, 2024, 5 Mode */ // CONSTANTS AND VARIABLE DECLARATION $CURRENT_VIEW = PUBLIC_VIEW; $CUDOZ = 1; $AVATAR_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . AVATAR_NAME; $CV_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "cv"; $FRIENDS_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "friends"; $BLOG_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "blog"; $GALLERY_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "gallery"; $MAGICJAR1_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar1"; $MAGICJAR2_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar2"; $MAGICJAR3_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar3"; $profilePic = APP_DEF_PROFILE_PIC; // PAGE PARAMETERS $lang = APP_DEF_LANG; $lang1 = substr(strip_tags(filter_input(INPUT_GET, "hl")??""), 0, 5); if ($lang1 !== PHP_STR) { $lang = $lang1; } $shortLang = getShortLang($lang); $blogSP = (int)substr(strip_tags(filter_input(INPUT_GET, "blogSP")??""), 0, 5); $password = filter_input(INPUT_POST, "Password")??""; $password = strip_tags($password); if ($password !== PHP_STR) { $hash = hash("sha256", $password . APP_SALT, false); if (defined("APP_" . strtoupper(AVATAR_NAME) . "_HASH")) { if ($hash !== constant("APP_" . strtoupper(AVATAR_NAME) . "_HASH")) { $password=PHP_STR; } } else { if ($hash !== APP_HASH) { $password=PHP_STR; } } // if ($hash !== APP_HASH) { // $password=PHP_STR; // } } if ($password !== PHP_STR) { $CURRENT_VIEW = ADMIN_VIEW; } else { $CURRENT_VIEW = PUBLIC_VIEW; } $magicJar1 = (int)substr(strip_tags(filter_input(INPUT_POST, "txtMagicJar1")??""), 0, 1); $magicJar2 = (int)substr(strip_tags(filter_input(INPUT_POST, "txtMagicJar2")??""), 0, 1); $magicJar3 = (int)substr(strip_tags(filter_input(INPUT_POST, "txtMagicJar3")??""), 0, 1); if ($CURRENT_VIEW === PUBLIC_VIEW ) { $MAXP = (int)substr(strip_tags(filter_input(INPUT_GET, "maxp")??""), 0, 2); if ($MAXP === 0) { $MAXP = APP_BLOG_WIDE_MAX_POSTS; } } function uploadNewRes() { global $AVATAR_PATH; global $CV_PATH; global $FRIENDS_PATH; global $BLOG_PATH; global $GALLERY_PATH; global $MAGICJAR1_PATH; global $MAGICJAR2_PATH; global $MAGICJAR3_PATH; global $magicJar1; global $magicJar2; global $magicJar3; //echo_ifdebug(true, "AVATAR_PATH#1="); //echo_ifdebug(true, $AVATAR_PATH); if (!empty($_FILES['files']['tmp_name'][0]) || !empty($_FILES['filesdd']['tmp_name'][0])) { $uploads = (array)fixMultipleFileUpload($_FILES['files']); if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) { $uploads = (array)fixMultipleFileUpload($_FILES['filesdd']); } //if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) { // echo("WARNING: No file uploaded."); // return; //} $google = "abcdefghijklmnopqrstuvwxyz"; if (count($uploads)>strlen($google)) { echo("WARNING: Too many uploaded files."); return; } $i=1; foreach($uploads as &$upload) { switch ($upload['error']) { case PHP_UPLOAD_ERR_OK: break; case PHP_UPLOAD_ERR_NO_FILE: echo("WARNING: One or more uploaded files are missing."); return; case PHP_UPLOAD_ERR_INI_SIZE: echo("WARNING: File exceeded INI size limit."); return; case PHP_UPLOAD_ERR_FORM_SIZE: echo("WARNING: File exceeded form size limit."); return; case PHP_UPLOAD_ERR_PARTIAL: echo("WARNING: File only partially uploaded."); return; case PHP_UPLOAD_ERR_NO_TMP_DIR: echo("WARNING: TMP dir doesn't exist."); return; case PHP_UPLOAD_ERR_CANT_WRITE: echo("WARNING: Failed to write to the disk."); return; case PHP_UPLOAD_ERR_EXTENSION: echo("WARNING: A PHP extension stopped the file upload."); return; default: echo("WARNING: Unexpected error happened."); return; } if (!is_uploaded_file($upload['tmp_name'])) { echo("WARNING: One or more file have not been uploaded."); return; } // name $name = (string)substr((string)filter_var($upload['name']), 0, 255); if ($name == PHP_STR) { echo("WARNING: Invalid file name: " . $name); return; } $upload['name'] = $name; // fileType $fileType = substr((string)filter_var($upload['type']), 0, 30); $upload['type'] = $fileType; // tmp_name $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300); if ($tmp_name == PHP_STR || !file_exists($tmp_name)) { echo("WARNING: Invalid file temp path: " . $tmp_name); return; } $upload['tmp_name'] = $tmp_name; //size $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12); if ($size == "") { echo("WARNING: Invalid file size."); return; } $upload["size"] = $size; $tmpFullPath = $upload["tmp_name"]; $originalFilename = pathinfo($name, PATHINFO_FILENAME); $originalFileExt = pathinfo($name, PATHINFO_EXTENSION); $fileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION)); $date = date("Ymd-His"); $rnd = mt_rand(1000000000, 9999999999); if ($originalFileExt!==PHP_STR) { $destFileName = $date . "-" . $rnd . substr($google, $i-1, 1) . "|" . str_replace(" ", "_", $originalFilename) . ".$fileExt"; } else { return; } //$CV_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "cv"; //$FRIENDS_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "friends"; //$BLOG_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "blog"; //$GALLERY_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "gallery"; $destPaths = []; $destFullPaths = []; if ($magicJar1 != 0) { $destPaths[] = $MAGICJAR1_PATH; $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName; } if ($magicJar2 != 0) { $destPaths[] = $MAGICJAR2_PATH; $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName; } if ($magicJar3 != 0) { $destPaths[] = $MAGICJAR3_PATH; $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName; } if (empty($destPaths)) { switch ($fileExt) { case "doc": case "docx": case "pdf": $destPaths[] = $CV_PATH; break; //case "txt": // $destPaths[] = $BLOG_PATH; // break; case "png": case "jpg": case "jpeg": case "gif": case "webp": $destPaths[] = $BLOG_PATH; break; default: $destPaths[] = $MAGICJAR1_PATH; break; } $destFullPaths[] = $destPaths[0] . DIRECTORY_SEPARATOR . $destFileName; } $iPath = 0; foreach($destFullPaths as $destFullPath) { if (file_exists($destFullPath)) { echo("WARNING: destination already exists"); exit(1); } if (filesize($tmpFullPath) > APP_FILE_MAX_SIZE) { echo("ERROR: file size(" . filesize($tmpFullPath) . ") exceeds app limit:" . APP_FILE_MAX_SIZE); exit(1); } if (!is_readable($AVATAR_PATH)) { mkdir($AVATAR_PATH, 0777); } if (!is_readable($destPaths[$iPath])) { mkdir($destPaths[$iPath], 0777); } $pattern = $destPaths[$iPath] . DIRECTORY_SEPARATOR . "*" . "|" . str_replace(" ", "_", $originalFilename) . ".$fileExt"; $aExistingPaths = glob($pattern); if (!empty($aExistingPaths)) { continue; } copy($tmpFullPath, $destFullPath); $iPath++; } // Cleaning up.. // Delete the tmp file.. unlink($tmpFullPath); $i++; } } else { //echo("WARNING: No file uploaded (err-pip-po)."); } } function writeFriends() { global $FRIENDS_PATH; $destPath = $FRIENDS_PATH; $s = filter_input(INPUT_POST, "f")??""; $s = strip_tags($s); if ($s != PHP_STR) { //echo($s); //exit(0); $friends=explode("|", $s); if (!is_readable($destPath)) { mkdir($destPath, 0777); } foreach($friends as $friend) { $a = explode("://",$friend); $s = $a[1]; $a = explode("/", $s); $friendName = $a[0] . ".txt"; file_put_contents($destPath . DIRECTORY_SEPARATOR . $friendName, $friend); } } } function grabProfileImage() { global $BLOG_PATH; $pattern = $BLOG_PATH . DIRECTORY_SEPARATOR . "*"; $aImagePaths = glob($pattern); if (isset($aImagePaths[0])) { $retval = basename($aImagePaths[0]); } else { $retval = null; } return $retval; } function startApp() { global $CURRENT_VIEW; global $profilePic; if ($CURRENT_VIEW == ADMIN_VIEW) { uploadNewRes(); writeFriends(); } $profilePic = grabProfileImage() ?? APP_DEF_PROFILE_PIC; //echo("profile pic=" . $profilePic); } startApp(); ?> <?PHP echo(APP_TITLE);?>



 


 
(($totPages - 1) * $MAXP)) { $nextPost = (($totPages - 1) * $MAXP); } if ($nextPost < 0) { $nextPost = 0; } $lastPost = (($totPages - 1) * $MAXP); if ($lastPost < 0) { $lastPost = 0; } // --- //echo("blogSP=".$blogSP); foreach ($aFilePaths as $filePath) { //echo("iCurEntry=".$iCurEntry); if ($iCurEntry<($blogSP+1)) { $iCurEntry++; continue; } if (($iEntry>$MAXP) || (!APP_PAGINATION && $iCurEntry>APP_BLOG_MAX_POSTS)) { break; } $orifilename = basename($filePath); $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION)); $date = explode("-",$orifilename)[0]; $time = explode("-",$orifilename)[1]; $time = left($time,2) . ":" . substr($time,2,2); if ($iEntry === count($aFilePaths) || $iEntry==$MAXP) { $marginbottom = "0px"; } else { $marginbottom = "5px"; } ?>
$iCurEntry)): ?> 1): ?>
 
 
(int)($MAXP / 3)): ?>
 
(int)(($MAXP+1) / 3)): ?>
 



   " style="text-align:left;width:25%;color:#000000;">
  
!
 
  A 5 Mode project and WYSIWYG system. .