473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

where to set permission in the code

142 100+
Hi, the following coding is and the whole of the admin, it uploads images you select to the folder called images:

But the problem is is sets the images permissions to 600 and I need them to be 644 in order to work,

I tried to set them but can't get it to work...

Example uploadpath/$folder",0644;

But it does not work please help...

[PHP]
$c = $HTTP_GET_VARS[c]; //Category
$n = $HTTP_GET_VARS[n]; //ResultOffset
$key = $HTTP_GET_VARS[key]; //ResultOrder
$locked = $HTTP_GET_VARS[locked]; //Suspended
//
if(!$c) $c = $HTTP_POST_VARS[c]; //FormOption
if(!$locked) $locked = $HTTP_POST_VARS[locked]; //FormOption
$action = $HTTP_POST_VARS[action];
$abortlist = $HTTP_POST_VARS[abortlist];
$photocat = $HTTP_POST_VARS[photocat];
$photodesc = $HTTP_POST_VARS[photodesc];
$submit = $HTTP_POST_VARS[submit];
//
require "config.inc.php";
dbget_dbopen();
if(!$locked) $locked = "0";
if(!session_admin()){
header("Location: login.php?page=admin.php");
}else{
$fsize = $HTTP_POST_FILES[photodata][size];
$tsize = $HTTP_POST_FILES[thumbdata][size];
if($fsize>0 and $fsize<$max_file_size and $tsize<$max_file_size/10){
$fnametmp = $HTTP_POST_FILES[photodata][tmp_name];
$fname = $HTTP_POST_FILES[photodata][name];
if($HTTP_POST_FILES[thumbdata][size]){
upload_one($fnametmp,$fname,$fsize,$photocat,$phot odesc,$HTTP_POST_FILES[thumbdata][tmp_name]);
}else{
upload_one($fnametmp,$fname,$fsize,$photocat,$phot odesc);
}
}
if($action=='abort' and $abortlist){
$result = dbget_rset_GetImgDetailedList($abortlist);
while($line=db_fetch_array($result)){
if(!$line[link]){
$file = "$line[id].$line[filetype]";
}else{
$file = $line[link];
}
$file_img = "$site_upload_folder/$file";
$file_thumb = "$site_upload_folder/$thumb_prefix$file";
unlink($file_img);
unlink($file_thumb);
}
db_free_result($result);
dbget_exec_DeleteImgList($abortlist);
}
$resultset = array();
$resultrows = 0;
$result = dbget_rset_AdminShowImages($c,$key,$n,$list_maxsho w,$locked);
while($line=db_fetch_array($result)){
$resultset[$resultrows][id] = $line[id];
$resultset[$resultrows][category] = show_cat($line[category]);
$resultset[$resultrows][description] = substr(show_desc(htmlspecialchars($line[description])),0,30)."..";
$resultset[$resultrows][link] = "$site_upload_folder/$thumb_prefix$line[link]";
$resultset[$resultrows][link] = get_thumb_url($resultset[$resultrows][link],$site_blank_thumb_url);
$resultset[$resultrows][count_vote] = number_format($line[count_vote],0);
$resultset[$resultrows][rating] = number_format($line[rating],3);
$resultset[$resultrows][suspended] = show_yesno($line[suspended]);
$resultrows++;
}
db_free_result($result);
$this_total = dbget_rset_AdminCountImages($c,$locked);
}
dbget_dbclose();
function upload_one($tmp_name,$name,$size,$category,$descri ption,$tmp_name_add=""){
global $IMG_WIDTH, $IMG_HEIGHT, $JPG_QUALITY, $HTTP_SESSION_VARS;
global $use_imagecreatetruecolor, $use_imagecopyresampled;
global $site_upload_folder, $item_criteria, $thumb_prefix, $def_imgtypes;
$type = get_filetype($name);
if(!in_list($def_imgtypes,strtolower($type))) die("Wrong file type");
$uid = $HTTP_SESSION_VARS[uid];
if(!$uid) $uid = 1;
$id = dbget_val_AddNewImage($category,$description,"",$n ame,$size,$type,"1",$uid);
if(!$id) return false;
$name = "$id.$type";
//
//$img_sz = getimagesize($tmp_name);
//resizer_main($tmp_name,$name,$img_sz[0],$img_sz[1],$site_upload_folder,"",$JPG_QUALITY,$use_imagecre atetruecolor,$use_imagecopyresampled);
//
if(!$tmp_name_add){
resizer_main($tmp_name,$name,$IMG_WIDTH,$IMG_HEIGH T,$site_upload_folder,$thumb_prefix,$JPG_QUALITY,$ use_imagecreatetruecolor,$use_imagecopyresampled);
}else{
move_uploaded_file($tmp_name_add,"$site_upload_fol der/$thumb_prefix$name") or die("Upload failed");
}
move_uploaded_file($tmp_name,"$site_upload_folder/$name") or die("Upload failed");
return dbget_exec_EnableImage($id,"0",$name);
}
//
include "tmp.admin.php";

