Example #1
0
function createfolder($path)
{
    if (!file_exists($path)) {
        createfolder(dirname($path));
        mkdir($path, 07777);
    }
}
Example #2
0
function createFolder($folder)
{
    $result = false;
    if (!file_exists($folder)) {
        createfolder(dirname($folder));
        $result = mkdir($folder, 511);
    }
    return $result;
}
Example #3
0
$createqty = 0;
$deleteqty = 0;
$renameqty = 0;
$errorqty = 0;
// Create any child folders with entered name
if (isset($_POST['createfolder'])) {
    foreach ($_POST['createfolder'] as $parent => $newfolder) {
        if ($newfolder != '') {
            $createthisfolder = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$parent]) . clean_filename($newfolder);
            if (!file_exists($createthisfolder) && createfolder($createthisfolder, $tinybrowser['unixpermissions'])) {
                $createqty++;
            } else {
                $errorqty++;
            }
            if ($typenow == 'image') {
                createfolder($createthisfolder . '/_thumbs/', $tinybrowser['unixpermissions']);
            }
        }
    }
}
// Delete any checked folders
if (isset($_POST['deletefolder'])) {
    foreach ($_POST['deletefolder'] as $delthis => $val) {
        if ($typenow == 'image') {
            $delthisthumbdir = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$delthis]) . '_thumbs/';
            if (is_dir($delthisthumbdir)) {
                rmdir($delthisthumbdir);
            }
        }
        $delthisdir = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$delthis]);
        if (is_dir($delthisdir) && rmdir($delthisdir)) {
Example #4
0
					$file['height'][] = 'N/A';
					$file['dimensions'][] = 'N/A';
					$file['type'][] = returnMIMEType($filename);
					}
				}
			}
		}
	closedir($dh);
	}
// create file upload folder
else
	{
	$success = createfolder($tinybrowser['docroot'].$browsepath,$tinybrowser['unixpermissions']);
	if($success)
		{
		if($typenow=='image') createfolder($tinybrowser['docroot'].$browsepath.'_thumbs/',$tinybrowser['unixpermissions']);
		$notify['type'][]='success';
		$notify['message'][]=sprintf(TB_MSGMKDIR, $browsepath);
		}
	else
		{
		$notify['type'][]='error';
		$notify['message'][]=sprintf(TB_MSGMKDIRFAIL, $browsepath);
		}
	}

// Assign directory structure to array
$browsedirs=array();
dirtree($browsedirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]);

// generate alert if new thumbnails created
Example #5
0
                    }
                } else {
                    $file['width'][] = 'N/A';
                    $file['height'][] = 'N/A';
                    $file['dimensions'][] = 'N/A';
                    $file['type'][] = returnMIMEType($filename);
                }
            }
        }
    }
    closedir($dh);
} else {
    $success = createfolder($tinybrowser['docroot'] . $browsepath, $tinybrowser['unixpermissions']);
    if ($success) {
        if ($typenow == 'image') {
            createfolder($tinybrowser['docroot'] . $browsepath . '_thumbs/', $tinybrowser['unixpermissions']);
        }
        $notify['type'][] = 'success';
        $notify['message'][] = sprintf(TB_MSGMKDIR, $browsepath);
    } else {
        $notify['type'][] = 'error';
        $notify['message'][] = sprintf(TB_MSGMKDIRFAIL, $browsepath);
    }
}
// generate alert if new thumbnails created
if ($newthumbqty > 0) {
    $notify['type'][] = 'info';
    $notify['message'][] = sprintf(TB_MSGNEWTHUMBS, $newthumbqty);
}
// determine sort order
$sortorder = $sorttypenow == 'asc' ? SORT_ASC : SORT_DESC;
Example #6
0
function createfolder($dir, $perm)
{
    is_dir(dirname($dir)) || createfolder(dirname($dir), $perm);
    return is_dir($dir) || @mkdir($dir, $perm);
}
Example #7
0
#	   file_get_contents("{$SYSCONFDIR}/{$PROJECT}/Db.conf")));
$path = "{$SYSCONFDIR}/{$PROJECT}}/Db.conf";
$alpha_buckets = array('a-c', 'd-f', 'g-i', 'j-l', 'm-o', 'p-r', 's-u', 'v-z');
db_init($path);
if (!$_pg_conn) {
    echo "ERROR: could not connect to DB\n";
    exit(1);
}
/*
 * Steps are:
 * 1. create top folder
 * using value returned from cratefolder,
 * 2. use that in a loop to create the other folders.
 * 3. Other folders are created with
 * createrfolder, and then associated with parent folder with
 * createfoldercontents.
 */
