Location: PHPKode > scripts > GigKalender > gallery/functions.php
<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/

  function checkIfOriginalIsPresent ( $Album, $ImageFileName )
  {
    global $AlbumsPathLocal;
    global $PossibleImageExtensions;
    $Array = explode ( '.', $ImageFileName );
    $ImageFileName = $Array[0];
    $PathOfOriginal = $AlbumsPathLocal.$Album.'/original/'.$ImageFileName;
    $amountPossibleImageExtensions = count($PossibleImageExtensions);
    for ($i=0; $i<$amountPossibleImageExtensions; $i++)
      if (is_file($PathOfOriginal.'.'.$PossibleImageExtensions[$i])) return $ImageFileName.'.'.$PossibleImageExtensions[$i];
    return false;
  }
  function getArrayOfAllAlbums ( $Directory )
  {
    $handle=opendir($Directory);
    $files = array();
    while ($file = readdir ($handle))
    if ($file != "." && $file != "..") { $files[] = $file; }
    array_multisort($files);
    return $files;
  }

  function countImages ( $Directory )
  {
    $handle=opendir($Directory);
    $files = array();
    while ($file = readdir ($handle))
    if ($file != "." && $file != "..") { $files[] = $file; }
    //natsort ( $files );
    return count($files);
  }

  function getTextFile ( $Album, $TextFile, $ImageFileName )
  {
    global $AlbumsPathLocal;
    global $PossibleTextExtensions;
    $Array = explode ( '.', $ImageFileName );
    $ImageFileName = $Array[0];


    if ($TextFile=='image') $TextPath = $AlbumsPathLocal.$Album.'/text/'.$ImageFileName;
    if ($TextFile=='title') $TextPath = $AlbumsPathLocal.$Album.'/title';
    if ($TextFile=='description') $TextPath = $AlbumsPathLocal.$Album.'/description';
    $amountPossibleTextExtensions = count($PossibleTextExtensions);
    for ($i=0; $i<$amountPossibleTextExtensions; $i++)
    {
      $TextFilePath = $TextPath.'.'.$PossibleTextExtensions[$i];
      if (is_file($TextFilePath))
      {
        if ( filesize($TextFilePath)>0 )
        {
          $fp = fopen ( $TextFilePath, 'r' );
          $Text = fread ( $fp, filesize ( $TextFilePath ) );
          fclose ( $fp );
          return $Text;
        }
        else return false;
      }
    }
  }

  function getArrayOfImagesInFolder ( $Folder )
  {
    global $AlbumsPathLocal;
    $handle=opendir ($AlbumsPathLocal.$Folder);
    $files = array();
    while ($file = readdir ($handle))
      if ($file != "." && $file != "..") { $files[] = $file; }
    array_multisort($files);
    $newFiles = array(pos($files));
    $amountFiles = count($files);
    for ($i=1; $i<$amountFiles; $i++)
      $newFiles[$i] = next($files);
    return $newFiles;
  }
  
?>
Return current item: GigKalender