5. Functions in file prepareDirOverviewGalleryAjax.php

The file is called in Javascript function prepareDirOverviewGallery(), implemented in file generate_jssor_code.js, as a Javascript AJAX call in a promise (see also Section 4.7). The following parameters are transferred by the POST method:

  1. Parent directory (String),
  2. Location directory (String),
  3. gallery PHP filename (String),
  4. Private (Boolean),
  5. Caller (String),
  6. Pagereload (Boolean)

The status of the $_SESSION[‘sess_username’] variable is checked. For any visitor of public pages of the site (see Table 1.16) the variable $_SESSION[‘sess_username’] is not set so that $uname=’site_visitor’. For a registered user of the site the variable $_SESSION[‘sess_username’] is set and $uname=$_SESSION[‘sess_username’]. The session variables are set in login.min.php (see also Section 12.11).

At the end of the script the JSON string encoded object albumDirThumbStatHtml_Object (see also Table 4.16) is returned to the JavaScript function caller chainedXHRequest().

5.1. Main script

<?php
// BEGIN PHP CODE WHEN CALLED FROM AJAX
sec_session_start();
if (isset($_POST['parent'])){$parent=$_POST['parent'];} else {$parent='';}
if (isset($_POST['dir']))$dir=$_POST['dir'];
if (isset($_POST['gpf']))$gpf=$_POST['gpf'];
if (isset($_POST['private'])){$private=$_POST['private'];}else {$private=0;}
if (isset($_POST['caller']))$caller=$_POST['caller'];else $caller='';
if (isset($_POST['pageReload'])){$pageReload=($_POST['pageReload']==='true'?true:false);
} else {$pageReload=false;}
if (($pageReload===false)&&($caller!='child')){$show_infowindow=1;}
else {$show_infowindow=0;}
if (isset($_SESSION['sess_username'])){$uname=$_SESSION['sess_username'];}
else $uname=WEBSITE_VISITOR;
if (isset($_SESSION['sess_user_permission'])){$permissionLevel=$_SESSION['sess_user_permission'];}
else $permissionLevel=VISITOR_PERMISSION_LEVEL;
if (isset($_SESSION['sess_group'])){$userGroup=$_SESSION['sess_group'];}
else $userGroup=VISITOR_GROUP;
$wdir=$_SERVER['DOCUMENT_ROOT'].DS.$parent.DS.$dir;
$albumInfo = AlbumCatalogue($parent.DS.$dir);
$pwd=getcwd(); // php directory
$sid=session_id();
$session=array('parent'=>$parent,'dir'=>$dir,'uname'=>$uname,'caller'=>$caller,'sid'=>$sid,'private'=>$private,'permissionLevel'=>$permissionLevel);
$phpDef=array('exists'=>false,'dirDescription'=>false);
$albumDirThumbStatHtml=array('nrIminfoFiles'=>0,
	'dirImList'=>NULL,
	'albumOwner'=>$albumInfo->Owner->__toString(),
	'media'=>array('iminfo'=>NULL,'new_M'=>NULL,'remove_M'=>NULL,'wdir'=>$wdir),
	'phpDef'=>array('exists'=>false,'dirDescription'=>false),
	'infoDialogBox'=>array('globalstat2binstr'=>'','show'=>$show_infowindow,'htmlStatCode'=>NULL),
	'jsList'=>array(),
	'sLang'=>'FULL_JAVASCRIPT',
	'status'=>array('proposeRegUserOrAdmin'=>array('login'=>0,'reason'=>''),
			'albumExists'=>true,
			'updIminfoCMIF_1'=>NULL,
			'updateProgressDialogBox'=>false,
			'permissionDeleteProcFile'=>false,
			'permissionLevel'=>array('current'=>$permissionLevel, 'requiredForUpdate'=>ALBUM_UPDATE_PERMISSION_LEVEL),
			'updateSuggested'=>false,
			'globStat'=>0x00000,
			'action_offset'=>0x00000,
			'time_stat'=>0x00000,
			'resize_stat'=>0x00000),
 	'server_info'=>array('uname'=>$uname,
         'sid'=>$sid,
         'hostname'=>$_SERVER['SERVER_NAME'],
         'hostaddress'=>$_SERVER['SERVER_ADDR'],
         'debugJS'=>DEBUG,
         'NumbSiteVisits'=>0,
         'mysql_server'=>array('status'=>1,'address'=>MYSQL_SERVER,'server_msg'=>NULL),
         'email_server'=>array('status'=>0,'address'=>MYSQL_SERVER,'server_msg'=>NULL),
));
list($GlobStat,$xml_defs,$iminfo_xml_stat,$upd_media_dir,$SysErrCode)=dirThumb($albumDirThumbStatHtml,$session,'#modal_popup');
if ($albumDirThumbStatHtml['status']['albumExists']){
	$albumDirThumbStatHtml['infoDialogBox']['globalstat2binstr']=_globalStat2Binstr($GlobStat);
	if ($albumDirThumbStatHtml['phpDef']['exists']){
      GenerateDirOverview($albumDirThumbStatHtml,$session,$gpf,$xml_defs,$iminfo_xml_stat,$upd_media_dir);
   }
	$media=$albumDirThumbStatHtml['media']['iminfo'];
// $_SESSION["show_infowindow"]="1"; NOT NEEDED ANYMORE
	if ($GlobStat&FPROC_STAT_PHPDEF_EXIST){
		if ($media['NoMedia']==TRUE) echo "NO MEDIA";
		else {
			$action=$media['UpdateAction']&MASK_MEDIA_PROCESSING;
			if ($action===ALL_MEDIA_PROCESSING){
				// Reference: http://stackoverflow.com/questions/3951768/window-open-and-pass-parameters-by-post-method
				echo "<form id='ResizeInfoForm' method='post' action='imageresizeprogress.php' target='TheWindow'>\n";
				echo "<input type='hidden' name='vakantieDir' value='$dir'/>\n";
				echo "<input type='hidden' name='parent' value='$parent'/>\n";
				echo "</form>\n";
				echo "<script>\n";
				echo "window.open('','TheWindow','height=400,width=600');\n";
				echo "document.getElementById('ResizeInfoForm').submit();\n";
				echo "</script>\n";
			}
			if (($action===UPD_MEDIA_PROCESSING)&&(($media['NewCount']+$media['PutBackM_Cnt'])>0)){
				$albumDirThumbStatHtml['status']['updateProgressDialogBox']=true;
			}
		}
	} else {// PHPDEFINITION FILE DOES NOT EXIST
		chdir($wdir);
		if ($GlobStat & FPROC_STAT_MEDIA_EXIST){
			$subDirsList=glob("*",GLOB_ONLYDIR);
			$numb_subDirs=count($subDirsList);
			$numb_iminfo=$albumDirThumbStatHtml['nrIminfoFiles'];
			if (($numb_iminfo>0)&&($numb_subDirs===$numb_iminfo)){
//				 echo "phpdefinition.xml probably accidentally removed, or renamed. <br>";
//				 if (!($GlobStat&RPROC_STAT_EXIST)) echo "File rproc.txt probably accidentally removed, or renamed.";
//				 if (!($GlobStat&FPROC_STAT_EXIST)) echo "File fotosproc.txt probably accidentally removed, or renamed.";
			}
			else {$albumDirThumbStatHtml['dirImList']=GetImageList4JSSOR($albumDirThumbStatHtml,$wdir,$subDirsList);}
		}
		chdir($pwd);
	}
	// At the end of div class"wrapper" (child of div class"inner-6")
	if ($albumDirThumbStatHtml['status']['proposeRegUserOrAdmin']['login']) {
		$reason=" ";
		$cnt=0;
		if ($albumDirThumbStatHtml['status']['proposeRegUserOrAdmin']['login'] & RESIZE_STAT_MASK_TIMECHANGE) {
		  $reason.=strval(++$cnt).") Directory(ies) timestamp change, (new/removed media)<br>";
		}
		if ($albumDirThumbStatHtml['status']['proposeRegUserOrAdmin']['login'] & RPROC_STAT_MASK) {
		  $reason.=strval(++$cnt).") rproc file update needed, <br>";
		}
		if ($albumDirThumbStatHtml['status']['proposeRegUserOrAdmin']['login'] & RPROC_UPD_MEDIA_MASK) {
		  $reason.=strval(++$cnt).") media (XML) update needed according to rproc, <br>";
		}
		$albumDirThumbStatHtml['status']['proposeRegUserOrAdmin']['reason']=$reason;
	}
}
echo json_encode($albumDirThumbStatHtml);
?>

5.2. AlbumCatalogue

Interface definition

AlbumCatalogue($albumDirectory)

Functions reads file albumOverview.xml in the document root.

Parameters:
  • $albumDirectory (String) – Directory of album
Return $result:

Node element of SimpleXMLElement

5.2.1. Source code

<?php
function AlbumCatalogue($albumDirectory) {
	$albumCatalogue=simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DS.'albumOverview.xml');
	$albumNode=$albumCatalogue->xpath("//AlbumOverview/Album[Directory=\"$albumDirectory\"]");
	if ($albumNode!= NULL) $result=$albumNode[0];
	else $result=new SimpleXMLElement("<Album><Name>Mars</Name><Directory>reizen/mars</Directory><Owner>DanyBoy</Owner><Description>Mars Trip 2040</Description><CreationDate>December 2040</CreationDate><ID>0</ID></Album>");
	return $result;
}

5.3. CheckProcessStatus_X000FF()

Interface definition

CheckProcessStatus_X000FF($phpDefFile, $media)

Function checks the media process status of a gallery (album): the check is carried out by counting media files in the location directories. If the file phpdefinition.xml exists (see Section 3.1.3), data of the location directories is stored in the private variable $xml = $phpDefFile object variable. If the file phpdefinition.xml does not exist then $xml = NULL, but media is found in the directory, then it will result in the generation of a simplified album gallery.

Reading of file phpdefinition.xml

The function looks for the file named phpdefinition.xml, which is an XML file containing information about the subdirectories and descriptions (see Listing 3.2). This phpdefinition.xml file is a user created file and must be in the root directory of the album. For each subdirectory name listed in this phpdefinition.xml file, a thumb icon jpg-file is assumed to exist (lower case: is case sensitive. See also Fig. 4.6). Only HTML code is generated for the subdirectories which exist. No message is generated if a subdirectory does not exist. If the file phpdefinition.xml is not found the function returns without generating HTML code.

If file phpdefinition.xml exists, then (|••••|••••|••••|1•••|••••|)

  • Media files are counted in all directories. The result of the count is stored in the fourth output argument of the function ( $mediaList).
  • Number of media files in location and public / private directories are compared. The result of the comparison is stored in the variable $XFFFFF[‘GlobStat’] (third output argument). Possible scenarios are listed in Table 5.2.
  • For all directories, modification status (i.e. comparing time stamps) is checked. The result is stored in the second output argument.

Function is called by dirThumbs() (for both normal user and admin).

Parameters:
  • $phpDefFile (String) – Filename with PHP definitions of the album (phpdefinition.xml),
  • $media (Object) – Media object,
Returns:

  1. $xml ( Object ) - phpdefinition object
    • If phpdefinition.xml does not exist: $xml = NULL;
    • If phpdefinition.xml exists: $xml = $phpDefFile; (XML object of phpdefinition.xml).
  2. $XFFFFF_Arr ( Object ) - XFFFFF_Arr object is array of elements, where each element is an array with 5 keys. An example is given in Section 3.3.3.3.
    • If phpdefinition.xml does not exist: single element array.
    • If phpdefinition.xml exists: Multi element array, where the number elements are determined by the number of location directories.
  3. $XFFFFF ( Object ) - XFFFFF object is an array with 5 associative keys. More info on the initialization values is given in Section 5.3.1.
  4. $mediaList ( Object ) - mediaList object
    • If phpdefinition.xml does not exist: Initial $media object (same as second input argument, see Table 3.8)
    • If phpdefinition.xml exists: $media[‘CountList’], and $media[‘NoMedia’] are set.

Table 5.1 Media count comparison description between location and public/private directories:
Comparison between location
and public/private directories
Comment
(ResizeCnt==0)&&(LocationCnt>0) |••••|••••|••••|••••|••00|= NO_PROCESSED_FILES  
(ResizeCnt==LocationCnt)&& (LocationCnt!=0) |••••|••••|••••|••••|••01|= PROCESSED_FILES_ORIGINALS_KEPT Location and public/private directories are not empty and have the same file count. Normally this means that the location and public/private directories have the same media files. Another indication for this is that the access times of the location and public/private directories and iminfo.xml files are the same within a few minutes. However, it can also happen by coincidence that several media files in the location directory have been removed and are replaced by new media files. This is not tested in this function. An indication that media has been removed and added is that the access times of the location and public/private directories and iminfo.xml files are different. Comparison of media content in location and public/private directory based on filename is done in another function: DetailedStatusAnalysis().
(LocationCnt==0)&&(ResizeCnt>0) |••••|••••|••••|••••|••11|= PROCESSED_FILES_ORIGINALS_REMOVED Original media files in the location directory have been removed. Normally the access times of the location and public/private directories and iminfo.xml files are the same within a few minutes and no update action is needed. However, if the access times of the location and public/private directories and iminfo.xml files differ significantly, then probably media have been removed, and the same number media been added. To identify which media has been removed, and which new media has been added, the function DetailedStatusAnalysis() is called.
(LocationCnt)!== ResizeCnt |••••|••••|••••|••••|••10|= PROCESSED_FILES_ORIGINALS_ADD_REM This is a strong indication that new media files have been added in the location directory (directories). Another indication for this is that the access times of the location and public/private directories and iminfo.xml files will be different. To identify which media has been removed, and which new media has been added, the function DetailedStatusAnalysis() is called. An update is then needed. update is then needed.
(LocationCnt==0)&&(ResizeCnt==0) NOT RELEVANT
Table 5.2 Media count comparison between location and public/private directories: translation to 0X0000F, and 0X000F0
Comparison between location and public/private directories 0X0000F 0X000F0
(ResizeCnt==0)&&(LocationCnt>0) |••••|••••|••••|••••|••00| |••••|••••|••••|110•|••••|= FPROC_STAT_MEDIA_EXIST
(ResizeCnt==LocationCnt)&& (LocationCnt!=0) |••••|••••|••••|••••|••01| = PROCESSED_FILES_ORIGINALS_KEPT |••••|••••|••••|111•|••••|= FPROC_STAT_MEDIA_EXIST || FPROC_STAT_ALBUM_MEDIA_EXIST
(LocationCnt==0)&&(ResizeCnt>0) |••••|••••|••••|••••|••11| = PROCESSED_FILES_ORIGINALS_REMOVED |••••|••••|••••|111•|••••|= FPROC_STAT_MEDIA_EXIST || FPROC_STAT_ALBUM_MEDIA_EXIST
(LocationCnt)!== ResizeCnt |••••|••••|••••|••••|••10| = PROCESSED_FILES_ORIGINALS_ADD_REM |••••|••••|••••|111•|••••|= FPROC_STAT_MEDIA_EXIST || FPROC_STAT_ALBUM_MEDIA_EXIST
(LocationCnt==0)&&(ResizeCnt==0) NOT RELEVANT |••••|••••|••••|1•••|••••|= FPROC_STAT_PHPDEF_EXIST

