$hideGoButton = ''; } if ($warn) { $img = 'warn.png'; } else { $img = 'pass.png'; } if ($autorun) { $task .= '&autorun=' . $autorun; } if ($blindInstall) { ob_end_clean(); $blindInstall = false; $stop = !$autorun; } else { $stop = !setupUserAuthorized(); } if ($stop) { ?> <div class="error"> <?php if (zp_loggedin()) { echo gettext("You need <em>USER ADMIN</em> rights to run setup."); } else { echo gettext('You must be logged in to run setup.'); } ?> </div> <?php $_zp_authority->printLoginForm('', false); } else {
/** * * checks presence and permissions of folders * @param $which * @param $path * @param $class * @param $relaxation * @param $subfolders */ function folderCheck($which, $path, $class, $subfolders, $recurse, $chmod, $updatechmod) { global $serverpath, $permission_names; $path = str_replace('\\', '/', $path); if (!is_dir($path) && $class == 'std') { mkdir_recursive($path, $chmod); } switch ($class) { case 'std': $append = trim(str_replace($serverpath, '', $path), '/'); if ($append != $which) { $f = " (<em>{$append}</em>)"; } else { $f = ''; } if (!is_null($subfolders)) { $subfolderfailed = ''; foreach ($subfolders as $subfolder) { if (!mkdir_recursive($path . $subfolder, $chmod)) { $subfolderfailed .= ', <code>' . $subfolder . '</code>'; } } if (!empty($subfolderfailed)) { return checkMark(-1, '', sprintf(gettext('<em>%1$s</em> folder%2$s [subfolder creation failure]'), $which, $f), sprintf(gettext('Setup could not create the following subfolders:<br />%s'), substr($subfolderfailed, 2))); } } if (isWin()) { $perms = fileperms($path) & 0700; $check = $chmod & 0700; } else { $perms = fileperms($path) & 0777; $check = $chmod; } if (setupUserAuthorized() && $updatechmod) { @chmod($path, $chmod); clearstatcache(); $perms = fileperms($path) & 0777; if (!checkPermissions($perms, $chmod)) { if (array_key_exists($perms & 0666 | 4, $permission_names)) { $perms_class = $permission_names[$perms & 0666 | 4]; } else { $perms_class = gettext('unknown'); } if (array_key_exists($chmod & 0666 | 4, $permission_names)) { $chmod_class = $permission_names[$chmod & 0666 | 4]; } else { $chmod_class = gettext('unknown'); } return checkMark(-1, '', sprintf(gettext('<em>%1$s</em> folder%2$s [permissions failure]'), $which, $f), sprintf(gettext('Setup could not change the file permissions from <em>%1$s</em> (<code>0%2$o</code>) to <em>%3$s</em> (<code>0%4$o</code>). You will have to set the permissions manually. See the <a href="http://www.zenphoto.org/news/troubleshooting-zenphoto#29">Troubleshooting guide</a> for details on Zenphoto permissions requirements.'), $perms_class, $perms, $chmod_class, $chmod)); } else { if ($recurse) { ?> <script type="text/javascript"> // <!-- <![CDATA[ $.ajax({ type: 'POST', cache: false, url: '<?php echo WEBPATH . '/' . ZENFOLDER; ?> /setup/setup_permissions_changer.php', data: 'folder=<?php echo $path; ?> &key=<?php echo sha1(filemtime(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE) . file_get_contents(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE)); ?> ' }); // ]]> --> </script> <?php } } } break; case 'in_webpath': $webpath = $_SERVER['SCRIPT_NAME']; if (empty($webpath)) { $serverroot = $serverpath; } else { $i = strpos($webpath, '/' . ZENFOLDER); $webpath = substr($webpath, 0, $i); $serverroot = substr($serverpath, 0, strpos($serverpath, $webpath)); } $append = substr($path, strlen($serverroot) + 1); $f = " (<em>{$append}</em>)"; break; case 'external': $append = $path; $f = " (<em>{$append}</em>)"; break; } if (!is_dir($path)) { $msg = " " . sprintf(gettext('You must create the folder <em>%1$s</em><br /><code>mkdir(%2$s, 0777)</code>.'), $append, substr($path, 0, -1)); if ($class != 'std') { return checkMark(false, '', sprintf(gettext('<em>%1$s</em> folder [<em>%2$s</em> does not exist]'), $which, $append), $msg); } else { return checkMark(false, '', sprintf(gettext('<em>%1$s</em> folder [<em>%2$s</em> does not exist and <strong>setup</strong> could not create it]'), $which, $append), $msg); } } else { if (!is_writable($path)) { $msg = sprintf(gettext('Change the permissions on the <code>%1$s</code> folder to be writable by the server (<code>chmod 777 %2$s</code>)'), $which, $append); return checkMark(false, '', sprintf(gettext('<em>%1$s</em> folder [<em>%2$s</em> is not writeable and <strong>setup</strong> could not make it so]'), $which, $append), $msg); } else { return checkMark(true, sprintf(gettext('<em>%1$s</em> folder%2$s'), $which, $f), '', ''); } } }