4. Process flow of viewing photo/video album¶
Function content
4.1. Album file structure¶

Fig. 4.1 Location directory has only media files and no “Resize” directory with media files: creation of new album. See also column b in Table 4.12 and Table 4.13.

Fig. 4.2 Location directory has both media files and “Resize” directory: #media files in location and “Resize” directories the same: after processing the media in the location directories (resizing, renaming, …) the original media files in the location directories are kept. There is no need for updating the album. See also row 2 / column c in Table 4.12 and Table 4.13 (i.e. under normal conditions files fproc.txt and rproc.txt both exist). See also column c in Table 4.12 and Table 4.13.

Fig. 4.3 Location directory has both media files and “Resize” directory: #media files in location (Aj) is different from #media files in “Resize” directories (Nj). Reason is that new media has been added in the location directory, and/or media has been removed in the Resize/Private directories. 🡺 Updating the album is needed. This is also detected by different timestamps of the directories. See also column d in Table 4.12 and Table 4.13.

Fig. 4.4 Location directory has no media files and “Resize” directories have media files. After processing the media in the location directories (resizing, renaming, …) the original media files in the location directories are removed. Probably no album update is needed. A possible hint for the need the need of an update is by comparing the timestamps of the directories. Then a more detailed analysis is done by comparing the iminfo.xml files in all location directories with the present media files. If there is a difference then an album update is needed. See also column e in Table 4.12 and Table 4.13.

Fig. 4.5 Album overview (familie.php, familie-private.php). For now, it is a static code, implemented as an HTML include file (reis-overzicht.html)
When clicking on an album (e.g. 2008 Vietnam) the familie-vakantie.php URL is called with parameters:
http://www.benoy.nl/familie-vakantie.php?vakantieDir=2008%20Vietnam.
When the URL famile-vakantie.php with arguments is loaded, in ‘old’ version of the following synchronous code is executed:
1 2 3 4 5 6 7 8 9 10 | <div id="innerWrapper" class="wrapper">
<?php
if (!isset($_GET["caller"])){$caller="parent";}else {$caller=$_GET["caller"];}
if (!isset($_GET["vakantieDir"])){$vakantieDir="2008 Vietnam";}
else {$vakantieDir=$_GET["vakantieDir"];}
if (empty($vakantieDir)){$vakantieDir="2008 Vietnam";}
include(__DIR__.DIRECTORY_SEPARATOR.'php'.DIRECTORY_SEPARATOR.'myFunction.php');
prepareGallery("reizen", $vakantieDir,"familie-gallery.php",$private_modus,$caller);
?>
</div>
|
The code has been updated to more modern programming standards, where synchronous calls to server-side executed code, is replaced by asynchronous API to server-side code (see Listing 4.2).
generateOverview()
is shown in Listing 4.3.¶1 2 3 4 5 6 | <div id="innerWrapper" class="wrapper">
</div>
...
<script>
generateOverview("holiday","reizen","familie-gallery.php","familie.php",private_modus);
</script>
|
generateOverview()
(implemented in overzicht.js) is called. For convenience the source code is also shown in this listing. This function then calls prepareDirOverviewGallery()
(implemented in generate_jssor_code.js) , in which the AJAX call to PHP - file php\prepareDirOverviewGalleryAjax.php
is executed (see also Table 4.1). The advantage of this approach is that the call is asynchronous.¶1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // JavaScript Document: this file must be included after all HTML code.
// Reason is that there are references to HTML ID objects. If called at the beginning
// these ID's are not yet defined! This means the functions are loaded into memory when
// reading the script file, and not loaded when they are called
function generateOverview(type,parentDir,gallery,uppage,private_modus){
var vakantieDir;
var vakantiefile;
var str;
var caller=$_GET("caller");
if (type==="bicycle"){
vakantieDir=$_GET("fietsDir");
vakantiefile=$_GET("fietsfile");
str="fietsDir";
}
else if (type==="holiday"){
vakantieDir=$_GET("vakantieDir");
vakantiefile=$_GET("vakantiefile");
str="vakantieDir";
}
phpGeneratedHTMLCode=false;
if (vakantieDir!=null){
if (caller==null) caller='parent';
prepareDirOverviewGallery(parentDir,vakantieDir,gallery,private_modus,caller,"innerWrapper");
}
else if (vakantiefile!=null) loadHTML_file(vakantiefile,"innerWrapper");
vakantie_overzicht(str,phpGeneratedHTMLCode,uppage)
}
|
The visibility of an album in the overview implies that the album’s directory and its directory thumb) exist. The following scenarios are then possible when calling the JavaScript
function generateOverview()
implemented in js\myjs\overzicht.js, which calls prepareDirOverviewGallery()
implemented
in js\myjs\generate_jssor_code.js (shown in Listing 4.3, and also see Table 4.1):
- The album’s directory is still empty 🡺 message box: see also Table 4.12, column b, row 5
- Album’s directory has media:
- Media is stored in sub-directories listed in the definition file, but the media have not been processed. 🡺 process all media (ALL_MEDIA_PROCESSING)
- Media is stored in the album’s root directory and no definition file exists. 🡺 Create media gallery with media file as they are (no pre-processing is carried out).
- Album’s directory has media and all media has been processed and no update is required (NO_MEDIA_PROCESSING is needed)
- Album’s directory has media and (note that the word ‘all’ has been deliberately omitted) media has been processed 🡺 update probably required (UPD_MEDIA_PROCESSING):
- New media has been detected by comparing the media list in iminfo.xml files with media files in the directories initiated by directory date changes.
- Media has been removed which is detected by comparing the media list in iminfo.xml files with media files in the directories initiated by directory date changes.
An example of the result is shown in Fig. 4.6.
4.2. Updating process: what needs to be updated and who can?¶
4.2.1. What needs to be updated?¶
In the analysis for media update process the following needs to be checked for updating:
- Content of file rproc.txt (one per album). Purpose of the file: see paragraph Section 3.1.2
- Content of each IMINFO.XML file (see paragraph Section 3.1.7)
- Transferring new media from location directory to “Resized” (public/private) directory if new media in location directory has been detected. In this case both the content of rproc.txt and IMINFO.XML files have also to be updated.
4.2.2. Who can update an album?¶
There are 2 options for updating an album:
- Only administrator can update all albums (i.e. all albums are locked, except for administrator). This option is selected when define(‘ALBUM_UPDATE_PERMISSION_LEVEL’,ADMIN_PERMISSION_LEVEL);.
- Registered users can update some albums. For this case there are multiple possibilities:
- define(‘ALBUM_UPDATE_PERMISSION_LEVEL’,REG_USER_PERMISSION_LEVEL);
4.3. Automatic code generation¶
For now the HTML code behind the web-page as shown in Fig. 4.5 is static. The HTML code behind the directory / location thumbs overview of an album, as shown in Fig. 4.6, and the location media gallery, are generated on the fly. This means the HTML code is generated automatically at the server side by an AJAX call, using the promise interface. Some details of the implemented process flow are shown in Fig. 4.7. Table 4.1 gives an overview of the JavaScript functions (and the files in which these functions are implemented) with the AJAX calls to PHP files, which generates the HTML code on demand.
Media list type | File | AJAX communication function 🡺 Server side PHP file | |
---|---|---|---|
Directory thumbs |
|
(/js/myjs/overzicht.js) |
🡺 JS: XMLHttpRequest - promise
AJAX communication object: |
Album media gallery |
|
(/js/myjs/ generate_jssor_code(2).js) |
JS: XMLHttpRequest 🡺 (see also Table 4.27, and Section 4.6) AJAX communication object: |