5.3.1. Output argument 3: $XFFFFF

Table 5.3 Initialization scenario’s for $XFFFFF
  phpdefinition.xml does not exist phpdefinition.xml exists
GlobStat &=~FPROC_STAT_PHPDEF_EXIST |=FPROC_STAT_MEDIA_EXIST Single hexadecimal value representing a global status (0x000ba). The meaning of the different values for a and b are given in Table 2.1 and Table 2.2.
FillStat RESIZE_STAT_MASK Hexadecimal number indicating which hexadecimal bits are assigned values.
admin FALSE FALSE. Default administrator status is false. It will be set to TRUE in a later stage if the web user is the administrator or is working on local host (IP address is 127.0.0.1) for testing purposes. The information is used in function StatusInfoWindow() for determining the callback functions of the “YES” and “NO” buttons.
server_ip ‘’ ‘’: assigned later
client_ip ‘’ ‘’: assigned later

5.3.2. Output argument 4: $mediaList

$mediaList is a matrix data structure containing the number of images and video’s in each location directory. The structure of the matrix is shown in Table 5.4. #videos represent the actual number of video files in a directory: video filenames with the same basename but with different extension (different mimetype e.g. WEBM and MP4) have the same video content.

Table 5.4 $mediaList array: row index is an integer starting from 0. The column indexes are associative keys with names ‘loc_images’, ‘loc_videos’, ‘Rsz_images’, ‘Rsz_videos’, ‘Prv_images’, and ‘Prv_videos’.
Array index locDirname loc_images loc_videos Rsz_images Rsz_videos Prv_images Prv_videos
0 Name0 #images #videos #images #videos #images #videos
1 Name1 #images #videos #images #videos #images #videos
2 Name2 #images #videos #images #videos #images #videos
3 Name3 #images #videos #images #videos #images #videos
4 Name4 #images #videos #images #videos #images #videos
5 Name5 #images #videos #images #videos #images #videos
6 Name6 #images #videos #images #videos #images #videos
7 Name7 #images #videos #images #videos #images #videos
8 Name8 #images #videos #images #videos #images #videos
9 Sum Sum Sum Sum Sum Sum

5.3.3. Source code

<?php
function CheckProcessStatus_X000FF($phpDefFile,$mediaIn){
// Count media files in directories
// INP1: $phpDefFile contains phpdefinition
// OUT1: 
// OUT2: $XFFFFF_Arr: array. # elements is (#locations + 1)
//		For each location entry: sub array with 3 numbers: directory, iminfo, and public dir access times
// OUT3: $XFFFFF Possible values for last row:	0x0000, 0x0001, 0x0002, 0x0003
// OUT4: $mediaList: each item (location directory) is a 6 element array with the following keys:
//		loc_images, loc_videos,	Rsz_images, Rsz_videos, Prv_images, Prv_videos
//		each key value represents either the #images or #videos.
// Set all bits of second hexadecimal (FPROC position)
	$XFFFFF=array('GlobStat'=>FPROC_STAT_PHPDEF_EXIST,'FillStat'=>RESIZE_STAT_MASK,'permissionDeleteProcFile'=>FALSE,'server_ip'=>'','client_ip'=>'');
	$media=$mediaIn;
	$now=time();
	if (!file_exists($phpDefFile)){
		$XFFFFF['GlobStat']&=~FPROC_STAT_PHPDEF_EXIST;
		$XFFFFF_Arr=array_fill(0,1,array('locDirname'=>'','XFFFFF'=>0,'dirAccessTime'=>$now,'iminfoAccessTime'=>$now,'resizedAccessTime'=>$now));
		$xml=NULL;
		// check for media files recursively in current directory (only 1 level subdirectory )
		$rcount=rfile_count(".",MEDIA_FILES_REGEX,1);
		if ($rcount>0) {
			$XFFFFF['GlobStat']|=FPROC_STAT_MEDIA_EXIST;
		}
		else $media['NoMedia']=TRUE;
	}
	else {
	  $xml=simplexml_load_file($phpDefFile);
	  $mediaCnt=array();
	  $mediaList=array();
	  $mediaCnt['loc_images']=0;
	  $mediaCnt['loc_videos']=0;
	  $mediaCnt['Rsz_images']=0;
	  $mediaCnt['Rsz_videos']=0;
	  $mediaCnt['Prv_images']=0;
	  $mediaCnt['Prv_videos']=0;
	  $nRows=$xml->directory->count();	  
	  $XFFFFF_Arr=array_fill(0,$nRows,array('locDirname'=>'','XFFFFF'=>0,'dirAccessTime'=>$now,'iminfoAccessTime'=>$now,'resizedAccessTime'=>$now));
	  $dir_status=0;
	  $i=0;
	  foreach ($xml->directory as $key=>$ldir){
		  $dirName=$ldir->name;
		  $xml_name=$dirName.DS.'iminfo.xml';
		  $dirAccessTime=floor(filemtime($dirName)/60)*60;
		  $iminfoAccessTime=floor(filemtime($xml_name)/60)*60;
		  $resizedAccessTime=floor(filemtime($dirName.DS."Resized")/60)*60;
		  $XFFFFF_Arr[$i]['locDirname']=$dirName;
		  $XFFFFF_Arr[$i]['dirAccessTime']=$dirAccessTime;
		  $XFFFFF_Arr[$i]['iminfoAccessTime']=$iminfoAccessTime;
		  $XFFFFF_Arr[$i]['resizedAccessTime']=$resizedAccessTime;
		  $media['CountList'][$i]['locDirname']=$dirName;
		  $media['CountList'][$i]['loc_images']=count(glob($dirName.DS.IMAGE_FILES,GLOB_BRACE));
		  $media['CountList'][$i]['loc_videos']=count(glob($dirName.DS.VIDEO_FILES,GLOB_BRACE));
		  $media['CountList'][$i]['Rsz_images']=count(glob($dirName.DS."Resized".DS.GALLERY_IMAGE_FILES,GLOB_BRACE));
		  $media['CountList'][$i]['Rsz_videos']=count(glob($dirName.DS."Resized".DS.VIDEO_FILES,GLOB_BRACE));
		  $media['CountList'][$i]['Prv_images']=count(glob($dirName.DS."Resized".DS."Private".DS.GALLERY_IMAGE_FILES,GLOB_BRACE));
		  $media['CountList'][$i]['Prv_videos']=count(glob($dirName.DS."Resized".DS."Private".DS.VIDEO_FILES,GLOB_BRACE));
		  $mediaCnt['loc_images']+=$media['CountList'][$i]['loc_images'];
		  $mediaCnt['loc_videos']+=$media['CountList'][$i]['loc_videos'];
		  $mediaCnt['Rsz_images']+=$media['CountList'][$i]['Rsz_images'];
		  $mediaCnt['Rsz_videos']+=$media['CountList'][$i]['Rsz_videos'];
		  $mediaCnt['Prv_images']+=$media['CountList'][$i]['Prv_images'];
		  $mediaCnt['Prv_videos']+=$media['CountList'][$i]['Prv_videos'];
		  if ($iminfoAccessTime != false){ // iminfo.xml file exists in this directory
			  if ($dirAccessTime > $iminfoAccessTime){
				  // Directory content has changed: media added or deleted
				  $dir_status|=LOCATION_DIR_HAS_CHANGED;
				  $XFFFFF_Arr[$i]['XFFFFF']|=LOCATION_DIR_HAS_CHANGED;
			  }
			  if ($resizedAccessTime > $iminfoAccessTime){
				  // Resized content has changed: media moved to Private or moved from Private to Resized.
				  $dir_status|=PUBLIC_DIR_HAS_CHANGED;
				  $XFFFFF_Arr[$i]['XFFFFF']|=PUBLIC_DIR_HAS_CHANGED;
			  }
		  }
		  $i++;
	  }
	  // Last row of $media['CountList'] contains the sum.
	  $media['CountList'][$nRows]['locDirname']='';
	  $media['CountList'][$nRows]['loc_images']=$mediaCnt['loc_images'];
	  $media['CountList'][$nRows]['loc_videos']=$mediaCnt['loc_videos'];
	  $media['CountList'][$nRows]['Rsz_images']=$mediaCnt['Rsz_images'];
	  $media['CountList'][$nRows]['Rsz_videos']=$mediaCnt['Rsz_videos'];
	  $media['CountList'][$nRows]['Prv_images']=$mediaCnt['Prv_images'];
	  $media['CountList'][$nRows]['Prv_videos']=$mediaCnt['Prv_videos'];
	  $loc_mediaCnt=$mediaCnt['loc_images']+$mediaCnt['loc_videos'];
	  $resize_prCnt=$mediaCnt['Rsz_images']+$mediaCnt['Rsz_videos'];
	  $resize_prCnt+=$mediaCnt['Prv_images']+$mediaCnt['Prv_videos'];
	  // Include timestamp info in global status variable!
	  $XFFFFF['GlobStat']=FPROC_STAT_PHPDEF_EXIST;
	  if (($resize_prCnt===0)&&($loc_mediaCnt>0)){
		  $XFFFFF['GlobStat']|=($dir_status|FPROC_STAT_MEDIA_EXIST);
	  }
	  else if (($resize_prCnt===$loc_mediaCnt)&&($loc_mediaCnt!=0)){
		  $XFFFFF['GlobStat']|=($dir_status|PROCESSED_FILES_ORIGINALS_KEPT);
		  $XFFFFF['GlobStat']|=(FPROC_STAT_MEDIA_EXIST|FPROC_STAT_ALBUM_MEDIA_EXIST);
	  }
	  else if (($loc_mediaCnt===0)&&($resize_prCnt>0)){
		  $XFFFFF['GlobStat']|=($dir_status|PROCESSED_FILES_ORIGINALS_REMOVED);
		  $XFFFFF['GlobStat']|=(FPROC_STAT_MEDIA_EXIST|FPROC_STAT_ALBUM_MEDIA_EXIST);
	  }
	  else if (($loc_mediaCnt)!==$resize_prCnt){
		  $XFFFFF['GlobStat']|=($dir_status|PROCESSED_FILES_ORIGINALS_ADD_REM);
		  $XFFFFF['GlobStat']|=(FPROC_STAT_MEDIA_EXIST|FPROC_STAT_ALBUM_MEDIA_EXIST);
	  }
	  else if (($loc_mediaCnt===0)&&($resize_prCnt===0)) $media['NoMedia']=TRUE;
	}
	return array($xml,$XFFFFF_Arr,$XFFFFF,$media);
}

5.4. CompareMediaCntRprocLocDir_XF0F00()

Interface definition

CompareMediaCntRprocLocDir_XF0F00($rData, $X5F, $X5F_Arr, $mediaObj)

Compares media files count in the location directories ( $media), public/private ( $media) directories and the media count numbers in rproc.txt file ($rData).

Parameters:
Returns:

  1. $X5F_upd ( Object ) - XFFFFF object, updated $XFFFFF (only a limited number of hexadecimal bits are updated): 0xF0F00,
    • If the media count in public and private directories is smaller than the number indicated by rproc.txt for the corresponding directories than media in public and/or private directories probably needs to be updated ( $5F_upd[‘GlobStat’]|= 0x10000 | 0x20000). This can happen when media public/private directories are removed. Updating of public/private directories can only be done when the original media files are still present in the location directory.
    • If the number indicated by rproc.txt is smaller than the media count in public and private directories than the file rproc.txt must be updated ($5F_upd[‘GlobStat’]|= 0x00200).
    • If the number of media files in the location directory is larger than in the public/private directories than probably new media has been added in the location directory. This requires a more thorough media count analysis (based on filename comparison) and will also require an update of the rproc.txt file (🡺 $5F_upd[‘GlobStat’] = 0x00400 | 0x00800). A more thorough media count analysis is initiated when fproc.txt is deleted and when the user is logged on.
  2. $X5F_Arr_Upd ( Object ) - XFFFFF_Arr object, updated array (updated $XFFFFF for each location directory)

5.4.1. Source code

<?php
function CompareMediaCntRprocLocDir_XF0F00($rprocList,$X5F,$X5F_Arr,$mediaObj){
// OUT1: $X5F_upd: updated status (0xF0F00)
// OUT2: $X5F_ArrUpd: updated status array (for each location directory)
	$X5F_upd=$X5F;
	$X5F_ArrUpd=$X5F_Arr;
	$dirCnt=count($X5F_Arr);
	for ($j=0;$j<$dirCnt;$j++){
		$rprocMediaCnt=$rprocList[$j][2]+$rprocList[$j][3];
		$media=$mediaObj['CountList'][$j];
		$pubprivCnt=$media['Rsz_images']+$media['Rsz_videos']+$media['Prv_images']+$media['Prv_videos'];
		if ($pubprivCnt < $rprocMediaCnt){//0X30000
			$X5F_upd['GlobStat']|=(RPROC_UPD_PUB_MEDIA|RPROC_UPD_PRV_MEDIA);
			$X5F_ArrUpd[$j]['XFFFFF']|=(RPROC_UPD_PUB_MEDIA|RPROC_UPD_PRV_MEDIA);
		}
		else if ($rprocMediaCnt < $pubprivCnt) {//0X00200
			$X5F_upd['GlobStat']|=RPROC_STAT_UPD_WITH_PUBPRIV_COUNT;
			$X5F_ArrUpd[$j]['XFFFFF']|=RPROC_STAT_UPD_WITH_PUBPRIV_COUNT;
		}
		if ($media['loc_images']>($media['Rsz_images']+$media['Prv_images'])){//0X00400
			$X5F_upd['GlobStat']|=RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT;
			$X5F_ArrUpd[$j]['XFFFFF']|=RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT;
		}
		if ($media['loc_videos']>($media['Rsz_videos']+$media['Prv_videos'])){ //0X00800
			$X5F_upd['GlobStat']|=RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT;
			$X5F_ArrUpd[$j]['XFFFFF']|=RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT;
		}
	}
	$X5F_upd['FillStat']|=0xF0F00;
	return array($X5F_upd,$X5F_ArrUpd);
}

