function check_executable_r($dir, $chmod = 0777, $func = CHMOD_DIR, $first = false)
{
    $dh = opendir($dir);
    if (!$first) {
        check_executable($dir, $chmod, false, $func);
    }
    while ($file = readdir($dh)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $dir . DIRECTORY_SEPARATOR . $file;
            if (is_dir($fullpath)) {
                check_executable($fullpath, $chmod, false, $func);
                check_executable_r($fullpath, $chmod, $func, true);
            }
        }
    }
    closedir($dh);
}
    check_writable('admin/data/notes.php');
    check_writable_r('docs');
    check_writable_r('language');
    check_executable_r('admin/backup');
    check_executable_r('admin/data');
    check_executable_r('designs');
    check_executable_r('docs');
    check_executable_r('images');
    check_executable_r('templates');
    check_executable_r('components');
    check_executable_r('language');
    check_executable('classes/cron/jobs');
    check_executable('classes/feedcreator');
    check_executable('classes/fonts');
    check_executable('classes/geshi');
    check_executable('classes/graphic/noises');
    check_writable_r('templates');
}
@ini_set('default_charset', '');
header('Content-type: text/html; charset: iso-8859-1');
$htmlhead = '';
// Arrays for Dates
$months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
// Arrays for Permissions
$gls = array('admin' => 'Is Administrator', 'gmod' => 'Is Global Moderator', 'guest' => 'Is Guest', 'members' => 'Can view Memberlist', 'profile' => 'Can view Profiles', 'pdf' => 'Can view PDF-Files', 'pm' => 'Can use PM', 'wwo' => 'Can view Who is Online', 'search' => 'Can use Search', 'team' => 'Can view Teamlist', 'usepic' => 'Can use (own) Avatar', 'useabout' => 'Create (own) Personal Page', 'usesignature' => 'Can use (own) Signature', 'downloadfiles' => 'Can download Attachements', 'forum' => 'Can view Forums', 'posttopics' => 'Can start a new Thread', 'postreplies' => 'Can write a reply', 'addvotes' => 'Can start a Poll', 'attachments' => 'Can add Attachements', 'edit' => 'Can edit own Posts', 'voting' => 'Can vote', 'docs' => 'Can view Documents/Pages');
$gll = array('admin' => 'The user ist he highest ranked Administrator in the forum. He may use this admincenter and has full control of the forum!', 'gmod' => 'The user will automatically be moderator in all forums and can use all options and actions on topics.', 'guest' => 'The users in this usergroup are (not registered) guests.', 'members' => 'May view the memberlist and use eventually observably data.', 'profile' => 'The user may view the profiles of the members and use eventually observably data.', 'pdf' => 'The user may download particular topics as PDF-file.', 'pm' => 'The user may use the Private Messaging (PM) System. He can send, receive, administer and archive private messages.', 'wwo' => 'May view the where-is-who-online-list with the users residence.', 'search' => 'May use the Search and view the results.', 'team' => 'May view the teamlist with administrators, global moderators and moderators.', 'usepic' => 'May upload his own picture for his profile (frequently named avatar) or indicate an URL to a picture.', 'useabout' => 'May create a personal site in his user profile.', 'usesignature' => 'The user may create his own signature.', 'downloadfiles' => 'The user may view and download attached files.', 'forum' => 'The user may generally view the forums and read them.', 'posttopics' => 'New topics may be started.', 'postreplies' => 'Answers to topics may be written.', 'addvotes' => 'Polls may be created within topics.', 'attachments' => 'The user may attach files to his post.', 'edit' => 'The user may edit and delete his own posts.', 'voting' => 'The user may participate in polls in topics.', 'docs' => 'May view all documents & pages.');
$glk = array_keys($gls);
$glk_forums = array('f_downloadfiles' => 'downloadfiles', 'f_forum' => 'forum', 'f_posttopics' => 'posttopics', 'f_postreplies' => 'postreplies', 'f_addvotes' => 'addvotes', 'f_attachments' => 'attachments', 'f_edit' => 'edit', 'f_voting' => 'voting');
$guest_limitation = array('admin', 'gmod', 'pm', 'usepic', 'useabout', 'usesignature', 'voting', 'edit');
// Variables
function resize_image_netpbm($src, $dest, $quality, $width, $height, $image_info)
{
    global $convert_options;
    $convert_path = $convert_options['convert_path'];
    $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
    $target = $width > $height ? $width : $height;
    $command = $convert_path . "/" . check_executable($types[$image_info[2]] . "topnm") . " " . $src . " | " . $convert_path . "/" . check_executable("pnmscale") . " --quiet -xysize " . $target . " " . $target . " | ";
    if ($image_info[2] == 1) {
        $command .= $convert_path . "/" . check_executable("ppmquant") . " 256 | " . $convert_path . "/" . check_executable("ppmtogif") . " > " . $dest;
    } elseif ($image_info[2] == 3) {
        $command .= $convert_path . "/" . check_executable("pnmtopng") . " > " . $dest;
    } else {
        $jpeg_exec = file_exists($convert_path . "/" . check_executable("pnmtojpeg")) ? check_executable("pnmtojpeg") : check_executable("ppmtojpeg");
        $command .= $convert_path . "/" . $jpeg_exec . " --quality=" . $quality . " > " . $dest;
    }
    system($command);
    return file_exists($dest) ? 1 : 0;
}
    echo $newdir;
    ?>
"></td>
  </tr>
  <tr>
   <td class="ubox" colspan="2" align="center"><input type="submit" name="Submit" value="Extract"></td> 
  </tr>
 </table>
</form>
	<?php 
    echo foot();
} elseif ($job == "extract2") {
    echo head();
    $file = $gpc->get('path', none);
    $dir = $gpc->get('to', none);
    check_executable($dir);
    $redirect = 'admin.php?action=explorer&path=' . urlencode(extract_dir($file, false));
    if (!preg_match('#\\.(tar\\.gz|tar|gz|zip)$#is', $file, $ext)) {
        error($redirect, 'The archive is currently not supported. (Failed at position: preg_match)');
    }
    unset($extension);
    if (isset($ext[1])) {
        $extension = $ext[1];
        if ($extension == 'zip') {
            include 'classes/class.zip.php';
            $archive = new PclZip($file);
            if ($archive->extract(PCLZIP_OPT_PATH, $dir) == 0) {
                error($redirect, $archive->errorInfo(true));
            }
        } elseif ($extension == 'tar.gz') {
            gzAbortNotLoaded();
Example #5
0
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
/* this file is called with ajax post javascript from "Check for updates" link in footer
 * It will return a string with the error/status.
 */
require_once '../inc/common.php';
require_once ELAB_ROOT . 'inc/locale.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    /* before we do the check, we need to make sure :
     * 1. git exists on the system
     * 2. curl extension is installed
     */
    // check if git exists on the system
    if (!check_executable('git')) {
        echo _('Install git to check for updates.');
        exit;
    }
    // check that curl extension is installed and loaded
    if (!extension_loaded('curl')) {
        echo _('You need to install the curl extension for php.');
        exit;
    }
    // all is good, go !
    // get what is the latest commit on master branch
    // we use curl and not git ls-remote to be able to input proxy settings
    $ch = curl_init();
    // get what is the current branch
    $current_branch = shell_exec('git symbolic-ref --short -q HEAD');
    // we remove the end of the line character