$sql = 'select users.root_folder_fk from users';
// who is my parent?
$pfolder4user = db_query1($sql);
// Create top level folder 'Freshmeat'
$f_pk = createfolder($pfolder4user, 'Freshmeat', "Top folder for FM Archives");
$sql_fm = "select folder_pk, folder_name from folder where folder_name='Freshmeat'";
$fm_pk = db_query1($sql_fm);
// Create the alpha bucket folders and associate them with the
// Freshmeat folder.
for ($num = 0; $num < count($alpha_buckets); $num++) {
    #echo "arraychunks: {$alpha_buckets[$num]}\n";
    $folder_pk = createfolder($fm_pk, "{$alpha_buckets[$num]}", "Holds Freshmeat archives");
    $fold_cont_pk = createfoldercontents($fm_pk, $folder_pk, 1);
}
Example #8
0
                    $file['width'][] = 'N/A';
                    $file['height'][] = 'N/A';
                    $file['dimensions'][] = 'N/A';
                    $file['type'][] = returnMIMEType($filename);
                }
            }
        }
    }
    closedir($dh);
} elseif ($_SESSION['tinybrowser']['sessionsecured'] == true && isset($_SESSION[$_SESSION['tinybrowser']['sessioncheck']])) {
    // Check request tokens
    secure_tokens(true, false);
    $success = createfolder($_SESSION['tinybrowser']['docroot'] . $browsepath, $_SESSION['tinybrowser']['unixpermissions']);
    if ($success) {
        if ($typenow == 'image') {
            createfolder($_SESSION['tinybrowser']['docroot'] . $browsepath . '_thumbs/', $_SESSION['tinybrowser']['unixpermissions']);
        }
        $notify['type'][] = 'success';
        $notify['message'][] = sprintf(TB_MSGMKDIR, $browsepath);
    } else {
        $notify['type'][] = 'error';
        $notify['message'][] = sprintf(TB_MSGMKDIRFAIL, $browsepath);
    }
}
// Assign directory structure to array
$browsedirs = array();
dirtree($browsedirs, $_SESSION['tinybrowser']['filetype'][$typenow], $_SESSION['tinybrowser']['docroot'], $_SESSION['tinybrowser']['path'][$typenow]);
// generate alert if new thumbnails created
if ($newthumbqty > 0) {
    $notify['type'][] = 'info';
    $notify['message'][] = sprintf(TB_MSGNEWTHUMBS, $newthumbqty);
Example #9
0
function check_upload_dirs()
{
    // We first clear the stat cache
    @clearstatcache();
    if (!file_exists($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['image'])) {
        //sprintf(TB_UPLOADIRNOTCREATED,$_SESSION['tinybrowser']['path']['image']);
        createfolder($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['image'], $_SESSION['tinybrowser']['unixpermissions']);
    }
    if (!file_exists($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['image'] . '_thumbs')) {
        //sprintf(TB_UPLOADIRNOTCREATED,$_SESSION['tinybrowser']['path']['image'].'_thumbs');
        createfolder($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['image'] . '_thumbs', $_SESSION['tinybrowser']['unixpermissions']);
    }
    if (!file_exists($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['media'])) {
        //sprintf(TB_UPLOADIRNOTCREATED,$_SESSION['tinybrowser']['path']['media']);
        createfolder($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['media'], $_SESSION['tinybrowser']['unixpermissions']);
    }
    if (!file_exists($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['file'])) {
        //sprintf(TB_UPLOADIRNOTCREATED,$_SESSION['tinybrowser']['path']['file']);
        createfolder($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['file'], $_SESSION['tinybrowser']['unixpermissions']);
    }
    // Maybe we need to do additional checks for some reasons
    if (!is_writeable($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['image'])) {
        sprintf(TB_UPLOADIRNOTWRITABLE, $_SESSION['tinybrowser']['path']['image']);
    }
    if (!is_writeable($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['media'])) {
        sprintf(TB_UPLOADIRNOTWRITABLE, $_SESSION['tinybrowser']['path']['media']);
    }
    if (!is_writeable($_SESSION['tinybrowser']['docroot'] . $_SESSION['tinybrowser']['path']['file'])) {
        sprintf(TB_UPLOADIRNOTWRITABLE, $_SESSION['tinybrowser']['path']['file']);
    }
}
Example #10
0
            $safefolder = str_replace(array('../', '..\\', './', '.\\', '..'), '', urldecode($_POST['actionfolder'][$parent]));
            $newfolder = substr($newfolder, 0, 32);
            // 32 in length
            $newfolder = clean_dirname($newfolder);
            if (has_bad_utf8($newfolder) || strlen($newfolder) == 0) {
                deny(TB_INVALID_FOLDERNAME);
            }
            $createthisfolder = $_SESSION['tinybrowser']['docroot'] . $dirpath . $safefolder . clean_filename($newfolder);
            verify_dir($createthisfolder, $typenow);
            if (!file_exists($createthisfolder) && createfolder($createthisfolder, $_SESSION['tinybrowser']['unixpermissions'])) {
                $createqty++;
            } else {
                $errorqty++;
            }
            if ($typenow == 'image') {
                createfolder($createthisfolder . '/_thumbs/', $_SESSION['tinybrowser']['unixpermissions']);
            }
        }
    }
}
// Delete any checked folders
if (isset($_POST['deletefolder'])) {
    foreach ($_POST['deletefolder'] as $delthis => $val) {
        $safefolder = str_replace(array('../', '..\\', './', '.\\'), '', urldecode($_POST['actionfolder'][$delthis]));
        if ($typenow == 'image') {
            $delthisthumbdir = $_SESSION['tinybrowser']['docroot'] . $dirpath . $safefolder . '_thumbs/';
            verify_dir($delthisthumbdir, $typenow);
            if (is_dir($delthisthumbdir)) {
                @rmdir($delthisthumbdir);
            }
        }
Example #11
0
$createqty = 0;
$deleteqty = 0;
$renameqty = 0;
$errorqty = 0;
// Create any child folders with entered name
if (isset($_POST['createfolder'])) {
    foreach ($_POST['createfolder'] as $parent => $newfolder) {
        if ($newfolder != '') {
            $createthisfolder = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$parent]) . clean_filename($newfolder);
            if (!file_exists($createthisfolder) && createfolder($createthisfolder, $tinybrowser['unixpermissions'])) {
                $createqty++;
            } else {
                $errorqty++;
            }
            if ($typenow == 'image') {
                createfolder($createthisfolder . '/' . $tinybrowser['thumbdir'] . '/', $tinybrowser['unixpermissions']);
            }
        }
    }
}
// Delete any checked folders
if (isset($_POST['deletefolder'])) {
    foreach ($_POST['deletefolder'] as $delthis => $val) {
        if ($typenow == 'image') {
            $delthisthumbdir = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$delthis]) . $tinybrowser['thumbdir'] . '/';
            if (is_dir($delthisthumbdir)) {
                rmdir($delthisthumbdir);
            }
        }
        $delthisdir = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$delthis]);
        if (is_dir($delthisdir) && rmdir($delthisdir)) {
Example #12
0
$dirpath = $tinybrowser['path'][$typenow];
$passfolder = '&folder=' . urlencode($foldernow);
// Assign browsing options
$actionnow = isset($_POST['editaction']) ? $_POST['editaction'] : 'create';
// Initalise alert array
$notify = array('type' => array(), 'message' => array());
$createqty = 0;
$deleteqty = 0;
$renameqty = 0;
$errorqty = 0;
// Create any child folders with entered name
if (isset($_POST['createfolder'])) {
    foreach ($_POST['createfolder'] as $parent => $newfolder) {
        if ($newfolder != '') {
            $createthisfolder = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$parent]) . clean_filename($newfolder);
            if (!file_exists($createthisfolder) && createfolder($createthisfolder, $tinybrowser['unixpermissions'])) {
                $createqty++;
            } else {
                $errorqty++;
            }
        }
    }
}
// Delete any checked folders
if (isset($_POST['deletefolder'])) {
    foreach ($_POST['deletefolder'] as $delthis => $val) {
        $delthisdir = $tinybrowser['docroot'] . $dirpath . urldecode($_POST['actionfolder'][$delthis]);
        if (is_dir($delthisdir) && rmdir($delthisdir)) {
            $deleteqty++;
        } else {
            $errorqty++;
Example #13
0
 $exists = $findnow ? preg_match('/' . preg_quote(clean_filename($findnow)) . '/i', $filename) : true;
 // assign file details to array, for all files or those that match search
 if ($exists) {
     $file['name'][] = $filename;
     $file['sortname'][] = strtolower($filename);
     $file['modified'][] = filemtime($tinybrowser['docroot'] . $browsepath . $filename);
     $file['size'][] = filesize($tinybrowser['docroot'] . $browsepath . $filename);
     // image specific info or general
     if ($typenow == 'image' && ($imginfo = @getimagesize($tinybrowser['docroot'] . $browsepath . $filename))) {
         $file['width'][] = $imginfo[0];
         $file['height'][] = $imginfo[1];
         $file['dimensions'][] = $imginfo[0] + $imginfo[1];
         $file['type'][] = $imginfo['mime'];
         // Check a thumbnail exists
         if (!file_exists($tinybrowser['docroot'] . $browsepath . $tinybrowser['thumbdir'] . '/')) {
             createfolder($tinybrowser['docroot'] . $browsepath . $tinybrowser['thumbdir'] . '/', $tinybrowser['unixpermissions']);
         }
         $thumbimg = $tinybrowser['docroot'] . $browsepath . $tinybrowser['thumbdir'] . '/' . $tinybrowser['thumbprefix'] . $filename;
         if (!file_exists($thumbimg)) {
             $nothumbimg = $tinybrowser['docroot'] . $browsepath . $filename;
             $mime = getimagesize($nothumbimg);
             $im = convert_image($nothumbimg, $mime['mime']);
             resizeimage($im, $tinybrowser['thumbsize'], $tinybrowser['thumbsize'], $thumbimg, $tinybrowser['thumbquality'], $mime['mime']);
             imagedestroy($im);
             $newthumbqty++;
         }
     } else {
         $file['width'][] = 'N/A';
         $file['height'][] = 'N/A';
         $file['dimensions'][] = 'N/A';
         $file['type'][] = returnMIMEType($filename);