5.5. dirThumbs()

Interface definition

dirThumbs(&$albumDirThumbStatHtml, $session, $popid='#modal_popup')

Function to create the directory overview with thumbs, where each thumb image is a link to a different location, day (or other vacation tag). The HTML code of the webpage is generated automatically. Basically it is a container function calling other functions with “limited” tasks.

Function is called by the main script of php\prepareDirOverviewGalleryAjax.php.

Parameters:
Returns:

  1. $XFFFFF[‘GlobStat’] ( Hexadecimal integer ) - see Section 3.3.2.2,
  2. $xml_defs ( Object ) - see phpdefinition object
  3. $iminfo_xml_stat ( 2 dimensional Array ) - matrix: #rows= #locations, #columns=8 (third output argument of check_mediacount_iminfo_files),
  4. $upd_media_dir ( 2 dimensional Array ) - matrix: #rows= #locations, #columns=2 (second output argument of check_mediacount_iminfo_files),
  5. $SysErrCode ( Integer ),

5.5.1. Reading of file phpdefinition.xml

The function looks for the file named phpdefinition.xml, which is an XML file containing information about the subdirectories and descriptions. This phpdefinition.xml file is a user created file and must be in the root directory of the album. For each subdirectory name listed in this phpdefinition.xml file, a thumb icon jpg-file is assumed to exist (lower case: is case sensitive). Only HTML code is generated for the subdirectories which exist. No message is generated if a subdirectory does not exist. If the file phpdefinition.xml is not found the function returns without generating HTML code.

The following functions are called:

  1. list($XFFFFF_Arr, $XFFFFF, $media[‘CountList’])=CheckProcessStatus($xml_defs);

5.5.2. Checking of file fproc.txt

The existence of a fproc.txt in the directory $vakantieDir is tested. If the file fproc.txt exists one of the output arguments of the function is set to 1 (meaning that all images have already been resized). Otherwise an empty fproc.txt is created in the vacation directory. The presence of this file means that the resized images have already been created and nothing should be done.

The actual reading of fproc.txt is implemented in RProc_FProc_Status_X00FF0().

5.5.3. Checking of file rproc.txt

The function also looks for the file rproc.txt (a csv file). If it does not exist, it will be created. An example of the file content is:

The actual reading of rproc.txt is implemented in RProc_FProc_Status_X00FF0().

Table 5.5 Example of rproc.txt content. It is a CSV-file: data in columns is separated by a “,”. After the last element in a row also a “,” is required.
DeReis 17 12 5
Weeshuis 13 13 0
HoChiMinh 74 68 6
DaguitHCM-TayNinh 19 16 3
DaguitHCM-Mekong 21 16 5
Mui Ne 56 44 12
Dalat 57 50 7
Nha trang 21 19 2
Hoian 88 85 3
Hue 94 90 4
Hanoi 52 48 4
Halong Bay 13 12 1
* 525 473 52

Each row has 4 data entries separated with commas.

  1. The first entry is the location directory,
  2. The second entry is the total number of pictures and videos files in this directory (video files with the same basename but with different extensions e.g. video.mp4 and video.webm, are considered as 2 files. In the file iminfo.txt these video files are considered as 1 media file. This may make the media counting somewhat confusing).
  3. The third entry is the total number of pictures in the “Resized” directory. These are the pictures visible in public mode.
  4. The fourth entry is the total number of pictures in the “Private” directory. Next to the pictures in the “Resized“ directory the pictures in the “Private” directory are also visible in private mode.

The information of rproc.txt is used to display the number of media files in each location directory. If the file rproc.txt does not exist, the number of images is determined by the number of (original) images in the location directory. In general, this is the case when the directory is entered for the first time. The “Resized” directory is not yet created and is created in the next phase. In that case the second and the third entry will be the same, while the last entry will be set to 0. This means that for the example given above the first entry will be:

DeReis, 17, 17, 0,

In order to save disk space, the original images in the location directory will be deleted when the images are resized in and created in the “Resized” directory. This poses a problem when the file rproc.txt is accidentally deleted because in that case the number of images cannot be determined. The second, third and fourth entries are then 0. The correct number of images must then be determined by the function :php:func`updateIminfoFiles()`.

As of October 28, 2015, the file phpdefinition.txt has been changed to an XML file: phpdefinition.xml. The reason for this is future extensibility, and flexibility. An example of phpdefinition.xml is given in Listing 3.2.

_images/Fig23_dirThumbs.png

Fig. 5.1 The variable $Resize determines whether to call the file imageresizeprogress.php or not.

5.5.4. Source code

<?php
function dirThumb(&$albumDirThumbStatHtml,$session,$popid='#modal_popup'){
// INP1 REQUIRED: pointer to $albumDirThumbStatHtml,
// INP2 REQUIRED: $session,
// INP8 OPTIONAL: popup id for presenting reisverslagen (per '$dir'
// OUT1: $defFile (-1, 0, 1)
// OUT2: $proposeAdminLogin,
// OUT3: $media: ['UpdateAction']MediaProcessing ACTION; ['CountList']: countlist in directories
// OUT4: $iminfo_objs
	$pwd=getcwd();
	$SysErrCode=0;
	$upd_notification=0;
	$media=InitMediaObject();
	$NewMedia=NULL;
	$RemMedia=NULL;
   $server_info=$albumDirThumbStatHtml['server_info'];
   $server_info_ref=&$albumDirThumbStatHtml['server_info'];
	$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode']=array_fill(0,4,array('DisplayModus'=>INIT_STAT_DISPLAY_MODE,
                'htmlStringCode'=>'','jsList'=>array(),
                'CalledByFunction'=>'','dialogStatus'=>0,
                'genTable'=>0,'db_active'=>0,
                'db_buttons'=>0,'sLang'=>$albumDirThumbStatHtml['sLang']));
	$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0]['CalledByFunction']='check_mediacount_iminfo_files';
	$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1]['CalledByFunction']='StatusInfoWindow';
	$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2]['CalledByFunction']='StatusInfoDirectoryAccessDates';
	$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][3]['CalledByFunction']='StatusInfoNewOrDeletedMedia';
	$kk=new RemoteAddress;
	$ip=$kk->getIpAddress();
	$wdir=$_SERVER['DOCUMENT_ROOT'].DS.$session['parent'].DS.$session['dir'];
	if (!is_dir($wdir)){
		$albumDirThumbStatHtml['status']['albumExists']=false;
		return array(NULL,NULL,NULL,NULL,-1);
	}
	chdir($wdir);
	list($rprocExist,$fprocExist)=rf_proc_stat(RPROCFILE,FPROCFILE);
	$albumDirThumbStatHtml['nrIminfoFiles']=rfile_count('.'.DS,'/iminfo.xml/');
//***************************************************************************
// STEP 1 MEDIA PROCESSING: COUNT OF MEDIA FILES: $XFFFFF['FillStat']=0x0000F
//***************************************************************************
	list($xml_defs,$XFFFFF_Arr,$XFFFFF,$media)=CheckProcessStatus_X000FF('phpdefinition.xml',$media);
	$XFFFFF['GlobStat']|=($rprocExist|$fprocExist);
	if (!($XFFFFF['GlobStat']&FPROC_STAT_PHPDEF_EXIST)){
		$albumDirThumbStatHtml['phpDef']['exists']=false;
		$albumDirThumbStatHtml['media']['iminfo']=$media;
		chdir($pwd);
		return array($XFFFFF['GlobStat'],$xml_defs,NULL,NULL,-1);
	}
//************************************************************
// STEP 2 MEDIA PROCESSING STATUS: $XFFFFF['FillStat']=0x00FFF
//************************************************************
	$albumDirThumbStatHtml['phpDef']['exists']=true;
	$dirCnt=$xml_defs->directory->count();
	$iminfo_objs=GetIminfoObjects($xml_defs);
	list($XFFFFF,$rData,$media['UpdateAction'])=RProc_FProc_Status_X00FF0($XFFFFF,$iminfo_objs,$session['caller']);
//	array_walk($XFFFFF_Arr,function(&$val,$key,$updVal){$val['XFFFFF']|=$updVal;},$XFFFFF['GlobStat']);
	array_walk($XFFFFF_Arr,'aw_cb_single_val',$XFFFFF['GlobStat']);
	$proposeUserOrAdminLogin=0;
	$XFFFFF['server_ip']=$_SERVER['SERVER_ADDR'];
	$XFFFFF['client_ip']=$ip;
// REMEMBER: PWD is vacation directory
	if ($albumDirThumbStatHtml['infoDialogBox']['show']){
		$info=array('wdir'=>$wdir,'ip'=>$ip,'modalClass'=>'modal-overlay','ndmt'=>'');
		$send_email=TRUE;
		$X0000F_2=$XFFFFF['GlobStat']&RESIZE_STAT_MASK_2; // |....|....|....|....|..**|
		$XFFFFF['permissionDeleteProcFile']=(($_SERVER['SERVER_ADDR']===LOCAL_ADDRESS) || ($session['permissionLevel']>=ALBUM_UPDATE_PERMISSION_LEVEL));
		if ( $XFFFFF['permissionDeleteProcFile'] ) {
			// DETAILED STATUS ANALYSIS WHEN NAND(fproc,rproc)=TRUE OR RESIZE STATUS IS 0x00002
			$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0]['DisplayModus']=STAT_TABLE_MODE;
			$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1]['DisplayModus']=STAT_DISPLAY_MODE;
			$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2]['DisplayModus']=STAT_TABLE_MODE;
			$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][3]['DisplayModus']=STAT_TABLE_MODE;
			list($media,$mListSorted,$NewMedia,$RemMedia)=DetailedStatusAnalysis($iminfo_objs,$media,($X0000F_2));
			if (($X0000F_2)===PROCESSED_FILES_ORIGINALS_ADD_REM){
				$m_p=$media['UpdateAction']&MASK_MEDIA_PROCESSING;
				$rproc_fproc=$XFFFFF['GlobStat']&(FPROC_STAT_EXIST|RPROC_STAT_EXIST);
				if ((($rproc_fproc>>NUMBER_OF_BITS_PER_DIGIT)<0x011)&&($m_p===UPD_MEDIA_PROCESSING)){
				// If RPROC.TXT and/or FOTOSPROC.TXT is deleted media update is needed --> PHASE 2
					Iminfo_XML_Objects_UpdateAndSave(1,$iminfo_objs,$NewMedia,$XFFFFF,$server_info,FALSE);
//					CreateRPROC('rproc.txt',PROCESSED_FILES_ORIGINALS_ADD_REM,$iminfo_objs);
					$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0]['DisplayModus']=NO_STAT_DISPLAY_MODE;
					list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0],$iminfo_objs,'',$media);
					list($XFFFFF,$XFFFFF_Arr)=Mediacount_IMINFO_X0F000($upd_media_dir,$XFFFFF,$XFFFFF_Arr);
					list($XFFFFF,$XFFFFF_Arr)=CompareMediaCntRprocLocDir_XF0F00($rData,$XFFFFF,$XFFFFF_Arr,$media);
					$SysErrCode =WriteMySessionVariables($session['uname'],$session['sid'],$upd_media_dir,'upd_media_dir');
					$SysErrCode|=WriteMySessionVariables($session['uname'],$session['sid'],$media,'mediaObj')<<NUMBER_OF_BITS_PER_DIGIT;
					$SysErrCode|=WriteMySessionVariables($session['uname'],$session['sid'],$XFFFFF_Arr,'XFFFFF_Arr')<<NUMBER_OF_BITS_PER_DIGIT;
					$SysErrCode|=WriteMySessionVariables($session['uname'],$session['sid'],$XFFFFF,'XFFFFF')<<NUMBER_OF_BITS_PER_DIGIT;
// PHASE 2 is continued in "media-update-progress.php" which is executed from an AJAX call
				}
				else {// Both RPROC.TXT and FOTOSPROC.TXT exist.
					$date_status=StatusInfoDirectoryAccessDates($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2],'modal-overlay',$XFFFFF_Arr,$dirCnt);
					list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0],$iminfo_objs,"modal-overlay",$media);
					list($XFFFFF,$XFFFFF_Arr)=Mediacount_IMINFO_X0F000($upd_media_dir,$XFFFFF,$XFFFFF_Arr);
					$info['ndmt']=StatusInfoNewOrDeletedMedia($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][3],'modal-overlay',$NewMedia,$media['NewCount'],$RemMedia,$media['RemovedCount']);
					list($XFFFFF,$XFFFFF_Arr)=CompareMediaCntRprocLocDir_XF0F00($rData,$XFFFFF,$XFFFFF_Arr,$media);
					$hexCode_StrRep=StatusInfoWindow($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1],$info,$rData,$XFFFFF,$media,$NewMedia,$RemMedia);
					if ($rprocExist&&(($XFFFFF['GlobStat']&RPROC_STAT_MASK)===RPROC_STAT_UPD_WITH_PUBPRIV_COUNT)){
						$rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_REMOVED,$iminfo_objs);
					}