Fig. 4.7 Promise proces flow scheme (see also following link)
4.3.1. Code fragment of implementation of promise¶
function chainedXHRequest(dir,url,method,params,containerID){
return new Promise(function(resolve,reject) {
var request = getXHR();
var albumDirThumbStatHtml;
request.responseType = 'text';
request.previous_text='';
request.open(method,url,true);
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.send(params);
request.onreadystatechange = function() {
if (request.readyState == 4) {// request finished and response is ready
switch(request.status){
case 200: //
albumDirThumbStatHtml = processResponse(dir,request.responseText,containerID);
if (albumDirThumbStatHtml.status.albumExists) resolve(albumDirThumbStatHtml); // Fullfilled
else reject('Album directory '+dir+' does not exist'); // Promise rejected --> catch
break;
case 203,204: // See https://www.w3schools.com/tags/ref_httpmessages.asp
break;
default:
reject(request.status);
}
}
};
request.onerror = function() {
console.log("Network Error");
reject(Error("Network Error"));
};
});
}
function prepareDirOverviewGallery(parent,dir,gpf,private_,caller,containerID){
var pageReload;
var new_im_cnt,new_vi_cnt,putback_im_cnt,putback_vi_cnt;
var vP=window.sessionStorage.getItem("previousPage");
var cP=window.sessionStorage.getItem("currentPage");
var wdir=parent+'/'+dir;
var uname,sid;
if(vP == cP){pageReload=true;}
else{pageReload=false;}
var params='parent='+parent+'&dir='+dir+'&gpf='+gpf+'&private='+private_+'&caller='+caller+'&pageReload='+pageReload;
chainedXHRequest(wdir,'php/prepareDirOverviewGalleryAjax.php','POST',params,containerID)
.then(function (albumDirThumbStatHtml) {
// Argument of anonymous function in the promise.then method is determined by the argument of the resolve function in the promise
if (albumDirThumbStatHtml.status.updateProgressDialogBox){
uname=albumDirThumbStatHtml.server_info.uname;
sid=albumDirThumbStatHtml.server_info.sid;
new_im_cnt=albumDirThumbStatHtml.media.iminfo.NewImageCnt;
new_vi_cnt=albumDirThumbStatHtml.media.iminfo.NewVideoCnt;
putback_im_cnt=albumDirThumbStatHtml.media.iminfo.PutBackM_ImageCnt;
putback_vi_cnt=albumDirThumbStatHtml.media.iminfo.PutBackM_VideoCnt;
media_update_progress_dialogbox(new_im_cnt,new_vi_cnt,putback_im_cnt,putback_vi_cnt,uname,sid,wdir);
console.log('prepareDirOverviewGallery: chainedXHRequest->Succes: UPDATE PROCESS DIALOG WINDOW');
} else {
console.log('prepareDirOverviewGallery: chainedXHRequest->Succes: NO UPDATE PROCESS DIALOG WINDOW');
}
}
)
.catch(function(rej){console.log('prepareDirOverviewGallery: chainedXHRequest->reject: '+ rej)});
// Argument of anonymous function in the promise.catch method is determined by the argument of the reject function in the promise
}
// prepareDirOverviewGallery_End
4.3.2. Media process status dialog message box: code generation¶
If an album update is suggested then the content of the dialogbox (Fig. 2.1) is generated.
The suggestion for an album update is determined by the key [‘updateSuggested’] of the status_Object
object definition (part of albumDirThumbStatHtml_Object
object, see Table 4.20)
Tab | Process function | See figure |
---|---|---|
Tab 1 (XML) | check_mediacount_iminfo_files() |
Fig. 2.2 |
Tab 2 (RPROC) | StatusInfoWindow() |
Fig. 2.3 |
Tab 3 (Dates) | StatusInfoDirectoryAccessDates() |
Fig. 2.4 |
Tab 4 (New/Rem.media) | StatusInfoNewOrDeletedMedia() |
Fig. 2.5 |
4.4. Process flow of generating and updating an album¶
4.4.1. User action scenarios: GUI¶
4.4.1.1. Normal user and NO need for update is detected¶
Overview of albums | Location overview of an album. | Location’s media gallery. |
4.4.1.2. Normal user and need for update detected¶
1 | 2 | 3 |
4 | 5 |
1 | 2 | 3 |
4 | 5 |
4.4.1.3. Admin user and NO need for update detected¶
Overview of albums | Location overview of an album. | Location’s media gallery. |
4.4.1.4. Admin user and need for album update is detected¶
1 | 2 | 3 |
4 | 5 |
1 | 2 | 3 |
4 | 5 |
4.4.2. Action/status codes: 0xFFFFFF¶
Action/status codes are represented by a 5-hexadecimal digit number: 0Xabcde (in the code it is represented as 0XFFFFF), where a, b, c, and d represent a hexadecimal digit (0 🡺 F). Each hexadecimal digit consists of 4 bits (see also Table 4.9)
- Hexadecimal bit 2(d): status of file fproc.txt (there is only 1 per album). Only one bit is used (set by function
RProc_FProc_Status_X00FF0()
) - Hexadecimal bit 3(c) (set by
RProc_FProc_Status_X00FF0()
): status of file rproc.txt (there is only 1 per album), or update method if one of the numbers of media in rproc.txt (see Table 3.2) is smaller than the corresponding numbers in IMINFO.XML.
0x0000F [1] | Resize and video thumbnail processing status in public and private directories. | |
---|---|---|
|F|F|F|F|●●XX| | CheckProcessStatus_X000FF() |
First 2 bits describe the status based on the media file counts in the location and public/private directories (0x0000 0x0003). |
|F|F|F|F|●X●●| | CheckProcessStatus_X000FF() |
Represent the date stamp status of the location directory. If the time stamp of the location directory is more recent (i.e. larger) than the timestamp of any of the iminfo.xml files in the public and private directories, then this bit is set. This means something has changed in the location directory (🡺 LOCATION_DIR_HAS_CHANGED = 0x00004) |
|F|F|F|F|X●●●| | CheckProcessStatus_X000FF() |
The fourth bit represent the date stamp status of the public directory (“Resized”). If the time stamp of any of the public directory is more recent (i.e. larger) than the timestamp of it corresponding iminfo.xml files in the public directories, then this bit is set (🡺 PUBLIC_DIR_HAS_CHANGED = 0x00008). The value of the first hexadecimal byte is the binary or operation of the 4 bits. If something has changed in the private directory, also the timestamp of the public directory will change. |
0x000F0 [2] | Status of fproc.txt and phpdefinition.xml files, presence of media. | |
---|---|---|
|F|F|F|●●●X|F| | rproc_stat | Status of file fproc.txt (1 per album). 🡺 FPROC_STAT_EXIST =0x00010 |
|F|F|F|●●X●|F| | CheckProcessStatus_X000FF() |
If there are album media (i.e. in the resized directories) then this bit is set 🡺 FPROC_STAT_ALBUM_MEDIA_EXIST =0x00020. This also means that also |F|F|F|●X●●|F| will be set (FPROC_STAT_MEDIA_EXIST =0x00040). In general, both bits |F|F|F|●XX●|F| will be set. |
|F|F|F|●X●●|F| | CheckProcessStatus_X000FF() |
If there is media in one or more location directories, then this bit is set 🡺 FPROC_STAT_MEDIA_EXIST. If there is only media in locatio directories (e.g. creation of a new album) then only bit |F|F|F|●X●●|F| will be set. |
|F|F|F|X●●●|F| | CheckProcessStatus_X000FF() |
Status of file phpdefinition.xml (1 per album) 🡺 FPROC_STAT_PHPDEF_EXIST |
0x00F00 [3] | Status of rproc.txt and update type of rproc.txt file if needed | |
---|---|---|
|F|F|●●●X|F|F| | rproc_stat
RProc_FProc_Status_X00FF0 |
Status of file rproc.txt (1 per album). 🡺 RPROC_STAT_EXIST =0x00100 |
|F|F|●●X●|F|F| | CompareMediaCntRprocLocDir_XF0F00 |
Updating of rproc.txt needed based on media count in public/private directories: RPROC_STAT_UPD_WITH_PUBPRIV_COUNT=0x00200 |
|F|F|●X●●|F|F| | CompareMediaCntRprocLocDir_XF0F00 |
Updating of rproc.txt needed based on media count in public/private directories: RPROC_STAT_UPD_WITH_LOC_IMAGE_COUNT =0x00400 |
|F|F|X●●●|F|F| | CompareMediaCntRprocLocDir_XF0F00 |
Updating of rproc.txt needed based on media count in public/private directories: RPROC_STAT_UPD_WITH_LOC_VIDEO_COUNT =0x00800 |
0x0F000 [4] | Media update type | |
---|---|---|
|F|●●●X|F|F|F| | Action status as dictated by IMINFO. Since each location directory has a IMINFO.XML file a global action status is derived from all IMINFO files: all action statuses of each IMINFO file are bitwise or-ed. For each location directory:
|
|
|F|●●X●|F|F|F| | ||
|F|●X●●|F|F|F| | ||
|F|X●●●|F|F|F| |
0xF0000 [5] | ||
---|---|---|
|●●●X|F|F|F|F| | CompareMediaCntRprocLocDir_XF0F00 |
|
|●●X●|F|F|F|F| | ||
|●X●●|F|F|F|F| | NOT USED | |
|X●●●|F|F|F|F| | NOT USED |
The first output argument of the function rf_proc_stat()
returns the status of first 3 hexadecimal bits (d, c, and b).
XFFFFF[GlobStat]
0XFFFFF
|
1st
F0000
|
2nd
0F000
|
3rd
00F00
|
4th
000F0
|
5th
0000F
|
Status comment |
---|---|---|---|---|---|---|
0X00102 = 258 | 0000 | 0000 | 0001 | 0000 | 0010 | Updating needed PROCESSED_FILES_ORIGINALS_ADD_REM |
0X0010e = 272 | 0000 | 0000 | 0001 | 0001 | 1110 | |
0X00113 = 275 | 0000 | 0000 | 0001 | 0001 | 0011 | Updating not needed PROCESSED_FILES_ORIGINALS_REMOVED |
0X3011e = 196894 | 0011 | 0000 | 0001 | 0001 | 1110 | Updating needed: Media added in location directory |
0X3111b = | 0011 | 0001 | 0001 | 0001 | 1011 | |
0X3210e =205070 | 0011 | 0010 | 0001 | 0000 | 1110 | FPROC is deleted: updating is initiated. |
4.4.3. When is an update suggested?¶
The status variable $XFFFFF[‘GlobStat’] (see Section 3.3.2.1) is one of the factors determining whether an album update is needed or not. The starting point is the decomposition of the status variable $XFFFFF[‘GlobStat’], as shown in Fig. 4.8.
The table in figure in Fig. 4.8 also indicates which bits of $XFFFFF[‘GlobStat’] are used: if one of these bits is not 0 then an album update is needed. However, it is not a sufficient condition. There are additional conditions, when met, must result in an album update. These additional conditions are determined by:
- number of removed and or added media (removing and adding media will modify directory date stamps. A modified timestamp of location and/or public/private directories is not sufficient.
Directory date stamp modifications are easy to check). The code implementation of the calculation of $albumDirThumbStatHtml[‘status’][‘updateSuggested’] is given in Listing 4.6.
.png)
Fig. 4.8 Summary of XFFFFF action functions. Album update is suggested when at least 1 bit in the 11 bit binary number enclosed by the red rectangular is not 0.
Bit position | Hexadecimal number position | Update will be initiated | Update target |
1 | 1 | NO | Not applicable |
2 | 1 | NO | Not applicable |
3 | 1 | NO | Not applicable |
4 | 1 | NO | Not applicable |
5 | 2 | NO | Not applicable |
6 | 2 | NO | Not applicable |
7 | 2 | YES | Update target not yet known |
8 | 2 | YES | Update target not yet known |
9 | 3 | NO | Not applicable |
10 | 3 | YES | Update of rproc.txt |
11 | 3 | YES | Update of rproc.txt |
12 | 3 | YES | Update of rproc.txt |
13 | 4 | YES | Update of public / private directories |
14 | 4 | YES | Update of public / private directories |
15 | 4 | YES | Update of public / private directories |
16 | 4 | YES | Update of public / private directories |
17 | 5 | YES | Update of public / private directories |
18 | 5 | YES | Update of public / private directories |
19 | 5 | NO | Not applicable |
20 | 5 | NO | Not applicable |
dirThumb()
).¶<?php
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);
4.4.4. Added image or video¶
If (an) image and or video is (are) added in location directory the following happens:
- Time stamp of location directory will change: newer than iminfo.xml file,
Status code value will change when file fproc.txt is deleted for determining the update procedure.
Mask | Initial status | After delete FPROC | Decimal value
decomposition
|
---|---|---|---|
0X3011e = 196894 | 196608 + 4366 = 200974
196608 + 8462 = 205070
196608 + 16654 = 213262
196608 + 33038 = 229646
|
||
0xF0000 | 3 🡺 0011 | 0011 | 196608 |
0x0F000 | 0000 | 0001 pub.images
0010 pub.videos
0100 prv.images
0100 prv.videos
|
4096+270 = 4366
8192+270 = 8462
16384+270 = 16654
32768+270 = 33038
|
0x00F00 | 1 🡺 0001
File rproc.txt exists
|
0001
File rproc.txt still exists
|
256 + 14 = 270 |
0x000F0 | 1 🡺 0001
File rproc.txt exists
|
0001
File rproc.txt still exists
|
0 |
0x0000F | e 🡺 1110 | 1110 | 14 |
4.4.5. Process flow: scenario schemes¶
The definition of fast status analysis is given in Section 4.4.8.
1 | (col a) PHASE 1 | (col b) 1. 0X●●●●0: ●.●.●.●.xx00 | (col c) 2. No media update 0x●●●●1: ●.●.●.●.xx01 | (col d) 3. No media update 0x●●●●1: ●.●.●.●.xx10 | (col e) 4. No media update 0x●●●●1: ●.●.●.●.xx11 |
---|---|---|---|---|---|
2 | rproc, fproc exist 0x●●11● |
NOT GOOD
|
Fast status analysis
|
Fast status analysis
|
Fast status analysis
|
3 | 0x●●10● : rproc exists, fproc does not exist. File fproc can only be deleted as admin, unless after time out. |
DO NOTHING DoAllResize = 0 Display message to login as admin. |
Fast status analysis Create fproc
|
Fast status analysis Create fproc
|
Fast status analysis Create fproc
|
4 | 0x●●01● : Only fproc exists. File rproc can only be deleted as admin, unless after time out. |
DO NOTHING DoAllResize = 0 Display message to login as admin. |
Fast status analysis: Create rproc(1)
|
Fast status analysis: Create rproc(2)
|
Fast status analysis: Create rproc(3)
|
5 | 0x●●00● : Files fproc and rproc do not exist | DO NOTHING. DoAllResize = 0 Display message to login as admin |
Fast status analysis: Create both rproc(1), fproc
|
Fast status analysis: Create both rproc(2), fproc
|
Fast status analysis: Create both rproc(3), fproc
|
1 | (col a) PHASE 1 | (col b) 1 (0X●●●●0) | (col c) 2 (0x●●●●1) Processed files originals kept | (col d) 3 (0x●●●●2) Processed files originals add rem | (col e) 4 (0x●●●●3) Processed files originals removed |
---|---|---|---|---|---|
2 | rproc, fproc exist 0x●●11● |
NOT GOOD
|
Fast status analysis: show initial state
|
Detailed (2) status analysis: show initial state
|
Fast status analysis: show initial state
|
3 | 0x●●10● : rproc exists, fproc does not exist. |
DO NOTHING DoAllResize = 0 |
|
|
|
4 | 0x●●01● : only fproc exists. | DO NOTHING DoAllResize = 0 |
|
|
|
5 | 0x●●00● : Files fproc and rproc do not exist | DO NOTHING. DoAllResize = 0 |
|
|
|
rproc | rproc.txt exists 🡺 updating |
rproc(1) | PROCESSED_FILES_ORIGINALS_KEPT: create rproc with media file info present in “Location” directory |
rproc(2) | PROCESSED_FILES_ORIGINALS_ADD_REM: create rproc with info from iminfo file. |
rproc(3) | PROCESSED_FILES_ORIGINALS_REMOVED: create rproc with media files in public and private directories |
Scenario | Application condition(s) | Action(s) |
---|---|---|
detailed(1) | Equal file count in location and Public/Private directories |
|
detailed(2) | File count in location directory is different than for Public/Private directories |
|
detailed(3) | Location directory is empty, Public/Private directories are not empty. |
|
4.4.5.1. Detailed check A¶
Compare media filenames in location and Public/Private directories (for public/Private directories: use info from iminfo.xml).
If all media filenames in location directory have a match with media filenames in public/private directories: no media update is needed.
Else equal media file count in location and Public/Private directories is a coincidence: in the location directory media files have been removed and replaced by others, i.e. by new media files.
🡺 Media update is needed: identify which media files have been added.
🡺 IMINFO (object or XML file) update(2) will be needed (executed when fproc.txt is deleted).
🡺 Proceed with processing new media: resizing images, create image and video thumbnails (executed when fproc.txt is deleted).
4.4.5.2. Detailed check B¶
Check if there has been media exchange between public and private directories (if this is the case identify which media has been moved from public to private or the other way around) by using info from iminfo.xml. If yes than update IMINFO (object or XML file) and rproc.txt, else no additional actions are needed.
4.4.5.3. Detailed check C¶
Compare media filenames in location and Public/Private directories (for public/Private directories: use info from iminfo.xml).
🡺 Identify which media files have been added and or deleted. Media update is needed.
🡺 IMINFO (object or XML file) update(2) will be needed (executed when fproc.txt is deleted).
🡺 Proceed with processing new media : resizing images, create image and video thumbnails (executed when fproc.txt is deleted).
4.4.6. Processing approach based on IMINFO.TXT file¶
The first approach is based on a text file named iminfo.txt. However, this approach is outdated, and not maintained anymore.
- iminfo.txt is manually updated,
check_mediacount_iminfo_files()
will detect new media and will result in a call toupdateIminfoFiles()
,updateIminfoFiles()
will callIminfoTXT2IminfoXML()
,IminfoTXT2IminfoXML()
will callImArray2IminfoXML()
to update iminfo.txt file.
4.4.7. Processing approach based on IMINFO.XML files¶
The second approach is based on XML format files.
New media must be known to IMINFO.XML before they can be processed. The process flow of how to get the new media info to iminfo.xml file is described in the next two sections.
4.4.8. Processing approach based on IMINFO.XML: guest user¶
Outcome of fast status analysis (see also Table 4.12 and Table 4.13), which is divided over Phase 1A, and Phase 1B (see also Fig. 4.9), is based on status of this phase steps.
4.4.8.1. Phase 1A (guest)¶
- Check media count in directories by:
CheckProcessStatus_X000FF()
- Counting media files in public and private directories,
- Counting media files in location directories,
- Comparing media count in location versus public / private directories.
- Record last access times of the following directories, and files:
CheckProcessStatus_X000FF()
- Location directories,
- Public / private directories,
- iminfo.xml files in each location directory.
- Reading file content of rproc.txt:
RProc_FProc_Status_X00FF0()
, and store data in matrix object. If needed create:- rproc.txt with info from iminfo – objects,
- rproc.txt file (is an empty file)
4.4.8.2. Phase 1B (guest)¶
Compare date stamps of directories compared to date stamps of iminfo.xml (implemented by
StatusInfoDirectoryAccessDates()
),Comparison of public and private media count in directories and rproc.txt:
CompareMediaCntRprocLocDir_XF0F00
for determining resulting action codes,StatusInfoWindow()
for generating Tab 2 in Media process status dialog message box (Fig. 2.3)
Comparison of public and private media count in directories and iminfo.xml (
check_mediacount_iminfo_files()
). Media file count in iminfo.xml must be the same with file count content of Public/Private directory. This means the total number of media files in iminfo.xml must be equal to the sum of number of media files in Resized (i.e. Public) and Private directories (video files with the same basename but different extensions are considered as 1 web media file). The content (i.e. names of the media) of iminfo.xml is not compared with the content of the location directory (because this can be made empty after media processing). If the number of files in Public/Private directories is different from the number of files marked with “R” in iminfo.xml (and also the number files in Private directories is different from the number of files marked with “Private” in iminfo.xml) then a warning is given (local web server) caused by moving images from “Resized” to “Private” directory or the other way around:🡺 UPDATE(1) iminfo.xml,
🡺 RPROC must be updated.
Remark: if a media file is added to a location directory, the procedure
check_mediacount_iminfo_files()
will not notice the added media file!
4.4.9. Processing approach based on IMINFO.XML: user with admin permission¶
This scenario also start with Phase 1A functions, but than continues with Phase 2 functions.
4.4.9.1. Phase 1A (admin)¶
- Call
CheckProcessStatus_X000FF()
: Check media count in directories by:- Counting media files in public and private directories,
- Counting media files in location directories,
- 🡺 Comparing media count in location versus public / private directories.
- Record last access time of location directories,
- Record last access time of public / private directories,
- Record last access time of iminfo.xml files in each location directory.
- 🡺 Compare access times.
- Reading file content of rproc.txt:
RProc_FProc_Status_X00FF0()
, and store data in matrix object. DetailedStatusAnalysis()
: Executes a detailed status analysis in each location directory: all media filenames in a location directory are compared with the filenames of media in public and private directories (info is stored in iminfo.xml file in each location directory). Differences mean that either media in public and or private directories have been added and/or deleted. The different detailed analysis scenarios are given in Table 4.15.
4.4.9.2. Phase 2 (admin), fproc.txt exists¶
- Counting media elements in iminfo.xml file in each location directory
check_mediacount_iminfo_files()
, - Compare date stamps of directories compared to date stamps of iminfo.xml (implemented by
StatusInfoDirectoryAccessDates()
) 🡺 - Identify which media files have been added in the location directory (implemented by
StatusInfoNewOrDeletedMedia()
). If the outcome is not empty 🡺 media update is needed. - Compare media count in public/private directories with the numbers in rproc.txt: set proper action code in XFFFFF[‘GlobStat’], and XFFFFF_Arr[$j][‘XFFFFF’] (implemented in
CompareMediaCntRprocLocDir_XF0F00
). StatusInfoWindow()
for generating the content of Tab 2 in Media process status dialog message box (Fig. 2.3). If $albumDirThumbStatHtml[‘status’][‘updateSuggested’] = True then the Media process status dialog message box is actually shown. When pressing the “OK” button (see Fig. 4.10) the file fproc.txt will be removed, and previous page will be shown again.
1 | 2 | 3 |
4.4.9.3. Phase 2 (admin), fproc.txt does not exist¶
This phase can only be reached from the previous step, i.e. by pressing the OK button in the Media process status dialog message box (Fig. 2.3).
- Update iminfo.xml object will be needed (when fproc.txt is deleted) and save to file (
Iminfo_XML_Objects_UpdateAndSave()
). For each new media:- A new media tag (element) is added to iminfo.xml object by calling
IminfoNewImageObject()
orIminfoNewVideoObject()
, - Set tag element Transferred2SiteDir to TRANSFER_FIRST_TIME_SCHEDULED [corresponds to -100],
- Set tag element “MIMETYPE” to “IMAGE” or “VIDEO”, and other tag elements within <media>,
- Update tag element ImageInfo->PublicCount (new image media will be stored in public directory),
- Update tag element VideoInfo->PublicCount and VideoInfo->PublicFilesCount (new video media will be stored in public directory),
- Tag elements TransferCount, TransferCountPublic, TransferCountPrivate, TransferFilesCountPublic (video), and TransferFilesCountPrivate (video) are not updated yet because the transfer is not yet executed.
- A new media tag (element) is added to iminfo.xml object by calling
- Proceed with processing new media: resizing images, create image and video thumbnails (when fproc.txt is deleted) (
media-update-progress.php
file 🡺update_media_directories()
🡺update_images()
orupdate_videos()
). Move or copy new media: - Video: from location directory to public/private directory, and generate thumbnail,
- Image: first resize and move to public/private directory, and generate thumbnail,
- Set Transferred2SiteDir node value = 1,
- Set all children of nodes “IMAGE”, or “VIDEO”, …
- Update tag element ImageInfo->TransferCountPublic (new image media is stored in public directory),
- Update tag element VideoInfo->TransferCountPublic and VideoInfo->PublicFilesCount (new video media is stored in public directory),
4.4.9.4. Media process flow (admin)¶
fproc.txt exists

