$value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$valid = pathinfo($path, PATHINFO_EXTENSION) == "zip";
if ($valid)
break;
}
}
return $valid;
}
/**
* Get all directories in the specified path and creates them on the page
* @param string $path path to search directories in
*/
function createDirectories($path)
{
$path = photoRoot . $path;
$displayedItems = 0;
$folders = getDirectories($path);
foreach ($folders as $key => $value) {
$folderTitle = $value;
$photos = getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value);
$albums = getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value);
$folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value;
?>
= $folderTitle ?>
1) {
echo " - ".$photos." photos";
} elseif ($photos == 1) {
echo " - ".$photos ." photo";
} else {
echo " - "."vide";
} ?>
1) {
echo " - ".$albums." albums";
} elseif ($albums == 1) {
echo " - ".$albums." album";
} ?>
$value) {
$realPath = realpath($path . DIRECTORY_SEPARATOR . $value);
$realPath_no_thumb = realpath($path_no_thumb . DIRECTORY_SEPARATOR . $value);
if (isValidImage($realPath) AND isValidImage($realPath_no_thumb)) {
$imageSrc = $path . DIRECTORY_SEPARATOR . $value;
$img_no_thumb = $path_no_thumb . DIRECTORY_SEPARATOR . $value;
$imageId = "photo-" . $displayedItems;
?> $value) {
$realPath = realpath($path . DIRECTORY_SEPARATOR . $value);
if (isValidDirectory($realPath, $value)) {
array_push($folders, $value);
}
}
return $folders;
}
/**
* Counts directories in the specified folder
* @param string $path path to search directories in
* @return int directories count
*/
function getDirectoriesCount($path)
{
$files = scandir($path);
$dirCount = 0;
foreach ($files as $key => $value) {
$realPath = realpath($path . DIRECTORY_SEPARATOR . $value);
if (isValidDirectory($realPath, $value)) {
$dirCount++;
}
}
return $dirCount;
}
/**
* Counts images in the specified folder
* @param string $path path to search photos in
* @return int photo count
*/
function getPhotoCount($path)
{
$files = scandir($path);
$fileCount = 0;
foreach ($files as $key => $value) {
$realPath = realpath($path . DIRECTORY_SEPARATOR . $value);
if (isValidImage($realPath)) {
$fileCount++;
}
}
return $fileCount;
}
/**
* Get the count of all directories, recursively from the path specified
* @param string $path root for search
* @return int total number of directories
*/
function getTotalAlbumCount($path)
{
$folders = getDirectories($path);
$total = sizeof($folders);
foreach ($folders as $key => $value) {
$total += getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value);
}
return $total;
}
function getTotalPhotoCount($path)
{
$folders = getDirectories($path);
$total = getPhotoCount($path);
foreach ($folders as $key => $value) {
$total += getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value);
}
return $total;
}
/**
* Check if the given image is valid
* @param string $imagePath absolute path of the image
* @return bool True if the file is a jpg, jpeg or png, false otherwise
*/
function isValidImage($imagePath)
{
$ext = pathinfo($imagePath, PATHINFO_EXTENSION);
return !is_dir($imagePath) && ($ext == "jpg" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG" || $ext == "png" || $ext == "PNG");
}
/**
* Check if the given folder is valid (is not '.' or '..')
* @param string $directoryPath directory path
* @param string $directory directory name
* @return bool True if the directory is valid, false otherwise
*/
function isValidDirectory($directoryPath, $directory)
{
return is_dir($directoryPath) && $directory != "." && $directory != ".." && substr($directory, 0, 1) !== ".";
}
/**
* Creates buttons representing the actual path for easier navigation
* @param string $path Actual Path
*/
function generatePath($path)
{
$folders = explode(DIRECTORY_SEPARATOR, $path);
$currentPath = "";
$pathTitle = "Menu";
$pathLink = "?" . urlParam . "=";
echo '
'.$pathTitle.'';
foreach ($folders as $value) {
if ($value != "") {
$pathTitle = $value;
$currentPath .= DIRECTORY_SEPARATOR . $value;
$pathLink = "?" . urlParam . "=" . $currentPath;
echo ' > '.$pathTitle.'';
}
}
}
//CAS
require_once("phpCAS-1.3.6/CAS.php");
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, "cas.insa-toulouse.fr", 443, 'cas', true);
// For production use set the CA certificate that is the issuer of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($cas_server_ca_cert_path);
// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
// force CAS authentication
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
// logout if desired
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}
?>
Vous êtes connecté !
Connecté en tant que : .
Vous pouvez vous déconnecter en cliquant ici :Se déconnecter
Clique sur le dossier de ton choix pour afficher les photos. Il faut que tu sois inscrit à l'INSA pour pouvoir
les regarder (et oui, pas de spoiler).
Il te suffit ensuite de cliquer sur la photo que tu veux télécharger.
Si tu ne peux pas voir les photos (la fenêtre pour entrer le mot de passe ne s'affiche pas), ouvre cette page avec un autre navigateur.