[/PHP]
Jul 18 '07 #1
3 2096
pbmods
5,821 Expert 4TB
Heya, webandwe.

Check out umask().
Jul 18 '07 #2
webandwe
142 100+
Hi, while I was looking at the unmask I got this script from the menu


This script sets all the permssion for all the files, but the problem is this thing check your whole website.

I added

$dir = "http://www.mardo-photo.co.za/photorate/images/";

To make the script just run under /images/ but it still check the whole website,

Can some please tell me how the script is getting to check the whole site and how can I limit the script just to 1 folder?

Thank-you


[PHP]
<?php
$dir = "http://www.mardo-photo.co.za/photorate/images/"; ///I added this **************88
error_reporting(E_ERROR | E_PARSE);
/* Makes is so Directories are not browseable to the public,
removing only the Public = Read permission, while leaving
the other chmod permissions for the file in tact.

If you have exectue already on, and read off, public viewers will only
be able to view files through links, but not browse
around to see what's inside of directories and see what
you've got laying around. */
//-------------------------------------------------------
// Get file mode
// Get file permissions supported by chmod
function getmod($filename) {
$val = 0;
$perms = fileperms($filename);
// Owner; User
$val += (($perms & 0x0100) ? 0x0100 : 0x0000); //Read
$val += (($perms & 0x0080) ? 0x0080 : 0x0000); //Write
$val += (($perms & 0x0040) ? 0x0040 : 0x0000); //Execute

// Group
$val += (($perms & 0x0020) ? 0x0020 : 0x0000); //Read
$val += (($perms & 0x0010) ? 0x0010 : 0x0000); //Write
$val += (($perms & 0x0008) ? 0x0008 : 0x0000); //Execute

// Global; World
$val += (($perms & 0x0004) ? 0x0004 : 0x0000); //Read
$val += (($perms & 0x0002) ? 0x0002 : 0x0000); //Write
$val += (($perms & 0x0001) ? 0x0001 : 0x0000); //Execute

// Misc
$val += (($perms & 0x40000) ? 0x40000 : 0x0000); //temporary file (01000000)
$val += (($perms & 0x80000) ? 0x80000 : 0x0000); //compressed file (02000000)
$val += (($perms & 0x100000) ? 0x100000 : 0x0000); //sparse file (04000000)
$val += (($perms & 0x0800) ? 0x0800 : 0x0000); //Hidden file (setuid bit) (04000)
$val += (($perms & 0x0400) ? 0x0400 : 0x0000); //System file (setgid bit) (02000)
$val += (($perms & 0x0200) ? 0x0200 : 0x0000); //Archive bit (sticky bit) (01000)

return $val;
}