// Following statement is for TEST purpose: REMOVE for web-server version
//					Iminfo_XML_Objects_UpdateAndSave(0,$iminfo_objs,$NewMedia,$XFFFFF,$server_info,FALSE);
				}
			}
			else if (($XFFFFF['GlobStat']>>NUMBER_OF_BITS_PER_DIGIT)===0x011){
// Both RPROC and FOTOSPROC exist: FAST STATUS ANALYSIS FOR 0x00001, 0x00003
				$date_status=StatusInfoDirectoryAccessDates($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2],'modal-overlay',$XFFFFF_Arr,$dirCnt);
				list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0],$iminfo_objs,'modal-overlay',$media);
				list($XFFFFF,$XFFFFF_Arr)=Mediacount_IMINFO_X0F000($upd_media_dir,$XFFFFF,$XFFFFF_Arr);
				$info['ndmt']=StatusInfoNewOrDeletedMedia($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][3],"modal-overlay",$NewMedia,$media['NewCount'],$RemMedia,$media['RemovedCount']);
				list($XFFFFF,$XFFFFF_Arr)=CompareMediaCntRprocLocDir_XF0F00($rData,$XFFFFF,$XFFFFF_Arr,$media);
				$hexCode_StrRep=StatusInfoWindow($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1],$info,$rData,$XFFFFF,$media,$NewMedia,$RemMedia);		
			}
			else if (($X0000F_2)===PROCESSED_FILES_ORIGINALS_KEPT){// DETAILED(1) STATUS ANALYSIS
			}
			else if (($X0000F_2)===PROCESSED_FILES_ORIGINALS_REMOVED){ // DETAILED(3) STATUS ANALYSIS
				if (($media['NewCount']===0)&&($XFFFFF['GlobStat']&LOCATION_DIR_HAS_CHANGED)){
					$i=0;
					foreach ($xml_defs->directory as $key=>$ldir){
						$xml_name=$ldir->name.DS.'iminfo.xml';
						touch($xml_name);
						$XFFFFF_Arr[$i++]['iminfoAccessTime']=floor(filemtime($xml_name)/60)*60;
					}
					// Set LOCATION_DIR_HAS_CHANGED BIT TO 0
					$XFFFFF['GlobStat']&=(~LOCATION_DIR_HAS_CHANGED);
				}
				if (($media['NewCount']===0)&&($XFFFFF['GlobStat']&PUBLIC_DIR_HAS_CHANGED)){
					$i=0;
					foreach ($xml_defs->directory as $key=>$ldir){
						$xml_name=$ldir->name.DS.'iminfo.xml';
						touch($xml_name);
						$XFFFFF_Arr[$i++]['iminfoAccessTime']=floor(filemtime($xml_name)/60)*60;
					}
					// Set PUBLIC_DIR_HAS_CHANGED BIT TO 0
					$XFFFFF['GlobStat']&=(~PUBLIC_DIR_HAS_CHANGED);
				}
				$date_status=StatusInfoDirectoryAccessDates($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2],'modal-overlay',$XFFFFF_Arr,$dirCnt);
				list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0],$iminfo_objs,'modal-overlay',$media);
				list($XFFFFF,$XFFFFF_Arr)=Mediacount_IMINFO_X0F000($upd_media_dir,$XFFFFF,$XFFFFF_Arr);
				$info['ndmt']=StatusInfoNewOrDeletedMedia($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][3],'modal-overlay',$NewMedia,$media['NewCount'],$RemMedia,$media['RemovedCount']);
				list($XFFFFF,$XFFFFF_Arr)=CompareMediaCntRprocLocDir_XF0F00($rData,$XFFFFF,$XFFFFF_Arr,$media);
				$hexCode_StrRep=StatusInfoWindow($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1],$info,$rData,$XFFFFF,$media,$NewMedia,$RemMedia);				
			}
// list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files(0,$iminfo_objs,"modal-overlay",$media);
// If the array $upd_iminfo contains at least one element with value
// UPDATE_IMINFO_NOFILE [1], UPDATE_IMINFO_MEDIACOUNT [2] or UPDATE_IMINFO_VERSION [3], then updating is needed.
			$count_arr=array_count_values($upd_iminfo);
			if (!isset($count_arr[UPDATE_IMINFO_EXISTS_OK])||($count_arr[UPDATE_IMINFO_EXISTS_OK]!=$dirCnt)){
				$upd_notification=updateIminfoFiles(UPDATE_IMINFO_MODUS_XML|UPDATE_IMINFO_MODUS_KEEP_MODTIME,$upd_iminfo,$iminfo_objs,$XFFFFF,$server_info,$send_email);
			}
//******************************************************************************
		}
// DEFAULT ACTION ON ARBITRARY HOST AND NOT LOGGED ON AS ADMIN NOR REGULAR USER
//******************************************************************************
		else {// FAST STATUS ANALYSIS: GET STAT OF RPROC.TXT, DIRECTORY DATES AND IMINFO.XML
//			list($F0F00_action,$rStat)=CheckRPROC($rData,$media['CountList']);
			$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0]['DisplayModus']=STAT_TABLE_MODE;
			$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2]['DisplayModus']=STAT_TABLE_MODE;
			list($XFFFFF,$XFFFFF_Arr)=CompareMediaCntRprocLocDir_XF0F00($rData,$XFFFFF,$XFFFFF_Arr,$media);
			$date_status=StatusInfoDirectoryAccessDates($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][2],'modal-overlay',$XFFFFF_Arr,$dirCnt);
			list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0],$iminfo_objs,'modal-overlay',$media);
			list($XFFFFF,$XFFFFF_Arr)=Mediacount_IMINFO_X0F000($upd_media_dir,$XFFFFF,$XFFFFF_Arr);
			$action_00F00=$XFFFFF['GlobStat']&RPROC_STAT_MASK;
//			if (($XFFFFF['GlobStat']&0xF0000)>=RPROC_UPD_PUB_MEDIA) $proposeUserOrAdminLogin=true;
//			if ((!$date_status)||($action_00F00>RPROC_STAT_EXIST)) $proposeUserOrAdminLogin=true;
			$proposeUserOrAdminLogin=$XFFFFF['GlobStat']&ADMIN_LOGIN_MASK;
			if ($proposeUserOrAdminLogin) $albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1]['DisplayModus']=STAT_TABLE_MODE;
			else $albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1]['DisplayModus']=NO_STAT_DISPLAY_MODE;
			$hexCode_StrRep=StatusInfoWindow($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][1],$info,$rData,$XFFFFF,$media);
//			if (!($rprocExist&&$fprocExist)) {
			$count_arr=array_count_values($upd_iminfo);
			if (!isset($count_arr[UPDATE_IMINFO_EXISTS_OK])||($count_arr[UPDATE_IMINFO_EXISTS_OK]!=$dirCnt)){
				$upd_notification=updateIminfoFiles(UPDATE_IMINFO_MODUS_XML|UPDATE_IMINFO_MODUS_KEEP_MODTIME,$upd_iminfo,$iminfo_objs,$XFFFFF,$server_info,$send_email);
			}
//			}
//			else $upd_iminfo=array_fill(0,$dirCnt,0); // Both RPROC and FOTOSPROC exist.
			if ($rprocExist&&($action_00F00===RPROC_STAT_UPD_WITH_PUBPRIV_COUNT)){
				$rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_REMOVED,$iminfo_objs);
			}
		}
		$albumDirThumbStatHtml['infoDialogBox']['globalstat2binstr']=$hexCode_StrRep;	
	} // END SHOW_INFOWINDOW
	else {// IF PAGE IS RELOADED OR CALLED BY CHILD
		$albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0]['DisplayModus']=NO_STAT_DISPLAY_MODE;
		list($upd_iminfo,$upd_media_dir,$iminfo_xml_stat)=check_mediacount_iminfo_files($albumDirThumbStatHtml['infoDialogBox']['htmlStatCode'][0],$iminfo_objs,'',$media);
	}

	$upd_data=array_fill_keys(array_column($upd_media_dir,'name'),array_fill(0,2,0));
	$i=0;
	foreach ($upd_data as &$data){
		$data[0]=$upd_iminfo[$i];
		$data[1]=$upd_media_dir[$i]['modus'];
		$i++;
	}
	unset($data);
	if (!$upd_notification) {
		// If updated was needed then it was not a regular web page visit --> not considered as web page visit.
		PageVisitNotification($albumDirThumbStatHtml,$wdir,$ip);
	}
	chdir($pwd);
	if ($session['caller']==='child'){$media['UpdateAction']=NO_MEDIA_PROCESSING;}
	$additional_removed_media=FALSE;
	$albumDirThumbStatHtml['status']['proposeRegUserOrAdmin']['login']=$proposeUserOrAdminLogin;
	$albumDirThumbStatHtml['status']['permissionDeleteProcFile']=$XFFFFF['permissionDeleteProcFile'];
	$albumDirThumbStatHtml['status']['globStat']=$XFFFFF['GlobStat'];
	$albumDirThumbStatHtml['status']['action_offset']=$XFFFFF['GlobStat']-RPROC_STAT_EXIST;
	$albumDirThumbStatHtml['status']['action_offset']=($XFFFFF['GlobStat']&RPROC_STAT_MASK)-RPROC_STAT_EXIST;
	$albumDirThumbStatHtml['status']['time_stat']=$XFFFFF['GlobStat']&RESIZE_STAT_MASK_TIMECHANGE;
	$albumDirThumbStatHtml['status']['resize_stat']=$XFFFFF['GlobStat']&RESIZE_STAT_MASK_2;
// Begin Album update conditions
	if (($media['RemovedCount']>0)||($media['NewCount']>0)) $additional_removed_media=TRUE;
	$albumDirThumbStatHtml['status']['updateSuggested']=((($XFFFFF['GlobStat']-RPROC_STAT_EXIST)>>(NUMBER_OF_BITS_PER_DIGIT*2))>0)
      ||($albumDirThumbStatHtml['status']['time_stat']>=4)||($additional_removed_media);
// End Album update conditions
//	$albumDirThumbStatHtml['status']['updIminfoCMIF_1']=array_combine(array_column($upd_media_dir,'name'),$upd_iminfo);
	$albumDirThumbStatHtml['status']['updIminfoCMIF_1']=$upd_data;
	$albumDirThumbStatHtml['media']['iminfo']=$media;
	$albumDirThumbStatHtml['media']['new_M']=$NewMedia;
	$albumDirThumbStatHtml['media']['remove_M']=$RemMedia;
	return array($XFFFFF['GlobStat'],$xml_defs,$iminfo_xml_stat,$upd_media_dir,$SysErrCode);
}

5.6. GenerateDirOverview()

Interface definition

GenerateDirOverview(&$albumDirThumbStatHtml, $session, $gpf, $xml_defs, $iminfo_xml_stat, $upd_media_dir)

Function is called by the main script of php\prepareDirOverviewGalleryAjax.php. Generates HTML code of directory overview page. The variable parts of the page are stored in jsList object (member of albumDirThumbStatHtml_Object).

Parameters:
Returns:

void

5.6.1. Source code

<?php
function GenerateDirOverview(&$albumDirThumbStatHtml,$session,$gpf,$xml_defs,$iminfo_xml_stat,$upd_media_dir){
	$pwd=getcwd();
	$parent=$_SERVER['DOCUMENT_ROOT'].DS.$session['parent'];
	$wdir=$parent.DS.$session['dir'];
//	$wdir=$session['parent'].DS.$session['dir'];
	chdir($wdir);
	if ($session['private']){$m=1;$n=1;}else{$m=2;$n=0;}
	$urlDir=rawurlencode($session['dir']);
	$urlParent=rawurlencode($session['parent']);
	$wdir=str_replace(' ','%20',$session['parent'].DS.$session['dir']);
	$dirCnt=$xml_defs->directory->count();
	$albumDirThumbStatHtml['jsList']=array_fill(0,$dirCnt,array());
	$i=0;
	$attProp=array_fill(0,6,array('id'=>'','src'=>'','class'=>'','title'=>'','href'=>'','onclick'=>'','innerHTML'=>'','alt'=>''));
	if (array_key_exists('HeeftBeschrijvingen',$xml_defs)&&($xml_defs->HeeftBeschrijvingen==1)){
		$albumDirThumbStatHtml['phpDef']['dirDescription']=true;
		foreach ($xml_defs->directory as $key => $ldir){
			$dirname=$ldir->name;
			if (is_dir($dirname)){
				$subDir=rawurlencode($dirname);
				$fIcon=$session['parent'].DS.$session['dir'].DS.$subDir.'.jpg';
				$imCnt=$iminfo_xml_stat[$i]['xml_pub_im']+$n*$iminfo_xml_stat[$i]['xml_prv_im'];
				$viCnt=$iminfo_xml_stat[$i]['xml_pub_vi']+$n*$iminfo_xml_stat[$i]['xml_prv_vi'];
				if (array_key_exists('thumb_caption',$ldir)){
					$title=$ldir->thumb_caption;
				}else {$title=$ldir->name;}
				$urlTitle=rawurlencode($title);
				$IDname=str_replace(' ','',$ldir->name);
				$ID_img_name=str_replace(' ','',$ldir->name).'_img';
				$umd=$upd_media_dir[$i]['modus'];
				$images=UPD_PUB_IMAGES+UPD_PRV_IMAGES;
				$videos=UPD_PUB_VIDEOS+UPD_PRV_VIDEOS;
				$IDanchorTitle=str_replace(' ','','Anchor'.$title);
				$nl_tab=array('\n','\t');
				$str=str_replace($nl_tab,"",($xml_defs->directory[$i]->verslag->asXML()));
//				var xmlText = new XMLSerializer().serializeToString(xml);
//							$str=$xml_defs->directory[$key]->verslag;
				$link="$gpf?vacDir=$urlDir&locDir=$subDir&title=$urlTitle&parent=$urlParent";
				$attProp[0]['href']=$link;
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'a_1','nr'=>1,'attrib'=>$attProp[0]);
				$attProp[1]['src']=$fIcon;
				if ($umd===UPD_NOTHING) {
					$attProp[1]['class']='directoryThumb';
				}
				else if (($umd&$videos)&&($umd&$images)){// BOTH IMAGES AND VIDEOS MISSING
					$attProp[1]['class']='directoryThumbUpdate';
					$attProp[1]['title']='Missing videos and images';
				}
				else if (($umd&$videos)&&!($umd&$images)){// ONLY VIDEOS MISSING
					$attProp[1]['class']='directoryThumbUpdate_v';
					$attProp[1]['title']='Missing videos';
				}
				else if (!($umd&$videos)&&($umd&$images)){// ONLY IMAGES MISSING
					$attProp[1]['class']='directoryThumbUpdate_im';
					$attProp[1]['title']='Missing images';
				}
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'thumb_2','nr'=>3,'attrib'=>$attProp[1]);
				if ($viCnt)	$attProp[2]['innerHTML']="$imCnt fotos, $viCnt videos";
				else $attProp[2]['innerHTML']="$imCnt fotos";
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'caption_3','nr'=>1,'attrib'=>$attProp[2]);
				$attProp[3]['id']=$IDanchorTitle;
				$attProp[3]['href']=$link;
				$attProp[3]['innerHTML']=(string)$title;
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'a2_4','nr'=>3,'attrib'=>$attProp[3]);
				$attProp[4]['id']=$IDname;
				$attProp[4]['innerHTML']=$str;
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'divStoryContent_5','nr'=>2,'attrib'=>$attProp[4]);
				$attProp[5]['onclick']="fillStory('$IDname','$IDanchorTitle')";
				$attProp[5]['innerHTML']='Lees meer';
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'a3_6','nr'=>2,'attrib'=>$attProp[5]);
			}
			$i++;
		}
	} else { // Zonder reisverslag
		foreach ($xml_defs->directory as $key=>$ldir){
			$albumDirThumbStatHtml['phpDef']['dirDescription']=false;
			$dirname=$ldir->name;
			if (is_dir($dirname)){
				$subDir=rawurlencode($dirname);
				$fIcon=$session['parent'].DS.$session['dir'].DS.$subDir.'.jpg';
				$imCnt=$iminfo_xml_stat[$i]['xml_r_pub_im']+$n*$iminfo_xml_stat[$i]['xml_r_prv_im'];
				$viCnt=$iminfo_xml_stat[$i]['xml_r_pub_vi']+$n*$iminfo_xml_stat[$i]['xml_r_prv_vi'];
				if (array_key_exists('thumb_caption',$ldir)){$title=$ldir->thumb_caption;}
				else {$title='';}
				$urlTitle=rawurlencode($title);
				$attProp[0]['href']="$gpf?vacDir=$urlDir&locDir=$subDir&title=$urlTitle&parent=$urlParent";
				$attProp[1]['src']=$fIcon;
				if ($viCnt)	$attProp[2]['innerHTML']="$title <br> $imCnt fotos, $viCnt videos";
				else $attProp[2]['innerHTML']="$title <br> $imCnt fotos";
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'a','nr'=>1,'attrib'=>$attProp[0]);
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'thumb','nr'=>1,'attrib'=>$attProp[1]);
				$albumDirThumbStatHtml['jsList'][$i][]=array('jsvar'=>'caption','nr'=>1,'attrib'=>$attProp[2]);
			}
			$i++;
		}
	}
	chdir($pwd);
}

