function chmod_r($dir, $dirPermissions, $filePermissions) { $dp = opendir($dir); $res = true; while ($file = readdir($dp)) { if ($file == "." || $file == "..") { continue; } $fullPath = $dir . "/" . $file; if (is_dir($fullPath)) { if ($res = @chmod($fullPath, $dirPermissions)) { $res = @chmod_r($fullPath, $dirPermissions, $filePermissions); } } else { $res = chmod($fullPath, $filePermissions); } if (!$res) { closedir($dp); return false; } } closedir($dp); if (is_dir($dir) && $res) { $res = @chmod($dir, $dirPermissions); } return $res; }
function chmod_r($path, $filemode) { if (!is_dir($path)) { return chmod($path, $filemode); } $dh = opendir($path); while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $fullpath = $path . '/' . $file; if (is_link($fullpath)) { return FALSE; } elseif (!is_dir($fullpath)) { if (!chmod($fullpath, $filemode)) { return FALSE; } elseif (!chmod_r($fullpath, $filemode)) { return FALSE; } } } } closedir($dh); if (chmod($path, $filemode)) { return TRUE; } else { return FALSE; } }
$autoinstallupgrade = 0; // keep this here for a bit, just incase $userid = get_userid(); $access = check_permission($userid, "Modify Modules"); /*if (!$access) { die('Permission Denied'); return; }*/ $smarty = new Smarty_CMS($gCms->config); $db =& $gCms->GetDb(); //Messagestring (success) for module operations $modulemessage = ""; include_once "header.php"; if ($access) { if ($action == "chmod") { $result = chmod_r($config['root_path'] . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $module, 0777); if (!$result) { echo $themeObject->ShowErrors(lang('cantchmodfiles')); } else { redirect($thisurl); } } if ($action == "exportxml") { // get our xml $message = ''; $files = 0; $modops =& $gCms->GetModuleOperations(); $object = $gCms->modules[$module]['object']; $xmltxt = $modops->CreateXMLPackage($object, $message, $files); if ($files == 0) { echo "<p class=\"error\">" . lang('errornofilesexported') . "</p>";
function chmod_r($path, $modes) { $dir = new DirectoryIterator($path); foreach ($dir as $item) { if ($item->isDir() && !$item->isDot()) { @chmod($item->getPathname(), $modes["dir"]); chmod_r($item->getPathname(), $modes); } else { @chmod($item->getPathname(), $modes["file"]); } } }
/** * Extract ZIP File */ function extractZip($zipPath, $extractTo, $appendPath = '', $perm = 0755) { $zip = new ZipArchive(); if ($zip->open($zipPath) === TRUE) { $zip->extractTo($extractTo); $zip->close(); chmod_r($extractTo . $appendPath, $perm, $perm); return true; } return false; }
/** * A function to recursively chmod all files and folders in a directory * * @see chmod * @param string The start location * @param integer The mode * Rolf: only used in admin/listmodules.php */ function chmod_r($path, $mode) { if (!is_dir($path)) { return chmod($path, $mode); } $dh = @opendir($path); if (!$dh) { return FALSE; } while ($file = readdir($dh)) { if ($file == '.' || $file == '..') { continue; } $p = $path . DIRECTORY_SEPARATOR . $file; if (is_dir($p)) { if (!@chmod_r($p, $mode)) { closedir($dh); return false; } } else { if (!is_link($p)) { if (!@chmod($p, $mode)) { closedir($dh); return false; } } } } @closedir($dh); return @chmod($path, $mode); }
$ticket = sanitize($_GET['ticket']); $filesize = filesize($uploadDirectory . $filename . '.' . $ext); //insert the attachment, remember at this point we don't have ref_id though. only uploaded it $qry = "INSERT INTO ost_ticket_attachment(attach_id,ticket_id,ref_id,ref_type,file_size,file_name,file_key,deleted,created) VALUES('" . $attach_id . "','" . $ticket . "','222','M','" . $filesize . "','" . ($fn . "." . $ext) . "','" . $r . "','0',NOW())"; $res = mysql_query($qry); mysql_close($link); //------------------- return array('success' => true, 'attach_id' => $attach_id); } else { return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered'); } } } // list of valid extensions, ex. array("jpeg", "xml", "bmp") $allowedExtensions = array(); // max file size in bytes $sizeLimit = 7 * 1024 * 1024; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); // new stuff for BugBase $updated_path = ALT_ATTACHMENTS . "/" . date('my'); //month year; chmod_r($updated_path . "/", 0744, 0744); //make sure no one can view, only download through download.php if (!file_exists($updated_path)) { mkdir($updated_path); } $updated_path = $updated_path . "/"; //--------------------- $result = $uploader->handleUpload($updated_path); // to pass data through iframe you will need to encode all html tags echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);