//-------------------------------------------------------
// Find out if file has mode
function hasmod($perms, $permission) {

# User Read = 0400 (256), Write = 0200 (128), Execute = 0100 (64)
# Group Read = 0040 (32), Write = 0020 (16), Execute = 0010 (8)
# Public Read = 0004 (4), Write = 0002 (2), Execute = 0001 (1)

return (($perms & $permission) == $permission);
}

//-------------------------------------------------------
// Take the read option off of all the subdirectories of the included path
function pathlock($dir, $listall = false, $testrun = true) {
echo "START @ " . date("F j, Y, h:i:s A") . "<br><br>";
echo ($testrun ? '**Test Run Activated (no changes will be made).**<br><br>' : '**Live Run Activated.**<br><br>');
echo $dir . " is our directory.<br><br>\n";
echo "[...IN PROGRESS...]<br><br>";

$file_list = '';
$stack[] = $dir;

while ($stack) {
$current_dir = array_pop($stack);
if ($dh = opendir($current_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file !== '.' AND $file !== '..') {
$current_file = "{$current_dir}/{$file}";
if (is_dir($current_file)) {
// BEG ADD PATH
$mode = getmod($current_file); //Get the mode
$HasPubRead = hasmod($mode,4);
if ($HasPubRead || $listall) { // Can the public read this dir?
//======================================
$ch = true;
$take = 0;
// Change the mode:
if ($HasPubRead) {
$take = 4; // Value for Public Read. 4 is the same in octal and decimal.
if (!$testrun) {
$ch = chmod($current_file, $mode-$take);
}
}

echo $current_file . ",current=" . decoct($mode) .
(($mode!==$mode-$take) ? ",new=" . decoct($mode-$take) : '') .
($ch ? '' : ',FAILED') . "<br>\n";
} // end if hasmod
// END ADD PATH
$stack[] = $current_file;
} // if if_dir
} //if ($file !== '.' AND $file !== '..')
} //while (($file = readdir($dh)) !== false)
} //if ($dh = opendir($current_dir))
} // while ($stack)

echo "<br>COMPLETE @ " . date("F j, Y, h:i:s A") . "<br>\n";
return;
//return $path_list;
} // end function

//-------------------------------------------------------
//listall Show all folders, even one's we're not going to process?
//testrun Do a test run without making any changes
pathlock($_SERVER["DOCUMENT_ROOT"],false,true); // listall?=false, testrun?=true

?>
[/PHP]
Jul 20 '07 #3
pbmods
5,821 Expert 4TB
Heya, webandwe.

Check out umask(). Just call it at the start of your routine with the proper value (remember that you must use the OPPOSITE of the permissions that you want.

For more info, check out this article, which also has the value that you are looking for.
Jul 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user...
1
by: Jody Gelowitz | last post by:
Exactly what is the size limit of Isolated Storage in the Internet permission set? I have a document indicating it is 10MB (http://msdn.microsoft.com/msdnmag/issues/02/07/NetSmartClients/) ...
12
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
4
by: Jason | last post by:
After reading Eugene Bobukh's blog entry about creating custom non-CAS permissions, I developed a few custom permissions to satisfy the needs of an application I'm currently working on. For...
6
by: Steve Richter | last post by:
I am getting error in a vbscript: ActiveX component cant create object: Excel.Application. The vbscript code is: Dim objExcel Set objExcel = CreateObject("Excel.Application") I am pretty...
5
by: Simon Hart | last post by:
Does anyone know the standard code access permission to be able to manipulate a process using the Process class? Thanks Simon.
4
by: Richard MSL | last post by:
I have a simple application in C++ that uses a dll I wrote in C#. It works fine when I run it on C: on my local PC, but when I attempt to run it on the i: drive on my LAN, it gets a loading...
1
by: doctorhardik | last post by:
other interesting thing i observe during my work which i describe below: i am using dotproject2.0.4 on fc3. it is working fine. but i want to generate pdf file report during this time i face...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
4
by: xzzy | last post by:
I have a v1.1 web app that works on my local computer. However, running it at the host computer, the following breaks: when a viewer selects a different country, the State dropdown should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.