5.7. GetImageList4JSSOR()

Interface definition

GetImageList4JSSOR($albumDirThumbStatHtml, $wdir, $dirList)
Parameters:
  • &$albumDirThumbStatHtml (Pointer to Object) – Pointer to Object of type albumDirThumbStatHtml_Object (see Table 4.16).
  • $wdir (String) – Working directory.
  • $dir (Array) – Directory list
Returns:

$dirImageList: array_fill(0,$dirCount,array(‘isDir’=>true,’name’=>’’,’imList’=>array())), list of image filenames

5.7.1. Source code

<?php
function GetImageList4JSSOR($albumDirThumbStatHtml,$wdir,$dirList){
	$kk=new RemoteAddress;
	$ip=$kk->getIpAddress();
	PageVisitNotification($albumDirThumbStatHtml,$wdir,$ip);
	$dirCount=count($dirList);
	$dirImageList=array_fill(0,$dirCount,array('isDir'=>true,'name'=>'','imList'=>NULL));
	$captions=0;
	$pwd=getcwd();
	foreach ($dirList as $key => $dir){
		$dirImageList[$key]['name']=$dir;
		if (!is_dir($dir)) {
			$dirImageList[$key]['isDir']=false;
			continue;
		}
		if(count(scandir($dir))===2) continue;
		chdir($dir);
		/* Alphabetic ordered list*/
		$imlist=glob(IMAGE_FILES,GLOB_BRACE);
		$dirImageList[$key]['imList']=array_fill(0,count($imlist),'');
		foreach ($imlist as $key2 => $img){
			$dirImageList[$key]['imList'][$key2]=$dir.DS.$img;
		}
		chdir($pwd);
	}
	return $dirImageList;
}

5.8. InitMediaObject()

Interface definition

InitMediaObject()

Initializes media object

Parameters:
  • Void
Returns:

media object

5.8.1. Source code

<?php
function InitMediaObject(){
	$media=array(
		'CountList'=>array(),
		'NoMedia'=>FALSE,
		'UpdateAction'=>NO_MEDIA_PROCESSING,
		'NewCount'=>0,
		'NewImageCnt'=>0,
		'NewVideoCnt'=>0,
		'RemovedCount'=>0,
		'ImInfoNT_ImageCnt'=>0,
		'ImInfoNT_VideoCnt'=>0,
		'PutBackM_ImageCnt'=>0,
		'PutBackM_VideoCnt'=>0,
		'PutBackM_Cnt'=>0);
	return $media;
}

5.9. Mediacount_IMINFO_X0F000()

Interface definition

Mediacount_IMINFO_X0F000($upd_media_dir, $XFFFFF, $XFFFFF_Arr)

Copies the info in $upd_media_dir to variables $XFFFFF, and $XFFFFF_Arr, $upd_media_dir[*][‘modus’] = $X0F000, where * refers to all location directories. Each $upd_media_dir[*][‘modus’] is added to $XFFFFF_Arr[*][‘XFFFFF’] (by binary or operation and the PHP function array_walk() and see Table 3.11). The result is stored in the second output argument $X5F_Arr_upd. The variable $upd_media_dir is defined as an output argument of the function check_mediacount_iminfo_files().

Parameters:
Returns:

  1. $X5F_upd ( Object ) - XFFFFF object, updated array for $XFFFFF: 0x0F000. The updated values are determined as follows: $X5F_upd = $XFFFFF | $upd_media_dir[1][‘modus’] | $upd_media_dir[2][‘modus’] |… | … | $upd_media_dir[n][‘modus’]. The operation is implemented by the PHP function array_reduce().
  2. $X5F_Arr_Upd ( Object ) - XFFFFF_Arr object,

5.9.1. Source code

<?php
function Mediacount_IMINFO_X0F000($upd_media_dir,$XFFFFF,$XFFFFF_Arr){
	$X5F=$XFFFFF;
	$X5F_Arr=$XFFFFF_Arr;
// http://stackoverflow.com/questions/7994497/how-to-get-an-array-of-specific-key-in-multidimensional-array-without-looping (as of PHP 5.5)
	$modus=array_column($upd_media_dir,'modus');
// http://stackoverflow.com/questions/3325638/php-array-bitwise					
	$X5F['GlobStat']|=array_reduce($modus,'_or',0);
	$X5F['FillStat']|=0x0F000;
//$modus=array_map(function ($ar){return $ar['modus'];},$upd_media_dir);
	array_walk($X5F_Arr,'aw_cb_array_val',$modus);
	return array($X5F,$X5F_Arr);
}

5.10. PageVisitNotification()

Interface definition

PageVisitNotification(&$albumDirThumbStatHtml, $wdir, $ip)

Function is called by dirThumbs() and by GetImageList4JSSOR()

Parameters:
  • &$albumDirThumbStatHtml (Pointer) – Pointer to albumDirThumbStatHtml_Object
  • $wdir (String) – directory name of album,
  • $ip (String) – IP address of web-client,
Returns:

5.10.1. Source code

<?php
function PageVisitNotification(&$albumDirThumbStatHtml,$wdir,$ip){
// Output arg 2: $stat: 2 byte. Least significant byte: MYSQL servar stat. Most significant bye: E-mail stat
	$fname=$_SERVER['DOCUMENT_ROOT'].DS.'log'.DS.'webpage_visits.log';
	$count_fname=$_SERVER['DOCUMENT_ROOT'].DS.'log'.DS.'webpage_visits.cnt';
	if (file_exists($count_fname)){
		$visit_cnt=file($count_fname);// Is a very small file: contains only 1 integer (#website visits)
		$nlines=intval($visit_cnt[0])+1;
	}
	else { // Fallback
		if (file_exists($fname)) {
			$fcontent=file($fname);
			if ($fcontent) $nlines=count($fcontent)+1;
			else $nlines=1;
		}
		else $nlines=1;
	}
	$file=fopen($fname,'a+');
	$today=date('Y-m-d H:i:s');
	$str=$nlines.') '.$today.', '.$ip.', URI:'.$_SERVER['REQUEST_URI'].', Directory photo album:'.$wdir.PHP_EOL;
	fwrite($file,$str);
	fclose($file);
	$file=fopen($count_fname,"w");// Create or overwrite file "webpage_visits.cnt".
	fwrite($file,$nlines);
	fclose($file);
   $albumDirThumbStatHtml['server_info']['NumbSiteVisits']=$nlines;
	$nlines_mail=VISITCNT_PER_EMAIL;
	if (($nlines % $nlines_mail) === 0){ // Send an e-mail notification after every $nlines_mail website visits.
      $mail=CreateEmailContainer(WEBMASTER,false,$ip);
      $msg=$mail->sql_msg_arr;
      $albumDirThumbStatHtml['server_info']['mysql_server']['status']=$mail->sql_stat;
      $albumDirThumbStatHtml['server_info']['mysql_server']['server_msg']=$msg;
      if ($mail->obj_stat==1){
         $mail->Subject.='Overview of last '.$nlines_mail.' web page visits.';
         $mail->Body=date('Ymd-Hi',time()).'<br>'.PHP_EOL;
   // 	$mail->Body.=implode('<br>'.PHP_EOL,array_slice($fcontent,-$nlines_mail));
         $mail->Body.=implode('<br>'.PHP_EOL,explode("\n",tail($fname,$nlines_mail)));
         if(!$mail->send()){
            $albumDirThumbStatHtml['server_info']['email_server']['status']=1;
            $albumDirThumbStatHtml['server_info']['email_server']['server_msg']=array('code'=>-1,'message'=>$mail->ErrorInfo);
         } 
         else {
            $albumDirThumbStatHtml['server_info']['email_server']['status']=2;
         }
         //return array($status,$mail->ErrorInfo);
      }
      else {// Error creating mail object
         $albumDirThumbStatHtml['server_info']['email_server']['status']=-1;
         $albumDirThumbStatHtml['server_info']['email_server']['server_msg']=$msg;
         //return array(002,$msg);
      }
	}
//	return array(000,""); // #website visits is not an integer multiple of $nlines_mail --> No e-mail is send
}

5.11. rf_proc_stat()

Interface definition

rf_proc_stat($rproc, $fproc)
Parameters:
  • $rproc (String) – Filename,
  • $fproc (String) – Filename,
Returns:

Array(Boolean, Boolean)

5.11.1. Source code

<?php
function rf_proc_stat($rproc,$fproc){
	$rExist=file_exists($rproc)*RPROC_STAT_EXIST;
	$fExist=file_exists($fproc)*FPROC_STAT_EXIST;
	return array($rExist,$fExist);
}

5.12. RProc_FProc_Status_X00FF0()

Interface definition

RProc_FProc_Status_X00FF0($X5F, $xml_objs, $caller)

Depending on the existence of the files rproc.txt and fproc.txt, these files are created or not. The status is recorded in $XFFFFF (first output argument). The file rproc.txt is created with the info stored in $xml_objs. (The bit |••••|••••|•••X|••••|••••|, with X=0 if the file rproc.txt does not exist, is NOT YET set 1 when rproc.txt is recreated. When is this done?)

Function is called by dirThumbs().

Parameters:
Returns:

  1. $XFFFFF ( Object ) - XFFFFF object, key[‘FillStat’] is updated. The third output argument (i.e. $XFFFFF[‘FillStat’]) of the function CheckProcessStatus_X000FF() is updated with extra information. This extra information is stored in the second and third hexadecimal bit (see Table 2.2 and Table 2.4). Possible values for the second hexagonal bit are 0 (fproc.txt does not exist) and 1 (fproc.txt exists). Possible values for the third hexagonal bit are 0 (rproc.txt does not exist) and 1 (rproc.txt exists).
  2. $rData ( Matrix ) - see Section 3.1.2
    • If file rproc.txt exists, $rData contains the data of content of rproc.txt.
    • If file rproc.txt does not exist, rproc.txt is first created using $xml_objs, and $rData contains the data of content of the new created rproc.txt file.
  3. $MediaUpdateAction ( Enumerated values ) - 2 hexadecimal bit number with the following possible values:
    • NO_MEDIA_PROCESSING (= 0x00)
    • ALL_MEDIA_PROCESSING (= 0x01)
    • UPD_MEDIA_PROCESSING (= 0x02)

5.12.1. Source code

<?php
function RProc_FProc_Status_X00FF0($X5F,$xml_objs,$caller){
// Check if RPROC.TXT and FOTOSPROC.TXT exist: IF NOT CREATE THEM.
// INP1: $X5F
// INP2: xml_defs
// INP3: $caller
// OUT1: array with: $stat,$rData,$MediaProcessing (used on local server or admin),$DoMediaUpdate (used on local server or +++++++++++++++++++++)
	$rprocExist=$X5F['GlobStat']&RPROC_STAT_EXIST;
	$fprocExist=$X5F['GlobStat']&FPROC_STAT_EXIST;
	$MediaProcessing=NO_MEDIA_PROCESSING;
	$stat=$X5F['GlobStat']&RESIZE_STAT_MASK_2;
	switch ($stat) {
		case NO_PROCESSED_FILES:// CODE 0x00000
			if ($fprocExist) {
				unlink(FPROCFILE);
				$defFile=-1;
				echo "<script>\n";
				echo "alert('File fproc.txt has been deleted.');\n";
				echo "</script>\n";
				return array($defFile,0,0,0,1);
			}
			else { // fproc does not exist
				$fproc=fopen(FPROCFILE,"w");
				fclose($fproc);
				if (($_SERVER[SERVER_ADDR]==='127.0.0.1')||($session['uname']===ADMINISTRATOR)) {
					$MediaProcessing=ALL_MEDIA_PROCESSING;
				}
				else $MediaProcessing=NO_MEDIA_PROCESSING;
			}
			// Create RPROC file even if it exists already
			$rData=CreateRPROC(RPROCFILE,NO_PROCESSED_FILES,$xml_objs);
		break;
		case PROCESSED_FILES_ORIGINALS_KEPT:// CODE 0x00001
			$MediaProcessing=NO_MEDIA_PROCESSING;
			if ((!$fprocExist)&&($caller!='child')) {
				$fproc=fopen(FPROCFILE,"w");
				fclose($fproc);
			}
			if (!$rprocExist){$rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_KEPT,$xml_objs);}
			else {$rData=f_parse_csv(RPROCFILE,1000,',');}
		break;
		case PROCESSED_FILES_ORIGINALS_ADD_REM:// CODE 0x00002
			// Reload source: http://stackoverflow.com/questions/456841/php-refresh (rototechno)
			$reload=isset($_SERVER['HTTP_CACHE_CONTROL'])&&$_SERVER['HTTP_CACHE_CONTROL']==='max-age=0';
			if (($caller!='child')&&(!$reload)){
				if ($rprocExist&&$fprocExist){ // NORMAL SITUATION FOR CODE 0002
					$rData=f_parse_csv(RPROCFILE,1000,',');
					$MediaProcessing=NO_MEDIA_PROCESSING;
				}
				elseif (!FPROCFILE){
					$MediaProcessing=NO_MEDIA_PROCESSING;
					$fproc=fopen(FPROCFILE,"w");
					fclose($fproc);
					if ($rprocExist) {//MUST BE UPDATED
						// $fprocExist=0 and $rprocExist=1
						$rData=f_parse_csv(RPROCFILE,1000,',');
						$MediaProcessing|=UPD_MEDIA_PROCESSING;
					}
					else { // BOTH FPROC AND RPROC ARE DELETED.
						$rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_ADD_REM,$xml_objs);
						$MediaProcessing=ALL_MEDIA_PROCESSING;
					}
				}
				else { // $fprocExist==1 and $rprocExist==0
					$MediaProcessing|=UPD_MEDIA_PROCESSING;
					$rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_ADD_REM,$xml_objs);
				}
			}
			else { // Caller is child or reload
				$MediaProcessing=NO_MEDIA_PROCESSING;
				if ($rprocExist&&$fprocExist){$rData=f_parse_csv(RPROCFILE,1000,',');}
				elseif (!$fprocExist){
					if ($rprocExist) {
						// $fprocExist=0 and $rprocExist=1
						$rData=f_parse_csv(RPROCFILE,1000,',');
					}
					else $rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_ADD_REM,$xml_objs);
				}
				else $rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_KEPT,$xml_objs);
			}
		break;
		case PROCESSED_FILES_ORIGINALS_REMOVED:// CODE 0x00003
			$MediaProcessing=NO_MEDIA_PROCESSING; // For all scenario's
			if ((!$fprocExist)&&($caller!='child')) {
				$fproc=fopen(FPROCFILE,"w");
				fclose($fproc);
			}
			if (!$rprocExist){$rData=CreateRPROC(RPROCFILE,PROCESSED_FILES_ORIGINALS_REMOVED,$xml_objs);}
			else {$rData=f_parse_csv(RPROCFILE,1000,',');}
		break;
	}
	$X5F['FillStat']|=0x00FF0;
	return array($X5F,$rData,$MediaProcessing);
}

