Commit 6b7e2ce3fd2eb8455e131fa17b71c79838faed62

Authored by Mark Holtzhausen
2 parents c77d0d52 a33d2bea

Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge

Showing 95 changed files with 3751 additions and 1754 deletions
bin/luceneserver/ktlucene.jar
No preview for this file type
call_home.php 0 → 100644
  1 +<?php
  2 +/*
  3 +* Data incoming format: <installation guid>|<user count>|<document count>|<KT version>|<KT edition>|<OS info>
  4 +*/
  5 +
  6 +$data = isset($_REQUEST['system_info']) ? strip_tags($_REQUEST['system_info']) : '';
  7 +
  8 +if(empty($data)){
  9 + exit(0);
  10 +}
  11 +
  12 +$file = 'var/system_info.txt';
  13 +$fp = fopen($file, 'a');
  14 +fwrite($fp, $data."\n");
  15 +fclose($fp);
  16 +
  17 +exit(0);
  18 +?>
0 \ No newline at end of file 19 \ No newline at end of file
dmsctl.bat
@@ -4,7 +4,7 @@ rem KnowledgeTree Control Script @@ -4,7 +4,7 @@ rem KnowledgeTree Control Script
4 4
5 5
6 rem ============= SET ENVIRONMENT VARIABLES ============== 6 rem ============= SET ENVIRONMENT VARIABLES ==============
7 -set INSTALL_PATH=%CD% 7 +set INSTALL_PATH=%~dp0
8 cd .. 8 cd ..
9 cd .. 9 cd ..
10 set ZEND_PATH=%CD% 10 set ZEND_PATH=%CD%
dmsctl.sh
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # chkconfig: 2345 55 25 2 # chkconfig: 2345 55 25
3 # description: KnowledgeTree Services 3 # description: KnowledgeTree Services
4 # 4 #
5 -# processname: ktdms 5 +# processname: ktdms
6 6
7 cd $(dirname $0) 7 cd $(dirname $0)
8 8
@@ -16,20 +16,37 @@ INSTALL_PATH=`pwd` @@ -16,20 +16,37 @@ INSTALL_PATH=`pwd`
16 JAVABIN=/usr/bin/java 16 JAVABIN=/usr/bin/java
17 ZEND_DIR=/usr/local/zend 17 ZEND_DIR=/usr/local/zend
18 18
  19 +# exits if the UID is not 0 [root]
  20 +check_root_privileges()
  21 +{
  22 + ID="id -u"
  23 + MYUID=`$ID 2> /dev/null`
  24 + if [ ! -z "$MYUID" ]; then
  25 + if [ $MYUID != 0 ]; then
  26 + echo "You need root privileges to run this script!";
  27 + exit 1
  28 + fi
  29 + else
  30 + echo "Could not detect UID";
  31 + exit 1
  32 + fi
  33 +}
  34 +
  35 +
19 if [ -f /etc/zce.rc ];then 36 if [ -f /etc/zce.rc ];then
20 . /etc/zce.rc 37 . /etc/zce.rc
21 else 38 else
22 echo "/etc/zce.rc doesn't exist!" 39 echo "/etc/zce.rc doesn't exist!"
23 exit 1; 40 exit 1;
24 fi 41 fi
25 - 42 +check_root_privileges
26 43
27 # OpenOffice 44 # OpenOffice
28 SOFFICEFILE=soffice 45 SOFFICEFILE=soffice
29 SOFFICE_PIDFILE=$INSTALL_PATH/var/log/soffice.bin.pid 46 SOFFICE_PIDFILE=$INSTALL_PATH/var/log/soffice.bin.pid
30 SOFFICE_PID="" 47 SOFFICE_PID=""
31 SOFFICE_PORT="8100" 48 SOFFICE_PORT="8100"
32 -SOFFICEBIN=/usr/bin/soffice 49 +SOFFICEBIN="/usr/share/ktdms-office/ktdms-office/openoffice/program/soffice"
33 SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager" 50 SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager"
34 SOFFICE_STATUS="" 51 SOFFICE_STATUS=""
35 52
@@ -38,7 +55,6 @@ LUCENE_PIDFILE=$INSTALL_PATH/var/log/lucene.pid @@ -38,7 +55,6 @@ LUCENE_PIDFILE=$INSTALL_PATH/var/log/lucene.pid
38 LUCENE_PID="" 55 LUCENE_PID=""
39 LUCENE="$JAVABIN -Xms512M -Xmx512M -jar ktlucene.jar" 56 LUCENE="$JAVABIN -Xms512M -Xmx512M -jar ktlucene.jar"
40 LUCENE_STATUS="" 57 LUCENE_STATUS=""
41 -:q  
42 58
43 # Scheduler 59 # Scheduler
44 SCHEDULER_PATH="$INSTALL_PATH/bin/" 60 SCHEDULER_PATH="$INSTALL_PATH/bin/"
@@ -71,7 +87,7 @@ get_pid() { @@ -71,7 +87,7 @@ get_pid() {
71 get_soffice_pid() { 87 get_soffice_pid() {
72 get_pid $SOFFICE_PIDFILE 88 get_pid $SOFFICE_PIDFILE
73 if [ ! $PID ]; then 89 if [ ! $PID ]; then
74 - return 90 + return
75 fi 91 fi
76 if [ $PID -gt 0 ]; then 92 if [ $PID -gt 0 ]; then
77 SOFFICE_PID=$PID 93 SOFFICE_PID=$PID
@@ -81,7 +97,7 @@ get_soffice_pid() { @@ -81,7 +97,7 @@ get_soffice_pid() {
81 get_lucene_pid() { 97 get_lucene_pid() {
82 get_pid $LUCENE_PIDFILE 98 get_pid $LUCENE_PIDFILE
83 if [ ! $PID ]; then 99 if [ ! $PID ]; then
84 - return 100 + return
85 fi 101 fi
86 if [ $PID -gt 0 ]; then 102 if [ $PID -gt 0 ]; then
87 LUCENE_PID=$PID 103 LUCENE_PID=$PID
@@ -91,7 +107,7 @@ get_lucene_pid() { @@ -91,7 +107,7 @@ get_lucene_pid() {
91 get_scheduler_pid() { 107 get_scheduler_pid() {
92 get_pid $SCHEDULER_PIDFILE 108 get_pid $SCHEDULER_PIDFILE
93 if [ ! $PID ]; then 109 if [ ! $PID ]; then
94 - return 110 + return
95 fi 111 fi
96 if [ $PID -gt 0 ]; then 112 if [ $PID -gt 0 ]; then
97 SCHEDULER_PID=$PID 113 SCHEDULER_PID=$PID
@@ -101,7 +117,7 @@ get_scheduler_pid() { @@ -101,7 +117,7 @@ get_scheduler_pid() {
101 get_mysql_pid() { 117 get_mysql_pid() {
102 get_pid $MYSQL_PIDFILE 118 get_pid $MYSQL_PIDFILE
103 if [ ! $PID ]; then 119 if [ ! $PID ]; then
104 - return 120 + return
105 fi 121 fi
106 if [ $PID -gt 0 ]; then 122 if [ $PID -gt 0 ]; then
107 MYSQL_PID=$PID 123 MYSQL_PID=$PID
@@ -183,7 +199,7 @@ start_soffice() { @@ -183,7 +199,7 @@ start_soffice() {
183 echo "$0 $ARG: openoffice could not be started" 199 echo "$0 $ARG: openoffice could not be started"
184 ERROR=3 200 ERROR=3
185 fi 201 fi
186 - else 202 + else
187 echo "$0 $ARG: path to openoffice binary ($SOFFICEBIN) could not be found" 203 echo "$0 $ARG: path to openoffice binary ($SOFFICEBIN) could not be found"
188 ERROR=3 204 ERROR=3
189 fi 205 fi
@@ -388,14 +404,45 @@ if [ ! -z ${2} ]; then @@ -388,14 +404,45 @@ if [ ! -z ${2} ]; then
388 [ "${2}" != "mysql" ] && [ "${2}" != "apache" ] && [ "${2}" != "agent" ] && [ "${2}" != "scheduler" ] && [ "${2}" != "soffice" ] && [ "${2}" != "lucene" ] && noserver $2 404 [ "${2}" != "mysql" ] && [ "${2}" != "apache" ] && [ "${2}" != "agent" ] && [ "${2}" != "scheduler" ] && [ "${2}" != "soffice" ] && [ "${2}" != "lucene" ] && noserver $2
389 SERVER=$2 405 SERVER=$2
390 fi 406 fi
391 - 407 +
392 408
393 if [ "x$3" != "x" ]; then 409 if [ "x$3" != "x" ]; then
394 MYSQL_PASSWORD=$3 410 MYSQL_PASSWORD=$3
395 fi 411 fi
396 412
397 # Are we running for first time 413 # Are we running for first time
398 -[[ -e $INSTALL_PATH/var/bin/dmsinit.lock ]] || firstrun 414 +if [ -e "/usr/share/knowledgetree/var/bin/dmsinit.lock" ]
  415 +then
  416 +echo "";
  417 +else
  418 + if grep --quiet LD_LIBRARAY_PATH /etc/zce.rc ; then
  419 + echo "Nothing to be done ... maybe"
  420 + else
  421 + echo "PATH=/usr/local/zend/bin:$PATH" >> /etc/zce.rc
  422 + if [ -z $LD_LIBRARY_PATH ] ; then
  423 + echo "LD_LIBRARY_PATH=$ZEND_DIR/lib" >> /etc/zce.rc
  424 + else
  425 + echo "LD_LIBRARY_PATH=$ZEND_DIR/lib:$LD_LIBRARY_PATH" >> /etc/zce.rc
  426 + fi
  427 + fi
  428 + touch $INSTALL_PATH/var/bin/dmsinit.lock
  429 + $ZEND_DIR/bin/zendctl.sh restart
  430 +fi
  431 +
  432 +#if [ "ls /usr/share/knowledgetree/var/bin/dmsinit.lock" != "" ] ; then
  433 +# echo "No lock"
  434 +#e#lse
  435 +# echo "lock"
  436 +#f#i
  437 +
  438 +#if [ -f "/usr/share/knowledgetree/var/bin/dmsinit.lock"] ; then
  439 +# firstrun
  440 +#else
  441 +# echo 'safd';
  442 +# exit 1;
  443 +#fi
  444 +
  445 +#[[ -e $INSTALL_PATH/var/bin/dmsinit.lock ]] || firstrun
399 446
400 case $1 in 447 case $1 in
401 help) help 448 help) help
dmsctl.vbs 0 → 100644
  1 +'
  2 +' KnowledgeTree
  3 +'
  4 +'
  5 +'
  6 +
  7 +' Service Name Consts
  8 +Const KTOFFICE = "KTOpenoffice"
  9 +Const KTSCHEDULER = "KTScheduler"
  10 +Const KTLUCENE = "KTLucene"
  11 +
  12 +' Service Control Manager Error Code Consts
  13 +Const SVC_SUCCESS = 0 ' Success
  14 +Const SVC_NOT_SUPPORTED = 1 ' Not Supported
  15 +Const SVC_ACCESS_DENIED = 2 ' Access Denied
  16 +Const SVC_DEPENDENT_SERVICES_RUNNING = 3 ' Dependent Services Running
  17 +Const SVC_INVALID_SERVICE_CONTROL = 4 ' Invalid Service Control
  18 +Const SVC_SERVICE_CANNOT_ACCEPT_CONTROL = 5 ' Service Cannot Accept Control
  19 +Const SVC_SERVICE_NOT_ACTIVE = 6 ' Service Not Active
  20 +Const SVC_SERVICE_REQUEST_TIMEOUT = 7 ' Service Request Timeout
  21 +Const SVC_UNKNOWN_FAILURE = 8 ' Unknown Failure
  22 +Const SVC_PATH_NOT_FOUND = 9 ' Path Not Found
  23 +Const SVC_SERVICE_ALREADY_RUNNING = 10 ' Service Already Running
  24 +Const SVC_SERVICE_DATABASE_LOCKED = 11 ' Service Database Locked
  25 +Const SVC_SERVICE_DEPENDENCY_DELETED = 12 ' Service Dependency Deleted
  26 +Const SVC_SERVICE_DEPENDENCY_FAILURE = 13 ' Service Dependency Failure
  27 +Const SVC_SERVICE_DISABLED = 14 ' Service Disabled
  28 +Const SVC_SERVICE_LOGON_FAILURE = 15 ' Service Logon Failure
  29 +Const SVC_SERVICE_MARKED_FOR_DELETION = 16 ' Service Marked For Deletion
  30 +Const SVC_SERVICES_NO_THREAD = 17 ' Service No Thread
  31 +Const SVC_STATUS_CIRCULAR_DEPENDENCY = 18 ' Status Circular Dependency
  32 +Const SVC_STATUS_DUPLICATE_NAME = 19 ' Status Duplicate Name
  33 +Const SVC_INVALID_NAME = 20 ' Status Invalid Name
  34 +Const SVC_STATUS_INVALID_PARAMETER = 21 ' Status Invalid Parameter
  35 +Const SVC_INVALID_SERVICES_ACCOUNT = 22 ' Status Invalid Service Account
  36 +Const SVC_STATUS_SERVICE_EXISTS = 23 ' Status Service Exists
  37 +Const SVC_SERVICE_ALREADY_PAUSED = 24 ' Service Already Paused
  38 +
  39 +Dim strComputer, currOS, currDir, doRunAs, lastErrorCode
  40 +
  41 +' Detecting the current directory
  42 +Set oFso = CreateObject("Scripting.FileSystemObject")
  43 +currDir = oFso.GetParentFolderName(Wscript.ScriptFullName)
  44 +
  45 +strComputer = "."
  46 +currOS = ""
  47 +doRunAs = false
  48 +
  49 +' Detecting the current OS
  50 +Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  51 +Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
  52 +
  53 +For Each objOperatingSystem in colOperatingSystems
  54 + currOS = objOperatingSystem.Caption & " " & objOperatingSystem.Version
  55 + currOS = trim(currOS)
  56 +Next
  57 +
  58 +Public Function isWindowsVista()
  59 + isWindowsVista = false
  60 + If left(currOS, 19) = "Microsoft Windows Vista" Then
  61 + isWindowsVista = TRUE
  62 + End If
  63 +End Function
  64 +
  65 +Public Function isWindows7()
  66 + isWindows7 = false
  67 + If left(currOS, 19) = "Microsoft Windows 7" Then
  68 + isWindows7 = TRUE
  69 + End If
  70 +End Function
  71 +
  72 +Public Function isWindows2008()
  73 + isWindows2008 = false
  74 + If mid(currOS, 27, 42) = "2008 Enterprise" Then
  75 + isWindows2008 = TRUE
  76 + End If
  77 +End Function
  78 +
  79 +' Will call this further down when the individual services need starting
  80 +If doRunAs = TRUE Then
  81 + 'runAs "C:\Program Files (x86)\Zend\ktdms\knowledgetree", "dmsctl_install.bat"
  82 +End If
  83 +
  84 +Public Sub runAs(ByVal strFolder, ByVal strFile)
  85 + Set objShell = CreateObject("Shell.Application")
  86 + Set objFolder = objShell.Namespace(strFolder)
  87 + Set objFolderItem = objFolder.ParseName(strFile)
  88 + objFolderItem.InvokeVerb "runas"
  89 +End Sub
  90 +
  91 +dim objArgs, errMsg, result, strUsage, isSuccess
  92 +
  93 +strUsage = "USAGE:" &_
  94 +"dmsctl.vbs <start|stop|restart|install|uninstall> [servicename]" & vbNewLine &_
  95 +vbNewLine &_
  96 +"help - this screen " & vbNewLine &_
  97 +"start - start the services" & vbNewLine &_
  98 +"stop - stop the services" & vbNewLine &_
  99 +"restart - restart the services" & vbNewLine &_
  100 +"install - install the services" & vbNewLine &_
  101 +"uninstall - uninstall the services" & vbNewLine &_
  102 +vbNewLine &_
  103 +"servicename - optional service name to start/stop only that service." & vbNewLine &_
  104 +" only mysql is supported for individual control at this time."
  105 +
  106 +Set objArgs = WScript.Arguments
  107 +If (objArgs.count < 1) Then
  108 + Wscript.Echo strUsage
  109 +Else
  110 + Select Case objArgs.Item(0)
  111 + Case "install"
  112 + isSuccess = TRUE ' Track if anything went wrong
  113 +
  114 + ' Installing KTOffice
  115 + result = exec(currDir & "\var\bin\officeinstall.bat")
  116 +
  117 + 'Install Failed
  118 + If result = 0 Then
  119 + isSuccess = false
  120 + writeLog "The " & KTOFFICE & " KnowledgeTree service could not be installed."
  121 + Else
  122 + writeLog "The " & KTOFFICE & " KnowledgeTree service was successfully installed."
  123 + End If
  124 +
  125 + ' Installing KTScheduler
  126 + result = exec(currDir & "\var\bin\schedulerinstall.bat")
  127 +
  128 + 'Install Failed
  129 + If result = 0 Then
  130 + isSuccess = false
  131 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service could not be installed."
  132 + Else
  133 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service was successfully installed."
  134 + End If
  135 +
  136 + ' Installing KTLucene
  137 + result = exec(currDir & "\var\bin\luceneinstall.bat")
  138 +
  139 + 'Install Failed
  140 + If result = 0 Then
  141 + isSuccess = false
  142 + writeLog "The " & KTLUCENE & " KnowledgeTree service could not be installed."
  143 + Else
  144 + writeLog "The " & KTLUCENE & " KnowledgeTree service was successfully installed."
  145 + End If
  146 +
  147 + If (isSuccess) Then
  148 + Wscript.Echo "The KnowledgeTree services were successfully installed"
  149 + Else
  150 + Wscript.Echo "There were errors installing the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  151 + End If
  152 +
  153 + Case "start"
  154 + If (objArgs.count > 1) Then
  155 + Select Case objArgs.Item(1)
  156 + Case "soffice"
  157 + isSuccess = TRUE
  158 + svcName = KTOFFICE
  159 + If (NOT isServiceStarted(svcName)) Then
  160 + If (NOT startService(svcName)) Then
  161 + isSuccess = FALSE
  162 + writeLog "The " & KTOFFICE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  163 + Else
  164 + writeLog "The " & KTOFFICE & " KnowledgeTree service was successfully started"
  165 + End If
  166 +
  167 + writeLog "Successfully started " & KTOFFICE
  168 + Else
  169 + writeLog KTOFFICE & " already started. Result Code: " & lastErrorCode
  170 + End If
  171 +
  172 + If (isSuccess) Then
  173 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service was successfully started"
  174 + Else
  175 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  176 + End If
  177 +
  178 + Case "scheduler"
  179 + isSuccess = TRUE
  180 + svcName = KTSCHEDULER
  181 + If (NOT isServiceStarted(svcName)) Then
  182 + If (NOT startService(svcName)) Then
  183 + isSuccess = FALSE
  184 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  185 + Else
  186 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service was successfully started"
  187 + End If
  188 +
  189 + writeLog "Successfully started " & KTSCHEDULER
  190 + Else
  191 + writeLog KTSCHEDULER & " already started. Result Code: " & lastErrorCode
  192 + End If
  193 +
  194 + If (isSuccess) Then
  195 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service was successfully started"
  196 + Else
  197 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  198 + End If
  199 +
  200 + Case "lucene"
  201 + isSuccess = TRUE
  202 + svcName = KTLUCENE
  203 + If (NOT isServiceStarted(svcName)) Then
  204 + If (NOT startService(svcName)) Then
  205 + isSuccess = false
  206 + writeLog "The " & KTLUCENE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  207 + Else
  208 + writeLog "The " & KTLUCENE & " KnowledgeTree service was successfully started"
  209 + End If
  210 +
  211 + writeLog "Successfully started " & KTLUCENE
  212 + Else
  213 + writeLog KTLUCENE & " already started. Result Code: " & lastErrorCode
  214 + End If
  215 +
  216 + If (isSuccess) Then
  217 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service was successfully started"
  218 + Else
  219 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  220 + End If
  221 + End Select
  222 + Else
  223 + isSuccess = TRUE
  224 +
  225 + svcName = KTOFFICE
  226 + If (NOT isServiceStarted(svcName)) Then
  227 + If (NOT startService(svcName)) Then
  228 + isSuccess = false
  229 + End If
  230 + writeLog "Successfully started " & KTOFFICE
  231 + Else
  232 + writeLog KTOFFICE & " already started. Result Code: " & lastErrorCode
  233 + End If
  234 +
  235 + svcName = KTSCHEDULER
  236 + If (NOT isServiceStarted(svcName)) Then
  237 + If (NOT startService(svcName)) Then
  238 + isSuccess = false
  239 + End If
  240 + writeLog "Successfully started " & KTSCHEDULER
  241 + Else
  242 + writeLog KTSCHEDULER & " already started. Result Code: " & lastErrorCode
  243 + End If
  244 +
  245 + svcName = KTLUCENE
  246 + If (NOT isServiceStarted(svcName)) Then
  247 + If (NOT startService(svcName)) Then
  248 + isSuccess = false
  249 + End If
  250 + writeLog "Successfully started " & KTLUCENE
  251 + Else
  252 + writeLog KTLUCENE & " already started. Result Code: " & lastErrorCode
  253 + End If
  254 +
  255 + If (isSuccess) Then
  256 + Wscript.Echo "The KnowledgeTree services were successfully started"
  257 + Else
  258 + Wscript.Echo "There were errors starting the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  259 + End If
  260 + End If
  261 + Case "stop"
  262 + If (objArgs.count > 1) Then
  263 + Select Case objArgs.Item(1)
  264 + Case "soffice"
  265 + isSuccess = TRUE
  266 + svcName = KTOFFICE
  267 + If (isServiceStarted(svcName)) Then
  268 + If (NOT stopService(svcName)) Then
  269 + isSuccess = false
  270 + writeLog "The " & KTOFFICE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  271 + Else
  272 + writeLog "The " & KTOFFICE & " KnowledgeTree service was successfully stopped"
  273 + End If
  274 +
  275 + writeLog "Successfully stopped " & KTOFFICE
  276 + Else
  277 + writeLog KTOFFICE & " already stopped. Result Code: " & lastErrorCode
  278 + End If
  279 +
  280 + If (isSuccess) Then
  281 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service was successfully stopped"
  282 + Else
  283 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  284 + End If
  285 +
  286 + Case "scheduler"
  287 + isSuccess = TRUE
  288 + svcName = KTSCHEDULER
  289 + If (isServiceStarted(svcName)) Then
  290 + If (NOT stopService(svcName)) Then
  291 + isSuccess = false
  292 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  293 + Else
  294 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service was successfully stopped"
  295 + End If
  296 +
  297 + writeLog "Successfully stopped " & KTSCHEDULER
  298 + Else
  299 + writeLog KTSCHEDULER & " already stopped. Result Code: " & lastErrorCode
  300 + End If
  301 +
  302 + If (isSuccess) Then
  303 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service was successfully stopped"
  304 + Else
  305 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  306 + End If
  307 +
  308 + Case "lucene"
  309 + isSuccess = TRUE
  310 + svcName = KTLUCENE
  311 + If (isServiceStarted(svcName)) Then
  312 + If (NOT stopService(svcName)) Then
  313 + isSuccess = false
  314 + writeLog "The " & KTLUCENE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  315 + Else
  316 + writeLog "The " & KTLUCENE & " KnowledgeTree service was successfully stopped"
  317 + End If
  318 +
  319 + writeLog "Successfully stopped " & KTLUCENE
  320 + Else
  321 + writeLog KTLUCENE & " already stopped. Result Code: " & lastErrorCode
  322 + End If
  323 +
  324 + If (isSuccess) Then
  325 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service was successfully stopped"
  326 + Else
  327 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  328 + End If
  329 + End Select
  330 + Else
  331 + 'Stopping all the services
  332 + isSuccess = TRUE
  333 +
  334 + svcName = KTOFFICE
  335 + If (isServiceStarted(svcName)) Then
  336 + If (NOT stopService(svcName)) Then
  337 + isSuccess = false
  338 + End If
  339 + writeLog "Successfully stopped " & KTOFFICE
  340 + Else
  341 + writeLog KTOFFICE & " already stopped. Result Code: " & lastErrorCode
  342 + End If
  343 +
  344 + svcName = KTSCHEDULER
  345 + If (isServiceStarted(svcName)) Then
  346 + If (NOT stopService(svcName)) Then
  347 + isSuccess = false
  348 + End If
  349 + writeLog "Successfully stopped " & KTSCHEDULER
  350 + Else
  351 + writeLog KTSCHEDULER & " already stopped. Result Code: " & lastErrorCode
  352 + End If
  353 +
  354 + svcName = KTLUCENE
  355 + If (isServiceStarted(svcName)) Then
  356 + If (NOT stopService(svcName)) Then
  357 + isSuccess = false
  358 + End If
  359 + writeLog "Successfully stopped " & KTLUCENE
  360 + Else
  361 + writeLog KTLUCENE & " already stopped. Result Code: " & lastErrorCode
  362 + End If
  363 +
  364 + If (isSuccess) Then
  365 + Wscript.Echo "The KnowledgeTree services were successfully stopped"
  366 + Else
  367 + Wscript.Echo "There were errors sopping the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  368 + End If
  369 + End If
  370 +
  371 + Case "uninstall"
  372 + isSuccess = TRUE
  373 +
  374 + svcName = KTOFFICE
  375 + If (NOT uninstallService(svcName)) Then
  376 + isSuccess = false
  377 + writeLog "The KnowledgeTree KTOffice service could not be uninstalled"
  378 + End If
  379 +
  380 + svcName = KTSCHEDULER
  381 + If (NOT uninstallService(svcName)) Then
  382 + isSuccess = false
  383 + writeLog "The KnowledgeTree KTScheduler service could not be uninstalled"
  384 + End If
  385 +
  386 + svcName = KTLUCENE
  387 + If (NOT uninstallService(svcName)) Then
  388 + isSuccess = false
  389 + writeLog "The KnowledgeTree KTLucene service could not be uninstalled"
  390 + End If
  391 +
  392 + If (isSuccess) Then
  393 + Wscript.Echo "The KnowledgeTree services were uninstalled"
  394 + Else
  395 + Wscript.Echo "There were errors uninstalling the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  396 + End If
  397 +
  398 + Case "uninstall_old" 'Depricated : This method prevents verbose error logging, using WMI to uninstall instead
  399 + isSuccess = TRUE ' Track if anything went wrong
  400 +
  401 + ' Stopping Then FALSE
  402 + 'svcName = KTOFFICE
  403 + 'If (isServiceStarted(svcName)) Then
  404 + ' If (NOT stopService(svcName)) Then
  405 + ' isSuccess = false
  406 + ' End If
  407 + 'End If
  408 +
  409 + ' FALSE KTOffice
  410 + result = exec("sc delete " & KTOFFICE)
  411 +
  412 + 'Uninstall Failed
  413 + If result = 0 Then
  414 + isSuccess = false
  415 + writeLog "The KnowledgeTree KTOffice service could not be uninstalled"
  416 + End If
  417 +
  418 + ' Stopping Then FALSE
  419 + 'svcName = KTSCHEDULER
  420 + 'If (isServiceStarted(svcName)) Then
  421 + ' If (NOT stopService(svcName)) Then
  422 + ' isSuccess = false
  423 + ' End If
  424 + 'End If
  425 +
  426 + ' FALSE KTScheduler
  427 + result = exec("sc delete " & KTSCHEDULER)
  428 +
  429 + 'Uninstall Failed
  430 + If result = 0 Then
  431 + isSuccess = false
  432 + writeLog "The KnowledgeTree KTScheduler service could not be uninstalled"
  433 + End If
  434 +
  435 + ' Stopping Then FALSE
  436 + 'svcName = KTLUCENE
  437 + 'If (isServiceStarted(svcName)) Then
  438 + ' If (NOT stopService(svcName)) Then
  439 + ' isSuccess = FALSE
  440 + ' End If
  441 + 'End If
  442 +
  443 + ' FALSE KTLucene
  444 + result = exec("sc delete " & KTLUCENE)
  445 +
  446 + 'Uninstall Failed
  447 + If result = 0 Then
  448 + isSuccess = FALSE
  449 + writeLog "The KnowledgeTree KTLucene service could not be uninstalled"
  450 + End If
  451 +
  452 + If (isSuccess) Then
  453 + Wscript.Echo "The KnowledgeTree services were uninstalled"
  454 + Else
  455 + Wscript.Echo "There were errors uninstalling the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  456 + End If
  457 +
  458 +
  459 + Case Else
  460 + Wscript.Echo strUsage
  461 + End Select
  462 +
  463 +End If
  464 +
  465 +' Method to check if a service is installed
  466 +Public Function isServiceInstalled(ByVal svcName)
  467 + strComputer = "."
  468 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  469 +
  470 + ' Obtain an instance of the the class
  471 + ' using a key property value.
  472 +
  473 + isServiceInstalled = FALSE
  474 +
  475 + svcQry = "SELECT * from Win32_Service"
  476 + Set objOutParams = objWMIService.ExecQuery(svcQry)
  477 +
  478 + For Each objSvc in objOutParams
  479 +
  480 + Select Case objSvc.Name
  481 + Case svcName
  482 + isServiceInstalled = TRUE
  483 + End Select
  484 +
  485 + Next
  486 +
  487 + If (Not isServiceInstalled) Then
  488 + lastErrorCode = SVC_INVALID_NAME
  489 + End If
  490 +
  491 +End Function
  492 +
  493 +' Method to interrogate a service
  494 +Public Function isServiceStarted(ByVal svcName)
  495 + If (NOT isServiceInstalled( svcName )) Then
  496 + isServiceStarted = FALSE
  497 + Exit Function
  498 + End If
  499 +
  500 + strComputer = "."
  501 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  502 +
  503 + ' Obtain an instance of the the class
  504 + ' using a key property value.
  505 + Set objShare = objWMIService.Get("Win32_Service.Name='" & svcName & "'")
  506 +
  507 + ' no InParameters to define
  508 +
  509 + ' Execute the method and obtain the return status.
  510 + ' The OutParameters object in objOutParams
  511 + ' is created by the provider.
  512 + Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "InterrogateService")
  513 +
  514 + lastErrorCode = objOutParams.ReturnValue
  515 +
  516 + If (objOutParams.ReturnValue = SVC_SERVICE_NOT_ACTIVE) Then
  517 + isServiceStarted = FALSE
  518 + Else
  519 + isServiceStarted = TRUE
  520 + End If
  521 +
  522 +end Function
  523 +
  524 +' Method to start a service
  525 +Public Function startService(ByVal svcName)
  526 + If (NOT isServiceInstalled( svcName )) Then
  527 + writeLog "The KnowledgeTree " & svcName & " service could not be started because it isn't installed. Run 'dmsctl.vbs install' to correct."
  528 + startService = FALSE
  529 + Exit Function
  530 + End If
  531 +
  532 + strComputer = "."
  533 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  534 + ' Obtain an instance of the the class
  535 + ' using a key property value.
  536 + Set objShare = objWMIService.Get("Win32_Service.Name='" & svcName &"'")
  537 +
  538 + ' no InParameters to define
  539 +
  540 + ' Execute the method and obtain the return status.
  541 + ' The OutParameters object in objOutParams
  542 + ' is created by the provider.
  543 + Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "StartService")
  544 +
  545 + lastErrorCode = objOutParams.ReturnValue
  546 +
  547 + If (objOutParams.ReturnValue = SVC_SUCCESS) Then
  548 + startService = TRUE
  549 + Else
  550 + startService = FALSE
  551 + End If
  552 +
  553 +End Function
  554 +
  555 +' Method to stop a service
  556 +Public Function stopService(ByVal svcName)
  557 + If (NOT isServiceInstalled( svcName )) Then
  558 + writeLog "The KnowledgeTree " & svcName & " service could not be stopped because it isn't installed. Run 'dmsctl.vbs install' to correct."
  559 + stopService = FALSE
  560 + Exit Function
  561 + End If
  562 +
  563 + strComputer = "."
  564 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  565 + ' Obtain an instance of the the class
  566 + ' using a key property value.
  567 + Set objShare = objWMIService.Get("Win32_Service.Name='" & svcName &"'")
  568 +
  569 + ' no InParameters to define
  570 +
  571 + ' Execute the method and obtain the return status.
  572 + ' The OutParameters object in objOutParams
  573 + ' is created by the provider.
  574 + Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "StopService")
  575 +
  576 + lastErrorCode = objOutParams.ReturnValue
  577 +
  578 + If (objOutParams.ReturnValue = SVC_SUCCESS) Then
  579 + stopService = TRUE
  580 + Else
  581 + stopService = FALSE
  582 + End If
  583 +
  584 +End Function
  585 +
  586 +' Method to uninstall a service
  587 +Public Function uninstallService(ByVal svcName)
  588 + If (NOT isServiceInstalled( svcName )) Then
  589 + uninstallService = TRUE ' Service already uninstalled so return TRUE
  590 + Exit Function
  591 + End If
  592 +
  593 + wasStopped = TRUE
  594 + If (NOT stopService(svcName)) Then
  595 + wasStopped = FALSE
  596 + End If
  597 +
  598 + strComputer = "."
  599 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  600 + ' Obtain an instance of the the class
  601 + ' using a key property value.
  602 + Set objShare = objWMIService.Get("Win32_Service.Name='" & svcName & "'")
  603 +
  604 + ' no InParameters to define
  605 +
  606 + ' Execute the method and obtain the return status.
  607 + ' The OutParameters object in objOutParams
  608 + ' is created by the provider.
  609 + Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "Delete")
  610 +
  611 + lastErrorCode = objOutParams.ReturnValue
  612 +
  613 + If (objOutParams.ReturnValue = SVC_SUCCESS) Then
  614 + uninstallService = TRUE
  615 + Else
  616 + uninstallService = FALSE
  617 +
  618 + ' Extra Event logging to assist the Administrator
  619 + If (wasStopped) Then
  620 + writeLog "The KnowledgeTree " & svcName & " service could not be uninstalled because it could not be stopped. Stop this service manually before uninstalling."
  621 + uninstallService = FALSE ' Must be stop service before it can be uninstalled
  622 + End If
  623 +
  624 + End If
  625 +
  626 +End Function
  627 +
  628 +
  629 +' Execute a command
  630 +Public Function exec(ByVal cmd)
  631 +
  632 + Dim WshShell, oExec
  633 + Set WshShell = CreateObject("WScript.Shell")
  634 +
  635 + Set oExec = WshShell.Exec(cmd)
  636 +
  637 + Do While oExec.Status = 0
  638 + WScript.Sleep 100
  639 + Loop
  640 +
  641 + exec = oExec.Status
  642 +
  643 +End Function
  644 +
  645 +Public Sub createCustomEventLog(ByVal strName)
  646 + Const NO_VALUE = Empty
  647 +
  648 + Set WshShell = WScript.CreateObject("WScript.Shell")
  649 + WshShell.RegWrite _
  650 + "HKLM\System\CurrentControlSet\Services\EventLog\" & strName & "\", NO_VALUE
  651 +End Sub
  652 +
  653 +' Event logging only works on Server 2003, 2000 and XP
  654 +Public Sub logEvent(ByVal strMessage)
  655 + ' Disabled until Windows Vista detection has been tested.
  656 + 'If (NOT isWindowsVista() AND NOT isWindows7() AND NOT isWindows2008()) Then
  657 + ' Const EVENT_SUCCESS = 0
  658 + ' Set objShell = Wscript.CreateObject("Wscript.Shell")
  659 + ' objShell.LogEvent EVENT_SUCCESS, strMessage
  660 + 'End If
  661 +End Sub
  662 +
  663 +' Event logging only works on Server 2003, 2000 and XP
  664 +Public Sub writeLog(ByVal strMessage)
  665 + Set objFSO = CreateObject("Scripting.FileSystemObject")
  666 + ForAppending = 8
  667 + Set objTextFile = objFSO.OpenTextFile (currDir & "\var\log\dmsctl.log", ForAppending, True)
  668 + objTextFile.WriteLine strMessage
  669 + objTextFile.Close
  670 +End Sub
  671 +
dmsctl_install.bat 0 → 100644
  1 +rem KnowledgeTree UAC Run installer as Administrator for Windows 7 and Vista
  2 +@echo off
  3 +call dmsctl.bat install
0 \ No newline at end of file 4 \ No newline at end of file
kthelp/ktcore/EN/welcome.html
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 </head> 4 </head>
5 <body> 5 <body>
6 <p class="descriptiveText"><b>#APP_NAME# is Document Management Made Simple.</b></p><br> 6 <p class="descriptiveText"><b>#APP_NAME# is Document Management Made Simple.</b></p><br>
7 -<a href="http://www.youtube.com/watch?v=adTzHbk3SLU" target="_blank"><img src="resources/graphics/video_dashlet.png" border="0" align="right" /></a> 7 +<a href="http://www.knowledgetree.com/video/gettingstarted" target="_blank"><img src="resources/graphics/video_dashlet.png" border="0" align="right" /></a>
8 <p class="descriptiveText">Easily and securely 8 <p class="descriptiveText">Easily and securely
9 manage your company's document creation, editing, versioning, and sharing - all from 9 manage your company's document creation, editing, versioning, and sharing - all from
10 a powerful Web interface and Microsoft&#0174 Office&#0174 and Windows&#0174 Explorer&#0174 tools.</p> 10 a powerful Web interface and Microsoft&#0174 Office&#0174 and Windows&#0174 Explorer&#0174 tools.</p>
kthelp/ktcore/EN/welcomeCommercial.html
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <body> 5 <body>
6 <p class="descriptiveText"><b>#APP_NAME# is Document Management Made Simple.</b></p> <br> 6 <p class="descriptiveText"><b>#APP_NAME# is Document Management Made Simple.</b></p> <br>
7 7
8 -<a href="http://www.youtube.com/watch?v=adTzHbk3SLU" target="_blank"><img src="resources/graphics/video_dashlet.png" border="0" align="right" /></a> 8 +<a href="http://www.knowledgetree.com/video/gettingstarted" target="_blank"><img src="resources/graphics/video_dashlet.png" border="0" align="right" /></a>
9 <p class="descriptiveText">Easily and securely manage your company's document creation, editing, versioning, and sharing - all from a powerful Web interface and Microsoft&#0174 Office and Windows&#0174 Explorer tools.</p> <br> 9 <p class="descriptiveText">Easily and securely manage your company's document creation, editing, versioning, and sharing - all from a powerful Web interface and Microsoft&#0174 Office and Windows&#0174 Explorer tools.</p> <br>
10 10
11 <p class="descriptiveText">A subscription to #APP_NAME# provides your organization with product updates, enhanced document management features, and commercial support. Please view your welcome mailer for information on accessing these services.</p> <br> 11 <p class="descriptiveText">A subscription to #APP_NAME# provides your organization with product updates, enhanced document management features, and commercial support. Please view your welcome mailer for information on accessing these services.</p> <br>
lib/plugins/plugin.inc.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -751,6 +751,11 @@ class KTPlugin { @@ -751,6 +751,11 @@ class KTPlugin {
751 )); 751 ));
752 752
753 } 753 }
  754 + }else{
  755 + // Update the plugin path, in case it has moved
  756 + $oEntity->updateFromArray(array(
  757 + 'path' => $this->stripKtDir($this->sFilename)
  758 + ));
754 } 759 }
755 /* ** Quick fix for optimisation. Reread must run plugin setup. ** */ 760 /* ** Quick fix for optimisation. Reread must run plugin setup. ** */
756 $this->setup(); 761 $this->setup();
lib/plugins/pluginutil.inc.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -598,10 +598,18 @@ class KTPluginUtil { @@ -598,10 +598,18 @@ class KTPluginUtil {
598 if (!KTUtil::isAbsolutePath($sPath)) { 598 if (!KTUtil::isAbsolutePath($sPath)) {
599 $sPath = sprintf("%s/%s", KT_DIR, $sPath); 599 $sPath = sprintf("%s/%s", KT_DIR, $sPath);
600 } 600 }
  601 + // Check that the file exists at the given path
  602 + // If it doesn't set it as unavailable and disabled
  603 + // else set it as available and enabled.
  604 + // We'll document this in case they've specifically disabled certain plugins
601 if (!file_exists($sPath)) { 605 if (!file_exists($sPath)) {
602 $oPluginEntity->setUnavailable(true); 606 $oPluginEntity->setUnavailable(true);
603 $oPluginEntity->setDisabled(true); 607 $oPluginEntity->setDisabled(true);
604 $res = $oPluginEntity->update(); 608 $res = $oPluginEntity->update();
  609 + }elseif ($oPluginEntity->getUnavailable()){
  610 + $oPluginEntity->setUnavailable(false);
  611 + $oPluginEntity->setDisabled(false);
  612 + $res = $oPluginEntity->update();
605 } 613 }
606 } 614 }
607 KTPluginEntity::clearAllCaches(); 615 KTPluginEntity::clearAllCaches();
lib/util/ktpclzip.inc.php
@@ -117,6 +117,10 @@ class KTPclZip { @@ -117,6 +117,10 @@ class KTPclZip {
117 */ 117 */
118 function createZipFile($sFolder) { 118 function createZipFile($sFolder) {
119 //Overriding $this->aPaths with specified 119 //Overriding $this->aPaths with specified
  120 + if (!is_dir($sFolder)) {
  121 + PEAR::raiseError( sprintf( _kt( "Couldn't create zip file, invalid folder was specified %s " ) , $sFolder ));
  122 + }
  123 +
120 if (!is_null($sFolder)) { 124 if (!is_null($sFolder)) {
121 $this->aPaths = $sFolder; 125 $this->aPaths = $sFolder;
122 } 126 }
@@ -139,20 +143,36 @@ class KTPclZip { @@ -139,20 +143,36 @@ class KTPclZip {
139 return $sExportCode; 143 return $sExportCode;
140 } 144 }
141 145
142 - /*  
143 - * Returns the part of the folder to be excluded from the zip content structure  
144 - * 146 +
  147 + /*
145 * @params: $sPath folder to start from. 148 * @params: $sPath folder to start from.
146 * @params: $ds directory separator 149 * @params: $ds directory separator
147 */ 150 */
148 - function getExcludePath($sPath, $ds = '/') { 151 + static function getExcludePath($sPath, $ds = '/') {
149 //Will grab the part of the full path to exclude from the zip contents 152 //Will grab the part of the full path to exclude from the zip contents
150 - if ($sPath[strlen($sPath)] == $ds) {  
151 - //Chopping the last ds to make the keepPath contain an actual folder name  
152 - $sPath = substr($sPath, 0, strlen($sPath) - 1); 153 +
  154 + /*
  155 + * For windows the pre drive letter needs to be removed for it to work with the pclzip class for version 2.5
  156 + */
  157 + // Now using pclzip 2.8.2 so no need to strip the drive letter.
  158 + /*
  159 + if (stristr(PHP_OS,'WIN')) {
  160 + $sPath = end(explode(':', $sPath));
153 } 161 }
154 - $keepPath = end(explode($ds, $sPath));  
155 - $excludePath = str_replace($keepPath, '', $sPath); 162 + */
  163 +
  164 + //Generating the exclude path : Flexible method (Can set $cutOff = count($aDir) - 1;) to include the parent folder.
  165 + /*
  166 + $aDir = explode($ds, $sPath);
  167 + $cutOff = count($aDir);
  168 + for ($i = 0; $i < $cutOff; $i++) {
  169 + //echo $aDir[$i] . "\n";
  170 + $excludePath .= $aDir[$i] . '/';
  171 + }
  172 + */
  173 +
  174 + $excludePath = str_replace('\\', '/', $sPath);
  175 +
156 return $excludePath; 176 return $excludePath;
157 } 177 }
158 178
lib/widgets/portlet.inc.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -153,13 +153,12 @@ class KTActionPortlet extends KTPortlet { @@ -153,13 +153,12 @@ class KTActionPortlet extends KTPortlet {
153 153
154 // Create button html 154 // Create button html
155 $button = "<div class='portlet_button'> 155 $button = "<div class='portlet_button'>
156 - <a href='$link'> 156 + <a href='{$link}'>
157 <div class='big_btn_left'></div> 157 <div class='big_btn_left'></div>
158 <div class='big_btn_middle'> 158 <div class='big_btn_middle'>
159 <div class='btn_text'>{$text}</div> 159 <div class='btn_text'>{$text}</div>
160 - <div class='{$class}'></div>  
161 </div> 160 </div>
162 - <div class='big_btn_right'></div> 161 + <div class='big_btn_right {$class}'></div>
163 </a> 162 </a>
164 </div>"; 163 </div>";
165 164
plugins/search2/reporting/IndexErrors.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -54,6 +54,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { @@ -54,6 +54,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher {
54 54
55 //Number of items on a page 55 //Number of items on a page
56 $itemsPerPage = 50; 56 $itemsPerPage = 50;
  57 + $pageNum = 1;
  58 +
  59 + if(isset($_REQUEST['itemsPerPage'])){
  60 + $itemsPerPage = $_REQUEST['itemsPerPage'];
  61 + }
57 62
58 //registerTypes registers the mime types and populates the needed tables. 63 //registerTypes registers the mime types and populates the needed tables.
59 $indexer = Indexer::get(); 64 $indexer = Indexer::get();
@@ -128,6 +133,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { @@ -128,6 +133,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher {
128 if(isset($_REQUEST['pageValue'])) 133 if(isset($_REQUEST['pageValue']))
129 { 134 {
130 $pageNum = (int)$_REQUEST['pageValue']; 135 $pageNum = (int)$_REQUEST['pageValue'];
  136 +
  137 + if($pageNum > $pages){
  138 + $pageNum = $pages;
  139 + }
  140 +
131 $start = (($pageNum-1)*$itemsPerPage)-1; 141 $start = (($pageNum-1)*$itemsPerPage)-1;
132 $limit = $start+$itemsPerPage; 142 $limit = $start+$itemsPerPage;
133 for($i = $start; $i <= $limit; $i++){ 143 for($i = $start; $i <= $limit; $i++){
@@ -145,13 +155,18 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { @@ -145,13 +155,18 @@ class IndexErrorsDispatcher extends KTAdminDispatcher {
145 } 155 }
146 } 156 }
147 157
  158 + $config = KTConfig::getSingleton();
  159 + $rootUrl = $config->get('KnowledgeTree/rootUrl');
  160 +
148 $oTemplate->setData(array( 161 $oTemplate->setData(array(
149 'context' => $this, 162 'context' => $this,
150 'pageList' => $aPages, 163 'pageList' => $aPages,
151 'pageCount' => $pages, 164 'pageCount' => $pages,
  165 + 'pageNum' => $pageNum,
152 'itemCount' => $items, 166 'itemCount' => $items,
153 'itemsPerPage' => $itemsPerPage, 167 'itemsPerPage' => $itemsPerPage,
154 - 'indexErrors' => $aIndexList 168 + 'indexErrors' => $aIndexList,
  169 + 'root_url' => $rootUrl
155 170
156 )); 171 ));
157 return $oTemplate; 172 return $oTemplate;
plugins/search2/reporting/PendingDocuments.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -51,6 +51,14 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher @@ -51,6 +51,14 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher
51 51
52 function do_main() { 52 function do_main() {
53 53
  54 + //Number of items on a page
  55 + $itemsPerPage = 50;
  56 + $pageNum = 1;
  57 +
  58 + if(isset($_REQUEST['itemsPerPage'])){
  59 + $itemsPerPage = $_REQUEST['itemsPerPage'];
  60 + }
  61 +
54 //registerTypes registers the mime types and populates the needed tables. 62 //registerTypes registers the mime types and populates the needed tables.
55 $indexer = Indexer::get(); 63 $indexer = Indexer::get();
56 $indexer->registerTypes(); 64 $indexer->registerTypes();
@@ -68,6 +76,51 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher @@ -68,6 +76,51 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher
68 $aPendingDocs[$key] = $doc; 76 $aPendingDocs[$key] = $doc;
69 } 77 }
70 78
  79 + $aPendingList = array();
  80 +
  81 + //creating page variables and loading the items for the current page
  82 + if(!empty($aPendingDocs)){
  83 + $items = count($aPendingDocs);
  84 +
  85 + if(fmod($items, $itemsPerPage) > 0){
  86 + $pages = floor($items/$itemsPerPage)+1;
  87 + }else{
  88 + $pages = ($items/$itemsPerPage);
  89 + }
  90 + for($i=1; $i<=$pages; $i++){
  91 + $aPages[] = $i;
  92 + }
  93 + if($items < $itemsPerPage){
  94 + $limit = $items-1;
  95 + }else{
  96 + $limit = $itemsPerPage-1;
  97 + }
  98 +
  99 + if(isset($_REQUEST['pageValue']))
  100 + {
  101 + $pageNum = (int)$_REQUEST['pageValue'];
  102 +
  103 + if($pageNum > $pages){
  104 + $pageNum = $pages;
  105 + }
  106 +
  107 + $start = (($pageNum-1)*$itemsPerPage)-1;
  108 + $limit = $start+$itemsPerPage;
  109 + for($i = $start; $i <= $limit; $i++){
  110 + if(isset($aPendingDocs[$i]))
  111 + {
  112 + $aPendingList[] = $aPendingDocs[$i];
  113 + }
  114 + }
  115 + }
  116 + else
  117 + {
  118 + for($i = 0; $i <= $limit; $i++){
  119 + $aPendingList[] = $aPendingDocs[$i];
  120 + }
  121 + }
  122 + }
  123 +
71 $oTemplating =& KTTemplating::getSingleton(); 124 $oTemplating =& KTTemplating::getSingleton();
72 $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments'); 125 $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments');
73 126
@@ -76,7 +129,12 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher @@ -76,7 +129,12 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher
76 129
77 $oTemplate->setData(array( 130 $oTemplate->setData(array(
78 'context' => $this, 131 'context' => $this,
79 - 'pending_docs' => $aPendingDocs, 132 + 'pageList' => $aPages,
  133 + 'pageCount' => $pages,
  134 + 'pageNum' => $pageNum,
  135 + 'itemCount' => $items,
  136 + 'itemsPerPage' => $itemsPerPage,
  137 + 'pending_docs' => $aPendingList,
80 'root_url' => $rootUrl 138 'root_url' => $rootUrl
81 )); 139 ));
82 return $oTemplate; 140 return $oTemplate;
plugins/thumbnails/thumbnails.php
@@ -147,10 +147,10 @@ class thumbnailGenerator extends BaseProcessor @@ -147,10 +147,10 @@ class thumbnailGenerator extends BaseProcessor
147 $mimeType = KTMime::getMimeTypeName($mimeTypeId); 147 $mimeType = KTMime::getMimeTypeName($mimeTypeId);
148 148
149 // Get the pdf source file - if the document is a pdf then use the document as the source 149 // Get the pdf source file - if the document is a pdf then use the document as the source
150 - if($mimeType == 'application/pdf'){ 150 + if($mimeType == 'application/pdf') {
151 $pdfDir = $default->documentRoot; 151 $pdfDir = $default->documentRoot;
152 $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->getStoragePath(); 152 $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->getStoragePath();
153 - }else{ 153 + } else {
154 $pdfDir = $default->pdfDirectory; 154 $pdfDir = $default->pdfDirectory;
155 $pdfFile = $pdfDir .DIRECTORY_SEPARATOR. $this->document->iId.'.pdf'; 155 $pdfFile = $pdfDir .DIRECTORY_SEPARATOR. $this->document->iId.'.pdf';
156 } 156 }
@@ -175,28 +175,23 @@ class thumbnailGenerator extends BaseProcessor @@ -175,28 +175,23 @@ class thumbnailGenerator extends BaseProcessor
175 $default->log->debug('Thumbnail Generator Plugin: PDF file does not exist, cannot generate a thumbnail'); 175 $default->log->debug('Thumbnail Generator Plugin: PDF file does not exist, cannot generate a thumbnail');
176 return false; 176 return false;
177 } 177 }
178 - // if a previous version of the thumbnail exists - delete it 178 +
  179 + // if a previous version of the thumbnail exists - delete it
179 if (file_exists($thumbnailfile)) { 180 if (file_exists($thumbnailfile)) {
180 @unlink($thumbnailfile); 181 @unlink($thumbnailfile);
181 } 182 }
182 // do generation 183 // do generation
183 - // if (extension_loaded('imagick')) {  
184 - $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert';  
185 - // windows path may contain spaces  
186 -  
187 - if (stristr(PHP_OS,'WIN')) {  
188 - $cmd = "\"{$pathConvert}\" -size 200x200 \"{$pdfFile}[0]\" -resize 200x200 \"$thumbnailfile\"";  
189 - }  
190 - else {  
191 - $cmd = "{$pathConvert} -size 200x200 {$pdfFile}[0] -resize 200x200 $thumbnailfile";  
192 - }  
193 - $result = KTUtil::pexec($cmd);  
194 - return true;  
195 - //}else{  
196 - //$default->log->debug('Thumbnail Generator Plugin: Imagemagick not installed, cannot generate a thumbnail');  
197 - // return false;  
198 - //}  
199 - 184 + $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert';
  185 + // windows path may contain spaces
  186 + if (stristr(PHP_OS,'WIN')) {
  187 + $cmd = "\"{$pathConvert}\" \"{$pdfFile}[0]\" -resize 200x200 \"$thumbnailfile\"";
  188 + }
  189 + else {
  190 + $cmd = "{$pathConvert} {$pdfFile}[0] -resize 200x200 $thumbnailfile";
  191 + }
  192 +
  193 + $result = KTUtil::pexec($cmd);
  194 + return true;
200 } 195 }
201 } 196 }
202 197
plugins/thumbnails/thumbnailsPlugin.php
@@ -49,6 +49,15 @@ class thumbnailsPlugin extends KTPlugin { @@ -49,6 +49,15 @@ class thumbnailsPlugin extends KTPlugin {
49 require_once(KT_LIB_DIR . '/templating/templating.inc.php'); 49 require_once(KT_LIB_DIR . '/templating/templating.inc.php');
50 $oTemplating =& KTTemplating::getSingleton(); 50 $oTemplating =& KTTemplating::getSingleton();
51 $oTemplating->addLocation('thumbnails', $plugin_dir.'templates', 'thumbnails.generator.processor.plugin'); 51 $oTemplating->addLocation('thumbnails', $plugin_dir.'templates', 'thumbnails.generator.processor.plugin');
  52 +
  53 + // check for existing config settings entry and only add if not already present
  54 + $sql = 'SELECT id FROM `config_settings` WHERE group_name = "externalBinary" AND item = "convertPath"';
  55 + $result = DBUtil::getOneResult($sql);
  56 + if(PEAR::isError($result) || empty($result)) {
  57 + DBUtil::runQuery('INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) '
  58 + . 'VALUES ("externalBinary", "convert", "The path to the ImageMagick \"convert\" binary", "convertPath", "default", "convert", '
  59 + . '"string", NULL, 1);');
  60 + }
52 } 61 }
53 } 62 }
54 63
resources/css/kt-framing.css
@@ -25,6 +25,7 @@ body @@ -25,6 +25,7 @@ body
25 { 25 {
26 /*margin-top: 15px;*/ 26 /*margin-top: 15px;*/
27 margin-left: 10px; 27 margin-left: 10px;
  28 + margin-right: 25px;
28 } 29 }
29 30
30 .copyright { 31 .copyright {
@@ -1218,20 +1219,6 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes @@ -1218,20 +1219,6 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes
1218 text-decoration: none; 1219 text-decoration: none;
1219 } 1220 }
1220 1221
1221 -.portlet_button a .arrow_download {  
1222 - background: transparent url(../../resources/graphics/download_arrow.gif) center right no-repeat;  
1223 - width: 20px;  
1224 - height: 47px;  
1225 - float: right;  
1226 -}  
1227 -  
1228 -.portlet_button a .arrow_upload {  
1229 - background: transparent url(../../resources/graphics/upload_arrow.gif) center right no-repeat;  
1230 - width: 20px;  
1231 - height: 47px;  
1232 - float: right;  
1233 -}  
1234 -  
1235 .portlet_button a .big_btn_left { 1222 .portlet_button a .big_btn_left {
1236 background: transparent url(../../resources/graphics/btn_left.gif) top left no-repeat; 1223 background: transparent url(../../resources/graphics/btn_left.gif) top left no-repeat;
1237 width: 10px; 1224 width: 10px;
@@ -1246,16 +1233,23 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes @@ -1246,16 +1233,23 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes
1246 text-align: center; 1233 text-align: center;
1247 vertical-align: middle; 1234 vertical-align: middle;
1248 align: center; 1235 align: center;
1249 - width: 89%; 1236 + width: 80%;
1250 } 1237 }
1251 1238
1252 .portlet_button a .big_btn_right { 1239 .portlet_button a .big_btn_right {
1253 - background: transparent url(../../resources/graphics/btn_right.gif) top right no-repeat;  
1254 float: left; 1240 float: left;
1255 - width: 10px; 1241 + width: 25px;
1256 height: 47px; 1242 height: 47px;
1257 } 1243 }
1258 1244
  1245 +.portlet_button a .arrow_upload{
  1246 + background: transparent url(../../resources/graphics/btn_right_up.gif) top right no-repeat;
  1247 +}
  1248 +
  1249 +.portlet_button a .arrow_download{
  1250 + background: transparent url(../../resources/graphics/btn_right_down.gif) top right no-repeat;
  1251 +}
  1252 +
1259 .portlet_button a:hover .big_btn_left { 1253 .portlet_button a:hover .big_btn_left {
1260 background: transparent url(../../resources/graphics/btn_left_ro.gif) top left no-repeat; 1254 background: transparent url(../../resources/graphics/btn_left_ro.gif) top left no-repeat;
1261 } 1255 }
@@ -1264,8 +1258,12 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes @@ -1264,8 +1258,12 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes
1264 background: transparent url(../../resources/graphics/btn_middle_ro.gif) repeat-x; 1258 background: transparent url(../../resources/graphics/btn_middle_ro.gif) repeat-x;
1265 } 1259 }
1266 1260
1267 -.portlet_button a:hover .big_btn_right {  
1268 - background: transparent url(../../resources/graphics/btn_right_ro.gif) top right no-repeat; 1261 +.portlet_button a:hover .arrow_upload {
  1262 + background: transparent url(../../resources/graphics/btn_right_ro_up.gif) top right no-repeat;
  1263 +}
  1264 +
  1265 +.portlet_button a:hover .arrow_download {
  1266 + background: transparent url(../../resources/graphics/btn_right_ro_down.gif) top right no-repeat;
1269 } 1267 }
1270 1268
1271 1269
@@ -1292,7 +1290,7 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes @@ -1292,7 +1290,7 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes
1292 width: 47%; 1290 width: 47%;
1293 margin-top: 0; 1291 margin-top: 0;
1294 margin-left: 0; 1292 margin-left: 0;
1295 - padding-right: 2em; 1293 + padding-right: 3em;
1296 float: left; 1294 float: left;
1297 padding-bottom: 2em; 1295 padding-bottom: 2em;
1298 height: 100%; 1296 height: 100%;
resources/graphics/btn_right_down.gif 0 → 100644

1.93 KB

resources/graphics/btn_right_ro_down.gif 0 → 100644

1.93 KB

resources/graphics/btn_right_ro_up.gif 0 → 100644

2.14 KB

resources/graphics/btn_right_up.gif 0 → 100644

2.14 KB

search2/documentProcessor/bin/documentProcessor.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * KnowledgeTree Community Edition 6 * KnowledgeTree Community Edition
7 * Document Management Made Simple 7 * Document Management Made Simple
8 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 8 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
9 - * 9 + *
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify it under 11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License version 3 as published by the 12 * the terms of the GNU General Public License version 3 as published by the
@@ -47,6 +47,7 @@ chdir(dirname(__FILE__)); @@ -47,6 +47,7 @@ chdir(dirname(__FILE__));
47 require_once('../documentProcessor.inc.php'); 47 require_once('../documentProcessor.inc.php');
48 48
49 $documentProcessor = DocumentProcessor::get(); 49 $documentProcessor = DocumentProcessor::get();
  50 +$documentProcessor->processIndexQueue();
50 $documentProcessor->processQueue(); 51 $documentProcessor->processQueue();
51 exit; 52 exit;
52 ?> 53 ?>
search2/documentProcessor/documentProcessor.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * KnowledgeTree Community Edition 6 * KnowledgeTree Community Edition
7 * Document Management Made Simple 7 * Document Management Made Simple
8 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 8 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
9 - * 9 + *
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify it under 11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License version 3 as published by the 12 * the terms of the GNU General Public License version 3 as published by the
@@ -105,6 +105,11 @@ class DocumentProcessor @@ -105,6 +105,11 @@ class DocumentProcessor
105 return $singleton; 105 return $singleton;
106 } 106 }
107 107
  108 + /**
  109 + * Load the processors that will get run on the documents, eg pdf generation
  110 + *
  111 + * @return array
  112 + */
108 private function loadProcessors() 113 private function loadProcessors()
109 { 114 {
110 // Get list of registered processors (plugins) 115 // Get list of registered processors (plugins)
@@ -116,7 +121,7 @@ class DocumentProcessor @@ -116,7 +121,7 @@ class DocumentProcessor
116 121
117 if(PEAR::isError($results)){ 122 if(PEAR::isError($results)){
118 global $default; 123 global $default;
119 - $default->log->debug('documentProcessor: error loading processors').' - '.$results->getMessage(); 124 + $default->log->error('documentProcessor: error loading processors').' - '.$results->getMessage();
120 return false; 125 return false;
121 } 126 }
122 127
@@ -139,34 +144,65 @@ class DocumentProcessor @@ -139,34 +144,65 @@ class DocumentProcessor
139 return $processors; 144 return $processors;
140 } 145 }
141 146
142 - public function processQueue() 147 + /**
  148 + * Fetch the documents in the indexing queue and start the indexer
  149 + *
  150 + */
  151 + public function processIndexQueue()
143 { 152 {
144 global $default; 153 global $default;
145 - $default->log->debug('documentProcessor: starting'); 154 +
  155 + if(!$default->enableIndexing){
  156 + $default->log->debug('documentProcessor: indexer disabled');
  157 + return ;
  158 + }
  159 +
  160 + $default->log->debug('documentProcessor: starting indexer');
146 161
147 // Check for lock file to ensure processor is not currently running 162 // Check for lock file to ensure processor is not currently running
148 $cacheDir = $default->cacheDirectory; 163 $cacheDir = $default->cacheDirectory;
149 $lockFile = $cacheDir . DIRECTORY_SEPARATOR . 'document_processor.lock'; 164 $lockFile = $cacheDir . DIRECTORY_SEPARATOR . 'document_processor.lock';
150 165
151 if(file_exists($lockFile)){ 166 if(file_exists($lockFile)){
152 - // lock file exists, exit  
153 - $default->log->debug('documentProcessor: stopping, lock file in place '.$lockFile);  
154 - return ; 167 + // If something causes the document processor to stop part way through processing, the lock
  168 + // file will remain stopping the document processor from resuming. To workaround this problem
  169 + // we check the creation date of the lockfile and remove it if it is older than 24 hours or
  170 + // 48 hours if the batch size is greater than 1000 documents.
  171 + $stat = stat($lockFile);
  172 + $created = $stat['mtime'];
  173 +
  174 + $gap = 24;
  175 + if($this->limit > 1000){
  176 + $gap = 48;
  177 + $default->log->warn('documentProcessor: batch size of documents to index is set to '.$this->limit.', this could cause problems.');
  178 + }
  179 + $check = time() - ($gap*60*60);
  180 +
  181 + if($check > $created){
  182 + $default->log->error('documentProcessor: lock file is older than '.$gap.' hours, deleting it to restart indexing - '.$lockFile);
  183 + @unlink($lockFile);
  184 + }else{
  185 + // lock file exists, exit
  186 + // through a warning if the lock file is older than half an hour
  187 + $small_gap = time() - (30*60);
  188 + if($small_gap > $created){
  189 + $default->log->warn('documentProcessor: stopping, lock file in place since '. date('Y-m-d H:i:s', $created) .' - '.$lockFile);
  190 + }
  191 + return ;
  192 + }
155 } 193 }
156 194
157 - if($default->enableIndexing){  
158 - // Setup indexing - load extractors, run diagnostics  
159 - if($this->indexer->preIndexingSetup() === false){  
160 - $default->log->debug('documentProcessor: stopping - indexer setup failed.');  
161 - return;  
162 - } 195 + // Setup indexing - load extractors, run diagnostics
  196 + if($this->indexer->preIndexingSetup() === false){
  197 + $default->log->error('documentProcessor: stopping - indexer setup failed.');
  198 + return;
163 } 199 }
164 200
165 // Get document queue 201 // Get document queue
166 $queue = $this->indexer->getDocumentsQueue($this->limit); 202 $queue = $this->indexer->getDocumentsQueue($this->limit);
167 203
168 if(empty($queue)){ 204 if(empty($queue)){
169 - $default->log->debug('documentProcessor: stopping - no documents in processing queue'); 205 + $default->log->debug('documentProcessor: stopping - no documents in indexing queue');
170 return ; 206 return ;
171 } 207 }
172 208
@@ -177,7 +213,8 @@ class DocumentProcessor @@ -177,7 +213,8 @@ class DocumentProcessor
177 foreach($queue as $item){ 213 foreach($queue as $item){
178 214
179 // Get the document object 215 // Get the document object
180 - $document = Document::get($item['document_id']); 216 + $docId = $item['document_id'];
  217 + $document = Document::get($docId);
181 218
182 if (PEAR::isError($document)) 219 if (PEAR::isError($document))
183 { 220 {
@@ -186,9 +223,59 @@ class DocumentProcessor @@ -186,9 +223,59 @@ class DocumentProcessor
186 } 223 }
187 224
188 // index document 225 // index document
189 - if($default->enableIndexing){  
190 - $this->indexer->processDocument($document, $item);  
191 - } 226 + $this->indexer->processDocument($document, $item);
  227 + }
  228 +
  229 + // update the indexer statistics
  230 + $this->indexer->updateIndexStats();
  231 +
  232 + // Remove lock file to indicate processing has completed
  233 + if(file_exists($lockFile)){
  234 + @unlink($lockFile);
  235 + }
  236 +
  237 + $default->log->debug('documentProcessor: stopping indexer, batch completed');
  238 + }
  239 +
  240 + /**
  241 + * Fetch the process queue for running the processors on
  242 + *
  243 + */
  244 + public function processQueue()
  245 + {
  246 + global $default;
  247 + $default->log->debug('documentProcessor: starting processing');
  248 +
  249 + if($this->processors === false){
  250 + $default->log->info('documentProcessor: stopping - no processors enabled');
  251 + return ;
  252 + }
  253 +
  254 + // Get processing queue
  255 + // Use the same batch size as the indexer (for now)
  256 + // If the batch size is huge then reset it to a smaller number
  257 + // Open office leaks memory, so we don't want to do too many documents at once
  258 + $batch = ($this->limit > 500) ? 500 : $this->limit;
  259 +
  260 + $queue = $this->indexer->getDocumentProcessingQueue($batch);
  261 +
  262 + if(empty($queue)){
  263 + $default->log->debug('documentProcessor: stopping - no documents in processing queue');
  264 + return ;
  265 + }
  266 +
  267 + // Process queue
  268 + foreach($queue as $item){
  269 +
  270 + // Get the document object
  271 + $docId = $item['document_id'];
  272 + $document = Document::get($docId);
  273 +
  274 + if (PEAR::isError($document))
  275 + {
  276 + Indexer::unqueueDocFromProcessing($docId, "Cannot resolve document id: {$document->getMessage()}", 'error');
  277 + continue;
  278 + }
192 279
193 // loop through processors 280 // loop through processors
194 if($this->processors !== false){ 281 if($this->processors !== false){
@@ -205,18 +292,11 @@ class DocumentProcessor @@ -205,18 +292,11 @@ class DocumentProcessor
205 $processor->setDocument($document); 292 $processor->setDocument($document);
206 $processor->processDocument(); 293 $processor->processDocument();
207 } 294 }
  295 + Indexer::unqueueDocFromProcessing($docId, "Document processed", 'debug');
208 } 296 }
209 } 297 }
210 298
211 - // update the indexer statistics  
212 - $this->indexer->updateIndexStats();  
213 -  
214 - // Remove lock file to indicate processing has completed  
215 - if(file_exists($lockFile)){  
216 - @unlink($lockFile);  
217 - }  
218 -  
219 - $default->log->debug('documentProcessor: stopping'); 299 + $default->log->debug('documentProcessor: stopping processing, batch completed');
220 } 300 }
221 301
222 /** 302 /**
search2/indexing/extractors/OpenOfficeTextExtractor.inc.php
1 <?php 1 <?php
2 -  
3 -require_once(KT_DIR.'/thirdparty/peclzip/pclzip.lib.php');  
4 -  
5 /** 2 /**
6 * $Id:$ 3 * $Id:$
7 * 4 *
8 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
9 * Document Management Made Simple 6 * Document Management Made Simple
10 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
11 - * 8 + *
12 * 9 *
13 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -39,6 +36,8 @@ require_once(KT_DIR.&#39;/thirdparty/peclzip/pclzip.lib.php&#39;); @@ -39,6 +36,8 @@ require_once(KT_DIR.&#39;/thirdparty/peclzip/pclzip.lib.php&#39;);
39 * 36 *
40 */ 37 */
41 38
  39 +require_once(KT_DIR.'/thirdparty/peclzip/pclzip.lib.php');
  40 +
42 class OpenOfficeTextExtractor extends ExternalDocumentExtractor 41 class OpenOfficeTextExtractor extends ExternalDocumentExtractor
43 { 42 {
44 public function __construct() 43 public function __construct()
@@ -138,6 +137,7 @@ class OpenOfficeTextExtractor extends ExternalDocumentExtractor @@ -138,6 +137,7 @@ class OpenOfficeTextExtractor extends ExternalDocumentExtractor
138 */ 137 */
139 public function diagnose() 138 public function diagnose()
140 { 139 {
  140 + return null;
141 if (false === $this->unzip) 141 if (false === $this->unzip)
142 { 142 {
143 return sprintf(_kt("Cannot locate unzip: %s."), $this->unzip); 143 return sprintf(_kt("Cannot locate unzip: %s."), $this->unzip);
search2/indexing/extractors/OpenXmlTextExtractor.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * KnowledgeTree Community Edition 6 * KnowledgeTree Community Edition
7 * Document Management Made Simple 7 * Document Management Made Simple
8 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 8 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
9 - * 9 + *
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify it under 11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License version 3 as published by the 12 * the terms of the GNU General Public License version 3 as published by the
@@ -37,6 +37,8 @@ @@ -37,6 +37,8 @@
37 * 37 *
38 */ 38 */
39 39
  40 +require_once(KT_DIR.'/thirdparty/peclzip/pclzip.lib.php');
  41 +
40 class OpenXmlTextExtractor extends ExternalDocumentExtractor 42 class OpenXmlTextExtractor extends ExternalDocumentExtractor
41 { 43 {
42 public function __construct() 44 public function __construct()
@@ -217,6 +219,9 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor @@ -217,6 +219,9 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor
217 } 219 }
218 $filename = str_replace('\\','/',$filename); 220 $filename = str_replace('\\','/',$filename);
219 221
  222 + /*
  223 + // Removing the unzip command as the whole document gets unzipped at the start
  224 +
220 $cmd = '"' .$this->unzip . '"' . ' ' . str_replace( 225 $cmd = '"' .$this->unzip . '"' . ' ' . str_replace(
221 array('{source}','{part}', '{target_dir}'), 226 array('{source}','{part}', '{target_dir}'),
222 array($this->sourcefile, $filename,$this->openxml_dir), $this->unzip_params); 227 array($this->sourcefile, $filename,$this->openxml_dir), $this->unzip_params);
@@ -226,6 +231,7 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor @@ -226,6 +231,7 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor
226 $this->output = _kt('Failed to execute command: ') . $cmd; 231 $this->output = _kt('Failed to execute command: ') . $cmd;
227 return false; 232 return false;
228 } 233 }
  234 + */
229 235
230 $filename = $this->openxml_dir . "/$filename"; 236 $filename = $this->openxml_dir . "/$filename";
231 if (!file_exists($filename)) 237 if (!file_exists($filename))
@@ -321,6 +327,7 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor @@ -321,6 +327,7 @@ class OpenXmlTextExtractor extends ExternalDocumentExtractor
321 */ 327 */
322 public function diagnose() 328 public function diagnose()
323 { 329 {
  330 + return null;
324 if (false === $this->unzip) 331 if (false === $this->unzip)
325 { 332 {
326 return sprintf(_kt("Cannot locate unzip: %s."), $this->unzip); 333 return sprintf(_kt("Cannot locate unzip: %s."), $this->unzip);
search2/indexing/indexerCore.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * KnowledgeTree Community Edition 6 * KnowledgeTree Community Edition
7 * Document Management Made Simple 7 * Document Management Made Simple
8 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 8 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
9 - * 9 + *
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify it under 11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License version 3 as published by the 12 * the terms of the GNU General Public License version 3 as published by the
@@ -643,6 +643,16 @@ abstract class Indexer @@ -643,6 +643,16 @@ abstract class Indexer
643 643
644 $default->log->debug("index: Queuing indexing of $document_id"); 644 $default->log->debug("index: Queuing indexing of $document_id");
645 645
  646 + // Appending the process queue to the index for convenience
  647 + // Don't want to complicate matters by creating too many new classes and files
  648 + Indexer::unqueueDocFromProcessing($document_id);
  649 +
  650 + // enqueue item
  651 + $date = date('Y-m-d H:i:s');
  652 + $sql = "INSERT INTO process_queue(document_id, date_added) VALUES($document_id, '$date')";
  653 + DBUtil::runQuery($sql);
  654 +
  655 + $default->log->debug("Processing queue: Queuing document for processing - $document_id");
646 } 656 }
647 657
648 private static function incrementCount() 658 private static function incrementCount()
@@ -722,8 +732,37 @@ abstract class Indexer @@ -722,8 +732,37 @@ abstract class Indexer
722 DBUtil::runQuery($sql); 732 DBUtil::runQuery($sql);
723 733
724 $default->log->debug("Indexer::clearoutDeleted: removed documents from indexing queue that have been deleted"); 734 $default->log->debug("Indexer::clearoutDeleted: removed documents from indexing queue that have been deleted");
  735 +
  736 + // Multiple indexing processes cannot occur at the same time - the lock file prevents this.
  737 + // However if the indexing is interrupted the documents can get stuck in the queue with the processdate set
  738 + // but never having been indexed. To prevent this we will clear the processdate on all documents without errors.
  739 + $sql = 'UPDATE index_files SET processdate = null where processdate is not null and status_msg is null';
  740 + $res = DBUtil::runQuery($sql);
  741 +
  742 + if(PEAR::isError($res)){
  743 + $default->log->error("Indexer::clearoutDeleted: something happened ".$res->getMessage);
  744 + }
  745 +
  746 + $default->log->debug("Indexer::clearoutDeleted: resetting processdate for documents that may be stuck");
725 } 747 }
726 748
  749 + /**
  750 + * Clearout the processing of documents that no longer exist.
  751 + *
  752 + */
  753 + public static function clearoutDeletedFromProcessor()
  754 + {
  755 + global $default;
  756 +
  757 + $sql = 'DELETE FROM
  758 + process_queue
  759 + WHERE
  760 + document_id in (SELECT d.id FROM documents AS d WHERE d.status_id=3) OR
  761 + NOT EXISTS(SELECT process_queue.document_id FROM documents WHERE process_queue.document_id=documents.id)';
  762 + $result = DBUtil::runQuery($sql);
  763 +
  764 + $default->log->debug("Process queue: removed documents from processing queue that have been deleted");
  765 + }
727 766
728 /** 767 /**
729 * Check if a document is scheduled to be indexed 768 * Check if a document is scheduled to be indexed
@@ -1191,7 +1230,7 @@ abstract class Indexer @@ -1191,7 +1230,7 @@ abstract class Indexer
1191 } 1230 }
1192 1231
1193 /** 1232 /**
1194 - * Get the queue of documents for processing 1233 + * Get the queue of documents for indexing
1195 * Refactored from indexDocuments() 1234 * Refactored from indexDocuments()
1196 */ 1235 */
1197 public function getDocumentsQueue($max = null) 1236 public function getDocumentsQueue($max = null)
@@ -1222,7 +1261,7 @@ abstract class Indexer @@ -1222,7 +1261,7 @@ abstract class Indexer
1222 if (PEAR::isError($result)) 1261 if (PEAR::isError($result))
1223 { 1262 {
1224 //unlink($indexLockFile); 1263 //unlink($indexLockFile);
1225 - if ($this->debug) $default->log->debug('indexDocuments: stopping - db error'); 1264 + if ($this->debug) $default->log->error('indexDocuments: stopping - db error');
1226 return; 1265 return;
1227 } 1266 }
1228 KTUtil::setSystemSetting('luceneIndexingDate', time()); 1267 KTUtil::setSystemSetting('luceneIndexingDate', time());
@@ -1253,6 +1292,51 @@ abstract class Indexer @@ -1253,6 +1292,51 @@ abstract class Indexer
1253 } 1292 }
1254 1293
1255 /** 1294 /**
  1295 + * Get the queue of documents for processing
  1296 + *
  1297 + */
  1298 + public function getDocumentProcessingQueue($max = null)
  1299 + {
  1300 + global $default;
  1301 + $max = (empty($max)) ? 20 : $max;
  1302 +
  1303 + // Cleanup the queue
  1304 + Indexer::clearoutDeletedFromProcessor();
  1305 +
  1306 + $date = date('Y-m-d H:i:s');
  1307 + // identify the indexers that must run
  1308 + // mysql specific limit!
  1309 + $sql = "SELECT
  1310 + pq.document_id, mt.filetypes, mt.mimetypes
  1311 + FROM
  1312 + process_queue pq
  1313 + INNER JOIN documents d ON pq.document_id=d.id
  1314 + INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id
  1315 + INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id
  1316 + INNER JOIN mime_types mt ON dcv.mime_id=mt.id
  1317 + WHERE
  1318 + (pq.date_processed IS NULL or pq.date_processed < date_sub('$date', interval 1 day)) AND dmv.status_id=1
  1319 + ORDER BY date_added
  1320 + LIMIT $max";
  1321 +
  1322 + $result = DBUtil::getResultArray($sql);
  1323 + if (PEAR::isError($result))
  1324 + {
  1325 + $default->log->error('Processing queue: stopping - db error: '.$result->getMessage());
  1326 + return;
  1327 + }
  1328 +
  1329 + // bail if no work to do
  1330 + if (count($result) == 0)
  1331 + {
  1332 + $default->log->debug('Processing queue: stopping - no work to be done');
  1333 + return;
  1334 + }
  1335 +
  1336 + return $result;
  1337 + }
  1338 +
  1339 + /**
1256 * Process a document - extract text and index it 1340 * Process a document - extract text and index it
1257 * Refactored from indexDocuments() 1341 * Refactored from indexDocuments()
1258 * 1342 *
@@ -1813,7 +1897,7 @@ abstract class Indexer @@ -1813,7 +1897,7 @@ abstract class Indexer
1813 } 1897 }
1814 1898
1815 /** 1899 /**
1816 - * Remove the document from the queue. This is normally called when it has been processed. 1900 + * Remove the document from the indexing queue. This is normally called when it has been processed.
1817 * 1901 *
1818 * @param int $docid 1902 * @param int $docid
1819 */ 1903 */
@@ -1829,6 +1913,23 @@ abstract class Indexer @@ -1829,6 +1913,23 @@ abstract class Indexer
1829 } 1913 }
1830 1914
1831 /** 1915 /**
  1916 + * Remove the document from the processing queue. This is normally called when it has been processed.
  1917 + *
  1918 + * @param int $docid
  1919 + */
  1920 + public static function unqueueDocFromProcessing($docid, $reason=false, $level='debug')
  1921 + {
  1922 + $sql = "DELETE FROM process_queue WHERE document_id=$docid";
  1923 + $result = DBUtil::runQuery($sql);
  1924 +
  1925 + if ($reason !== false)
  1926 + {
  1927 + global $default;
  1928 + $default->log->$level("Processor queue: removing document $docid from the queue - $reason");
  1929 + }
  1930 + }
  1931 +
  1932 + /**
1832 * Run a query on the index. 1933 * Run a query on the index.
1833 * 1934 *
1834 * @param string $query 1935 * @param string $query
setup/migrate/config/commercial_config.xml
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <migrate version="3.7" type="Commercial Edition"> 10 <migrate version="3.7" type="Commercial Edition">
11 <steps> 11 <steps>
12 <step name="Current Installation">installation</step> 12 <step name="Current Installation">installation</step>
13 - <step name="Database Migration">database</step> 13 + <step name="Database Export">database</step>
14 <step name="Deactivate Services">services</step> 14 <step name="Deactivate Services">services</step>
15 <step name="Complete">complete</step> 15 <step name="Complete">complete</step>
16 </steps> 16 </steps>
setup/migrate/config/community_config.xml
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <migrate version="3.7" type="Community Edition"> 10 <migrate version="3.7" type="Community Edition">
11 <steps> 11 <steps>
12 <step name="Current Installation">installation</step> 12 <step name="Current Installation">installation</step>
13 - <step name="Database Migration">database</step> 13 + <step name="Database Export">database</step>
14 <step name="Deactivate Services">services</step> 14 <step name="Deactivate Services">services</step>
15 <step name="Complete">complete</step> 15 <step name="Complete">complete</step>
16 </steps> 16 </steps>
setup/migrate/migrater.php
@@ -540,6 +540,9 @@ class Migrater { @@ -540,6 +540,9 @@ class Migrater {
540 $this->_landing(); 540 $this->_landing();
541 } elseif ($res == 'landing') { 541 } elseif ($res == 'landing') {
542 $this->_landing(); 542 $this->_landing();
  543 + } elseif ($res == 'binstall') {
  544 + $util = new MigrateUtil();
  545 + $util->redirect('../wizard/index.php?step_name=dependencies');
543 } else { 546 } else {
544 } 547 }
545 break; 548 break;
@@ -550,10 +553,10 @@ class Migrater { @@ -550,10 +553,10 @@ class Migrater {
550 $util = new MigrateUtil(); 553 $util = new MigrateUtil();
551 $util->redirect('../wizard/index.php?step_name=installtype'); 554 $util->redirect('../wizard/index.php?step_name=installtype');
552 break; 555 break;
553 - case 'binstall':  
554 - $util = new MigrateUtil();  
555 - $util->redirect('../wizard/index.php?step_name=dependencies');  
556 - break; 556 +// case 'binstall':
  557 +// $util = new MigrateUtil();
  558 +// $util->redirect('../wizard/index.php?step_name=dependencies');
  559 +// break;
557 default: 560 default:
558 // TODO : handle silent 561 // TODO : handle silent
559 $this->_landing(); 562 $this->_landing();
setup/migrate/steps/migrateComplete.php
1 <?php 1 <?php
2 /** 2 /**
3 -* Complete Step Controller. 3 +* Migrate Complete Step Controller.
4 * 4 *
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
@@ -42,30 +42,57 @@ @@ -42,30 +42,57 @@
42 42
43 class migrateComplete extends Step { 43 class migrateComplete extends Step {
44 /** 44 /**
45 - * List of services to check 45 + * Flag if step needs to run silently
46 * 46 *
47 - * @access private  
48 - * @var array 47 + * @access protected
  48 + * @var boolean
49 */ 49 */
50 - private $services_check = 'tick';  
51 - private $paths_check = 'tick';  
52 - private $privileges_check = 'tick';  
53 - private $database_check = 'tick';  
54 - protected $conf = array();  
55 protected $silent = true; 50 protected $silent = true;
56 - 51 +
  52 + /**
  53 + * Name of BitRock Stack MySql
  54 + *
  55 + * @access protected
  56 + * @var string
  57 + */
  58 + protected $mysqlServiceName = "KTMysql";
  59 +
  60 + /**
  61 + * Name of BitRock Stack MySql
  62 + *
  63 + * @access protected
  64 + * @var string
  65 + */
  66 + protected $zendMysql = "MySQL_ZendServer51";
  67 +
  68 + /**
  69 + * Returns step state
  70 + *
  71 + * @author KnowledgeTree Team
  72 + * @param none
  73 + * @access public
  74 + * @return string
  75 + */
57 function doStep() { 76 function doStep() {
58 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); 77 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent);
59 - $this->doRun();  
60 - return 'landing'; 78 + return $this->doRun();
61 } 79 }
62 80
63 function doRun() { 81 function doRun() {
64 - $this->checkServices();  
65 - $this->checkSqlDump();  
66 - $this->checkPaths(); 82 + $this->checkSqlDump();
  83 + if(!$this->inStep("complete")) {
  84 +
  85 + return 'landing';
  86 + }
  87 + if($this->next()) {
  88 + if($this->checkZendMysql()) {
  89 + return 'binstall';
  90 + } else {
  91 + return 'error';
  92 + }
  93 + }
67 $this->removeInstallSessions(); 94 $this->removeInstallSessions();
68 - $this->storeSilent();// Set silent mode variables 95 + return 'landing';
69 } 96 }
70 97
71 private function removeInstallSessions() { 98 private function removeInstallSessions() {
@@ -77,26 +104,13 @@ class migrateComplete extends Step { @@ -77,26 +104,13 @@ class migrateComplete extends Step {
77 } 104 }
78 } 105 }
79 106
80 - private function checkPaths() {  
81 - $installation = $this->getDataFromSession("installation"); // Get installation directory  
82 - foreach ($installation['urlPaths'] as $path) {  
83 - if(is_writable($path['path']) && is_readable($path['path'])) {  
84 - $this->temp_variables['paths'][$path['name']]['class'] = "tick";  
85 - } else {  
86 - $this->temp_variables['paths'][$path['name']]['class'] = "cross_orange";  
87 - }  
88 - $this->temp_variables['paths'][$path['name']]['name'] = $path['name'];  
89 - $this->temp_variables['paths'][$path['name']]['msg'] = $path['path'];  
90 - }  
91 - }  
92 -  
93 private function checkSqlDump() { 107 private function checkSqlDump() {
94 $database = $this->getDataFromSession("database"); // Get installation directory 108 $database = $this->getDataFromSession("database"); // Get installation directory
95 $sqlFile = $database['dumpLocation']; 109 $sqlFile = $database['dumpLocation'];
96 if(file_exists($sqlFile)) { 110 if(file_exists($sqlFile)) {
97 $this->temp_variables['sql']['class'] = "tick"; 111 $this->temp_variables['sql']['class'] = "tick";
98 - $this->temp_variables['sql']['name'] = "dms.sql";  
99 - $this->temp_variables['sql']['msg'] = "Data file created"; 112 + $this->temp_variables['sql']['name'] = "";//dms.sql
  113 + $this->temp_variables['sql']['msg'] = $sqlFile;
100 return true; 114 return true;
101 } else { 115 } else {
102 $this->temp_variables['sql']['class'] = "cross"; 116 $this->temp_variables['sql']['class'] = "cross";
@@ -106,41 +120,75 @@ class migrateComplete extends Step { @@ -106,41 +120,75 @@ class migrateComplete extends Step {
106 } 120 }
107 } 121 }
108 122
109 - private function checkServices()  
110 - {  
111 - $services = $this->util->loadInstallServices(); // Use installer services class  
112 - $this->conf = $this->getDataFromSession("installation"); // Get installation directory  
113 - foreach ($services as $serviceName) {  
114 - $className = OS.$serviceName;  
115 - $serv = $this->util->loadInstallService($className);  
116 - $serv->load();  
117 - $sStatus = $serv->status();  
118 - if($sStatus == 'STARTED') {  
119 - $state = 'cross';  
120 - $this->error[] = "Service : {$serv->getName()} could not be uninstalled.<br/>";  
121 - $this->services_check = 'cross';  
122 - //$stopmsg = OS.'GetStopMsg';  
123 - $this->temp_variables['services'][$serv->getName()]['msg'] = "Service Running"; //$serv->getStopMsg($this->conf['location']);  
124 - } else {  
125 - $state = 'tick';  
126 - $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled";  
127 - }  
128 - $this->temp_variables['services'][$serv->getName()]['class'] = $state;  
129 - $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName(); 123 + /**
  124 + * Check if services are uninstall
  125 + *
  126 + */
  127 + private function checkMysql() {
  128 + $running = false;
  129 + if(WINDOWS_OS) {
  130 + $cmd = "sc query {$this->mysqlServiceName}";
  131 + $response = $this->util->pexec($cmd);
  132 + if($response['out']) {
  133 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  134 + }
  135 + if($state == "STARTED")
  136 + $running = true;
  137 + } else {
  138 + $installation = $this->getDataFromSession("installation"); // Get installation directory
  139 + $mysqlPid = $installation['location'].DS."mysql".DS."data".DS."mysqld.pid";
  140 + if(file_exists($mysqlPid))
  141 + $running = true;
130 } 142 }
131 - if ($this->services_check != 'tick') { 143 + if($running) {
  144 + $this->temp_variables['ktmysql']['class'] = "cross";
  145 + $this->temp_variables['ktmysql']['name'] = "KTMysql";
  146 + $this->temp_variables['ktmysql']['msg'] = "Service Running";
  147 + $this->error[] = "Service : KTMysql running.<br/>";
132 return false; 148 return false;
  149 + } else {
  150 + $this->temp_variables['ktmysql']['class'] = "tick";
  151 + $this->temp_variables['ktmysql']['name'] = "KTMysql";
  152 + $this->temp_variables['ktmysql']['msg'] = "Service has been uninstalled";
  153 + return true;
133 } 154 }
134 -  
135 - return true;  
136 } 155 }
137 156
138 - /**  
139 - * Set all silent mode varibles  
140 - *  
141 - */  
142 - private function storeSilent() {  
143 - $this->temp_variables['servicesCheck'] = $this->services_check; 157 + private function checkZendMysql() {
  158 + $running = false;
  159 + if(WINDOWS_OS) {
  160 + $cmd = "sc query {$this->zendMysql}";
  161 + $response = $this->util->pexec($cmd);
  162 + if($response['out']) {
  163 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  164 + }
  165 + if($state == "STARTED" || $state == "RUNNING")
  166 + $running = true;
  167 + } else {
  168 + //TODO : Read fomr my.cnf file
  169 + $mysqlPid = "/var/run/mysqld/mysqld.sock";
  170 + if(file_exists($mysqlPid))
  171 + $running = true;
  172 + $mysqlPid = "/var/run/mysqld/mysqld.pid";
  173 + if(file_exists($mysqlPid))
  174 + $running = true;
  175 + }
  176 + if($running) {
  177 + $this->temp_variables['zmysql']['class'] = "tick";
  178 + $this->temp_variables['zmysql']['name'] = "KTMysql";
  179 + $this->temp_variables['zmysql']['msg'] = "Service Running";
  180 + return true;
  181 + } else {
  182 + $this->temp_variables['zmysql']['class'] = "cross";
  183 + $this->temp_variables['zmysql']['name'] = "Mysql";
  184 + $this->temp_variables['zmysql']['msg'] = "Service not running";
  185 + $this->error[] = "Service : KTMysql running.<br/>";
  186 + return false;
  187 + }
  188 + }
  189 +
  190 + public function getErrors() {
  191 + return $this->error;
144 } 192 }
145 } 193 }
146 ?> 194 ?>
147 \ No newline at end of file 195 \ No newline at end of file
setup/migrate/steps/migrateDatabase.php
1 <?php 1 <?php
2 /** 2 /**
3 -* Database Step Controller. 3 +* Migrate Database Step Controller.
4 * 4 *
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
@@ -152,6 +152,8 @@ class migrateDatabase extends Step @@ -152,6 +152,8 @@ class migrateDatabase extends Step
152 if(!empty($fileContents)) { 152 if(!empty($fileContents)) {
153 $this->sqlDumpFile = realpath($sqlFile); // Store location of dump 153 $this->sqlDumpFile = realpath($sqlFile); // Store location of dump
154 return true; 154 return true;
  155 + } else {
  156 + unlink($sqlFile);
155 } 157 }
156 } 158 }
157 $noFile = true; 159 $noFile = true;
@@ -168,9 +170,9 @@ class migrateDatabase extends Step @@ -168,9 +170,9 @@ class migrateDatabase extends Step
168 } 170 }
169 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile; 171 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
170 if($noFile) { 172 if($noFile) {
171 - $this->error[]['error'] = "Could not connect to the KnowledgeTree Database";  
172 - $this->error[]['msg'] = "Make sure all KnowledgeTree Services are running.";  
173 - $this->error[]['cmd'] = "<p class=\"description\">Click <b>Next</b> after resolving the above errors.</p>"; 173 + $this->error[]['error'] = "The KnowledgeTree Setup Wizard was unable to connect to your KnowledgeTree 3.6.1 database.";
  174 + $this->error[]['msg'] = "Please ensure that all KnowledgeTree Services are running.";
  175 + $this->error[]['cmd'] = "Click <b>Next</b> after resolving the above errors.";
174 $this->temp_variables['manual_export'] = ""; 176 $this->temp_variables['manual_export'] = "";
175 } else { 177 } else {
176 $this->error[]['error'] = "Could not export database:"; 178 $this->error[]['error'] = "Could not export database:";
setup/migrate/steps/migrateInstallation.php
@@ -128,7 +128,7 @@ class migrateInstallation extends step @@ -128,7 +128,7 @@ class migrateInstallation extends step
128 128
129 public function detectInstallation() { 129 public function detectInstallation() {
130 if(WINDOWS_OS) { 130 if(WINDOWS_OS) {
131 - $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files x86\ktdms"=>"C:\Program Files x86\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path"); 131 + $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files (x86)\ktdms"=>"C:\Program Files (x86)\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path");
132 foreach ($knownWindowsLocations as $loc=>$configPath) { 132 foreach ($knownWindowsLocations as $loc=>$configPath) {
133 if(file_exists($configPath)) 133 if(file_exists($configPath))
134 $this->location = $loc; 134 $this->location = $loc;
@@ -160,7 +160,7 @@ class migrateInstallation extends step @@ -160,7 +160,7 @@ class migrateInstallation extends step
160 public function checkVersion() { 160 public function checkVersion() {
161 if($this->foundVersion < $this->supportedVersion) { 161 if($this->foundVersion < $this->supportedVersion) {
162 $this->versionError = true; 162 $this->versionError = true;
163 - $this->error[] = "KT installation needs to be 3.6.1 or higher"; 163 + $this->error[] = "KnowledgeTree installation needs to be 3.6.1 or higher";
164 return false; 164 return false;
165 } 165 }
166 166
@@ -173,7 +173,7 @@ class migrateInstallation extends step @@ -173,7 +173,7 @@ class migrateInstallation extends step
173 $foundVersion = file_get_contents($verFile); 173 $foundVersion = file_get_contents($verFile);
174 return $foundVersion; 174 return $foundVersion;
175 } else { 175 } else {
176 - $this->error[] = "KT installation version not found"; 176 + $this->error[] = "KnowledgeTree installation version not found";
177 } 177 }
178 178
179 return false; 179 return false;
@@ -214,10 +214,10 @@ class migrateInstallation extends step @@ -214,10 +214,10 @@ class migrateInstallation extends step
214 214
215 return true; 215 return true;
216 } 216 }
217 - $this->error[] = "KT installation configuration file empty"; 217 + $this->error[] = "KnowledgeTree installation configuration file empty";
218 } 218 }
219 } else { 219 } else {
220 - $this->error[] = "KT installation configuration file not found"; 220 + $this->error[] = "KnowledgeTree installation configuration file not found";
221 } 221 }
222 } else { 222 } else {
223 $this->error[] = "Please Enter a Location"; 223 $this->error[] = "Please Enter a Location";
@@ -241,16 +241,10 @@ class migrateInstallation extends step @@ -241,16 +241,10 @@ class migrateInstallation extends step
241 if ($froot == 'default') { 241 if ($froot == 'default') {
242 $froot = $this->location; 242 $froot = $this->location;
243 } 243 }
244 - $this->ktSettings = array('fileSystemRoot'=> $froot,  
245 - ); 244 + $this->ktSettings = array('fileSystemRoot'=> $froot);
246 $varDir = $froot.DS.'var'; 245 $varDir = $froot.DS.'var';
247 - $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir),  
248 - array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'),  
249 - array('name'=> 'Document Root', 'path'=> $varDir.DS.'Documents'),  
250 - array('name'=> 'UI Directory', 'path'=> $froot.DS.'presentation'.DS.'lookAndFeel'.DS.'knowledgeTree'),  
251 - array('name'=> 'Temporary Directory', 'path'=> $varDir.DS.'tmp'),  
252 - array('name'=> 'Cache Directory', 'path'=> $varDir.DS.'cache'),  
253 - array('name'=> 'Upload Directory', 'path'=> $varDir.DS.'uploads'), 246 + $this->urlPaths = array(
  247 + array('name'=> 'Document Root', 'path'=> $froot.DS.'Documents'),
254 ); 248 );
255 $this->dbSettings['dbPort'] = $this->util->getPort($this->location); // Add Port 249 $this->dbSettings['dbPort'] = $this->util->getPort($this->location); // Add Port
256 $this->temp_variables['urlPaths'] = $this->urlPaths; 250 $this->temp_variables['urlPaths'] = $this->urlPaths;
setup/migrate/steps/migrateServices.php
@@ -116,6 +116,7 @@ class migrateServices extends Step @@ -116,6 +116,7 @@ class migrateServices extends Step
116 116
117 protected $conf = array(); 117 protected $conf = array();
118 118
  119 + protected $mysqlServiceName = "KTMysql";
119 /** 120 /**
120 * Main control of services setup 121 * Main control of services setup
121 * 122 *
@@ -155,10 +156,12 @@ class migrateServices extends Step @@ -155,10 +156,12 @@ class migrateServices extends Step
155 * @return boolean 156 * @return boolean
156 */ 157 */
157 private function doRun() { 158 private function doRun() {
  159 + $installation = $this->getDataFromSession("installation"); // Get installation directory
  160 + $this->conf = $installation['location'];
158 if(!$this->alreadyUninstalled()) { // Pre-check if services are uninstalled 161 if(!$this->alreadyUninstalled()) { // Pre-check if services are uninstalled
159 $this->uninstallServices(); 162 $this->uninstallServices();
160 } 163 }
161 - $this->uninstallServices(); 164 + //$this->uninstallServices();
162 return $this->checkServices(); 165 return $this->checkServices();
163 } 166 }
164 167
@@ -186,12 +189,23 @@ class migrateServices extends Step @@ -186,12 +189,23 @@ class migrateServices extends Step
186 } 189 }
187 190
188 private function mysqlRunning() { 191 private function mysqlRunning() {
189 - $installation = $this->getDataFromSession("installation"); // Get installation directory  
190 - $mysqlPid = $installation['location'].DS."mysql".DS."data".DS."mysqld.pid";  
191 - if(file_exists($mysqlPid)) {  
192 - return true; 192 + $running = false;
  193 + if(WINDOWS_OS) {
  194 + $cmd = "sc query {$this->mysqlServiceName}";
  195 + $response = $this->util->pexec($cmd);
  196 + if($response['out']) {
  197 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  198 + }
  199 + if($state == "STARTED" || $state == 'RUNNING') {
  200 + $running = true;
  201 + }
  202 + } else {
  203 + $installation = $this->getDataFromSession("installation"); // Get installation directory
  204 + $mysqlPid = $installation['location'].DS."mysql".DS."data".DS."mysqld.pid";
  205 + if(file_exists($mysqlPid))
  206 + $running = true;
193 } 207 }
194 - return false; 208 + return $running;
195 } 209 }
196 210
197 /** 211 /**
@@ -199,11 +213,10 @@ class migrateServices extends Step @@ -199,11 +213,10 @@ class migrateServices extends Step
199 * 213 *
200 */ 214 */
201 private function uninstallServices() { 215 private function uninstallServices() {
202 - $this->conf = $this->getDataFromSession("installation"); // Get installation directory  
203 - if($this->conf['location'] != '') {  
204 - $func = OS."Stop";// Try the dmsctl  
205 - $this->$func();  
206 - } 216 + $func = OS."Stop";
  217 + //echo "$func";
  218 + $this->$func();
  219 +
207 $this->shutdown(); 220 $this->shutdown();
208 } 221 }
209 222
@@ -225,12 +238,18 @@ class migrateServices extends Step @@ -225,12 +238,18 @@ class migrateServices extends Step
225 * 238 *
226 */ 239 */
227 private function windowsStop() { 240 private function windowsStop() {
  241 + $cmd = "sc stop KTScheduler";
  242 + $response = $this->util->pexec($cmd);
  243 + $cmd = "sc stop KTLucene";
  244 + $response = $this->util->pexec($cmd);
  245 + $cmd = "sc stop KTOpenoffice";
  246 + $response = $this->util->pexec($cmd);
  247 + $cmd = "sc delete KTOpenoffice";
  248 + $response = $this->util->pexec($cmd);
228 $cmd = "sc delete KTLucene"; 249 $cmd = "sc delete KTLucene";
229 - $this->util->pexec($cmd); 250 + $response = $this->util->pexec($cmd);
230 $cmd = "sc delete KTScheduler"; 251 $cmd = "sc delete KTScheduler";
231 - $this->util->pexec($cmd);  
232 - $cmd = "sc delete KTOpenoffice";  
233 - $this->util->pexec($cmd); 252 + $response = $this->util->pexec($cmd);
234 } 253 }
235 254
236 /** 255 /**
@@ -247,10 +266,17 @@ class migrateServices extends Step @@ -247,10 +266,17 @@ class migrateServices extends Step
247 $serv->uninstall(); 266 $serv->uninstall();
248 } 267 }
249 } 268 }
  269 + $this->shutdownMysql();
  270 + }
  271 +
  272 + private function shutdownMysql() {
  273 + $cmd = "sc stop {$this->mysqlServiceName}";
  274 + $response = $this->util->pexec($cmd);
  275 +
250 } 276 }
251 277
252 /** 278 /**
253 - * Check if services are uninstall 279 + * Check if services are uninstall
254 * 280 *
255 */ 281 */
256 private function checkServices() { 282 private function checkServices() {
@@ -259,18 +285,22 @@ class migrateServices extends Step @@ -259,18 +285,22 @@ class migrateServices extends Step
259 $serv = $this->util->loadInstallService($className); 285 $serv = $this->util->loadInstallService($className);
260 $serv->load(); 286 $serv->load();
261 $sStatus = $serv->status(); 287 $sStatus = $serv->status();
262 - if($sStatus == 'STARTED') { 288 + if($sStatus == 'STARTED' || $sStatus == 'RUNNING') {
  289 + $state = 'cross';
  290 + $this->error[] = "Service : {$serv->getName()} could not be uninstalled.<br/>";
  291 + $this->serviceCheck = 'cross';
  292 + $this->temp_variables['services'][$serv->getName()]['msg'] = "Service Running";
  293 + } elseif ($sStatus == 'STOPPED') {
263 $state = 'cross'; 294 $state = 'cross';
264 $this->error[] = "Service : {$serv->getName()} could not be uninstalled.<br/>"; 295 $this->error[] = "Service : {$serv->getName()} could not be uninstalled.<br/>";
265 $this->serviceCheck = 'cross'; 296 $this->serviceCheck = 'cross';
266 - //$stopmsg = OS.'GetStopMsg';  
267 - $this->temp_variables['services'][$serv->getName()]['msg'] = "Service Running"; //$serv->getStopMsg($this->conf['location']); 297 + $this->temp_variables['services'][$serv->getName()]['msg'] = "Service Stopped, please uninstall service";
268 } else { 298 } else {
269 $state = 'tick'; 299 $state = 'tick';
270 $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled"; 300 $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled";
271 } 301 }
272 $this->temp_variables['services'][$serv->getName()]['class'] = $state; 302 $this->temp_variables['services'][$serv->getName()]['class'] = $state;
273 - $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName(); 303 + $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getHRName();
274 } 304 }
275 if(!$this->checkMysql()) { 305 if(!$this->checkMysql()) {
276 return false; 306 return false;
@@ -287,18 +317,40 @@ class migrateServices extends Step @@ -287,18 +317,40 @@ class migrateServices extends Step
287 * 317 *
288 */ 318 */
289 private function checkMysql() { 319 private function checkMysql() {
290 - $installation = $this->getDataFromSession("installation"); // Get installation directory  
291 - $mysqlPid = $installation['location'].DS."mysql".DS."data".DS."mysqld.pid";  
292 - if(file_exists($mysqlPid)) { 320 + $running = false;
  321 + if(WINDOWS_OS) {
  322 + $cmd = "sc query {$this->mysqlServiceName}";
  323 + $response = $this->util->pexec($cmd);
  324 + if($response['out']) {
  325 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  326 + }
  327 + if($state == "STARTED" || $state == "RUNNING") {
  328 + $running = true;
  329 + }
  330 + } else {
  331 + $installation = $this->getDataFromSession("installation"); // Get installation directory
  332 + $mysqlPid = $installation['location'].DS."mysql".DS."data".DS."mysqld.pid";
  333 + if(file_exists($mysqlPid))
  334 + $running = true;
  335 + }
  336 + if($running) {
293 $this->temp_variables['services']['KTMysql']['class'] = "cross"; 337 $this->temp_variables['services']['KTMysql']['class'] = "cross";
294 - $this->temp_variables['services']['KTMysql']['name'] = "KTMysql"; 338 + if(WINDOWS_OS) {
  339 + $this->temp_variables['services']['KTMysql']['name'] = "KnowledgeTree Mysql Service. (KTMysql)";
  340 + } else {
  341 + $this->temp_variables['services']['KTMysql']['name'] = "KnowledgeTree Mysql Service.";
  342 + }
295 $this->temp_variables['services']['KTMysql']['msg'] = "Service Running"; 343 $this->temp_variables['services']['KTMysql']['msg'] = "Service Running";
296 $this->error[] = "Service : KTMysql running.<br/>"; 344 $this->error[] = "Service : KTMysql running.<br/>";
297 return false; 345 return false;
298 } else { 346 } else {
299 $this->temp_variables['services']['KTMysql']['class'] = "tick"; 347 $this->temp_variables['services']['KTMysql']['class'] = "tick";
300 - $this->temp_variables['services']['KTMysql']['name'] = "KTMysql";  
301 - $this->temp_variables['services']['KTMysql']['msg'] = "Service has been uninstalled"; 348 + if(WINDOWS_OS) {
  349 + $this->temp_variables['services']['KTMysql']['name'] = "KnowledgeTree Mysql Service. (KTMysql)";
  350 + } else {
  351 + $this->temp_variables['services']['KTMysql']['name'] = "KnowledgeTree Mysql Service.";
  352 + }
  353 + $this->temp_variables['services']['KTMysql']['msg'] = "Service has been stopped";
302 return true; 354 return true;
303 } 355 }
304 } 356 }
setup/migrate/templates/complete.tpl
1 <form action="index.php?step_name=<?php echo $step_name; ?>" method="post" id="<?php echo $step_name; ?>"> 1 <form action="index.php?step_name=<?php echo $step_name; ?>" method="post" id="<?php echo $step_name; ?>">
2 <p class="title">Migration Completed</p> 2 <p class="title">Migration Completed</p>
3 3
4 - <p class="description">This allows you to check that your KnowledgeTree configuration is set  
5 - up correctly. You can run this at any time after configuration to check  
6 - that things are still set up correctly.</p>  
7 -  
8 - <?php  
9 - if($errors || $warnings){  
10 - echo '<div>'  
11 - . '<a href="http://wiki.knowledgetree.com/Web_Based_Migrater#Post_Migrate" target="_blank">'  
12 - . 'Click Here for help on overcoming post migrate issues</a></div><br/>';  
13 - }  
14 - ?> 4 + <p class="description">Your database migration was successfully completed. Please check the section below for details of the migration and final instructions</p>
15 <div id="step_content_<?php echo $step_name; ?>" class="step"> 5 <div id="step_content_<?php echo $step_name; ?>" class="step">
  6 +
16 <!-- SQL --> 7 <!-- SQL -->
17 - <h3>Exported Database</h3>  
18 - <table>  
19 - <tr>  
20 - <td> <span class='<?php echo $sql['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> </td>  
21 - <td style="width:25%;"> <?php echo $sql['name']; ?> </td>  
22 - <td style="width:75%;"> <?php echo $sql['msg']; ?> </td>  
23 - <tr>  
24 - </table>  
25 -<!-- Services -->  
26 - <h3>Uninstalled Services</h3>  
27 - <table>  
28 - <?php  
29 - if(isset($step_vars['services'])) {  
30 - foreach ($step_vars['services'] as $ser){  
31 - ?>  
32 - <tr>  
33 - <td> <span class='<?php echo $ser['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> </td>  
34 - <td style="width:25%;"> <?php echo $ser['name']; ?> </td>  
35 - <td style="width:75%;"> <?php echo $ser['msg']; ?> </td>  
36 - <?php if ($ser['class'] != 'tick') {  
37 - ?>  
38 -<!-- <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td>-->  
39 - <?php  
40 - } ?>  
41 - </tr>  
42 - <?php  
43 - }  
44 - }  
45 - ?>  
46 - </table>  
47 -<!-- Paths -->  
48 - <h3>System Path</h3>  
49 - <table>  
50 - <?php  
51 - if(isset($step_vars['paths'])) {  
52 - foreach ($step_vars['paths'] as $path){  
53 - ?>  
54 - <tr>  
55 - <td> <span class='<?php echo $path['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> </td>  
56 - <td style="width:25%;"> <?php echo $path['name']; ?> </td>  
57 - <td style="width:75%;"> <?php echo $path['msg']; ?> </td>  
58 - <?php if ($path['class'] != 'tick') {  
59 - ?>  
60 -<!-- <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td>-->  
61 - <?php  
62 - } ?>  
63 - </tr>  
64 - <?php  
65 - }  
66 - }  
67 - ?>  
68 - </table> 8 + <h3>KnowledgeTree database successfully exported to:</h3>
  9 + <span class='<?php echo $sql['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><?php echo $sql['msg']; ?>
  10 + <br /><br />
  11 + <h3>Start new MySQL service</h3>
  12 + In order to complete the upgrade process please start the Zend Server MySQL service and then click <b>Next</b> to continue (<a href="http://wiki.knowledgetree.com/Web_Based_Migrater#Complete" target="_blank">Click here for help</a>).
  13 + <br /><br />
  14 + <?php if(!empty($errors)) { ?>
  15 + <span class='<?php echo $zmysql['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  16 + <?php echo $zmysql['name']; ?>
  17 + <?php echo $zmysql['msg']; ?>
  18 + <?php } ?>
69 </div> 19 </div>
70 - <input class="button_next" type="submit" value="Continue Installation" name="BInstall"/> 20 +<!-- <input class="button_next" type="submit" value="Continue Installation" name="BInstall"/>-->
  21 + <input class="button_next" type="submit" value="Next" name="Next"/>
71 </form> 22 </form>
72 <?php if (AJAX) { echo $html->js('form.js'); } ?> 23 <?php if (AJAX) { echo $html->js('form.js'); } ?>
73 \ No newline at end of file 24 \ No newline at end of file
setup/migrate/templates/database.tpl
@@ -3,16 +3,10 @@ @@ -3,16 +3,10 @@
3 <div id="database" class="step1" style="display:block;"> 3 <div id="database" class="step1" style="display:block;">
4 <div class="description"> 4 <div class="description">
5 This step configures the connection to the database server and migrates the database. 5 This step configures the connection to the database server and migrates the database.
6 -<!-- The details for an administrative <br/>-->  
7 -<!-- user on the database server are required in order to be able to configure and migrate the database.-->  
8 </div> 6 </div>
9 <div id="step_content_<?php echo $step_name; ?>" class="step"> 7 <div id="step_content_<?php echo $step_name; ?>" class="step">
10 - <?php  
11 - //print_r($errors);  
12 - ?>  
13 <?php if(empty($errors)) { ?> 8 <?php if(empty($errors)) { ?>
14 -<p class="description">The Setup Wizard will now migrate your existing database to the new Zend Server stack. This process may take  
15 - several minutes to complete.</p><br /> 9 +<p class="description">The Setup Wizard will now export your existing database in preparation for the migration to the new KnowledgeTree Stack.</p><br />
16 <span class="error">Please ensure that your database is backed up before proceeding. If you need assistance with backing up see the &nbsp;<a class="description_click" target="_blank" href="http://wiki.knowledgetree.com/Backing_up_and_restoring_KnowledgeTree">'Backing up and restoring KnowledgeTree'</a>&nbsp; wiki entry. 10 <span class="error">Please ensure that your database is backed up before proceeding. If you need assistance with backing up see the &nbsp;<a class="description_click" target="_blank" href="http://wiki.knowledgetree.com/Backing_up_and_restoring_KnowledgeTree">'Backing up and restoring KnowledgeTree'</a>&nbsp; wiki entry.
17 </span> 11 </span>
18 <br /><br /> 12 <br /><br />
setup/migrate/templates/installation.tpl
1 <form action="index.php?step_name=<?php echo $step_name; ?>" method="post" id="<?php echo $step_name; ?>"> 1 <form action="index.php?step_name=<?php echo $step_name; ?>" method="post" id="<?php echo $step_name; ?>">
2 <p class="title">Current Installation</p> 2 <p class="title">Current Installation</p>
3 -<!--Continue Message-->  
4 - <?php  
5 - if(!$errors && !$warnings) {  
6 - ?>  
7 - <span class='big_ok'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>  
8 - KnowledgeTree installation has been detected. Please click <b>Next</b> to continue.  
9 - <br/><br/>  
10 - <?php  
11 - }  
12 - ?>  
13 <!--Warning and Error Messages--> 3 <!--Warning and Error Messages-->
14 <?php if($errors) { ?> 4 <?php if($errors) { ?>
15 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 5 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
@@ -26,19 +16,18 @@ @@ -26,19 +16,18 @@
26 <?php } ?> 16 <?php } ?>
27 <div id="step_content_<?php echo $step_name; ?>" class="step"> 17 <div id="step_content_<?php echo $step_name; ?>" class="step">
28 <p class="description"> 18 <p class="description">
29 - Enter the full path of the installation you wish to upgrade:  
30 - </p>  
31 - <p class="empty_space">  
32 - <small>The default is <b>'C:\Program Files\ktdms'</b> on Windows and <b>'/opt/ktdms'</b> or <b>'/home/<i>username</i>/ktdms/'</b> on other operating systems.</small> 19 + The Setup Wizard will now prepare your current KnowledgeTree database for migration to the new KnowledgeTree Stack.
  20 + </p>
  21 +
  22 + <p class="description">
  23 + Please enter the full path of the installation you wish to upgrade:
33 </p> 24 </p>
34 - <p class="empty_space">  
35 - <small>  
36 - Make sure that the KnowledgeTree services are running.  
37 - </small>  
38 - </p>  
39 - <br/> 25 +
40 <input id="location" name="location" type="text" style="width:430px; float:left" value="<?php if($location) echo $location; ?>"> 26 <input id="location" name="location" type="text" style="width:430px; float:left" value="<?php if($location) echo $location; ?>">
41 <br/><br/> 27 <br/><br/>
  28 + <p class="description">
  29 + <small>(The default is <b>'C:\Program Files\ktdms'</b> on Windows and <b>'/opt/ktdms'</b> or <b>'/home/<i>username</i>/ktdms/'</b> on other operating systems.)</small>
  30 + </p>
42 <?php 31 <?php
43 if($errors) { 32 if($errors) {
44 foreach ($errors as $error) { 33 foreach ($errors as $error) {
setup/migrate/templates/installation_confirm.tpl
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 </table> 68 </table>
69 69
70 </div> 70 </div>
71 - <input type="submit" name="Edit" value="Edit" class="button_previous"/> 71 + <input type="submit" name="Edit" value="Back" class="button_previous"/>
72 <input type="submit" name="Confirm" value="Confirm" class="button_next"/> 72 <input type="submit" name="Confirm" value="Confirm" class="button_next"/>
73 </form> 73 </form>
74 <?php if (AJAX) { echo $html->js('form.js'); } ?> 74 <?php if (AJAX) { echo $html->js('form.js'); } ?>
75 \ No newline at end of file 75 \ No newline at end of file
setup/migrate/templates/services.tpl
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <p class="title">Deactivate Services</p> 2 <p class="title">Deactivate Services</p>
3 3
4 <p class="description"> 4 <p class="description">
5 - All KnowledgeTree services need to be deactivated before the migration takes place. 5 + All KnowledgeTree services need to be shutdown before the migration can continue.
6 </p> 6 </p>
7 <!--Continue Message--> 7 <!--Continue Message-->
8 <?php 8 <?php
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 <?php } else { ?> 38 <?php } else { ?>
39 All services are uninstalled. 39 All services are uninstalled.
40 <?php } ?> 40 <?php } ?>
41 - <h3><?php echo "<span class='{$serviceCheck}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Services Check</h3> 41 + <h3><?php echo "<span class='{$serviceCheck}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Please shutdown the following services</h3>
42 <?php if($silent) { ?> 42 <?php if($silent) { ?>
43 <?php if($serviceCheck != 'tick') { 43 <?php if($serviceCheck != 'tick') {
44 $details = 'Hide Details'; 44 $details = 'Hide Details';
@@ -49,8 +49,7 @@ @@ -49,8 +49,7 @@
49 } 49 }
50 $display = 'block'; 50 $display = 'block';
51 ?> 51 ?>
52 -<!-- <div id="option6" class="onclick notop" onclick="javascript:{w.toggleClass('service_details', 'option6');}"><?php echo $details; ?></div>-->  
53 - <div class="service_details" style="display:<?php echo $display; ?>"> 52 + <div class="service_details" style="display:<?php echo $display; ?>">
54 <?php } ?> 53 <?php } ?>
55 <table> 54 <table>
56 <?php 55 <?php
@@ -60,8 +59,8 @@ @@ -60,8 +59,8 @@
60 ?> 59 ?>
61 <tr> 60 <tr>
62 <td> <span class='<?php echo $ser['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> </td> 61 <td> <span class='<?php echo $ser['class']; ?>'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> </td>
63 - <td style="width:20%;"> <?php echo $ser['name']; ?> </td>  
64 - <td style="width:75%;"> <?php echo $ser['msg']; ?> </td> 62 + <td style="width:50%;"> <?php echo $ser['name']; ?> </td>
  63 + <td style="width:50%;"> <?php echo $ser['msg']; ?> </td>
65 <?php if ($ser['class'] != 'tick') { 64 <?php if ($ser['class'] != 'tick') {
66 ?> 65 ?>
67 <!-- <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td>--> 66 <!-- <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td>-->
@@ -76,7 +75,7 @@ @@ -76,7 +75,7 @@
76 </table> 75 </table>
77 <?php if ($serviceCheck != 'tick') { ?> 76 <?php if ($serviceCheck != 'tick') { ?>
78 <br/> 77 <br/>
79 - <p class=\"description\">Click <b>Next</b> if deactivating the above services.</p> 78 + <p class=\"description\">Click <b>Next</b> if the above services are deactivated .</p>
80 <?php } ?> 79 <?php } ?>
81 <?php if($silent) { ?> 80 <?php if($silent) { ?>
82 </div> 81 </div>
setup/migrate/templates/wizard.tpl
@@ -11,6 +11,9 @@ @@ -11,6 +11,9 @@
11 <?php echo $html->css('wizard.css'); ?> 11 <?php echo $html->css('wizard.css'); ?>
12 <?php echo $html->css('migrate.css'); ?> 12 <?php echo $html->css('migrate.css'); ?>
13 <?php if(AGENT == "IE6") echo $html->css('ie6.css'); ?> 13 <?php if(AGENT == "IE6") echo $html->css('ie6.css'); ?>
  14 + <?php if(AGENT == "IE7") echo $html->css('ie7.css'); ?>
  15 + <?php if(AGENT == "IE8") echo $html->css('ie8.css'); ?>
  16 + <?php if(INSTALL_TYPE == "community") echo $html->css('community.css'); ?>
14 <meta http-equiv=Content-Type content="text/html; charset=utf-8"> 17 <meta http-equiv=Content-Type content="text/html; charset=utf-8">
15 </head> 18 </head>
16 <body onload=""> 19 <body onload="">
setup/upgrade/lib/UpgradeItems.inc.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -57,16 +57,16 @@ require_once(&quot;../wizard/dbUtilities.php&quot;); @@ -57,16 +57,16 @@ require_once(&quot;../wizard/dbUtilities.php&quot;);
57 57
58 // {{{ Upgrade_Already_Applied 58 // {{{ Upgrade_Already_Applied
59 class Upgrade_Already_Applied { 59 class Upgrade_Already_Applied {
60 - 60 +
61 function Upgrade_Already_Applied($oUpgradeItem) { 61 function Upgrade_Already_Applied($oUpgradeItem) {
62 $this->oUpgradeItem = $oUpgradeItem; 62 $this->oUpgradeItem = $oUpgradeItem;
63 } 63 }
64 - 64 +
65 } 65 }
66 // }}} 66 // }}}
67 67
68 class UpgradeItem { 68 class UpgradeItem {
69 - 69 +
70 public $type = ""; 70 public $type = "";
71 public $name; 71 public $name;
72 public $version; 72 public $version;
@@ -76,7 +76,8 @@ class UpgradeItem { @@ -76,7 +76,8 @@ class UpgradeItem {
76 public $parent; 76 public $parent;
77 public $date; 77 public $date;
78 public $result; 78 public $result;
79 - 79 + protected $error;
  80 +
80 function UpgradeItem($name, $version, $description = null, $phase = 0, $priority = 0) { 81 function UpgradeItem($name, $version, $description = null, $phase = 0, $priority = 0) {
81 $this->name = $name; 82 $this->name = $name;
82 $this->version = $version; 83 $this->version = $version;
@@ -86,7 +87,7 @@ class UpgradeItem { @@ -86,7 +87,7 @@ class UpgradeItem {
86 $this->description = $description; 87 $this->description = $description;
87 $this->phase = $phase; 88 $this->phase = $phase;
88 $this->priority = $priority; 89 $this->priority = $priority;
89 - 90 +
90 $this->dbUtilities = new dbUtilities(); 91 $this->dbUtilities = new dbUtilities();
91 $this->iniUtilities = new iniUtilities(); 92 $this->iniUtilities = new iniUtilities();
92 } 93 }
@@ -122,6 +123,14 @@ class UpgradeItem { @@ -122,6 +123,14 @@ class UpgradeItem {
122 return $this->type; 123 return $this->type;
123 } 124 }
124 125
  126 + public function getErrors()
  127 + {
  128 + if(isset($this->error[0])){
  129 + return $this->error[0];
  130 + }
  131 + return $this->error;
  132 + }
  133 +
125 /** 134 /**
126 * Runs a DB query and returns a result based on arguments which specify what to look for 135 * Runs a DB query and returns a result based on arguments which specify what to look for
127 * 136 *
@@ -135,13 +144,13 @@ class UpgradeItem { @@ -135,13 +144,13 @@ class UpgradeItem {
135 $this->dbUtilities = new dbUtilities(); 144 $this->dbUtilities = new dbUtilities();
136 $this->iniUtilities = new iniUtilities(); 145 $this->iniUtilities = new iniUtilities();
137 } 146 }
138 - 147 +
139 $wizConfigHandler = new configuration(); 148 $wizConfigHandler = new configuration();
140 $configPath = $wizConfigHandler->readConfigPathIni(); 149 $configPath = $wizConfigHandler->readConfigPathIni();
141 - 150 +
142 $this->iniUtilities->load($configPath); 151 $this->iniUtilities->load($configPath);
143 $dconf = $this->iniUtilities->getSection('db'); 152 $dconf = $this->iniUtilities->getSection('db');
144 - $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); 153 + $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbAdminUser'], $dconf['dbAdminPass'], $dconf['dbName']);
145 $result = $this->dbUtilities->query($query); 154 $result = $this->dbUtilities->query($query);
146 if($checkResult) { 155 if($checkResult) {
147 $assArr = $this->dbUtilities->fetchAssoc($result); 156 $assArr = $this->dbUtilities->fetchAssoc($result);
@@ -153,7 +162,7 @@ class UpgradeItem { @@ -153,7 +162,7 @@ class UpgradeItem {
153 } 162 }
154 return !is_null($result); 163 return !is_null($result);
155 } 164 }
156 - 165 +
157 function _upgradeTableInstalled() { 166 function _upgradeTableInstalled() {
158 $query = "SELECT COUNT(id) FROM upgrades"; 167 $query = "SELECT COUNT(id) FROM upgrades";
159 $res = $this->runDBQuery($query, true, true); 168 $res = $this->runDBQuery($query, true, true);
@@ -169,7 +178,7 @@ class UpgradeItem { @@ -169,7 +178,7 @@ class UpgradeItem {
169 } 178 }
170 $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1"; 179 $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1";
171 $res = $this->runDBQuery($query, true, false); 180 $res = $this->runDBQuery($query, true, false);
172 - 181 +
173 if(!$res) { 182 if(!$res) {
174 return true; 183 return true;
175 } 184 }
@@ -214,7 +223,7 @@ class UpgradeItem { @@ -214,7 +223,7 @@ class UpgradeItem {
214 } 223 }
215 $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES (NULL, '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')"; 224 $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES (NULL, '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')";
216 $this->dbUtilities->query($sql); 225 $this->dbUtilities->query($sql);
217 - 226 +
218 return true; 227 return true;
219 } 228 }
220 229
@@ -225,7 +234,7 @@ class UpgradeItem { @@ -225,7 +234,7 @@ class UpgradeItem {
225 } // end class UpgradeItem 234 } // end class UpgradeItem
226 235
227 class SQLUpgradeItem extends UpgradeItem { 236 class SQLUpgradeItem extends UpgradeItem {
228 - 237 +
229 function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) { 238 function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) {
230 $this->type = "sql"; 239 $this->type = "sql";
231 $this->priority = 0; 240 $this->priority = 0;
@@ -335,7 +344,7 @@ class SQLUpgradeItem extends UpgradeItem { @@ -335,7 +344,7 @@ class SQLUpgradeItem extends UpgradeItem {
335 $phase = 0; 344 $phase = 0;
336 return array($fromVersion, $toVersion, $description, $phase); 345 return array($fromVersion, $toVersion, $description, $phase);
337 } 346 }
338 - $matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*)\.sql$#', $path, $matches); 347 + $matched = preg_match('#^([\d\.-]*)/(?:(\d*)-)?(.*)\.sql$#', $path, $matches);
339 //$matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*):(?:(\d*))\.sql$#', $path, $matches); 348 //$matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*):(?:(\d*))\.sql$#', $path, $matches);
340 if ($matched != 0) { 349 if ($matched != 0) {
341 $fromVersion = $matches[1]; 350 $fromVersion = $matches[1];
@@ -366,11 +375,11 @@ class SQLUpgradeItem extends UpgradeItem { @@ -366,11 +375,11 @@ class SQLUpgradeItem extends UpgradeItem {
366 $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name); 375 $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name);
367 return $this->dbUtilities->runQueries($queries); 376 return $this->dbUtilities->runQueries($queries);
368 } 377 }
369 - 378 +
370 } // end class SQLUpgradeItem 379 } // end class SQLUpgradeItem
371 380
372 class KTRebuildPermissionObserver { 381 class KTRebuildPermissionObserver {
373 - 382 +
374 function start() { 383 function start() {
375 $this->lastBeat = time(); 384 $this->lastBeat = time();
376 } 385 }
@@ -384,11 +393,11 @@ class KTRebuildPermissionObserver { @@ -384,11 +393,11 @@ class KTRebuildPermissionObserver {
384 } 393 }
385 function end() { 394 function end() {
386 } 395 }
387 - 396 +
388 } 397 }
389 398
390 class RecordUpgradeItem extends UpgradeItem { 399 class RecordUpgradeItem extends UpgradeItem {
391 - 400 +
392 function RecordUpgradeItem ($version, $oldversion = null) { 401 function RecordUpgradeItem ($version, $oldversion = null) {
393 $this->type = "upgrade"; 402 $this->type = "upgrade";
394 if (is_null($oldversion)) { 403 if (is_null($oldversion)) {
@@ -426,7 +435,7 @@ class RecordUpgradeItem extends UpgradeItem { @@ -426,7 +435,7 @@ class RecordUpgradeItem extends UpgradeItem {
426 KTPermissionUtil::rebuildPermissionLookups(true); 435 KTPermissionUtil::rebuildPermissionLookups(true);
427 $po->end(); 436 $po->end();
428 */ 437 */
429 - 438 +
430 $versionFile=KT_DIR . '/docs/VERSION-NAME.txt'; 439 $versionFile=KT_DIR . '/docs/VERSION-NAME.txt';
431 $fp = fopen($versionFile,'rt'); 440 $fp = fopen($versionFile,'rt');
432 $systemVersion = fread($fp, filesize($versionFile)); 441 $systemVersion = fread($fp, filesize($versionFile));
@@ -495,7 +504,7 @@ class RecordUpgradeItem extends UpgradeItem { @@ -495,7 +504,7 @@ class RecordUpgradeItem extends UpgradeItem {
495 @unlink($sFile); 504 @unlink($sFile);
496 } 505 }
497 } 506 }
498 - 507 +
499 } // end class RecordUpgradeItem 508 } // end class RecordUpgradeItem
500 509
501 ?> 510 ?>
setup/upgrade/step.php
@@ -467,7 +467,7 @@ class Step @@ -467,7 +467,7 @@ class Step
467 $foundVersion = file_get_contents($verFile); 467 $foundVersion = file_get_contents($verFile);
468 return $foundVersion; 468 return $foundVersion;
469 } else { 469 } else {
470 - $this->error[] = "KT installation version not found"; 470 + $this->error[] = "KnowledgeTree installation version not found";
471 } 471 }
472 472
473 return false; 473 return false;
setup/upgrade/steps/upgradeComplete.php
@@ -49,8 +49,13 @@ class upgradeComplete extends Step { @@ -49,8 +49,13 @@ class upgradeComplete extends Step {
49 49
50 public function doStep() { 50 public function doStep() {
51 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); 51 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent);
  52 + $this->temp_variables['isCE'] = false;
  53 + $type = $this->util->getVersionType();
  54 + if($type == "community")
  55 + $this->temp_variables['isCE'] = true;
52 $this->doRun(); 56 $this->doRun();
53 $this->storeSilent(); 57 $this->storeSilent();
  58 + $this->util->deleteMigrateFile();
54 return 'landing'; 59 return 'landing';
55 } 60 }
56 61
@@ -86,7 +91,7 @@ class upgradeComplete extends Step { @@ -86,7 +91,7 @@ class upgradeComplete extends Step {
86 */ 91 */
87 protected function storeSilent() { 92 protected function storeSilent() {
88 $v = $this->getDataFromSession('upgradeProperties'); 93 $v = $this->getDataFromSession('upgradeProperties');
89 - $this->temp_variables['sysVersion'] = $v['upgrade_version']; 94 + $this->temp_variables['sysVersion'] = $this->util->readVersion();
90 $this->temp_variables['migrateCheck'] = $this->migrateCheck; 95 $this->temp_variables['migrateCheck'] = $this->migrateCheck;
91 $this->temp_variables['servicesCheck'] = $this->servicesCheck; 96 $this->temp_variables['servicesCheck'] = $this->servicesCheck;
92 } 97 }
setup/upgrade/steps/upgradeDatabase.php
1 <?php 1 <?php
2 /** 2 /**
3 -* Upgrade Step Controller. 3 +* Upgrade Step Controller.
4 * 4 *
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
@@ -44,7 +44,7 @@ define(&#39;KT_DIR&#39;, SYSTEM_DIR); @@ -44,7 +44,7 @@ define(&#39;KT_DIR&#39;, SYSTEM_DIR);
44 define('KT_LIB_DIR', SYSTEM_DIR.'lib'); 44 define('KT_LIB_DIR', SYSTEM_DIR.'lib');
45 require_once(WIZARD_LIB . 'upgrade.inc.php'); 45 require_once(WIZARD_LIB . 'upgrade.inc.php');
46 46
47 -class upgradeDatabase extends Step 47 +class upgradeDatabase extends Step
48 { 48 {
49 /** 49 /**
50 * Location of database binaries. 50 * Location of database binaries.
@@ -54,7 +54,7 @@ class upgradeDatabase extends Step @@ -54,7 +54,7 @@ class upgradeDatabase extends Step
54 * @var string 54 * @var string
55 */ 55 */
56 private $mysqlDir; // TODO:multiple databases 56 private $mysqlDir; // TODO:multiple databases
57 - 57 +
58 /** 58 /**
59 * Name of database binary. 59 * Name of database binary.
60 * 60 *
@@ -63,7 +63,7 @@ class upgradeDatabase extends Step @@ -63,7 +63,7 @@ class upgradeDatabase extends Step
63 * @var string 63 * @var string
64 */ 64 */
65 private $dbBinary = ''; // TODO:multiple databases 65 private $dbBinary = ''; // TODO:multiple databases
66 - 66 +
67 /** 67 /**
68 * List of errors used in template 68 * List of errors used in template
69 * 69 *
@@ -72,7 +72,7 @@ class upgradeDatabase extends Step @@ -72,7 +72,7 @@ class upgradeDatabase extends Step
72 * @var array 72 * @var array
73 */ 73 */
74 public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); 74 public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword');
75 - 75 +
76 /** 76 /**
77 * Flag to store class information in session 77 * Flag to store class information in session
78 * 78 *
@@ -81,12 +81,13 @@ class upgradeDatabase extends Step @@ -81,12 +81,13 @@ class upgradeDatabase extends Step
81 * @var array 81 * @var array
82 */ 82 */
83 public $storeInSession = true; 83 public $storeInSession = true;
84 - 84 +
85 public $sysVersion = ''; 85 public $sysVersion = '';
86 protected $silent = false; 86 protected $silent = false;
87 protected $temp_variables = array(); 87 protected $temp_variables = array();
88 public $paths = ''; 88 public $paths = '';
89 - 89 + public $migrateCheck = false;
  90 +
90 /** 91 /**
91 * Main control of database setup 92 * Main control of database setup
92 * 93 *
@@ -96,9 +97,10 @@ class upgradeDatabase extends Step @@ -96,9 +97,10 @@ class upgradeDatabase extends Step
96 * @return string 97 * @return string
97 */ 98 */
98 public function doStep() { 99 public function doStep() {
99 - $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent, 100 + $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent,
100 "loadingText"=>"The database upgrade is under way. Please wait until it completes"); 101 "loadingText"=>"The database upgrade is under way. Please wait until it completes");
101 $this->initErrors(); 102 $this->initErrors();
  103 + $this->checkMigration();
102 if(!$this->inStep("database")) { 104 if(!$this->inStep("database")) {
103 $this->doRun(); 105 $this->doRun();
104 return 'landing'; 106 return 'landing';
@@ -119,25 +121,31 @@ class upgradeDatabase extends Step @@ -119,25 +121,31 @@ class upgradeDatabase extends Step
119 } 121 }
120 return 'error'; 122 return 'error';
121 } 123 }
122 - 124 +
123 $this->doRun(); 125 $this->doRun();
124 return 'landing'; 126 return 'landing';
125 } 127 }
  128 +
  129 + public function checkMigration() {
  130 + if($this->util->isMigration()) {
  131 + $this->migrateCheck = true;
  132 + }
  133 + }
126 134
127 private function confirmUpgrade() { 135 private function confirmUpgrade() {
128 return isset($_POST['ConfirmUpgrade']); 136 return isset($_POST['ConfirmUpgrade']);
129 } 137 }
130 - 138 +
131 private function upgrading() { 139 private function upgrading() {
132 return isset($_POST['RunUpgrade']); 140 return isset($_POST['RunUpgrade']);
133 - }  
134 - 141 + }
  142 +
135 private function doRun($action = null) { 143 private function doRun($action = null) {
136 $this->readConfig(); 144 $this->readConfig();
137 - 145 +
138 $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']); 146 $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
139 $this->temp_variables['action'] = $action; 147 $this->temp_variables['action'] = $action;
140 - 148 +
141 if (is_null($action) || ($action == 'preview')) { 149 if (is_null($action) || ($action == 'preview')) {
142 $this->temp_variables['title'] = 'Preview Upgrade'; 150 $this->temp_variables['title'] = 'Preview Upgrade';
143 $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable(); 151 $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable();
@@ -154,10 +162,10 @@ class upgradeDatabase extends Step @@ -154,10 +162,10 @@ class upgradeDatabase extends Step
154 } 162 }
155 $this->temp_variables['backupSuccessful'] = true; 163 $this->temp_variables['backupSuccessful'] = true;
156 } 164 }
157 - 165 +
158 return true; 166 return true;
159 } 167 }
160 - 168 +
161 private function generateUpgradeTable() { 169 private function generateUpgradeTable() {
162 $this->sysVersion = $this->readVersion(); 170 $this->sysVersion = $this->readVersion();
163 $this->temp_variables['systemVersion'] = $this->sysVersion; 171 $this->temp_variables['systemVersion'] = $this->sysVersion;
@@ -194,10 +202,10 @@ class upgradeDatabase extends Step @@ -194,10 +202,10 @@ class upgradeDatabase extends Step
194 $foundVersion = file_get_contents($verFile); 202 $foundVersion = file_get_contents($verFile);
195 return $foundVersion; 203 return $foundVersion;
196 } else { 204 } else {
197 - $this->error[] = "KT installation version not found"; 205 + $this->error[] = "KnowledgeTree installation version not found";
198 } 206 }
199 207
200 - return false; 208 + return false;
201 } 209 }
202 210
203 /** 211 /**
@@ -213,14 +221,15 @@ class upgradeDatabase extends Step @@ -213,14 +221,15 @@ class upgradeDatabase extends Step
213 $this->error[$e] = false; 221 $this->error[$e] = false;
214 } 222 }
215 } 223 }
216 - 224 +
217 public function storeSilent() { 225 public function storeSilent() {
218 $this->temp_variables['paths'] = $this->paths; 226 $this->temp_variables['paths'] = $this->paths;
219 $this->temp_variables['sysVersion'] = $this->sysVersion; 227 $this->temp_variables['sysVersion'] = $this->sysVersion;
220 $this->temp_variables['sysVersion'] = $this->sysVersion; 228 $this->temp_variables['sysVersion'] = $this->sysVersion;
221 $this->temp_variables['dbSettings'] = $this->dbSettings; 229 $this->temp_variables['dbSettings'] = $this->dbSettings;
  230 + $this->temp_variables['migrateCheck'] = $this->migrateCheck;
222 } 231 }
223 - 232 +
224 private function upgradeConfirm() 233 private function upgradeConfirm()
225 { 234 {
226 if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) { 235 if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) {
@@ -234,12 +243,12 @@ class upgradeDatabase extends Step @@ -234,12 +243,12 @@ class upgradeDatabase extends Step
234 private function doDatabaseUpgrade() 243 private function doDatabaseUpgrade()
235 { 244 {
236 $errors = false; 245 $errors = false;
237 - 246 +
238 $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to 247 $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to
239 upgrade your KnowledgeTree installation to <strong>' . $this->sysVersion . '</strong>'; 248 upgrade your KnowledgeTree installation to <strong>' . $this->sysVersion . '</strong>';
240 - 249 +
241 $this->performPreUpgradeActions(); 250 $this->performPreUpgradeActions();
242 - 251 +
243 $res = $this->performAllUpgrades(); 252 $res = $this->performAllUpgrades();
244 if (!$res) { 253 if (!$res) {
245 $errors = true; 254 $errors = true;
@@ -247,7 +256,7 @@ class upgradeDatabase extends Step @@ -247,7 +256,7 @@ class upgradeDatabase extends Step
247 // TODO instantiate error details hideable section? 256 // TODO instantiate error details hideable section?
248 $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font> 257 $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font>
249 <br/><br/> 258 <br/><br/>
250 - Please restore from your backup and ensure that the database does not contain 259 + Please restore from your backup and ensure that the database does not contain
251 any unsupported modifications and try the upgrade process again. 260 any unsupported modifications and try the upgrade process again.
252 <br/><br/> 261 <br/><br/>
253 If the problem persists, contact KnowledgeTree Support.'; 262 If the problem persists, contact KnowledgeTree Support.';
@@ -255,27 +264,27 @@ class upgradeDatabase extends Step @@ -255,27 +264,27 @@ class upgradeDatabase extends Step
255 else { 264 else {
256 $this->temp_variables['upgradeStatus'] = '<font color="green">Upgrade succeeded.</font>'; 265 $this->temp_variables['upgradeStatus'] = '<font color="green">Upgrade succeeded.</font>';
257 } 266 }
258 - 267 +
259 $this->performPostUpgradeActions(); 268 $this->performPostUpgradeActions();
260 -  
261 - 269 +
  270 +
262 return !$errors; 271 return !$errors;
263 } 272 }
264 273
265 private function performPreUpgradeActions() { 274 private function performPreUpgradeActions() {
266 - 275 +
267 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. 276 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
268 // It should idealy work the same as the upgrades. 277 // It should idealy work the same as the upgrades.
269 // Lock the scheduler 278 // Lock the scheduler
270 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock'; 279 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
271 touch($lockFile); 280 touch($lockFile);
272 return true; 281 return true;
273 - 282 +
274 } 283 }
275 - 284 +
276 private function deleteDirectory($sPath) { 285 private function deleteDirectory($sPath) {
277 if (empty($sPath) || !is_dir($sPath)) return; 286 if (empty($sPath) || !is_dir($sPath)) return;
278 - 287 +
279 if (!WINDOWS_OS) { 288 if (!WINDOWS_OS) {
280 if (file_exists('/bin/rm')) { 289 if (file_exists('/bin/rm')) {
281 $this->util->pexec(array('/bin/rm', '-rf', $sPath)); 290 $this->util->pexec(array('/bin/rm', '-rf', $sPath));
@@ -303,28 +312,31 @@ class upgradeDatabase extends Step @@ -303,28 +312,31 @@ class upgradeDatabase extends Step
303 closedir($hPath); 312 closedir($hPath);
304 rmdir($sPath); 313 rmdir($sPath);
305 } 314 }
306 - 315 +
307 private function performPostUpgradeActions() { 316 private function performPostUpgradeActions() {
308 - 317 +
309 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. 318 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
310 // It should idealy work the same as the upgrades. 319 // It should idealy work the same as the upgrades.
311 - 320 +
312 // Ensure all plugins are re-registered. 321 // Ensure all plugins are re-registered.
313 $sql = "TRUNCATE plugin_helper"; 322 $sql = "TRUNCATE plugin_helper";
314 $this->util->dbUtilities->query($sql); 323 $this->util->dbUtilities->query($sql);
315 - 324 +
316 // Clear out all caches and proxies - they need to be regenerated with the new code 325 // Clear out all caches and proxies - they need to be regenerated with the new code
317 $this->deleteDirectory($this->proxyPath); 326 $this->deleteDirectory($this->proxyPath);
318 $this->deleteDirectory($this->cachePath); 327 $this->deleteDirectory($this->cachePath);
319 - 328 +
  329 + // Recreate the cache directory - it doesn't get regenerated
  330 + mkdir($this->cachePath, 0755);
  331 +
320 // Unlock the scheduler 332 // Unlock the scheduler
321 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock'; 333 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
322 if(file_exists($lockFile)){ 334 if(file_exists($lockFile)){
323 unlink($lockFile); 335 unlink($lockFile);
324 } 336 }
325 - 337 +
326 return true; 338 return true;
327 - 339 +
328 } 340 }
329 341
330 private function performAllUpgrades () { 342 private function performAllUpgrades () {
@@ -343,11 +355,12 @@ class upgradeDatabase extends Step @@ -343,11 +355,12 @@ class upgradeDatabase extends Step
343 } else { 355 } else {
344 $class = "even"; 356 $class = "even";
345 } 357 }
346 - $this->temp_variables['upgradeTable'] .= sprintf('<div class="row %s"><div class="foo">%s</div>' . "\n", $class, 358 + $this->temp_variables['upgradeTable'] .= sprintf('<div class="row %s"><div class="foo">%s</div>' . "\n", $class,
347 htmlspecialchars($upgrade->getDescription())); 359 htmlspecialchars($upgrade->getDescription()));
348 ++$row; 360 ++$row;
349 $res = $upgrade->performUpgrade(); 361 $res = $upgrade->performUpgrade();
350 - $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res)); 362 + $errors = $upgrade->getErrors();
  363 + $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res, $errors));
351 $this->temp_variables['upgradeTable'] .= '<br>' . "\n"; 364 $this->temp_variables['upgradeTable'] .= '<br>' . "\n";
352 $this->temp_variables['upgradeTable'] .= "</div>\n"; 365 $this->temp_variables['upgradeTable'] .= "</div>\n";
353 if ($res === false) { 366 if ($res === false) {
@@ -355,11 +368,11 @@ class upgradeDatabase extends Step @@ -355,11 +368,11 @@ class upgradeDatabase extends Step
355 break; 368 break;
356 } 369 }
357 } 370 }
358 - 371 +
359 return $res; 372 return $res;
360 } 373 }
361 -  
362 - private function showResult($res) { 374 +
  375 + private function showResult($res, $errors = null) {
363 if ($res && is_a($res, 'Upgrade_Already_Applied')) { 376 if ($res && is_a($res, 'Upgrade_Already_Applied')) {
364 return '<span style="color: orange">Already applied</span>'; 377 return '<span style="color: orange">Already applied</span>';
365 } 378 }
@@ -367,7 +380,15 @@ class upgradeDatabase extends Step @@ -367,7 +380,15 @@ class upgradeDatabase extends Step
367 return '<span style="color: green">Success</span>'; 380 return '<span style="color: green">Success</span>';
368 } 381 }
369 if ($res === false) { 382 if ($res === false) {
370 - return '<span style="color: red">Failure</span>'; 383 + $str = '<span style="color: red">Failure</span>';
  384 + if(is_array($errors)){
  385 + $str .= '<ul style="padding-left: 20px; color: red;">';
  386 + foreach ($errors as $error){
  387 + $str .= '<li style="padding: 5px 2px 0;">'.$error."</li>\n";
  388 + }
  389 + $str .= '</ul>';
  390 + }
  391 + return $str;
371 } 392 }
372 return $res; 393 return $res;
373 } 394 }
setup/upgrade/templates/complete.tpl
1 -<?php //global $default; ?>  
2 <form> 1 <form>
3 <p class="title">Database Upgrade Completed</p> 2 <p class="title">Database Upgrade Completed</p>
4 -  
5 <div id="step_content_complete" class="step"> 3 <div id="step_content_complete" class="step">
6 <!-- Services --> 4 <!-- Services -->
7 - <br/><br/>  
8 <div> 5 <div>
9 Your database has been upgraded to <?php echo $sysVersion; ?> 6 Your database has been upgraded to <?php echo $sysVersion; ?>
10 </div> 7 </div>
11 -<br/><br/> 8 + <br/>
  9 + <div>
  10 + <a href="http://wiki.knowledgetree.com/Web_Based_Installer#Post_Install" target="_blank">
  11 + Click Here for help on overcoming post install issues
  12 + </a>
  13 + </div>
12 <?php if($migrateCheck) { ?> 14 <?php if($migrateCheck) { ?>
13 - <h3>Services</h3>  
14 - The KnowledgeTree services need to be started to allow for optimal functioning of the search, indexing and pdf generation.  
15 - <?php if(!WINDOWS_OS) { ?>  
16 - To start the services, execute the dmsctl.sh shell script in the KnowledgeTree directory from a terminal. 15 + <br/>
  16 + <h3>Services</h3>
  17 + The KnowledgeTree services need to be started to allow for optimal functioning of the search, indexing and pdf generation.
  18 + <?php if(!WINDOWS_OS) { ?>
  19 + To start the services, execute the dmsctl.sh shell script in the KnowledgeTree directory from a terminal.
  20 + <br/>
  21 + <br/>
  22 + <?php } else { ?>
  23 + To start the services, execute the dmsctl.bat batch file in the KnowledgeTree directory from a command prompt, run as administrator.
  24 + <br/>
  25 + <br/>
  26 + <?php } ?>
  27 + <p class="disclaimer">
  28 + <?php if(WINDOWS_OS) { ?>
  29 + <b>Using shortcuts:</b>
17 <br/> 30 <br/>
  31 + [START MENU] => [Programs] => [KnowledgeTree 3.7.x] => [services]
18 <br/> 32 <br/>
19 - <?php } else { ?>  
20 - To start the services, execute the dmsctl.bat batch file in the KnowledgeTree directory from a command prompt, run as administrator. 33 + Click [Install Services]
21 <br/> 34 <br/>
  35 + [START MENU] => [Programs] => [KnowledgeTree 3.7.x] => [services]
22 <br/> 36 <br/>
23 - <?php } ?>  
24 - <p class="disclaimer">  
25 - <?php if(WINDOWS_OS) { ?>  
26 - cd <?php echo "\"".SYSTEM_ROOT."\""; ?> <br/>  
27 - dmsctl.bat install<br/>  
28 - dmsctl.bat start  
29 - <?php } else { ?> 37 + Click [Start Services]
  38 + <br/>
  39 + <br/>
  40 + <b>Alternatively:</b>
  41 + <br/>
  42 + Open a command prompt and enter the following:
  43 + <br/>
  44 + <br/>
  45 + cd <?php echo "\"".SYSTEM_DIR."\""; ?> <br/>
  46 + dmsctl.bat install<br/>
  47 + dmsctl.bat start
  48 + <?php } else { ?>
  49 + <?php if ($isCE) { ?>
30 cd /usr/share/knowledgetree-ce<br/> 50 cd /usr/share/knowledgetree-ce<br/>
31 - sudo ./dmsctl.sh start 51 + <?php } else { ?>
  52 + cd /usr/share/knowledgetree<br/>
32 <?php } ?> 53 <?php } ?>
33 - </p>  
34 - <br/> 54 + sudo ./dmsctl.sh start
35 <?php } ?> 55 <?php } ?>
  56 + </p>
  57 + <br/>
  58 + <?php } else { ?>
  59 + <br>
  60 + <?php } ?>
36 </div> 61 </div>
37 - <a href="../../login.php" class="back button_next" style="width:50px;" onclick="javascript:{w.clearSessions();}">Finish</a> 62 +<!-- <a href="../../login.php" class="back button_next" style="width:50px;" onclick="javascript:{w.clearSessions();}">Finish</a>-->
  63 + <input type="submit" name="Next" value="Finish" class="button_next"/>
38 </form> 64 </form>
39 \ No newline at end of file 65 \ No newline at end of file
setup/upgrade/templates/database.tpl
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 <?php } 21 <?php }
22 else if ($action == 'confirm') { 22 else if ($action == 'confirm') {
23 if ($backupStatus) { ?> 23 if ($backupStatus) { ?>
24 - <p>We are about to start the upgrade process.<P> 24 + <p>We are about to start the upgrade process. Are you sure you want to proceed with the upgrade process?<P>
25 <?php } 25 <?php }
26 else { ?> 26 else { ?>
27 <p><font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font><p> 27 <p><font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font><p>
@@ -29,17 +29,9 @@ @@ -29,17 +29,9 @@
29 <?php } 29 <?php }
30 else if ($action == 'runUpgrade') { 30 else if ($action == 'runUpgrade') {
31 // hiding pre-upgrade notification 31 // hiding pre-upgrade notification
32 - /*  
33 - echo $preUpgrade;  
34 - echo '<br/><br/>';  
35 - */  
36 echo $upgradeTable; 32 echo $upgradeTable;
37 echo '<br/><br/>'; 33 echo '<br/><br/>';
38 // hiding pre-upgrade notification 34 // hiding pre-upgrade notification
39 - /*  
40 - echo $postUpgrade;  
41 - echo '<br/><br/>';  
42 - */  
43 echo $upgradeStatus; 35 echo $upgradeStatus;
44 echo '<br/><br/>'; 36 echo '<br/><br/>';
45 } 37 }
@@ -58,9 +50,15 @@ @@ -58,9 +50,15 @@
58 <?php } 50 <?php }
59 else if ($action == 'runUpgrade') { ?> 51 else if ($action == 'runUpgrade') { ?>
60 <?php if ($backupSuccessful) { ?> 52 <?php if ($backupSuccessful) { ?>
  53 + <?php if($migrateCheck) { ?>
  54 + <script type="text/javascript">
  55 + alert("To complete the upgrade please do the following before continuing:\n\n1. Hard refresh your browser (CTRL-F5) on first view of the Dashboard.\n\n\nSelect 'Finish' at the bottom of this page to continue.");
  56 + </script>
  57 + <?php } else { ?>
61 <script type="text/javascript"> 58 <script type="text/javascript">
62 alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'Finish' at the bottom of this page to continue.") 59 alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'Finish' at the bottom of this page to continue.")
63 </script> 60 </script>
  61 + <?php } ?>
64 <input type="submit" name="Next" value="Finish" class="button_next"/> 62 <input type="submit" name="Next" value="Finish" class="button_next"/>
65 <?php } 63 <?php }
66 else { ?><input type="submit" name="Previous" value="Restore" class="button_previous"/><?php } ?> 64 else { ?><input type="submit" name="Previous" value="Restore" class="button_previous"/><?php } ?>
setup/upgrade/templates/installation.tpl
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 You will not be able to log into KnowledgeTree until your the database upgrade process is completed. 8 You will not be able to log into KnowledgeTree until your the database upgrade process is completed.
9 </p> 9 </p>
10 <p class="empty_space"> 10 <p class="empty_space">
11 - <font color="#ffa500">!!NB!! You are advised to backup the database before attempting the upgrade. !!NB!!</font> 11 + <font color="red">You are advised to backup the database before attempting the upgrade.</font>
12 </p> 12 </p>
13 <p class="empty_space"></p> 13 <p class="empty_space"></p>
14 If you have already done this, you may skip this step and can continue directly to the upgrade. 14 If you have already done this, you may skip this step and can continue directly to the upgrade.
setup/upgrade/templates/loading.tpl
1 <div id="loadingBar" style="display:none; text-align: center; padding: 4px;"> 1 <div id="loadingBar" style="display:none; text-align: center; padding: 4px;">
2 - <img src="/setup/wizard/resources/graphics/loading.gif"> 2 + <img src="../wizard/resources/graphics/loading.gif">
3 <br/> 3 <br/>
4 <?php echo $loadingText; ?> 4 <?php echo $loadingText; ?>
5 </div> 5 </div>
setup/upgrade/templates/wizard.tpl
@@ -11,6 +11,9 @@ @@ -11,6 +11,9 @@
11 <?php echo $html->css('wizard.css'); ?> 11 <?php echo $html->css('wizard.css'); ?>
12 <?php echo $html->css('migrate.css'); ?> 12 <?php echo $html->css('migrate.css'); ?>
13 <?php if(AGENT == "IE6") echo $html->css('ie6.css'); ?> 13 <?php if(AGENT == "IE6") echo $html->css('ie6.css'); ?>
  14 + <?php if(AGENT == "IE7") echo $html->css('ie7.css'); ?>
  15 + <?php if(AGENT == "IE8") echo $html->css('ie8.css'); ?>
  16 + <?php if(INSTALL_TYPE == "community") echo $html->css('community.css'); ?>
14 <meta http-equiv=Content-Type content="text/html; charset=utf-8"> 17 <meta http-equiv=Content-Type content="text/html; charset=utf-8">
15 </head> 18 </head>
16 <body onload=""> 19 <body onload="">
setup/upgrade/upgradeWizard.php
@@ -146,18 +146,6 @@ class UpgradeWizard { @@ -146,18 +146,6 @@ class UpgradeWizard {
146 } 146 }
147 147
148 /** 148 /**
149 - * Create upgrade file  
150 - *  
151 - * @author KnowledgeTree Team  
152 - * @access private  
153 - * @param none  
154 - * @return void  
155 - */  
156 - private function createUpgradeFile() {  
157 - touch(SYSTEM_DIR.'var'.DS.'bin'.DS."upgrade.lock");  
158 - }  
159 -  
160 - /**  
161 * Remove upgrade file 149 * Remove upgrade file
162 * 150 *
163 * @author KnowledgeTree Team 151 * @author KnowledgeTree Team
@@ -222,11 +210,11 @@ class UpgradeWizard { @@ -222,11 +210,11 @@ class UpgradeWizard {
222 */ 210 */
223 public function dispatch() { 211 public function dispatch() {
224 $this->load(); 212 $this->load();
225 - // is this necessary?  
226 - $this->createUpgradeFile();  
227 $response = $this->systemChecks(); 213 $response = $this->systemChecks();
228 if($this->util->installationSpecified()) { // Check if the migrator needs to be accessed 214 if($this->util->installationSpecified()) { // Check if the migrator needs to be accessed
229 $this->util->redirect('../wizard/index.php?step_name=install_type'); 215 $this->util->redirect('../wizard/index.php?step_name=install_type');
  216 + } elseif ($this->util->finishInstall()) { // Check if the installer has completed
  217 + $this->util->redirect('../../login.php');
230 } 218 }
231 if($response === true) { 219 if($response === true) {
232 $this->displayUpgrader(); 220 $this->displayUpgrader();
setup/upgrade/upgrader.php
@@ -400,20 +400,6 @@ class Upgrader { @@ -400,20 +400,6 @@ class Upgrader {
400 for ($i=1; $i< count($steps)+1; $i++) { 400 for ($i=1; $i< count($steps)+1; $i++) {
401 $this->_upgradeHelper($steps[$i]); 401 $this->_upgradeHelper($steps[$i]);
402 } 402 }
403 -  
404 - $this->_completeUpgrade();  
405 - }  
406 -  
407 - /**  
408 - * Complete upgrade cleanup process  
409 - *  
410 - * @author KnowledgeTree Team  
411 - * @param none  
412 - * @access private  
413 - * @return void  
414 - */  
415 - private function _completeUpgrade() {  
416 - touch("upgrade");  
417 } 403 }
418 404
419 /** 405 /**
setup/wizard/installUtil.php
@@ -522,42 +522,56 @@ class InstallUtil { @@ -522,42 +522,56 @@ class InstallUtil {
522 } 522 }
523 } 523 }
524 524
  525 +
525 /** 526 /**
526 - * Check if system needs to be accessed 527 + * Check if system needs to be migrated
527 * 528 *
528 * @author KnowledgeTree Team 529 * @author KnowledgeTree Team
529 * @access public 530 * @access public
530 * @param none 531 * @param none
531 * @return boolean 532 * @return boolean
532 */ 533 */
533 - public function finishSpecified() {  
534 - if(isset($_GET['Finish'])) {  
535 - if($_GET['Finish'] == "Finish") { 534 + public function migrationSpecified() {
  535 + if(isset($_POST['installtype'])) {
  536 + if($_POST['installtype'] == "Upgrade Installation") {
536 return true; 537 return true;
537 } 538 }
538 } 539 }
539 540
540 return false; 541 return false;
541 - } 542 + }
  543 +
  544 + public function upgradeInstall() {
  545 + if(isset($_GET['Upgrade'])) {
  546 + return true;
  547 + }
  548 + if(isset($_GET['Next'])) {
  549 + if($_POST['Next'] == "Upgrade") {
  550 + return true;
  551 + }
  552 + }
542 553
  554 + return false;
  555 + }
  556 +
543 /** 557 /**
544 - * Check if system needs to be migrated 558 + * Check if system needs to be accessed
545 * 559 *
546 * @author KnowledgeTree Team 560 * @author KnowledgeTree Team
547 * @access public 561 * @access public
548 * @param none 562 * @param none
549 * @return boolean 563 * @return boolean
550 */ 564 */
551 - public function migrationSpecified() {  
552 - if(isset($_POST['installtype'])) {  
553 - if($_POST['installtype'] == "Upgrade Installation") { 565 + public function finishInstall() {
  566 + if(isset($_GET['Next'])) {
  567 + if($_GET['Next'] == "Finish") {
554 return true; 568 return true;
555 } 569 }
556 } 570 }
557 571
558 return false; 572 return false;
559 } 573 }
560 - 574 +
561 /** 575 /**
562 * Check if system needs to be migrated 576 * Check if system needs to be migrated
563 * 577 *
@@ -595,7 +609,6 @@ class InstallUtil { @@ -595,7 +609,6 @@ class InstallUtil {
595 } 609 }
596 610
597 public function loginSpecified() { 611 public function loginSpecified() {
598 -// return true;  
599 if(isset($_GET['Return'])) { 612 if(isset($_GET['Return'])) {
600 if($_GET['Return'] == "Return To Installation") { 613 if($_GET['Return'] == "Return To Installation") {
601 return true; 614 return true;
@@ -727,7 +740,13 @@ class InstallUtil { @@ -727,7 +740,13 @@ class InstallUtil {
727 return true; 740 return true;
728 return false; 741 return false;
729 } 742 }
730 - 743 +
  744 + public function isCommunity() {
  745 + if(INSTALL_TYPE == "community")
  746 + return true;
  747 + return false;
  748 + }
  749 +
731 /** 750 /**
732 * Determine type of installation 751 * Determine type of installation
733 * 752 *
@@ -859,7 +878,7 @@ class InstallUtil { @@ -859,7 +878,7 @@ class InstallUtil {
859 return $type; 878 return $type;
860 } 879 }
861 880
862 - return false; 881 + return "community";
863 } 882 }
864 883
865 /** 884 /**
@@ -1040,8 +1059,93 @@ class InstallUtil { @@ -1040,8 +1059,93 @@ class InstallUtil {
1040 } 1059 }
1041 // }}} 1060 // }}}
1042 1061
1043 - /*  
1044 - Just Because.  
1045 - */ 1062 + // {{{ copyDirectory
  1063 + function copyDirectory($sSrc, $sDst, $bMove = false) {
  1064 + if (file_exists($sDst)) {
  1065 + return false; //PEAR::raiseError(_kt("Destination directory already exists."));
  1066 + }
  1067 + if (!WINDOWS_OS) {
  1068 + if ($bMove && file_exists('/bin/mv')) {
  1069 + $this->pexec(array('/bin/mv', $sSrc, $sDst));
  1070 + return;
  1071 + }
  1072 + if (!$bMove && file_exists('/bin/cp')) {
  1073 + $this->pexec(array('/bin/cp', '-R', $sSrc, $sDst));
  1074 + return;
  1075 + }
  1076 + }
  1077 + if (substr($sDst, 0, strlen($sSrc)) === $sSrc) {
  1078 + return false; //PEAR::raiseError(_kt("Destination of move is within source"));
  1079 + }
  1080 + $hSrc = @opendir($sSrc);
  1081 + if ($hSrc === false) {
  1082 + return false; //PEAR::raiseError(sprintf(_kt("Could not open source directory: %s"), $sSrc));
  1083 + }
  1084 + if (@mkdir($sDst, 0777) === false) {
  1085 + return false; //PEAR::raiseError(sprintf(_kt("Could not create destination directory: %s"), $sDst));
  1086 + }
  1087 + while (($sFilename = readdir($hSrc)) !== false) {
  1088 + if (in_array($sFilename, array('.', '..'))) {
  1089 + continue;
  1090 + }
  1091 + $sOldFile = sprintf("%s/%s", $sSrc, $sFilename);
  1092 + $sNewFile = sprintf("%s/%s", $sDst, $sFilename);
  1093 + if (is_dir($sOldFile)) {
  1094 + $this->copyDirectory($sOldFile, $sNewFile, $bMove);
  1095 + continue;
  1096 + }
  1097 + if ($bMove) {
  1098 + $this->moveFile($sOldFile, $sNewFile);
  1099 + } else {
  1100 + copy($sOldFile, $sNewFile);
  1101 + }
  1102 + }
  1103 + if ($bMove) {
  1104 + @rmdir($sSrc);
  1105 + }
  1106 + }
  1107 + // }}}
  1108 +
  1109 + // {{{ moveFile
  1110 + function moveFile ($sSrc, $sDst) {
  1111 + // Only 4.3.3 and above allow us to use rename across partitions
  1112 + // on Unix-like systems.
  1113 + if (!WINDOWS_OS) {
  1114 + // If /bin/mv exists, just use it.
  1115 + if (file_exists('/bin/mv')) {
  1116 + $this->pexec(array('/bin/mv', $sSrc, $sDst));
  1117 + return;
  1118 + }
  1119 + $aSrcStat = stat($sSrc);
  1120 + if ($aSrcStat === false) {
  1121 + return false; //PEAR::raiseError(sprintf(_kt("Couldn't stat source file: %s"), $sSrc));
  1122 + }
  1123 + $aDstStat = stat(dirname($sDst));
  1124 + if ($aDstStat === false) {
  1125 + return false; //PEAR::raiseError(sprintf(_kt("Couldn't stat destination location: %s"), $sDst));
  1126 + }
  1127 + if ($aSrcStat["dev"] === $aDstStat["dev"]) {
  1128 + $res = @rename($sSrc, $sDst);
  1129 + if ($res === false) {
  1130 + return false; //PEAR::raiseError(sprintf(_kt("Couldn't move file to destination: %s"), $sDst));
  1131 + }
  1132 + return;
  1133 + }
  1134 + $res = @copy($sSrc, $sDst);
  1135 + if ($res === false) {
  1136 + return false; //PEAR::raiseError(sprintf(_kt("Could not copy to destination: %s"), $sDst));
  1137 + }
  1138 + $res = @unlink($sSrc);
  1139 + if ($res === false) {
  1140 + return false; //PEAR::raiseError(sprintf(_kt("Could not remove source: %s"), $sSrc));
  1141 + }
  1142 + } else {
  1143 + $res = @rename($sSrc, $sDst);
  1144 + if ($res === false) {
  1145 + return false; //PEAR::raiseError(sprintf(_kt("Could not move to destination: %s"), $sDst));
  1146 + }
  1147 + }
  1148 + }
  1149 + // }}}
1046 } 1150 }
1047 ?> 1151 ?>
setup/wizard/installWizard.php
@@ -104,18 +104,6 @@ class InstallWizard { @@ -104,18 +104,6 @@ class InstallWizard {
104 public function __construct(){} 104 public function __construct(){}
105 105
106 /** 106 /**
107 - * Check if system has been install  
108 - *  
109 - * @author KnowledgeTree Team  
110 - * @access private  
111 - * @param none  
112 - * @return boolean  
113 - */  
114 - private function isSystemInstalled() {  
115 - return $this->util->isSystemInstalled();  
116 - }  
117 -  
118 - /**  
119 * Display the wizard 107 * Display the wizard
120 * 108 *
121 * @author KnowledgeTree Team 109 * @author KnowledgeTree Team
@@ -280,12 +268,17 @@ class InstallWizard { @@ -280,12 +268,17 @@ class InstallWizard {
280 } elseif ($this->getBypass() === "0") { 268 } elseif ($this->getBypass() === "0") {
281 $this->createInstallFile(); 269 $this->createInstallFile();
282 } 270 }
283 - if(!$this->isSystemInstalled()) { // Check if the systems not installed  
284 - if($this->util->loginSpecified()) { 271 + if ($this->util->finishInstall()) { // Check if the installer has completed
  272 + $this->util->redirect('../../login.php');
  273 + } elseif ($this->util->upgradeInstall()) { // Check if the upgrader needs to be accessed
  274 + $this->util->redirect('../upgrade/index.php');
  275 + }
  276 + if(!$this->util->isSystemInstalled()) { // Check if the systems not installed
  277 + if($this->util->loginSpecified()) { // Back to wizard from upgrader
285 $this->util->redirect('../../control.php'); 278 $this->util->redirect('../../control.php');
286 } elseif($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed 279 } elseif($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed
287 $this->util->redirect('../migrate/index.php?'); 280 $this->util->redirect('../migrate/index.php?');
288 - } elseif ($this->util->upgradeSpecified()) { 281 + } elseif ($this->util->upgradeSpecified()) { // Check if the upgrader needs to be accessed
289 $this->util->redirect('../upgrade/index.php?action=installer'); 282 $this->util->redirect('../upgrade/index.php?action=installer');
290 } 283 }
291 $response = $this->systemChecks(); 284 $response = $this->systemChecks();
setup/wizard/lib/plugins/pluginutil.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id$
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008, 2009 KnowledgeTree Inc.
  8 + *
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + * Contributor( s): ______________________________________
  36 + *
  37 + */
  38 +
  39 +//require_once(KT_LIB_DIR . '/plugins/pluginentity.inc.php');
  40 +//require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
  41 +//
  42 +//class KTPluginResourceRegistry {
  43 +// var $aResources = array();
  44 +//
  45 +// function &getSingleton() {
  46 +// if (!KTUtil::arrayGet($GLOBALS, 'oKTPluginResourceRegistry')) {
  47 +// $GLOBALS['oKTPluginResourceRegistry'] = new KTPluginResourceRegistry;
  48 +// }
  49 +// return $GLOBALS['oKTPluginResourceRegistry'];
  50 +// }
  51 +//
  52 +// function registerResource($sPath) {
  53 +// $this->aResources[$sPath] = true;
  54 +// }
  55 +//
  56 +// function isRegistered($sPath) {
  57 +// if (KTUtil::arrayGet($this->aResources, $sPath)) {
  58 +// return true;
  59 +// }
  60 +// $sPath = dirname($sPath);
  61 +// if (KTUtil::arrayGet($this->aResources, $sPath)) {
  62 +// return true;
  63 +// }
  64 +// return false;
  65 +// }
  66 +//}
  67 +
  68 +class KTPluginUtil {
  69 +// const CACHE_FILENAME = 'kt_plugins.cache';
  70 +//
  71 +// /**
  72 +// * Store the plugin cache in the cache directory.
  73 +// * @deprecated
  74 +// */
  75 +// static function savePluginCache($array)
  76 +// {
  77 +// $config = KTConfig::getSingleton();
  78 +// $cachePlugins = $config->get('cache/cachePlugins', false);
  79 +// if (!$cachePlugins)
  80 +// {
  81 +// return false;
  82 +// }
  83 +//
  84 +// $cacheDir = $config->get('cache/cacheDirectory');
  85 +//
  86 +// $written = file_put_contents($cacheDir . '/' . KTPluginUtil::CACHE_FILENAME , serialize($array));
  87 +//
  88 +// if (!$written)
  89 +// {
  90 +// global $default;
  91 +//
  92 +// $default->log->warn('savePluginCache - The cache did not write anything.');
  93 +//
  94 +// // try unlink a zero size file - just in case
  95 +// @unlink($cacheFile);
  96 +// }
  97 +// }
  98 +
  99 +// /**
  100 +// * Remove the plugin cache.
  101 +// * @deprecated
  102 +// */
  103 +// static function removePluginCache()
  104 +// {
  105 +// $config = KTConfig::getSingleton();
  106 +// $cachePlugins = $config->get('cache/cachePlugins', false);
  107 +// if (!$cachePlugins)
  108 +// {
  109 +// return false;
  110 +// }
  111 +// $cacheDir = $config->get('cache/cacheDirectory');
  112 +//
  113 +// $cacheFile=$cacheDir . '/' . KTPluginUtil::CACHE_FILENAME;
  114 +// @unlink($cacheFile);
  115 +// }
  116 +
  117 +// /**
  118 +// * Reads the plugin cache file. This must still be unserialised.
  119 +// * @deprecated
  120 +// * @return mixed Returns false on failure, or the serialised cache.
  121 +// */
  122 +// static function readPluginCache()
  123 +// {
  124 +// $config = KTConfig::getSingleton();
  125 +// $cachePlugins = $config->get('cache/cachePlugins', false);
  126 +// if (!$cachePlugins)
  127 +// {
  128 +// return false;
  129 +// }
  130 +// $cacheDir = $config->get('cache/cacheDirectory');
  131 +//
  132 +// $cacheFile=$cacheDir . '/' . KTPluginUtil::CACHE_FILENAME;
  133 +// if (!is_file($cacheFile))
  134 +// {
  135 +// return false;
  136 +// }
  137 +//
  138 +// $cache = file_get_contents($cacheFile);
  139 +//
  140 +// // we check for an empty cache in case there was a problem. We rather try and reload everything otherwise.
  141 +// if (strlen($cache) == 0)
  142 +// {
  143 +// return false;
  144 +// }
  145 +// if (!class_exists('KTPluginEntityProxy')) {
  146 +// KTEntityUtil::_proxyCreate('KTPluginEntity', 'KTPluginEntityProxy');
  147 +// }
  148 +//
  149 +// return unserialize($cache);
  150 +// }
  151 +
  152 +// /**
  153 +// * Load the plugins for the current page
  154 +// *
  155 +// * @param unknown_type $sType
  156 +// */
  157 +// static function loadPlugins ($sType) {
  158 +//
  159 +// // Check the current page - can be extended.
  160 +// // Currently we only distinguish between the dashboard and everything else.
  161 +// if($sType != 'dashboard'){
  162 +// $sType = 'general';
  163 +// }
  164 +//
  165 +// $aPlugins = array();
  166 +// $aPluginHelpers = array();
  167 +// $aDisabled = array();
  168 +//
  169 +// // Get the list of enabled plugins
  170 +// $query = "SELECT h.classname, h.pathname, h.plugin FROM plugin_helper h
  171 +// INNER JOIN plugins p ON (p.namespace = h.plugin)
  172 +// WHERE p.disabled = 0 AND h.classtype='plugin' ORDER BY p.orderby";
  173 +// $aPluginHelpers = DBUtil::getResultArray($query);
  174 +//
  175 +// if(PEAR::isError($aPluginHelpers)){
  176 +// global $default;
  177 +// $default->log->debug('Error in pluginutil: '.$aPluginHelpers->getMessage());
  178 +// return false;
  179 +// }
  180 +//
  181 +// // Check that there are plugins and if not, register them
  182 +// if (empty($aPluginHelpers) || (isset($_POST['_force_plugin_truncate']))) {
  183 +// DBUtil::startTransaction();
  184 +// KTPluginUtil::registerPlugins();
  185 +// DBUtil::commit();
  186 +//
  187 +// $query = "SELECT h.classname, h.pathname, h.plugin FROM plugin_helper h
  188 +// INNER JOIN plugins p ON (p.namespace = h.plugin)
  189 +// WHERE p.disabled = 0 AND h.classtype='plugin' ORDER BY p.orderby";
  190 +// $aPluginHelpers = DBUtil::getResultArray($query);
  191 +// }
  192 +//
  193 +// // Create plugin objects
  194 +// foreach ($aPluginHelpers as $aItem){
  195 +// $classname = $aItem['classname'];
  196 +// $path = $aItem['pathname'];
  197 +//
  198 +// if (!empty($path)) {
  199 +// $path = KT_DIR.'/'.$path;
  200 +// require_once($path);
  201 +//
  202 +// $oPlugin = new $classname($path);
  203 +// if($oPlugin->load()){
  204 +// $aPlugins[] = $oPlugin;
  205 +// }else{
  206 +// $aDisabled[] = "'{$aItem['plugin']}'";
  207 +// }
  208 +// }
  209 +// }
  210 +//
  211 +// $sDisabled = implode(',', $aDisabled);
  212 +//
  213 +// // load plugin helpers into global space
  214 +// $query = 'SELECT h.* FROM plugin_helper h
  215 +// INNER JOIN plugins p ON (p.namespace = h.plugin)
  216 +// WHERE p.disabled = 0 ';//WHERE viewtype='{$sType}'";
  217 +// if(!empty($sDisabled)){
  218 +// $query .= " AND h.plugin NOT IN ($sDisabled) ";
  219 +// }
  220 +// $query .= ' ORDER BY p.orderby';
  221 +//
  222 +// $aPluginList = DBUtil::getResultArray($query);
  223 +//
  224 +// KTPluginUtil::load($aPluginList);
  225 +//
  226 +// // Load the template locations - ignore disabled plugins
  227 +// // Allow for templates that don't correctly link to the plugin
  228 +// $query = "SELECT * FROM plugin_helper h
  229 +// LEFT JOIN plugins p ON (p.namespace = h.plugin)
  230 +// WHERE h.classtype='locations' AND (disabled = 0 OR disabled IS NULL) AND unavailable = 0";
  231 +//
  232 +// $aLocations = DBUtil::getResultArray($query);
  233 +//
  234 +// if(!empty($aLocations)){
  235 +// $oTemplating =& KTTemplating::getSingleton();
  236 +// foreach ($aLocations as $location){
  237 +// $aParams = explode('|', $location['object']);
  238 +// call_user_func_array(array(&$oTemplating, 'addLocation2'), $aParams);
  239 +// }
  240 +// }
  241 +// return true;
  242 +// }
  243 +
  244 + /**
  245 + * Load the plugins into the global space
  246 + *
  247 + * @param array $aPlugins
  248 + */
  249 + function load($aPlugins) {
  250 +
  251 + require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php');
  252 + require_once(KT_LIB_DIR . '/actions/portletregistry.inc.php');
  253 + require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php');
  254 + require_once(KT_LIB_DIR . '/plugins/pageregistry.inc.php');
  255 + require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php');
  256 + require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php");
  257 + require_once(KT_LIB_DIR . "/dashboard/dashletregistry.inc.php");
  258 + require_once(KT_LIB_DIR . "/i18n/i18nregistry.inc.php");
  259 + require_once(KT_LIB_DIR . "/help/help.inc.php");
  260 + require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php");
  261 + require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php");
  262 + require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php");
  263 + require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php");
  264 + require_once(KT_LIB_DIR . "/browse/criteriaregistry.php");
  265 + require_once(KT_LIB_DIR . "/authentication/interceptorregistry.inc.php");
  266 +
  267 + $oPRegistry =& KTPortletRegistry::getSingleton();
  268 + $oTRegistry =& KTTriggerRegistry::getSingleton();
  269 + $oARegistry =& KTActionRegistry::getSingleton();
  270 + $oPageRegistry =& KTPageRegistry::getSingleton();
  271 + $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
  272 + $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
  273 + $oDashletRegistry =& KTDashletRegistry::getSingleton();
  274 + $oi18nRegistry =& KTi18nRegistry::getSingleton();
  275 + $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
  276 + $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
  277 + $oColumnRegistry =& KTColumnRegistry::getSingleton();
  278 + $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
  279 + $oTemplating =& KTTemplating::getSingleton();
  280 + $oWidgetFactory =& KTWidgetFactory::getSingleton();
  281 + $oValidatorFactory =& KTValidatorFactory::getSingleton();
  282 + $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
  283 + $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
  284 + $oKTPluginRegistry =& KTPluginRegistry::getSingleton();
  285 +
  286 +
  287 + // Loop through the loaded plugins and register them for access
  288 + foreach ($aPlugins as $plugin){
  289 + $sName = $plugin['namespace'];
  290 + $sParams = $plugin['object'];
  291 + $aParams = explode('|', $sParams);
  292 + $sClassType = $plugin['classtype'];
  293 +
  294 + switch ($sClassType) {
  295 + case 'portlet':
  296 + $aLocation = unserialize($aParams[0]);
  297 + if($aLocation != false){
  298 + $aParams[0] = $aLocation;
  299 + }
  300 + if(isset($aParams[3])){
  301 + $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
  302 + }
  303 + call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $aParams);
  304 + break;
  305 +
  306 + case 'trigger':
  307 + if(isset($aParams[4])){
  308 + $aParams[4] = KTPluginUtil::getFullPath($aParams[4]);
  309 + }
  310 + call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $aParams);
  311 + break;
  312 +
  313 + case 'action':
  314 + if(isset($aParams[3])){
  315 + $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
  316 + }
  317 + call_user_func_array(array(&$oARegistry, 'registerAction'), $aParams);
  318 + break;
  319 +
  320 + case 'page':
  321 + if(isset($aParams[2])){
  322 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  323 + }
  324 + call_user_func_array(array(&$oPageRegistry, 'registerPage'), $aParams);
  325 + break;
  326 +
  327 + case 'authentication_provider':
  328 + if(isset($aParams[3])){
  329 + $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
  330 + }
  331 + $aParams[0] = _kt($aParams[0]);
  332 + call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $aParams);
  333 + break;
  334 +
  335 + case 'admin_category':
  336 + $aParams[1] = _kt($aParams[1]);
  337 + $aParams[2] = _kt($aParams[2]);
  338 + call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $aParams);
  339 + break;
  340 +
  341 + case 'admin_page':
  342 + if(isset($aParams[5])){
  343 + $aParams[5] = KTPluginUtil::getFullPath($aParams[5]);
  344 + }
  345 + $aParams[3] = _kt($aParams[3]);
  346 + $aParams[4] = _kt($aParams[4]);
  347 + call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $aParams);
  348 + break;
  349 +
  350 + case 'dashlet':
  351 + if(isset($aParams[2])){
  352 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  353 + }
  354 + call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $aParams);
  355 + break;
  356 +
  357 + case 'i18nlang':
  358 + if(isset($aParams[2]) && $aParams[2] != 'default'){
  359 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  360 + }
  361 + call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $aParams);
  362 +
  363 +
  364 + case 'i18n':
  365 + if(isset($aParams[2])){
  366 + $aParams[1] = $aParams[2];
  367 + unset($aParams[2]);
  368 + } else {
  369 + $aParams[1] = KTPluginUtil::getFullPath($aParams[1]);
  370 + }
  371 + call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $aParams);
  372 + break;
  373 +
  374 + case 'language':
  375 + call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $aParams);
  376 + break;
  377 +
  378 + case 'help_language':
  379 + if(isset($aParams[2])){
  380 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  381 + }
  382 + call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $aParams);
  383 + break;
  384 +
  385 + case 'workflow_trigger':
  386 + if(isset($aParams[2])){
  387 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  388 + }
  389 + call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $aParams);
  390 + break;
  391 +
  392 + case 'column':
  393 + if(isset($aParams[3])){
  394 + $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
  395 + }
  396 + $aParams[0] = _kt($aParams[0]);
  397 + call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $aParams);
  398 + break;
  399 +
  400 + case 'view':
  401 + $aParams[0] = _kt($aParams[0]);
  402 + call_user_func_array(array(&$oColumnRegistry, 'registerView'), $aParams);
  403 + break;
  404 +
  405 + case 'notification_handler':
  406 + if(isset($aParams[2])){
  407 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  408 + }
  409 + call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $aParams);
  410 + break;
  411 +
  412 + case 'template_location':
  413 + if(isset($aParams[1])){
  414 + $aParams[1] = KTPluginUtil::getFullPath($aParams[1]);
  415 + }
  416 + call_user_func_array(array(&$oTemplating, 'addLocation2'), $aParams);
  417 + break;
  418 +
  419 + case 'criterion':
  420 + $aInit = unserialize($aParams[3]);
  421 + if($aInit != false){
  422 + $aParams[3] = $aInit;
  423 + }
  424 + if(isset($aParams[2])){
  425 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  426 + }
  427 + call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $aParams);
  428 + break;
  429 +
  430 + case 'widget':
  431 + if(isset($aParams[2])){
  432 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  433 + }
  434 + call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $aParams);
  435 + break;
  436 +
  437 + case 'validator':
  438 + if(isset($aParams[2])){
  439 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  440 + }
  441 + call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $aParams);
  442 + break;
  443 +
  444 + case 'interceptor':
  445 + if(isset($aParams[2])){
  446 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  447 + }
  448 + call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $aParams);
  449 + break;
  450 +
  451 + case 'plugin':
  452 + if(isset($aParams[2])){
  453 + $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
  454 + }
  455 + $oKTPluginRegistry->_aPluginDetails[$sName] = $aParams;
  456 + break;
  457 + }
  458 + }
  459 + }
  460 +
  461 + /**
  462 + * Get the absolute path
  463 + */
  464 + function getFullPath($sPath = '') {
  465 + if(empty($sPath)){
  466 + return '';
  467 + }
  468 + $sPath = (KTUtil::isAbsolutePath($sPath)) ? $sPath : KT_DIR . '/' . $sPath;
  469 + return $sPath;
  470 + }
  471 +
  472 + /**
  473 + * This loads the plugins in the plugins folder. It searches for files ending with 'Plugin.php'.
  474 + * This is called by the 'Re-read plugins' action in the web interface.
  475 + */
  476 + function registerPlugins () {
  477 + global $default;
  478 +
  479 + // Path to lock file
  480 + $cacheDir = $default->cacheDirectory . DIRECTORY_SEPARATOR;
  481 + $lockFile = $cacheDir.'plugin_register.lock';
  482 +
  483 + // Check if the lock file exists
  484 + if(KTPluginUtil::doCheck($lockFile)){
  485 + return true;
  486 + }
  487 +
  488 + // Create the lock file, run through the plugin registration and then delete the lock file
  489 + touch($lockFile);
  490 + KTPluginUtil::doPluginRegistration();
  491 + @unlink($lockFile);
  492 + }
  493 +
  494 + /**
  495 + * Check the lockfile
  496 + */
  497 + function doCheck($lockFile)
  498 + {
  499 + if(file_exists($lockFile)){
  500 + // If it does exist, do a stat on it to check when it was created.
  501 + // if it was accessed more than 5 minutes ago then delete it and proceed with the plugin registration
  502 + // otherwise wait till lock file is deleted signalling that the registration is complete and return.
  503 +
  504 + $stat = stat($lockFile);
  505 +
  506 + $time = time() - (60 * 5);
  507 + if($stat['mtime'] > $time){
  508 +
  509 + $cnt = 0;
  510 +
  511 + while(file_exists($lockFile)){
  512 + $cnt++;
  513 + sleep(2);
  514 +
  515 + // if we've been waiting too long - typically it should only take a few seconds so 2 mins is too much time.
  516 + if($cnt > 60){
  517 + @unlink($lockFile);
  518 + return false;
  519 + }
  520 + }
  521 + return true;
  522 + }
  523 + @unlink($lockFile);
  524 + }
  525 + return false;
  526 + }
  527 +
  528 + /* Get the priority of the plugin */
  529 + function getPluginPriority($sFile) {
  530 + $defaultPriority = 10;
  531 + $priority = array(
  532 + "ktcore" => 1,
  533 + "ktstandard" => 2,
  534 + "i18n" => 3
  535 + );
  536 + foreach($priority as $pattern => $priority) {
  537 + if(ereg($pattern, $sFile)) {
  538 + return $priority;
  539 + }
  540 + }
  541 + return $defaultPriority;
  542 + }
  543 +
  544 + /**
  545 + * Read the plugins directory and register all plugins in the database.
  546 + */
  547 + function doPluginRegistration()
  548 + {
  549 + global $default;
  550 +
  551 + KTPluginUtil::_deleteSmartyFiles();
  552 + require_once(KT_LIB_DIR . '/cache/cache.inc.php');
  553 + $oCache =& KTCache::getSingleton();
  554 + $oCache->deleteAllCaches();
  555 +
  556 + // Remove all entries from the plugin_helper table and refresh it.
  557 + $query = "DELETE FROM plugin_helper";
  558 + $res = DBUtil::runQuery($query);
  559 +
  560 + $files = array();
  561 + $plugins = array();
  562 +
  563 + KTPluginUtil::_walk(KT_DIR . '/plugins', $files);
  564 + foreach ($files as $sFile) {
  565 + $plugin_ending = "Plugin.php";
  566 + if (substr($sFile, -strlen($plugin_ending)) === $plugin_ending) {
  567 + /* Set default priority */
  568 + $plugins[$sFile] = KTPluginUtil::getPluginPriority($sFile);
  569 + }
  570 + }
  571 +
  572 + /* Sort the plugins by priority */
  573 + asort($plugins);
  574 +
  575 + /*
  576 + Add a check to indicate that plugin registration is occuring.
  577 + This check has been put in place to prevent the plugin being registered on every page load.
  578 + */
  579 + $_SESSION['plugins_registerplugins'] = true;
  580 + foreach($plugins as $sFile => $priority) {
  581 + require_once($sFile);
  582 + }
  583 + $_SESSION['plugins_registerplugins'] = false;
  584 +
  585 + $oRegistry =& KTPluginRegistry::getSingleton();
  586 + $aRegistryList = $oRegistry->getPlugins();
  587 + foreach ($aRegistryList as $oPlugin) {
  588 + $res = $oPlugin->register();
  589 + if (PEAR::isError($res)) {
  590 + //var_dump($res);
  591 + $default->log->debug('Register of plugin failed: ' . $res->getMessage());
  592 + }
  593 + }
  594 +
  595 + $aPluginList = KTPluginEntity::getList();
  596 + foreach ($aPluginList as $oPluginEntity) {
  597 + $sPath = $oPluginEntity->getPath();
  598 + if (!KTUtil::isAbsolutePath($sPath)) {
  599 + $sPath = sprintf("%s/%s", KT_DIR, $sPath);
  600 + }
  601 + if (!file_exists($sPath)) {
  602 + $oPluginEntity->setUnavailable(true);
  603 + $oPluginEntity->setDisabled(true);
  604 + $res = $oPluginEntity->update();
  605 + }
  606 + }
  607 + KTPluginEntity::clearAllCaches();
  608 +
  609 + KTPluginUtil::_deleteSmartyFiles();
  610 + require_once(KT_LIB_DIR . '/cache/cache.inc.php');
  611 + $oCache =& KTCache::getSingleton();
  612 + $oCache->deleteAllCaches();
  613 +
  614 + //KTPluginUtil::removePluginCache();
  615 + }
  616 +
  617 + function _deleteSmartyFiles() {
  618 + $oConfig =& KTConfig::getSingleton();
  619 + $dir = sprintf('%s/%s', $oConfig->get('urls/varDirectory'), 'tmp');
  620 +
  621 + $dh = @opendir($dir);
  622 + if (empty($dh)) {
  623 + return;
  624 + }
  625 + $aFiles = array();
  626 + while (false !== ($sFilename = readdir($dh))) {
  627 + if (substr($sFilename, -10) == "smarty.inc") {
  628 + $aFiles[] = sprintf('%s/%s', $dir, $sFilename);
  629 + }
  630 + if (substr($sFilename, -10) == "smarty.php") {
  631 + $aFiles[] = sprintf('%s/%s', $dir, $sFilename);
  632 + }
  633 + }
  634 + foreach ($aFiles as $sFile) {
  635 + @unlink($sFile);
  636 + }
  637 + }
  638 +
  639 + function _walk ($path, &$files) {
  640 + if (!is_dir($path)) {
  641 + return;
  642 + }
  643 + $dirh = opendir($path);
  644 + while (($entry = readdir($dirh)) !== false) {
  645 + if (in_array($entry, array('.', '..'))) {
  646 + continue;
  647 + }
  648 + $newpath = $path . '/' . $entry;
  649 + if (is_dir($newpath)) {
  650 + KTPluginUtil::_walk($newpath, $files);
  651 + }
  652 + if (!is_file($newpath)) {
  653 + continue;
  654 + }
  655 + $files[] = $newpath;
  656 + }
  657 + }
  658 +
  659 + function resourceIsRegistered($path) {
  660 + $oRegistry =& KTPluginResourceRegistry::getSingleton();
  661 + return $oRegistry->isRegistered($path);
  662 + }
  663 +
  664 + function registerResource($path) {
  665 + $oRegistry =& KTPluginResourceRegistry::getSingleton();
  666 + $oRegistry->registerResource($path);
  667 + }
  668 +
  669 + function readResource($sPath) {
  670 + global $default;
  671 + $php_file = ".php";
  672 + if (substr($sPath, -strlen($php_file)) === $php_file) {
  673 + require_once($php_file);
  674 + } else {
  675 + $pi = pathinfo($sPath);
  676 + $mime_type = "";
  677 + $sExtension = KTUtil::arrayGet($pi, 'extension');
  678 + if (!empty($sExtension)) {
  679 + $mime_type = DBUtil::getOneResultKey(array("SELECT mimetypes FROM " . $default->mimetypes_table . " WHERE LOWER(filetypes) = ?", $sExtension), "mimetypes");
  680 + }
  681 + if (empty($mime_type)) {
  682 + $mime_type = "application/octet-stream";
  683 + }
  684 + $sFullPath = KT_DIR . '/plugins' . $sPath;
  685 + header("Content-Type: $mime_type");
  686 + header("Content-Length: " . filesize($sFullPath));
  687 + readfile($sFullPath);
  688 + }
  689 + }
  690 +
  691 + /**
  692 + * Get the full path to the plugin
  693 + *
  694 + * @param string $sNamespace The namespace of the plugin
  695 + * @param bool $relative Whether the path should be relative or full
  696 + * @return string
  697 + */
  698 + static function getPluginPath($sNamespace, $relative = false)
  699 + {
  700 + $oEntity = KTPluginEntity::getByNamespace($sNamespace);
  701 +
  702 + if(PEAR::isError($oEntity)){
  703 + return $oEntity;
  704 + }
  705 + $dir = dirname($oEntity->getPath()) . '/';
  706 +
  707 + if(!$relative){
  708 + $dir = KT_DIR . '/' . $dir;
  709 + }
  710 +
  711 + return $dir;
  712 + }
  713 +
  714 + // utility function to detect if the plugin is loaded and active.
  715 + static function pluginIsActive($sNamespace) {
  716 +
  717 + $oReg =& KTPluginRegistry::getSingleton();
  718 + $plugin = $oReg->getPlugin($sNamespace);
  719 +
  720 + if (is_null($plugin) || PEAR::isError($plugin)) { return false; } // no such plugin
  721 + else { // check if its active
  722 + $ent = KTPluginEntity::getByNamespace($sNamespace);
  723 +
  724 + if (PEAR::isError($ent)) { return false; }
  725 +
  726 + // we now can ask
  727 + return (!$ent->getDisabled());
  728 + }
  729 + }
  730 +}
  731 +
  732 +?>
setup/wizard/lib/services/unixLucene.php
@@ -50,6 +50,7 @@ class unixLucene extends unixService { @@ -50,6 +50,7 @@ class unixLucene extends unixService {
50 private $javaXms; 50 private $javaXms;
51 private $javaXmx; 51 private $javaXmx;
52 public $name = "KTLucene"; 52 public $name = "KTLucene";
  53 + public $hrname = "KnowledgeTree Indexer Service";
53 54
54 /** 55 /**
55 * Load defaults needed by service 56 * Load defaults needed by service
@@ -223,6 +224,10 @@ class unixLucene extends unixService { @@ -223,6 +224,10 @@ class unixLucene extends unixService {
223 return $this->name; 224 return $this->name;
224 } 225 }
225 226
  227 + public function getHRName() {
  228 + return $this->hrname;
  229 + }
  230 +
226 public function getStopMsg($installDir) { 231 public function getStopMsg($installDir) {
227 return "";//"Execute from terminal : $installDir/dmsctl.sh stop"; 232 return "";//"Execute from terminal : $installDir/dmsctl.sh stop";
228 } 233 }
setup/wizard/lib/services/unixOpenOffice.php
@@ -54,6 +54,7 @@ class unixOpenOffice extends unixService { @@ -54,6 +54,7 @@ class unixOpenOffice extends unixService {
54 // office executable 54 // office executable
55 private $soffice; 55 private $soffice;
56 public $name = "KTOpenOffice"; 56 public $name = "KTOpenOffice";
  57 + public $hrname = "KnowledgeTree OpenOffice.org Service";
57 58
58 /** 59 /**
59 * Load defaults needed by service 60 * Load defaults needed by service
@@ -173,6 +174,10 @@ class unixOpenOffice extends unixService { @@ -173,6 +174,10 @@ class unixOpenOffice extends unixService {
173 return $this->name; 174 return $this->name;
174 } 175 }
175 176
  177 + public function getHRName() {
  178 + return $this->hrname;
  179 + }
  180 +
176 public function getStopMsg($installDir) { 181 public function getStopMsg($installDir) {
177 return "";//"Execute from terminal : $installDir/dmsctl.sh stop"; 182 return "";//"Execute from terminal : $installDir/dmsctl.sh stop";
178 } 183 }
setup/wizard/lib/services/unixScheduler.php
@@ -48,6 +48,7 @@ class unixScheduler extends unixService { @@ -48,6 +48,7 @@ class unixScheduler extends unixService {
48 private $scheduler; 48 private $scheduler;
49 private $phpCli; 49 private $phpCli;
50 public $name = "KTScheduler"; 50 public $name = "KTScheduler";
  51 + public $hrname = "KnowledgeTree Scheduler Service";
51 52
52 /** 53 /**
53 * Load defaults needed by service 54 * Load defaults needed by service
@@ -178,7 +179,7 @@ class unixScheduler extends unixService { @@ -178,7 +179,7 @@ class unixScheduler extends unixService {
178 function start() { 179 function start() {
179 // TODO : Write sh on the fly? Not sure the reasoning here 180 // TODO : Write sh on the fly? Not sure the reasoning here
180 $source = $this->getSchedulerSourceLoc(); 181 $source = $this->getSchedulerSourceLoc();
181 - $this->writeSchedulerTask(); 182 +// $this->writeSchedulerTask();
182 $logFile = "/dev/null"; 183 $logFile = "/dev/null";
183 // @unlink($logFile); 184 // @unlink($logFile);
184 if($source) { // Source 185 if($source) { // Source
@@ -201,6 +202,10 @@ class unixScheduler extends unixService { @@ -201,6 +202,10 @@ class unixScheduler extends unixService {
201 return $this->name; 202 return $this->name;
202 } 203 }
203 204
  205 + public function getHRName() {
  206 + return $this->hrname;
  207 + }
  208 +
204 public function getStopMsg($installDir) { 209 public function getStopMsg($installDir) {
205 return "Service Running";//"Execute from terminal : $installDir/dmsctl.sh stop"; 210 return "Service Running";//"Execute from terminal : $installDir/dmsctl.sh stop";
206 } 211 }
setup/wizard/lib/services/windowsLucene.php
@@ -132,6 +132,10 @@ class windowsLucene extends windowsService { @@ -132,6 +132,10 @@ class windowsLucene extends windowsService {
132 */ 132 */
133 public $name = "KTLucene"; 133 public $name = "KTLucene";
134 134
  135 + public $hrname = "KnowledgeTree Indexer Service. (KTLucene)";
  136 +
  137 + public $description = "KnowledgeTree Indexer Service.";
  138 +
135 /** 139 /**
136 * Load defaults needed by service 140 * Load defaults needed by service
137 * 141 *
@@ -417,23 +421,15 @@ class windowsLucene extends windowsService { @@ -417,23 +421,15 @@ class windowsLucene extends windowsService {
417 */ 421 */
418 public function install() { 422 public function install() {
419 $state = $this->status(); 423 $state = $this->status();
420 -// if($state == '') {  
421 $luceneExe = $this->getLuceneExe(); 424 $luceneExe = $this->getLuceneExe();
422 $luceneSource = $this->getLuceneSource(); 425 $luceneSource = $this->getLuceneSource();
423 $luceneDir = $this->getluceneDir(); 426 $luceneDir = $this->getluceneDir();
424 -// if($luceneExe && $luceneSource && $luceneDir) {  
425 - $cmd = "\"{$luceneExe}\""." -install \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto";  
426 - if(DEBUG) {  
427 - echo "$cmd<br/>";  
428 - return false;  
429 - }  
430 - $this->writeLuceneInstall($cmd);  
431 - //$response = $this->util->pexec($cmd);  
432 -// return $response;  
433 -// }  
434 - return $state;  
435 -// }  
436 - 427 + $cmd = "\"{$luceneExe}\""." -install \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto";
  428 + if(DEBUG) {
  429 + echo "$cmd<br/>";
  430 + return false;
  431 + }
  432 + $this->writeLuceneInstall($cmd);
437 return $state; 433 return $state;
438 } 434 }
439 435
@@ -468,6 +464,10 @@ class windowsLucene extends windowsService { @@ -468,6 +464,10 @@ class windowsLucene extends windowsService {
468 return ''; 464 return '';
469 } 465 }
470 466
  467 + public function getHRName() {
  468 + return $this->hrname;
  469 + }
  470 +
471 public function getStopMsg($installDir) { 471 public function getStopMsg($installDir) {
472 return "";//"Execute from command prompt : $installDir/dmsctl.bat stop"; 472 return "";//"Execute from command prompt : $installDir/dmsctl.bat stop";
473 } 473 }
setup/wizard/lib/services/windowsOpenOffice.php
@@ -130,8 +130,12 @@ class windowsOpenOffice extends windowsService { @@ -130,8 +130,12 @@ class windowsOpenOffice extends windowsService {
130 * @param none 130 * @param none
131 * @return string 131 * @return string
132 */ 132 */
133 - public $name = "KTOpenOffice"; 133 + public $name = "KTOpenoffice";
134 134
  135 + public $hrname = "KnowledgeTree OpenOffice.org Service. (KTOpenOffice)";
  136 +
  137 + public $description = "KnowledgeTree OpenOffice.org Service.";
  138 +
135 /** 139 /**
136 * Load defaults needed by service 140 * Load defaults needed by service
137 * 141 *
@@ -210,7 +214,7 @@ class windowsOpenOffice extends windowsService { @@ -210,7 +214,7 @@ class windowsOpenOffice extends windowsService {
210 if($status == '') { 214 if($status == '') {
211 $binary = $this->getBin(); 215 $binary = $this->getBin();
212 if($binary != '') { 216 if($binary != '') {
213 - $cmd = "\"{$this->winservice}\" install $this->name "."-displayname {$this->name} -start auto \"".$binary."\" -headless -invisible -nofirststartwizard -\"accept=socket,host={$this->host},port={$this->port};urp;\"";; 217 + $cmd = "\"{$this->winservice}\" install \"{$this->name}\" -description \"{$this->description}\" -displayname \"{$this->name}\" -start auto \"".$binary."\" -headless -invisible -nofirststartwizard -\"accept=socket,host={$this->host},port={$this->port};urp;\"";;
214 if(DEBUG) { 218 if(DEBUG) {
215 echo "$cmd<br/>"; 219 echo "$cmd<br/>";
216 return false; 220 return false;
@@ -257,6 +261,10 @@ class windowsOpenOffice extends windowsService { @@ -257,6 +261,10 @@ class windowsOpenOffice extends windowsService {
257 return false; 261 return false;
258 } 262 }
259 263
  264 + public function getHRName() {
  265 + return $this->hrname;
  266 + }
  267 +
260 public function getStopMsg($installDir) { 268 public function getStopMsg($installDir) {
261 return "";//"Execute from command prompt : $installDir/dmsctl.bat stop"; 269 return "";//"Execute from command prompt : $installDir/dmsctl.bat stop";
262 } 270 }
setup/wizard/lib/services/windowsScheduler.php
@@ -77,6 +77,10 @@ class windowsScheduler extends windowsService { @@ -77,6 +77,10 @@ class windowsScheduler extends windowsService {
77 */ 77 */
78 public $name = "KTScheduler"; 78 public $name = "KTScheduler";
79 79
  80 + public $hrname = "KnowledgeTree Scheduler Service. (KTScheduler)";
  81 +
  82 + public $description = "KnowledgeTree Scheduler Service.";
  83 +
80 /** 84 /**
81 * Load defaults needed by service 85 * Load defaults needed by service
82 * 86 *
@@ -178,7 +182,7 @@ class windowsScheduler extends windowsService { @@ -178,7 +182,7 @@ class windowsScheduler extends windowsService {
178 } 182 }
179 183
180 private function setOptions() { 184 private function setOptions() {
181 - $this->options = "-displayname {$this->name} -start auto -binary \"{$this->getSchedulerScriptPath()}\" -headless -invisible "; 185 + $this->options = "-displayname \"{$this->name}\" -description \"{$this->description}\" -start auto -binary \"{$this->getSchedulerScriptPath()}\" -headless -invisible ";
182 } 186 }
183 187
184 private function writeTaskRunner() { 188 private function writeTaskRunner() {
@@ -231,36 +235,9 @@ class windowsScheduler extends windowsService { @@ -231,36 +235,9 @@ class windowsScheduler extends windowsService {
231 $state = $this->status(); 235 $state = $this->status();
232 if($state == '') { 236 if($state == '') {
233 $this->writeTaskRunner(); 237 $this->writeTaskRunner();
234 - //if (function_exists('win32_create_service')) { // TODO what if it does not exist? check how the dmsctl.bat does this  
235 - if(DEBUG) {  
236 - echo '<pre>';  
237 - print_r(array('service' => $this->name, 'display' => $this->name, 'path' => $this->getSchedulerScriptPath()));  
238 - echo '</pre>';  
239 - echo '<pre>';  
240 - print_r(file_get_contents($this->getSchedulerScriptPath()));  
241 - echo '</pre>';  
242 - return ;  
243 - }  
244 - /*  
245 - $response = win32_create_service(array(  
246 - 'service' => $this->name,  
247 - 'display' => $this->name,  
248 - 'path' => $this->getSchedulerScriptPath()  
249 - ));  
250 - return $response;  
251 - */  
252 - //} else { // Attempt to use the winserv  
253 - // TODO: Add service using winserv  
254 - $this->setWinservice();  
255 - $this->setOptions();  
256 - $cmd = "\"{$this->winservice}\" install $this->name $this->options";  
257 - if(DEBUG) {  
258 - echo "$cmd<br/>";  
259 - return false;  
260 - }  
261 - //$response = $this->util->pexec($cmd);  
262 - //return $response;  
263 - //} 238 + $this->setWinservice();
  239 + $this->setOptions();
  240 + $cmd = "\"{$this->winservice}\" install $this->name $this->options";
264 $this->writeSchedulerInstall($cmd); 241 $this->writeSchedulerInstall($cmd);
265 } 242 }
266 return $state; 243 return $state;
@@ -278,8 +255,12 @@ class windowsScheduler extends windowsService { @@ -278,8 +255,12 @@ class windowsScheduler extends windowsService {
278 return false; 255 return false;
279 } 256 }
280 257
  258 + public function getHRName() {
  259 + return $this->hrname;
  260 + }
  261 +
281 public function getStopMsg($installDir) { 262 public function getStopMsg($installDir) {
282 - return "";//"Execute from command prompt : $installDir/dmsctl.bat stop"; 263 + return "";
283 } 264 }
284 } 265 }
285 ?> 266 ?>
286 \ No newline at end of file 267 \ No newline at end of file
setup/wizard/path.php
@@ -45,6 +45,8 @@ @@ -45,6 +45,8 @@
45 define('AGENT', 'IE6'); 45 define('AGENT', 'IE6');
46 } else if(preg_match("/MSIE 7\.\d/", $browser)) { 46 } else if(preg_match("/MSIE 7\.\d/", $browser)) {
47 define('AGENT', 'IE7'); 47 define('AGENT', 'IE7');
  48 + } else if(preg_match("/MSIE 8\.\d/", $browser)) {
  49 + define('AGENT', 'IE8');
48 } else { 50 } else {
49 define('AGENT', 'OTHER'); 51 define('AGENT', 'OTHER');
50 } 52 }
@@ -64,7 +66,6 @@ @@ -64,7 +66,6 @@
64 } else { 66 } else {
65 define('DS', '/'); 67 define('DS', '/');
66 } 68 }
67 - $wizard = realpath(dirname(__FILE__));  
68 // Define environment root 69 // Define environment root
69 $wizard = realpath(dirname(__FILE__)); 70 $wizard = realpath(dirname(__FILE__));
70 $xdir = explode(DS, $wizard); 71 $xdir = explode(DS, $wizard);
setup/wizard/resources/css/community.css 0 → 100644
  1 +#step_content {
  2 + min-height: 400px;
  3 +}
  4 +
  5 +#step_content_dependencies {
  6 + min-height:270px;
  7 +}
  8 +
  9 +#step_content_configuration {
  10 + min-height:130px;
  11 +}
  12 +
  13 +#step_content_services {
  14 + min-height:230px;
  15 +}
  16 +
  17 +#step_content_registration {
  18 + min-height:100px;
  19 +}
  20 +
  21 +#step_content_registration_confirm {
  22 + min-height:300px;
  23 +}
  24 +
  25 +#step_content_install {
  26 + min-height:150px;
  27 +}
  28 +
  29 +#step_content_database {
  30 + min-height:240px;
  31 +}
  32 +
  33 +#step_content_database_confirm {
  34 + min-height:370px;
  35 +}
  36 +
  37 +#step_content_complete {
  38 + min-height:340px;
  39 +}
  40 +
  41 +.license_agreement {
  42 + height:270px;
  43 +}
0 \ No newline at end of file 44 \ No newline at end of file
setup/wizard/resources/css/ie7.css
1 #logo { 1 #logo {
2 right:70%; 2 right:70%;
3 } 3 }
4 -  
5 -.onclick {  
6 - cursor: pointer;  
7 - color: #EC7725;  
8 - /*width: 150px;*/width:350px;padding-top:12px;position:static;  
9 -}  
10 -  
11 -.dependency_details {  
12 - padding-top:12px;  
13 - position:static;  
14 - width:650px;  
15 -}  
16 -  
17 -.dependencies {  
18 - position:static;  
19 - right:30%;  
20 - width:650px;  
21 -}  
22 -  
23 -.description_complete {  
24 - position:static;  
25 - right:35%;  
26 - width:100%;  
27 -}  
28 \ No newline at end of file 4 \ No newline at end of file
setup/wizard/resources/css/ie8.css 0 → 100644
  1 +#logo {
  2 + right:70%;
  3 +}
0 \ No newline at end of file 4 \ No newline at end of file
setup/wizard/resources/css/wizard.css
@@ -368,7 +368,7 @@ select { @@ -368,7 +368,7 @@ select {
368 .onclick { 368 .onclick {
369 cursor: pointer; 369 cursor: pointer;
370 color: #EC7725; 370 color: #EC7725;
371 - /*width: 150px;*/width:350px;top:12px;position:relative; 371 + /*width: 150px;*//*width:350px;top:12px;position:relative;*/width:350px;padding-top:12px;position:static;
372 } 372 }
373 373
374 .description { 374 .description {
@@ -563,15 +563,15 @@ td.dir_description { @@ -563,15 +563,15 @@ td.dir_description {
563 } 563 }
564 564
565 .dependency_details { 565 .dependency_details {
566 - top:12px;  
567 - position:relative; 566 + /*top:12px;*/padding-top:12px;
  567 + /*position:relative;*/position:static;
568 width:650px; 568 width:650px;
569 } 569 }
570 570
571 .dependencies { 571 .dependencies {
572 - position:relative; 572 + /*position:relative;*/position:static;
573 right:30%; 573 right:30%;
574 - width:880px; 574 + /*width:880px;*/width:650px;
575 } 575 }
576 576
577 .registration_template { 577 .registration_template {
@@ -583,7 +583,7 @@ td.dir_description { @@ -583,7 +583,7 @@ td.dir_description {
583 } 583 }
584 584
585 .description_complete { 585 .description_complete {
586 - position:relative; 586 + /*position:relative;*/position:static;
587 right:35%; 587 right:35%;
588 width:100%; 588 width:100%;
589 } 589 }
@@ -594,4 +594,28 @@ td.dir_description { @@ -594,4 +594,28 @@ td.dir_description {
594 594
595 .advoptions { 595 .advoptions {
596 top:0px; 596 top:0px;
  597 +}
  598 +
  599 +.description_1 {
  600 + color:#898989;
  601 + font-size:100%;
  602 + line-height:150%;
  603 + font-family:sans-serif;
  604 +}
  605 +
  606 +.twitter {
  607 +
  608 +}
  609 +
  610 +.facebook {
  611 +
  612 +}
  613 +
  614 +.connect {
  615 + float:none;
  616 + padding-bottom:0;
  617 + padding-left:560px;
  618 + padding-right:10px;
  619 + padding-top:10px;
  620 + position:static;
597 } 621 }
598 \ No newline at end of file 622 \ No newline at end of file
setup/wizard/resources/graphics/facebookbutton.png 0 → 100644

6.93 KB

setup/wizard/resources/graphics/twitterbutton.png 0 → 100644

6.81 KB

setup/wizard/steps/complete.php
@@ -61,6 +61,10 @@ class complete extends Step { @@ -61,6 +61,10 @@ class complete extends Step {
61 61
62 function doStep() { 62 function doStep() {
63 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); 63 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent);
  64 + $this->temp_variables['isCE'] = false;
  65 + $type = $this->util->getVersionType();
  66 + if($type == "community")
  67 + $this->temp_variables['isCE'] = true;
64 $this->doRun(); 68 $this->doRun();
65 return 'landing'; 69 return 'landing';
66 } 70 }
@@ -69,10 +73,14 @@ class complete extends Step { @@ -69,10 +73,14 @@ class complete extends Step {
69 $this->checkFileSystem(); // check filesystem (including location of document directory and logging) 73 $this->checkFileSystem(); // check filesystem (including location of document directory and logging)
70 $this->checkDb(); // check database 74 $this->checkDb(); // check database
71 $this->checkServices(); // check services 75 $this->checkServices(); // check services
72 - $this->checkInstallType();// Set silent mode variables  
73 - $this->storeSilent();// Set silent mode variables 76 + $this->checkInstallType(); // Set silent mode variables
  77 + $this->storeSilent(); // Set silent mode variables
74 } 78 }
75 79
  80 + /**
  81 + * Check all the system paths
  82 + *
  83 + */
76 private function checkFileSystem() 84 private function checkFileSystem()
77 { 85 {
78 // defaults 86 // defaults
@@ -130,6 +138,10 @@ class complete extends Step { @@ -130,6 +138,10 @@ class complete extends Step {
130 } 138 }
131 } 139 }
132 140
  141 + /**
  142 + * Check if a database connection can be made
  143 + *
  144 + */
133 private function checkDb() 145 private function checkDb()
134 { 146 {
135 // defaults 147 // defaults
@@ -199,6 +211,10 @@ class complete extends Step { @@ -199,6 +211,10 @@ class complete extends Step {
199 } 211 }
200 } 212 }
201 213
  214 + /**
  215 + * Check if all services are deactivated
  216 + *
  217 + */
202 private function checkServices() 218 private function checkServices()
203 { 219 {
204 $services = new services(); 220 $services = new services();
@@ -217,15 +233,28 @@ class complete extends Step { @@ -217,15 +233,28 @@ class complete extends Step {
217 return true; 233 return true;
218 } 234 }
219 235
  236 + /**
  237 + * Check the install type and store
  238 + *
  239 + */
220 function checkInstallType() { 240 function checkInstallType() {
221 if ($this->util->isMigration()) { 241 if ($this->util->isMigration()) {
222 $this->migrate_check = true; 242 $this->migrate_check = true;
  243 + $this->registerPlugins(); // Set silent mode variables
223 } else { 244 } else {
224 $this->migrate_check = false; 245 $this->migrate_check = false;
225 } 246 }
226 } 247 }
227 248
228 /** 249 /**
  250 + * Register extra commercial plugins
  251 + *
  252 + */
  253 + private function registerPlugins() {
  254 +
  255 + }
  256 +
  257 + /**
229 * Set all silent mode varibles 258 * Set all silent mode varibles
230 * 259 *
231 */ 260 */
@@ -236,7 +265,6 @@ class complete extends Step { @@ -236,7 +265,6 @@ class complete extends Step {
236 $this->temp_variables['database_check'] = $this->database_check; 265 $this->temp_variables['database_check'] = $this->database_check;
237 $this->temp_variables['migrate_check'] = $this->migrate_check; 266 $this->temp_variables['migrate_check'] = $this->migrate_check;
238 $this->temp_variables['servicesValidation'] = $this->servicesValidation; 267 $this->temp_variables['servicesValidation'] = $this->servicesValidation;
239 - //if(!$this->pathsSection) {die;} else {echo 'huh';}  
240 $this->temp_variables['pathsSection'] = $this->pathsSection; 268 $this->temp_variables['pathsSection'] = $this->pathsSection;
241 $this->temp_variables['databaseSection'] = $this->databaseSection; 269 $this->temp_variables['databaseSection'] = $this->databaseSection;
242 $this->temp_variables['privilegesSection'] = $this->privilegesSection; 270 $this->temp_variables['privilegesSection'] = $this->privilegesSection;
setup/wizard/steps/configuration.php
@@ -247,10 +247,12 @@ class configuration extends Step @@ -247,10 +247,12 @@ class configuration extends Step
247 public function doRun($edit = false) 247 public function doRun($edit = false)
248 { 248 {
249 $server = $this->getServerInfo(); 249 $server = $this->getServerInfo();
250 - if(!$edit) $this->temp_variables['server'] = $server; 250 + if(!$edit || $this->util->isMigration())
  251 + $this->temp_variables['server'] = $server;
251 252
252 $paths = $this->getPathInfo($server['file_system_root']['value']); 253 $paths = $this->getPathInfo($server['file_system_root']['value']);
253 - if(!$edit) $this->temp_variables['paths'] = $paths; 254 + if(!$edit || $this->util->isMigration())
  255 + $this->temp_variables['paths'] = $paths;
254 256
255 // Rewrite file system root 257 // Rewrite file system root
256 if(!$this->fpath) { 258 if(!$this->fpath) {
@@ -432,13 +434,15 @@ class configuration extends Step @@ -432,13 +434,15 @@ class configuration extends Step
432 { 434 {
433 if(isset($this->temp_variables['paths'])) { 435 if(isset($this->temp_variables['paths'])) {
434 if ($this->util->isMigration()) { // Check if its an upgrade 436 if ($this->util->isMigration()) { // Check if its an upgrade
435 - $this->readInstallation(); // Read values from config.ini of other installation 437 + $this->readConfigPath(); // Read contents of config-path file as only var Documents are used of old stack
  438 + $this->readInstallation(); // Read values from config.ini of other installation and overwrite config-path's
436 $dirs = $this->getFromConfigPath(); // Store contents 439 $dirs = $this->getFromConfigPath(); // Store contents
437 } else { 440 } else {
438 $dirs = $this->temp_variables['paths']; // Pull from temp 441 $dirs = $this->temp_variables['paths']; // Pull from temp
439 } 442 }
440 } else { 443 } else {
441 if ($this->util->isMigration()) { // Check if its an upgrade 444 if ($this->util->isMigration()) { // Check if its an upgrade
  445 + $this->readConfigPath(); // Read contents of config-path file as only var Documents are used of old stack
442 $this->readInstallation(); // Read values from config.ini of other installation 446 $this->readInstallation(); // Read values from config.ini of other installation
443 } else { 447 } else {
444 $this->readConfigPath(); // Read contents of config-path file 448 $this->readConfigPath(); // Read contents of config-path file
@@ -455,13 +459,13 @@ class configuration extends Step @@ -455,13 +459,13 @@ class configuration extends Step
455 } 459 }
456 if(WINDOWS_OS) 460 if(WINDOWS_OS)
457 $path = preg_replace('/\//', '\\',$path); 461 $path = preg_replace('/\//', '\\',$path);
458 - $dirs[$key]['path'] = $path;  
459 - $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows  
460 - if(isset($dir['file'])) {  
461 - $class = $this->util->checkPermission($path, false, true);  
462 - } else {  
463 - $class = $this->util->checkPermission($path, $dir['create']);  
464 - } 462 + $dirs[$key]['path'] = $path;
  463 + $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
  464 + if(isset($dir['file'])) {
  465 + $class = $this->util->checkPermission($path, false, true);
  466 + } else {
  467 + $class = $this->util->checkPermission($path, $dir['create']);
  468 + }
465 if(isset($class['msg'])) { 469 if(isset($class['msg'])) {
466 if($class['class'] != 'tick') { 470 if($class['class'] != 'tick') {
467 $this->temp_variables['paths_perms'] = $class['class']; 471 $this->temp_variables['paths_perms'] = $class['class'];
setup/wizard/steps/database.php
@@ -309,11 +309,7 @@ class database extends Step @@ -309,11 +309,7 @@ class database extends Step
309 $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2(); 309 $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();
310 return false; 310 return false;
311 } 311 }
312 -// if($this->dport == '') {  
313 -// $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname);  
314 -// } else {  
315 - $this->util->dbUtilities->load($this->dhost, $this->dport, $this->duname, $this->dpassword, $this->dname);  
316 -// } 312 + $this->util->dbUtilities->load($this->dhost, $this->dport, $this->duname, $this->dpassword, $this->dname);
317 if (!$this->util->dbUtilities->getDatabaseLink()) { 313 if (!$this->util->dbUtilities->getDatabaseLink()) {
318 $this->error['con'] = "Could not connect to the database, please check username and password"; 314 $this->error['con'] = "Could not connect to the database, please check username and password";
319 return false; 315 return false;
@@ -642,12 +638,20 @@ class database extends Step @@ -642,12 +638,20 @@ class database extends Step
642 $this->error['con'] = "Could not populate schema "; 638 $this->error['con'] = "Could not populate schema ";
643 } 639 }
644 $this->writeBinaries(); 640 $this->writeBinaries();
645 - // ensure a guid was generated and is stored  
646 - $this->util->getSystemIdentifier(); 641 + $this->addServerPort();
  642 + $this->util->getSystemIdentifier(); // ensure a guid was generated and is stored
  643 + $this->reBuildPaths();
647 644
648 return true; 645 return true;
649 } 646 }
650 647
  648 + private function addServerPort() {
  649 + $conf = $this->util->getDataFromSession('configuration');
  650 + $port = $conf['server']['port']['value'];
  651 + $iserverPorts = 'UPDATE config_settings SET value = "'.$port.'" where group_name = "server" and item IN("internal_server_port", "server_port");'; // Update internal server port
  652 + $this->util->dbUtilities->query($iserverPorts);
  653 + }
  654 +
651 /** 655 /**
652 * Create database 656 * Create database
653 * 657 *
@@ -770,16 +774,26 @@ class database extends Step @@ -770,16 +774,26 @@ class database extends Step
770 $this->parse_mysql_dump($sqlFile); 774 $this->parse_mysql_dump($sqlFile);
771 $dropPluginHelper = "TRUNCATE plugin_helper;"; // Remove plugin helper table 775 $dropPluginHelper = "TRUNCATE plugin_helper;"; // Remove plugin helper table
772 $this->util->dbUtilities->query($dropPluginHelper); 776 $this->util->dbUtilities->query($dropPluginHelper);
773 - $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; // Remove references to old paths  
774 - $this->util->dbUtilities->query($updateUrls); 777 + $this->addServerPort();
  778 + $this->util->dbUtilities->query($iserverPorts);
775 $updateExternalBinaries = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "externalBinary";'; // Remove references to old paths 779 $updateExternalBinaries = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "externalBinary";'; // Remove references to old paths
776 $this->util->dbUtilities->query($updateExternalBinaries); 780 $this->util->dbUtilities->query($updateExternalBinaries);
  781 + $this->reBuildPaths();
777 $this->writeBinaries(); // Rebuild some of the binaries 782 $this->writeBinaries(); // Rebuild some of the binaries
778 $this->util->getSystemIdentifier(); // ensure a guid was generated and is stored 783 $this->util->getSystemIdentifier(); // ensure a guid was generated and is stored
779 784
780 return true; 785 return true;
781 } 786 }
782 787
  788 + private function reBuildPaths() {
  789 + $conf = $this->util->getDataFromSession('configuration');
  790 + $paths = $conf['paths'];
  791 + foreach ($paths as $k=>$path) {
  792 + $sql = 'UPDATE config_settings SET value = "'.$path['path'].'" where item = "'.$k.'";';
  793 + $this->util->dbUtilities->query($sql);
  794 + }
  795 + }
  796 +
783 private function writeBinaries() { 797 private function writeBinaries() {
784 // if Windows, attempt to insert full paths to binaries 798 // if Windows, attempt to insert full paths to binaries
785 if (WINDOWS_OS) { 799 if (WINDOWS_OS) {
@@ -790,12 +804,47 @@ class database extends Step @@ -790,12 +804,47 @@ class database extends Step
790 'df' => array(0 => 'externalBinary', 1 => SYSTEM_ROOT . 'bin\gnuwin32\df.exe'), 804 'df' => array(0 => 'externalBinary', 1 => SYSTEM_ROOT . 'bin\gnuwin32\df.exe'),
791 'zip' => array(0 => 'export', 1 => SYSTEM_ROOT . 'bin\zip\zip.exe'), 805 'zip' => array(0 => 'export', 1 => SYSTEM_ROOT . 'bin\zip\zip.exe'),
792 'unzip' => array(0 => 'import', 1 => SYSTEM_ROOT . 'bin\unzip\unzip.exe')); 806 'unzip' => array(0 => 'import', 1 => SYSTEM_ROOT . 'bin\unzip\unzip.exe'));
  807 +
  808 + if (INSTALL_TYPE == 'commercial' || true) {
  809 + $winBinaries['pdf2swf'] = array(0 => 'externalBinary', 1 => SYSTEM_ROOT . 'bin\swftools\pdf2swf.exe');
  810 + }
  811 +
793 foreach ($winBinaries as $displayName => $bin) 812 foreach ($winBinaries as $displayName => $bin)
794 { 813 {
795 // continue without attempting to set the path if we can't find the file in the specified location 814 // continue without attempting to set the path if we can't find the file in the specified location
796 if (!file_exists($bin[1])) continue; 815 if (!file_exists($bin[1])) continue;
797 - $updateBin = 'UPDATE config_settings c SET c.value = "'. str_replace('\\', '\\\\', $bin[1]) . '" '  
798 - . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";'; 816 +
  817 + // escape paths for insert/update query
  818 + $bin[1] = str_replace('\\', '\\\\', $bin[1]);
  819 +
  820 + // instaView won't exist, must be inserted instead of updated
  821 + // TODO this may need to be modified to first check for existing setting as with the convert step below; not necessary for 3.7.0.x
  822 + if ($displayName == 'pdf2swf') {
  823 + $updateBin = 'INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) '
  824 + . 'VALUES ("' . $bin[0] . '", "' . $displayName . '", "The path to the SWFTools \"pdf2swf\" binary", "pdf2swfPath", '
  825 + . '"' . $bin[1] . '", "pdf2swf", "string", NULL, 1);';
  826 + }
  827 + // on a migration, the convert setting will not exist, so do something similar to the above, but first check whether it exists
  828 + else if ($displayName == 'convert') {
  829 + // check for existing config settings entry and only add if not already present
  830 + $sql = 'SELECT id FROM `config_settings` WHERE group_name = "externalBinary" AND item = "convertPath"';
  831 + $result = $this->util->dbUtilities->query($sql);
  832 + $output = $this->util->dbUtilities->fetchAssoc($result);
  833 + if(is_null($output)) {
  834 + $updateBin = 'INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) '
  835 + . 'VALUES ("' . $bin[0] . '", "' . $displayName . '", "The path to the ImageMagick \"convert\" binary", "convertPath", '
  836 + . '"' . $bin[1] . '", "convert", "string", NULL, 1)';
  837 + }
  838 + else {
  839 + $updateBin = 'UPDATE config_settings c SET c.value = "'. $bin[1] . '" '
  840 + . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";';
  841 + }
  842 + }
  843 + else {
  844 + $updateBin = 'UPDATE config_settings c SET c.value = "'. $bin[1] . '" '
  845 + . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";';
  846 + }
  847 +
799 $this->util->dbUtilities->query($updateBin); 848 $this->util->dbUtilities->query($updateBin);
800 } 849 }
801 } 850 }
setup/wizard/steps/install.php
@@ -60,9 +60,11 @@ class install extends step @@ -60,9 +60,11 @@ class install extends step
60 * @var array 60 * @var array
61 */ 61 */
62 protected $runInstall = true; 62 protected $runInstall = true;
  63 + private $ce_check = false;
63 64
64 public function doStep() { 65 public function doStep() {
65 $this->temp_variables = array("step_name"=>"install"); 66 $this->temp_variables = array("step_name"=>"install");
  67 + $this->checkInstallType(); // Set silent mode variables
66 if(!$this->inStep("install")) { 68 if(!$this->inStep("install")) {
67 return 'landing'; 69 return 'landing';
68 } 70 }
@@ -104,6 +106,24 @@ class install extends step @@ -104,6 +106,24 @@ class install extends step
104 $this->callHome(); 106 $this->callHome();
105 } 107 }
106 108
  109 + /**
  110 + * Check the install type and store
  111 + *
  112 + */
  113 + function checkInstallType() {
  114 + if ($this->util->isCommunity()) {
  115 + $this->ce_check = true;
  116 + $this->registerPlugins(); // Set silent mode variables
  117 + } else {
  118 + $this->ce_check = false;
  119 + }
  120 + $this->temp_variables['ce_check'] = $this->ce_check;
  121 + }
  122 +
  123 + function registerPlugins() {
  124 +
  125 + }
  126 +
107 public function callHome() { 127 public function callHome() {
108 $conf = $this->getDataFromSession("install"); // retrieve database information from session 128 $conf = $this->getDataFromSession("install"); // retrieve database information from session
109 $dbconf = $this->getDataFromSession("database"); 129 $dbconf = $this->getDataFromSession("database");
@@ -116,5 +136,7 @@ class install extends step @@ -116,5 +136,7 @@ class install extends step
116 $this->util->dbUtilities->query($query); 136 $this->util->dbUtilities->query($query);
117 $this->util->dbUtilities->close(); // close the database connection 137 $this->util->dbUtilities->close(); // close the database connection
118 } 138 }
  139 +
  140 +
119 } 141 }
120 ?> 142 ?>
121 \ No newline at end of file 143 \ No newline at end of file
setup/wizard/steps/installtype.php
@@ -45,6 +45,10 @@ class installType extends step @@ -45,6 +45,10 @@ class installType extends step
45 45
46 public function doStep() { 46 public function doStep() {
47 $this->temp_variables = array("step_name"=>"installtype"); 47 $this->temp_variables = array("step_name"=>"installtype");
  48 + $type = $this->util->getVersionType();
  49 + $this->temp_variables['isCE'] = false;
  50 + if($type == "community")
  51 + $this->temp_variables['isCE'] = true;
48 if(!$this->inStep("installtype")) { 52 if(!$this->inStep("installtype")) {
49 return 'landing'; 53 return 'landing';
50 } 54 }
setup/wizard/templates/complete.tpl
@@ -4,9 +4,7 @@ @@ -4,9 +4,7 @@
4 </p> 4 </p>
5 <p class="description"> 5 <p class="description">
6 This step allows you to check that your KnowledgeTree configuration is set up correctly. 6 This step allows you to check that your KnowledgeTree configuration is set up correctly.
7 -<!-- <br/>-->  
8 Click <b>Finish</b> to browse to the KnowledgeTree Web Interface. Default login credentials are <b>username:</b> <i>admin</i> and <b>password:</b> <i>admin</i>. 7 Click <b>Finish</b> to browse to the KnowledgeTree Web Interface. Default login credentials are <b>username:</b> <i>admin</i> and <b>password:</b> <i>admin</i>.
9 -<!-- You can run this at any time after configuration to check that things are still set up correctly.-->  
10 </p> 8 </p>
11 <div> 9 <div>
12 <a href="http://wiki.knowledgetree.com/Web_Based_Installer#Post_Install" target="_blank"> 10 <a href="http://wiki.knowledgetree.com/Web_Based_Installer#Post_Install" target="_blank">
@@ -15,6 +13,7 @@ @@ -15,6 +13,7 @@
15 </div> 13 </div>
16 <br/> 14 <br/>
17 <div id="step_content_<?php echo $step_name; ?>" class="step"> 15 <div id="step_content_<?php echo $step_name; ?>" class="step">
  16 +
18 <?php if(!$servicesValidation) { ?> 17 <?php if(!$servicesValidation) { ?>
19 <?php if(!$migrate_check) { ?> 18 <?php if(!$migrate_check) { ?>
20 <h3>Services</h3> 19 <h3>Services</h3>
@@ -29,12 +28,31 @@ @@ -29,12 +28,31 @@
29 <br/> 28 <br/>
30 <?php } ?> 29 <?php } ?>
31 <p class="disclaimer"> 30 <p class="disclaimer">
32 - <?php if(WINDOWS_OS) { ?>  
33 - cd <?php echo "\"".SYSTEM_ROOT."\""; ?> <br/>  
34 - dmsctl.bat install<br/>  
35 - dmsctl.bat start  
36 - <?php } else { ?>  
37 - cd /usr/share/knowledgetree-ce<br/> 31 + <?php if(WINDOWS_OS) { ?>
  32 + <b>Using shortcuts:</b>
  33 + <br/>
  34 + [START MENU] => [Programs] => [KnowledgeTree 3.7.x] => [services]
  35 + <br/>
  36 + Click [Install Services]
  37 + <br/>
  38 + [START MENU] => [Programs] => [KnowledgeTree 3.7.x] => [services]
  39 + <br/>
  40 + Click [Start Services]
  41 + <br/>
  42 + <br/>
  43 + <b>Alternatively:</b>
  44 + <br/>
  45 + Open a command prompt and enter the following:
  46 + <br/>
  47 + cd <?php echo "\"".SYSTEM_DIR."\""; ?> <br/>
  48 + dmsctl.bat install<br/>
  49 + dmsctl.bat start
  50 + <?php } else { ?>
  51 + <?php if ($isCE) { ?>
  52 + cd /usr/share/knowledgetree-ce<br/>
  53 + <?php } else { ?>
  54 + cd /usr/share/knowledgetree<br/>
  55 + <?php } ?>
38 sudo ./dmsctl.sh start 56 sudo ./dmsctl.sh start
39 <?php } ?> 57 <?php } ?>
40 </p> 58 </p>
@@ -46,7 +64,6 @@ @@ -46,7 +64,6 @@
46 $iconFlag = "<span class='{$paths_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; 64 $iconFlag = "<span class='{$paths_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
47 $checkHeading = "<h3 style='width:35%; float:left;'>".$iconFlag."Paths and Permissions</h3>"; 65 $checkHeading = "<h3 style='width:35%; float:left;'>".$iconFlag."Paths and Permissions</h3>";
48 ?> 66 ?>
49 -<!-- <div>-->  
50 <?php if($pathsSection) { 67 <?php if($pathsSection) {
51 $details = 'Show Details'; 68 $details = 'Show Details';
52 $display = 'none'; 69 $display = 'none';
@@ -54,11 +71,6 @@ @@ -54,11 +71,6 @@
54 $details = 'Hide Details'; 71 $details = 'Hide Details';
55 $display = 'block'; 72 $display = 'block';
56 }?> 73 }?>
57 -<!-- <h3><?php //echo "<span class='{$paths_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Paths and Permissions</h3>-->  
58 - <?php if($silent) { ?>  
59 -<!-- <div id="option8" class="onclick" onclick="javascript:{w.toggleClass('paths_check', 'option8');}">Show Details</div>-->  
60 -<!-- <div class="paths_check" style="display:none">-->  
61 - <?php } ?>  
62 <?php 74 <?php
63 $pathsCheck = $checkHeading; 75 $pathsCheck = $checkHeading;
64 $pathsCheck .= "<div id='option8' class='onclick' onclick='javascript:{w.toggleClass(\"paths_check\", \"option8\");}'>"; 76 $pathsCheck .= "<div id='option8' class='onclick' onclick='javascript:{w.toggleClass(\"paths_check\", \"option8\");}'>";
@@ -67,7 +79,6 @@ @@ -67,7 +79,6 @@
67 echo $pathsCheck; 79 echo $pathsCheck;
68 ?> 80 ?>
69 <table class="description_complete"> 81 <table class="description_complete">
70 -<!-- <table class="description">-->  
71 <tr></tr> 82 <tr></tr>
72 <?php if (!empty($varDirectory)) echo '<tr>' . $varDirectory . '</tr>'; ?> 83 <?php if (!empty($varDirectory)) echo '<tr>' . $varDirectory . '</tr>'; ?>
73 <?php if (!empty($documentRoot)) echo '<tr>' . $documentRoot . '</tr>'; ?> 84 <?php if (!empty($documentRoot)) echo '<tr>' . $documentRoot . '</tr>'; ?>
@@ -80,10 +91,8 @@ @@ -80,10 +91,8 @@
80 <?php if($silent) { ?> 91 <?php if($silent) { ?>
81 </div> 92 </div>
82 <?php } ?> 93 <?php } ?>
83 -<!-- </div>-->  
84 <br/> 94 <br/>
85 <br/> 95 <br/>
86 -<!-- <div>-->  
87 <!-- Database connectivity --> 96 <!-- Database connectivity -->
88 <?php 97 <?php
89 $iconFlag = "<span class='{$database_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; 98 $iconFlag = "<span class='{$database_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
@@ -96,10 +105,7 @@ @@ -96,10 +105,7 @@
96 $details = 'Hide Details'; 105 $details = 'Hide Details';
97 $display = 'block'; 106 $display = 'block';
98 }?> 107 }?>
99 -<!-- <h3><?php //echo "<span class='{$database_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Database connectivity</h3>-->  
100 <?php if($silent) { ?> 108 <?php if($silent) { ?>
101 -<!-- <div id="option9" class="onclick" onclick="javascript:{w.toggleClass('database_check', 'option9');}">Show Details</div>-->  
102 -<!-- <div class="database_check" style="display:none">-->  
103 <?php 109 <?php
104 $databaseCheck = $checkHeading; 110 $databaseCheck = $checkHeading;
105 $databaseCheck .= "<div id='option9' class='onclick' onclick='javascript:{w.toggleClass(\"database_check\", \"option9\");}'>"; 111 $databaseCheck .= "<div id='option9' class='onclick' onclick='javascript:{w.toggleClass(\"database_check\", \"option9\");}'>";
@@ -129,10 +135,7 @@ @@ -129,10 +135,7 @@
129 $details = 'Hide Details'; 135 $details = 'Hide Details';
130 $display = 'block'; 136 $display = 'block';
131 }?> 137 }?>
132 -<!-- <h3><?php //echo "<span class='{$privileges_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Privileges</h3>-->  
133 <?php if($silent) { ?> 138 <?php if($silent) { ?>
134 -<!-- <div id="option1" class="onclick" onclick="javascript:{w.toggleClass('privileges_check', 'option1');}">Show Details</div>-->  
135 -<!-- <div class="privileges_check" style="display:none">-->  
136 <?php 139 <?php
137 $privilegesCheck = $checkHeading; 140 $privilegesCheck = $checkHeading;
138 $privilegesCheck .= "<div id='option1' class='onclick' onclick='javascript:{w.toggleClass(\"privileges_check\", \"option1\");}'>"; 141 $privilegesCheck .= "<div id='option1' class='onclick' onclick='javascript:{w.toggleClass(\"privileges_check\", \"option1\");}'>";
@@ -148,7 +151,6 @@ @@ -148,7 +151,6 @@
148 <?php if($silent) { ?> 151 <?php if($silent) { ?>
149 </div> 152 </div>
150 <?php } ?> 153 <?php } ?>
151 -<!-- </div>-->  
152 <!-- Services --> 154 <!-- Services -->
153 <br/> 155 <br/>
154 <!-- <br/>--> 156 <!-- <br/>-->
@@ -160,46 +162,18 @@ @@ -160,46 +162,18 @@
160 <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div> 162 <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div>
161 <div class="services_check" style="display:none"> 163 <div class="services_check" style="display:none">
162 <?php } ?> 164 <?php } ?>
163 -<!-- <table class="description_complete">-->  
164 <table class="description"> 165 <table class="description">
165 <tr> 166 <tr>
166 <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td> 167 <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
167 <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td> 168 <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
168 - <?php if ($LuceneStatus != 'tick') { ?>  
169 - <td>  
170 - <?php if (AJAX) { ?>  
171 -<!-- <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>-->  
172 - <?php } else { ?>  
173 -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->  
174 - <?php } ?>  
175 - </td>  
176 - <?php } ?>  
177 </tr> 169 </tr>
178 <tr> 170 <tr>
179 <td> <?php echo "<span class='{$SchedulerStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td> 171 <td> <?php echo "<span class='{$SchedulerStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
180 <td> Scheduler Service <?php if ($SchedulerStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td> 172 <td> Scheduler Service <?php if ($SchedulerStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
181 - <?php if ($SchedulerStatus != 'tick') { ?>  
182 - <td>  
183 - <?php if (AJAX) { ?>  
184 -<!-- <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>-->  
185 - <?php } else { ?>  
186 -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->  
187 - <?php } ?>  
188 - </td>  
189 - <?php } ?>  
190 </tr> 173 </tr>
191 <tr> 174 <tr>
192 <td> <?php echo "<span class='{$OpenOfficeStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td> 175 <td> <?php echo "<span class='{$OpenOfficeStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
193 <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td> 176 <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
194 - <?php if ($OpenOfficeStatus != 'tick') { ?>  
195 - <td>  
196 - <?php if (AJAX) { ?>  
197 -<!-- <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>-->  
198 - <?php } else { ?>  
199 -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->  
200 - <?php } ?>  
201 - </td>  
202 - <?php } ?>  
203 </tr> 177 </tr>
204 </table> 178 </table>
205 <?php if($silent) { ?> 179 <?php if($silent) { ?>
@@ -208,14 +182,22 @@ @@ -208,14 +182,22 @@
208 </div> 182 </div>
209 <?php } ?> 183 <?php } ?>
210 <?php } ?> 184 <?php } ?>
  185 + <div class="connect">
  186 + <a class="twitter" href="http://www.twitter.com/knowledgetreesw" style="color:#FFFFFF;" target="_blank">
  187 + <?php echo $html->image('twitterbutton.png'); ?>
  188 + </a>
  189 + <br/>
  190 + <br/>
  191 + <a class="facebook" href="http://www.facebook.com/pages/KnowledgeTree-Document-Management-Made-Simple/59248880725" style="color:#FFFFFF;" target="_blank">
  192 + <?php echo $html->image('facebookbutton.png'); ?>
  193 + </a>
  194 + </div>
211 </div> 195 </div>
212 <?php 196 <?php
213 $script = $_SERVER['SCRIPT_NAME']; 197 $script = $_SERVER['SCRIPT_NAME'];
214 $file_system_root = $_SERVER['DOCUMENT_ROOT']; 198 $file_system_root = $_SERVER['DOCUMENT_ROOT'];
215 $host = $_SERVER['SERVER_NAME']; 199 $host = $_SERVER['SERVER_NAME'];
216 $port = $_SERVER['SERVER_PORT']; 200 $port = $_SERVER['SERVER_PORT'];
217 - //$ssl_enabled = isset($_SERVER['HTTPS']) ? (strtolower($_SERVER['HTTPS']) === 'on' ? 'yes' : 'no') : 'no';  
218 -  
219 $pos = strpos($script, '/setup/wizard/'); 201 $pos = strpos($script, '/setup/wizard/');
220 $root_url = substr($script, 0, $pos); 202 $root_url = substr($script, 0, $pos);
221 if($port == '') 203 if($port == '')
@@ -224,9 +206,11 @@ @@ -224,9 +206,11 @@
224 $redirect = "http://".$_SERVER['SERVER_NAME'].":$port".$root_url."/admin.php"; 206 $redirect = "http://".$_SERVER['SERVER_NAME'].":$port".$root_url."/admin.php";
225 ?> 207 ?>
226 <?php if($migrate_check) { ?> 208 <?php if($migrate_check) { ?>
227 - <a href="../upgrade/index.php" class="back button_next" style="width:30px;" onclick="javascript:{w.clearSessions();}">Next</a> 209 +<!-- <a href="../upgrade/index.php" class="back button_next" style="width:30px;" onclick="javascript:{w.clearSessions();}">Next</a>-->
  210 + <input type="submit" name="Upgrade" value="Next" class="button_next"/>
228 <?php } else { ?> 211 <?php } else { ?>
229 - <a href="../../login.php" class="back button_next" style="width:50px;" onclick="javascript:{w.clearSessions();}">Finish</a> 212 +<!-- <a href="../../login.php" class="back button_next" style="width:50px;" onclick="javascript:{w.clearSessions();}">Finish</a>-->
  213 + <input type="submit" name="Next" value="Finish" class="button_next"/>
230 <?php } ?> 214 <?php } ?>
231 </form> 215 </form>
232 <?php if (AJAX) { echo $html->js('form.js'); } ?> 216 <?php if (AJAX) { echo $html->js('form.js'); } ?>
233 \ No newline at end of file 217 \ No newline at end of file
setup/wizard/templates/configuration.tpl
@@ -61,19 +61,8 @@ @@ -61,19 +61,8 @@
61 <td> <div id="tooltips" title="Absolute path to KnowledgeTree Source directory">&nbsp;</div> </td> 61 <td> <div id="tooltips" title="Absolute path to KnowledgeTree Source directory">&nbsp;</div> </td>
62 <td><input name='file_system_root' id='file_system_root' size='<?php echo $input_size; ?>' value='<?php echo $server['file_system_root']['value']; ?>' /></td> 62 <td><input name='file_system_root' id='file_system_root' size='<?php echo $input_size; ?>' value='<?php echo $server['file_system_root']['value']; ?>' /></td>
63 </tr> 63 </tr>
64 - <tr>  
65 - <td> <label for='yes'>Do you have SSL Enabled?: </label> </td>  
66 - <td> <div id="tooltips" title="Whether or not you have SSL installed">&nbsp;</div> </td>  
67 - <td>  
68 - <label for='yes'>Yes</label>  
69 - <input class="radio" type='radio' name='ssl_enabled' id='yes' value='yes' <?php echo $server['ssl_enabled']['value'] == 'yes' ? 'CHECKED' : ''; ?> />  
70 - &nbsp;&nbsp;&nbsp;  
71 - <label for='no'>No</label>  
72 - <input class="radio" type='radio' name='ssl_enabled' id='no' value='no' <?php echo $server['ssl_enabled']['value'] == 'no' ? 'CHECKED' : ''; ?> />  
73 - </td>  
74 - </tr>  
75 </table> 64 </table>
76 - 65 + <input type='hidden' name='ssl_enabled' id='no' value='no' checked='' />
77 <h3><?php echo "<span class='{$paths_perms}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Paths and Permissions</h3> 66 <h3><?php echo "<span class='{$paths_perms}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Paths and Permissions</h3>
78 <?php if($silent) { ?> 67 <?php if($silent) { ?>
79 <div id="option7" class="onclick" onclick="javascript:{w.toggleClass('paths_perms', 'option7');}">Show Details</div> 68 <div id="option7" class="onclick" onclick="javascript:{w.toggleClass('paths_perms', 'option7');}">Show Details</div>
setup/wizard/templates/configuration_confirm.tpl
@@ -49,11 +49,6 @@ @@ -49,11 +49,6 @@
49 <td> <div id="tooltips" title="Absolute path to KnowledgeTree Source directory">&nbsp;</div> </td> 49 <td> <div id="tooltips" title="Absolute path to KnowledgeTree Source directory">&nbsp;</div> </td>
50 <td><?php echo $server['file_system_root']['value']; ?></td> 50 <td><?php echo $server['file_system_root']['value']; ?></td>
51 </tr> 51 </tr>
52 - <tr>  
53 - <td>Do you have SSL Enabled?: </td>  
54 - <td> <div id="tooltips" title="Whether or not you have SSL installed">&nbsp;</div> </td>  
55 - <td><?php echo $server['ssl_enabled']['value']; ?></td>  
56 - </tr>  
57 </table> 52 </table>
58 53
59 <h3>Paths and Permissions</h3> 54 <h3>Paths and Permissions</h3>
setup/wizard/templates/database.tpl
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <div id="database" class="step1" style="display:block;"> 11 <div id="database" class="step1" style="display:block;">
12 <div class="description"> 12 <div class="description">
13 This step configures the connection to the database server and installs the database. The details for an administrative <br/> 13 This step configures the connection to the database server and installs the database. The details for an administrative <br/>
14 - user on the database server are required in order to be able to configure and install the installation database. 14 + user on the database server are required in order to be able to configure and install the KnowledgeTree database.
15 </div> 15 </div>
16 <div id="step_content_<?php echo $step_name; ?>" class="step"> 16 <div id="step_content_<?php echo $step_name; ?>" class="step">
17 <!-- Check For immediate Errors --> 17 <!-- Check For immediate Errors -->
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 <table> 63 <table>
64 <tr> 64 <tr>
65 <td width="10px"> <label for='dhost'>Host: </label> </td> 65 <td width="10px"> <label for='dhost'>Host: </label> </td>
66 - <td width="205px"> <div id="tooltips" title="The address of the server where the database is located, if different to the current server">&nbsp;</div> </td> 66 + <td width="10px"> <div id="tooltips" title="The address of the server where the database is located, if different to the current server">&nbsp;</div> </td>
67 <td width="10px"> <input type="text" value="<?php echo $dhost?>" id="dhost" name="dhost" size='<?php echo $input_size; ?>' class="textinput"/> </td> 67 <td width="10px"> <input type="text" value="<?php echo $dhost?>" id="dhost" name="dhost" size='<?php echo $input_size; ?>' class="textinput"/> </td>
68 </tr> 68 </tr>
69 <tr> 69 <tr>
setup/wizard/templates/dependencies.tpl
@@ -20,16 +20,13 @@ @@ -20,16 +20,13 @@
20 <?php if($errors) { ?> 20 <?php if($errors) { ?>
21 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 21 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
22 <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. </span> 22 <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. </span>
23 - <!--<br/>-->  
24 <?php } elseif ($warnings) { ?> 23 <?php } elseif ($warnings) { ?>
25 <span class='cross_orange'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 24 <span class='cross_orange'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
26 <span class='warning_message'>Not all optional dependencies required by KnowledgeTree have been met but you will be able to continue.</span> 25 <span class='warning_message'>Not all optional dependencies required by KnowledgeTree have been met but you will be able to continue.</span>
27 - <!--<br/>-->  
28 <?php } ?> 26 <?php } ?>
29 <?php 27 <?php
30 if($errors || $warnings) { 28 if($errors || $warnings) {
31 ?> 29 ?>
32 -<!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->  
33 <a href="http://wiki.knowledgetree.com/Web_Based_Installer#PHP_Dependencies" target="_blank" class="description_click">Click here for help on overcoming dependency issues</span></a> 30 <a href="http://wiki.knowledgetree.com/Web_Based_Installer#PHP_Dependencies" target="_blank" class="description_click">Click here for help on overcoming dependency issues</span></a>
34 <?php } ?> 31 <?php } ?>
35 <!--Content--> 32 <!--Content-->
@@ -38,10 +35,6 @@ @@ -38,10 +35,6 @@
38 $iconFlag = "<span class='{$php}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; 35 $iconFlag = "<span class='{$php}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
39 $checkHeading = "<h3 style='width:30%; float:left'>".$iconFlag."PHP Version Check</h3>"; 36 $checkHeading = "<h3 style='width:30%; float:left'>".$iconFlag."PHP Version Check</h3>";
40 ?> 37 ?>
41 -<!-- <h3>-->  
42 - <?php  
43 -// echo "<span class='{$php}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";  
44 - ?>  
45 <!-- PHP Version Check</h3>--> 38 <!-- PHP Version Check</h3>-->
46 <?php if($silent) { ?> 39 <?php if($silent) { ?>
47 <?php if($versionSection) { 40 <?php if($versionSection) {
@@ -58,30 +51,22 @@ @@ -58,30 +51,22 @@
58 $phpVersionCheck .= $details."</div>"; 51 $phpVersionCheck .= $details."</div>";
59 $phpVersionCheck .= "<div class='php_details dependency_details' style='display:".$display.";'>"; 52 $phpVersionCheck .= "<div class='php_details dependency_details' style='display:".$display.";'>";
60 ?> 53 ?>
61 -<!-- <div id="option1" class="onclick" onclick="javascript:{w.toggleClass('php_details', 'option1');}"> <?php //echo $details; ?></div>-->  
62 -<!-- <div class="php_details" style="display:<?php //echo $display; ?>">-->  
63 <?php } ?> 54 <?php } ?>
64 <?php 55 <?php
65 $space = "<p class='space'>&nbsp;</p>"; 56 $space = "<p class='space'>&nbsp;</p>";
66 $phpVersionCheck .= "<p class='description dependencies'>Your version of PHP must be between 5.0 and 5.2 to run optimally. Versions that are 5.3 or higher are not recommended.</p>"; 57 $phpVersionCheck .= "<p class='description dependencies'>Your version of PHP must be between 5.0 and 5.2 to run optimally. Versions that are 5.3 or higher are not recommended.</p>";
67 ?> 58 ?>
68 -<!-- <p class="description">  
69 - Your version of PHP must be between 5.0 and 5.2 to run optimally. Versions that are 5.3 or higher are not recommended.  
70 - </p>-->  
71 <?php $phpVersionCheck .= "<span class='{$version['class']}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>{$version['version']}"; ?> 59 <?php $phpVersionCheck .= "<span class='{$version['class']}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>{$version['version']}"; ?>
72 <?php //echo "<span class='{$version['class']}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>{$version['version']}"; ?> 60 <?php //echo "<span class='{$version['class']}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>{$version['version']}"; ?>
73 <?php if($version['class'] != 'tick') { ?> 61 <?php if($version['class'] != 'tick') { ?>
74 <?php if (AJAX) { ?> 62 <?php if (AJAX) { ?>
75 <?php $phpVersionCheck .= "<a href='#' class='refresh' onclick='w.refresh('dependencies')'>Refresh</a>"; ?> 63 <?php $phpVersionCheck .= "<a href='#' class='refresh' onclick='w.refresh('dependencies')'>Refresh</a>"; ?>
76 -<!-- <a href="#" class="refresh" onclick="w.refresh('dependencies')">Refresh</a>-->  
77 <?php } else { ?> 64 <?php } else { ?>
78 <?php $phpVersionCheck .= "<a href='javascript:this.location.reload();' class='refresh'>Refresh</a>"; ?> 65 <?php $phpVersionCheck .= "<a href='javascript:this.location.reload();' class='refresh'>Refresh</a>"; ?>
79 -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->  
80 <?php } ?> 66 <?php } ?>
81 <?php } ?> 67 <?php } ?>
82 <?php if($silent) { ?> 68 <?php if($silent) { ?>
83 <?php $phpVersionCheck .= "</div>"; ?> 69 <?php $phpVersionCheck .= "</div>"; ?>
84 -<!-- </div>-->  
85 <?php } ?> 70 <?php } ?>
86 <?php echo $phpVersionCheck; ?> 71 <?php echo $phpVersionCheck; ?>
87 <br /> 72 <br />
@@ -89,7 +74,6 @@ @@ -89,7 +74,6 @@
89 $iconFlag = "<span class='{$php_ext}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; 74 $iconFlag = "<span class='{$php_ext}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
90 $checkHeading = "<h3 style='width:30%; float:left'>".$iconFlag."PHP Extensions</h3>"; 75 $checkHeading = "<h3 style='width:30%; float:left'>".$iconFlag."PHP Extensions</h3>";
91 ?> 76 ?>
92 -<!-- <h3><?php //echo "<span class='{$php_ext}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>PHP Extensions</h3>-->  
93 <?php 77 <?php
94 if($silent) { ?> 78 if($silent) { ?>
95 <?php if($extensionSection) { 79 <?php if($extensionSection) {
@@ -106,15 +90,10 @@ @@ -106,15 +90,10 @@
106 $phpExtensionCheck .= $details."</div>"; 90 $phpExtensionCheck .= $details."</div>";
107 $phpExtensionCheck .= "<div class='php_ext_details dependency_details' style='display:".$display.";'>"; 91 $phpExtensionCheck .= "<div class='php_ext_details dependency_details' style='display:".$display.";'>";
108 ?> 92 ?>
109 -<!-- <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('php_ext_details', 'option2');}"><?php //echo $details; ?></div>-->  
110 -<!-- <div class="php_ext_details" style="display:<?php //echo $display; ?>">-->  
111 <?php } ?> 93 <?php } ?>
112 <?php 94 <?php
113 $phpExtensionCheck .= "<p class='description dependencies'>The extensions shown in red below are required for KnowledgeTree to run optimally. Items shown in orange are optional, but recommended.</p>"; 95 $phpExtensionCheck .= "<p class='description dependencies'>The extensions shown in red below are required for KnowledgeTree to run optimally. Items shown in orange are optional, but recommended.</p>";
114 ?> 96 ?>
115 -<!-- <p class="description">  
116 - The extensions shown in red below are required for KnowledgeTree to run optimally. Items shown in orange are optional, but recommended.  
117 - </p>-->  
118 <br/> 97 <br/>
119 <?php echo $phpExtensionCheck; ?> 98 <?php echo $phpExtensionCheck; ?>
120 <table class="description"> 99 <table class="description">
@@ -164,7 +143,6 @@ @@ -164,7 +143,6 @@
164 $iconFlag = "<span class='{$php_con}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; 143 $iconFlag = "<span class='{$php_con}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
165 $checkHeading = "<h3 style='width:30%; float:left'>".$iconFlag."PHP Configurations</h3>"; 144 $checkHeading = "<h3 style='width:30%; float:left'>".$iconFlag."PHP Configurations</h3>";
166 ?> 145 ?>
167 -<!-- <h3><?php //echo "<span class='{$php_con}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>PHP Configuration</h3>-->  
168 <?php 146 <?php
169 if($silent) { ?> 147 if($silent) { ?>
170 <?php if($configurationSection) { 148 <?php if($configurationSection) {
@@ -181,15 +159,10 @@ @@ -181,15 +159,10 @@
181 $phpDirectivesCheck .= $details."</div>"; 159 $phpDirectivesCheck .= $details."</div>";
182 $phpDirectivesCheck .= "<div class='php_con_details dependency_details' style='display:".$display.";'>"; 160 $phpDirectivesCheck .= "<div class='php_con_details dependency_details' style='display:".$display.";'>";
183 ?> 161 ?>
184 -<!-- <div id="option3" class="onclick" onclick="javascript:{w.toggleClass('php_con_details', 'option3');}"><?php //echo $details; ?></div>-->  
185 -<!-- <div class="php_con_details" style="display:<?php //echo $display; ?>">-->  
186 <?php } ?> 162 <?php } ?>
187 <?php 163 <?php
188 $phpDirectivesCheck .= "<p class='description dependencies'>The configurations shown in red below are required for KnowledgeTree to run optimally. Items shown in orange are optional, but recommended.</p>"; 164 $phpDirectivesCheck .= "<p class='description dependencies'>The configurations shown in red below are required for KnowledgeTree to run optimally. Items shown in orange are optional, but recommended.</p>";
189 ?> 165 ?>
190 -<!-- <p class="description">-->  
191 -<!-- The configurations shown in red below are required for KnowledgeTree to run optimally. Items shown in orange are optional, but recommended.-->  
192 -<!-- </p>-->  
193 <br/> 166 <br/>
194 <?php echo $phpDirectivesCheck; ?> 167 <?php echo $phpDirectivesCheck; ?>
195 <table class="description"> 168 <table class="description">
setup/wizard/templates/install.tpl
1 <form id="registration_install_complete" action="index.php?step_name=<?php echo $step_name; ?>" method="post"> 1 <form id="registration_install_complete" action="index.php?step_name=<?php echo $step_name; ?>" method="post">
2 <p class="title">Finalizing System Installation</p> 2 <p class="title">Finalizing System Installation</p>
3 - <div id="step_content_<?php echo $step_name; ?>" class="step"> 3 + <?php if($ce_check) { ?>
  4 + <div id="step_content_<?php echo $step_name; ?>" class="step">
  5 + <?php } else { ?>
  6 + <div id="step_content" class="step">
  7 + <?php } ?>
4 <p class="empty_space" style="font-size:11pt;"> The wizard will now complete the installation and run a final check on your system. </p> 8 <p class="empty_space" style="font-size:11pt;"> The wizard will now complete the installation and run a final check on your system. </p>
5 <!-- <br/>--> 9 <!-- <br/>-->
  10 +<?php if($ce_check) { ?>
6 <p class="empty_space" style="font-size:11pt;" id="left_space"> 11 <p class="empty_space" style="font-size:11pt;" id="left_space">
7 We would greatly appreciate it if you would allow us to collect anonymous usage statistics to help us provide a better quality product. 12 We would greatly appreciate it if you would allow us to collect anonymous usage statistics to help us provide a better quality product.
8 <br/> 13 <br/>
@@ -13,6 +18,21 @@ @@ -13,6 +18,21 @@
13 <!-- <br/><br/><br/><br/>--> 18 <!-- <br/><br/><br/><br/>-->
14 <p> <input type='checkbox' name='call_home' value='enable' checked style="float:left;"/>&nbsp;&nbsp; 19 <p> <input type='checkbox' name='call_home' value='enable' checked style="float:left;"/>&nbsp;&nbsp;
15 <label for='call_home'>Help to improve KnowledgeTree by providing anonymous usage statistics</label></p> 20 <label for='call_home'>Help to improve KnowledgeTree by providing anonymous usage statistics</label></p>
  21 +<?php } else { ?>
  22 + <p class="empty_space" style="font-size:11pt;">
  23 + We would greatly appreciate it if you would allow us to collect anonymous usage statistics to help us provide a better quality product.
  24 + <br/>
  25 + <br/>
  26 + The information includes a unique identification number, number of users you have created, your operating system type and your IP address. Your privacy is protected by the <a href="http://www.knowledgetree.com/about/legal" target="_blank">KnowledgeTree Privacy and Data Protection Agreements.</a>
  27 + </p>
  28 +<!-- <div class="demo"><?php //echo $html->image('greenit.jpg', array('style'=>'padding-left: 35px;')); ?></div>-->
  29 + <br/><br/><br/><br/><br/><br/><br/><br/>
  30 +
  31 +<p>
  32 + <input type='checkbox' name='call_home' value='enable' checked style="float:left;"/>&nbsp;&nbsp;
  33 + <label for='call_home'>Help to improve KnowledgeTree by providing anonymous usage statistics</label>
  34 +</p>
  35 +<?php } ?>
16 </div> 36 </div>
17 <input type="submit" name="Previous" value="Previous" class="button_previous"/> 37 <input type="submit" name="Previous" value="Previous" class="button_previous"/>
18 <input type="submit" name="Install" value="Install" class="button_next"/> 38 <input type="submit" name="Install" value="Install" class="button_next"/>
setup/wizard/templates/installtype.tpl
@@ -7,16 +7,18 @@ @@ -7,16 +7,18 @@
7 <table> 7 <table>
8 <tr> 8 <tr>
9 <td> <input type="radio" name="installtype" value="Clean Install" checked id="clean" /> </td> 9 <td> <input type="radio" name="installtype" value="Clean Install" checked id="clean" /> </td>
10 - <td> <label for="clean"><b>Install KnowledgeTree (Default)</b> <br/>Install KnowledgeTree for the first time</label> </td> 10 + <td> <label for="clean"><b>Install KnowledgeTree (Default)</b> <br/>Choose this option if you are installing KnowledgeTree for the first time</label> </td>
11 </tr> 11 </tr>
12 <tr> 12 <tr>
13 <td> <input type="radio" name="installtype" value="Upgrade Installation" id="migrate" /> </td> 13 <td> <input type="radio" name="installtype" value="Upgrade Installation" id="migrate" /> </td>
14 - <td> <label for="migrate"><b>Upgrade KnowledgeTree Stack Install</b> <br/>Migrate KnowledgeTree to the new Zend Server Stack and then perform the upgrade</label></td> 14 + <td> <label for="migrate"><b>Upgrade KnowledgeTree Stack Install</b> <br/>Choose this option if you are upgrading from a previous version of the KnowledgeTree Stack</label></td>
15 </tr> 15 </tr>
  16 + <?php if ($isCE) { ?>
16 <tr> 17 <tr>
17 <td> <input type="radio" name="installtype" value="Upgrade Only" id="upgrade" /> </td> 18 <td> <input type="radio" name="installtype" value="Upgrade Only" id="upgrade" /> </td>
18 - <td> <label for="upgrade"><b>Upgrade KnowledgeTree Source Only Install</b> <br/> Upgrade from a Source Only installation of KnowledgeTree</label></td> 19 + <td> <label for="upgrade"><b>Upgrade KnowledgeTree Source Only Install</b> <br/>Choose this option if you are upgrading from a previous Source Only installation of KnowledgeTree</label></td>
19 </tr> 20 </tr>
  21 + <?php } ?>
20 </table> 22 </table>
21 </div> 23 </div>
22 <input type="submit" name="Previous" value="Previous" class="button_previous"/> 24 <input type="submit" name="Previous" value="Previous" class="button_previous"/>
setup/wizard/templates/license.tpl
@@ -4,9 +4,8 @@ @@ -4,9 +4,8 @@
4 foreach($errors as $k=>$e) { 4 foreach($errors as $k=>$e) {
5 echo "<span class='error'>".$e."</span>"; 5 echo "<span class='error'>".$e."</span>";
6 } 6 }
7 - //print_r($errors);  
8 }?> 7 }?>
9 -<p class="description"> 8 +<p class="description_1">
10 Please read and accept the license agreement below before continuing with the setup. 9 Please read and accept the license agreement below before continuing with the setup.
11 </p> 10 </p>
12 11
setup/wizard/templates/welcome.tpl
@@ -7,6 +7,5 @@ @@ -7,6 +7,5 @@
7 <div class="demo"><?php //echo $html->image('kt_browse.png'); ?> </div> 7 <div class="demo"><?php //echo $html->image('kt_browse.png'); ?> </div>
8 </div> 8 </div>
9 <input type="submit" name="Next" value="Next" class="button_next"/> 9 <input type="submit" name="Next" value="Next" class="button_next"/>
10 -<!-- <input type="submit" name="Migrate" value="Migrate" class="button_next"/>-->  
11 </form> 10 </form>
12 <?php if (AJAX) { echo $html->js('form.js'); } ?> 11 <?php if (AJAX) { echo $html->js('form.js'); } ?>
13 \ No newline at end of file 12 \ No newline at end of file
setup/wizard/templates/wizard.tpl
@@ -11,6 +11,8 @@ @@ -11,6 +11,8 @@
11 <?php echo $html->css('wizard.css'); ?> 11 <?php echo $html->css('wizard.css'); ?>
12 <?php if(AGENT == "IE6") echo $html->css('ie6.css'); ?> 12 <?php if(AGENT == "IE6") echo $html->css('ie6.css'); ?>
13 <?php if(AGENT == "IE7") echo $html->css('ie7.css'); ?> 13 <?php if(AGENT == "IE7") echo $html->css('ie7.css'); ?>
  14 + <?php if(AGENT == "IE8") echo $html->css('ie8.css'); ?>
  15 + <?php if(INSTALL_TYPE == "community") echo $html->css('community.css'); ?>
14 <meta http-equiv=Content-Type content="text/html; charset=utf-8"> 16 <meta http-equiv=Content-Type content="text/html; charset=utf-8">
15 </head> 17 </head>
16 <body onload=""> 18 <body onload="">
sql/mysql/install/data.sql
@@ -1767,14 +1767,15 @@ INSERT INTO `upgrades` VALUES @@ -1767,14 +1767,15 @@ INSERT INTO `upgrades` VALUES
1767 (223, 'sql*3.6.2*0*3.6.2/data_types.sql', 'Add large text and date fields','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'), 1767 (223, 'sql*3.6.2*0*3.6.2/data_types.sql', 'Add large text and date fields','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'),
1768 (224,'upgrade*3.6.2*99*upgrade3.6.2','Upgrade from version 3.6.1 to 3.6.2','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'), 1768 (224,'upgrade*3.6.2*99*upgrade3.6.2','Upgrade from version 3.6.1 to 3.6.2','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'),
1769 (225,'upgrade*3.6.3*99*upgrade3.6.3','Upgrade from version 3.6.2 to 3.6.3','2009-06-01 00:00:00',1,'upgrade*3.6.3*99*upgrade3.6.3'), 1769 (225,'upgrade*3.6.3*99*upgrade3.6.3','Upgrade from version 3.6.2 to 3.6.3','2009-06-01 00:00:00',1,'upgrade*3.6.3*99*upgrade3.6.3'),
1770 -(226,'sql*3.7.0-1*0*3.7.0-1/plugins_admin.sql','Database upgrade to version 3.7.0-1: Plugins admin','2009-09-01 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1771 -(227,'sql*3.7.0-1*0*3.7.0-1/config_settings.sql','Database upgrade to version 3.7.0-1: Config settings','2009-09-01 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1772 -(228,'sql*3.7.0-1*0*3.7.0-1/plugin_helper.sql','Database upgrade to version 3.7.0-1: Plugin helper','2009-09-01 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1773 -(229,'sql*3.7.0-1*0*3.7.0-1/call_home_task.sql','Database upgrade to version 3.7.0-1: Call home task','2009-09-01 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1774 -(230,'sql*3.7.0-1*0*3.7.0-1/hide_zip_config.sql','Database upgrade to version 3.7.0-1: Hide zip config','2009-09-01 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1775 -(231,'sql*3.7.0-1*0*3.7.0-1/mime_extractors_reset.sql','Database upgrade to version 3.7.0-1: Mime extractors reset','2009-09-01 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1776 -(232,'upgrade*3.7.0-1*99*upgrade3.7.0-1','Upgrade from version 3.6.3 to 3.7.0-1','2009-11-13 00:00:00',1,'upgrade*3.7.0-1*99*upgrade3.7.0-1'),  
1777 -(233,'upgrade*3.7.0.2*99*upgrade3.7.0.2','Upgrade from version 3.7.0-1 to 3.7.0.2','2009-11-19 00:00:00',1,'upgrade*3.7.0.2*99*upgrade3.7.0.2'); 1770 +(226,'sql*3.7.0.1*0*3.7.0.1/plugins_admin.sql','Database upgrade to version 3.7.0.1: Plugins admin','2009-09-01 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1771 +(227,'sql*3.7.0.1*0*3.7.0.1/config_settings.sql','Database upgrade to version 3.7.0.1: Config settings','2009-09-01 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1772 +(228,'sql*3.7.0.1*0*3.7.0.1/plugin_helper.sql','Database upgrade to version 3.7.0.1: Plugin helper','2009-09-01 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1773 +(229,'sql*3.7.0.1*0*3.7.0.1/call_home_task.sql','Database upgrade to version 3.7.0.1: Call home task','2009-09-01 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1774 +(230,'sql*3.7.0.1*0*3.7.0.1/hide_zip_config.sql','Database upgrade to version 3.7.0.1: Hide zip config','2009-09-01 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1775 +(231,'sql*3.7.0.1*0*3.7.0.1/mime_extractors_reset.sql','Database upgrade to version 3.7.0.1: Mime extractors reset','2009-09-01 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1776 +(232,'upgrade*3.7.0.1*99*upgrade3.7.0.1','Upgrade from version 3.6.3 to 3.7.0.1','2009-11-13 00:00:00',1,'upgrade*3.7.0.1*99*upgrade3.7.0.1'),
  1777 +(233,'sql*3.7.0.2*0*3.7.0.2/processor_queue.sql','Database upgrade to version 3.7.0.1: Processor Queue','2009-09-01 00:00:00',1,'upgrade*3.7.0.2*99*upgrade3.7.0.2'),
  1778 +(234,'upgrade*3.7.0.2*99*upgrade3.7.0.2','Upgrade from version 3.7.0.1 to 3.7.0.2','2009-11-19 00:00:00',1,'upgrade*3.7.0.2*99*upgrade3.7.0.2');
1778 /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */; 1779 /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */;
1779 UNLOCK TABLES; 1780 UNLOCK TABLES;
1780 1781
sql/mysql/install/structure.sql
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 -- KnowledgeTree Community Edition 4 -- KnowledgeTree Community Edition
5 -- Document Management Made Simple 5 -- Document Management Made Simple
6 -- Copyright (C) 2008, 2009 KnowledgeTree Inc. 6 -- Copyright (C) 2008, 2009 KnowledgeTree Inc.
7 --- 7 +--
8 -- 8 --
9 -- This program is free software; you can redistribute it and/or modify it under 9 -- This program is free software; you can redistribute it and/or modify it under
10 -- the terms of the GNU General Public License version 3 as published by the 10 -- the terms of the GNU General Public License version 3 as published by the
@@ -1327,6 +1327,20 @@ CREATE TABLE `plugins` ( @@ -1327,6 +1327,20 @@ CREATE TABLE `plugins` (
1327 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 1327 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1328 1328
1329 -- 1329 --
  1330 +-- Table structure for table `process_queue`
  1331 +--
  1332 +
  1333 +CREATE table `process_queue` (
  1334 + `document_id` int(11) NOT NULL,
  1335 + `date_added` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  1336 + `date_processed` timestamp,
  1337 + `status_msg` mediumtext,
  1338 + `process_type` varchar(20),
  1339 + PRIMARY KEY (`document_id`),
  1340 + CONSTRAINT `process_queue_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
  1341 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  1342 +
  1343 +--
1330 -- Table structure for table `role_allocations` 1344 -- Table structure for table `role_allocations`
1331 -- 1345 --
1332 1346
sql/mysql/upgrade/3.7.0-1/call_home_task.sql renamed to sql/mysql/upgrade/3.7.0.1/call_home_task.sql
sql/mysql/upgrade/3.7.0-1/config_settings.sql renamed to sql/mysql/upgrade/3.7.0.1/config_settings.sql
1 INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit) 1 INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit)
2 -VALUES ('urls', 'Internal Var Directory', 'The path to the internal var directory that must sit within the web root', 'internalVarDirectory', 'default', '${fileSystemRoot}/var', 'string', NULL, 0);  
3 -  
4 -INSERT INTO `config_settings` (group_name, display_name, description, item, value, default_value, type, options, can_edit)  
5 -VALUES ('externalBinary', 'convert', 'The path to the ImageMagick "convert" binary', 'convertPath', 'default', 'convert', 'string', NULL, 1);  
6 \ No newline at end of file 2 \ No newline at end of file
  3 +VALUES ('urls', 'Internal Var Directory', 'The path to the internal var directory that must sit within the web root', 'internalVarDirectory', 'default', '${fileSystemRoot}/var', 'string', NULL, 0);
7 \ No newline at end of file 4 \ No newline at end of file
sql/mysql/upgrade/3.7.0-1/hide_zip_config.sql renamed to sql/mysql/upgrade/3.7.0.1/hide_zip_config.sql
sql/mysql/upgrade/3.7.0-1/mime_extractors_reset.sql renamed to sql/mysql/upgrade/3.7.0.1/mime_extractors_reset.sql
sql/mysql/upgrade/3.7.0-1/plugin_helper.sql renamed to sql/mysql/upgrade/3.7.0.1/plugin_helper.sql
sql/mysql/upgrade/3.7.0-1/plugins_admin.sql renamed to sql/mysql/upgrade/3.7.0.1/plugins_admin.sql
sql/mysql/upgrade/3.7.0.2/processor_queue.sql 0 → 100644
  1 +--
  2 +-- Table structure for table `process_queue`
  3 +--
  4 +
  5 +CREATE table `process_queue` (
  6 + `document_id` int(11) NOT NULL,
  7 + `date_added` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  8 + `date_processed` timestamp,
  9 + `status_msg` mediumtext,
  10 + `process_type` varchar(20),
  11 + PRIMARY KEY (`document_id`),
  12 + CONSTRAINT `process_queue_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
  13 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
templates/ktcore/principals/about.smarty
@@ -5,8 +5,6 @@ @@ -5,8 +5,6 @@
5 {if ($smallVersion !== 'Community Edition')} 5 {if ($smallVersion !== 'Community Edition')}
6 {i18n}All rights reserved.{/i18n}<br> 6 {i18n}All rights reserved.{/i18n}<br>
7 {/if} 7 {/if}
8 -  
9 -{i18n}.{/i18n}  
10 <br> 8 <br>
11 {if ($smallVersion == 'Community Edition')} 9 {if ($smallVersion == 'Community Edition')}
12 {i18n}This program is free software and published under the <a href=" http://www.gnu.org/licenses/">GNU General Public License version 3</a>{/i18n}<br><br> 10 {i18n}This program is free software and published under the <a href=" http://www.gnu.org/licenses/">GNU General Public License version 3</a>{/i18n}<br><br>
@@ -31,143 +29,55 @@ @@ -31,143 +29,55 @@
31 <li><a href="http://people.knowledgetree.com/">Blogs</a>: See what the KnowledgeTree team have to say</li> 29 <li><a href="http://people.knowledgetree.com/">Blogs</a>: See what the KnowledgeTree team have to say</li>
32 </ul> 30 </ul>
33 </p> 31 </p>
  32 +<br/>
34 <p> 33 <p>
35 <strong>Thanks to the following contributors for helping us with code contributions and testing...</strong></p> 34 <strong>Thanks to the following contributors for helping us with code contributions and testing...</strong></p>
36 -<ul>  
37 - <li>  
38 - Fu Bin  
39 - </li>  
40 - <li>  
41 - Blackhold  
42 - </li>  
43 - <li>  
44 - Chris Buechler  
45 - </li>  
46 - <li>  
47 - Guillaume Dufloux  
48 - </li>  
49 - <li>  
50 - David Alfonso Faspar  
51 - </li>  
52 - <li>  
53 - Ruud Feringa  
54 - </li>  
55 - <li>  
56 - Hil&aacute;rio Fernandes  
57 - </li>  
58 - <li>  
59 - William Hawkins  
60 - </li>  
61 - <li>  
62 - Lody Hoekstra  
63 - </li>  
64 - <li>  
65 - Kenny Horan  
66 - </li>  
67 - <li>  
68 - Artur Kiwa  
69 - </li>  
70 - <li>  
71 - Michael Knight  
72 - </li>  
73 - <li>  
74 - Jeongkyu Kim  
75 - </li>  
76 - <li>  
77 - Rogerio Kohler  
78 - </li>  
79 - <li>  
80 - Piotr Krawiecki  
81 - </li>  
82 - <li>  
83 - Ola Larsson  
84 - </li>  
85 - <li>  
86 - Pavel Lastovicka  
87 - </li>  
88 - <li>  
89 - Michel Loiseleur  
90 - </li>  
91 - <li>  
92 - Renat Lumpau  
93 - </li>  
94 - <li>  
95 - Marco Lusini  
96 - </li>  
97 - <li>  
98 - Michael Malone  
99 - </li>  
100 - <li>  
101 - Jochem Meijers  
102 - </li>  
103 - <li>  
104 - John Miles  
105 - </li>  
106 - <li>  
107 - Ismail Mogal  
108 - </li>  
109 - <li>  
110 - David Nalley  
111 - </li>  
112 - <li>  
113 - Marco Napetti  
114 - </li>  
115 - <li>  
116 - Manuela Patrono  
117 - </li>  
118 - <li>  
119 - Antti Poro  
120 - </li>  
121 - <li>  
122 - Nicolas Quienot  
123 - </li>  
124 - <li>  
125 - Ken Rainsforth  
126 - </li>  
127 - <li>  
128 - Antonio Rizzelli  
129 - </li>  
130 - <li>  
131 - Greg Rundlett  
132 - </li>  
133 - <li>  
134 - Leonardo Russo  
135 - </li>  
136 - <li>  
137 - Ricardo Silva  
138 - </li>  
139 - <li>  
140 - Mario Steinhoff  
141 - </li>  
142 - <li>  
143 - Phillip Steinbachs  
144 - </li>  
145 - <li>  
146 - Tahir Tahang  
147 - </li>  
148 - <li>  
149 - Paul Trgina  
150 - </li>  
151 - <li>  
152 - Harry Tsio  
153 - </li>  
154 - <li>  
155 - Bjarte Kalstveit Vebj&oslash;rnsen  
156 - </li>  
157 - <li>  
158 - Zakariah  
159 - </li>  
160 - <li>  
161 - Jaime Zarate  
162 - </li>  
163 - <li>  
164 - And all the KnowledgeTree staff that <a href="http://en.wikipedia.org/wiki/Eat_one's_own_dog_food">"dogfood"</a> KnowledgeTree every day.  
165 - </li>  
166 -  
167 -</ul> 35 + Fu Bin,
  36 + Blackhold,
  37 + Chris Buechler,
  38 + Guillaume Dufloux,
  39 + David Alfonso Faspar,
  40 + Ruud Feringa,
  41 + Hil&aacute;rio Fernandes,
  42 + William Hawkins,
  43 + Lody Hoekstra,
  44 + Kenny Horan,
  45 + Artur Kiwa,
  46 + Michael Knight,
  47 + Jeongkyu Kim,
  48 + Rogerio Kohler,
  49 + Piotr Krawiecki ,
  50 + Ola Larsson,
  51 + Pavel Lastovicka,
  52 + Michel Loiseleur ,
  53 + Renat Lumpau,
  54 + Marco Lusini,
  55 + Michael Malone,
  56 + Jochem Meijers,
  57 + John Miles,
  58 + Ismail Mogal,
  59 + David Nalley,
  60 + Marco Napetti,
  61 + Manuela Patrono,
  62 + Antti Poro,
  63 + Nicolas Quienot,
  64 + Ken Rainsforth,
  65 + Antonio Rizzelli,
  66 + Greg Rundlett,
  67 + Leonardo Russo,
  68 + Ricardo Silva,
  69 + Mario Steinhoff,
  70 + Phillip Steinbachs,
  71 + Tahir Tahang,
  72 + Paul Trgina,
  73 + Harry Tsio,
  74 + Bjarte Kalstveit Vebj&oslash;rnsen,
  75 + Zakariah,
  76 + Jaime Zarate, <br><br/>
  77 + And the KnowledgeTree team who <a href="http://en.wikipedia.org/wiki/Eat_one's_own_dog_food">"dogfood"</a> KnowledgeTree every day.
168 78
169 <p><small>[If you feel you should be here too, please let us know at <a href="mailto:contributions@knowledgetree.com">contributions@knowledgetree.com</a>]</small></p> 79 <p><small>[If you feel you should be here too, please let us know at <a href="mailto:contributions@knowledgetree.com">contributions@knowledgetree.com</a>]</small></p>
170 80
171 - 81 +<br/>
172 <p>This software utilizes third-party software from <a set="yes" linkindex="11" href="http://pear.php.net/">Pear</a>, <a set="yes" linkindex="12" href="http://phpmailer.sourceforge.net/">PHPMailer</a>, <a set="yes" linkindex="13" href="http://smarty.php.net/">Smarty Template Engine</a>, <a set="yes" linkindex="14" href="http://sourceforge.net/projects/jscalendar">JSCalendar</a>, <a set="yes" linkindex="15" href="http://mochikit.com/">Mochikit</a>, <a set="yes" linkindex="16" href="http://tinymce.moxiecode.com/">Moxiecode Systems</a>, <a set="yes" linkindex="17" href="http://developer.yahoo.com/yui/">Yahoo Developer Network</a>.</p> 82 <p>This software utilizes third-party software from <a set="yes" linkindex="11" href="http://pear.php.net/">Pear</a>, <a set="yes" linkindex="12" href="http://phpmailer.sourceforge.net/">PHPMailer</a>, <a set="yes" linkindex="13" href="http://smarty.php.net/">Smarty Template Engine</a>, <a set="yes" linkindex="14" href="http://sourceforge.net/projects/jscalendar">JSCalendar</a>, <a set="yes" linkindex="15" href="http://mochikit.com/">Mochikit</a>, <a set="yes" linkindex="16" href="http://tinymce.moxiecode.com/">Moxiecode Systems</a>, <a set="yes" linkindex="17" href="http://developer.yahoo.com/yui/">Yahoo Developer Network</a>.</p>
173 83
templates/ktcore/search2/reporting/indexerrors.smarty
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 {foreach key=key from=$indexErrors item=indexError} 40 {foreach key=key from=$indexErrors item=indexError}
41 <tr> 41 <tr>
42 <td class="centered"><input type="checkbox" name="index_error[{$indexError.document_id}]" value="1"/></td> 42 <td class="centered"><input type="checkbox" name="index_error[{$indexError.document_id}]" value="1"/></td>
43 - <td><a href="/view.php?fDocumentId={$indexError.document_id}">{$indexError.filename|truncate:40:'...'}</a></td> 43 + <td><a href="{$root_url}/view.php?fDocumentId={$indexError.document_id}">{$indexError.filename|truncate:40:'...'}</a></td>
44 <td>{if $indexError.extractor}{$indexError.extractor}{else}<p><font color="#FF9933">{i18n}n/a{/i18n}</font></p>{/if}</td> 44 <td>{if $indexError.extractor}{$indexError.extractor}{else}<p><font color="#FF9933">{i18n}n/a{/i18n}</font></p>{/if}</td>
45 <td>{$indexError.indexdate}</td> 45 <td>{$indexError.indexdate}</td>
46 46
@@ -57,18 +57,31 @@ @@ -57,18 +57,31 @@
57 <tfoot> 57 <tfoot>
58 <tr> 58 <tr>
59 <td colspan="4"> 59 <td colspan="4">
60 -<div align="center">  
61 -{foreach item=page from=$pageList}  
62 -<a id="pageButton{$page}" href="#" onclick="nextSearchPage({$page});">{$page}</a>  
63 -{/foreach}  
64 -</div>  
65 -</td>  
66 -</tr>  
67 -<tr>  
68 -<td colspan="4">  
69 -<div> {$itemCount} items, {$itemsPerPage} items per page.</div> 60 + <div align="center">
  61 + {foreach item=page from=$pageList}
  62 + {if $pageNum == $page}
  63 + {$page}&nbsp;
  64 + {else}
  65 + <a id="pageButton{$page}" href="#" onclick="nextSearchPage({$page});">{$page}</a>&nbsp;
  66 + {/if}
  67 + {/foreach}
  68 + </div>
70 </td> 69 </td>
71 </tr> 70 </tr>
  71 + <tr>
  72 + <td colspan="2">
  73 + <div> {$itemCount} {i18n}items{/i18n}, {$itemsPerPage} {i18n}items per page{/i18n}.</div>
  74 + </td>
  75 + <td align="right">
  76 + <select name="itemsPerPage">
  77 + <option value='10' {if $itemsPerPage == 10}selected='true'{/if} onclick="nextSearchPage({$pageNum});" >10</option>
  78 + <option value='20' {if $itemsPerPage == 20}selected='true'{/if} onclick="nextSearchPage({$pageNum});">20</option>
  79 + <option value='50' {if $itemsPerPage == 50}selected='true'{/if} onclick="nextSearchPage({$pageNum});">50</option>
  80 + <option value='100' {if $itemsPerPage == 100}selected='true'{/if} onclick="nextSearchPage({$pageNum});">100</option>
  81 + </select>
  82 + {i18n}items per page{/i18n}
  83 + </td>
  84 + </tr>
72 </tfoot> 85 </tfoot>
73 </table> 86 </table>
74 87
templates/ktcore/search2/reporting/pendingdocuments.smarty
  1 +{literal}
  2 +<script type="text/javascript">
  3 + function nextSearchPage(value)
  4 + {
  5 + var hiddenPageVal = document.getElementById("pageValue");
  6 + hiddenPageVal.value = value;
  7 + document.pendingQueueForm.submit();
  8 + }
  9 +</script>
  10 +{/literal}
1 <h2>{i18n}Pending Documents Indexing Queue{/i18n}</h2> 11 <h2>{i18n}Pending Documents Indexing Queue{/i18n}</h2>
2 -{i18n}This report lists documents that are waiting to be indexed.{/i18n}  
3 -<br><br> 12 +<p class="descriptiveText">{i18n}This report lists documents that are waiting to be indexed.{/i18n}</p>
  13 +<br>
4 {i18n}If a document is not associated with an extractor, no content will be added to the index. These documents can be identified in the list by the extractor column reflecting n/a.{/i18n} 14 {i18n}If a document is not associated with an extractor, no content will be added to the index. These documents can be identified in the list by the extractor column reflecting n/a.{/i18n}
5 <br><br> 15 <br><br>
6 16
@@ -11,6 +21,9 @@ @@ -11,6 +21,9 @@
11 {else} 21 {else}
12 22
13 23
  24 +<form name="pendingQueueForm" action="{$smarty.server.PHP_SELF}" method="POST">
  25 +<input type="hidden" name="pageValue" id="pageValue" value="" />
  26 +
14 <table class=kt_collection> 27 <table class=kt_collection>
15 28
16 <thead> 29 <thead>
@@ -33,6 +46,40 @@ @@ -33,6 +46,40 @@
33 46
34 </tbody> 47 </tbody>
35 48
  49 +<tfoot>
  50 + <tr>
  51 + <td colspan="3">
  52 + <div align="center">
  53 + {foreach item=page from=$pageList}
  54 + {if $pageNum == $page}
  55 + {$page}&nbsp;
  56 + {else}
  57 + <a id="pageButton{$page}" href="#" onclick="nextSearchPage({$page});">{$page}</a>&nbsp;
  58 + {/if}
  59 + {/foreach}
  60 + </div>
  61 + </td>
  62 + </tr>
  63 + <tr>
  64 + <td colspan="2">
  65 + <div> {$itemCount} {i18n}items{/i18n},
  66 + {$itemsPerPage} {i18n}items per page{/i18n}.
  67 + </div>
  68 + </td>
  69 + <td align="right">
  70 + <select name="itemsPerPage">
  71 + <option value='10' {if $itemsPerPage == 10}selected='true'{/if} onclick="nextSearchPage({$pageNum});" >10</option>
  72 + <option value='20' {if $itemsPerPage == 20}selected='true'{/if} onclick="nextSearchPage({$pageNum});">20</option>
  73 + <option value='50' {if $itemsPerPage == 50}selected='true'{/if} onclick="nextSearchPage({$pageNum});">50</option>
  74 + <option value='100' {if $itemsPerPage == 100}selected='true'{/if} onclick="nextSearchPage({$pageNum});">100</option>
  75 + </select>
  76 + {i18n}items per page{/i18n}
  77 + </td>
  78 + </tr>
  79 +</tfoot>
  80 +
36 </table> 81 </table>
37 82
  83 +</form>
  84 +
38 {/if} 85 {/if}
thirdparty/peclzip/pclzip.lib.php 100755 → 100644
1 <?php 1 <?php
2 // -------------------------------------------------------------------------------- 2 // --------------------------------------------------------------------------------
3 -// PhpConcept Library - Zip Module 2.5 3 +// PhpConcept Library - Zip Module 2.8.2
4 // -------------------------------------------------------------------------------- 4 // --------------------------------------------------------------------------------
5 -// License GNU/LGPL - Vincent Blavet - March 2006 5 +// License GNU/LGPL - Vincent Blavet - August 2009
6 // http://www.phpconcept.net 6 // http://www.phpconcept.net
7 // -------------------------------------------------------------------------------- 7 // --------------------------------------------------------------------------------
8 // 8 //
@@ -22,12 +22,14 @@ @@ -22,12 +22,14 @@
22 // The use of this software is at the risk of the user. 22 // The use of this software is at the risk of the user.
23 // 23 //
24 // -------------------------------------------------------------------------------- 24 // --------------------------------------------------------------------------------
25 -// $Id: pclzip.lib.php,v 1.44 2006/03/08 21:23:59 vblavet Exp $ 25 +// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
26 // -------------------------------------------------------------------------------- 26 // --------------------------------------------------------------------------------
27 27
28 // ----- Constants 28 // ----- Constants
29 - define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );  
30 - 29 + if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
  30 + define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
  31 + }
  32 +
31 // ----- File list separator 33 // ----- File list separator
32 // In version 1.x of PclZip, the separator for file list is a space 34 // In version 1.x of PclZip, the separator for file list is a space
33 // (which is not a very smart choice, specifically for windows paths !). 35 // (which is not a very smart choice, specifically for windows paths !).
@@ -38,14 +40,18 @@ @@ -38,14 +40,18 @@
38 // Recommanded values for compatibility with older versions : 40 // Recommanded values for compatibility with older versions :
39 //define( 'PCLZIP_SEPARATOR', ' ' ); 41 //define( 'PCLZIP_SEPARATOR', ' ' );
40 // Recommanded values for smart separation of filenames. 42 // Recommanded values for smart separation of filenames.
41 - define( 'PCLZIP_SEPARATOR', ',' ); 43 + if (!defined('PCLZIP_SEPARATOR')) {
  44 + define( 'PCLZIP_SEPARATOR', ',' );
  45 + }
42 46
43 // ----- Error configuration 47 // ----- Error configuration
44 // 0 : PclZip Class integrated error handling 48 // 0 : PclZip Class integrated error handling
45 // 1 : PclError external library error handling. By enabling this 49 // 1 : PclError external library error handling. By enabling this
46 // you must ensure that you have included PclError library. 50 // you must ensure that you have included PclError library.
47 // [2,...] : reserved for futur use 51 // [2,...] : reserved for futur use
48 - define( 'PCLZIP_ERROR_EXTERNAL', 0 ); 52 + if (!defined('PCLZIP_ERROR_EXTERNAL')) {
  53 + define( 'PCLZIP_ERROR_EXTERNAL', 0 );
  54 + }
49 55
50 // ----- Optional static temporary directory 56 // ----- Optional static temporary directory
51 // By default temporary files are generated in the script current 57 // By default temporary files are generated in the script current
@@ -56,14 +62,28 @@ @@ -56,14 +62,28 @@
56 // Samples : 62 // Samples :
57 // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); 63 // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
58 // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); 64 // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
59 - define( 'PCLZIP_TEMPORARY_DIR', '' ); 65 + if (!defined('PCLZIP_TEMPORARY_DIR')) {
  66 + define( 'PCLZIP_TEMPORARY_DIR', '' );
  67 + }
  68 +
  69 + // ----- Optional threshold ratio for use of temporary files
  70 + // Pclzip sense the size of the file to add/extract and decide to
  71 + // use or not temporary file. The algorythm is looking for
  72 + // memory_limit of PHP and apply a ratio.
  73 + // threshold = memory_limit * ratio.
  74 + // Recommended values are under 0.5. Default 0.47.
  75 + // Samples :
  76 + // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
  77 + if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
  78 + define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
  79 + }
60 80
61 // -------------------------------------------------------------------------------- 81 // --------------------------------------------------------------------------------
62 // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED ***** 82 // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
63 // -------------------------------------------------------------------------------- 83 // --------------------------------------------------------------------------------
64 84
65 // ----- Global variables 85 // ----- Global variables
66 - $g_pclzip_version = "2.5"; 86 + $g_pclzip_version = "2.8.2";
67 87
68 // ----- Error codes 88 // ----- Error codes
69 // -1 : Unable to open file in binary write mode 89 // -1 : Unable to open file in binary write mode
@@ -126,11 +146,20 @@ @@ -126,11 +146,20 @@
126 // which is not correctly supported by PHP ... 146 // which is not correctly supported by PHP ...
127 //define( 'PCLZIP_OPT_CRYPT', 77018 ); 147 //define( 'PCLZIP_OPT_CRYPT', 77018 );
128 define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); 148 define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
129 - 149 + define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
  150 + define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
  151 + define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
  152 + define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
  153 + define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
  154 + define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
  155 +
130 // ----- File description attributes 156 // ----- File description attributes
131 define( 'PCLZIP_ATT_FILE_NAME', 79001 ); 157 define( 'PCLZIP_ATT_FILE_NAME', 79001 );
132 define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); 158 define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
133 define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); 159 define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
  160 + define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
  161 + define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
  162 + define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
134 163
135 // ----- Call backs values 164 // ----- Call backs values
136 define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); 165 define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
@@ -169,7 +198,7 @@ @@ -169,7 +198,7 @@
169 // ----- Internal error handling 198 // ----- Internal error handling
170 var $error_code = 1; 199 var $error_code = 1;
171 var $error_string = ''; 200 var $error_string = '';
172 - 201 +
173 // ----- Current status of the magic_quotes_runtime 202 // ----- Current status of the magic_quotes_runtime
174 // This value store the php configuration for magic_quotes 203 // This value store the php configuration for magic_quotes
175 // The class can then disable the magic_quotes and reset it after 204 // The class can then disable the magic_quotes and reset it after
@@ -185,12 +214,10 @@ @@ -185,12 +214,10 @@
185 // -------------------------------------------------------------------------------- 214 // --------------------------------------------------------------------------------
186 function PclZip($p_zipname) 215 function PclZip($p_zipname)
187 { 216 {
188 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");  
189 217
190 // ----- Tests the zlib 218 // ----- Tests the zlib
191 if (!function_exists('gzopen')) 219 if (!function_exists('gzopen'))
192 { 220 {
193 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");  
194 die('Abort '.basename(__FILE__).' : Missing zlib extensions'); 221 die('Abort '.basename(__FILE__).' : Missing zlib extensions');
195 } 222 }
196 223
@@ -200,7 +227,6 @@ @@ -200,7 +227,6 @@
200 $this->magic_quotes_status = -1; 227 $this->magic_quotes_status = -1;
201 228
202 // ----- Return 229 // ----- Return
203 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);  
204 return; 230 return;
205 } 231 }
206 // -------------------------------------------------------------------------------- 232 // --------------------------------------------------------------------------------
@@ -244,7 +270,6 @@ @@ -244,7 +270,6 @@
244 // -------------------------------------------------------------------------------- 270 // --------------------------------------------------------------------------------
245 function create($p_filelist) 271 function create($p_filelist)
246 { 272 {
247 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");  
248 $v_result=1; 273 $v_result=1;
249 274
250 // ----- Reset the error handler 275 // ----- Reset the error handler
@@ -256,7 +281,6 @@ @@ -256,7 +281,6 @@
256 281
257 // ----- Look for variable options arguments 282 // ----- Look for variable options arguments
258 $v_size = func_num_args(); 283 $v_size = func_num_args();
259 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");  
260 284
261 // ----- Look for arguments 285 // ----- Look for arguments
262 if ($v_size > 1) { 286 if ($v_size > 1) {
@@ -269,7 +293,6 @@ @@ -269,7 +293,6 @@
269 293
270 // ----- Look for first arg 294 // ----- Look for first arg
271 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { 295 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
272 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");  
273 296
274 // ----- Parse the options 297 // ----- Parse the options
275 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, 298 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
@@ -279,11 +302,13 @@ @@ -279,11 +302,13 @@
279 PCLZIP_CB_PRE_ADD => 'optional', 302 PCLZIP_CB_PRE_ADD => 'optional',
280 PCLZIP_CB_POST_ADD => 'optional', 303 PCLZIP_CB_POST_ADD => 'optional',
281 PCLZIP_OPT_NO_COMPRESSION => 'optional', 304 PCLZIP_OPT_NO_COMPRESSION => 'optional',
282 - PCLZIP_OPT_COMMENT => 'optional' 305 + PCLZIP_OPT_COMMENT => 'optional',
  306 + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
  307 + PCLZIP_OPT_TEMP_FILE_ON => 'optional',
  308 + PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
283 //, PCLZIP_OPT_CRYPT => 'optional' 309 //, PCLZIP_OPT_CRYPT => 'optional'
284 )); 310 ));
285 if ($v_result != 1) { 311 if ($v_result != 1) {
286 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
287 return 0; 312 return 0;
288 } 313 }
289 } 314 }
@@ -292,7 +317,6 @@ @@ -292,7 +317,6 @@
292 // Here we need to support the first historic synopsis of the 317 // Here we need to support the first historic synopsis of the
293 // method. 318 // method.
294 else { 319 else {
295 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");  
296 320
297 // ----- Get the first argument 321 // ----- Get the first argument
298 $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; 322 $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
@@ -304,27 +328,29 @@ @@ -304,27 +328,29 @@
304 else if ($v_size > 2) { 328 else if ($v_size > 2) {
305 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 329 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
306 "Invalid number / type of arguments"); 330 "Invalid number / type of arguments");
307 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
308 return 0; 331 return 0;
309 } 332 }
310 } 333 }
311 } 334 }
  335 +
  336 + // ----- Look for default option values
  337 + $this->privOptionDefaultThreshold($v_options);
312 338
313 // ----- Init 339 // ----- Init
314 $v_string_list = array(); 340 $v_string_list = array();
315 $v_att_list = array(); 341 $v_att_list = array();
316 $v_filedescr_list = array(); 342 $v_filedescr_list = array();
317 $p_result_list = array(); 343 $p_result_list = array();
318 - 344 +
319 // ----- Look if the $p_filelist is really an array 345 // ----- Look if the $p_filelist is really an array
320 if (is_array($p_filelist)) { 346 if (is_array($p_filelist)) {
321 - 347 +
322 // ----- Look if the first element is also an array 348 // ----- Look if the first element is also an array
323 // This will mean that this is a file description entry 349 // This will mean that this is a file description entry
324 if (isset($p_filelist[0]) && is_array($p_filelist[0])) { 350 if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
325 $v_att_list = $p_filelist; 351 $v_att_list = $p_filelist;
326 } 352 }
327 - 353 +
328 // ----- The list is a list of string names 354 // ----- The list is a list of string names
329 else { 355 else {
330 $v_string_list = $p_filelist; 356 $v_string_list = $p_filelist;
@@ -340,10 +366,9 @@ @@ -340,10 +366,9 @@
340 // ----- Invalid variable type for $p_filelist 366 // ----- Invalid variable type for $p_filelist
341 else { 367 else {
342 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); 368 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
343 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
344 return 0; 369 return 0;
345 } 370 }
346 - 371 +
347 // ----- Reformat the string list 372 // ----- Reformat the string list
348 if (sizeof($v_string_list) != 0) { 373 if (sizeof($v_string_list) != 0) {
349 foreach ($v_string_list as $v_string) { 374 foreach ($v_string_list as $v_string) {
@@ -351,16 +376,18 @@ @@ -351,16 +376,18 @@
351 $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; 376 $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
352 } 377 }
353 else { 378 else {
354 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename");  
355 } 379 }
356 } 380 }
357 } 381 }
358 - 382 +
359 // ----- For each file in the list check the attributes 383 // ----- For each file in the list check the attributes
360 $v_supported_attributes 384 $v_supported_attributes
361 = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' 385 = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
362 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' 386 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
363 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' 387 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
  388 + ,PCLZIP_ATT_FILE_MTIME => 'optional'
  389 + ,PCLZIP_ATT_FILE_CONTENT => 'optional'
  390 + ,PCLZIP_ATT_FILE_COMMENT => 'optional'
364 ); 391 );
365 foreach ($v_att_list as $v_entry) { 392 foreach ($v_att_list as $v_entry) {
366 $v_result = $this->privFileDescrParseAtt($v_entry, 393 $v_result = $this->privFileDescrParseAtt($v_entry,
@@ -368,7 +395,6 @@ @@ -368,7 +395,6 @@
368 $v_options, 395 $v_options,
369 $v_supported_attributes); 396 $v_supported_attributes);
370 if ($v_result != 1) { 397 if ($v_result != 1) {
371 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
372 return 0; 398 return 0;
373 } 399 }
374 } 400 }
@@ -376,19 +402,16 @@ @@ -376,19 +402,16 @@
376 // ----- Expand the filelist (expand directories) 402 // ----- Expand the filelist (expand directories)
377 $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); 403 $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
378 if ($v_result != 1) { 404 if ($v_result != 1) {
379 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
380 return 0; 405 return 0;
381 } 406 }
382 407
383 // ----- Call the create fct 408 // ----- Call the create fct
384 $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); 409 $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
385 if ($v_result != 1) { 410 if ($v_result != 1) {
386 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
387 return 0; 411 return 0;
388 } 412 }
389 413
390 // ----- Return 414 // ----- Return
391 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);  
392 return $p_result_list; 415 return $p_result_list;
393 } 416 }
394 // -------------------------------------------------------------------------------- 417 // --------------------------------------------------------------------------------
@@ -430,7 +453,6 @@ @@ -430,7 +453,6 @@
430 // -------------------------------------------------------------------------------- 453 // --------------------------------------------------------------------------------
431 function add($p_filelist) 454 function add($p_filelist)
432 { 455 {
433 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");  
434 $v_result=1; 456 $v_result=1;
435 457
436 // ----- Reset the error handler 458 // ----- Reset the error handler
@@ -442,7 +464,6 @@ @@ -442,7 +464,6 @@
442 464
443 // ----- Look for variable options arguments 465 // ----- Look for variable options arguments
444 $v_size = func_num_args(); 466 $v_size = func_num_args();
445 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");  
446 467
447 // ----- Look for arguments 468 // ----- Look for arguments
448 if ($v_size > 1) { 469 if ($v_size > 1) {
@@ -455,7 +476,6 @@ @@ -455,7 +476,6 @@
455 476
456 // ----- Look for first arg 477 // ----- Look for first arg
457 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { 478 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
458 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");  
459 479
460 // ----- Parse the options 480 // ----- Parse the options
461 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, 481 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
@@ -467,11 +487,13 @@ @@ -467,11 +487,13 @@
467 PCLZIP_OPT_NO_COMPRESSION => 'optional', 487 PCLZIP_OPT_NO_COMPRESSION => 'optional',
468 PCLZIP_OPT_COMMENT => 'optional', 488 PCLZIP_OPT_COMMENT => 'optional',
469 PCLZIP_OPT_ADD_COMMENT => 'optional', 489 PCLZIP_OPT_ADD_COMMENT => 'optional',
470 - PCLZIP_OPT_PREPEND_COMMENT => 'optional' 490 + PCLZIP_OPT_PREPEND_COMMENT => 'optional',
  491 + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
  492 + PCLZIP_OPT_TEMP_FILE_ON => 'optional',
  493 + PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
471 //, PCLZIP_OPT_CRYPT => 'optional' 494 //, PCLZIP_OPT_CRYPT => 'optional'
472 )); 495 ));
473 if ($v_result != 1) { 496 if ($v_result != 1) {
474 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
475 return 0; 497 return 0;
476 } 498 }
477 } 499 }
@@ -480,7 +502,6 @@ @@ -480,7 +502,6 @@
480 // Here we need to support the first historic synopsis of the 502 // Here we need to support the first historic synopsis of the
481 // method. 503 // method.
482 else { 504 else {
483 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");  
484 505
485 // ----- Get the first argument 506 // ----- Get the first argument
486 $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; 507 $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
@@ -494,27 +515,29 @@ @@ -494,27 +515,29 @@
494 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); 515 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
495 516
496 // ----- Return 517 // ----- Return
497 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
498 return 0; 518 return 0;
499 } 519 }
500 } 520 }
501 } 521 }
502 522
  523 + // ----- Look for default option values
  524 + $this->privOptionDefaultThreshold($v_options);
  525 +
503 // ----- Init 526 // ----- Init
504 $v_string_list = array(); 527 $v_string_list = array();
505 $v_att_list = array(); 528 $v_att_list = array();
506 $v_filedescr_list = array(); 529 $v_filedescr_list = array();
507 $p_result_list = array(); 530 $p_result_list = array();
508 - 531 +
509 // ----- Look if the $p_filelist is really an array 532 // ----- Look if the $p_filelist is really an array
510 if (is_array($p_filelist)) { 533 if (is_array($p_filelist)) {
511 - 534 +
512 // ----- Look if the first element is also an array 535 // ----- Look if the first element is also an array
513 // This will mean that this is a file description entry 536 // This will mean that this is a file description entry
514 if (isset($p_filelist[0]) && is_array($p_filelist[0])) { 537 if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
515 $v_att_list = $p_filelist; 538 $v_att_list = $p_filelist;
516 } 539 }
517 - 540 +
518 // ----- The list is a list of string names 541 // ----- The list is a list of string names
519 else { 542 else {
520 $v_string_list = $p_filelist; 543 $v_string_list = $p_filelist;
@@ -530,22 +553,24 @@ @@ -530,22 +553,24 @@
530 // ----- Invalid variable type for $p_filelist 553 // ----- Invalid variable type for $p_filelist
531 else { 554 else {
532 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); 555 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
533 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
534 return 0; 556 return 0;
535 } 557 }
536 - 558 +
537 // ----- Reformat the string list 559 // ----- Reformat the string list
538 if (sizeof($v_string_list) != 0) { 560 if (sizeof($v_string_list) != 0) {
539 foreach ($v_string_list as $v_string) { 561 foreach ($v_string_list as $v_string) {
540 $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; 562 $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
541 } 563 }
542 } 564 }
543 - 565 +
544 // ----- For each file in the list check the attributes 566 // ----- For each file in the list check the attributes
545 $v_supported_attributes 567 $v_supported_attributes
546 = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' 568 = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
547 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' 569 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
548 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' 570 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
  571 + ,PCLZIP_ATT_FILE_MTIME => 'optional'
  572 + ,PCLZIP_ATT_FILE_CONTENT => 'optional'
  573 + ,PCLZIP_ATT_FILE_COMMENT => 'optional'
549 ); 574 );
550 foreach ($v_att_list as $v_entry) { 575 foreach ($v_att_list as $v_entry) {
551 $v_result = $this->privFileDescrParseAtt($v_entry, 576 $v_result = $this->privFileDescrParseAtt($v_entry,
@@ -553,7 +578,6 @@ @@ -553,7 +578,6 @@
553 $v_options, 578 $v_options,
554 $v_supported_attributes); 579 $v_supported_attributes);
555 if ($v_result != 1) { 580 if ($v_result != 1) {
556 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
557 return 0; 581 return 0;
558 } 582 }
559 } 583 }
@@ -561,19 +585,16 @@ @@ -561,19 +585,16 @@
561 // ----- Expand the filelist (expand directories) 585 // ----- Expand the filelist (expand directories)
562 $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); 586 $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
563 if ($v_result != 1) { 587 if ($v_result != 1) {
564 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
565 return 0; 588 return 0;
566 } 589 }
567 590
568 // ----- Call the create fct 591 // ----- Call the create fct
569 $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); 592 $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
570 if ($v_result != 1) { 593 if ($v_result != 1) {
571 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
572 return 0; 594 return 0;
573 } 595 }
574 596
575 // ----- Return 597 // ----- Return
576 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);  
577 return $p_result_list; 598 return $p_result_list;
578 } 599 }
579 // -------------------------------------------------------------------------------- 600 // --------------------------------------------------------------------------------
@@ -606,7 +627,7 @@ @@ -606,7 +627,7 @@
606 // write protected 627 // write protected
607 // newer_exist : the file was not extracted because a newer file exists 628 // newer_exist : the file was not extracted because a newer file exists
608 // path_creation_fail : the file is not extracted because the folder 629 // path_creation_fail : the file is not extracted because the folder
609 - // does not exists and can not be created 630 + // does not exist and can not be created
610 // write_error : the file was not extracted because there was a 631 // write_error : the file was not extracted because there was a
611 // error while writing the file 632 // error while writing the file
612 // read_error : the file was not extracted because there was a error 633 // read_error : the file was not extracted because there was a error
@@ -621,7 +642,6 @@ @@ -621,7 +642,6 @@
621 // -------------------------------------------------------------------------------- 642 // --------------------------------------------------------------------------------
622 function listContent() 643 function listContent()
623 { 644 {
624 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");  
625 $v_result=1; 645 $v_result=1;
626 646
627 // ----- Reset the error handler 647 // ----- Reset the error handler
@@ -629,7 +649,6 @@ @@ -629,7 +649,6 @@
629 649
630 // ----- Check archive 650 // ----- Check archive
631 if (!$this->privCheckFormat()) { 651 if (!$this->privCheckFormat()) {
632 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
633 return(0); 652 return(0);
634 } 653 }
635 654
@@ -638,12 +657,10 @@ @@ -638,12 +657,10 @@
638 if (($v_result = $this->privList($p_list)) != 1) 657 if (($v_result = $this->privList($p_list)) != 1)
639 { 658 {
640 unset($p_list); 659 unset($p_list);
641 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());  
642 return(0); 660 return(0);
643 } 661 }
644 662
645 // ----- Return 663 // ----- Return
646 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);  
647 return $p_list; 664 return $p_list;
648 } 665 }
649 // -------------------------------------------------------------------------------- 666 // --------------------------------------------------------------------------------
@@ -682,7 +699,6 @@ @@ -682,7 +699,6 @@
682 // -------------------------------------------------------------------------------- 699 // --------------------------------------------------------------------------------
683 function extract() 700 function extract()
684 { 701 {
685 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");  
686 $v_result=1; 702 $v_result=1;
687 703
688 // ----- Reset the error handler 704 // ----- Reset the error handler
@@ -690,7 +706,6 @@ @@ -690,7 +706,6 @@
690 706
691 // ----- Check archive 707 // ----- Check archive
692 if (!$this->privCheckFormat()) { 708 if (!$this->privCheckFormat()) {
693 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
694 return(0); 709 return(0);
695 } 710 }
696 711
@@ -703,7 +718,6 @@ @@ -703,7 +718,6 @@
703 718
704 // ----- Look for variable options arguments 719 // ----- Look for variable options arguments
705 $v_size = func_num_args(); 720 $v_size = func_num_args();
706 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");  
707 721
708 // ----- Default values for option 722 // ----- Default values for option
709 $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; 723 $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
@@ -715,7 +729,6 @@ @@ -715,7 +729,6 @@
715 729
716 // ----- Look for first arg 730 // ----- Look for first arg
717 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { 731 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
718 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");  
719 732
720 // ----- Parse the options 733 // ----- Parse the options
721 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, 734 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
@@ -734,10 +747,12 @@ @@ -734,10 +747,12 @@
734 PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', 747 PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
735 PCLZIP_OPT_REPLACE_NEWER => 'optional' 748 PCLZIP_OPT_REPLACE_NEWER => 'optional'
736 ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' 749 ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
737 - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' 750 + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
  751 + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
  752 + PCLZIP_OPT_TEMP_FILE_ON => 'optional',
  753 + PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
738 )); 754 ));
739 if ($v_result != 1) { 755 if ($v_result != 1) {
740 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
741 return 0; 756 return 0;
742 } 757 }
743 758
@@ -764,7 +779,6 @@ @@ -764,7 +779,6 @@
764 // Here we need to support the first historic synopsis of the 779 // Here we need to support the first historic synopsis of the
765 // method. 780 // method.
766 else { 781 else {
767 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");  
768 782
769 // ----- Get the first argument 783 // ----- Get the first argument
770 $v_path = $v_arg_list[0]; 784 $v_path = $v_arg_list[0];
@@ -778,14 +792,15 @@ @@ -778,14 +792,15 @@
778 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); 792 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
779 793
780 // ----- Return 794 // ----- Return
781 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());  
782 return 0; 795 return 0;
783 } 796 }
784 } 797 }
785 } 798 }
786 799
  800 + // ----- Look for default option values
  801 + $this->privOptionDefaultThreshold($v_options);
  802 +
787 // ----- Trace 803 // ----- Trace
788 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");  
789 804
790 // ----- Call the extracting fct 805 // ----- Call the extracting fct
791 $p_list = array(); 806 $p_list = array();
@@ -793,12 +808,10 @@ @@ -793,12 +808,10 @@
793 $v_remove_all_path, $v_options); 808 $v_remove_all_path, $v_options);
794 if ($v_result < 1) { 809 if ($v_result < 1) {
795 unset($p_list); 810 unset($p_list);
796 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());  
797 return(0); 811 return(0);
798 } 812 }
799 813
800 // ----- Return 814 // ----- Return
801 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);  
802 return $p_list; 815 return $p_list;
803 } 816 }
804 // -------------------------------------------------------------------------------- 817 // --------------------------------------------------------------------------------
@@ -843,7 +856,6 @@ @@ -843,7 +856,6 @@
843 //function extractByIndex($p_index, options...) 856 //function extractByIndex($p_index, options...)
844 function extractByIndex($p_index) 857 function extractByIndex($p_index)
845 { 858 {
846 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");  
847 $v_result=1; 859 $v_result=1;
848 860
849 // ----- Reset the error handler 861 // ----- Reset the error handler
@@ -851,7 +863,6 @@ @@ -851,7 +863,6 @@
851 863
852 // ----- Check archive 864 // ----- Check archive
853 if (!$this->privCheckFormat()) { 865 if (!$this->privCheckFormat()) {
854 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
855 return(0); 866 return(0);
856 } 867 }
857 868
@@ -864,7 +875,6 @@ @@ -864,7 +875,6 @@
864 875
865 // ----- Look for variable options arguments 876 // ----- Look for variable options arguments
866 $v_size = func_num_args(); 877 $v_size = func_num_args();
867 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");  
868 878
869 // ----- Default values for option 879 // ----- Default values for option
870 $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; 880 $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
@@ -880,7 +890,6 @@ @@ -880,7 +890,6 @@
880 890
881 // ----- Look for first arg 891 // ----- Look for first arg
882 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { 892 if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
883 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");  
884 893
885 // ----- Parse the options 894 // ----- Parse the options
886 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, 895 $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
@@ -894,10 +903,12 @@ @@ -894,10 +903,12 @@
894 PCLZIP_OPT_SET_CHMOD => 'optional', 903 PCLZIP_OPT_SET_CHMOD => 'optional',
895 PCLZIP_OPT_REPLACE_NEWER => 'optional' 904 PCLZIP_OPT_REPLACE_NEWER => 'optional'
896 ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' 905 ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
897 - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' 906 + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
  907 + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
  908 + PCLZIP_OPT_TEMP_FILE_ON => 'optional',
  909 + PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
898 )); 910 ));
899 if ($v_result != 1) { 911 if ($v_result != 1) {
900 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
901 return 0; 912 return 0;
902 } 913 }
903 914
@@ -920,10 +931,8 @@ @@ -920,10 +931,8 @@
920 } 931 }
921 if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { 932 if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
922 $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; 933 $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
923 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");  
924 } 934 }
925 else { 935 else {
926 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");  
927 } 936 }
928 } 937 }
929 938
@@ -931,7 +940,6 @@ @@ -931,7 +940,6 @@
931 // Here we need to support the first historic synopsis of the 940 // Here we need to support the first historic synopsis of the
932 // method. 941 // method.
933 else { 942 else {
934 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");  
935 943
936 // ----- Get the first argument 944 // ----- Get the first argument
937 $v_path = $v_arg_list[0]; 945 $v_path = $v_arg_list[0];
@@ -945,14 +953,12 @@ @@ -945,14 +953,12 @@
945 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); 953 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
946 954
947 // ----- Return 955 // ----- Return
948 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
949 return 0; 956 return 0;
950 } 957 }
951 } 958 }
952 } 959 }
953 960
954 // ----- Trace 961 // ----- Trace
955 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");  
956 962
957 // ----- Trick 963 // ----- Trick
958 // Here I want to reuse extractByRule(), so I need to parse the $p_index 964 // Here I want to reuse extractByRule(), so I need to parse the $p_index
@@ -962,19 +968,19 @@ @@ -962,19 +968,19 @@
962 $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, 968 $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
963 array (PCLZIP_OPT_BY_INDEX => 'optional' )); 969 array (PCLZIP_OPT_BY_INDEX => 'optional' ));
964 if ($v_result != 1) { 970 if ($v_result != 1) {
965 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
966 return 0; 971 return 0;
967 } 972 }
968 $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; 973 $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
969 974
  975 + // ----- Look for default option values
  976 + $this->privOptionDefaultThreshold($v_options);
  977 +
970 // ----- Call the extracting fct 978 // ----- Call the extracting fct
971 if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { 979 if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
972 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());  
973 return(0); 980 return(0);
974 } 981 }
975 982
976 // ----- Return 983 // ----- Return
977 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);  
978 return $p_list; 984 return $p_list;
979 } 985 }
980 // -------------------------------------------------------------------------------- 986 // --------------------------------------------------------------------------------
@@ -990,7 +996,7 @@ @@ -990,7 +996,7 @@
990 // Options : 996 // Options :
991 // PCLZIP_OPT_BY_INDEX : 997 // PCLZIP_OPT_BY_INDEX :
992 // PCLZIP_OPT_BY_NAME : 998 // PCLZIP_OPT_BY_NAME :
993 - // PCLZIP_OPT_BY_EREG : 999 + // PCLZIP_OPT_BY_EREG :
994 // PCLZIP_OPT_BY_PREG : 1000 // PCLZIP_OPT_BY_PREG :
995 // Return Values : 1001 // Return Values :
996 // 0 on failure, 1002 // 0 on failure,
@@ -999,7 +1005,6 @@ @@ -999,7 +1005,6 @@
999 // -------------------------------------------------------------------------------- 1005 // --------------------------------------------------------------------------------
1000 function delete() 1006 function delete()
1001 { 1007 {
1002 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");  
1003 $v_result=1; 1008 $v_result=1;
1004 1009
1005 // ----- Reset the error handler 1010 // ----- Reset the error handler
@@ -1007,7 +1012,6 @@ @@ -1007,7 +1012,6 @@
1007 1012
1008 // ----- Check archive 1013 // ----- Check archive
1009 if (!$this->privCheckFormat()) { 1014 if (!$this->privCheckFormat()) {
1010 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
1011 return(0); 1015 return(0);
1012 } 1016 }
1013 1017
@@ -1016,7 +1020,6 @@ @@ -1016,7 +1020,6 @@
1016 1020
1017 // ----- Look for variable options arguments 1021 // ----- Look for variable options arguments
1018 $v_size = func_num_args(); 1022 $v_size = func_num_args();
1019 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");  
1020 1023
1021 // ----- Look for arguments 1024 // ----- Look for arguments
1022 if ($v_size > 0) { 1025 if ($v_size > 0) {
@@ -1030,7 +1033,6 @@ @@ -1030,7 +1033,6 @@
1030 PCLZIP_OPT_BY_PREG => 'optional', 1033 PCLZIP_OPT_BY_PREG => 'optional',
1031 PCLZIP_OPT_BY_INDEX => 'optional' )); 1034 PCLZIP_OPT_BY_INDEX => 'optional' ));
1032 if ($v_result != 1) { 1035 if ($v_result != 1) {
1033 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
1034 return 0; 1036 return 0;
1035 } 1037 }
1036 } 1038 }
@@ -1043,7 +1045,6 @@ @@ -1043,7 +1045,6 @@
1043 if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { 1045 if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1044 $this->privSwapBackMagicQuotes(); 1046 $this->privSwapBackMagicQuotes();
1045 unset($v_list); 1047 unset($v_list);
1046 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());  
1047 return(0); 1048 return(0);
1048 } 1049 }
1049 1050
@@ -1051,7 +1052,6 @@ @@ -1051,7 +1052,6 @@
1051 $this->privSwapBackMagicQuotes(); 1052 $this->privSwapBackMagicQuotes();
1052 1053
1053 // ----- Return 1054 // ----- Return
1054 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);  
1055 return $v_list; 1055 return $v_list;
1056 } 1056 }
1057 // -------------------------------------------------------------------------------- 1057 // --------------------------------------------------------------------------------
@@ -1064,12 +1064,10 @@ @@ -1064,12 +1064,10 @@
1064 // -------------------------------------------------------------------------------- 1064 // --------------------------------------------------------------------------------
1065 function deleteByIndex($p_index) 1065 function deleteByIndex($p_index)
1066 { 1066 {
1067 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");  
1068 - 1067 +
1069 $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); 1068 $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1070 1069
1071 // ----- Return 1070 // ----- Return
1072 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);  
1073 return $p_list; 1071 return $p_list;
1074 } 1072 }
1075 // -------------------------------------------------------------------------------- 1073 // --------------------------------------------------------------------------------
@@ -1090,7 +1088,6 @@ @@ -1090,7 +1088,6 @@
1090 // -------------------------------------------------------------------------------- 1088 // --------------------------------------------------------------------------------
1091 function properties() 1089 function properties()
1092 { 1090 {
1093 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");  
1094 1091
1095 // ----- Reset the error handler 1092 // ----- Reset the error handler
1096 $this->privErrorReset(); 1093 $this->privErrorReset();
@@ -1101,7 +1098,6 @@ @@ -1101,7 +1098,6 @@
1101 // ----- Check archive 1098 // ----- Check archive
1102 if (!$this->privCheckFormat()) { 1099 if (!$this->privCheckFormat()) {
1103 $this->privSwapBackMagicQuotes(); 1100 $this->privSwapBackMagicQuotes();
1104 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
1105 return(0); 1101 return(0);
1106 } 1102 }
1107 1103
@@ -1115,16 +1111,14 @@ @@ -1115,16 +1111,14 @@
1115 if (@is_file($this->zipname)) 1111 if (@is_file($this->zipname))
1116 { 1112 {
1117 // ----- Open the zip file 1113 // ----- Open the zip file
1118 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
1119 if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) 1114 if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1120 { 1115 {
1121 $this->privSwapBackMagicQuotes(); 1116 $this->privSwapBackMagicQuotes();
1122 - 1117 +
1123 // ----- Error log 1118 // ----- Error log
1124 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); 1119 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1125 1120
1126 // ----- Return 1121 // ----- Return
1127 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);  
1128 return 0; 1122 return 0;
1129 } 1123 }
1130 1124
@@ -1133,7 +1127,6 @@ @@ -1133,7 +1127,6 @@
1133 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) 1127 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1134 { 1128 {
1135 $this->privSwapBackMagicQuotes(); 1129 $this->privSwapBackMagicQuotes();
1136 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
1137 return 0; 1130 return 0;
1138 } 1131 }
1139 1132
@@ -1150,7 +1143,6 @@ @@ -1150,7 +1143,6 @@
1150 $this->privSwapBackMagicQuotes(); 1143 $this->privSwapBackMagicQuotes();
1151 1144
1152 // ----- Return 1145 // ----- Return
1153 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);  
1154 return $v_prop; 1146 return $v_prop;
1155 } 1147 }
1156 // -------------------------------------------------------------------------------- 1148 // --------------------------------------------------------------------------------
@@ -1169,7 +1161,6 @@ @@ -1169,7 +1161,6 @@
1169 // -------------------------------------------------------------------------------- 1161 // --------------------------------------------------------------------------------
1170 function duplicate($p_archive) 1162 function duplicate($p_archive)
1171 { 1163 {
1172 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");  
1173 $v_result = 1; 1164 $v_result = 1;
1174 1165
1175 // ----- Reset the error handler 1166 // ----- Reset the error handler
@@ -1178,7 +1169,6 @@ @@ -1178,7 +1169,6 @@
1178 // ----- Look if the $p_archive is a PclZip object 1169 // ----- Look if the $p_archive is a PclZip object
1179 if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) 1170 if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1180 { 1171 {
1181 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");  
1182 1172
1183 // ----- Duplicate the archive 1173 // ----- Duplicate the archive
1184 $v_result = $this->privDuplicate($p_archive->zipname); 1174 $v_result = $this->privDuplicate($p_archive->zipname);
@@ -1187,7 +1177,6 @@ @@ -1187,7 +1177,6 @@
1187 // ----- Look if the $p_archive is a string (so a filename) 1177 // ----- Look if the $p_archive is a string (so a filename)
1188 else if (is_string($p_archive)) 1178 else if (is_string($p_archive))
1189 { 1179 {
1190 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");  
1191 1180
1192 // ----- Check that $p_archive is a valid zip file 1181 // ----- Check that $p_archive is a valid zip file
1193 // TBC : Should also check the archive format 1182 // TBC : Should also check the archive format
@@ -1211,7 +1200,6 @@ @@ -1211,7 +1200,6 @@
1211 } 1200 }
1212 1201
1213 // ----- Return 1202 // ----- Return
1214 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
1215 return $v_result; 1203 return $v_result;
1216 } 1204 }
1217 // -------------------------------------------------------------------------------- 1205 // --------------------------------------------------------------------------------
@@ -1232,7 +1220,6 @@ @@ -1232,7 +1220,6 @@
1232 // -------------------------------------------------------------------------------- 1220 // --------------------------------------------------------------------------------
1233 function merge($p_archive_to_add) 1221 function merge($p_archive_to_add)
1234 { 1222 {
1235 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");  
1236 $v_result = 1; 1223 $v_result = 1;
1237 1224
1238 // ----- Reset the error handler 1225 // ----- Reset the error handler
@@ -1240,14 +1227,12 @@ @@ -1240,14 +1227,12 @@
1240 1227
1241 // ----- Check archive 1228 // ----- Check archive
1242 if (!$this->privCheckFormat()) { 1229 if (!$this->privCheckFormat()) {
1243 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  
1244 return(0); 1230 return(0);
1245 } 1231 }
1246 1232
1247 // ----- Look if the $p_archive_to_add is a PclZip object 1233 // ----- Look if the $p_archive_to_add is a PclZip object
1248 if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) 1234 if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1249 { 1235 {
1250 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");  
1251 1236
1252 // ----- Merge the archive 1237 // ----- Merge the archive
1253 $v_result = $this->privMerge($p_archive_to_add); 1238 $v_result = $this->privMerge($p_archive_to_add);
@@ -1256,7 +1241,6 @@ @@ -1256,7 +1241,6 @@
1256 // ----- Look if the $p_archive_to_add is a string (so a filename) 1241 // ----- Look if the $p_archive_to_add is a string (so a filename)
1257 else if (is_string($p_archive_to_add)) 1242 else if (is_string($p_archive_to_add))
1258 { 1243 {
1259 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");  
1260 1244
1261 // ----- Create a temporary archive 1245 // ----- Create a temporary archive
1262 $v_object_archive = new PclZip($p_archive_to_add); 1246 $v_object_archive = new PclZip($p_archive_to_add);
@@ -1274,7 +1258,6 @@ @@ -1274,7 +1258,6 @@
1274 } 1258 }
1275 1259
1276 // ----- Return 1260 // ----- Return
1277 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
1278 return $v_result; 1261 return $v_result;
1279 } 1262 }
1280 // -------------------------------------------------------------------------------- 1263 // --------------------------------------------------------------------------------
@@ -1389,7 +1372,6 @@ @@ -1389,7 +1372,6 @@
1389 // -------------------------------------------------------------------------------- 1372 // --------------------------------------------------------------------------------
1390 function privCheckFormat($p_level=0) 1373 function privCheckFormat($p_level=0)
1391 { 1374 {
1392 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");  
1393 $v_result = true; 1375 $v_result = true;
1394 1376
1395 // ----- Reset the file system cache 1377 // ----- Reset the file system cache
@@ -1402,7 +1384,6 @@ @@ -1402,7 +1384,6 @@
1402 if (!is_file($this->zipname)) { 1384 if (!is_file($this->zipname)) {
1403 // ----- Error log 1385 // ----- Error log
1404 PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); 1386 PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1405 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());  
1406 return(false); 1387 return(false);
1407 } 1388 }
1408 1389
@@ -1410,7 +1391,6 @@ @@ -1410,7 +1391,6 @@
1410 if (!is_readable($this->zipname)) { 1391 if (!is_readable($this->zipname)) {
1411 // ----- Error log 1392 // ----- Error log
1412 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); 1393 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1413 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());  
1414 return(false); 1394 return(false);
1415 } 1395 }
1416 1396
@@ -1424,7 +1404,6 @@ @@ -1424,7 +1404,6 @@
1424 // TBC 1404 // TBC
1425 1405
1426 // ----- Return 1406 // ----- Return
1427 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
1428 return $v_result; 1407 return $v_result;
1429 } 1408 }
1430 // -------------------------------------------------------------------------------- 1409 // --------------------------------------------------------------------------------
@@ -1446,13 +1425,11 @@ @@ -1446,13 +1425,11 @@
1446 // -------------------------------------------------------------------------------- 1425 // --------------------------------------------------------------------------------
1447 function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) 1426 function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1448 { 1427 {
1449 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");  
1450 $v_result=1; 1428 $v_result=1;
1451 - 1429 +
1452 // ----- Read the options 1430 // ----- Read the options
1453 $i=0; 1431 $i=0;
1454 while ($i<$p_size) { 1432 while ($i<$p_size) {
1455 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");  
1456 1433
1457 // ----- Check if the option is supported 1434 // ----- Check if the option is supported
1458 if (!isset($v_requested_options[$p_options_list[$i]])) { 1435 if (!isset($v_requested_options[$p_options_list[$i]])) {
@@ -1460,7 +1437,6 @@ @@ -1460,7 +1437,6 @@
1460 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); 1437 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1461 1438
1462 // ----- Return 1439 // ----- Return
1463 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1464 return PclZip::errorCode(); 1440 return PclZip::errorCode();
1465 } 1441 }
1466 1442
@@ -1476,16 +1452,64 @@ @@ -1476,16 +1452,64 @@
1476 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1452 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1477 1453
1478 // ----- Return 1454 // ----- Return
1479 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1480 return PclZip::errorCode(); 1455 return PclZip::errorCode();
1481 } 1456 }
1482 1457
1483 // ----- Get the value 1458 // ----- Get the value
1484 - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);  
1485 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); 1459 + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1486 $i++; 1460 $i++;
1487 break; 1461 break;
1488 1462
  1463 + case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
  1464 + // ----- Check the number of parameters
  1465 + if (($i+1) >= $p_size) {
  1466 + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  1467 + return PclZip::errorCode();
  1468 + }
  1469 +
  1470 + // ----- Check for incompatible options
  1471 + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
  1472 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
  1473 + return PclZip::errorCode();
  1474 + }
  1475 +
  1476 + // ----- Check the value
  1477 + $v_value = $p_options_list[$i+1];
  1478 + if ((!is_integer($v_value)) || ($v_value<0)) {
  1479 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  1480 + return PclZip::errorCode();
  1481 + }
  1482 +
  1483 + // ----- Get the value (and convert it in bytes)
  1484 + $v_result_list[$p_options_list[$i]] = $v_value*1048576;
  1485 + $i++;
  1486 + break;
  1487 +
  1488 + case PCLZIP_OPT_TEMP_FILE_ON :
  1489 + // ----- Check for incompatible options
  1490 + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
  1491 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
  1492 + return PclZip::errorCode();
  1493 + }
  1494 +
  1495 + $v_result_list[$p_options_list[$i]] = true;
  1496 + break;
  1497 +
  1498 + case PCLZIP_OPT_TEMP_FILE_OFF :
  1499 + // ----- Check for incompatible options
  1500 + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
  1501 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
  1502 + return PclZip::errorCode();
  1503 + }
  1504 + // ----- Check for incompatible options
  1505 + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
  1506 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
  1507 + return PclZip::errorCode();
  1508 + }
  1509 +
  1510 + $v_result_list[$p_options_list[$i]] = true;
  1511 + break;
  1512 +
1489 case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : 1513 case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1490 // ----- Check the number of parameters 1514 // ----- Check the number of parameters
1491 if (($i+1) >= $p_size) { 1515 if (($i+1) >= $p_size) {
@@ -1493,19 +1517,16 @@ @@ -1493,19 +1517,16 @@
1493 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1517 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1494 1518
1495 // ----- Return 1519 // ----- Return
1496 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1497 return PclZip::errorCode(); 1520 return PclZip::errorCode();
1498 } 1521 }
1499 1522
1500 // ----- Get the value 1523 // ----- Get the value
1501 if ( is_string($p_options_list[$i+1]) 1524 if ( is_string($p_options_list[$i+1])
1502 && ($p_options_list[$i+1] != '')) { 1525 && ($p_options_list[$i+1] != '')) {
1503 - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);  
1504 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); 1526 + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1505 $i++; 1527 $i++;
1506 } 1528 }
1507 else { 1529 else {
1508 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored.");  
1509 } 1530 }
1510 break; 1531 break;
1511 1532
@@ -1517,7 +1538,6 @@ @@ -1517,7 +1538,6 @@
1517 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1538 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1518 1539
1519 // ----- Return 1540 // ----- Return
1520 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1521 return PclZip::errorCode(); 1541 return PclZip::errorCode();
1522 } 1542 }
1523 1543
@@ -1533,15 +1553,16 @@ @@ -1533,15 +1553,16 @@
1533 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1553 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1534 1554
1535 // ----- Return 1555 // ----- Return
1536 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1537 return PclZip::errorCode(); 1556 return PclZip::errorCode();
1538 } 1557 }
1539 - ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");  
1540 $i++; 1558 $i++;
1541 break; 1559 break;
1542 1560
1543 // ----- Look for options that request an EREG or PREG expression 1561 // ----- Look for options that request an EREG or PREG expression
1544 case PCLZIP_OPT_BY_EREG : 1562 case PCLZIP_OPT_BY_EREG :
  1563 + // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
  1564 + // to PCLZIP_OPT_BY_PREG
  1565 + $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1545 case PCLZIP_OPT_BY_PREG : 1566 case PCLZIP_OPT_BY_PREG :
1546 //case PCLZIP_OPT_CRYPT : 1567 //case PCLZIP_OPT_CRYPT :
1547 // ----- Check the number of parameters 1568 // ----- Check the number of parameters
@@ -1550,7 +1571,6 @@ @@ -1550,7 +1571,6 @@
1550 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1571 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1551 1572
1552 // ----- Return 1573 // ----- Return
1553 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1554 return PclZip::errorCode(); 1574 return PclZip::errorCode();
1555 } 1575 }
1556 1576
@@ -1563,10 +1583,8 @@ @@ -1563,10 +1583,8 @@
1563 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1583 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1564 1584
1565 // ----- Return 1585 // ----- Return
1566 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1567 return PclZip::errorCode(); 1586 return PclZip::errorCode();
1568 } 1587 }
1569 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");  
1570 $i++; 1588 $i++;
1571 break; 1589 break;
1572 1590
@@ -1583,7 +1601,6 @@ @@ -1583,7 +1601,6 @@
1583 ."'"); 1601 ."'");
1584 1602
1585 // ----- Return 1603 // ----- Return
1586 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1587 return PclZip::errorCode(); 1604 return PclZip::errorCode();
1588 } 1605 }
1589 1606
@@ -1599,10 +1616,8 @@ @@ -1599,10 +1616,8 @@
1599 ."'"); 1616 ."'");
1600 1617
1601 // ----- Return 1618 // ----- Return
1602 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1603 return PclZip::errorCode(); 1619 return PclZip::errorCode();
1604 } 1620 }
1605 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");  
1606 $i++; 1621 $i++;
1607 break; 1622 break;
1608 1623
@@ -1614,14 +1629,12 @@ @@ -1614,14 +1629,12 @@
1614 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1629 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1615 1630
1616 // ----- Return 1631 // ----- Return
1617 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1618 return PclZip::errorCode(); 1632 return PclZip::errorCode();
1619 } 1633 }
1620 1634
1621 // ----- Get the value 1635 // ----- Get the value
1622 $v_work_list = array(); 1636 $v_work_list = array();
1623 if (is_string($p_options_list[$i+1])) { 1637 if (is_string($p_options_list[$i+1])) {
1624 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");  
1625 1638
1626 // ----- Remove spaces 1639 // ----- Remove spaces
1627 $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); 1640 $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
@@ -1630,11 +1643,9 @@ @@ -1630,11 +1643,9 @@
1630 $v_work_list = explode(",", $p_options_list[$i+1]); 1643 $v_work_list = explode(",", $p_options_list[$i+1]);
1631 } 1644 }
1632 else if (is_integer($p_options_list[$i+1])) { 1645 else if (is_integer($p_options_list[$i+1])) {
1633 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");  
1634 $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; 1646 $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1635 } 1647 }
1636 else if (is_array($p_options_list[$i+1])) { 1648 else if (is_array($p_options_list[$i+1])) {
1637 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");  
1638 $v_work_list = $p_options_list[$i+1]; 1649 $v_work_list = $p_options_list[$i+1];
1639 } 1650 }
1640 else { 1651 else {
@@ -1642,10 +1653,9 @@ @@ -1642,10 +1653,9 @@
1642 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1653 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1643 1654
1644 // ----- Return 1655 // ----- Return
1645 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1646 return PclZip::errorCode(); 1656 return PclZip::errorCode();
1647 } 1657 }
1648 - 1658 +
1649 // ----- Reduce the index list 1659 // ----- Reduce the index list
1650 // each index item in the list must be a couple with a start and 1660 // each index item in the list must be a couple with a start and
1651 // an end value : [0,3], [5-5], [8-10], ... 1661 // an end value : [0,3], [5-5], [8-10], ...
@@ -1656,10 +1666,10 @@ @@ -1656,10 +1666,10 @@
1656 // ----- Explode the item 1666 // ----- Explode the item
1657 $v_item_list = explode("-", $v_work_list[$j]); 1667 $v_item_list = explode("-", $v_work_list[$j]);
1658 $v_size_item_list = sizeof($v_item_list); 1668 $v_size_item_list = sizeof($v_item_list);
1659 - 1669 +
1660 // ----- TBC : Here we might check that each item is a 1670 // ----- TBC : Here we might check that each item is a
1661 // real integer ... 1671 // real integer ...
1662 - 1672 +
1663 // ----- Look for single value 1673 // ----- Look for single value
1664 if ($v_size_item_list == 1) { 1674 if ($v_size_item_list == 1) {
1665 // ----- Set the option value 1675 // ----- Set the option value
@@ -1676,15 +1686,12 @@ @@ -1676,15 +1686,12 @@
1676 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1686 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1677 1687
1678 // ----- Return 1688 // ----- Return
1679 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1680 return PclZip::errorCode(); 1689 return PclZip::errorCode();
1681 } 1690 }
1682 1691
1683 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");  
1684 1692
1685 // ----- Look for list sort 1693 // ----- Look for list sort
1686 if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { 1694 if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1687 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");  
1688 $v_sort_flag=true; 1695 $v_sort_flag=true;
1689 1696
1690 // ----- TBC : An automatic sort should be writen ... 1697 // ----- TBC : An automatic sort should be writen ...
@@ -1692,16 +1699,14 @@ @@ -1692,16 +1699,14 @@
1692 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1699 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1693 1700
1694 // ----- Return 1701 // ----- Return
1695 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1696 return PclZip::errorCode(); 1702 return PclZip::errorCode();
1697 } 1703 }
1698 $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; 1704 $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1699 } 1705 }
1700 - 1706 +
1701 // ----- Sort the items 1707 // ----- Sort the items
1702 if ($v_sort_flag) { 1708 if ($v_sort_flag) {
1703 // TBC : To Be Completed 1709 // TBC : To Be Completed
1704 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");  
1705 } 1710 }
1706 1711
1707 // ----- Next option 1712 // ----- Next option
@@ -1716,7 +1721,6 @@ @@ -1716,7 +1721,6 @@
1716 case PCLZIP_OPT_REPLACE_NEWER : 1721 case PCLZIP_OPT_REPLACE_NEWER :
1717 case PCLZIP_OPT_STOP_ON_ERROR : 1722 case PCLZIP_OPT_STOP_ON_ERROR :
1718 $v_result_list[$p_options_list[$i]] = true; 1723 $v_result_list[$p_options_list[$i]] = true;
1719 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");  
1720 break; 1724 break;
1721 1725
1722 // ----- Look for options that request an octal value 1726 // ----- Look for options that request an octal value
@@ -1727,13 +1731,11 @@ @@ -1727,13 +1731,11 @@
1727 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1731 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1728 1732
1729 // ----- Return 1733 // ----- Return
1730 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1731 return PclZip::errorCode(); 1734 return PclZip::errorCode();
1732 } 1735 }
1733 1736
1734 // ----- Get the value 1737 // ----- Get the value
1735 $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; 1738 $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1736 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");  
1737 $i++; 1739 $i++;
1738 break; 1740 break;
1739 1741
@@ -1754,13 +1756,11 @@ @@ -1754,13 +1756,11 @@
1754 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1756 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1755 1757
1756 // ----- Return 1758 // ----- Return
1757 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1758 return PclZip::errorCode(); 1759 return PclZip::errorCode();
1759 } 1760 }
1760 1761
1761 // ----- Get the value 1762 // ----- Get the value
1762 $v_function_name = $p_options_list[$i+1]; 1763 $v_function_name = $p_options_list[$i+1];
1763 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");  
1764 1764
1765 // ----- Check that the value is a valid existing function 1765 // ----- Check that the value is a valid existing function
1766 if (!function_exists($v_function_name)) { 1766 if (!function_exists($v_function_name)) {
@@ -1768,7 +1768,6 @@ @@ -1768,7 +1768,6 @@
1768 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); 1768 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1769 1769
1770 // ----- Return 1770 // ----- Return
1771 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1772 return PclZip::errorCode(); 1771 return PclZip::errorCode();
1773 } 1772 }
1774 1773
@@ -1784,7 +1783,6 @@ @@ -1784,7 +1783,6 @@
1784 .$p_options_list[$i]."'"); 1783 .$p_options_list[$i]."'");
1785 1784
1786 // ----- Return 1785 // ----- Return
1787 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1788 return PclZip::errorCode(); 1786 return PclZip::errorCode();
1789 } 1787 }
1790 1788
@@ -1797,22 +1795,66 @@ @@ -1797,22 +1795,66 @@
1797 for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { 1795 for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1798 // ----- Look for mandatory option 1796 // ----- Look for mandatory option
1799 if ($v_requested_options[$key] == 'mandatory') { 1797 if ($v_requested_options[$key] == 'mandatory') {
1800 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");  
1801 // ----- Look if present 1798 // ----- Look if present
1802 if (!isset($v_result_list[$key])) { 1799 if (!isset($v_result_list[$key])) {
1803 // ----- Error log 1800 // ----- Error log
1804 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); 1801 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1805 1802
1806 // ----- Return 1803 // ----- Return
1807 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1808 return PclZip::errorCode(); 1804 return PclZip::errorCode();
1809 } 1805 }
1810 } 1806 }
1811 } 1807 }
1812 } 1808 }
  1809 +
  1810 + // ----- Look for default values
  1811 + if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
  1812 +
  1813 + }
1813 1814
1814 // ----- Return 1815 // ----- Return
1815 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); 1816 + return $v_result;
  1817 + }
  1818 + // --------------------------------------------------------------------------------
  1819 +
  1820 + // --------------------------------------------------------------------------------
  1821 + // Function : privOptionDefaultThreshold()
  1822 + // Description :
  1823 + // Parameters :
  1824 + // Return Values :
  1825 + // --------------------------------------------------------------------------------
  1826 + function privOptionDefaultThreshold(&$p_options)
  1827 + {
  1828 + $v_result=1;
  1829 +
  1830 + if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
  1831 + || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
  1832 + return $v_result;
  1833 + }
  1834 +
  1835 + // ----- Get 'memory_limit' configuration value
  1836 + $v_memory_limit = ini_get('memory_limit');
  1837 + $v_memory_limit = trim($v_memory_limit);
  1838 + $last = strtolower(substr($v_memory_limit, -1));
  1839 +
  1840 + if($last == 'g')
  1841 + //$v_memory_limit = $v_memory_limit*1024*1024*1024;
  1842 + $v_memory_limit = $v_memory_limit*1073741824;
  1843 + if($last == 'm')
  1844 + //$v_memory_limit = $v_memory_limit*1024*1024;
  1845 + $v_memory_limit = $v_memory_limit*1048576;
  1846 + if($last == 'k')
  1847 + $v_memory_limit = $v_memory_limit*1024;
  1848 +
  1849 + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
  1850 +
  1851 +
  1852 + // ----- Sanity check : No threshold if value lower than 1M
  1853 + if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
  1854 + unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
  1855 + }
  1856 +
  1857 + // ----- Return
1816 return $v_result; 1858 return $v_result;
1817 } 1859 }
1818 // -------------------------------------------------------------------------------- 1860 // --------------------------------------------------------------------------------
@@ -1827,19 +1869,17 @@ @@ -1827,19 +1869,17 @@
1827 // -------------------------------------------------------------------------------- 1869 // --------------------------------------------------------------------------------
1828 function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) 1870 function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1829 { 1871 {
1830 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", "");  
1831 $v_result=1; 1872 $v_result=1;
1832 - 1873 +
1833 // ----- For each file in the list check the attributes 1874 // ----- For each file in the list check the attributes
1834 foreach ($p_file_list as $v_key => $v_value) { 1875 foreach ($p_file_list as $v_key => $v_value) {
1835 - 1876 +
1836 // ----- Check if the option is supported 1877 // ----- Check if the option is supported
1837 if (!isset($v_requested_options[$v_key])) { 1878 if (!isset($v_requested_options[$v_key])) {
1838 // ----- Error log 1879 // ----- Error log
1839 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); 1880 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1840 1881
1841 // ----- Return 1882 // ----- Return
1842 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1843 return PclZip::errorCode(); 1883 return PclZip::errorCode();
1844 } 1884 }
1845 1885
@@ -1848,16 +1888,13 @@ @@ -1848,16 +1888,13 @@
1848 case PCLZIP_ATT_FILE_NAME : 1888 case PCLZIP_ATT_FILE_NAME :
1849 if (!is_string($v_value)) { 1889 if (!is_string($v_value)) {
1850 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); 1890 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1851 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1852 return PclZip::errorCode(); 1891 return PclZip::errorCode();
1853 } 1892 }
1854 1893
1855 $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); 1894 $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1856 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");  
1857 - 1895 +
1858 if ($p_filedescr['filename'] == '') { 1896 if ($p_filedescr['filename'] == '') {
1859 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); 1897 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1860 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1861 return PclZip::errorCode(); 1898 return PclZip::errorCode();
1862 } 1899 }
1863 1900
@@ -1866,16 +1903,13 @@ @@ -1866,16 +1903,13 @@
1866 case PCLZIP_ATT_FILE_NEW_SHORT_NAME : 1903 case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1867 if (!is_string($v_value)) { 1904 if (!is_string($v_value)) {
1868 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); 1905 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1869 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1870 return PclZip::errorCode(); 1906 return PclZip::errorCode();
1871 } 1907 }
1872 1908
1873 $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); 1909 $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1874 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");  
1875 1910
1876 if ($p_filedescr['new_short_name'] == '') { 1911 if ($p_filedescr['new_short_name'] == '') {
1877 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); 1912 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1878 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1879 return PclZip::errorCode(); 1913 return PclZip::errorCode();
1880 } 1914 }
1881 break; 1915 break;
@@ -1883,27 +1917,46 @@ @@ -1883,27 +1917,46 @@
1883 case PCLZIP_ATT_FILE_NEW_FULL_NAME : 1917 case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1884 if (!is_string($v_value)) { 1918 if (!is_string($v_value)) {
1885 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); 1919 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1886 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1887 return PclZip::errorCode(); 1920 return PclZip::errorCode();
1888 } 1921 }
1889 1922
1890 $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); 1923 $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1891 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");  
1892 1924
1893 if ($p_filedescr['new_full_name'] == '') { 1925 if ($p_filedescr['new_full_name'] == '') {
1894 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); 1926 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1895 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1896 return PclZip::errorCode(); 1927 return PclZip::errorCode();
1897 } 1928 }
1898 break; 1929 break;
1899 1930
  1931 + // ----- Look for options that takes a string
  1932 + case PCLZIP_ATT_FILE_COMMENT :
  1933 + if (!is_string($v_value)) {
  1934 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
  1935 + return PclZip::errorCode();
  1936 + }
  1937 +
  1938 + $p_filedescr['comment'] = $v_value;
  1939 + break;
  1940 +
  1941 + case PCLZIP_ATT_FILE_MTIME :
  1942 + if (!is_integer($v_value)) {
  1943 + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
  1944 + return PclZip::errorCode();
  1945 + }
  1946 +
  1947 + $p_filedescr['mtime'] = $v_value;
  1948 + break;
  1949 +
  1950 + case PCLZIP_ATT_FILE_CONTENT :
  1951 + $p_filedescr['content'] = $v_value;
  1952 + break;
  1953 +
1900 default : 1954 default :
1901 // ----- Error log 1955 // ----- Error log
1902 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 1956 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1903 "Unknown parameter '".$v_key."'"); 1957 "Unknown parameter '".$v_key."'");
1904 1958
1905 // ----- Return 1959 // ----- Return
1906 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1907 return PclZip::errorCode(); 1960 return PclZip::errorCode();
1908 } 1961 }
1909 1962
@@ -1912,22 +1965,19 @@ @@ -1912,22 +1965,19 @@
1912 for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { 1965 for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1913 // ----- Look for mandatory option 1966 // ----- Look for mandatory option
1914 if ($v_requested_options[$key] == 'mandatory') { 1967 if ($v_requested_options[$key] == 'mandatory') {
1915 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");  
1916 // ----- Look if present 1968 // ----- Look if present
1917 if (!isset($p_file_list[$key])) { 1969 if (!isset($p_file_list[$key])) {
1918 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); 1970 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1919 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1920 return PclZip::errorCode(); 1971 return PclZip::errorCode();
1921 } 1972 }
1922 } 1973 }
1923 } 1974 }
1924 } 1975 }
1925 - 1976 +
1926 // end foreach 1977 // end foreach
1927 } 1978 }
1928 - 1979 +
1929 // ----- Return 1980 // ----- Return
1930 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
1931 return $v_result; 1981 return $v_result;
1932 } 1982 }
1933 // -------------------------------------------------------------------------------- 1983 // --------------------------------------------------------------------------------
@@ -1935,6 +1985,12 @@ @@ -1935,6 +1985,12 @@
1935 // -------------------------------------------------------------------------------- 1985 // --------------------------------------------------------------------------------
1936 // Function : privFileDescrExpand() 1986 // Function : privFileDescrExpand()
1937 // Description : 1987 // Description :
  1988 + // This method look for each item of the list to see if its a file, a folder
  1989 + // or a string to be added as file. For any other type of files (link, other)
  1990 + // just ignore the item.
  1991 + // Then prepare the information that will be stored for that file.
  1992 + // When its a folder, expand the folder with all the files that are in that
  1993 + // folder (recursively).
1938 // Parameters : 1994 // Parameters :
1939 // Return Values : 1995 // Return Values :
1940 // 1 on success. 1996 // 1 on success.
@@ -1942,58 +1998,59 @@ @@ -1942,58 +1998,59 @@
1942 // -------------------------------------------------------------------------------- 1998 // --------------------------------------------------------------------------------
1943 function privFileDescrExpand(&$p_filedescr_list, &$p_options) 1999 function privFileDescrExpand(&$p_filedescr_list, &$p_options)
1944 { 2000 {
1945 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", "");  
1946 $v_result=1; 2001 $v_result=1;
1947 - 2002 +
1948 // ----- Create a result list 2003 // ----- Create a result list
1949 $v_result_list = array(); 2004 $v_result_list = array();
1950 - 2005 +
1951 // ----- Look each entry 2006 // ----- Look each entry
1952 for ($i=0; $i<sizeof($p_filedescr_list); $i++) { 2007 for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
  2008 +
1953 // ----- Get filedescr 2009 // ----- Get filedescr
1954 $v_descr = $p_filedescr_list[$i]; 2010 $v_descr = $p_filedescr_list[$i];
1955 - 2011 +
1956 // ----- Reduce the filename 2012 // ----- Reduce the filename
1957 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr before reduction :'".$v_descr['filename']."'");  
1958 - $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename']); 2013 + $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
1959 $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); 2014 $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
1960 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'");  
1961 -  
1962 - // ----- Get type of descr  
1963 - if (!file_exists($v_descr['filename'])) { 2015 +
  2016 + // ----- Look for real file or folder
  2017 + if (file_exists($v_descr['filename'])) {
  2018 + if (@is_file($v_descr['filename'])) {
  2019 + $v_descr['type'] = 'file';
  2020 + }
  2021 + else if (@is_dir($v_descr['filename'])) {
  2022 + $v_descr['type'] = 'folder';
  2023 + }
  2024 + else if (@is_link($v_descr['filename'])) {
  2025 + // skip
  2026 + continue;
  2027 + }
  2028 + else {
  2029 + // skip
  2030 + continue;
  2031 + }
  2032 + }
  2033 +
  2034 + // ----- Look for string added as file
  2035 + else if (isset($v_descr['content'])) {
  2036 + $v_descr['type'] = 'virtual_file';
  2037 + }
  2038 +
  2039 + // ----- Missing file
  2040 + else {
1964 // ----- Error log 2041 // ----- Error log
1965 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_descr['filename']."' does not exists");  
1966 - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exists"); 2042 + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
1967 2043
1968 // ----- Return 2044 // ----- Return
1969 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
1970 return PclZip::errorCode(); 2045 return PclZip::errorCode();
1971 } 2046 }
1972 - if (@is_file($v_descr['filename'])) {  
1973 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file");  
1974 - $v_descr['type'] = 'file';  
1975 - }  
1976 - else if (@is_dir($v_descr['filename'])) {  
1977 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder");  
1978 - $v_descr['type'] = 'folder';  
1979 - }  
1980 - else if (@is_link($v_descr['filename'])) {  
1981 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link");  
1982 - // skip  
1983 - continue;  
1984 - }  
1985 - else {  
1986 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type");  
1987 - // skip  
1988 - continue;  
1989 - }  
1990 - 2047 +
1991 // ----- Calculate the stored filename 2048 // ----- Calculate the stored filename
1992 $this->privCalculateStoredFilename($v_descr, $p_options); 2049 $this->privCalculateStoredFilename($v_descr, $p_options);
1993 - 2050 +
1994 // ----- Add the descriptor in result list 2051 // ----- Add the descriptor in result list
1995 $v_result_list[sizeof($v_result_list)] = $v_descr; 2052 $v_result_list[sizeof($v_result_list)] = $v_descr;
1996 - 2053 +
1997 // ----- Look for folder 2054 // ----- Look for folder
1998 if ($v_descr['type'] == 'folder') { 2055 if ($v_descr['type'] == 'folder') {
1999 // ----- List of items in folder 2056 // ----- List of items in folder
@@ -2001,58 +2058,59 @@ @@ -2001,58 +2058,59 @@
2001 $v_dirlist_nb = 0; 2058 $v_dirlist_nb = 0;
2002 if ($v_folder_handler = @opendir($v_descr['filename'])) { 2059 if ($v_folder_handler = @opendir($v_descr['filename'])) {
2003 while (($v_item_handler = @readdir($v_folder_handler)) !== false) { 2060 while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2004 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory");  
2005 2061
2006 // ----- Skip '.' and '..' 2062 // ----- Skip '.' and '..'
2007 if (($v_item_handler == '.') || ($v_item_handler == '..')) { 2063 if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2008 continue; 2064 continue;
2009 } 2065 }
2010 - 2066 +
2011 // ----- Compose the full filename 2067 // ----- Compose the full filename
2012 $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; 2068 $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2013 - 2069 +
2014 // ----- Look for different stored filename 2070 // ----- Look for different stored filename
2015 // Because the name of the folder was changed, the name of the 2071 // Because the name of the folder was changed, the name of the
2016 // files/sub-folders also change 2072 // files/sub-folders also change
2017 - if ($v_descr['stored_filename'] != $v_descr['filename']) {  
2018 - $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; 2073 + if (($v_descr['stored_filename'] != $v_descr['filename'])
  2074 + && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
  2075 + if ($v_descr['stored_filename'] != '') {
  2076 + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
  2077 + }
  2078 + else {
  2079 + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
  2080 + }
2019 } 2081 }
2020 - 2082 +
2021 $v_dirlist_nb++; 2083 $v_dirlist_nb++;
2022 } 2084 }
  2085 +
  2086 + @closedir($v_folder_handler);
2023 } 2087 }
2024 else { 2088 else {
2025 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped.");  
2026 // TBC : unable to open folder in read mode 2089 // TBC : unable to open folder in read mode
2027 } 2090 }
2028 - 2091 +
2029 // ----- Expand each element of the list 2092 // ----- Expand each element of the list
2030 if ($v_dirlist_nb != 0) { 2093 if ($v_dirlist_nb != 0) {
2031 // ----- Expand 2094 // ----- Expand
2032 if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { 2095 if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2033 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2034 return $v_result; 2096 return $v_result;
2035 } 2097 }
2036 - 2098 +
2037 // ----- Concat the resulting list 2099 // ----- Concat the resulting list
2038 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')");  
2039 $v_result_list = array_merge($v_result_list, $v_dirlist_descr); 2100 $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2040 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'");  
2041 } 2101 }
2042 else { 2102 else {
2043 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand.");  
2044 } 2103 }
2045 - 2104 +
2046 // ----- Free local array 2105 // ----- Free local array
2047 unset($v_dirlist_descr); 2106 unset($v_dirlist_descr);
2048 } 2107 }
2049 } 2108 }
2050 - 2109 +
2051 // ----- Get the result list 2110 // ----- Get the result list
2052 $p_filedescr_list = $v_result_list; 2111 $p_filedescr_list = $v_result_list;
2053 2112
2054 // ----- Return 2113 // ----- Return
2055 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2056 return $v_result; 2114 return $v_result;
2057 } 2115 }
2058 // -------------------------------------------------------------------------------- 2116 // --------------------------------------------------------------------------------
@@ -2065,10 +2123,9 @@ @@ -2065,10 +2123,9 @@
2065 // -------------------------------------------------------------------------------- 2123 // --------------------------------------------------------------------------------
2066 function privCreate($p_filedescr_list, &$p_result_list, &$p_options) 2124 function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2067 { 2125 {
2068 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list");  
2069 $v_result=1; 2126 $v_result=1;
2070 $v_list_detail = array(); 2127 $v_list_detail = array();
2071 - 2128 +
2072 // ----- Magic quotes trick 2129 // ----- Magic quotes trick
2073 $this->privDisableMagicQuotes(); 2130 $this->privDisableMagicQuotes();
2074 2131
@@ -2076,7 +2133,6 @@ @@ -2076,7 +2133,6 @@
2076 if (($v_result = $this->privOpenFd('wb')) != 1) 2133 if (($v_result = $this->privOpenFd('wb')) != 1)
2077 { 2134 {
2078 // ----- Return 2135 // ----- Return
2079 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2080 return $v_result; 2136 return $v_result;
2081 } 2137 }
2082 2138
@@ -2090,7 +2146,6 @@ @@ -2090,7 +2146,6 @@
2090 $this->privSwapBackMagicQuotes(); 2146 $this->privSwapBackMagicQuotes();
2091 2147
2092 // ----- Return 2148 // ----- Return
2093 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2094 return $v_result; 2149 return $v_result;
2095 } 2150 }
2096 // -------------------------------------------------------------------------------- 2151 // --------------------------------------------------------------------------------
@@ -2103,34 +2158,29 @@ @@ -2103,34 +2158,29 @@
2103 // -------------------------------------------------------------------------------- 2158 // --------------------------------------------------------------------------------
2104 function privAdd($p_filedescr_list, &$p_result_list, &$p_options) 2159 function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2105 { 2160 {
2106 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list");  
2107 $v_result=1; 2161 $v_result=1;
2108 $v_list_detail = array(); 2162 $v_list_detail = array();
2109 2163
2110 // ----- Look if the archive exists or is empty 2164 // ----- Look if the archive exists or is empty
2111 if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) 2165 if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2112 { 2166 {
2113 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");  
2114 2167
2115 // ----- Do a create 2168 // ----- Do a create
2116 $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); 2169 $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2117 2170
2118 // ----- Return 2171 // ----- Return
2119 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2120 return $v_result; 2172 return $v_result;
2121 } 2173 }
2122 // ----- Magic quotes trick 2174 // ----- Magic quotes trick
2123 $this->privDisableMagicQuotes(); 2175 $this->privDisableMagicQuotes();
2124 2176
2125 // ----- Open the zip file 2177 // ----- Open the zip file
2126 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
2127 if (($v_result=$this->privOpenFd('rb')) != 1) 2178 if (($v_result=$this->privOpenFd('rb')) != 1)
2128 { 2179 {
2129 // ----- Magic quotes trick 2180 // ----- Magic quotes trick
2130 $this->privSwapBackMagicQuotes(); 2181 $this->privSwapBackMagicQuotes();
2131 2182
2132 // ----- Return 2183 // ----- Return
2133 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2134 return $v_result; 2184 return $v_result;
2135 } 2185 }
2136 2186
@@ -2140,20 +2190,16 @@ @@ -2140,20 +2190,16 @@
2140 { 2190 {
2141 $this->privCloseFd(); 2191 $this->privCloseFd();
2142 $this->privSwapBackMagicQuotes(); 2192 $this->privSwapBackMagicQuotes();
2143 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2144 return $v_result; 2193 return $v_result;
2145 } 2194 }
2146 2195
2147 // ----- Go to beginning of File 2196 // ----- Go to beginning of File
2148 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");  
2149 @rewind($this->zip_fd); 2197 @rewind($this->zip_fd);
2150 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");  
2151 2198
2152 // ----- Creates a temporay file 2199 // ----- Creates a temporay file
2153 $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; 2200 $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2154 2201
2155 // ----- Open the temporary file in write mode 2202 // ----- Open the temporary file in write mode
2156 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
2157 if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) 2203 if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2158 { 2204 {
2159 $this->privCloseFd(); 2205 $this->privCloseFd();
@@ -2162,7 +2208,6 @@ @@ -2162,7 +2208,6 @@
2162 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); 2208 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2163 2209
2164 // ----- Return 2210 // ----- Return
2165 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
2166 return PclZip::errorCode(); 2211 return PclZip::errorCode();
2167 } 2212 }
2168 2213
@@ -2172,7 +2217,6 @@ @@ -2172,7 +2217,6 @@
2172 while ($v_size != 0) 2217 while ($v_size != 0)
2173 { 2218 {
2174 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 2219 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2175 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
2176 $v_buffer = fread($this->zip_fd, $v_read_size); 2220 $v_buffer = fread($this->zip_fd, $v_read_size);
2177 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); 2221 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2178 $v_size -= $v_read_size; 2222 $v_size -= $v_read_size;
@@ -2195,20 +2239,17 @@ @@ -2195,20 +2239,17 @@
2195 $this->privSwapBackMagicQuotes(); 2239 $this->privSwapBackMagicQuotes();
2196 2240
2197 // ----- Return 2241 // ----- Return
2198 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2199 return $v_result; 2242 return $v_result;
2200 } 2243 }
2201 2244
2202 // ----- Store the offset of the central dir 2245 // ----- Store the offset of the central dir
2203 $v_offset = @ftell($this->zip_fd); 2246 $v_offset = @ftell($this->zip_fd);
2204 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");  
2205 2247
2206 // ----- Copy the block of file headers from the old archive 2248 // ----- Copy the block of file headers from the old archive
2207 $v_size = $v_central_dir['size']; 2249 $v_size = $v_central_dir['size'];
2208 while ($v_size != 0) 2250 while ($v_size != 0)
2209 { 2251 {
2210 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 2252 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2211 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
2212 $v_buffer = @fread($v_zip_temp_fd, $v_read_size); 2253 $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2213 @fwrite($this->zip_fd, $v_buffer, $v_read_size); 2254 @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2214 $v_size -= $v_read_size; 2255 $v_size -= $v_read_size;
@@ -2226,7 +2267,6 @@ @@ -2226,7 +2267,6 @@
2226 $this->privSwapBackMagicQuotes(); 2267 $this->privSwapBackMagicQuotes();
2227 2268
2228 // ----- Return 2269 // ----- Return
2229 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2230 return $v_result; 2270 return $v_result;
2231 } 2271 }
2232 $v_count++; 2272 $v_count++;
@@ -2259,7 +2299,6 @@ @@ -2259,7 +2299,6 @@
2259 $this->privSwapBackMagicQuotes(); 2299 $this->privSwapBackMagicQuotes();
2260 2300
2261 // ----- Return 2301 // ----- Return
2262 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2263 return $v_result; 2302 return $v_result;
2264 } 2303 }
2265 2304
@@ -2287,7 +2326,6 @@ @@ -2287,7 +2326,6 @@
2287 PclZipUtilRename($v_zip_temp_name, $this->zipname); 2326 PclZipUtilRename($v_zip_temp_name, $this->zipname);
2288 2327
2289 // ----- Return 2328 // ----- Return
2290 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2291 return $v_result; 2329 return $v_result;
2292 } 2330 }
2293 // -------------------------------------------------------------------------------- 2331 // --------------------------------------------------------------------------------
@@ -2299,7 +2337,6 @@ @@ -2299,7 +2337,6 @@
2299 // -------------------------------------------------------------------------------- 2337 // --------------------------------------------------------------------------------
2300 function privOpenFd($p_mode) 2338 function privOpenFd($p_mode)
2301 { 2339 {
2302 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);  
2303 $v_result=1; 2340 $v_result=1;
2304 2341
2305 // ----- Look if already open 2342 // ----- Look if already open
@@ -2309,24 +2346,20 @@ @@ -2309,24 +2346,20 @@
2309 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); 2346 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2310 2347
2311 // ----- Return 2348 // ----- Return
2312 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
2313 return PclZip::errorCode(); 2349 return PclZip::errorCode();
2314 } 2350 }
2315 2351
2316 // ----- Open the zip file 2352 // ----- Open the zip file
2317 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');  
2318 if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) 2353 if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2319 { 2354 {
2320 // ----- Error log 2355 // ----- Error log
2321 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); 2356 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2322 2357
2323 // ----- Return 2358 // ----- Return
2324 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
2325 return PclZip::errorCode(); 2359 return PclZip::errorCode();
2326 } 2360 }
2327 2361
2328 // ----- Return 2362 // ----- Return
2329 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2330 return $v_result; 2363 return $v_result;
2331 } 2364 }
2332 // -------------------------------------------------------------------------------- 2365 // --------------------------------------------------------------------------------
@@ -2338,7 +2371,6 @@ @@ -2338,7 +2371,6 @@
2338 // -------------------------------------------------------------------------------- 2371 // --------------------------------------------------------------------------------
2339 function privCloseFd() 2372 function privCloseFd()
2340 { 2373 {
2341 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");  
2342 $v_result=1; 2374 $v_result=1;
2343 2375
2344 if ($this->zip_fd != 0) 2376 if ($this->zip_fd != 0)
@@ -2346,7 +2378,6 @@ @@ -2346,7 +2378,6 @@
2346 $this->zip_fd = 0; 2378 $this->zip_fd = 0;
2347 2379
2348 // ----- Return 2380 // ----- Return
2349 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2350 return $v_result; 2381 return $v_result;
2351 } 2382 }
2352 // -------------------------------------------------------------------------------- 2383 // --------------------------------------------------------------------------------
@@ -2367,7 +2398,6 @@ @@ -2367,7 +2398,6 @@
2367 // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) 2398 // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2368 function privAddList($p_filedescr_list, &$p_result_list, &$p_options) 2399 function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2369 { 2400 {
2370 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list");  
2371 $v_result=1; 2401 $v_result=1;
2372 2402
2373 // ----- Add the files 2403 // ----- Add the files
@@ -2375,7 +2405,6 @@ @@ -2375,7 +2405,6 @@
2375 if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) 2405 if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2376 { 2406 {
2377 // ----- Return 2407 // ----- Return
2378 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2379 return $v_result; 2408 return $v_result;
2380 } 2409 }
2381 2410
@@ -2389,7 +2418,6 @@ @@ -2389,7 +2418,6 @@
2389 if ($v_header_list[$i]['status'] == 'ok') { 2418 if ($v_header_list[$i]['status'] == 'ok') {
2390 if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { 2419 if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2391 // ----- Return 2420 // ----- Return
2392 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2393 return $v_result; 2421 return $v_result;
2394 } 2422 }
2395 $v_count++; 2423 $v_count++;
@@ -2415,12 +2443,10 @@ @@ -2415,12 +2443,10 @@
2415 unset($v_header_list); 2443 unset($v_header_list);
2416 2444
2417 // ----- Return 2445 // ----- Return
2418 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2419 return $v_result; 2446 return $v_result;
2420 } 2447 }
2421 2448
2422 // ----- Return 2449 // ----- Return
2423 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2424 return $v_result; 2450 return $v_result;
2425 } 2451 }
2426 // -------------------------------------------------------------------------------- 2452 // --------------------------------------------------------------------------------
@@ -2429,55 +2455,54 @@ @@ -2429,55 +2455,54 @@
2429 // Function : privAddFileList() 2455 // Function : privAddFileList()
2430 // Description : 2456 // Description :
2431 // Parameters : 2457 // Parameters :
2432 - // $p_filedescr_list : An array containing the file description 2458 + // $p_filedescr_list : An array containing the file description
2433 // or directory names to add in the zip 2459 // or directory names to add in the zip
2434 // $p_result_list : list of added files with their properties (specially the status field) 2460 // $p_result_list : list of added files with their properties (specially the status field)
2435 // Return Values : 2461 // Return Values :
2436 // -------------------------------------------------------------------------------- 2462 // --------------------------------------------------------------------------------
2437 function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) 2463 function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2438 { 2464 {
2439 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list");  
2440 $v_result=1; 2465 $v_result=1;
2441 $v_header = array(); 2466 $v_header = array();
2442 2467
2443 // ----- Recuperate the current number of elt in list 2468 // ----- Recuperate the current number of elt in list
2444 $v_nb = sizeof($p_result_list); 2469 $v_nb = sizeof($p_result_list);
2445 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements");  
2446 2470
2447 // ----- Loop on the files 2471 // ----- Loop on the files
2448 for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { 2472 for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2449 // ----- Format the filename 2473 // ----- Format the filename
2450 $p_filedescr_list[$j]['filename'] 2474 $p_filedescr_list[$j]['filename']
2451 = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); 2475 = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2452 -  
2453 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'"); 2476 +
2454 2477
2455 // ----- Skip empty file names 2478 // ----- Skip empty file names
2456 // TBC : Can this be possible ? not checked in DescrParseAtt ? 2479 // TBC : Can this be possible ? not checked in DescrParseAtt ?
2457 if ($p_filedescr_list[$j]['filename'] == "") { 2480 if ($p_filedescr_list[$j]['filename'] == "") {
2458 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");  
2459 continue; 2481 continue;
2460 } 2482 }
2461 2483
2462 // ----- Check the filename 2484 // ----- Check the filename
2463 - if (!file_exists($p_filedescr_list[$j]['filename'])) {  
2464 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exists");  
2465 - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exists");  
2466 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); 2485 + if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
  2486 + && (!file_exists($p_filedescr_list[$j]['filename']))) {
  2487 + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2467 return PclZip::errorCode(); 2488 return PclZip::errorCode();
2468 } 2489 }
2469 2490
2470 // ----- Look if it is a file or a dir with no all path remove option 2491 // ----- Look if it is a file or a dir with no all path remove option
2471 - if ( (is_file($p_filedescr_list[$j]['filename']))  
2472 - || ( is_dir($p_filedescr_list[$j]['filename']) 2492 + // or a dir with all its path removed
  2493 +// if ( (is_file($p_filedescr_list[$j]['filename']))
  2494 +// || ( is_dir($p_filedescr_list[$j]['filename'])
  2495 + if ( ($p_filedescr_list[$j]['type'] == 'file')
  2496 + || ($p_filedescr_list[$j]['type'] == 'virtual_file')
  2497 + || ( ($p_filedescr_list[$j]['type'] == 'folder')
2473 && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) 2498 && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2474 - || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { 2499 + || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
  2500 + ) {
2475 2501
2476 // ----- Add the file 2502 // ----- Add the file
2477 $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, 2503 $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2478 $p_options); 2504 $p_options);
2479 if ($v_result != 1) { 2505 if ($v_result != 1) {
2480 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2481 return $v_result; 2506 return $v_result;
2482 } 2507 }
2483 2508
@@ -2485,10 +2510,8 @@ @@ -2485,10 +2510,8 @@
2485 $p_result_list[$v_nb++] = $v_header; 2510 $p_result_list[$v_nb++] = $v_header;
2486 } 2511 }
2487 } 2512 }
2488 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements");  
2489 2513
2490 // ----- Return 2514 // ----- Return
2491 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2492 return $v_result; 2515 return $v_result;
2493 } 2516 }
2494 // -------------------------------------------------------------------------------- 2517 // --------------------------------------------------------------------------------
@@ -2501,9 +2524,8 @@ @@ -2501,9 +2524,8 @@
2501 // -------------------------------------------------------------------------------- 2524 // --------------------------------------------------------------------------------
2502 function privAddFile($p_filedescr, &$p_header, &$p_options) 2525 function privAddFile($p_filedescr, &$p_header, &$p_options)
2503 { 2526 {
2504 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'");  
2505 $v_result=1; 2527 $v_result=1;
2506 - 2528 +
2507 // ----- Working variable 2529 // ----- Working variable
2508 $p_filename = $p_filedescr['filename']; 2530 $p_filename = $p_filedescr['filename'];
2509 2531
@@ -2513,19 +2535,18 @@ @@ -2513,19 +2535,18 @@
2513 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); 2535 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2514 2536
2515 // ----- Return 2537 // ----- Return
2516 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
2517 return PclZip::errorCode(); 2538 return PclZip::errorCode();
2518 } 2539 }
2519 -  
2520 - // ----- Look for a stored different filename 2540 +
  2541 + // ----- Look for a stored different filename
  2542 + /* TBC : Removed
2521 if (isset($p_filedescr['stored_filename'])) { 2543 if (isset($p_filedescr['stored_filename'])) {
2522 $v_stored_filename = $p_filedescr['stored_filename']; 2544 $v_stored_filename = $p_filedescr['stored_filename'];
2523 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"');  
2524 } 2545 }
2525 else { 2546 else {
2526 $v_stored_filename = $p_filedescr['stored_filename']; 2547 $v_stored_filename = $p_filedescr['stored_filename'];
2527 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same');  
2528 } 2548 }
  2549 + */
2529 2550
2530 // ----- Set the file properties 2551 // ----- Set the file properties
2531 clearstatcache(); 2552 clearstatcache();
@@ -2533,29 +2554,63 @@ @@ -2533,29 +2554,63 @@
2533 $p_header['version_extracted'] = 10; 2554 $p_header['version_extracted'] = 10;
2534 $p_header['flag'] = 0; 2555 $p_header['flag'] = 0;
2535 $p_header['compression'] = 0; 2556 $p_header['compression'] = 0;
2536 - $p_header['mtime'] = filemtime($p_filename);  
2537 $p_header['crc'] = 0; 2557 $p_header['crc'] = 0;
2538 $p_header['compressed_size'] = 0; 2558 $p_header['compressed_size'] = 0;
2539 - $p_header['size'] = filesize($p_filename);  
2540 $p_header['filename_len'] = strlen($p_filename); 2559 $p_header['filename_len'] = strlen($p_filename);
2541 $p_header['extra_len'] = 0; 2560 $p_header['extra_len'] = 0;
2542 - $p_header['comment_len'] = 0;  
2543 $p_header['disk'] = 0; 2561 $p_header['disk'] = 0;
2544 $p_header['internal'] = 0; 2562 $p_header['internal'] = 0;
2545 -// $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);  
2546 - $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010);  
2547 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'");  
2548 $p_header['offset'] = 0; 2563 $p_header['offset'] = 0;
2549 $p_header['filename'] = $p_filename; 2564 $p_header['filename'] = $p_filename;
2550 - $p_header['stored_filename'] = $v_stored_filename; 2565 +// TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
  2566 + $p_header['stored_filename'] = $p_filedescr['stored_filename'];
2551 $p_header['extra'] = ''; 2567 $p_header['extra'] = '';
2552 - $p_header['comment'] = '';  
2553 $p_header['status'] = 'ok'; 2568 $p_header['status'] = 'ok';
2554 $p_header['index'] = -1; 2569 $p_header['index'] = -1;
2555 2570
  2571 + // ----- Look for regular file
  2572 + if ($p_filedescr['type']=='file') {
  2573 + $p_header['external'] = 0x00000000;
  2574 + $p_header['size'] = filesize($p_filename);
  2575 + }
  2576 +
  2577 + // ----- Look for regular folder
  2578 + else if ($p_filedescr['type']=='folder') {
  2579 + $p_header['external'] = 0x00000010;
  2580 + $p_header['mtime'] = filemtime($p_filename);
  2581 + $p_header['size'] = filesize($p_filename);
  2582 + }
  2583 +
  2584 + // ----- Look for virtual file
  2585 + else if ($p_filedescr['type'] == 'virtual_file') {
  2586 + $p_header['external'] = 0x00000000;
  2587 + $p_header['size'] = strlen($p_filedescr['content']);
  2588 + }
  2589 +
  2590 +
  2591 + // ----- Look for filetime
  2592 + if (isset($p_filedescr['mtime'])) {
  2593 + $p_header['mtime'] = $p_filedescr['mtime'];
  2594 + }
  2595 + else if ($p_filedescr['type'] == 'virtual_file') {
  2596 + $p_header['mtime'] = time();
  2597 + }
  2598 + else {
  2599 + $p_header['mtime'] = filemtime($p_filename);
  2600 + }
  2601 +
  2602 + // ------ Look for file comment
  2603 + if (isset($p_filedescr['comment'])) {
  2604 + $p_header['comment_len'] = strlen($p_filedescr['comment']);
  2605 + $p_header['comment'] = $p_filedescr['comment'];
  2606 + }
  2607 + else {
  2608 + $p_header['comment_len'] = 0;
  2609 + $p_header['comment'] = '';
  2610 + }
  2611 +
2556 // ----- Look for pre-add callback 2612 // ----- Look for pre-add callback
2557 if (isset($p_options[PCLZIP_CB_PRE_ADD])) { 2613 if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2558 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");  
2559 2614
2560 // ----- Generate a local information 2615 // ----- Generate a local information
2561 $v_local_header = array(); 2616 $v_local_header = array();
@@ -2564,7 +2619,8 @@ @@ -2564,7 +2619,8 @@
2564 // ----- Call the callback 2619 // ----- Call the callback
2565 // Here I do not use call_user_func() because I need to send a reference to the 2620 // Here I do not use call_user_func() because I need to send a reference to the
2566 // header. 2621 // header.
2567 - eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); 2622 +// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
  2623 + $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2568 if ($v_result == 0) { 2624 if ($v_result == 0) {
2569 // ----- Change the file status 2625 // ----- Change the file status
2570 $p_header['status'] = "skipped"; 2626 $p_header['status'] = "skipped";
@@ -2575,7 +2631,6 @@ @@ -2575,7 +2631,6 @@
2575 // Only some fields can be modified 2631 // Only some fields can be modified
2576 if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { 2632 if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2577 $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); 2633 $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2578 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");  
2579 } 2634 }
2580 } 2635 }
2581 2636
@@ -2583,7 +2638,7 @@ @@ -2583,7 +2638,7 @@
2583 if ($p_header['stored_filename'] == "") { 2638 if ($p_header['stored_filename'] == "") {
2584 $p_header['status'] = "filtered"; 2639 $p_header['status'] = "filtered";
2585 } 2640 }
2586 - 2641 +
2587 // ----- Check the path length 2642 // ----- Check the path length
2588 if (strlen($p_header['stored_filename']) > 0xFF) { 2643 if (strlen($p_header['stored_filename']) > 0xFF) {
2589 $p_header['status'] = 'filename_too_long'; 2644 $p_header['status'] = 'filename_too_long';
@@ -2593,85 +2648,103 @@ @@ -2593,85 +2648,103 @@
2593 if ($p_header['status'] == 'ok') { 2648 if ($p_header['status'] == 'ok') {
2594 2649
2595 // ----- Look for a file 2650 // ----- Look for a file
2596 - if (is_file($p_filename))  
2597 - {  
2598 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); 2651 + if ($p_filedescr['type'] == 'file') {
  2652 + // ----- Look for using temporary file to zip
  2653 + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
  2654 + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
  2655 + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
  2656 + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
  2657 + $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
  2658 + if ($v_result < PCLZIP_ERR_NO_ERROR) {
  2659 + return $v_result;
  2660 + }
  2661 + }
  2662 +
  2663 + // ----- Use "in memory" zip algo
  2664 + else {
  2665 +
2599 // ----- Open the source file 2666 // ----- Open the source file
2600 if (($v_file = @fopen($p_filename, "rb")) == 0) { 2667 if (($v_file = @fopen($p_filename, "rb")) == 0) {
2601 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); 2668 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2602 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
2603 return PclZip::errorCode(); 2669 return PclZip::errorCode();
2604 } 2670 }
2605 2671
2606 - if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {  
2607 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");  
2608 - // ----- Read the file content  
2609 - $v_content_compressed = @fread($v_file, $p_header['size']); 2672 + // ----- Read the file content
  2673 + $v_content = @fread($v_file, $p_header['size']);
2610 2674
2611 - // ----- Calculate the CRC  
2612 - $p_header['crc'] = @crc32($v_content_compressed); 2675 + // ----- Close the file
  2676 + @fclose($v_file);
2613 2677
  2678 + // ----- Calculate the CRC
  2679 + $p_header['crc'] = @crc32($v_content);
  2680 +
  2681 + // ----- Look for no compression
  2682 + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2614 // ----- Set header parameters 2683 // ----- Set header parameters
2615 $p_header['compressed_size'] = $p_header['size']; 2684 $p_header['compressed_size'] = $p_header['size'];
2616 $p_header['compression'] = 0; 2685 $p_header['compression'] = 0;
2617 } 2686 }
  2687 +
  2688 + // ----- Look for normal compression
2618 else { 2689 else {
2619 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");  
2620 - // ----- Read the file content  
2621 - $v_content = @fread($v_file, $p_header['size']);  
2622 -  
2623 - // ----- Calculate the CRC  
2624 - $p_header['crc'] = @crc32($v_content);  
2625 -  
2626 - // ----- Compress the file  
2627 - $v_content_compressed = @gzdeflate($v_content); 2690 + // ----- Compress the content
  2691 + $v_content = @gzdeflate($v_content);
2628 2692
2629 // ----- Set header parameters 2693 // ----- Set header parameters
2630 - $p_header['compressed_size'] = strlen($v_content_compressed); 2694 + $p_header['compressed_size'] = strlen($v_content);
2631 $p_header['compression'] = 8; 2695 $p_header['compression'] = 8;
2632 } 2696 }
  2697 +
  2698 + // ----- Call the header generation
  2699 + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
  2700 + @fclose($v_file);
  2701 + return $v_result;
  2702 + }
  2703 +
  2704 + // ----- Write the compressed (or not) content
  2705 + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2633 2706
2634 - // ----- Look for encryption  
2635 - /*  
2636 - if ((isset($p_options[PCLZIP_OPT_CRYPT]))  
2637 - && ($p_options[PCLZIP_OPT_CRYPT] != "")) {  
2638 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ....");  
2639 -  
2640 - // Should be a random header  
2641 - $v_header = 'xxxxxxxxxxxx';  
2642 - $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed,  
2643 - $p_header['compressed_size'],  
2644 - $v_header,  
2645 - $p_header['crc'],  
2646 - "test");  
2647 -  
2648 - $p_header['compressed_size'] += 12;  
2649 - $p_header['flag'] = 1;  
2650 -  
2651 - // ----- Add the header to the data  
2652 - $v_content_compressed = $v_header.$v_content_compressed;  
2653 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed)."");  
2654 } 2707 }
2655 - */  
2656 2708
  2709 + }
  2710 +
  2711 + // ----- Look for a virtual file (a file from string)
  2712 + else if ($p_filedescr['type'] == 'virtual_file') {
  2713 +
  2714 + $v_content = $p_filedescr['content'];
  2715 +
  2716 + // ----- Calculate the CRC
  2717 + $p_header['crc'] = @crc32($v_content);
  2718 +
  2719 + // ----- Look for no compression
  2720 + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
  2721 + // ----- Set header parameters
  2722 + $p_header['compressed_size'] = $p_header['size'];
  2723 + $p_header['compression'] = 0;
  2724 + }
  2725 +
  2726 + // ----- Look for normal compression
  2727 + else {
  2728 + // ----- Compress the content
  2729 + $v_content = @gzdeflate($v_content);
  2730 +
  2731 + // ----- Set header parameters
  2732 + $p_header['compressed_size'] = strlen($v_content);
  2733 + $p_header['compression'] = 8;
  2734 + }
  2735 +
2657 // ----- Call the header generation 2736 // ----- Call the header generation
2658 if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { 2737 if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2659 @fclose($v_file); 2738 @fclose($v_file);
2660 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2661 return $v_result; 2739 return $v_result;
2662 } 2740 }
2663 2741
2664 // ----- Write the compressed (or not) content 2742 // ----- Write the compressed (or not) content
2665 - @fwrite($this->zip_fd,  
2666 - $v_content_compressed, $p_header['compressed_size']);  
2667 -  
2668 - // ----- Close the file  
2669 - @fclose($v_file); 2743 + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2670 } 2744 }
2671 2745
2672 // ----- Look for a directory 2746 // ----- Look for a directory
2673 - else {  
2674 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder"); 2747 + else if ($p_filedescr['type'] == 'folder') {
2675 // ----- Look for directory last '/' 2748 // ----- Look for directory last '/'
2676 if (@substr($p_header['stored_filename'], -1) != '/') { 2749 if (@substr($p_header['stored_filename'], -1) != '/') {
2677 $p_header['stored_filename'] .= '/'; 2750 $p_header['stored_filename'] .= '/';
@@ -2685,7 +2758,6 @@ @@ -2685,7 +2758,6 @@
2685 // ----- Call the header generation 2758 // ----- Call the header generation
2686 if (($v_result = $this->privWriteFileHeader($p_header)) != 1) 2759 if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2687 { 2760 {
2688 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2689 return $v_result; 2761 return $v_result;
2690 } 2762 }
2691 } 2763 }
@@ -2693,7 +2765,6 @@ @@ -2693,7 +2765,6 @@
2693 2765
2694 // ----- Look for post-add callback 2766 // ----- Look for post-add callback
2695 if (isset($p_options[PCLZIP_CB_POST_ADD])) { 2767 if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2696 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");  
2697 2768
2698 // ----- Generate a local information 2769 // ----- Generate a local information
2699 $v_local_header = array(); 2770 $v_local_header = array();
@@ -2702,7 +2773,8 @@ @@ -2702,7 +2773,8 @@
2702 // ----- Call the callback 2773 // ----- Call the callback
2703 // Here I do not use call_user_func() because I need to send a reference to the 2774 // Here I do not use call_user_func() because I need to send a reference to the
2704 // header. 2775 // header.
2705 - eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); 2776 +// eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
  2777 + $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2706 if ($v_result == 0) { 2778 if ($v_result == 0) {
2707 // ----- Ignored 2779 // ----- Ignored
2708 $v_result = 1; 2780 $v_result = 1;
@@ -2713,7 +2785,116 @@ @@ -2713,7 +2785,116 @@
2713 } 2785 }
2714 2786
2715 // ----- Return 2787 // ----- Return
2716 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); 2788 + return $v_result;
  2789 + }
  2790 + // --------------------------------------------------------------------------------
  2791 +
  2792 + // --------------------------------------------------------------------------------
  2793 + // Function : privAddFileUsingTempFile()
  2794 + // Description :
  2795 + // Parameters :
  2796 + // Return Values :
  2797 + // --------------------------------------------------------------------------------
  2798 + function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
  2799 + {
  2800 + $v_result=PCLZIP_ERR_NO_ERROR;
  2801 +
  2802 + // ----- Working variable
  2803 + $p_filename = $p_filedescr['filename'];
  2804 +
  2805 +
  2806 + // ----- Open the source file
  2807 + if (($v_file = @fopen($p_filename, "rb")) == 0) {
  2808 + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
  2809 + return PclZip::errorCode();
  2810 + }
  2811 +
  2812 + // ----- Creates a compressed temporary file
  2813 + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
  2814 + if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
  2815 + fclose($v_file);
  2816 + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
  2817 + return PclZip::errorCode();
  2818 + }
  2819 +
  2820 + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
  2821 + $v_size = filesize($p_filename);
  2822 + while ($v_size != 0) {
  2823 + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
  2824 + $v_buffer = @fread($v_file, $v_read_size);
  2825 + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
  2826 + @gzputs($v_file_compressed, $v_buffer, $v_read_size);
  2827 + $v_size -= $v_read_size;
  2828 + }
  2829 +
  2830 + // ----- Close the file
  2831 + @fclose($v_file);
  2832 + @gzclose($v_file_compressed);
  2833 +
  2834 + // ----- Check the minimum file size
  2835 + if (filesize($v_gzip_temp_name) < 18) {
  2836 + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
  2837 + return PclZip::errorCode();
  2838 + }
  2839 +
  2840 + // ----- Extract the compressed attributes
  2841 + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
  2842 + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
  2843 + return PclZip::errorCode();
  2844 + }
  2845 +
  2846 + // ----- Read the gzip file header
  2847 + $v_binary_data = @fread($v_file_compressed, 10);
  2848 + $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
  2849 +
  2850 + // ----- Check some parameters
  2851 + $v_data_header['os'] = bin2hex($v_data_header['os']);
  2852 +
  2853 + // ----- Read the gzip file footer
  2854 + @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
  2855 + $v_binary_data = @fread($v_file_compressed, 8);
  2856 + $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
  2857 +
  2858 + // ----- Set the attributes
  2859 + $p_header['compression'] = ord($v_data_header['cm']);
  2860 + //$p_header['mtime'] = $v_data_header['mtime'];
  2861 + $p_header['crc'] = $v_data_footer['crc'];
  2862 + $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
  2863 +
  2864 + // ----- Close the file
  2865 + @fclose($v_file_compressed);
  2866 +
  2867 + // ----- Call the header generation
  2868 + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
  2869 + return $v_result;
  2870 + }
  2871 +
  2872 + // ----- Add the compressed data
  2873 + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
  2874 + {
  2875 + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
  2876 + return PclZip::errorCode();
  2877 + }
  2878 +
  2879 + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
  2880 + fseek($v_file_compressed, 10);
  2881 + $v_size = $p_header['compressed_size'];
  2882 + while ($v_size != 0)
  2883 + {
  2884 + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
  2885 + $v_buffer = @fread($v_file_compressed, $v_read_size);
  2886 + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
  2887 + @fwrite($this->zip_fd, $v_buffer, $v_read_size);
  2888 + $v_size -= $v_read_size;
  2889 + }
  2890 +
  2891 + // ----- Close the file
  2892 + @fclose($v_file_compressed);
  2893 +
  2894 + // ----- Unlink the temporary file
  2895 + @unlink($v_gzip_temp_name);
  2896 +
  2897 + // ----- Return
2717 return $v_result; 2898 return $v_result;
2718 } 2899 }
2719 // -------------------------------------------------------------------------------- 2900 // --------------------------------------------------------------------------------
@@ -2728,9 +2909,8 @@ @@ -2728,9 +2909,8 @@
2728 // -------------------------------------------------------------------------------- 2909 // --------------------------------------------------------------------------------
2729 function privCalculateStoredFilename(&$p_filedescr, &$p_options) 2910 function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2730 { 2911 {
2731 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'");  
2732 $v_result=1; 2912 $v_result=1;
2733 - 2913 +
2734 // ----- Working variables 2914 // ----- Working variables
2735 $p_filename = $p_filedescr['filename']; 2915 $p_filename = $p_filedescr['filename'];
2736 if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { 2916 if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
@@ -2752,16 +2932,18 @@ @@ -2752,16 +2932,18 @@
2752 $p_remove_all_dir = 0; 2932 $p_remove_all_dir = 0;
2753 } 2933 }
2754 2934
  2935 +
2755 // ----- Look for full name change 2936 // ----- Look for full name change
2756 if (isset($p_filedescr['new_full_name'])) { 2937 if (isset($p_filedescr['new_full_name'])) {
2757 - $v_stored_filename = $p_filedescr['new_full_name'];  
2758 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'"); 2938 + // ----- Remove drive letter if any
  2939 + $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2759 } 2940 }
2760 - 2941 +
2761 // ----- Look for path and/or short name change 2942 // ----- Look for path and/or short name change
2762 else { 2943 else {
2763 2944
2764 // ----- Look for short name change 2945 // ----- Look for short name change
  2946 + // Its when we cahnge just the filename but not the path
2765 if (isset($p_filedescr['new_short_name'])) { 2947 if (isset($p_filedescr['new_short_name'])) {
2766 $v_path_info = pathinfo($p_filename); 2948 $v_path_info = pathinfo($p_filename);
2767 $v_dir = ''; 2949 $v_dir = '';
@@ -2769,7 +2951,6 @@ @@ -2769,7 +2951,6 @@
2769 $v_dir = $v_path_info['dirname'].'/'; 2951 $v_dir = $v_path_info['dirname'].'/';
2770 } 2952 }
2771 $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; 2953 $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2772 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'");  
2773 } 2954 }
2774 else { 2955 else {
2775 // ----- Calculate the stored filename 2956 // ----- Calculate the stored filename
@@ -2779,7 +2960,6 @@ @@ -2779,7 +2960,6 @@
2779 // ----- Look for all path to remove 2960 // ----- Look for all path to remove
2780 if ($p_remove_all_dir) { 2961 if ($p_remove_all_dir) {
2781 $v_stored_filename = basename($p_filename); 2962 $v_stored_filename = basename($p_filename);
2782 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'");  
2783 } 2963 }
2784 // ----- Look for partial path remove 2964 // ----- Look for partial path remove
2785 else if ($p_remove_dir != "") { 2965 else if ($p_remove_dir != "") {
@@ -2788,7 +2968,7 @@ @@ -2788,7 +2968,7 @@
2788 2968
2789 if ( (substr($p_filename, 0, 2) == "./") 2969 if ( (substr($p_filename, 0, 2) == "./")
2790 || (substr($p_remove_dir, 0, 2) == "./")) { 2970 || (substr($p_remove_dir, 0, 2) == "./")) {
2791 - 2971 +
2792 if ( (substr($p_filename, 0, 2) == "./") 2972 if ( (substr($p_filename, 0, 2) == "./")
2793 && (substr($p_remove_dir, 0, 2) != "./")) { 2973 && (substr($p_remove_dir, 0, 2) != "./")) {
2794 $p_remove_dir = "./".$p_remove_dir; 2974 $p_remove_dir = "./".$p_remove_dir;
@@ -2804,33 +2984,31 @@ @@ -2804,33 +2984,31 @@
2804 if ($v_compare > 0) { 2984 if ($v_compare > 0) {
2805 if ($v_compare == 2) { 2985 if ($v_compare == 2) {
2806 $v_stored_filename = ""; 2986 $v_stored_filename = "";
2807 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");  
2808 } 2987 }
2809 else { 2988 else {
2810 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'");  
2811 $v_stored_filename = substr($v_stored_filename, 2989 $v_stored_filename = substr($v_stored_filename,
2812 strlen($p_remove_dir)); 2990 strlen($p_remove_dir));
2813 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'");  
2814 } 2991 }
2815 } 2992 }
2816 } 2993 }
  2994 +
  2995 + // ----- Remove drive letter if any
  2996 + $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
  2997 +
2817 // ----- Look for path to add 2998 // ----- Look for path to add
2818 if ($p_add_dir != "") { 2999 if ($p_add_dir != "") {
2819 if (substr($p_add_dir, -1) == "/") 3000 if (substr($p_add_dir, -1) == "/")
2820 $v_stored_filename = $p_add_dir.$v_stored_filename; 3001 $v_stored_filename = $p_add_dir.$v_stored_filename;
2821 else 3002 else
2822 $v_stored_filename = $p_add_dir."/".$v_stored_filename; 3003 $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2823 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");  
2824 } 3004 }
2825 } 3005 }
2826 3006
2827 // ----- Filename (reduce the path of stored name) 3007 // ----- Filename (reduce the path of stored name)
2828 $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); 3008 $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
2829 $p_filedescr['stored_filename'] = $v_stored_filename; 3009 $p_filedescr['stored_filename'] = $v_stored_filename;
2830 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename']));  
2831 - 3010 +
2832 // ----- Return 3011 // ----- Return
2833 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2834 return $v_result; 3012 return $v_result;
2835 } 3013 }
2836 // -------------------------------------------------------------------------------- 3014 // --------------------------------------------------------------------------------
@@ -2843,15 +3021,12 @@ @@ -2843,15 +3021,12 @@
2843 // -------------------------------------------------------------------------------- 3021 // --------------------------------------------------------------------------------
2844 function privWriteFileHeader(&$p_header) 3022 function privWriteFileHeader(&$p_header)
2845 { 3023 {
2846 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');  
2847 $v_result=1; 3024 $v_result=1;
2848 3025
2849 // ----- Store the offset position of the file 3026 // ----- Store the offset position of the file
2850 $p_header['offset'] = ftell($this->zip_fd); 3027 $p_header['offset'] = ftell($this->zip_fd);
2851 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);  
2852 3028
2853 // ----- Transform UNIX mtime to DOS format mdate/mtime 3029 // ----- Transform UNIX mtime to DOS format mdate/mtime
2854 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');  
2855 $v_date = getdate($p_header['mtime']); 3030 $v_date = getdate($p_header['mtime']);
2856 $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; 3031 $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
2857 $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; 3032 $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
@@ -2879,7 +3054,6 @@ @@ -2879,7 +3054,6 @@
2879 } 3054 }
2880 3055
2881 // ----- Return 3056 // ----- Return
2882 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2883 return $v_result; 3057 return $v_result;
2884 } 3058 }
2885 // -------------------------------------------------------------------------------- 3059 // --------------------------------------------------------------------------------
@@ -2892,20 +3066,18 @@ @@ -2892,20 +3066,18 @@
2892 // -------------------------------------------------------------------------------- 3066 // --------------------------------------------------------------------------------
2893 function privWriteCentralFileHeader(&$p_header) 3067 function privWriteCentralFileHeader(&$p_header)
2894 { 3068 {
2895 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');  
2896 $v_result=1; 3069 $v_result=1;
2897 3070
2898 // TBC 3071 // TBC
2899 //for(reset($p_header); $key = key($p_header); next($p_header)) { 3072 //for(reset($p_header); $key = key($p_header); next($p_header)) {
2900 - // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);  
2901 //} 3073 //}
2902 3074
2903 // ----- Transform UNIX mtime to DOS format mdate/mtime 3075 // ----- Transform UNIX mtime to DOS format mdate/mtime
2904 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');  
2905 $v_date = getdate($p_header['mtime']); 3076 $v_date = getdate($p_header['mtime']);
2906 $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; 3077 $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
2907 $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; 3078 $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
2908 3079
  3080 +
2909 // ----- Packed data 3081 // ----- Packed data
2910 $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, 3082 $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
2911 $p_header['version'], $p_header['version_extracted'], 3083 $p_header['version'], $p_header['version_extracted'],
@@ -2935,7 +3107,6 @@ @@ -2935,7 +3107,6 @@
2935 } 3107 }
2936 3108
2937 // ----- Return 3109 // ----- Return
2938 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2939 return $v_result; 3110 return $v_result;
2940 } 3111 }
2941 // -------------------------------------------------------------------------------- 3112 // --------------------------------------------------------------------------------
@@ -2948,7 +3119,6 @@ @@ -2948,7 +3119,6 @@
2948 // -------------------------------------------------------------------------------- 3119 // --------------------------------------------------------------------------------
2949 function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) 3120 function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
2950 { 3121 {
2951 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');  
2952 $v_result=1; 3122 $v_result=1;
2953 3123
2954 // ----- Packed data 3124 // ----- Packed data
@@ -2966,7 +3136,6 @@ @@ -2966,7 +3136,6 @@
2966 } 3136 }
2967 3137
2968 // ----- Return 3138 // ----- Return
2969 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
2970 return $v_result; 3139 return $v_result;
2971 } 3140 }
2972 // -------------------------------------------------------------------------------- 3141 // --------------------------------------------------------------------------------
@@ -2979,24 +3148,21 @@ @@ -2979,24 +3148,21 @@
2979 // -------------------------------------------------------------------------------- 3148 // --------------------------------------------------------------------------------
2980 function privList(&$p_list) 3149 function privList(&$p_list)
2981 { 3150 {
2982 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");  
2983 $v_result=1; 3151 $v_result=1;
2984 3152
2985 // ----- Magic quotes trick 3153 // ----- Magic quotes trick
2986 $this->privDisableMagicQuotes(); 3154 $this->privDisableMagicQuotes();
2987 3155
2988 // ----- Open the zip file 3156 // ----- Open the zip file
2989 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
2990 if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) 3157 if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
2991 { 3158 {
2992 // ----- Magic quotes trick 3159 // ----- Magic quotes trick
2993 $this->privSwapBackMagicQuotes(); 3160 $this->privSwapBackMagicQuotes();
2994 - 3161 +
2995 // ----- Error log 3162 // ----- Error log
2996 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); 3163 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
2997 3164
2998 // ----- Return 3165 // ----- Return
2999 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3000 return PclZip::errorCode(); 3166 return PclZip::errorCode();
3001 } 3167 }
3002 3168
@@ -3005,15 +3171,11 @@ @@ -3005,15 +3171,11 @@
3005 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) 3171 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3006 { 3172 {
3007 $this->privSwapBackMagicQuotes(); 3173 $this->privSwapBackMagicQuotes();
3008 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3009 return $v_result; 3174 return $v_result;
3010 } 3175 }
3011 3176
3012 // ----- Go to beginning of Central Dir 3177 // ----- Go to beginning of Central Dir
3013 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");  
3014 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");  
3015 @rewind($this->zip_fd); 3178 @rewind($this->zip_fd);
3016 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");  
3017 if (@fseek($this->zip_fd, $v_central_dir['offset'])) 3179 if (@fseek($this->zip_fd, $v_central_dir['offset']))
3018 { 3180 {
3019 $this->privSwapBackMagicQuotes(); 3181 $this->privSwapBackMagicQuotes();
@@ -3022,10 +3184,8 @@ @@ -3022,10 +3184,8 @@
3022 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); 3184 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3023 3185
3024 // ----- Return 3186 // ----- Return
3025 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3026 return PclZip::errorCode(); 3187 return PclZip::errorCode();
3027 } 3188 }
3028 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");  
3029 3189
3030 // ----- Read each entry 3190 // ----- Read each entry
3031 for ($i=0; $i<$v_central_dir['entries']; $i++) 3191 for ($i=0; $i<$v_central_dir['entries']; $i++)
@@ -3034,7 +3194,6 @@ @@ -3034,7 +3194,6 @@
3034 if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) 3194 if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3035 { 3195 {
3036 $this->privSwapBackMagicQuotes(); 3196 $this->privSwapBackMagicQuotes();
3037 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3038 return $v_result; 3197 return $v_result;
3039 } 3198 }
3040 $v_header['index'] = $i; 3199 $v_header['index'] = $i;
@@ -3051,7 +3210,6 @@ @@ -3051,7 +3210,6 @@
3051 $this->privSwapBackMagicQuotes(); 3210 $this->privSwapBackMagicQuotes();
3052 3211
3053 // ----- Return 3212 // ----- Return
3054 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3055 return $v_result; 3213 return $v_result;
3056 } 3214 }
3057 // -------------------------------------------------------------------------------- 3215 // --------------------------------------------------------------------------------
@@ -3071,17 +3229,19 @@ @@ -3071,17 +3229,19 @@
3071 // $p_info['comment'] = Comment associated with the file. 3229 // $p_info['comment'] = Comment associated with the file.
3072 // $p_info['folder'] = true/false : indicates if the entry is a folder or not. 3230 // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
3073 // $p_info['status'] = status of the action on the file. 3231 // $p_info['status'] = status of the action on the file.
  3232 + // $p_info['crc'] = CRC of the file content.
3074 // Parameters : 3233 // Parameters :
3075 // Return Values : 3234 // Return Values :
3076 // -------------------------------------------------------------------------------- 3235 // --------------------------------------------------------------------------------
3077 function privConvertHeader2FileInfo($p_header, &$p_info) 3236 function privConvertHeader2FileInfo($p_header, &$p_info)
3078 { 3237 {
3079 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");  
3080 $v_result=1; 3238 $v_result=1;
3081 3239
3082 // ----- Get the interesting attributes 3240 // ----- Get the interesting attributes
3083 - $p_info['filename'] = $p_header['filename'];  
3084 - $p_info['stored_filename'] = $p_header['stored_filename']; 3241 + $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
  3242 + $p_info['filename'] = $v_temp_path;
  3243 + $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
  3244 + $p_info['stored_filename'] = $v_temp_path;
3085 $p_info['size'] = $p_header['size']; 3245 $p_info['size'] = $p_header['size'];
3086 $p_info['compressed_size'] = $p_header['compressed_size']; 3246 $p_info['compressed_size'] = $p_header['compressed_size'];
3087 $p_info['mtime'] = $p_header['mtime']; 3247 $p_info['mtime'] = $p_header['mtime'];
@@ -3089,9 +3249,9 @@ @@ -3089,9 +3249,9 @@
3089 $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); 3249 $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3090 $p_info['index'] = $p_header['index']; 3250 $p_info['index'] = $p_header['index'];
3091 $p_info['status'] = $p_header['status']; 3251 $p_info['status'] = $p_header['status'];
  3252 + $p_info['crc'] = $p_header['crc'];
3092 3253
3093 // ----- Return 3254 // ----- Return
3094 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3095 return $v_result; 3255 return $v_result;
3096 } 3256 }
3097 // -------------------------------------------------------------------------------- 3257 // --------------------------------------------------------------------------------
@@ -3114,7 +3274,6 @@ @@ -3114,7 +3274,6 @@
3114 // -------------------------------------------------------------------------------- 3274 // --------------------------------------------------------------------------------
3115 function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) 3275 function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3116 { 3276 {
3117 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");  
3118 $v_result=1; 3277 $v_result=1;
3119 3278
3120 // ----- Magic quotes trick 3279 // ----- Magic quotes trick
@@ -3133,9 +3292,7 @@ @@ -3133,9 +3292,7 @@
3133 // ----- Look for the path end '/' 3292 // ----- Look for the path end '/'
3134 while (substr($p_path, -1) == "/") 3293 while (substr($p_path, -1) == "/")
3135 { 3294 {
3136 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");  
3137 $p_path = substr($p_path, 0, strlen($p_path)-1); 3295 $p_path = substr($p_path, 0, strlen($p_path)-1);
3138 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");  
3139 } 3296 }
3140 } 3297 }
3141 3298
@@ -3147,11 +3304,9 @@ @@ -3147,11 +3304,9 @@
3147 $p_remove_path_size = strlen($p_remove_path); 3304 $p_remove_path_size = strlen($p_remove_path);
3148 3305
3149 // ----- Open the zip file 3306 // ----- Open the zip file
3150 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
3151 if (($v_result = $this->privOpenFd('rb')) != 1) 3307 if (($v_result = $this->privOpenFd('rb')) != 1)
3152 { 3308 {
3153 $this->privSwapBackMagicQuotes(); 3309 $this->privSwapBackMagicQuotes();
3154 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3155 return $v_result; 3310 return $v_result;
3156 } 3311 }
3157 3312
@@ -3163,7 +3318,6 @@ @@ -3163,7 +3318,6 @@
3163 $this->privCloseFd(); 3318 $this->privCloseFd();
3164 $this->privSwapBackMagicQuotes(); 3319 $this->privSwapBackMagicQuotes();
3165 3320
3166 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3167 return $v_result; 3321 return $v_result;
3168 } 3322 }
3169 3323
@@ -3174,12 +3328,9 @@ @@ -3174,12 +3328,9 @@
3174 $j_start = 0; 3328 $j_start = 0;
3175 for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) 3329 for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3176 { 3330 {
3177 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");  
3178 3331
3179 // ----- Read next Central dir entry 3332 // ----- Read next Central dir entry
3180 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");  
3181 @rewind($this->zip_fd); 3333 @rewind($this->zip_fd);
3182 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");  
3183 if (@fseek($this->zip_fd, $v_pos_entry)) 3334 if (@fseek($this->zip_fd, $v_pos_entry))
3184 { 3335 {
3185 // ----- Close the zip file 3336 // ----- Close the zip file
@@ -3190,10 +3341,8 @@ @@ -3190,10 +3341,8 @@
3190 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); 3341 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3191 3342
3192 // ----- Return 3343 // ----- Return
3193 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3194 return PclZip::errorCode(); 3344 return PclZip::errorCode();
3195 } 3345 }
3196 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");  
3197 3346
3198 // ----- Read the file header 3347 // ----- Read the file header
3199 $v_header = array(); 3348 $v_header = array();
@@ -3203,7 +3352,6 @@ @@ -3203,7 +3352,6 @@
3203 $this->privCloseFd(); 3352 $this->privCloseFd();
3204 $this->privSwapBackMagicQuotes(); 3353 $this->privSwapBackMagicQuotes();
3205 3354
3206 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3207 return $v_result; 3355 return $v_result;
3208 } 3356 }
3209 3357
@@ -3219,49 +3367,43 @@ @@ -3219,49 +3367,43 @@
3219 // ----- Look for extract by name rule 3367 // ----- Look for extract by name rule
3220 if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) 3368 if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
3221 && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { 3369 && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3222 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");  
3223 3370
3224 // ----- Look if the filename is in the list 3371 // ----- Look if the filename is in the list
3225 for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { 3372 for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3226 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");  
3227 3373
3228 // ----- Look for a directory 3374 // ----- Look for a directory
3229 if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { 3375 if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3230 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");  
3231 3376
3232 // ----- Look if the directory is in the filename path 3377 // ----- Look if the directory is in the filename path
3233 if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) 3378 if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3234 && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { 3379 && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3235 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");  
3236 $v_extract = true; 3380 $v_extract = true;
3237 } 3381 }
3238 } 3382 }
3239 // ----- Look for a filename 3383 // ----- Look for a filename
3240 elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { 3384 elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3241 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");  
3242 $v_extract = true; 3385 $v_extract = true;
3243 } 3386 }
3244 } 3387 }
3245 } 3388 }
3246 3389
3247 // ----- Look for extract by ereg rule 3390 // ----- Look for extract by ereg rule
  3391 + // ereg() is deprecated with PHP 5.3
  3392 + /*
3248 else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) 3393 else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
3249 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { 3394 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3250 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");  
3251 3395
3252 if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { 3396 if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
3253 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");  
3254 $v_extract = true; 3397 $v_extract = true;
3255 } 3398 }
3256 } 3399 }
  3400 + */
3257 3401
3258 // ----- Look for extract by preg rule 3402 // ----- Look for extract by preg rule
3259 else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) 3403 else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
3260 && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { 3404 && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3261 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");  
3262 3405
3263 if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { 3406 if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3264 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");  
3265 $v_extract = true; 3407 $v_extract = true;
3266 } 3408 }
3267 } 3409 }
@@ -3269,23 +3411,18 @@ @@ -3269,23 +3411,18 @@
3269 // ----- Look for extract by index rule 3411 // ----- Look for extract by index rule
3270 else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) 3412 else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3271 && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { 3413 && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3272 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");  
3273 - 3414 +
3274 // ----- Look if the index is in the list 3415 // ----- Look if the index is in the list
3275 for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { 3416 for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3276 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");  
3277 3417
3278 if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { 3418 if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3279 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");  
3280 $v_extract = true; 3419 $v_extract = true;
3281 } 3420 }
3282 if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { 3421 if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3283 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");  
3284 $j_start = $j+1; 3422 $j_start = $j+1;
3285 } 3423 }
3286 3424
3287 if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { 3425 if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3288 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");  
3289 break; 3426 break;
3290 } 3427 }
3291 } 3428 }
@@ -3293,7 +3430,6 @@ @@ -3293,7 +3430,6 @@
3293 3430
3294 // ----- Look for no rule, which means extract all the archive 3431 // ----- Look for no rule, which means extract all the archive
3295 else { 3432 else {
3296 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");  
3297 $v_extract = true; 3433 $v_extract = true;
3298 } 3434 }
3299 3435
@@ -3301,35 +3437,30 @@ @@ -3301,35 +3437,30 @@
3301 if ( ($v_extract) 3437 if ( ($v_extract)
3302 && ( ($v_header['compression'] != 8) 3438 && ( ($v_header['compression'] != 8)
3303 && ($v_header['compression'] != 0))) { 3439 && ($v_header['compression'] != 0))) {
3304 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")");  
3305 $v_header['status'] = 'unsupported_compression'; 3440 $v_header['status'] = 'unsupported_compression';
3306 3441
3307 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR 3442 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3308 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) 3443 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3309 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { 3444 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3310 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");  
3311 3445
3312 $this->privSwapBackMagicQuotes(); 3446 $this->privSwapBackMagicQuotes();
3313 - 3447 +
3314 PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, 3448 PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3315 "Filename '".$v_header['stored_filename']."' is " 3449 "Filename '".$v_header['stored_filename']."' is "
3316 ."compressed by an unsupported compression " 3450 ."compressed by an unsupported compression "
3317 ."method (".$v_header['compression'].") "); 3451 ."method (".$v_header['compression'].") ");
3318 3452
3319 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3320 return PclZip::errorCode(); 3453 return PclZip::errorCode();
3321 } 3454 }
3322 } 3455 }
3323 - 3456 +
3324 // ----- Check encrypted files 3457 // ----- Check encrypted files
3325 if (($v_extract) && (($v_header['flag'] & 1) == 1)) { 3458 if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3326 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption");  
3327 $v_header['status'] = 'unsupported_encryption'; 3459 $v_header['status'] = 'unsupported_encryption';
3328 3460
3329 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR 3461 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3330 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) 3462 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3331 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { 3463 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3332 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");  
3333 3464
3334 $this->privSwapBackMagicQuotes(); 3465 $this->privSwapBackMagicQuotes();
3335 3466
@@ -3338,35 +3469,29 @@ @@ -3338,35 +3469,29 @@
3338 ." filename '".$v_header['stored_filename'] 3469 ." filename '".$v_header['stored_filename']
3339 ."'"); 3470 ."'");
3340 3471
3341 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3342 return PclZip::errorCode(); 3472 return PclZip::errorCode();
3343 } 3473 }
3344 } 3474 }
3345 3475
3346 // ----- Look for real extraction 3476 // ----- Look for real extraction
3347 if (($v_extract) && ($v_header['status'] != 'ok')) { 3477 if (($v_extract) && ($v_header['status'] != 'ok')) {
3348 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract");  
3349 $v_result = $this->privConvertHeader2FileInfo($v_header, 3478 $v_result = $this->privConvertHeader2FileInfo($v_header,
3350 $p_file_list[$v_nb_extracted++]); 3479 $p_file_list[$v_nb_extracted++]);
3351 if ($v_result != 1) { 3480 if ($v_result != 1) {
3352 $this->privCloseFd(); 3481 $this->privCloseFd();
3353 $this->privSwapBackMagicQuotes(); 3482 $this->privSwapBackMagicQuotes();
3354 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3355 return $v_result; 3483 return $v_result;
3356 } 3484 }
3357 3485
3358 $v_extract = false; 3486 $v_extract = false;
3359 } 3487 }
3360 - 3488 +
3361 // ----- Look for real extraction 3489 // ----- Look for real extraction
3362 if ($v_extract) 3490 if ($v_extract)
3363 { 3491 {
3364 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");  
3365 3492
3366 // ----- Go to the file position 3493 // ----- Go to the file position
3367 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");  
3368 @rewind($this->zip_fd); 3494 @rewind($this->zip_fd);
3369 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");  
3370 if (@fseek($this->zip_fd, $v_header['offset'])) 3495 if (@fseek($this->zip_fd, $v_header['offset']))
3371 { 3496 {
3372 // ----- Close the zip file 3497 // ----- Close the zip file
@@ -3378,20 +3503,19 @@ @@ -3378,20 +3503,19 @@
3378 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); 3503 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3379 3504
3380 // ----- Return 3505 // ----- Return
3381 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3382 return PclZip::errorCode(); 3506 return PclZip::errorCode();
3383 } 3507 }
3384 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");  
3385 3508
3386 // ----- Look for extraction as string 3509 // ----- Look for extraction as string
3387 if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { 3510 if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3388 3511
  3512 + $v_string = '';
  3513 +
3389 // ----- Extracting the file 3514 // ----- Extracting the file
3390 - $v_result1 = $this->privExtractFileAsString($v_header, $v_string); 3515 + $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3391 if ($v_result1 < 1) { 3516 if ($v_result1 < 1) {
3392 $this->privCloseFd(); 3517 $this->privCloseFd();
3393 $this->privSwapBackMagicQuotes(); 3518 $this->privSwapBackMagicQuotes();
3394 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);  
3395 return $v_result1; 3519 return $v_result1;
3396 } 3520 }
3397 3521
@@ -3402,7 +3526,6 @@ @@ -3402,7 +3526,6 @@
3402 $this->privCloseFd(); 3526 $this->privCloseFd();
3403 $this->privSwapBackMagicQuotes(); 3527 $this->privSwapBackMagicQuotes();
3404 3528
3405 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3406 return $v_result; 3529 return $v_result;
3407 } 3530 }
3408 3531
@@ -3411,7 +3534,7 @@ @@ -3411,7 +3534,7 @@
3411 3534
3412 // ----- Next extracted file 3535 // ----- Next extracted file
3413 $v_nb_extracted++; 3536 $v_nb_extracted++;
3414 - 3537 +
3415 // ----- Look for user callback abort 3538 // ----- Look for user callback abort
3416 if ($v_result1 == 2) { 3539 if ($v_result1 == 2) {
3417 break; 3540 break;
@@ -3425,7 +3548,6 @@ @@ -3425,7 +3548,6 @@
3425 if ($v_result1 < 1) { 3548 if ($v_result1 < 1) {
3426 $this->privCloseFd(); 3549 $this->privCloseFd();
3427 $this->privSwapBackMagicQuotes(); 3550 $this->privSwapBackMagicQuotes();
3428 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);  
3429 return $v_result1; 3551 return $v_result1;
3430 } 3552 }
3431 3553
@@ -3433,7 +3555,6 @@ @@ -3433,7 +3555,6 @@
3433 if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { 3555 if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3434 $this->privCloseFd(); 3556 $this->privCloseFd();
3435 $this->privSwapBackMagicQuotes(); 3557 $this->privSwapBackMagicQuotes();
3436 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3437 return $v_result; 3558 return $v_result;
3438 } 3559 }
3439 3560
@@ -3452,7 +3573,6 @@ @@ -3452,7 +3573,6 @@
3452 if ($v_result1 < 1) { 3573 if ($v_result1 < 1) {
3453 $this->privCloseFd(); 3574 $this->privCloseFd();
3454 $this->privSwapBackMagicQuotes(); 3575 $this->privSwapBackMagicQuotes();
3455 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);  
3456 return $v_result1; 3576 return $v_result1;
3457 } 3577 }
3458 3578
@@ -3463,7 +3583,6 @@ @@ -3463,7 +3583,6 @@
3463 $this->privCloseFd(); 3583 $this->privCloseFd();
3464 $this->privSwapBackMagicQuotes(); 3584 $this->privSwapBackMagicQuotes();
3465 3585
3466 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3467 return $v_result; 3586 return $v_result;
3468 } 3587 }
3469 3588
@@ -3480,7 +3599,6 @@ @@ -3480,7 +3599,6 @@
3480 $this->privSwapBackMagicQuotes(); 3599 $this->privSwapBackMagicQuotes();
3481 3600
3482 // ----- Return 3601 // ----- Return
3483 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3484 return $v_result; 3602 return $v_result;
3485 } 3603 }
3486 // -------------------------------------------------------------------------------- 3604 // --------------------------------------------------------------------------------
@@ -3496,18 +3614,15 @@ @@ -3496,18 +3614,15 @@
3496 // -------------------------------------------------------------------------------- 3614 // --------------------------------------------------------------------------------
3497 function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) 3615 function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3498 { 3616 {
3499 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");  
3500 $v_result=1; 3617 $v_result=1;
3501 3618
3502 // ----- Read the file header 3619 // ----- Read the file header
3503 if (($v_result = $this->privReadFileHeader($v_header)) != 1) 3620 if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3504 { 3621 {
3505 // ----- Return 3622 // ----- Return
3506 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3507 return $v_result; 3623 return $v_result;
3508 } 3624 }
3509 3625
3510 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");  
3511 3626
3512 // ----- Check that the file header is coherent with $p_entry info 3627 // ----- Check that the file header is coherent with $p_entry info
3513 if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { 3628 if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
@@ -3518,15 +3633,12 @@ @@ -3518,15 +3633,12 @@
3518 if ($p_remove_all_path == true) { 3633 if ($p_remove_all_path == true) {
3519 // ----- Look for folder entry that not need to be extracted 3634 // ----- Look for folder entry that not need to be extracted
3520 if (($p_entry['external']&0x00000010)==0x00000010) { 3635 if (($p_entry['external']&0x00000010)==0x00000010) {
3521 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered");  
3522 3636
3523 $p_entry['status'] = "filtered"; 3637 $p_entry['status'] = "filtered";
3524 3638
3525 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3526 return $v_result; 3639 return $v_result;
3527 } 3640 }
3528 3641
3529 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed");  
3530 // ----- Get the basename of the path 3642 // ----- Get the basename of the path
3531 $p_entry['filename'] = basename($p_entry['filename']); 3643 $p_entry['filename'] = basename($p_entry['filename']);
3532 } 3644 }
@@ -3534,28 +3646,23 @@ @@ -3534,28 +3646,23 @@
3534 // ----- Look for path to remove 3646 // ----- Look for path to remove
3535 else if ($p_remove_path != "") 3647 else if ($p_remove_path != "")
3536 { 3648 {
3537 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove");  
3538 if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) 3649 if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3539 { 3650 {
3540 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");  
3541 3651
3542 // ----- Change the file status 3652 // ----- Change the file status
3543 $p_entry['status'] = "filtered"; 3653 $p_entry['status'] = "filtered";
3544 3654
3545 // ----- Return 3655 // ----- Return
3546 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3547 return $v_result; 3656 return $v_result;
3548 } 3657 }
3549 3658
3550 $p_remove_path_size = strlen($p_remove_path); 3659 $p_remove_path_size = strlen($p_remove_path);
3551 if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) 3660 if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3552 { 3661 {
3553 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");  
3554 3662
3555 // ----- Remove the path 3663 // ----- Remove the path
3556 $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); 3664 $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3557 3665
3558 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");  
3559 } 3666 }
3560 } 3667 }
3561 3668
@@ -3563,28 +3670,24 @@ @@ -3563,28 +3670,24 @@
3563 if ($p_path != '') { 3670 if ($p_path != '') {
3564 $p_entry['filename'] = $p_path."/".$p_entry['filename']; 3671 $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3565 } 3672 }
3566 - 3673 +
3567 // ----- Check a base_dir_restriction 3674 // ----- Check a base_dir_restriction
3568 if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { 3675 if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3569 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction");  
3570 $v_inclusion 3676 $v_inclusion
3571 = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], 3677 = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3572 - $p_entry['filename']); 3678 + $p_entry['filename']);
3573 if ($v_inclusion == 0) { 3679 if ($v_inclusion == 0) {
3574 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction");  
3575 3680
3576 PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, 3681 PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3577 "Filename '".$p_entry['filename']."' is " 3682 "Filename '".$p_entry['filename']."' is "
3578 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); 3683 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3579 3684
3580 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3581 return PclZip::errorCode(); 3685 return PclZip::errorCode();
3582 } 3686 }
3583 } 3687 }
3584 3688
3585 // ----- Look for pre-extract callback 3689 // ----- Look for pre-extract callback
3586 if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { 3690 if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3587 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");  
3588 3691
3589 // ----- Generate a local information 3692 // ----- Generate a local information
3590 $v_local_header = array(); 3693 $v_local_header = array();
@@ -3593,16 +3696,16 @@ @@ -3593,16 +3696,16 @@
3593 // ----- Call the callback 3696 // ----- Call the callback
3594 // Here I do not use call_user_func() because I need to send a reference to the 3697 // Here I do not use call_user_func() because I need to send a reference to the
3595 // header. 3698 // header.
3596 - eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); 3699 +// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
  3700 + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3597 if ($v_result == 0) { 3701 if ($v_result == 0) {
3598 // ----- Change the file status 3702 // ----- Change the file status
3599 $p_entry['status'] = "skipped"; 3703 $p_entry['status'] = "skipped";
3600 $v_result = 1; 3704 $v_result = 1;
3601 } 3705 }
3602 - 3706 +
3603 // ----- Look for abort result 3707 // ----- Look for abort result
3604 if ($v_result == 2) { 3708 if ($v_result == 2) {
3605 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");  
3606 // ----- This status is internal and will be changed in 'skipped' 3709 // ----- This status is internal and will be changed in 'skipped'
3607 $p_entry['status'] = "aborted"; 3710 $p_entry['status'] = "aborted";
3608 $v_result = PCLZIP_ERR_USER_ABORTED; 3711 $v_result = PCLZIP_ERR_USER_ABORTED;
@@ -3611,10 +3714,8 @@ @@ -3611,10 +3714,8 @@
3611 // ----- Update the informations 3714 // ----- Update the informations
3612 // Only some fields can be modified 3715 // Only some fields can be modified
3613 $p_entry['filename'] = $v_local_header['filename']; 3716 $p_entry['filename'] = $v_local_header['filename'];
3614 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");  
3615 } 3717 }
3616 3718
3617 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");  
3618 3719
3619 // ----- Look if extraction should be done 3720 // ----- Look if extraction should be done
3620 if ($p_entry['status'] == 'ok') { 3721 if ($p_entry['status'] == 'ok') {
@@ -3622,35 +3723,30 @@ @@ -3622,35 +3723,30 @@
3622 // ----- Look for specific actions while the file exist 3723 // ----- Look for specific actions while the file exist
3623 if (file_exists($p_entry['filename'])) 3724 if (file_exists($p_entry['filename']))
3624 { 3725 {
3625 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");  
3626 3726
3627 // ----- Look if file is a directory 3727 // ----- Look if file is a directory
3628 if (is_dir($p_entry['filename'])) 3728 if (is_dir($p_entry['filename']))
3629 { 3729 {
3630 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");  
3631 3730
3632 // ----- Change the file status 3731 // ----- Change the file status
3633 $p_entry['status'] = "already_a_directory"; 3732 $p_entry['status'] = "already_a_directory";
3634 - 3733 +
3635 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR 3734 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3636 // For historical reason first PclZip implementation does not stop 3735 // For historical reason first PclZip implementation does not stop
3637 // when this kind of error occurs. 3736 // when this kind of error occurs.
3638 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) 3737 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3639 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { 3738 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3640 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");  
3641 3739
3642 PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, 3740 PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3643 "Filename '".$p_entry['filename']."' is " 3741 "Filename '".$p_entry['filename']."' is "
3644 ."already used by an existing directory"); 3742 ."already used by an existing directory");
3645 3743
3646 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3647 return PclZip::errorCode(); 3744 return PclZip::errorCode();
3648 - } 3745 + }
3649 } 3746 }
3650 // ----- Look if file is write protected 3747 // ----- Look if file is write protected
3651 else if (!is_writeable($p_entry['filename'])) 3748 else if (!is_writeable($p_entry['filename']))
3652 { 3749 {
3653 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");  
3654 3750
3655 // ----- Change the file status 3751 // ----- Change the file status
3656 $p_entry['status'] = "write_protected"; 3752 $p_entry['status'] = "write_protected";
@@ -3660,28 +3756,23 @@ @@ -3660,28 +3756,23 @@
3660 // when this kind of error occurs. 3756 // when this kind of error occurs.
3661 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) 3757 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3662 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { 3758 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3663 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");  
3664 3759
3665 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 3760 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3666 "Filename '".$p_entry['filename']."' exists " 3761 "Filename '".$p_entry['filename']."' exists "
3667 ."and is write protected"); 3762 ."and is write protected");
3668 3763
3669 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3670 return PclZip::errorCode(); 3764 return PclZip::errorCode();
3671 - } 3765 + }
3672 } 3766 }
3673 3767
3674 // ----- Look if the extracted file is older 3768 // ----- Look if the extracted file is older
3675 else if (filemtime($p_entry['filename']) > $p_entry['mtime']) 3769 else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3676 { 3770 {
3677 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");  
3678 // ----- Change the file status 3771 // ----- Change the file status
3679 if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) 3772 if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3680 && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { 3773 && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3681 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced");  
3682 - }  
3683 - else {  
3684 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced"); 3774 + }
  3775 + else {
3685 $p_entry['status'] = "newer_exist"; 3776 $p_entry['status'] = "newer_exist";
3686 3777
3687 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR 3778 // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
@@ -3689,19 +3780,16 @@ @@ -3689,19 +3780,16 @@
3689 // when this kind of error occurs. 3780 // when this kind of error occurs.
3690 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) 3781 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3691 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { 3782 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3692 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");  
3693 3783
3694 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 3784 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3695 "Newer version of '".$p_entry['filename']."' exists " 3785 "Newer version of '".$p_entry['filename']."' exists "
3696 ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); 3786 ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3697 3787
3698 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
3699 return PclZip::errorCode(); 3788 return PclZip::errorCode();
  3789 + }
3700 } 3790 }
3701 - }  
3702 } 3791 }
3703 else { 3792 else {
3704 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");  
3705 } 3793 }
3706 } 3794 }
3707 3795
@@ -3714,19 +3802,17 @@ @@ -3714,19 +3802,17 @@
3714 else 3802 else
3715 $v_dir_to_check = dirname($p_entry['filename']); 3803 $v_dir_to_check = dirname($p_entry['filename']);
3716 3804
3717 - if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {  
3718 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");  
3719 -  
3720 - // ----- Change the file status  
3721 - $p_entry['status'] = "path_creation_fail";  
3722 -  
3723 - // ----- Return  
3724 - ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3725 - //return $v_result;  
3726 - $v_result = 1; 3805 + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
  3806 +
  3807 + // ----- Change the file status
  3808 + $p_entry['status'] = "path_creation_fail";
  3809 +
  3810 + // ----- Return
  3811 + //return $v_result;
  3812 + $v_result = 1;
  3813 + }
3727 } 3814 }
3728 } 3815 }
3729 - }  
3730 3816
3731 // ----- Look if extraction should be done 3817 // ----- Look if extraction should be done
3732 if ($p_entry['status'] == 'ok') { 3818 if ($p_entry['status'] == 'ok') {
@@ -3736,35 +3822,30 @@ @@ -3736,35 +3822,30 @@
3736 { 3822 {
3737 // ----- Look for not compressed file 3823 // ----- Look for not compressed file
3738 if ($p_entry['compression'] == 0) { 3824 if ($p_entry['compression'] == 0) {
3739 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");  
3740 3825
3741 - // ----- Opening destination file 3826 + // ----- Opening destination file
3742 if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) 3827 if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3743 { 3828 {
3744 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");  
3745 3829
3746 // ----- Change the file status 3830 // ----- Change the file status
3747 $p_entry['status'] = "write_error"; 3831 $p_entry['status'] = "write_error";
3748 3832
3749 // ----- Return 3833 // ----- Return
3750 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3751 return $v_result; 3834 return $v_result;
3752 } 3835 }
3753 3836
3754 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes");  
3755 3837
3756 // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks 3838 // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3757 $v_size = $p_entry['compressed_size']; 3839 $v_size = $p_entry['compressed_size'];
3758 while ($v_size != 0) 3840 while ($v_size != 0)
3759 { 3841 {
3760 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 3842 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3761 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");  
3762 $v_buffer = @fread($this->zip_fd, $v_read_size); 3843 $v_buffer = @fread($this->zip_fd, $v_read_size);
3763 /* Try to speed up the code 3844 /* Try to speed up the code
3764 $v_binary_data = pack('a'.$v_read_size, $v_buffer); 3845 $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3765 @fwrite($v_dest_file, $v_binary_data, $v_read_size); 3846 @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3766 */ 3847 */
3767 - @fwrite($v_dest_file, $v_buffer, $v_read_size); 3848 + @fwrite($v_dest_file, $v_buffer, $v_read_size);
3768 $v_size -= $v_read_size; 3849 $v_size -= $v_read_size;
3769 } 3850 }
3770 3851
@@ -3773,92 +3854,87 @@ @@ -3773,92 +3854,87 @@
3773 3854
3774 // ----- Change the file mtime 3855 // ----- Change the file mtime
3775 touch($p_entry['filename'], $p_entry['mtime']); 3856 touch($p_entry['filename'], $p_entry['mtime']);
3776 - 3857 +
3777 3858
3778 } 3859 }
3779 else { 3860 else {
3780 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")");  
3781 // ----- TBC 3861 // ----- TBC
3782 // Need to be finished 3862 // Need to be finished
3783 if (($p_entry['flag'] & 1) == 1) { 3863 if (($p_entry['flag'] & 1) == 1) {
3784 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted");  
3785 - /*  
3786 - // ----- Read the encryption header  
3787 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes");  
3788 - $v_encryption_header = @fread($this->zip_fd, 12);  
3789 -  
3790 - // ----- Read the encrypted & compressed file in a buffer  
3791 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes");  
3792 - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12);  
3793 -  
3794 - // ----- Decrypt the buffer  
3795 - $this->privDecrypt($v_encryption_header, $v_buffer,  
3796 - $p_entry['compressed_size']-12, $p_entry['crc']);  
3797 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'");  
3798 - */  
3799 - }  
3800 - else {  
3801 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes");  
3802 - // ----- Read the compressed file in a buffer (one shot)  
3803 - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); 3864 + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
  3865 + return PclZip::errorCode();
3804 } 3866 }
3805 3867
3806 - // ----- Decompress the file  
3807 - $v_file_content = @gzinflate($v_buffer);  
3808 - unset($v_buffer);  
3809 - if ($v_file_content === FALSE) {  
3810 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file");  
3811 -  
3812 - // ----- Change the file status  
3813 - // TBC  
3814 - $p_entry['status'] = "error";  
3815 3868
3816 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3817 - return $v_result; 3869 + // ----- Look for using temporary file to unzip
  3870 + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
  3871 + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
  3872 + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
  3873 + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
  3874 + $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
  3875 + if ($v_result < PCLZIP_ERR_NO_ERROR) {
  3876 + return $v_result;
  3877 + }
3818 } 3878 }
  3879 +
  3880 + // ----- Look for extract in memory
  3881 + else {
3819 3882
3820 - // ----- Opening destination file  
3821 - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {  
3822 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");  
3823 -  
3824 - // ----- Change the file status  
3825 - $p_entry['status'] = "write_error";  
3826 -  
3827 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3828 - return $v_result; 3883 +
  3884 + // ----- Read the compressed file in a buffer (one shot)
  3885 + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
  3886 +
  3887 + // ----- Decompress the file
  3888 + $v_file_content = @gzinflate($v_buffer);
  3889 + unset($v_buffer);
  3890 + if ($v_file_content === FALSE) {
  3891 +
  3892 + // ----- Change the file status
  3893 + // TBC
  3894 + $p_entry['status'] = "error";
  3895 +
  3896 + return $v_result;
  3897 + }
  3898 +
  3899 + // ----- Opening destination file
  3900 + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
  3901 +
  3902 + // ----- Change the file status
  3903 + $p_entry['status'] = "write_error";
  3904 +
  3905 + return $v_result;
  3906 + }
  3907 +
  3908 + // ----- Write the uncompressed data
  3909 + @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
  3910 + unset($v_file_content);
  3911 +
  3912 + // ----- Closing the destination file
  3913 + @fclose($v_dest_file);
  3914 +
3829 } 3915 }
3830 3916
3831 - // ----- Write the uncompressed data  
3832 - @fwrite($v_dest_file, $v_file_content, $p_entry['size']);  
3833 - unset($v_file_content);  
3834 -  
3835 - // ----- Closing the destination file  
3836 - @fclose($v_dest_file);  
3837 -  
3838 // ----- Change the file mtime 3917 // ----- Change the file mtime
3839 @touch($p_entry['filename'], $p_entry['mtime']); 3918 @touch($p_entry['filename'], $p_entry['mtime']);
3840 } 3919 }
3841 3920
3842 // ----- Look for chmod option 3921 // ----- Look for chmod option
3843 if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { 3922 if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3844 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");  
3845 3923
3846 // ----- Change the mode of the file 3924 // ----- Change the mode of the file
3847 @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); 3925 @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3848 } 3926 }
3849 3927
3850 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");  
3851 } 3928 }
3852 } 3929 }
3853 3930
3854 - // ----- Change abort status  
3855 - if ($p_entry['status'] == "aborted") {  
3856 - $p_entry['status'] = "skipped";  
3857 - }  
3858 - 3931 + // ----- Change abort status
  3932 + if ($p_entry['status'] == "aborted") {
  3933 + $p_entry['status'] = "skipped";
  3934 + }
  3935 +
3859 // ----- Look for post-extract callback 3936 // ----- Look for post-extract callback
3860 elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { 3937 elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3861 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");  
3862 3938
3863 // ----- Generate a local information 3939 // ----- Generate a local information
3864 $v_local_header = array(); 3940 $v_local_header = array();
@@ -3867,17 +3943,92 @@ @@ -3867,17 +3943,92 @@
3867 // ----- Call the callback 3943 // ----- Call the callback
3868 // Here I do not use call_user_func() because I need to send a reference to the 3944 // Here I do not use call_user_func() because I need to send a reference to the
3869 // header. 3945 // header.
3870 - eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); 3946 +// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
  3947 + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3871 3948
3872 // ----- Look for abort result 3949 // ----- Look for abort result
3873 if ($v_result == 2) { 3950 if ($v_result == 2) {
3874 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");  
3875 $v_result = PCLZIP_ERR_USER_ABORTED; 3951 $v_result = PCLZIP_ERR_USER_ABORTED;
3876 } 3952 }
3877 } 3953 }
3878 3954
3879 // ----- Return 3955 // ----- Return
3880 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); 3956 + return $v_result;
  3957 + }
  3958 + // --------------------------------------------------------------------------------
  3959 +
  3960 + // --------------------------------------------------------------------------------
  3961 + // Function : privExtractFileUsingTempFile()
  3962 + // Description :
  3963 + // Parameters :
  3964 + // Return Values :
  3965 + // --------------------------------------------------------------------------------
  3966 + function privExtractFileUsingTempFile(&$p_entry, &$p_options)
  3967 + {
  3968 + $v_result=1;
  3969 +
  3970 + // ----- Creates a temporary file
  3971 + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
  3972 + if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
  3973 + fclose($v_file);
  3974 + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
  3975 + return PclZip::errorCode();
  3976 + }
  3977 +
  3978 +
  3979 + // ----- Write gz file format header
  3980 + $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
  3981 + @fwrite($v_dest_file, $v_binary_data, 10);
  3982 +
  3983 + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
  3984 + $v_size = $p_entry['compressed_size'];
  3985 + while ($v_size != 0)
  3986 + {
  3987 + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
  3988 + $v_buffer = @fread($this->zip_fd, $v_read_size);
  3989 + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
  3990 + @fwrite($v_dest_file, $v_buffer, $v_read_size);
  3991 + $v_size -= $v_read_size;
  3992 + }
  3993 +
  3994 + // ----- Write gz file format footer
  3995 + $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
  3996 + @fwrite($v_dest_file, $v_binary_data, 8);
  3997 +
  3998 + // ----- Close the temporary file
  3999 + @fclose($v_dest_file);
  4000 +
  4001 + // ----- Opening destination file
  4002 + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
  4003 + $p_entry['status'] = "write_error";
  4004 + return $v_result;
  4005 + }
  4006 +
  4007 + // ----- Open the temporary gz file
  4008 + if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
  4009 + @fclose($v_dest_file);
  4010 + $p_entry['status'] = "read_error";
  4011 + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
  4012 + return PclZip::errorCode();
  4013 + }
  4014 +
  4015 +
  4016 + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
  4017 + $v_size = $p_entry['size'];
  4018 + while ($v_size != 0) {
  4019 + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
  4020 + $v_buffer = @gzread($v_src_file, $v_read_size);
  4021 + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
  4022 + @fwrite($v_dest_file, $v_buffer, $v_read_size);
  4023 + $v_size -= $v_read_size;
  4024 + }
  4025 + @fclose($v_dest_file);
  4026 + @gzclose($v_src_file);
  4027 +
  4028 + // ----- Delete the temporary file
  4029 + @unlink($v_gzip_temp_name);
  4030 +
  4031 + // ----- Return
3881 return $v_result; 4032 return $v_result;
3882 } 4033 }
3883 // -------------------------------------------------------------------------------- 4034 // --------------------------------------------------------------------------------
@@ -3890,16 +4041,13 @@ @@ -3890,16 +4041,13 @@
3890 // -------------------------------------------------------------------------------- 4041 // --------------------------------------------------------------------------------
3891 function privExtractFileInOutput(&$p_entry, &$p_options) 4042 function privExtractFileInOutput(&$p_entry, &$p_options)
3892 { 4043 {
3893 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', "");  
3894 $v_result=1; 4044 $v_result=1;
3895 4045
3896 // ----- Read the file header 4046 // ----- Read the file header
3897 if (($v_result = $this->privReadFileHeader($v_header)) != 1) { 4047 if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
3898 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
3899 return $v_result; 4048 return $v_result;
3900 } 4049 }
3901 4050
3902 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");  
3903 4051
3904 // ----- Check that the file header is coherent with $p_entry info 4052 // ----- Check that the file header is coherent with $p_entry info
3905 if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { 4053 if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
@@ -3908,7 +4056,6 @@ @@ -3908,7 +4056,6 @@
3908 4056
3909 // ----- Look for pre-extract callback 4057 // ----- Look for pre-extract callback
3910 if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { 4058 if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3911 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");  
3912 4059
3913 // ----- Generate a local information 4060 // ----- Generate a local information
3914 $v_local_header = array(); 4061 $v_local_header = array();
@@ -3917,7 +4064,8 @@ @@ -3917,7 +4064,8 @@
3917 // ----- Call the callback 4064 // ----- Call the callback
3918 // Here I do not use call_user_func() because I need to send a reference to the 4065 // Here I do not use call_user_func() because I need to send a reference to the
3919 // header. 4066 // header.
3920 - eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); 4067 +// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
  4068 + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3921 if ($v_result == 0) { 4069 if ($v_result == 0) {
3922 // ----- Change the file status 4070 // ----- Change the file status
3923 $p_entry['status'] = "skipped"; 4071 $p_entry['status'] = "skipped";
@@ -3926,7 +4074,6 @@ @@ -3926,7 +4074,6 @@
3926 4074
3927 // ----- Look for abort result 4075 // ----- Look for abort result
3928 if ($v_result == 2) { 4076 if ($v_result == 2) {
3929 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");  
3930 // ----- This status is internal and will be changed in 'skipped' 4077 // ----- This status is internal and will be changed in 'skipped'
3931 $p_entry['status'] = "aborted"; 4078 $p_entry['status'] = "aborted";
3932 $v_result = PCLZIP_ERR_USER_ABORTED; 4079 $v_result = PCLZIP_ERR_USER_ABORTED;
@@ -3935,11 +4082,9 @@ @@ -3935,11 +4082,9 @@
3935 // ----- Update the informations 4082 // ----- Update the informations
3936 // Only some fields can be modified 4083 // Only some fields can be modified
3937 $p_entry['filename'] = $v_local_header['filename']; 4084 $p_entry['filename'] = $v_local_header['filename'];
3938 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");  
3939 } 4085 }
3940 4086
3941 // ----- Trace 4087 // ----- Trace
3942 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");  
3943 4088
3944 // ----- Look if extraction should be done 4089 // ----- Look if extraction should be done
3945 if ($p_entry['status'] == 'ok') { 4090 if ($p_entry['status'] == 'ok') {
@@ -3948,8 +4093,6 @@ @@ -3948,8 +4093,6 @@
3948 if (!(($p_entry['external']&0x00000010)==0x00000010)) { 4093 if (!(($p_entry['external']&0x00000010)==0x00000010)) {
3949 // ----- Look for not compressed file 4094 // ----- Look for not compressed file
3950 if ($p_entry['compressed_size'] == $p_entry['size']) { 4095 if ($p_entry['compressed_size'] == $p_entry['size']) {
3951 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");  
3952 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");  
3953 4096
3954 // ----- Read the file in a buffer (one shot) 4097 // ----- Read the file in a buffer (one shot)
3955 $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); 4098 $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -3959,12 +4102,10 @@ @@ -3959,12 +4102,10 @@
3959 unset($v_buffer); 4102 unset($v_buffer);
3960 } 4103 }
3961 else { 4104 else {
3962 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");  
3963 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");  
3964 4105
3965 // ----- Read the compressed file in a buffer (one shot) 4106 // ----- Read the compressed file in a buffer (one shot)
3966 $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); 4107 $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3967 - 4108 +
3968 // ----- Decompress the file 4109 // ----- Decompress the file
3969 $v_file_content = gzinflate($v_buffer); 4110 $v_file_content = gzinflate($v_buffer);
3970 unset($v_buffer); 4111 unset($v_buffer);
@@ -3973,7 +4114,6 @@ @@ -3973,7 +4114,6 @@
3973 echo $v_file_content; 4114 echo $v_file_content;
3974 unset($v_file_content); 4115 unset($v_file_content);
3975 } 4116 }
3976 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");  
3977 } 4117 }
3978 } 4118 }
3979 4119
@@ -3984,7 +4124,6 @@ @@ -3984,7 +4124,6 @@
3984 4124
3985 // ----- Look for post-extract callback 4125 // ----- Look for post-extract callback
3986 elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { 4126 elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3987 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");  
3988 4127
3989 // ----- Generate a local information 4128 // ----- Generate a local information
3990 $v_local_header = array(); 4129 $v_local_header = array();
@@ -3993,16 +4132,15 @@ @@ -3993,16 +4132,15 @@
3993 // ----- Call the callback 4132 // ----- Call the callback
3994 // Here I do not use call_user_func() because I need to send a reference to the 4133 // Here I do not use call_user_func() because I need to send a reference to the
3995 // header. 4134 // header.
3996 - eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); 4135 +// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
  4136 + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3997 4137
3998 // ----- Look for abort result 4138 // ----- Look for abort result
3999 if ($v_result == 2) { 4139 if ($v_result == 2) {
4000 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");  
4001 $v_result = PCLZIP_ERR_USER_ABORTED; 4140 $v_result = PCLZIP_ERR_USER_ABORTED;
4002 } 4141 }
4003 } 4142 }
4004 4143
4005 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4006 return $v_result; 4144 return $v_result;
4007 } 4145 }
4008 // -------------------------------------------------------------------------------- 4146 // --------------------------------------------------------------------------------
@@ -4013,9 +4151,8 @@ @@ -4013,9 +4151,8 @@
4013 // Parameters : 4151 // Parameters :
4014 // Return Values : 4152 // Return Values :
4015 // -------------------------------------------------------------------------------- 4153 // --------------------------------------------------------------------------------
4016 - function privExtractFileAsString(&$p_entry, &$p_string) 4154 + function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4017 { 4155 {
4018 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");  
4019 $v_result=1; 4156 $v_result=1;
4020 4157
4021 // ----- Read the file header 4158 // ----- Read the file header
@@ -4023,52 +4160,110 @@ @@ -4023,52 +4160,110 @@
4023 if (($v_result = $this->privReadFileHeader($v_header)) != 1) 4160 if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4024 { 4161 {
4025 // ----- Return 4162 // ----- Return
4026 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4027 return $v_result; 4163 return $v_result;
4028 } 4164 }
4029 4165
4030 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");  
4031 4166
4032 // ----- Check that the file header is coherent with $p_entry info 4167 // ----- Check that the file header is coherent with $p_entry info
4033 if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { 4168 if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4034 // TBC 4169 // TBC
4035 } 4170 }
4036 4171
4037 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'"); 4172 + // ----- Look for pre-extract callback
  4173 + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4038 4174
4039 - // ----- Do the extraction (if not a folder)  
4040 - if (!(($p_entry['external']&0x00000010)==0x00000010))  
4041 - {  
4042 - // ----- Look for not compressed file  
4043 -// if ($p_entry['compressed_size'] == $p_entry['size'])  
4044 - if ($p_entry['compression'] == 0) {  
4045 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");  
4046 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");  
4047 -  
4048 - // ----- Reading the file  
4049 - $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); 4175 + // ----- Generate a local information
  4176 + $v_local_header = array();
  4177 + $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
  4178 +
  4179 + // ----- Call the callback
  4180 + // Here I do not use call_user_func() because I need to send a reference to the
  4181 + // header.
  4182 +// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
  4183 + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
  4184 + if ($v_result == 0) {
  4185 + // ----- Change the file status
  4186 + $p_entry['status'] = "skipped";
  4187 + $v_result = 1;
4050 } 4188 }
4051 - else {  
4052 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')"); 4189 +
  4190 + // ----- Look for abort result
  4191 + if ($v_result == 2) {
  4192 + // ----- This status is internal and will be changed in 'skipped'
  4193 + $p_entry['status'] = "aborted";
  4194 + $v_result = PCLZIP_ERR_USER_ABORTED;
  4195 + }
  4196 +
  4197 + // ----- Update the informations
  4198 + // Only some fields can be modified
  4199 + $p_entry['filename'] = $v_local_header['filename'];
  4200 + }
4053 4201
4054 - // ----- Reading the file  
4055 - $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);  
4056 4202
4057 - // ----- Decompress the file  
4058 - if (($p_string = @gzinflate($v_data)) === FALSE) {  
4059 - // TBC 4203 + // ----- Look if extraction should be done
  4204 + if ($p_entry['status'] == 'ok') {
  4205 +
  4206 + // ----- Do the extraction (if not a folder)
  4207 + if (!(($p_entry['external']&0x00000010)==0x00000010)) {
  4208 + // ----- Look for not compressed file
  4209 + // if ($p_entry['compressed_size'] == $p_entry['size'])
  4210 + if ($p_entry['compression'] == 0) {
  4211 +
  4212 + // ----- Reading the file
  4213 + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4060 } 4214 }
  4215 + else {
  4216 +
  4217 + // ----- Reading the file
  4218 + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
  4219 +
  4220 + // ----- Decompress the file
  4221 + if (($p_string = @gzinflate($v_data)) === FALSE) {
  4222 + // TBC
  4223 + }
  4224 + }
  4225 +
  4226 + // ----- Trace
4061 } 4227 }
4062 -  
4063 - // ----- Trace  
4064 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); 4228 + else {
  4229 + // TBC : error : can not extract a folder in a string
  4230 + }
  4231 +
4065 } 4232 }
4066 - else {  
4067 - // TBC : error : can not extract a folder in a string 4233 +
  4234 + // ----- Change abort status
  4235 + if ($p_entry['status'] == "aborted") {
  4236 + $p_entry['status'] = "skipped";
  4237 + }
  4238 +
  4239 + // ----- Look for post-extract callback
  4240 + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
  4241 +
  4242 + // ----- Generate a local information
  4243 + $v_local_header = array();
  4244 + $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
  4245 +
  4246 + // ----- Swap the content to header
  4247 + $v_local_header['content'] = $p_string;
  4248 + $p_string = '';
  4249 +
  4250 + // ----- Call the callback
  4251 + // Here I do not use call_user_func() because I need to send a reference to the
  4252 + // header.
  4253 +// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
  4254 + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
  4255 +
  4256 + // ----- Swap back the content to header
  4257 + $p_string = $v_local_header['content'];
  4258 + unset($v_local_header['content']);
  4259 +
  4260 + // ----- Look for abort result
  4261 + if ($v_result == 2) {
  4262 + $v_result = PCLZIP_ERR_USER_ABORTED;
  4263 + }
4068 } 4264 }
4069 4265
4070 // ----- Return 4266 // ----- Return
4071 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4072 return $v_result; 4267 return $v_result;
4073 } 4268 }
4074 // -------------------------------------------------------------------------------- 4269 // --------------------------------------------------------------------------------
@@ -4081,25 +4276,20 @@ @@ -4081,25 +4276,20 @@
4081 // -------------------------------------------------------------------------------- 4276 // --------------------------------------------------------------------------------
4082 function privReadFileHeader(&$p_header) 4277 function privReadFileHeader(&$p_header)
4083 { 4278 {
4084 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");  
4085 $v_result=1; 4279 $v_result=1;
4086 4280
4087 // ----- Read the 4 bytes signature 4281 // ----- Read the 4 bytes signature
4088 $v_binary_data = @fread($this->zip_fd, 4); 4282 $v_binary_data = @fread($this->zip_fd, 4);
4089 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");  
4090 $v_data = unpack('Vid', $v_binary_data); 4283 $v_data = unpack('Vid', $v_binary_data);
4091 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");  
4092 4284
4093 // ----- Check signature 4285 // ----- Check signature
4094 if ($v_data['id'] != 0x04034b50) 4286 if ($v_data['id'] != 0x04034b50)
4095 { 4287 {
4096 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");  
4097 4288
4098 // ----- Error log 4289 // ----- Error log
4099 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); 4290 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4100 4291
4101 // ----- Return 4292 // ----- Return
4102 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4103 return PclZip::errorCode(); 4293 return PclZip::errorCode();
4104 } 4294 }
4105 4295
@@ -4111,51 +4301,36 @@ @@ -4111,51 +4301,36 @@
4111 { 4301 {
4112 $p_header['filename'] = ""; 4302 $p_header['filename'] = "";
4113 $p_header['status'] = "invalid_header"; 4303 $p_header['status'] = "invalid_header";
4114 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));  
4115 4304
4116 // ----- Error log 4305 // ----- Error log
4117 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); 4306 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4118 4307
4119 // ----- Return 4308 // ----- Return
4120 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4121 return PclZip::errorCode(); 4309 return PclZip::errorCode();
4122 } 4310 }
4123 4311
4124 // ----- Extract the values 4312 // ----- Extract the values
4125 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");  
4126 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");  
4127 $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); 4313 $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4128 4314
4129 // ----- Get filename 4315 // ----- Get filename
4130 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);  
4131 $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); 4316 $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4132 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');  
4133 4317
4134 // ----- Get extra_fields 4318 // ----- Get extra_fields
4135 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);  
4136 if ($v_data['extra_len'] != 0) { 4319 if ($v_data['extra_len'] != 0) {
4137 $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); 4320 $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4138 } 4321 }
4139 else { 4322 else {
4140 $p_header['extra'] = ''; 4323 $p_header['extra'] = '';
4141 } 4324 }
4142 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');  
4143 4325
4144 // ----- Extract properties 4326 // ----- Extract properties
4145 $p_header['version_extracted'] = $v_data['version']; 4327 $p_header['version_extracted'] = $v_data['version'];
4146 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');  
4147 $p_header['compression'] = $v_data['compression']; 4328 $p_header['compression'] = $v_data['compression'];
4148 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\'');  
4149 $p_header['size'] = $v_data['size']; 4329 $p_header['size'] = $v_data['size'];
4150 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');  
4151 $p_header['compressed_size'] = $v_data['compressed_size']; 4330 $p_header['compressed_size'] = $v_data['compressed_size'];
4152 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');  
4153 $p_header['crc'] = $v_data['crc']; 4331 $p_header['crc'] = $v_data['crc'];
4154 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');  
4155 $p_header['flag'] = $v_data['flag']; 4332 $p_header['flag'] = $v_data['flag'];
4156 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');  
4157 $p_header['filename_len'] = $v_data['filename_len']; 4333 $p_header['filename_len'] = $v_data['filename_len'];
4158 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\'');  
4159 4334
4160 // ----- Recuperate date in UNIX format 4335 // ----- Recuperate date in UNIX format
4161 $p_header['mdate'] = $v_data['mdate']; 4336 $p_header['mdate'] = $v_data['mdate'];
@@ -4173,19 +4348,16 @@ @@ -4173,19 +4348,16 @@
4173 $v_day = $p_header['mdate'] & 0x001F; 4348 $v_day = $p_header['mdate'] & 0x001F;
4174 4349
4175 // ----- Get UNIX date format 4350 // ----- Get UNIX date format
4176 - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); 4351 + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4177 4352
4178 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');  
4179 } 4353 }
4180 else 4354 else
4181 { 4355 {
4182 $p_header['mtime'] = time(); 4356 $p_header['mtime'] = time();
4183 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');  
4184 } 4357 }
4185 4358
4186 // TBC 4359 // TBC
4187 //for(reset($v_data); $key = key($v_data); next($v_data)) { 4360 //for(reset($v_data); $key = key($v_data); next($v_data)) {
4188 - // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);  
4189 //} 4361 //}
4190 4362
4191 // ----- Set the stored filename 4363 // ----- Set the stored filename
@@ -4195,7 +4367,6 @@ @@ -4195,7 +4367,6 @@
4195 $p_header['status'] = "ok"; 4367 $p_header['status'] = "ok";
4196 4368
4197 // ----- Return 4369 // ----- Return
4198 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4199 return $v_result; 4370 return $v_result;
4200 } 4371 }
4201 // -------------------------------------------------------------------------------- 4372 // --------------------------------------------------------------------------------
@@ -4208,25 +4379,20 @@ @@ -4208,25 +4379,20 @@
4208 // -------------------------------------------------------------------------------- 4379 // --------------------------------------------------------------------------------
4209 function privReadCentralFileHeader(&$p_header) 4380 function privReadCentralFileHeader(&$p_header)
4210 { 4381 {
4211 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");  
4212 $v_result=1; 4382 $v_result=1;
4213 4383
4214 // ----- Read the 4 bytes signature 4384 // ----- Read the 4 bytes signature
4215 $v_binary_data = @fread($this->zip_fd, 4); 4385 $v_binary_data = @fread($this->zip_fd, 4);
4216 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");  
4217 $v_data = unpack('Vid', $v_binary_data); 4386 $v_data = unpack('Vid', $v_binary_data);
4218 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");  
4219 4387
4220 // ----- Check signature 4388 // ----- Check signature
4221 if ($v_data['id'] != 0x02014b50) 4389 if ($v_data['id'] != 0x02014b50)
4222 { 4390 {
4223 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");  
4224 4391
4225 // ----- Error log 4392 // ----- Error log
4226 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); 4393 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4227 4394
4228 // ----- Return 4395 // ----- Return
4229 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4230 return PclZip::errorCode(); 4396 return PclZip::errorCode();
4231 } 4397 }
4232 4398
@@ -4238,56 +4404,41 @@ @@ -4238,56 +4404,41 @@
4238 { 4404 {
4239 $p_header['filename'] = ""; 4405 $p_header['filename'] = "";
4240 $p_header['status'] = "invalid_header"; 4406 $p_header['status'] = "invalid_header";
4241 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));  
4242 4407
4243 // ----- Error log 4408 // ----- Error log
4244 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); 4409 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4245 4410
4246 // ----- Return 4411 // ----- Return
4247 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4248 return PclZip::errorCode(); 4412 return PclZip::errorCode();
4249 } 4413 }
4250 4414
4251 // ----- Extract the values 4415 // ----- Extract the values
4252 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");  
4253 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");  
4254 $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); 4416 $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4255 4417
4256 // ----- Get filename 4418 // ----- Get filename
4257 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);  
4258 if ($p_header['filename_len'] != 0) 4419 if ($p_header['filename_len'] != 0)
4259 $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); 4420 $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4260 else 4421 else
4261 $p_header['filename'] = ''; 4422 $p_header['filename'] = '';
4262 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');  
4263 4423
4264 // ----- Get extra 4424 // ----- Get extra
4265 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);  
4266 if ($p_header['extra_len'] != 0) 4425 if ($p_header['extra_len'] != 0)
4267 $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); 4426 $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4268 else 4427 else
4269 $p_header['extra'] = ''; 4428 $p_header['extra'] = '';
4270 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');  
4271 4429
4272 // ----- Get comment 4430 // ----- Get comment
4273 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);  
4274 if ($p_header['comment_len'] != 0) 4431 if ($p_header['comment_len'] != 0)
4275 $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); 4432 $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4276 else 4433 else
4277 $p_header['comment'] = ''; 4434 $p_header['comment'] = '';
4278 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');  
4279 4435
4280 // ----- Extract properties 4436 // ----- Extract properties
4281 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');  
4282 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');  
4283 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');  
4284 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');  
4285 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');  
4286 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');  
4287 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');  
4288 4437
4289 // ----- Recuperate date in UNIX format 4438 // ----- Recuperate date in UNIX format
4290 - if ($p_header['mdate'] && $p_header['mtime']) 4439 + //if ($p_header['mdate'] && $p_header['mtime'])
  4440 + // TBC : bug : this was ignoring time with 0/0/0
  4441 + if (1)
4291 { 4442 {
4292 // ----- Extract time 4443 // ----- Extract time
4293 $v_hour = ($p_header['mtime'] & 0xF800) >> 11; 4444 $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
@@ -4300,14 +4451,12 @@ @@ -4300,14 +4451,12 @@
4300 $v_day = $p_header['mdate'] & 0x001F; 4451 $v_day = $p_header['mdate'] & 0x001F;
4301 4452
4302 // ----- Get UNIX date format 4453 // ----- Get UNIX date format
4303 - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); 4454 + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4304 4455
4305 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');  
4306 } 4456 }
4307 else 4457 else
4308 { 4458 {
4309 $p_header['mtime'] = time(); 4459 $p_header['mtime'] = time();
4310 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');  
4311 } 4460 }
4312 4461
4313 // ----- Set the stored filename 4462 // ----- Set the stored filename
@@ -4317,18 +4466,13 @@ @@ -4317,18 +4466,13 @@
4317 $p_header['status'] = 'ok'; 4466 $p_header['status'] = 'ok';
4318 4467
4319 // ----- Look if it is a directory 4468 // ----- Look if it is a directory
4320 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");  
4321 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');  
4322 if (substr($p_header['filename'], -1) == '/') { 4469 if (substr($p_header['filename'], -1) == '/') {
4323 //$p_header['external'] = 0x41FF0010; 4470 //$p_header['external'] = 0x41FF0010;
4324 $p_header['external'] = 0x00000010; 4471 $p_header['external'] = 0x00000010;
4325 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\'');  
4326 } 4472 }
4327 4473
4328 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');  
4329 4474
4330 // ----- Return 4475 // ----- Return
4331 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4332 return $v_result; 4476 return $v_result;
4333 } 4477 }
4334 // -------------------------------------------------------------------------------- 4478 // --------------------------------------------------------------------------------
@@ -4343,44 +4487,31 @@ @@ -4343,44 +4487,31 @@
4343 // -------------------------------------------------------------------------------- 4487 // --------------------------------------------------------------------------------
4344 function privCheckFileHeaders(&$p_local_header, &$p_central_header) 4488 function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4345 { 4489 {
4346 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", "");  
4347 $v_result=1; 4490 $v_result=1;
4348 4491
4349 - // ----- Check the static values  
4350 - // TBC  
4351 - if ($p_local_header['filename'] != $p_central_header['filename']) {  
4352 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed');  
4353 - }  
4354 - if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {  
4355 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed');  
4356 - }  
4357 - if ($p_local_header['flag'] != $p_central_header['flag']) {  
4358 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed');  
4359 - }  
4360 - if ($p_local_header['compression'] != $p_central_header['compression']) {  
4361 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed');  
4362 - }  
4363 - if ($p_local_header['mtime'] != $p_central_header['mtime']) {  
4364 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed');  
4365 - }  
4366 - if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {  
4367 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed');  
4368 - }  
4369 -  
4370 - // ----- Look for flag bit 3  
4371 - if (($p_local_header['flag'] & 8) == 8) {  
4372 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !');  
4373 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header');  
4374 - $p_local_header['size'] = $p_central_header['size'];  
4375 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\'');  
4376 - $p_local_header['compressed_size'] = $p_central_header['compressed_size'];  
4377 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\'');  
4378 - $p_local_header['crc'] = $p_central_header['crc'];  
4379 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\'');  
4380 - } 4492 + // ----- Check the static values
  4493 + // TBC
  4494 + if ($p_local_header['filename'] != $p_central_header['filename']) {
  4495 + }
  4496 + if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
  4497 + }
  4498 + if ($p_local_header['flag'] != $p_central_header['flag']) {
  4499 + }
  4500 + if ($p_local_header['compression'] != $p_central_header['compression']) {
  4501 + }
  4502 + if ($p_local_header['mtime'] != $p_central_header['mtime']) {
  4503 + }
  4504 + if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
  4505 + }
  4506 +
  4507 + // ----- Look for flag bit 3
  4508 + if (($p_local_header['flag'] & 8) == 8) {
  4509 + $p_local_header['size'] = $p_central_header['size'];
  4510 + $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
  4511 + $p_local_header['crc'] = $p_central_header['crc'];
  4512 + }
4381 4513
4382 // ----- Return 4514 // ----- Return
4383 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4384 return $v_result; 4515 return $v_result;
4385 } 4516 }
4386 // -------------------------------------------------------------------------------- 4517 // --------------------------------------------------------------------------------
@@ -4393,21 +4524,17 @@ @@ -4393,21 +4524,17 @@
4393 // -------------------------------------------------------------------------------- 4524 // --------------------------------------------------------------------------------
4394 function privReadEndCentralDir(&$p_central_dir) 4525 function privReadEndCentralDir(&$p_central_dir)
4395 { 4526 {
4396 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");  
4397 $v_result=1; 4527 $v_result=1;
4398 4528
4399 // ----- Go to the end of the zip file 4529 // ----- Go to the end of the zip file
4400 $v_size = filesize($this->zipname); 4530 $v_size = filesize($this->zipname);
4401 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");  
4402 @fseek($this->zip_fd, $v_size); 4531 @fseek($this->zip_fd, $v_size);
4403 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');  
4404 if (@ftell($this->zip_fd) != $v_size) 4532 if (@ftell($this->zip_fd) != $v_size)
4405 { 4533 {
4406 // ----- Error log 4534 // ----- Error log
4407 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); 4535 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4408 4536
4409 // ----- Return 4537 // ----- Return
4410 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4411 return PclZip::errorCode(); 4538 return PclZip::errorCode();
4412 } 4539 }
4413 4540
@@ -4415,28 +4542,22 @@ @@ -4415,28 +4542,22 @@
4415 // in this case the end of central dir is at 22 bytes of the file end 4542 // in this case the end of central dir is at 22 bytes of the file end
4416 $v_found = 0; 4543 $v_found = 0;
4417 if ($v_size > 26) { 4544 if ($v_size > 26) {
4418 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');  
4419 @fseek($this->zip_fd, $v_size-22); 4545 @fseek($this->zip_fd, $v_size-22);
4420 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');  
4421 if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) 4546 if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4422 { 4547 {
4423 // ----- Error log 4548 // ----- Error log
4424 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); 4549 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4425 4550
4426 // ----- Return 4551 // ----- Return
4427 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4428 return PclZip::errorCode(); 4552 return PclZip::errorCode();
4429 } 4553 }
4430 4554
4431 // ----- Read for bytes 4555 // ----- Read for bytes
4432 $v_binary_data = @fread($this->zip_fd, 4); 4556 $v_binary_data = @fread($this->zip_fd, 4);
4433 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");  
4434 $v_data = @unpack('Vid', $v_binary_data); 4557 $v_data = @unpack('Vid', $v_binary_data);
4435 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");  
4436 4558
4437 // ----- Check signature 4559 // ----- Check signature
4438 if ($v_data['id'] == 0x06054b50) { 4560 if ($v_data['id'] == 0x06054b50) {
4439 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");  
4440 $v_found = 1; 4561 $v_found = 1;
4441 } 4562 }
4442 4563
@@ -4445,7 +4566,6 @@ @@ -4445,7 +4566,6 @@
4445 4566
4446 // ----- Go back to the maximum possible size of the Central Dir End Record 4567 // ----- Go back to the maximum possible size of the Central Dir End Record
4447 if (!$v_found) { 4568 if (!$v_found) {
4448 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');  
4449 $v_maximum_size = 65557; // 0xFFFF + 22; 4569 $v_maximum_size = 65557; // 0xFFFF + 22;
4450 if ($v_maximum_size > $v_size) 4570 if ($v_maximum_size > $v_size)
4451 $v_maximum_size = $v_size; 4571 $v_maximum_size = $v_size;
@@ -4456,10 +4576,8 @@ @@ -4456,10 +4576,8 @@
4456 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); 4576 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4457 4577
4458 // ----- Return 4578 // ----- Return
4459 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4460 return PclZip::errorCode(); 4579 return PclZip::errorCode();
4461 } 4580 }
4462 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');  
4463 4581
4464 // ----- Read byte per byte in order to find the signature 4582 // ----- Read byte per byte in order to find the signature
4465 $v_pos = ftell($this->zip_fd); 4583 $v_pos = ftell($this->zip_fd);
@@ -4470,12 +4588,14 @@ @@ -4470,12 +4588,14 @@
4470 $v_byte = @fread($this->zip_fd, 1); 4588 $v_byte = @fread($this->zip_fd, 1);
4471 4589
4472 // ----- Add the byte 4590 // ----- Add the byte
4473 - $v_bytes = ($v_bytes << 8) | Ord($v_byte); 4591 + //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
  4592 + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
  4593 + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
  4594 + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4474 4595
4475 // ----- Compare the bytes 4596 // ----- Compare the bytes
4476 if ($v_bytes == 0x504b0506) 4597 if ($v_bytes == 0x504b0506)
4477 { 4598 {
4478 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');  
4479 $v_pos++; 4599 $v_pos++;
4480 break; 4600 break;
4481 } 4601 }
@@ -4486,13 +4606,11 @@ @@ -4486,13 +4606,11 @@
4486 // ----- Look if not found end of central dir 4606 // ----- Look if not found end of central dir
4487 if ($v_pos == $v_size) 4607 if ($v_pos == $v_size)
4488 { 4608 {
4489 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");  
4490 4609
4491 // ----- Error log 4610 // ----- Error log
4492 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); 4611 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4493 4612
4494 // ----- Return 4613 // ----- Return
4495 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4496 return PclZip::errorCode(); 4614 return PclZip::errorCode();
4497 } 4615 }
4498 } 4616 }
@@ -4503,25 +4621,19 @@ @@ -4503,25 +4621,19 @@
4503 // ----- Look for invalid block size 4621 // ----- Look for invalid block size
4504 if (strlen($v_binary_data) != 18) 4622 if (strlen($v_binary_data) != 18)
4505 { 4623 {
4506 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));  
4507 4624
4508 // ----- Error log 4625 // ----- Error log
4509 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); 4626 PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4510 4627
4511 // ----- Return 4628 // ----- Return
4512 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4513 return PclZip::errorCode(); 4629 return PclZip::errorCode();
4514 } 4630 }
4515 4631
4516 // ----- Extract the values 4632 // ----- Extract the values
4517 - ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");  
4518 - ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");  
4519 $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); 4633 $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4520 4634
4521 // ----- Check the global size 4635 // ----- Check the global size
4522 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);  
4523 if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { 4636 if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4524 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.");  
4525 4637
4526 // ----- Removed in release 2.2 see readme file 4638 // ----- Removed in release 2.2 see readme file
4527 // The check of the file size is a little too strict. 4639 // The check of the file size is a little too strict.
@@ -4534,38 +4646,29 @@ @@ -4534,38 +4646,29 @@
4534 .' Some trailing bytes exists after the archive.'); 4646 .' Some trailing bytes exists after the archive.');
4535 4647
4536 // ----- Return 4648 // ----- Return
4537 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4538 return PclZip::errorCode(); 4649 return PclZip::errorCode();
4539 } 4650 }
4540 } 4651 }
4541 4652
4542 // ----- Get comment 4653 // ----- Get comment
4543 - if ($v_data['comment_size'] != 0) 4654 + if ($v_data['comment_size'] != 0) {
4544 $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); 4655 $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
  4656 + }
4545 else 4657 else
4546 $p_central_dir['comment'] = ''; 4658 $p_central_dir['comment'] = '';
4547 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');  
4548 4659
4549 $p_central_dir['entries'] = $v_data['entries']; 4660 $p_central_dir['entries'] = $v_data['entries'];
4550 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');  
4551 $p_central_dir['disk_entries'] = $v_data['disk_entries']; 4661 $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4552 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');  
4553 $p_central_dir['offset'] = $v_data['offset']; 4662 $p_central_dir['offset'] = $v_data['offset'];
4554 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');  
4555 $p_central_dir['size'] = $v_data['size']; 4663 $p_central_dir['size'] = $v_data['size'];
4556 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');  
4557 $p_central_dir['disk'] = $v_data['disk']; 4664 $p_central_dir['disk'] = $v_data['disk'];
4558 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');  
4559 $p_central_dir['disk_start'] = $v_data['disk_start']; 4665 $p_central_dir['disk_start'] = $v_data['disk_start'];
4560 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');  
4561 4666
4562 // TBC 4667 // TBC
4563 //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { 4668 //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4564 - // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);  
4565 //} 4669 //}
4566 4670
4567 // ----- Return 4671 // ----- Return
4568 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4569 return $v_result; 4672 return $v_result;
4570 } 4673 }
4571 // -------------------------------------------------------------------------------- 4674 // --------------------------------------------------------------------------------
@@ -4578,16 +4681,13 @@ @@ -4578,16 +4681,13 @@
4578 // -------------------------------------------------------------------------------- 4681 // --------------------------------------------------------------------------------
4579 function privDeleteByRule(&$p_result_list, &$p_options) 4682 function privDeleteByRule(&$p_result_list, &$p_options)
4580 { 4683 {
4581 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");  
4582 $v_result=1; 4684 $v_result=1;
4583 $v_list_detail = array(); 4685 $v_list_detail = array();
4584 4686
4585 // ----- Open the zip file 4687 // ----- Open the zip file
4586 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
4587 if (($v_result=$this->privOpenFd('rb')) != 1) 4688 if (($v_result=$this->privOpenFd('rb')) != 1)
4588 { 4689 {
4589 // ----- Return 4690 // ----- Return
4590 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4591 return $v_result; 4691 return $v_result;
4592 } 4692 }
4593 4693
@@ -4596,21 +4696,16 @@ @@ -4596,21 +4696,16 @@
4596 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) 4696 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4597 { 4697 {
4598 $this->privCloseFd(); 4698 $this->privCloseFd();
4599 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4600 return $v_result; 4699 return $v_result;
4601 } 4700 }
4602 4701
4603 // ----- Go to beginning of File 4702 // ----- Go to beginning of File
4604 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");  
4605 @rewind($this->zip_fd); 4703 @rewind($this->zip_fd);
4606 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");  
4607 4704
4608 // ----- Scan all the files 4705 // ----- Scan all the files
4609 // ----- Start at beginning of Central Dir 4706 // ----- Start at beginning of Central Dir
4610 $v_pos_entry = $v_central_dir['offset']; 4707 $v_pos_entry = $v_central_dir['offset'];
4611 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");  
4612 @rewind($this->zip_fd); 4708 @rewind($this->zip_fd);
4613 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");  
4614 if (@fseek($this->zip_fd, $v_pos_entry)) 4709 if (@fseek($this->zip_fd, $v_pos_entry))
4615 { 4710 {
4616 // ----- Close the zip file 4711 // ----- Close the zip file
@@ -4620,17 +4715,14 @@ @@ -4620,17 +4715,14 @@
4620 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); 4715 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4621 4716
4622 // ----- Return 4717 // ----- Return
4623 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4624 return PclZip::errorCode(); 4718 return PclZip::errorCode();
4625 } 4719 }
4626 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");  
4627 4720
4628 // ----- Read each entry 4721 // ----- Read each entry
4629 $v_header_list = array(); 4722 $v_header_list = array();
4630 $j_start = 0; 4723 $j_start = 0;
4631 for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) 4724 for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4632 { 4725 {
4633 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");  
4634 4726
4635 // ----- Read the file header 4727 // ----- Read the file header
4636 $v_header_list[$v_nb_extracted] = array(); 4728 $v_header_list[$v_nb_extracted] = array();
@@ -4639,11 +4731,9 @@ @@ -4639,11 +4731,9 @@
4639 // ----- Close the zip file 4731 // ----- Close the zip file
4640 $this->privCloseFd(); 4732 $this->privCloseFd();
4641 4733
4642 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4643 return $v_result; 4734 return $v_result;
4644 } 4735 }
4645 4736
4646 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");  
4647 4737
4648 // ----- Store the index 4738 // ----- Store the index
4649 $v_header_list[$v_nb_extracted]['index'] = $i; 4739 $v_header_list[$v_nb_extracted]['index'] = $i;
@@ -4654,54 +4744,47 @@ @@ -4654,54 +4744,47 @@
4654 // ----- Look for extract by name rule 4744 // ----- Look for extract by name rule
4655 if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) 4745 if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
4656 && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { 4746 && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4657 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");  
4658 4747
4659 // ----- Look if the filename is in the list 4748 // ----- Look if the filename is in the list
4660 for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { 4749 for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4661 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");  
4662 4750
4663 // ----- Look for a directory 4751 // ----- Look for a directory
4664 if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { 4752 if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4665 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");  
4666 4753
4667 // ----- Look if the directory is in the filename path 4754 // ----- Look if the directory is in the filename path
4668 if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) 4755 if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4669 && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { 4756 && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4670 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");  
4671 $v_found = true; 4757 $v_found = true;
4672 } 4758 }
4673 elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ 4759 elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4674 && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { 4760 && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4675 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");  
4676 $v_found = true; 4761 $v_found = true;
4677 } 4762 }
4678 } 4763 }
4679 // ----- Look for a filename 4764 // ----- Look for a filename
4680 elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { 4765 elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4681 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");  
4682 $v_found = true; 4766 $v_found = true;
4683 } 4767 }
4684 } 4768 }
4685 } 4769 }
4686 4770
4687 // ----- Look for extract by ereg rule 4771 // ----- Look for extract by ereg rule
  4772 + // ereg() is deprecated with PHP 5.3
  4773 + /*
4688 else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) 4774 else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
4689 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { 4775 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4690 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");  
4691 4776
4692 if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { 4777 if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4693 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");  
4694 $v_found = true; 4778 $v_found = true;
4695 } 4779 }
4696 } 4780 }
  4781 + */
4697 4782
4698 // ----- Look for extract by preg rule 4783 // ----- Look for extract by preg rule
4699 else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) 4784 else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
4700 && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { 4785 && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4701 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");  
4702 4786
4703 if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { 4787 if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4704 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");  
4705 $v_found = true; 4788 $v_found = true;
4706 } 4789 }
4707 } 4790 }
@@ -4709,41 +4792,33 @@ @@ -4709,41 +4792,33 @@
4709 // ----- Look for extract by index rule 4792 // ----- Look for extract by index rule
4710 else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) 4793 else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4711 && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { 4794 && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4712 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");  
4713 4795
4714 // ----- Look if the index is in the list 4796 // ----- Look if the index is in the list
4715 for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { 4797 for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4716 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");  
4717 4798
4718 if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { 4799 if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4719 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");  
4720 $v_found = true; 4800 $v_found = true;
4721 } 4801 }
4722 if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { 4802 if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4723 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");  
4724 $j_start = $j+1; 4803 $j_start = $j+1;
4725 } 4804 }
4726 4805
4727 if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { 4806 if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4728 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");  
4729 break; 4807 break;
4730 } 4808 }
4731 } 4809 }
4732 } 4810 }
4733 else { 4811 else {
4734 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file");  
4735 $v_found = true; 4812 $v_found = true;
4736 } 4813 }
4737 4814
4738 // ----- Look for deletion 4815 // ----- Look for deletion
4739 if ($v_found) 4816 if ($v_found)
4740 { 4817 {
4741 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");  
4742 unset($v_header_list[$v_nb_extracted]); 4818 unset($v_header_list[$v_nb_extracted]);
4743 } 4819 }
4744 else 4820 else
4745 { 4821 {
4746 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");  
4747 $v_nb_extracted++; 4822 $v_nb_extracted++;
4748 } 4823 }
4749 } 4824 }
@@ -4758,24 +4833,18 @@ @@ -4758,24 +4833,18 @@
4758 $v_temp_zip = new PclZip($v_zip_temp_name); 4833 $v_temp_zip = new PclZip($v_zip_temp_name);
4759 4834
4760 // ----- Open the temporary zip file in write mode 4835 // ----- Open the temporary zip file in write mode
4761 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");  
4762 if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { 4836 if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4763 $this->privCloseFd(); 4837 $this->privCloseFd();
4764 4838
4765 // ----- Return 4839 // ----- Return
4766 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4767 return $v_result; 4840 return $v_result;
4768 } 4841 }
4769 4842
4770 // ----- Look which file need to be kept 4843 // ----- Look which file need to be kept
4771 for ($i=0; $i<sizeof($v_header_list); $i++) { 4844 for ($i=0; $i<sizeof($v_header_list); $i++) {
4772 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");  
4773 4845
4774 // ----- Calculate the position of the header 4846 // ----- Calculate the position of the header
4775 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");  
4776 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");  
4777 @rewind($this->zip_fd); 4847 @rewind($this->zip_fd);
4778 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");  
4779 if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { 4848 if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4780 // ----- Close the zip file 4849 // ----- Close the zip file
4781 $this->privCloseFd(); 4850 $this->privCloseFd();
@@ -4786,10 +4855,8 @@ @@ -4786,10 +4855,8 @@
4786 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); 4855 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4787 4856
4788 // ----- Return 4857 // ----- Return
4789 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4790 return PclZip::errorCode(); 4858 return PclZip::errorCode();
4791 } 4859 }
4792 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");  
4793 4860
4794 // ----- Read the file header 4861 // ----- Read the file header
4795 $v_local_header = array(); 4862 $v_local_header = array();
@@ -4800,10 +4867,9 @@ @@ -4800,10 +4867,9 @@
4800 @unlink($v_zip_temp_name); 4867 @unlink($v_zip_temp_name);
4801 4868
4802 // ----- Return 4869 // ----- Return
4803 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4804 return $v_result; 4870 return $v_result;
4805 } 4871 }
4806 - 4872 +
4807 // ----- Check that local file header is same as central file header 4873 // ----- Check that local file header is same as central file header
4808 if ($this->privCheckFileHeaders($v_local_header, 4874 if ($this->privCheckFileHeaders($v_local_header,
4809 $v_header_list[$i]) != 1) { 4875 $v_header_list[$i]) != 1) {
@@ -4819,10 +4885,8 @@ @@ -4819,10 +4885,8 @@
4819 @unlink($v_zip_temp_name); 4885 @unlink($v_zip_temp_name);
4820 4886
4821 // ----- Return 4887 // ----- Return
4822 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4823 return $v_result; 4888 return $v_result;
4824 } 4889 }
4825 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");  
4826 4890
4827 // ----- Read/write the data block 4891 // ----- Read/write the data block
4828 if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { 4892 if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
@@ -4832,27 +4896,22 @@ @@ -4832,27 +4896,22 @@
4832 @unlink($v_zip_temp_name); 4896 @unlink($v_zip_temp_name);
4833 4897
4834 // ----- Return 4898 // ----- Return
4835 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4836 return $v_result; 4899 return $v_result;
4837 } 4900 }
4838 } 4901 }
4839 4902
4840 // ----- Store the offset of the central dir 4903 // ----- Store the offset of the central dir
4841 $v_offset = @ftell($v_temp_zip->zip_fd); 4904 $v_offset = @ftell($v_temp_zip->zip_fd);
4842 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");  
4843 4905
4844 // ----- Re-Create the Central Dir files header 4906 // ----- Re-Create the Central Dir files header
4845 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");  
4846 for ($i=0; $i<sizeof($v_header_list); $i++) { 4907 for ($i=0; $i<sizeof($v_header_list); $i++) {
4847 // ----- Create the file header 4908 // ----- Create the file header
4848 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);  
4849 if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { 4909 if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4850 $v_temp_zip->privCloseFd(); 4910 $v_temp_zip->privCloseFd();
4851 $this->privCloseFd(); 4911 $this->privCloseFd();
4852 @unlink($v_zip_temp_name); 4912 @unlink($v_zip_temp_name);
4853 4913
4854 // ----- Return 4914 // ----- Return
4855 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4856 return $v_result; 4915 return $v_result;
4857 } 4916 }
4858 4917
@@ -4860,7 +4919,6 @@ @@ -4860,7 +4919,6 @@
4860 $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); 4919 $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4861 } 4920 }
4862 4921
4863 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");  
4864 4922
4865 // ----- Zip file comment 4923 // ----- Zip file comment
4866 $v_comment = ''; 4924 $v_comment = '';
@@ -4880,7 +4938,6 @@ @@ -4880,7 +4938,6 @@
4880 @unlink($v_zip_temp_name); 4938 @unlink($v_zip_temp_name);
4881 4939
4882 // ----- Return 4940 // ----- Return
4883 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4884 return $v_result; 4941 return $v_result;
4885 } 4942 }
4886 4943
@@ -4896,22 +4953,20 @@ @@ -4896,22 +4953,20 @@
4896 // TBC : I should test the result ... 4953 // TBC : I should test the result ...
4897 //@rename($v_zip_temp_name, $this->zipname); 4954 //@rename($v_zip_temp_name, $this->zipname);
4898 PclZipUtilRename($v_zip_temp_name, $this->zipname); 4955 PclZipUtilRename($v_zip_temp_name, $this->zipname);
4899 - 4956 +
4900 // ----- Destroy the temporary archive 4957 // ----- Destroy the temporary archive
4901 unset($v_temp_zip); 4958 unset($v_temp_zip);
4902 } 4959 }
4903 - 4960 +
4904 // ----- Remove every files : reset the file 4961 // ----- Remove every files : reset the file
4905 else if ($v_central_dir['entries'] != 0) { 4962 else if ($v_central_dir['entries'] != 0) {
4906 $this->privCloseFd(); 4963 $this->privCloseFd();
4907 4964
4908 if (($v_result = $this->privOpenFd('wb')) != 1) { 4965 if (($v_result = $this->privOpenFd('wb')) != 1) {
4909 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4910 return $v_result; 4966 return $v_result;
4911 } 4967 }
4912 4968
4913 if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { 4969 if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4914 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4915 return $v_result; 4970 return $v_result;
4916 } 4971 }
4917 4972
@@ -4919,7 +4974,6 @@ @@ -4919,7 +4974,6 @@
4919 } 4974 }
4920 4975
4921 // ----- Return 4976 // ----- Return
4922 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4923 return $v_result; 4977 return $v_result;
4924 } 4978 }
4925 // -------------------------------------------------------------------------------- 4979 // --------------------------------------------------------------------------------
@@ -4939,25 +4993,21 @@ @@ -4939,25 +4993,21 @@
4939 { 4993 {
4940 $v_result = 1; 4994 $v_result = 1;
4941 4995
4942 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");  
4943 4996
4944 // ----- Remove the final '/' 4997 // ----- Remove the final '/'
4945 if (($p_is_dir) && (substr($p_dir, -1)=='/')) 4998 if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4946 { 4999 {
4947 $p_dir = substr($p_dir, 0, strlen($p_dir)-1); 5000 $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4948 } 5001 }
4949 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");  
4950 5002
4951 // ----- Check the directory availability 5003 // ----- Check the directory availability
4952 if ((is_dir($p_dir)) || ($p_dir == "")) 5004 if ((is_dir($p_dir)) || ($p_dir == ""))
4953 { 5005 {
4954 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");  
4955 return 1; 5006 return 1;
4956 } 5007 }
4957 5008
4958 // ----- Extract parent directory 5009 // ----- Extract parent directory
4959 $p_parent_dir = dirname($p_dir); 5010 $p_parent_dir = dirname($p_dir);
4960 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");  
4961 5011
4962 // ----- Just a check 5012 // ----- Just a check
4963 if ($p_parent_dir != $p_dir) 5013 if ($p_parent_dir != $p_dir)
@@ -4967,26 +5017,22 @@ @@ -4967,26 +5017,22 @@
4967 { 5017 {
4968 if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) 5018 if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
4969 { 5019 {
4970 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
4971 return $v_result; 5020 return $v_result;
4972 } 5021 }
4973 } 5022 }
4974 } 5023 }
4975 5024
4976 // ----- Create the directory 5025 // ----- Create the directory
4977 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");  
4978 if (!@mkdir($p_dir, 0777)) 5026 if (!@mkdir($p_dir, 0777))
4979 { 5027 {
4980 // ----- Error log 5028 // ----- Error log
4981 PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); 5029 PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
4982 5030
4983 // ----- Return 5031 // ----- Return
4984 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
4985 return PclZip::errorCode(); 5032 return PclZip::errorCode();
4986 } 5033 }
4987 5034
4988 // ----- Return 5035 // ----- Return
4989 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");  
4990 return $v_result; 5036 return $v_result;
4991 } 5037 }
4992 // -------------------------------------------------------------------------------- 5038 // --------------------------------------------------------------------------------
@@ -5000,41 +5046,34 @@ @@ -5000,41 +5046,34 @@
5000 // -------------------------------------------------------------------------------- 5046 // --------------------------------------------------------------------------------
5001 function privMerge(&$p_archive_to_add) 5047 function privMerge(&$p_archive_to_add)
5002 { 5048 {
5003 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");  
5004 $v_result=1; 5049 $v_result=1;
5005 5050
5006 // ----- Look if the archive_to_add exists 5051 // ----- Look if the archive_to_add exists
5007 if (!is_file($p_archive_to_add->zipname)) 5052 if (!is_file($p_archive_to_add->zipname))
5008 { 5053 {
5009 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");  
5010 5054
5011 // ----- Nothing to merge, so merge is a success 5055 // ----- Nothing to merge, so merge is a success
5012 $v_result = 1; 5056 $v_result = 1;
5013 5057
5014 // ----- Return 5058 // ----- Return
5015 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5016 return $v_result; 5059 return $v_result;
5017 } 5060 }
5018 5061
5019 // ----- Look if the archive exists 5062 // ----- Look if the archive exists
5020 if (!is_file($this->zipname)) 5063 if (!is_file($this->zipname))
5021 { 5064 {
5022 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");  
5023 5065
5024 // ----- Do a duplicate 5066 // ----- Do a duplicate
5025 $v_result = $this->privDuplicate($p_archive_to_add->zipname); 5067 $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5026 5068
5027 // ----- Return 5069 // ----- Return
5028 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5029 return $v_result; 5070 return $v_result;
5030 } 5071 }
5031 5072
5032 // ----- Open the zip file 5073 // ----- Open the zip file
5033 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
5034 if (($v_result=$this->privOpenFd('rb')) != 1) 5074 if (($v_result=$this->privOpenFd('rb')) != 1)
5035 { 5075 {
5036 // ----- Return 5076 // ----- Return
5037 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5038 return $v_result; 5077 return $v_result;
5039 } 5078 }
5040 5079
@@ -5043,23 +5082,18 @@ @@ -5043,23 +5082,18 @@
5043 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) 5082 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5044 { 5083 {
5045 $this->privCloseFd(); 5084 $this->privCloseFd();
5046 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5047 return $v_result; 5085 return $v_result;
5048 } 5086 }
5049 5087
5050 // ----- Go to beginning of File 5088 // ----- Go to beginning of File
5051 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");  
5052 @rewind($this->zip_fd); 5089 @rewind($this->zip_fd);
5053 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");  
5054 5090
5055 // ----- Open the archive_to_add file 5091 // ----- Open the archive_to_add file
5056 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");  
5057 if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) 5092 if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5058 { 5093 {
5059 $this->privCloseFd(); 5094 $this->privCloseFd();
5060 5095
5061 // ----- Return 5096 // ----- Return
5062 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5063 return $v_result; 5097 return $v_result;
5064 } 5098 }
5065 5099
@@ -5070,20 +5104,16 @@ @@ -5070,20 +5104,16 @@
5070 $this->privCloseFd(); 5104 $this->privCloseFd();
5071 $p_archive_to_add->privCloseFd(); 5105 $p_archive_to_add->privCloseFd();
5072 5106
5073 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5074 return $v_result; 5107 return $v_result;
5075 } 5108 }
5076 5109
5077 // ----- Go to beginning of File 5110 // ----- Go to beginning of File
5078 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");  
5079 @rewind($p_archive_to_add->zip_fd); 5111 @rewind($p_archive_to_add->zip_fd);
5080 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");  
5081 5112
5082 // ----- Creates a temporay file 5113 // ----- Creates a temporay file
5083 $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; 5114 $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5084 5115
5085 // ----- Open the temporary file in write mode 5116 // ----- Open the temporary file in write mode
5086 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
5087 if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) 5117 if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5088 { 5118 {
5089 $this->privCloseFd(); 5119 $this->privCloseFd();
@@ -5092,7 +5122,6 @@ @@ -5092,7 +5122,6 @@
5092 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); 5122 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5093 5123
5094 // ----- Return 5124 // ----- Return
5095 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
5096 return PclZip::errorCode(); 5125 return PclZip::errorCode();
5097 } 5126 }
5098 5127
@@ -5102,7 +5131,6 @@ @@ -5102,7 +5131,6 @@
5102 while ($v_size != 0) 5131 while ($v_size != 0)
5103 { 5132 {
5104 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 5133 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5105 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5106 $v_buffer = fread($this->zip_fd, $v_read_size); 5134 $v_buffer = fread($this->zip_fd, $v_read_size);
5107 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); 5135 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5108 $v_size -= $v_read_size; 5136 $v_size -= $v_read_size;
@@ -5113,7 +5141,6 @@ @@ -5113,7 +5141,6 @@
5113 while ($v_size != 0) 5141 while ($v_size != 0)
5114 { 5142 {
5115 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 5143 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5116 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5117 $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); 5144 $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5118 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); 5145 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5119 $v_size -= $v_read_size; 5146 $v_size -= $v_read_size;
@@ -5121,14 +5148,12 @@ @@ -5121,14 +5148,12 @@
5121 5148
5122 // ----- Store the offset of the central dir 5149 // ----- Store the offset of the central dir
5123 $v_offset = @ftell($v_zip_temp_fd); 5150 $v_offset = @ftell($v_zip_temp_fd);
5124 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");  
5125 5151
5126 // ----- Copy the block of file headers from the old archive 5152 // ----- Copy the block of file headers from the old archive
5127 $v_size = $v_central_dir['size']; 5153 $v_size = $v_central_dir['size'];
5128 while ($v_size != 0) 5154 while ($v_size != 0)
5129 { 5155 {
5130 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 5156 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5131 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5132 $v_buffer = @fread($this->zip_fd, $v_read_size); 5157 $v_buffer = @fread($this->zip_fd, $v_read_size);
5133 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); 5158 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5134 $v_size -= $v_read_size; 5159 $v_size -= $v_read_size;
@@ -5139,7 +5164,6 @@ @@ -5139,7 +5164,6 @@
5139 while ($v_size != 0) 5164 while ($v_size != 0)
5140 { 5165 {
5141 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 5166 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5142 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5143 $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); 5167 $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5144 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); 5168 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5145 $v_size -= $v_read_size; 5169 $v_size -= $v_read_size;
@@ -5170,7 +5194,6 @@ @@ -5170,7 +5194,6 @@
5170 unset($v_header_list); 5194 unset($v_header_list);
5171 5195
5172 // ----- Return 5196 // ----- Return
5173 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5174 return $v_result; 5197 return $v_result;
5175 } 5198 }
5176 5199
@@ -5196,7 +5219,6 @@ @@ -5196,7 +5219,6 @@
5196 PclZipUtilRename($v_zip_temp_name, $this->zipname); 5219 PclZipUtilRename($v_zip_temp_name, $this->zipname);
5197 5220
5198 // ----- Return 5221 // ----- Return
5199 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5200 return $v_result; 5222 return $v_result;
5201 } 5223 }
5202 // -------------------------------------------------------------------------------- 5224 // --------------------------------------------------------------------------------
@@ -5209,33 +5231,27 @@ @@ -5209,33 +5231,27 @@
5209 // -------------------------------------------------------------------------------- 5231 // --------------------------------------------------------------------------------
5210 function privDuplicate($p_archive_filename) 5232 function privDuplicate($p_archive_filename)
5211 { 5233 {
5212 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");  
5213 $v_result=1; 5234 $v_result=1;
5214 5235
5215 // ----- Look if the $p_archive_filename exists 5236 // ----- Look if the $p_archive_filename exists
5216 if (!is_file($p_archive_filename)) 5237 if (!is_file($p_archive_filename))
5217 { 5238 {
5218 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");  
5219 5239
5220 // ----- Nothing to duplicate, so duplicate is a success. 5240 // ----- Nothing to duplicate, so duplicate is a success.
5221 $v_result = 1; 5241 $v_result = 1;
5222 5242
5223 // ----- Return 5243 // ----- Return
5224 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5225 return $v_result; 5244 return $v_result;
5226 } 5245 }
5227 5246
5228 // ----- Open the zip file 5247 // ----- Open the zip file
5229 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
5230 if (($v_result=$this->privOpenFd('wb')) != 1) 5248 if (($v_result=$this->privOpenFd('wb')) != 1)
5231 { 5249 {
5232 // ----- Return 5250 // ----- Return
5233 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5234 return $v_result; 5251 return $v_result;
5235 } 5252 }
5236 5253
5237 // ----- Open the temporary file in write mode 5254 // ----- Open the temporary file in write mode
5238 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  
5239 if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) 5255 if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5240 { 5256 {
5241 $this->privCloseFd(); 5257 $this->privCloseFd();
@@ -5243,7 +5259,6 @@ @@ -5243,7 +5259,6 @@
5243 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); 5259 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5244 5260
5245 // ----- Return 5261 // ----- Return
5246 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  
5247 return PclZip::errorCode(); 5262 return PclZip::errorCode();
5248 } 5263 }
5249 5264
@@ -5253,7 +5268,6 @@ @@ -5253,7 +5268,6 @@
5253 while ($v_size != 0) 5268 while ($v_size != 0)
5254 { 5269 {
5255 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); 5270 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5256 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");  
5257 $v_buffer = fread($v_zip_temp_fd, $v_read_size); 5271 $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5258 @fwrite($this->zip_fd, $v_buffer, $v_read_size); 5272 @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5259 $v_size -= $v_read_size; 5273 $v_size -= $v_read_size;
@@ -5266,7 +5280,6 @@ @@ -5266,7 +5280,6 @@
5266 @fclose($v_zip_temp_fd); 5280 @fclose($v_zip_temp_fd);
5267 5281
5268 // ----- Return 5282 // ----- Return
5269 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5270 return $v_result; 5283 return $v_result;
5271 } 5284 }
5272 // -------------------------------------------------------------------------------- 5285 // --------------------------------------------------------------------------------
@@ -5306,29 +5319,6 @@ @@ -5306,29 +5319,6 @@
5306 // -------------------------------------------------------------------------------- 5319 // --------------------------------------------------------------------------------
5307 5320
5308 // -------------------------------------------------------------------------------- 5321 // --------------------------------------------------------------------------------
5309 - // Function : privDecrypt()  
5310 - // Description :  
5311 - // Parameters :  
5312 - // Return Values :  
5313 - // --------------------------------------------------------------------------------  
5314 - function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc)  
5315 - {  
5316 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size."");  
5317 - $v_result=1;  
5318 -  
5319 - // ----- To Be Modified ;-)  
5320 - $v_pwd = "test";  
5321 -  
5322 - $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header,  
5323 - $p_crc, $v_pwd);  
5324 -  
5325 - // ----- Return  
5326 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5327 - return $v_result;  
5328 - }  
5329 - // --------------------------------------------------------------------------------  
5330 -  
5331 - // --------------------------------------------------------------------------------  
5332 // Function : privDisableMagicQuotes() 5322 // Function : privDisableMagicQuotes()
5333 // Description : 5323 // Description :
5334 // Parameters : 5324 // Parameters :
@@ -5336,36 +5326,28 @@ @@ -5336,36 +5326,28 @@
5336 // -------------------------------------------------------------------------------- 5326 // --------------------------------------------------------------------------------
5337 function privDisableMagicQuotes() 5327 function privDisableMagicQuotes()
5338 { 5328 {
5339 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', "");  
5340 $v_result=1; 5329 $v_result=1;
5341 5330
5342 // ----- Look if function exists 5331 // ----- Look if function exists
5343 if ( (!function_exists("get_magic_quotes_runtime")) 5332 if ( (!function_exists("get_magic_quotes_runtime"))
5344 || (!function_exists("set_magic_quotes_runtime"))) { 5333 || (!function_exists("set_magic_quotes_runtime"))) {
5345 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");  
5346 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5347 return $v_result; 5334 return $v_result;
5348 } 5335 }
5349 5336
5350 // ----- Look if already done 5337 // ----- Look if already done
5351 if ($this->magic_quotes_status != -1) { 5338 if ($this->magic_quotes_status != -1) {
5352 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled");  
5353 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5354 return $v_result; 5339 return $v_result;
5355 } 5340 }
5356 5341
5357 // ----- Get and memorize the magic_quote value 5342 // ----- Get and memorize the magic_quote value
5358 $this->magic_quotes_status = @get_magic_quotes_runtime(); 5343 $this->magic_quotes_status = @get_magic_quotes_runtime();
5359 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'");  
5360 5344
5361 // ----- Disable magic_quotes 5345 // ----- Disable magic_quotes
5362 if ($this->magic_quotes_status == 1) { 5346 if ($this->magic_quotes_status == 1) {
5363 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes");  
5364 @set_magic_quotes_runtime(0); 5347 @set_magic_quotes_runtime(0);
5365 } 5348 }
5366 5349
5367 // ----- Return 5350 // ----- Return
5368 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5369 return $v_result; 5351 return $v_result;
5370 } 5352 }
5371 // -------------------------------------------------------------------------------- 5353 // --------------------------------------------------------------------------------
@@ -5378,32 +5360,25 @@ @@ -5378,32 +5360,25 @@
5378 // -------------------------------------------------------------------------------- 5360 // --------------------------------------------------------------------------------
5379 function privSwapBackMagicQuotes() 5361 function privSwapBackMagicQuotes()
5380 { 5362 {
5381 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");  
5382 $v_result=1; 5363 $v_result=1;
5383 5364
5384 // ----- Look if function exists 5365 // ----- Look if function exists
5385 if ( (!function_exists("get_magic_quotes_runtime")) 5366 if ( (!function_exists("get_magic_quotes_runtime"))
5386 || (!function_exists("set_magic_quotes_runtime"))) { 5367 || (!function_exists("set_magic_quotes_runtime"))) {
5387 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");  
5388 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5389 return $v_result; 5368 return $v_result;
5390 } 5369 }
5391 5370
5392 // ----- Look if something to do 5371 // ----- Look if something to do
5393 if ($this->magic_quotes_status != -1) { 5372 if ($this->magic_quotes_status != -1) {
5394 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");  
5395 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5396 return $v_result; 5373 return $v_result;
5397 } 5374 }
5398 5375
5399 // ----- Swap back magic_quotes 5376 // ----- Swap back magic_quotes
5400 if ($this->magic_quotes_status == 1) { 5377 if ($this->magic_quotes_status == 1) {
5401 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");  
5402 @set_magic_quotes_runtime($this->magic_quotes_status); 5378 @set_magic_quotes_runtime($this->magic_quotes_status);
5403 } 5379 }
5404 5380
5405 // ----- Return 5381 // ----- Return
5406 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5407 return $v_result; 5382 return $v_result;
5408 } 5383 }
5409 // -------------------------------------------------------------------------------- 5384 // --------------------------------------------------------------------------------
@@ -5420,7 +5395,6 @@ @@ -5420,7 +5395,6 @@
5420 // -------------------------------------------------------------------------------- 5395 // --------------------------------------------------------------------------------
5421 function PclZipUtilPathReduction($p_dir) 5396 function PclZipUtilPathReduction($p_dir)
5422 { 5397 {
5423 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");  
5424 $v_result = ""; 5398 $v_result = "";
5425 5399
5426 // ----- Look for not empty path 5400 // ----- Look for not empty path
@@ -5447,7 +5421,6 @@ @@ -5447,7 +5421,6 @@
5447 // ----- It is an invalid path, so the path is not modified 5421 // ----- It is an invalid path, so the path is not modified
5448 // TBC 5422 // TBC
5449 $v_result = $p_dir; 5423 $v_result = $p_dir;
5450 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged");  
5451 $v_skip = 0; 5424 $v_skip = 0;
5452 } 5425 }
5453 } 5426 }
@@ -5471,7 +5444,7 @@ @@ -5471,7 +5444,7 @@
5471 } 5444 }
5472 } 5445 }
5473 } 5446 }
5474 - 5447 +
5475 // ----- Look for skip 5448 // ----- Look for skip
5476 if ($v_skip > 0) { 5449 if ($v_skip > 0) {
5477 while ($v_skip > 0) { 5450 while ($v_skip > 0) {
@@ -5482,7 +5455,6 @@ @@ -5482,7 +5455,6 @@
5482 } 5455 }
5483 5456
5484 // ----- Return 5457 // ----- Return
5485 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5486 return $v_result; 5458 return $v_result;
5487 } 5459 }
5488 // -------------------------------------------------------------------------------- 5460 // --------------------------------------------------------------------------------
@@ -5504,19 +5476,16 @@ @@ -5504,19 +5476,16 @@
5504 // -------------------------------------------------------------------------------- 5476 // --------------------------------------------------------------------------------
5505 function PclZipUtilPathInclusion($p_dir, $p_path) 5477 function PclZipUtilPathInclusion($p_dir, $p_path)
5506 { 5478 {
5507 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");  
5508 $v_result = 1; 5479 $v_result = 1;
5509 - 5480 +
5510 // ----- Look for path beginning by ./ 5481 // ----- Look for path beginning by ./
5511 if ( ($p_dir == '.') 5482 if ( ($p_dir == '.')
5512 || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { 5483 || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5513 $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); 5484 $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5514 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'");  
5515 } 5485 }
5516 if ( ($p_path == '.') 5486 if ( ($p_path == '.')
5517 || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { 5487 || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5518 $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); 5488 $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5519 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'");  
5520 } 5489 }
5521 5490
5522 // ----- Explode dir and path by directory separator 5491 // ----- Explode dir and path by directory separator
@@ -5529,7 +5498,6 @@ @@ -5529,7 +5498,6 @@
5529 $i = 0; 5498 $i = 0;
5530 $j = 0; 5499 $j = 0;
5531 while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { 5500 while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5532 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");  
5533 5501
5534 // ----- Look for empty dir (path reduction) 5502 // ----- Look for empty dir (path reduction)
5535 if ($v_list_dir[$i] == '') { 5503 if ($v_list_dir[$i] == '') {
@@ -5543,7 +5511,6 @@ @@ -5543,7 +5511,6 @@
5543 5511
5544 // ----- Compare the items 5512 // ----- Compare the items
5545 if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { 5513 if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
5546 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");  
5547 $v_result = 0; 5514 $v_result = 0;
5548 } 5515 }
5549 5516
@@ -5554,11 +5521,9 @@ @@ -5554,11 +5521,9 @@
5554 5521
5555 // ----- Look if everything seems to be the same 5522 // ----- Look if everything seems to be the same
5556 if ($v_result) { 5523 if ($v_result) {
5557 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");  
5558 // ----- Skip all the empty items 5524 // ----- Skip all the empty items
5559 while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; 5525 while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5560 while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; 5526 while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5561 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");  
5562 5527
5563 if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { 5528 if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5564 // ----- There are exactly the same 5529 // ----- There are exactly the same
@@ -5571,7 +5536,6 @@ @@ -5571,7 +5536,6 @@
5571 } 5536 }
5572 5537
5573 // ----- Return 5538 // ----- Return
5574 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5575 return $v_result; 5539 return $v_result;
5576 } 5540 }
5577 // -------------------------------------------------------------------------------- 5541 // --------------------------------------------------------------------------------
@@ -5589,30 +5553,23 @@ @@ -5589,30 +5553,23 @@
5589 // -------------------------------------------------------------------------------- 5553 // --------------------------------------------------------------------------------
5590 function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) 5554 function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5591 { 5555 {
5592 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");  
5593 $v_result = 1; 5556 $v_result = 1;
5594 5557
5595 if ($p_mode==0) 5558 if ($p_mode==0)
5596 { 5559 {
5597 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));  
5598 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));  
5599 while ($p_size != 0) 5560 while ($p_size != 0)
5600 { 5561 {
5601 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); 5562 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5602 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5603 $v_buffer = @fread($p_src, $v_read_size); 5563 $v_buffer = @fread($p_src, $v_read_size);
5604 @fwrite($p_dest, $v_buffer, $v_read_size); 5564 @fwrite($p_dest, $v_buffer, $v_read_size);
5605 $p_size -= $v_read_size; 5565 $p_size -= $v_read_size;
5606 } 5566 }
5607 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));  
5608 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));  
5609 } 5567 }
5610 else if ($p_mode==1) 5568 else if ($p_mode==1)
5611 { 5569 {
5612 while ($p_size != 0) 5570 while ($p_size != 0)
5613 { 5571 {
5614 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); 5572 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5615 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5616 $v_buffer = @gzread($p_src, $v_read_size); 5573 $v_buffer = @gzread($p_src, $v_read_size);
5617 @fwrite($p_dest, $v_buffer, $v_read_size); 5574 @fwrite($p_dest, $v_buffer, $v_read_size);
5618 $p_size -= $v_read_size; 5575 $p_size -= $v_read_size;
@@ -5623,7 +5580,6 @@ @@ -5623,7 +5580,6 @@
5623 while ($p_size != 0) 5580 while ($p_size != 0)
5624 { 5581 {
5625 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); 5582 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5626 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5627 $v_buffer = @fread($p_src, $v_read_size); 5583 $v_buffer = @fread($p_src, $v_read_size);
5628 @gzwrite($p_dest, $v_buffer, $v_read_size); 5584 @gzwrite($p_dest, $v_buffer, $v_read_size);
5629 $p_size -= $v_read_size; 5585 $p_size -= $v_read_size;
@@ -5634,7 +5590,6 @@ @@ -5634,7 +5590,6 @@
5634 while ($p_size != 0) 5590 while ($p_size != 0)
5635 { 5591 {
5636 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); 5592 $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5637 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");  
5638 $v_buffer = @gzread($p_src, $v_read_size); 5593 $v_buffer = @gzread($p_src, $v_read_size);
5639 @gzwrite($p_dest, $v_buffer, $v_read_size); 5594 @gzwrite($p_dest, $v_buffer, $v_read_size);
5640 $p_size -= $v_read_size; 5595 $p_size -= $v_read_size;
@@ -5642,7 +5597,6 @@ @@ -5642,7 +5597,6 @@
5642 } 5597 }
5643 5598
5644 // ----- Return 5599 // ----- Return
5645 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5646 return $v_result; 5600 return $v_result;
5647 } 5601 }
5648 // -------------------------------------------------------------------------------- 5602 // --------------------------------------------------------------------------------
@@ -5661,26 +5615,21 @@ @@ -5661,26 +5615,21 @@
5661 // -------------------------------------------------------------------------------- 5615 // --------------------------------------------------------------------------------
5662 function PclZipUtilRename($p_src, $p_dest) 5616 function PclZipUtilRename($p_src, $p_dest)
5663 { 5617 {
5664 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");  
5665 $v_result = 1; 5618 $v_result = 1;
5666 5619
5667 // ----- Try to rename the files 5620 // ----- Try to rename the files
5668 if (!@rename($p_src, $p_dest)) { 5621 if (!@rename($p_src, $p_dest)) {
5669 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");  
5670 5622
5671 // ----- Try to copy & unlink the src 5623 // ----- Try to copy & unlink the src
5672 if (!@copy($p_src, $p_dest)) { 5624 if (!@copy($p_src, $p_dest)) {
5673 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");  
5674 $v_result = 0; 5625 $v_result = 0;
5675 } 5626 }
5676 else if (!@unlink($p_src)) { 5627 else if (!@unlink($p_src)) {
5677 - //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");  
5678 $v_result = 0; 5628 $v_result = 0;
5679 } 5629 }
5680 } 5630 }
5681 5631
5682 // ----- Return 5632 // ----- Return
5683 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5684 return $v_result; 5633 return $v_result;
5685 } 5634 }
5686 // -------------------------------------------------------------------------------- 5635 // --------------------------------------------------------------------------------
@@ -5696,23 +5645,20 @@ @@ -5696,23 +5645,20 @@
5696 // -------------------------------------------------------------------------------- 5645 // --------------------------------------------------------------------------------
5697 function PclZipUtilOptionText($p_option) 5646 function PclZipUtilOptionText($p_option)
5698 { 5647 {
5699 - //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");  
5700 - 5648 +
5701 $v_list = get_defined_constants(); 5649 $v_list = get_defined_constants();
5702 for (reset($v_list); $v_key = key($v_list); next($v_list)) { 5650 for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5703 - $v_prefix = substr($v_key, 0, 10);  
5704 - if (( ($v_prefix == 'PCLZIP_OPT')  
5705 - || ($v_prefix == 'PCLZIP_CB_')  
5706 - || ($v_prefix == 'PCLZIP_ATT'))  
5707 - && ($v_list[$v_key] == $p_option)) {  
5708 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);  
5709 - return $v_key; 5651 + $v_prefix = substr($v_key, 0, 10);
  5652 + if (( ($v_prefix == 'PCLZIP_OPT')
  5653 + || ($v_prefix == 'PCLZIP_CB_')
  5654 + || ($v_prefix == 'PCLZIP_ATT'))
  5655 + && ($v_list[$v_key] == $p_option)) {
  5656 + return $v_key;
5710 } 5657 }
5711 } 5658 }
5712 - 5659 +
5713 $v_result = 'Unknown'; 5660 $v_result = 'Unknown';
5714 5661
5715 - //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);  
5716 return $v_result; 5662 return $v_result;
5717 } 5663 }
5718 // -------------------------------------------------------------------------------- 5664 // --------------------------------------------------------------------------------
var/bin/schedulerTask.sh
@@ -2,11 +2,11 @@ @@ -2,11 +2,11 @@
2 PHP_CLI="/usr/local/zend/bin/php" 2 PHP_CLI="/usr/local/zend/bin/php"
3 3
4 BIN_DIR=$(dirname $0) 4 BIN_DIR=$(dirname $0)
5 -INSTALL_DIR="../../${BIN_DIR}" 5 +INSTALL_DIR="../..${BIN_DIR}"
6 6
7 cd $INSTALL_DIR/bin 7 cd $INSTALL_DIR/bin
8 8
9 while true; do 9 while true; do
10 $PHP_CLI -Cq scheduler.php 10 $PHP_CLI -Cq scheduler.php
11 sleep 30 11 sleep 30
12 -done  
13 \ No newline at end of file 12 \ No newline at end of file
  13 +done