Fig. 4.11 Processing flow diagram for administrator: initiate update process by deleting fproc.txt. The blue process boxes represent PHP code. Green process box represents Javascript code. The functions delete_fotoproc_file_back2calling_page()
and AnalyseDeletedAndNewMedia()
both are implemented in public_private.js. The decision determined by value of $status[‘updateSuggested’] is documented in Section 4.4.3.
fproc.txt does not exist
4.5. PHP API objects for AJAX communication¶
OLD code:
list($GlobStat,$proposeAdminLogin,$media,$SysErrCode)=dirThumbs2($parent,$dir,$gpf,$private,$show_infowindow,$uname,$caller,"#modal_popup",$sid);
NEW code:
list($GlobStat,$proposeAdminLogin,$media,$SysErrCode)=dirThumbs2($parent,$dir,$albumDirThumbStatHtml,$session,"#modal_popup");
GenerateDirOverview($parent,$dir,$gpf,$private,$xml_defs, $iminfo_xml_stat, $upd_media_dir);
The PHP API data object for the AJAX communication interface is the albumDirThumbStatHtml object (see Table 4.16, and code implementation see Section 4.7). The communication of the albumDirThumbStatHtml object makes use of the JSON method.
-
interface
albumDirThumbStatHtml_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
nrIminfoFiles | Integer | 0 | |
media | Object | NULL | Object definition: see Table 4.17. |
albumOwner | String | $albumInfo->Owner | |
phpdef | Boolean | false | True if file phpdefinition.xml exists. |
infoDialogBox | Object | Object definition: see Table 4.18. | |
jsList | Array of objects | ‘’ | Numerical key. The length of the array is determined by
the number location directories. Each object element of
[jsList][$i] is an array of 6 (location
directory with description, see also
Fig. 3.2) or 3
(location directory without description, see also
Fig. 3.1)
simple object elements with 3 associative
key’s (jsvar, nr, and attrib)
e.g. [‘jsList’][2][0->5][‘attrib’]. The data in
each element of jsList is used to generate HTML
code for directory thumb overview for regular albums
with regular Javascript HTML DOM Document Object
function calls(i.e. with phpDef = TRUE) 🡺
the content of HTML/ Javascript code is generated in PHP
(at server side) in function
GenerateDirOverview() . |
dirImlist | Array | Numerical key. Object with directory names and array with images: album for which phpDef = FALSE. HTML code is generated in JAVASCRIPT code (at client side). | |
sLang | String | FULL_JAVASCRIPT | Execution language of object key jsList in
object
|
status | Object | Object definition: see Table 4.20 | |
server_info | Object | Object definition: see Table 4.21 |
-
interface
media_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
iminfo | Media object | NULL | Object definition: see section Section 3.3.1, and Table 3.8. |
New_M | New media object | NULL | Object definition: see Section 6.3. |
Remove_M | Removed media object | NULL | Object definition: see Section 6.3. |
-
interface
infoDialogBox_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
globalstat2binstr | String | ‘’ | |
show | Boolean | Dynamic | If TRUE show info dialog box: see $show_infowindow old code. |
htmlStatCode | Array of objects | NULL | 4 element array with numerical keys (one for each tab as shown in Fig. 2.2. Definition: see Table 4.19. |
-
interface
htmlStatCode_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
DisplayModus | O7777 | INIT_STAT_DISPLAY_MODE | See Table 2.13. Possible values for each tab (0 🡺 3) are given in Table 2.10 and Table 2.11. |
htmlStringCode | String | “” | Single string with HTML code for the table in each tab in Media process status dialog message box (HTML code for table content for each tab is generated in PHP code at server side). |
CalledByFunction | String | “” | Name of function (debug purposes). |
dialogStatus | Integer | 0 |
|
genTable | Integer | 0 | Same for all tabs: (DisplayModus&01000) |
jsList | Array | NULL | Only assigned for Tab2. Array has numerical keys and contains Javascript or JQuery commands to be executed for generating HTML code of Tab2 when sLang (see Table 4.16) is set to JQUERY or JAVASCRIPT: CSS modifications. When sLang is set to FULL_JAVASCRIPT jsList contains only a single HTML message string. ( StatusInfoWindow() as an alternative for htmlStringCode). |
db_active | Integer | 0 | Same for all tabs: (DisplayModus&00001) |
db_buttons | Integer | 0 | Same for all tabs: (DisplayModus&00100) |
sLang | String | albumDirThumbHtml[sLang] | Same for all tabs. |
-
interface
status_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
proposeRegUserOrAdmin | Object | See comment | Object definition: ‘login’=>0 (hexadecimal), ‘reason’=>’’ (String). Is only set when user has no permission to update album.
|
albumExists | Boolean | True | |
updIminfoCMIF_1 | Array | NULL | String key (CMIF=check_mediacount_iminfo_files). See
Table 4.24. Value assigned in
dirThumbs() . |
updateProgressDialogBox | Boolean | False | If media is added or moved, than updating is needed. The update process is monitored by a progress bar in the updateProgressDialogBox (than set to true). |
permissionDeleteProcFile | Boolean | False | Determined by $XFFFFF[‘permissionDeleteProcFile’].
Value assigned in dirThumbs() . |
permissionLevel | Object | See comment, read only | Object definition: ‘current’=>$permissionLevel, ‘requiredForUpdate’=>ALBUM_UPDATE_PERMISSION_LEVEL |
updateSuggested | Boolean | False | |
globStat | 0XFFFFF | 0X00000 | See Section 3.3.2.1. Value assigned
in dirThumbs() . |
action_offset | 0XFFFFF | 0X00000 | Value assigned in dirThumbs() . |
Time_stat | 0XFFFFF | 0X00000 | Value of |F|F|F|F|XX●●| see Table 4.8.
Value assigned in dirThumbs() . |
Resize_stat | 0XFFFFF | 0X00000 | Value of |F|F|F|F|●●XX| see Table 4.8.
Value assigned in dirThumbs() . |
-
interface
server_info_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
uname | String | $uname | username (is stored in $_SESSION array). See also Section 12.11. |
sid | Integer | $sid | Session identification number. |
hostname | String | $_SERVER[‘SERVER_NAME’] | hostname |
hostaddress | String | $_SERVER[‘SERVER_ADDR’] | host address (name or IP). |
debugJS | Boolean | define(‘DEBUG’,true); | See listing Listing 2.1 |
NumbSiteVisits | Integer | 0 | Total number of website visitors. |
mysql_server | Object | Object definition: see Table 4.22 | |
email_server | Object | Object definition: see Table 4.23 |
-
interface
mysql_server_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
status | Integer | 1: |
|
address | String | MYSQL_SERVER | see Table 1.1 |
server_msg | Array() | Empty | Array of strings with warning messages. |
-
interface
email_server_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
status | Integer | 0: |
|
address | String | MYSQL_SERVER | see Table 1.1 |
server_msg | Array() | Empty | Array of strings with warning messages. |
-
interface
updIminfoCMIF_1_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
Location | 0xF | 0x0 | First output argument of
check_mediacount_iminfo_files() |
-
interface
session_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
parent | String | $parent | Parent directory |
dir | String | $dir | Album’s directory |
uname | String | $uname | Parameter input from AJAX request |
caller | String | $caller | Parameter input from AJAX request |
sid | Integer | Session_id() | PHP built – in function |
private | Boolean | $private | Parameter input from AJAX request |
-
interface
albumDirHtml_Object
¶
Object key | Data types | Initialization | Comment |
---|---|---|---|
xml | Boolean | true | |
nrMedia | Integer | 0 | Number of (released) media in iminfo.xml |
media | Array of objects | NULL | Object has following keys:
Assignment of values is implemended in
|
videoInfo | Array of objects | See comment | array(‘hasVideo’=>false,’width’=>0,’height’=>0) |
AJAX JavaScript function | JavaScript file (js/myjs/) | Server side PHP file (.php) | Com. method | JSON response object |
---|---|---|---|---|
media_update_progress_dialogbox() |
dlgboxes_generic |
|
Jquery: $.ajax JS: XMLHttpRequest |
array()([‘status’], ‘im_progress’ or ‘vi_progress’) |
|
dlgboxes_private |
|
Jquery: $.ajax | $logoutData (redirect URL after logout) |
dlgboxes_private |
|
Jquery: $.ajax | array(‘message’ => ‘Filecontent’) | |
dlgboxes_private |
|
Jquery: $.ajax | array()([‘code’], [‘msg]’) | |
|
dlgboxes_private |
|
Jquery: $.ajax | array(‘localhost’, ‘standard_localhost’) |
|
dlgboxes_private |
|
Jquery: $.ajax | array(‘phpversion’, ‘os_info’, ‘mysqlversion’, ‘mysqlhostname’) |
|
dlgboxes_private |
|
Jquery: $.ajax | array(‘session_id’, ‘session_user_id’,’session_username’, ‘ck_lt’, ‘ck_path’, ‘ck_domain’) |
dlgboxes_private |
|
Jquery: $.ajax | array()([‘code’], [‘msg]’) | |
dlgboxes_private |
|
Jquery: $.ajax | array()([‘code’], [‘msg]’) | |
|
dlgboxes_public |
|
Jquery: $.ajax | array()([‘code’], [‘msg]’) |
dlgboxes_public |
|
Jquery: $.ajax | array()([‘code’], [‘msg]’) | |
generate_jssor_code(2) | prepareGalleryAjax | JS: XMLHttpRequest | albumDirHtml_Object() |
|
generateOverview() 🡺
prepareDirOverviewGallery() |
overzicht 🡺 generate_jssor_code | prepareDirOverview-GalleryAjax | JS: XMLHttpRequest | albumDirThumbStatHtml_Object |
An example of the JSON response object of type array()([‘code’],[‘msg]’) is
$d['SID']=array("code"=>1,"message"=>$sid);
$d['login']=array('code'=>-3,'message'=>$message);
Server side PHP file | Key id’s of array() converted to JSON object | Code values | Message (Level 1) / Assigned in (Level 2,3) |
---|---|---|---|
|
changepassword (Level 1) | E_MYSQL_NOT_CONNECTED (-7) | Failed login: cannot connect to MYSQL server. |
E_MYSQL_SERVER_UNKOWN (-6) | Failed login: cannot connect to MYSQL server. | ||
E_MYSQL_CONFIG_NOT_FOUND (-5) | Failed login: cannot connect to MYSQL server. | ||
UNREGISTERED_USER (-1) | Procedure for resetting password failed: unknown user | ||
KNOWN_USER_WRONG_PASSWORD (-2) | Procedure for resetting password failed: current password incorrect. | ||
USER_PASSWORD_CHANGED (3) | Password changed. | ||
email (Level 2) | See Table 4.29 | loginNotificationEmail() |
|
CreateEmail (Level 3) | See Table 4.30 | CreateEmailContainer . |
|
ConnectMySQLServer (Level 4) | See Table 4.31 | connect_2_mysqli_server() |
|
|
register_new_user (Level 1) | E_MYSQL_NOT_CONNECTED (-7) | Failed login: cannot connect to MYSQL server. |
E_MYSQL_SERVER_UNKOWN (-6) | Failed login: cannot connect to MYSQL server. | ||
E_MYSQL_CONFIG_NOT_FOUND (-5) | Failed login: cannot connect to MYSQL server. | ||
E_NEW_USER_NOT_ADDED (-8) | Error description (determined by server) | ||
E_NEW_USER_PASSWD_MISMATCH (-9) | Passwords do not match. | ||
E_NEW_USER_NAME_TOO_LONG (-10) | Username too long (max 30char). | ||
USER_NEW_REGISTERED (5) | New user registered. | ||
ConnectMySQLServer (Level 2) | See Table 4.31 | connect_2_mysqli_server() |
|
|
mysql_backup | 1 | $backup_file_name |
|
login (Level 1) | E_MYSQL_NOT_CONNECTED (-7) | Failed login: cannot connect to MYSQL server. |
E_MYSQL_SERVER_UNKOWN (-6) | Failed login: cannot connect to MYSQL server. Given server address not found in mysqli_config.ini. | ||
E_MYSQL_CONFIG_NOT_FOUND (-5) | Failed login: cannot connect to MYSQL server. | ||
KNOWN_USER_WRONG_PASSWORD (-2) | Failed login: wrong credentials. | ||
UNREGISTERED_USER (-1) | Failed login: unregistered username | ||
USER_LOGGED_ON (1) | User $username is logged on from $ip at time $time_str | ||
ADMIN_LOGGED_ON (2) | User admin is logged on from $ip at time $time_str | ||
SID (Level 1) | $sid | $SID | |
email (Level 2) | See Table 4.29 | loginNotificationEmail() |
|
CreateEmail (Level 3) | See Table 4.30 | CreateEmailContainer . |
|
ConnectMySQLServer (Level 4) | See Table 4.31 | connect_2_mysqli_server() |
|
|
ForgotPassword (Level 1) | E_MYSQL_NOT_CONNECTED (-7) | Failed login: cannot connect to MYSQL server. |
E_MYSQL_SERVER_UNKOWN (-6) | Failed login: cannot connect to MYSQL server. | ||
E_MYSQL_CONFIG_NOT_FOUND (-5) | Failed login: cannot connect to MYSQL server. | ||
ADMIN_USER_NO_RESET_PASSWD (-4) | User admin does not forget password. | ||
KNOWN_USER_WRONG_EMAIL (-3) | Username is registered. Unknown e-mail address. | ||
UNREGISTERED_USER (-1) | Username not registered. | ||
USER_PASSWORD_RESET (4) | Password reset. | ||
email (Level 2) | See Table 4.29 | loginNotificationEmail() |
|
CreateEmail (Level 3) | See Table 4.30 | CreateEmailContainer . |
|
ConnectMySQLServer (Level 4) | See Table 4.31 | connect_2_mysqli_server() |
Assigned in PHP function | Called by PHP function / file | Code values | Message |
---|---|---|---|
(implemented in |
E_PHPMAILER_OBJECT (-11) | PHPMailer: Mail error: cannot create PHPMailer object in $fname (= name of calling file). | |
E_PHPMAILER_CANNOT_SEND (-12) | PHPMailer: Sending mail error in $fname. | ||
0 | PHPMailer: Mail send from $fname. |
Assigned in PHP function | Called by PHP function | Code values | Message |
---|---|---|---|
(implemented in |
E_MAIL_CONT_WEBSERVER_NF (-13) | USERNAME webserver IN MEMBERS TABLE NOT FOUND. | |
E_WEBSERVER_TABLE_NF (-14) | webserver TABLE NOT KNOWN. Should not occur. | ||
E_ISP_HOSTNAME_NF (-15) | message’=>’ISP ‘.HOSTNAME_ISP.’ NOT FOUND. (wrong definition of HOSTNAME_ISP. (See also Listing 1.2.) |
Assigned in PHP function | Called by PHP function | Code values | Message |
---|---|---|---|
(implemented in |
CreateEmailContainer |
-1 | File mysql_config.ini not found
(see Section 1.7.3). |
0 | MYSQL @ ISP($hn), LOCAL WEBSERVER, or MYSQL @ ISP($hn), ISP WEBSERVER. | ||
mysqli_connect_errno() (values > 0) | mysqli_connect_error() |
4.6. prepareGalleryAjax.php¶
See also third row in Table 4.1, and image in the third column of Table 4.2.
<?php
set_time_limit(0);
require_once($_SERVER['DOCUMENT_ROOT'].'/php/filesystem.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/login/loginFunctions.php');
function createGalleryPictures($parent,$vakantieDir,$locations){
$fprocfile=$parent.DS.$vakantieDir.DS.FPROCFILE;
if (file_exists($fprocfile)){exit();}
// $fproc=fopen($fprocfile,"w");
// fclose($fproc);
if(session_id()===''){session_start();}
$_SESSION['parent']=$parent;
$_SESSION['vakantieDir']=$vakantieDir;
$_SESSION['locations']=$locations;
echo "<script>window.open('imageresizeprogress.php','_blank');window.focus();</script>";
// ResizeGalleryPictures($parent,$vakantieDir,$locations);
}
// createAlbumCodeFromXML_Begin
function createAlbumCodeFromXML(&$albumDir4Html,$wdir,$xmlfile,$mode){
// INP1: work directory
// INP2: name of XML iminfo file
// INP3: private or public mode
$xml=simplexml_load_file($xmlfile);
if (isset($xml->VideoInfo)){
// Dummy DIV with DATA-ATTRIBUTE VIDEO INFO
$videoInfo=$xml->VideoInfo;
if($videoInfo->HasVideo>0){
$albumDir4Html['videoInfo']['hasVideo']=true;
$albumDir4Html['videoInfo']['width']=intval($videoInfo->VideoWidth);
$albumDir4Html['videoInfo']['height']=intval($videoInfo->VideoHeight);
} else {
// echo "<div id=\"generalVideoInfo\" data-hasvideo=\"0\"></div>\n";
}
} else {
// echo "<div id=\"generalVideoInfo\" data-hasvideo=\"0\"></div>\n";
}
// Slides Container: required properties (position, width, and height are set in SlideBox class)
$nrMedia=0;
foreach ($xml->media as $media){
$dir=$wdir.DS."Resized";
if (($mode==='ONLY_PUBLIC')&&(trim($media->PublicPrivate)===PRIVATE_DIR)){continue;}
else if (($mode==='PUBLIC_AND_PRIVATE')&&(trim($media->PublicPrivate)===PRIVATE_DIR))
{$dir=$dir.DS.PRIVATE_DIR;}
// $nrMedia++;
$mtype=$media->MIMETYPE->children();
$SrcCount=intval($media->Count);
$mEntry['name']=array_fill(0,$SrcCount,"");
$mEntry['srcCount']=$SrcCount;
if (intval($media->Transferred2SiteDir) > TRANSFER_NONE) {
$nrMedia++;
if ($mtype->getName()==='IMAGE'){
$img=trim($media->TimeSortedFile);
$thumb=str_replace('small','thumb',$img);
$mEntry['type']='IMAGE';
$mEntry['name'][0]=$dir.DS.$img;
$mEntry['thumb']=$dir.DS.$thumb;
}
else if ($mtype->getName()==='VIDEO'){
$basename=pathinfo(trim($media->TimeSortedFile),PATHINFO_FILENAME);
$video=$media->MIMETYPE->VIDEO;
for ($i=0;$i<$SrcCount;$i++){
$ext=strtolower($video->TYPE[$i]->attributes()->ext);
$mEntry['name'][$i]=$dir.DS.$basename.".".$ext;
}
$mEntry['type']='VIDEO';
$mEntry['width']=$media->Width;
$mEntry['thumb']=$dir.DS.$basename.'.thm';
}
$albumDir4Html['media'][]=$mEntry;
}
}
$albumDir4Html['nrMedia']=$nrMedia;
}
// createAlbumCodeFromXML_End
// createAlbumCode_Begin
function createAlbumCode(&$albumDirHtml,$parent,$vakantieDir,$locDir){
$pwd=getcwd();
/* location directory will be the working directory*/
// $wdir=str_replace(' ','%20',$_SERVER['DOCUMENT_ROOT'].DS.$parent.DS.$vakantieDir.DS.$locDir);
$wdir=$_SERVER['DOCUMENT_ROOT'].DS.$parent.DS.$vakantieDir.DS.$locDir;
chdir($wdir);
if (file_exists('iminfo.xml')){createAlbumCodeFromXML($albumDirHtml,$parent.DS.$vakantieDir.DS.$locDir,'iminfo.xml','ONLY_PUBLIC');}
chdir($pwd);
}
// createAlbumCode_End
// createPrivateAlbumCode_Begin
function createPrivateAlbumCode(&$albumDirHtml,$parent,$vakantieDir,$locDir){
$pwd=getcwd();
/* location directory will be the working directory*/
// $wdir=str_replace(' ','%20',$_SERVER['DOCUMENT_ROOT'].DS.$parent.DS.$vakantieDir.DS.$locDir);
$wdir=$_SERVER['DOCUMENT_ROOT'].DS.$parent.DS.$vakantieDir.DS.$locDir;
chdir($wdir);
if (file_exists('iminfo.xml')){createAlbumCodeFromXML($albumDirHtml,$parent.DS.$vakantieDir.DS.$locDir,'iminfo.xml','PUBLIC_AND_PRIVATE');}
chdir($pwd);
}
// createPrivateAlbumCode_End
// Start script
// BEGIN PHP CODE WHEN CALLED FROM AJAX
sec_session_start();
if (isset($_POST['parent'])){$parent=$_POST['parent'];} else {$parent='';}
if (isset($_POST['locDir']))$locDir=$_POST['locDir'];
if (isset($_POST['vacDir']))$vacDir=$_POST['vacDir'];
if (isset($_POST['private'])){$private=intval($_POST['private']);}else {$private=0;}
if (isset($_POST['pageReload'])){$pageReload=($_POST['pageReload']==='true'?true:false);
} else {$pageReload=false;}
if (isset($_SESSION['sess_username']))$uname=$_SESSION['sess_username'];
else $uname=WEBSITE_VISITOR;
$wdir=$_SERVER['DOCUMENT_ROOT'].DS.$parent.DS.$locDir;
$pwd=getcwd(); // php directory
$sid=session_id();
$albumDirHtml=array('xml'=>true,'nrMedia'=>0,'media'=>NULL,'videoInfo'=>array('hasVideo'=>false,'width'=>0,'height'=>0));
if ($private) createPrivateAlbumCode($albumDirHtml,$parent,$vacDir,$locDir);
else createAlbumCode($albumDirHtml,$parent,$vacDir,$locDir);
echo json_encode($albumDirHtml);
?>
4.7. prepareDirOverviewGalleryAjax.php¶
See also second row in Table 4.1, and Fig. 4.6.
<?php
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);
?>