5.13. StatusInfoWindow()

Interface definition

StatusInfoWindow($dm, $wdir, $id, $rprocList, $stat, $X5F_Arr, $mediaObj)

Function compares media count in file rproc.txt and public / private directories. When logged on the “Media processing status” tables are displayed: this function will generate table 2 (tab title RPROC see Fig. 5.2).

Parameters:
  • $dm (Integer) – display modus. 3-digit byte (i.e. 3-digit octagonal number: 0xyz). Of each digit only 1 byte is used. Reason for using the octagonal range is that Dreamweaver editor does not recognize the binary PHP number representation (i.e. 0bxyz). See Section 2.4 and Table 2.13.
  • $wdir (String) – working directory
  • $id (String) – modal dialog ID for JQUERY
  • $rprocList (Matrix) – Matrix
  • $stat (Object) – part of XFFFFF object
  • $X5F_Arr (Object) – XFFFFF_Arr object
  • $mediaObj (Object) – Media object,
Returns:

$globStat (=$X5F[‘GlobStat’])

  • If (#Resized images + #Resized video) < #rproc public 🡺 Resized images / video cells have warning color.
  • If (#Private images + #Private video) < #rproc private 🡺 Private images / video cells have warning color.
  • If (#rproc public + #rproc private) < ((#Resized im. + #Resized vid. + #Private im. + #Private vid.) 🡺 rproc pub and rproc private cells have warning color
_images/Fig_DialogMsgBox_MediaProcessStatus.png

Fig. 5.2 Dialog message box: media process status.

5.13.1. Source code

<?php
function StatusInfoWindow(&$statDB_html,$info,$rprocList,$X5F,$mediaObj,$NewMedia=FALSE,$RemMedia=FALSE){
// STATUSINFOWINDOW compares media count in RPROC.TXT and Public/Private directories.
// INP1: : 
// INP2: info array: 1) wdir, 2) IP, 3) ModalClassID of OVERLAY DIV WINDOW, 4) New Deleted Media Table ID
// INP3: List with content of RPROC file.
// INP4: Location directory status (hexadecimal number)
// INP5: Media object.
	$dm=$statDB_html['DisplayModus'];
	$statDB_html['genTable']=($dm&01000);
	$em=($dm&00070); // echo mode
	$statDB_html['db_active']=$dm&00001;
	$statDB_html['db_buttons']=$dm&00100;
	$nrElements=count($mediaObj['CountList']);
	$pubpriv_bg=array_fill(0,$nrElements,array_fill_keys(array('pub_im','pub_vi','prv_im','prv_vi'),BACKGROUND_COLOR_NORMAL));
	$rprocColor=array_fill(0,$nrElements,BACKGROUND_COLOR_NORMAL);
	$loc_bg=array_fill(0,$nrElements,array_fill_keys(array('im','vi'),BACKGROUND_COLOR_NORMAL));
	$loc_bg_final=array_fill_keys(array('im','vi'),BACKGROUND_COLOR_NORMAL);
	$GlobStat=$X5F['GlobStat'];
	$additional_removed_media=FALSE;
	if (($mediaObj['RemovedCount']>0)||($mediaObj['NewCount']>0))	$additional_removed_media=TRUE;
	$j=0;
	foreach ($mediaObj['CountList'] as $media){
		$pubprivColor=BACKGROUND_COLOR_NORMAL;
		$rprocMediaCnt=$rprocList[$j][2]+$rprocList[$j][3];
		$pubprivCnt=$media['Rsz_images']+$media['Rsz_videos'];
		$pubprivCnt+=$media['Prv_images']+$media['Prv_videos'];
		if ($pubprivCnt < $rprocMediaCnt){
			if (($media['Rsz_images']+$media['Rsz_videos'])<$rprocList[$j][2]){
				$pubpriv_bg[$j]['pub_im']=BACKGROUND_COLOR_WARNING; // Table 2, column 5
				$pubpriv_bg[$j]['pub_vi']=BACKGROUND_COLOR_WARNING; // Table 2, column 6
			}
			if (($media['Prv_images']+$media['Prv_videos'])<$rprocList[$j][3]){
				$pubpriv_bg[$j]['prv_im']=BACKGROUND_COLOR_WARNING; // Table 2, column 7
				$pubpriv_bg[$j]['prv_vi']=BACKGROUND_COLOR_WARNING; // Table 2, column 8
			}
			$pubprivColor=BACKGROUND_COLOR_WARNING;
		}
		else if ($rprocMediaCnt < $pubprivCnt) {
			$rprocColor[$j]=BACKGROUND_COLOR_WARNING;
		}
		if ($media['loc_images']>($media['Rsz_images']+$media['Prv_images'])){
			$loc_bg[$j]['im']=BACKGROUND_COLOR_WARNING; // Table 2, column 3
			$loc_bg_final['im']=BACKGROUND_COLOR_WARNING;
		}
		if ($media['loc_videos']>($media['Rsz_videos']+$media['Prv_videos'])){
			$loc_bg[$j]['vi']=BACKGROUND_COLOR_WARNING; // Table 2, column 4
			$loc_bg_final['vi']=BACKGROUND_COLOR_WARNING;
		}
		$j++;
	}
	$hexCode_StrRep=_globalStat2Binstr($GlobStat);
	if ($statDB_html['genTable']){
		$RemMediaCnt=$mediaObj['RemovedCount'];
		$NewMediaCnt=$mediaObj['NewCount'];
		$class='.'.$info['modalClass'];
// Shift 2 digits
		$rproc_exists=($GlobStat&RPROC_STAT_MASK)>>(NUMBER_OF_BITS_PER_DIGIT*2);
// Shift 1 digit
		$fproc_exists=($GlobStat&FPROC_STAT_EXIST)>>(NUMBER_OF_BITS_PER_DIGIT);
		$resize_stat=$GlobStat&RESIZE_STAT_MASK_2;
		$time_stat=$GlobStat&RESIZE_STAT_MASK_TIMECHANGE;
		$iminfo_update_media=$GlobStat&UPD_MEDIA_MASK; // 0x0F000
//OK		my_echo($em,"$('$class h2').html('Media processing status');\n");
		$str="<table id=\"rproc-table\" class=\"modal-table\">";
		$str.="<thead style=\"background-color:#cecece\"><tr>";
		$toolTip="Sum of photographs and videos";
		$str.="<th title=\"".$toolTip."\">rproc<br>pub</th>";		//COL1 HEADER
		$str.="<th title=\"".$toolTip."\">rproc<br>priv</th>";	//COL2 HEADER
		$str.="<th>Location <br>dir img</th>";							//COL3 HEADER
		$str.="<th>Location <br>dir videos</th>";						//COL4 HEADER
		$str.="<th>Resized <br>img</th>";								//COL5 HEADER
		$str.="<th>Resized <br>video</th>";								//COL6 HEADER
		$str.="<th>Private <br>img</th>";								//COL7 HEADER
		$str.="<th>Private <br>video</th>";								//COL8 HEADER
		$str.="</tr></thead>";
		$str.="<tbody>";
		$i=1;
		foreach ($mediaObj['CountList'] as $media){
			$j=$i-1;
			if ($i<$nrElements){
				$str.='<tr>';
				$toolTip=$media['locDirname'];
				$str.="<td title=\"$toolTip\" style=\"background-color:".$rprocColor[$j]."\">".strval($rprocList[$j][2]).'</td>'; //COL1
				$str.="<td style=\"background-color:".$rprocColor[$j]."\">".strval($rprocList[$j][3]).'</td>'; //COL2
				$str.="<td style=\"background-color:".$loc_bg[$j]['im']."\">".$media['loc_images'].'</td>'; //COL3
				$str.="<td style=\"background-color:".$loc_bg[$j]['vi']."\">".$media['loc_videos'].'</td>'; //COL4
				$str.="<td style=\"background-color:".$pubpriv_bg[$j]['pub_im']."\">".$media['Rsz_images'].'</td>'; //COL5
				$str.="<td style=\"background-color:".$pubpriv_bg[$j]['pub_vi']."\">".$media['Rsz_videos'].'</td>'; //COL6
				$str.="<td style=\"background-color:".$pubpriv_bg[$j]['prv_im']."\">".$media['Prv_images'].'</td>'; //COL7
				$str.="<td style=\"background-color:".$pubpriv_bg[$j]['prv_vi']."\">".$media['Prv_videos'].'</td></tr>'; //COL8
			} else { // LAST ROW (SUM)
				if ($rprocMediaCnt===$pubprivCnt){
					$rprocColor[$j]=BACKGROUND_COLOR_OK;
					$pubpriv_bg[$j]['pub_im']=BACKGROUND_COLOR_OK;
					$pubpriv_bg[$j]['pub_vi']=BACKGROUND_COLOR_OK;
					$pubpriv_bg[$j]['prv_im']=BACKGROUND_COLOR_OK;
					$pubpriv_bg[$j]['prv_vi']=BACKGROUND_COLOR_OK;
					$finState=BACKGROUND_COLOR_OK;
				} else {
					$finState=BACKGROUND_COLOR_WARNING;
				}
				$str.='<tfoot>';
				$str.='<tr>';
				$str.="<th style=\"background-color:".$rprocColor[$j]."\">".strval($rprocList[$j][2]).'</th>';
				$str.="<th style=\"background-color:".$rprocColor[$j]."\">".strval($rprocList[$j][3]).'</th>';
				$str.="<th style=\"background-color:".$loc_bg_final['im']."\">".$media['loc_images'].'</th>';
				$str.="<th style=\"background-color:".$loc_bg_final['vi']."\">".$media['loc_videos'].'</th>';
				$str.="<th style=\"background-color:".$pubpriv_bg[$j]['pub_im']."\">".$media['Rsz_images'].'</th>';
				$str.="<th style=\"background-color:".$pubpriv_bg[$j]['pub_vi']."\">".$media['Rsz_videos'].'</th>';
				$str.="<th style=\"background-color:".$pubpriv_bg[$j]['prv_im']."\">".$media['Prv_images'].'</th>';
				$str.="<th style=\"background-color:".$pubpriv_bg[$j]['prv_vi']."\">".$media['Prv_videos'].'</th></tr>';
				$str.='</tfoot>';
			}
			$i++;
		}
		$str.='</tbody></table>';
		$statDB_html['htmlStringCode']=$str;
		$statDB_html['dialogStatus']=$GlobStat;
		$up_images=false;$up_videos=false;
// STATUS AND PROPOSED UPDATE ACTION MESSAGES
//		$action_offset=($GlobStat&(RPROC_STAT_MASK|RPROC_UPD_MEDIA_MASK))-RPROC_STAT_EXIST;
		$action_offset=($GlobStat&RPROC_STAT_MASK)-RPROC_STAT_EXIST;
		if (!$rproc_exists) $message="File \"rproc.txt\" is created with info from directory content. <br>";
		else $message="0X00F00 status: F>=1. File \"rproc.txt\" exists.<br>";
		$tab2ColorIsSet=false;
		$sLang=$statDB_html['sLang'];
		$binCode_rep=globalstat2binstr($GlobStat);
		$fprocHexStr=globalstat_1pos_2binstr($GlobStat,2);
		$rprocHexStr=globalstat_1pos_2binstr($GlobStat,3);
		if ($sLang==="JQUERY"){
			switch($action_offset){//0X00F00
				case RPROC_STAT_UPD_WITH_PUBPRIV_COUNT:
					$message.='Action code:0X00F00-[2]. Based on file count update of RPROC.TXT needed: <br> &#160 with public/private count.<br>';
					$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F00'});";
					$statDB_html['jsList'][]="$('$class a#tab2').attr({'data-selectedTabColor':'#F00','data-unselectedTabColor':'#F77'});";
					$tab2ColorIsSet=true;
				break;
				case RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT:
					$message.='Action code:0X00F00-[4]. Based on file count update of RPROC.TXT needed: <br> &#160 with location image count.<br>';
					$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F90'});";
					$tab2ColorIsSet=true;
				break;
				case RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT:
					$message.='Action code:0X00F00-[8]. Based on file count update of RPROC.TXT needed: <br> &#160 with location video count.<br>';
					$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F90'});";
					$tab2ColorIsSet=true;
				break;
				case (RPROC_STAT_UPD_WITH_PUBPRIV_COUNT|RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT):
					$message.='Action code:0X00F00-[6]. Based on file count update of RPROC.TXT needed: <br> &#160 with pub/priv, and loc/image count.<br>';
					$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F00'});";
					$statDB_html['jsList'][]="$('$class a#tab2').attr({'data-selectedTabColor':'#F00','data-unselectedTabColor':'#F77'});";
					$tab2ColorIsSet=true;
				break;
				case (RPROC_STAT_UPD_WITH_PUBPRIV_COUNT|RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT):
					$message.='Action code:0X00F00-[B]. Based on file count update of RPROC.TXT needed: <br> &#160 with pub/priv, and loc/video count.<br>';
					$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F00'});";
					$statDB_html['jsList'][]="$('$class a#tab2').attr({'data-selectedTabColor':'#F00','data-unselectedTabColor':'#F77'});";
					$tab2ColorIsSet=true;
				break;
				case (RPROC_STAT_UPD_WITH_PUBPRIV_COUNT|RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT|RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT):
					$message.='Action code:0X00F00-[D]. Based on file count update of RPROC.TXT needed: <br> &#160 with pub/priv, and loc/image-video count.<br>';
					$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F00'});";
					$statDB_html['jsList'][]="$('$class a#tab2').attr({'data-selectedTabColor':'#F00','data-unselectedTabColor':'#F77'});";
					$tab2ColorIsSet=true;
				break;
			} // END SWITCH ACTION_OFFSET
			if (($GlobStat&RPROC_UPD_MEDIA_MASK)===(RPROC_UPD_PUB_MEDIA|RPROC_UPD_PRV_MEDIA)){
				$message.='Action code: 0XF0000-[1,2] According to RPROC.TXT updating of media is needed.<br>';
				$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#F00'});";
				$statDB_html['jsList'][]="$('$class a#tab2').attr({'data-selectedTabColor':'#F00','data-unselectedTabColor':'#F77'});";
				$tab2ColorIsSet=true;
			}
			switch ($time_stat){
				case LOCATION_DIR_HAS_CHANGED:
					$message.='At least one location directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
				case PUBLIC_DIR_HAS_CHANGED:
					$message.='At least one public(Resized) directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
				case PUBLIC_DIR_HAS_CHANGED|LOCATION_DIR_HAS_CHANGED:
					$message.='At least one location and public(Resized) directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
			} // END SWITCH TIME_STAT
			if ($pubprivColor===BACKGROUND_COLOR_WARNING){
				if (($pubpriv_bg[$j]['pub_im']===BACKGROUND_COLOR_WARNING)||($pubpriv_bg[$j]['prv_im']===BACKGROUND_COLOR_WARNING)){
					$up_images=true;
				}
				if (($pubpriv_bg[$j]['pub_vi']===BACKGROUND_COLOR_WARNING)||($pubpriv_bg[$j]['prv_vi']===BACKGROUND_COLOR_WARNING)){
					$up_videos=true;
				}
		// NOT USED -> SKIP CODE
		//		if ($up_images&&$up_videos) $action|=PPUPD_ALL_MEDIA;
		//		else if ($up_images&&!$up_videos) $action|=PPUPD_IMAGES;
		//		else if (!$up_images&&$up_videos) $action|=PPUPD_VIDEOS;
				$message.='Update public and private directories (by deleting file \"fproc.txt\")<br>';
			}
// Generate HTML code
			$statDB_html['jsList'][]="$('$class #modal-messages2').html('Global STATUS CODE (bin.rep.): $binCode_rep<br>');";
			$statDB_html['jsList'][]="$('$class #modal-messages2').append('STATUS / ACTION CODE: $message');";
			$statDB_html['jsList'][]="$('$class #mm-Left').append('Resize process result (F1:xx..): $resize_stat<br>');";
			$statDB_html['jsList'][]="$('$class #mm-Left').append('Existence fproc_file (F2): $fprocHexStr<br>');";
			$statDB_html['jsList'][]="$('$class #mm-Left').append('Existence rproc_file (F3): $rprocHexStr<br>');";
			$statDB_html['jsList'][]="$('$class #mm-Left').append('Server name:".$_SERVER['SERVER_NAME']."<br>');";
			$statDB_html['jsList'][]="$('$class #mm-Left').append('Server IP address:".$_SERVER['SERVER_ADDR']."<br>');";
			$statDB_html['jsList'][]="$('$class').first().css({'visibility':'visible','opacity':1});";
			$statDB_html['jsList'][]="$('body').addClass('modal-open');";
			if ($statDB_html['db_active']){$statDB_html['jsList'][]="$('$class .modal-body2').css({'display':'inline-block'});";}
			else {
				$statDB_html['jsList'][]="$('$class .modal-body2').css({'display':'none'});";
				$statDB_html['jsList'][]="$('$class a#no').html('Cancel');";
				$statDB_html['jsList'][]="$('$class a#ok').html('Logon');";
			}
			if (((($GlobStat-RPROC_STAT_EXIST) >> (NUMBER_OF_BITS_PER_DIGIT*2))>0)||($time_stat>=4)||($additional_removed_media)){
				$statDB_html['jsList'][]="$('$class #mm-Right').html('Delete FOTOSPROC.TXT file for processing new media?');";
				if ($time_stat){
					$statDB_html['jsList'][]="$('$class #modal-messages3').html('Global STATUS CODE (bin.rep.): $binCode_rep<br>');";
					$statDB_html['jsList'][]="$('$class #modal-messages3').append('STATUS / ACTION CODE: $message');";
					$statDB_html['jsList'][]="$('$class #mm-Right').html('Delete FOTOSPROC.TXT file for updating directory content?');";
				}
				if ($X5F['permissionDeleteProcFile']){StatusInfoWindow_ok_Callbacks($class,$NewMediaCnt,$RemMediaCnt,$NewMedia,$RemMedia,$info);}
				else {
					$statDB_html['jsList'][]="$('$class a#ok').click(function(){ $('#login_button').trigger('click');overlayClose()});";
					$statDB_html['jsList'][]="$('$class #mm-Right').html('FOTOSPROC.TXT file has to be removed for updating directory content.<br>');";
					$statDB_html['jsList'][]="$('$class #mm-Right').append('This can only be done when admin user is logged on.<br>');";
					$statDB_html['jsList'][]="$('$class #mm-Right').append('Do you want to log on?');";
				}
			}
			else {
				$statDB_html['jsList'][]="$('$class a#ok').css({'display':'none'});";
				$statDB_html['jsList'][]="$('$class a#no').html('Close');";
			}
			if (!$tab2ColorIsSet) {
				$statDB_html['jsList'][]="$('$class a#tab2').css({'background':'#0F0'});";
				$statDB_html['jsList'][]="$('$class a#tab2').attr({'data-selectedTabColor':'#0F0','data-unselectedTabColor':'#7F7'});";
			}
			if ($dm&00100) {$statDB_html['jsList'][]="$('$class #modal-messages2b').css({'display':'table'});";}
			else {
				$statDB_html['jsList'][]="$('$class #modal-messages2b').css({'display':'none'});";
				$statDB_html['jsList'][]="$('$class a#ok').css({'display':'none'});";
				$statDB_html['jsList'][]="$('$class a#no').html('Close');";
			}
			$statDB_html['jsList'][]="$('$class #mm-Left').css({'width':'50%'});";
		}
		else if ($sLang==="JAVASCRIPT") {
			switch($action_offset){//0X00F00
				case RPROC_STAT_UPD_WITH_PUBPRIV_COUNT:
					$message.='Action code:0X00F00-[2]. Based on file count update of RPROC.TXT needed: <br> &#160 with public/private count.<br>';
					$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F00';";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-selectedTabColor','#F00');";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-unselectedTabColor','#F77');";
					$tab2ColorIsSet=true;
				break;
				case RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT:
					$message.='Action code:0X00F00-[4]. Based on file count update of RPROC.TXT needed: <br> &#160 with location image count.<br>';
					$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F90';";
					$tab2ColorIsSet=true;
				break;
				case RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT:
					$message.='Action code:0X00F00-[8]. Based on file count update of RPROC.TXT needed: <br> &#160 with location video count.<br>';
					$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F90';";
					$tab2ColorIsSet=true;
				break;
				case (RPROC_STAT_UPD_WITH_PUBPRIV_COUNT|RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT):
					$message.='Action code:0X00F00-[6]. Based on file count update of RPROC.TXT needed: <br> &#160 with pub/priv, and loc/image count.<br>';
					$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F00';";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-selectedTabColor','#F00');";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-unselectedTabColor','#F77');";
					$tab2ColorIsSet=true;
				break;
				case (RPROC_STAT_UPD_WITH_PUBPRIV_COUNT|RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT):
					$message.='Action code:0X00F00-[B]. Based on file count update of RPROC.TXT needed: <br> &#160 with pub/priv, and loc/video count.<br>';
					$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F00';";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-selectedTabColor','#F00');";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-unselectedTabColor','#F77');";
					$tab2ColorIsSet=true;
				break;
				case (RPROC_STAT_UPD_WITH_PUBPRIV_COUNT|RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT|RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT):
					$message.='Action code:0X00F00-[D]. Based on file count update of RPROC.TXT needed: <br> &#160 with pub/priv, and loc/image-video count.<br>';
					$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F00';";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-selectedTabColor','#F00');";
					$statDB_html['jsList'][]="tabs[1].setAttribute('data-unselectedTabColor','#F77');";
					$tab2ColorIsSet=true;
				break;
			} // END SWITCH ACTION_OFFSET
			if (($GlobStat&RPROC_UPD_MEDIA_MASK)===(RPROC_UPD_PUB_MEDIA|RPROC_UPD_PRV_MEDIA)){
				$message.='Action code: 0XF0000-[1,2] According to RPROC.TXT updating of media is needed.<br>';
				$statDB_html['jsList'][]="tabs[1].style.backgroundColor='#F00';";
				$statDB_html['jsList'][]="tabs[1].setAttribute('data-selectedTabColor','#F00');";
				$statDB_html['jsList'][]="tabs[1].setAttribute('data-unselectedTabColor','#F77');";
				$tab2ColorIsSet=true;
			}
			switch ($time_stat){
				case LOCATION_DIR_HAS_CHANGED:
					$message.='At least one location directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
				case PUBLIC_DIR_HAS_CHANGED:
					$message.='At least one public(Resized) directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
				case PUBLIC_DIR_HAS_CHANGED|LOCATION_DIR_HAS_CHANGED:
					$message.='At least one location and public(Resized) directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
			} // END SWITCH TIME_STAT
			if ($pubprivColor===BACKGROUND_COLOR_WARNING){
				if (($pubpriv_bg[$j]['pub_im']===BACKGROUND_COLOR_WARNING)||($pubpriv_bg[$j]['prv_im']===BACKGROUND_COLOR_WARNING)){
					$up_images=true;
				}
				if (($pubpriv_bg[$j]['pub_vi']===BACKGROUND_COLOR_WARNING)||($pubpriv_bg[$j]['prv_vi']===BACKGROUND_COLOR_WARNING)){
					$up_videos=true;
				}
				$message.='Update public and private directories (by deleting file \"fproc.txt\")<br>';
			}
// Generate HTML code
			$elm="mediaProcStatDB";
			$query=".querySelector";
			$statDB_html['jsList'][]="modal_messages2.innerHTML='Global STATUS CODE (bin.rep.): $binCode_rep<br>';";
			$statDB_html['jsList'][]="modal_messages2.insertAdjacentHTML('beforeend','STATUS / ACTION CODE: $message');";
			$statDB_html['jsList'][]="mm_left.innerHTML='Resize process result (F1:xx..): $resize_stat<br>';";
			$statDB_html['jsList'][]="mm_left.insertAdjacentHTML('beforeend','Existence fproc_file (F2): $fprocHexStr<br>');";
			$statDB_html['jsList'][]="mm_left.insertAdjacentHTML('beforeend','Existence rproc_file (F3): $rprocHexStr<br>');";
			$statDB_html['jsList'][]="mm_left.insertAdjacentHTML('beforeend','Server name:".$_SERVER['SERVER_NAME']."<br>');";
			$statDB_html['jsList'][]="mm_left.insertAdjacentHTML('beforeend','Server IP address:".$_SERVER['SERVER_ADDR']."');";
			$statDB_html['jsList'][]=$elm.".style.cssText='visibility: visible;opacity: 1;';";
			$statDB_html['jsList'][]="document.getElementsByTagName('BODY')[0].classList.add('modal-open')";
			if ($statDB_html['db_active']){$statDB_html['jsList'][]=$elm.$query."('.modal-body2').style.display='inline-block';";}
			else {
				$statDB_html['jsList'][]=$elm.$query."('.modal-body2').style.display='none';";
				$statDB_html['jsList'][]=$elm.$query."('a#no').innerHTML='Cancel';";
				$statDB_html['jsList'][]=$elm.$query."('a#ok').innerHTML='Logon';";
			}
			if (((($GlobStat-RPROC_STAT_EXIST) >> (NUMBER_OF_BITS_PER_DIGIT*2))>0)||($time_stat>=4)||($additional_removed_media)){
				$statDB_html['jsList'][]=$elm.$query."('#mm-Right').innerHTML='Delete FOTOSPROC.TXT file for processing new media?';";
				if ($time_stat){
					$statDB_html['jsList'][]=$elm.$query."('#modal-messages3').innerHTML='Global STATUS CODE (bin.rep.): $binCode_rep<br>';";
					$statDB_html['jsList'][]=$elm.$query."('#modal-messages3').insertAdjacentHTML('beforeend','STATUS / ACTION CODE: $message');";
					$statDB_html['jsList'][]=$elm.$query."('#mm-Right').innerHTML='Delete FOTOSPROC.TXT file for updating directory content?';";
				}
				if ($X5F['permissionDeleteProcFile']){StatusInfoWindow_ok_Callbacks($class,$NewMediaCnt,$RemMediaCnt,$NewMedia,$RemMedia,$info);}
				else { // FIXED TEXT
					$statDB_html['jsList'][]=$elm.$query."('a#ok').onclick=function(){ $('#login_button').trigger('click');overlayClose()};";
					$statDB_html['jsList'][]=$elm.$query."('#mm-Right').innerHTML='FOTOSPROC.TXT file has to be removed for updating directory content.<br>'";
					$statDB_html['jsList'][]=$elm.$query."('#mm-Right').insertAdjacentHTML('beforeend','This can only be done when admin user is logged on.<br>');";
					$statDB_html['jsList'][]=$elm.$query."('#mm-Right').insertAdjacentHTML('beforeend','Do you want to log on?');";
				}
			}
			else { // FIXED TEXT
				$statDB_html['jsList'][]=$elm.$query."('a#ok').style.display='none';";
				$statDB_html['jsList'][]=$elm.$query."('a#no').innerHTML='Close';";
			}
			if (!$tab2ColorIsSet) { // FIXED TEXT
				$statDB_html['jsList'][]=$elm.$query."('a#tab2').style.backgroundColor='#0F0';";
				$statDB_html['jsList'][]=$elm.$query."('a#tab2').setAttribute('data-selectedTabColor','#0F0');";
				$statDB_html['jsList'][]=$elm.$query."('a#tab2').setAttribute('data-unselectedTabColor','#7F7');";
			}
			if ($dm&00100) {$statDB_html['jsList'][]=$elm.$query."('#modal-messages2b').style.display='table';";}
			else { // FIXED TEXT
				$statDB_html['jsList'][]=$elm.$query."('#modal-messages2b').style.display='none';";
				$statDB_html['jsList'][]=$elm.$query."('a#ok').style.display='none';";
				$statDB_html['jsList'][]=$elm.$query."('a#no').innerHTML='Close';";
			}
			$statDB_html['jsList'][]="mm_left.style.width='50%';";			
		} // END JAVASCRIPT
		else if ($sLang==="FULL_JAVASCRIPT") {
// PREVIOUS CODE MOVED TO MEDIAPROCESSINGDIALOGBOX IN GENERATE_JSSOR_CODE.JS AND IS EXECUTED IN AN AJAX CALL
			switch ($time_stat){
				case LOCATION_DIR_HAS_CHANGED:
					$message.='At least one location directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
				case PUBLIC_DIR_HAS_CHANGED:
					$message.='At least one public(Resized) directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
				case PUBLIC_DIR_HAS_CHANGED|LOCATION_DIR_HAS_CHANGED:
					$message.='At least one location and public(Resized) directory has changed.<br>';
					if (($resize_stat===PROCESSED_FILES_ORIGINALS_REMOVED)&&($mediaObj['NewCount']===0)){$message.=' But no new media found.';}
				break;
			} // END SWITCH TIME_STAT
			if ($pubprivColor===BACKGROUND_COLOR_WARNING){
				if (($pubpriv_bg[$j]['pub_im']===BACKGROUND_COLOR_WARNING)||($pubpriv_bg[$j]['prv_im']===BACKGROUND_COLOR_WARNING)){
					$up_images=true;// NOT USED ANYMORE
				}
				if (($pubpriv_bg[$j]['pub_vi']===BACKGROUND_COLOR_WARNING)||($pubpriv_bg[$j]['prv_vi']===BACKGROUND_COLOR_WARNING)){
					$up_videos=true;// NOT USED ANYMORE
				}
				$message.='Update public and private directories (by deleting file \"fproc.txt\")<br>';
			}
			$statDB_html['jsList'][]=$message;
		} // END FULL_JAVASCRIPT
	}
	return $hexCode_StrRep;
}

5.14. StatusInfoNewOrDeletedMedia()

Interface definition

StatusInfoNewOrDeletedMedia(&$statDB_html, $modalClassID, &$new_media, $newmedia_cnt, &$rem_media, $remmedia_cnt)

Information about new media and removed media (obtained in function DetailedStatusAnalysis()) is stored in input arguments $new_media, and $rem_media, respectively. If there are no new or no removed media detected the function will do nothing and return an empty string. Otherwise table 4 (tab title New/Removed media, with ID “NewOrDeletedMedia-table”) will be generated (see Fig. 5.3 and Fig. 5.4).

Parameters:
  • &$statDB_html (Pointer) – Pointer to albumDirThumbStatHtml_Object
  • $modalClassID (String) – modal dialog ID for JQUERY,
  • &$new_media (Pointer to array of Strings) – new media list,
  • $newmedia_cnt (Integer) – Number of new media,
  • &$rem_media – removed media list,
  • $rem_media_cnt – Number of removed media,
Returns:

HTML ID (String) tag of table with new and deleted media. If there are no new or deleted media then ID tag is an empty string.

_images/Fig25_NewMediaDetected.png

Fig. 5.3 Dialog message box media process status: new media detected

_images/Fig26_RemovedMediaDetected.png

Fig. 5.4 Dialog message box media process status: removed media detected

The table in the “New/Removed media” tab has 5 columns (see Fig. 5.4):

  1. Location directory

  2. Media filename. Each cell element in this column has 2 HTML-5 data-value attributes

    1. data-pubpriv: public or private,
    2. data-orgname: original media filename (without time sorting prefix),
  3. Number of media files: for images, this number is 1. For videos, the number of files is determined by the number of different video extensions (e.g. mp4, webm)

  4. String can have the following values:

    1. “New media” (see Fig. 5.3).
    2. “Removed media Has original”. Because of the availability of the original file, the media can be put back if needed. Otherwise the iminfo entry will be updated: the tag Transferred2SiteDir will be set to 0 (TRANSFER_NONE). The choice can be made in column 5.
    3. Removed media: no original media file is available. The media entry in the iminfo.xml file will be deleted. The cell in column will be empty.
  5. 2 radio buttons: For “Removed media. Has original” the possible options are:

    1. Update iminfo (tag Transferred2SiteDir)
    2. Put back: move or copy to public or private directory (is determined by the data-pubpriv attribute of the cell in column 2.

    For new media the options are:

    1. Public
    2. Private

5.14.1. Source code

<?php
function StatusInfoNewOrDeletedMedia(&$statDB_html,$modalClassID,&$new_media,$newmedia_cnt,&$rem_media,$remmedia_cnt){
// OUT1: ID of table with new and deleted media. If there are no new or deleted media then ID is empty string.
	$dm=$statDB_html['DisplayModus'];
	$statDB_html['genTable']=($dm&01000)&&((strlen($modalClassID)>1));
	$statDB_html['db_active']=$dm&00001;
	$statDB_html['db_buttons']=$dm&00100;
	$em=($dm&00010);
	if (($newmedia_cnt===0)&&($remmedia_cnt===0)) return "";
	if ($statDB_html['genTable']){
		$class='.'.$modalClassID;
		$str="<table id=\"NewOrDeletedMedia-table\" class=\"modal-table\">";
		$str.="<thead style=\"background-color:#cecece\"><tr>";
		$str.='<th>Location <br>directory</th>';// Column 1 header
		$str.='<th>Media filename</th>';// Column 2 header
		$str.='<th>#Files</th>';// Column 3 header
		$str.='<th>New / Removed</th>';// Column 4 header
		$str.='<th>Pub/Private<br>Upd.Iminfo/Put back</th>';// Column 5 header
		$str.='</tr></thead>';
		$str.='<tbody>';
		$cnt=1;
		if ($newmedia_cnt>0) foreach ($new_media as $key=>$loc){
			// For new media data-pubpriv attribute is not known because it is determined by the user
			if ($loc['image_count']>0){
				$new_image_loc=$loc['image_files'];
				foreach ($new_image_loc as $key2=>$new_image){
					$str.='<tr>';
					$str.='<td>'.$key.'</td>';
					$str.="<td data-pubpriv=\"NA\" data-orgname=\"".$new_image[0]['name']."\">".$new_image[0]['name'].'</td>';
					$str.='<td>'.'1'.'</td>';
					$grpName='radio'.$cnt;
					$str.='<td>New media</td>';
					$str.="<td><div class=\"new_removed_radio_options\"><label><input type=\"radio\" name=\"$grpName\" value=\"Public\" checked>(Pub)</label></div><div class=\"new_removed_radio_options\"><label><input type=\"radio\" name=\"$grpName\" value=\"Private\">(Priv)</label></div></td>";
					$str.='</tr>';
					$new_media[$key]['image_files'][$key2][0]['tableEntry']=$cnt;
					$cnt++;
				}
			}
			if ($loc['video_count']>0){
				$new_video_loc=$loc['video_files'];
				foreach ($new_video_loc as $key2=>$new_video){
					$str.='<tr>';
					$str.='<td>'.$key.'</td>';
					$str.="<td data-pubpriv=\"NA\" data-orgname=\"".$new_video[0]['name']."\">".$new_video[0]['name'].'</td>';
					$str.='<td>'.strval(count($new_video)).'</td>';
					$grpName='radio'.$cnt;
					$str.='<td>New media</td>';
					$str.="<td><div class=\"new_removed_radio_options\"><label><input type=\"radio\" name=\"$grpName\" value=\"Public\" checked>(Pub)</label></div><div class=\"new_removed_radio_options\"><label><input type=\"radio\" name=\"$grpName\" value=\"Private\">(Priv)</label></div></td>";
					$str.='</tr>';
					$new_media[$key]['video_files'][$key2][0]['tableEntry']=$cnt;
					$cnt++;
				}
			}
		}
		if ($remmedia_cnt>0) foreach ($rem_media as $key=>$loc){
			foreach ($loc as $key2=>$removed){
				$orgName=$removed['location_org_name'];
				$str.='<tr>';
				$str.='<td>'.$key.'</td>';
				$str.="<td data-pubpriv=\"".$removed['public_private']."\" data-orgname=\"".$orgName."\">".$removed['name'].'</td>';
				$str.='<td>'.'1'.'</td>';
				$grpName='radio'.$cnt;
				if (file_exists($key.DS.$orgName)){
					$str.="<td style=\"background-color:#55FF55\">Removed media<br>Has original</td>";
					if ($removed['TransferStatus']!=TRANSFER_NONE)
						$str.="<td><div class=\"new_removed_radio_options\"><input type=\"radio\" name=\"$grpName\" value=\"NotPutBack\">(U.i)</div><div class=\"new_removed_radio_options\"><input type=\"radio\" name=\"$grpName\" value=\"PutBack\" checked>(P.B.)</div></td>";
					else
						$str.="<td><div class=\"new_removed_radio_options\"><input type=\"radio\" name=\"$grpName\" value=\"NotPutBack\" checked><label for=\"NotPutBack\"> - U.I.</label></div><div class=\"new_removed_radio_options\"><input type=\"radio\" name=\"$grpName\" value=\"PutBack\"><label for=\"PutBack\"> - P.B.</label></div></td>";
				}
				else { // ORIGINAL FILE NOT AVAILABLE
					$str.="<td style=\"background-color:#FFAA00\">Removed media<br>No original</td>";
					$str.="<td><div class=\"new_removed_radio_options\"><label><input type=\"radio\" disabled>(U.i)</label></div><div class=\"new_removed_radio_options\"><label><input type=\"radio\" disabled>(P.B.)</label></div></td>";
				}
				$str.='</tr>';
				$rem_media[$key][$key2]['tableEntry']=$cnt;
				$cnt++;
			}
		}
		$str.='</tbody></table>';
		$statDB_html['htmlStringCode']=$str;
		return "NewOrDeletedMedia-table";
	}
	else return "";
}

5.15. StatusInfoDirectoryAccessDates()

Interface definition

StatusInfoDirectoryAccessDates(&$statDB_html, $modalClassID, $stat, $dirCnt)

Function is called by

  1. dirThumbs() [4x],
  2. media-update-progress.php.
Parameters:
  • &$statDB_html (Pointer) – Pointer to albumDirThumbStatHtml_Object
  • $modalClassID (String) – modal dialog ID for JQUERY
  • $dirCnt (Integer) – Number location directories
Returns:

Boolean

5.15.1. Source code

<?php
function StatusInfoDirectoryAccessDates(&$statDB_html,$modalClassID,$stat,$dirCnt){
// OUT1: Date status of iminfo, location dir and public dir
// Value of first argument is not relevant
	$dm=$statDB_html['DisplayModus'];
	$statDB_html['genTable']=($dm&01000)&&((strlen($modalClassID)>1));
	$statDB_html['db_active']=$dm&00001;
	$statDB_html['db_buttons']=$dm&00100;
	$dates_ok=true;
	if ($statDB_html['genTable']){
		$em=($dm&00010);
		$class='.'.$modalClassID;
		$str="<table id=\"DirAccesDates-table\" class=\"modal-table\">";
		$str.="<thead style=\"background-color:#cecece\"><tr>";
		$str.='<th>Directory</th>';
		$str.='<th>iminfo.xml</th>';// Column 2 header
		$str.='<th>loc directory</th>';// Column 3 header
		$str.='<th>public directory</th>';// Column 4 header
		$str.='</tr></thead>';
		$str.='<tbody>';
		$bg=BACKGROUND_COLOR_NORMAL;
		for ($i=0;$i<$dirCnt;$i++){
			$str.='<tr>';
			$bg1=BACKGROUND_COLOR_NORMAL;
			$bg2=BACKGROUND_COLOR_NORMAL;
			$str.="<td>".$stat[$i]['locDirname']."</td>";
			// Column 2
			$str.="<td style=\"background-color:".$bg."\">".date("Ymd-Hi",$stat[$i]['iminfoAccessTime']).'</td>';
			if ($stat[$i]['dirAccessTime']>$stat[$i]['iminfoAccessTime']){
				$bg1=BACKGROUND_COLOR_ALERT;
				$dates_ok=false;
			}
			// Column 3
			$str.="<td style=\"background-color:".$bg1."\">".date("Ymd-Hi",$stat[$i]['dirAccessTime']).'</td>';
			if ($stat[$i]['resizedAccessTime']>$stat[$i]['iminfoAccessTime']){
				$bg2=BACKGROUND_COLOR_ALERT;
				$dates_ok=false;
			}
			// Column 4
			$str.="<td style=\"background-color:".$bg2."\">".date("Ymd-Hi",$stat[$i]['resizedAccessTime']).'</td>';
			$str.='</tr>';
		}
		$str.='</tbody></table>';
		$statDB_html['htmlStringCode']=$str;
		$statDB_html['dialogStatus']=$dates_ok;
	}
	else {
		for ($i=0;$i<$dirCnt;$i++){
			if ($stat[$i]['dirAccessTime']>$stat[$i]['iminfoAccessTime']) $dates_ok=false;
			if ($stat[$i]['resizedAccessTime']>$stat[$i]['iminfoAccessTime']) $dates_ok=false;
		}
	}
	return $dates_ok;
}

5.16. WriteMySessionVariables()

Interface definition

WriteMySessionVariables($uname, $sid, $variable, $varname)
Parameters:
  • $uname (String) – Username,
  • $sid (String) – Session ID,
  • $variable (Object) – Data object,
  • $varname (String) – Name of the variable to be saved to file in JSON format,
Returns:

Integer: write status code.

5.16.1. Source code

<?php
function WriteMySessionVariables($uname,$sid,$variable,$varname){
	$SysErrCode=0;
	$tmp_dir=$_SERVER['DOCUMENT_ROOT'].DS."tmp".DS.$uname;
	if (!is_dir($tmp_dir)){
		if (!mkdir($tmp_dir,0777,true)) {
			return SYSTEM_ERROR_TMP_MKDIR;
		}
	}
	if (!file_put_contents($tmp_dir.DS.$sid.'-'.$varname.'.json',json_encode($variable))){
		$SysErrCode=SYSTEM_ERROR_TMP_JSON;
	}
	return $SysErrCode;
}