本文整理汇总了PHP中sanitizeFilename函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitizeFilename函数的具体用法?PHP sanitizeFilename怎么用?PHP sanitizeFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanitizeFilename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deserialize
/**
* Deserialize a JSON string into an object
*
* @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string
* @param string $httpHeaders HTTP headers
* @param string $discriminator discriminator if polymorphism is used
*
* @return object an instance of $class
*/
public static function deserialize($data, $class, $httpHeaders = null, $discriminator = null)
{
if (null === $data) {
return null;
} elseif (substr($class, 0, 4) === 'map[') {
// for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
if (strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass, null, $discriminator);
}
}
return $deserialized;
} elseif (strcasecmp(substr($class, -2), '[]') == 0) {
$subClass = substr($class, 0, -2);
$values = array();
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass, null, $discriminator);
}
return $values;
} elseif ($class === 'object') {
settype($data, 'array');
return $data;
} elseif ($class === '\\DateTime') {
// Some API's return an invalid, empty string as a
// date-time property. DateTime::__construct() will return
// the current time for empty input which is probably not
// what is meant. The invalid empty string is probably to
// be interpreted as a missing field/value. Let's handle
// this graceful.
if (!empty($data)) {
return new \DateTime($data);
} else {
return null;
}
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
settype($data, $class);
return $data;
} elseif ($class === '\\SplFileObject') {
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . sanitizeFilename($match[1]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
if (Configuration::getDefaultConfiguration()->getDebug()) {
error_log("[DEBUG] Written {$byte_written} byte to {$filename}. Please move the file to a proper folder or delete the temp file after processing." . PHP_EOL, 3, Configuration::getDefaultConfiguration()->getDebugFile());
}
return $deserialized;
} else {
// If a discriminator is defined and points to a valid subclass, use it.
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
$subclass = '\\Swagger\\Client\\Model\\' . $data->{$discriminator};
if (is_subclass_of($subclass, $class)) {
$class = $subclass;
}
}
$instance = new $class();
foreach ($instance::swaggerTypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
continue;
}
$propertyValue = $data->{$instance::attributeMap()[$property]};
if (isset($propertyValue)) {
$instance->{$propertySetter}(self::deserialize($propertyValue, $type, null, $discriminator));
}
}
return $instance;
}
}
示例2: sanitizeFilename
<?php
require_once 'peerlib/peerutils.inc';
require_once 'peerlib/imageresize.php';
//
// phpinfo();
//setlocale(LC_CTYPE,'en_US.UTF-8');
//setlocale(LC_ALL,'en_US.UTF-8','en_EN');
//passthru('export LC_CTYPE=en_US.UTF-8;/usr/bin/locale');
echo "<br/>\n";
$testfile = 'part/one(two)[three];four| five';
echo $testfile . "<br/>\n";
echo "result=" . sanitizeFilename($testfile) . "<br/>\n";
$sql = "select upload_id,rel_file_path,mime_type from uploads where prjm_id=385 and mime_type ='image/jpeg'";
$resultSet = $dbConn->Execute($sql);
if ($result !== false) {
while (!$resultSet->EOF) {
extract($resultSet->fields);
$source = $upload_path_prefix . '/' . $rel_file_path;
echo "upload_id={$upload_id} {$mime_type} {$source} <br/>\n";
$resized = imageresize($source);
if ($resized > 0) {
$sql2 = "update uploads set filesize={$resized} where upload_id={$upload_id}";
$dbConn->Execute($sql2);
echo "RESIZED<br/>";
}
$resultSet->moveNext();
}
}
//passthru('/home/hombergp/testsite/peer/locale.sh');
//$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
示例3: deserialize
/**
* Deserialize a JSON string into an object
*
* @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string
* @param string $httpHeaders HTTP headers
*
* @return object an instance of $class
*/
public static function deserialize($data, $class, $httpHeaders = null)
{
if (null === $data) {
$deserialized = null;
} elseif (substr($class, 0, 4) === 'map[') {
// for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
if (strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass);
}
}
} elseif (strcasecmp(substr($class, -2), '[]') == 0) {
$subClass = substr($class, 0, -2);
$values = array();
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass);
}
$deserialized = $values;
} elseif ($class === 'ByteArray') {
// byte array
$deserialized = unpack('C*', (string) $data);
} elseif ($class === '\\DateTime') {
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
settype($data, $class);
$deserialized = $data;
} elseif ($class === '\\SplFileObject') {
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . sanitizeFilename($match[1]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
error_log("[INFO] Written {$byte_written} byte to {$filename}. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
} else {
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
$propertySetter = $instance::$setters[$property];
if (!isset($propertySetter) || !isset($data->{$instance::$attributeMap[$property]})) {
continue;
}
$propertyValue = $data->{$instance::$attributeMap[$property]};
if (isset($propertyValue)) {
$instance->{$propertySetter}(self::deserialize($propertyValue, $type));
}
}
$deserialized = $instance;
}
return $deserialized;
}
示例4: extract
<?php
include_once './peerlib/peerutils.inc';
require_once './peerlib/validators.inc';
require_once 'component.inc';
$debug = false;
$prjtg_id = 1;
extract($_SESSION);
if (isset($_REQUEST['prjtg_id_id'])) {
$class_id = validate($_REQUEST['prjtg_id'], 'integer', $prjtg_id);
}
$sql = "select substr(now()::text,1,16) as ts,rtrim(afko)||'-'||year as project,tutor, coalesce(grp_name,'g'||grp_num) as grp_name\n" . "from all_prj_tutor where prjtg_id={$prjtg_id}";
$resultSet = $dbConn->Execute($sql);
extract($resultSet->fields);
$texdir = $site_home . '/tex/out';
$basename = sanitizeFilename('groupphotolist_' . trim(preg_replace('/\\s+/', '_', $project . '_' . $grp_name)));
$filename = $basename . '.tex';
$pdfname = $basename . '.pdf';
$fp = fopen($texdir . '/' . $filename, "w");
fwrite($fp, "\\documentclass[10pt]{article}\n" . "\\usepackage[utf8]{inputenc}\n" . "\\usepackage[a4paper,scale={0.9,0.88}]{geometry}\n" . "\\usepackage{longtable}\n" . "\\usepackage{times}\n" . "\\usepackage{color}\n" . "\\usepackage{graphicx}\n" . "\\usepackage{colortbl}\n" . "\\usepackage{fancyhdr}\n" . "\\usepackage[pdftex,colorlinks=true,\n pdfstartview=FitV,\n linkcolor=blue,\n citecolor=blue,\n urlcolor=blue,]{hyperref}\n" . "\\setlength\\voffset{.2in}\n" . "\\renewcommand\\footrulewidth{1pt}\n" . "\\newcommand\\tabletail{\\end{longtable}}\n" . "\\renewcommand\\arraystretch{1.2}\n" . "\\def\\mystrut(#1,#2){\\vrule height #1 depth #2 width 0pt}\n" . "\\newcolumntype{C}[1]{%" . " >{\\mystrut(30mm,20mm)\\centering}%\n" . " p{#1}%\n" . " <{}}\n " . "\\newcommand\\tablehead[1]{\n" . "\\begin{longtable}{p{35mm}p{35mm}p{35mm}p{35mm}p{35mm}}%\n" . " \\endhead%\n" . " \\endfoot%\n" . " \\endlastfoot%\n" . "}\n" . " \n" . "\\chead[ {$grp_name} tutor {$tutor} ]{ {$grp_name} tutor {$tutor} }\n" . "\\rhead[produced on " . $ts . "]{produced on " . $ts . "}\n" . "\\lhead[Project {$project}]{Project {$project}}\n" . "\\lfoot[Fontys Venlo \\textbf{peerweb}]{Fontys Venlo \\textbf{peerweb}}\n" . "\\rfoot[\\tiny\\url{https://www.fontysvenlo.org/peerweb/groupphoto.php?prjtg_id={$prjtg_id}}]%\n" . "{\\tiny\\url{https://www.fontysvenlo.org/peerweb/groupphoto.php?prjtg_id={$prjtg_id}}}\n" . "\\begin{document}\n" . "\\pagestyle{fancy}\n" . "\\setlength{\\parindent}{0pt}\n" . "\\setlength{\\parskip}{0pt}\n ");
$sql = "select snummer,roepnaam||coalesce(' '||voorvoegsel||' ',' ')||achternaam as name,\n" . " photo, coalesce(tutor,'---') as slb\n" . " from student s join prj_grp pg using(snummer) natural join portrait p" . " left join tutor t on(s.slb=t.userid) \n" . " where pg.prjtg_id={$prjtg_id}\n" . " order by achternaam,roepnaam\n";
$resultSet = $dbConn->Execute($sql);
if ($debug) {
echo $sql;
}
if (!$resultSet->EOF) {
fwrite($fp, "\\tablehead{" . $grp_name . "}\n");
}
$fotodir = '../../peer/';
$colcount = 0;
$cont = '';
示例5: markload
function markload($img, $upload)
{
function sanitizeFilename($f)
{
$replace_chars = array('Š' => 'S', 'š' => 's', 'Ð' => 'Dj', 'Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'ƒ' => 'f');
$f = strtr($f, $replace_chars);
// convert & to "and", @ to "at", and # to "number"
$f = preg_replace(array('/[\\&]/', '/[\\@]/', '/[\\#]/'), array('-and-', '-at-', '-number-'), $f);
$f = preg_replace('/[^(\\x20-\\x7F)]*/', '', $f);
// removes any special chars we missed
$f = str_replace(' ', '-', $f);
// convert space to hyphen
$f = str_replace('\'', '', $f);
// removes apostrophes
$f = preg_replace('/[^\\w\\-\\.]+/', '', $f);
// remove non-word chars (leaving hyphens and periods)
$f = preg_replace('/[\\-]+/', '-', $f);
// converts groups of hyphens into one
return strtolower($f);
}
global $exp, $rep_exp, $thumb_indicator, $thumb_width, $imgdir;
// replace image by uploaded image if applicable
if ($upload) {
$img = $_FILES['u']['tmp_name'];
}
// create image object
if (exif_imagetype($img) == IMAGETYPE_JPEG) {
$img_el = imagecreatefromjpeg($img);
$ext = '.jpg';
} elseif (exif_imagetype($img) == IMAGETYPE_PNG) {
$img_el = imagecreatefrompng($img);
$ext = '.png';
} elseif (exif_imagetype($img) == IMAGETYPE_GIF) {
$img_el = imagecreatefromgif($img);
$ext = '.gif';
}
// get image dimensions
$img_w = imagesx($img_el);
$img_h = imagesy($img_el);
// get time/date string
$img_date = date(ymdHis);
// get original filename in case file was uploaded
if ($upload) {
// construct file name, removing extension
$img_file = sanitizeFilename(preg_replace('/\\.[^.\\s]{3,4}$/', '', $_FILES['u']['name']));
} else {
$img_file = sanitizeFilename(basename($img));
}
$img_file = str_replace($exp, $rep_exp, $img_file);
// define image name
$img_name = $imgdir . '/' . $img_date . $exp . $img_w . $exp . $img_h . $exp . $img_file;
if ($upload) {
$img_name .= $ext;
}
// copy actual image
copy($img, $img_name);
// create thumbnail
$thumb_height = floor($img_h * ($thumb_width / $img_w));
$thumb_name = $imgdir . '/' . $img_date . $exp . $thumb_indicator . $exp . $img_w . $exp . $img_h . $exp . $img_file;
if ($upload) {
$thumb_name .= $ext;
}
$thumb_image = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($thumb_image, $img_el, 0, 0, 0, 0, $thumb_width, $thumb_height, $img_w, $img_h);
imagejpeg($thumb_image, $thumb_name);
echo json_encode(array('img_name' => $img_name, 'thumb_name' => $thumb_name));
}
示例6: sanitizeFilename
public static function sanitizeFilename($filename)
{
return sanitizeFilename($filename);
}
示例7: coalesce
$sql = "select coalesce(max(vers),0)+1 as vers,version_limit from " . "project_deliverables left join (select vers,doctype,prjm_id from uploads \n" . "where snummer={$snummer} and doctype={$doctype} and prjm_id={$prjm_id}) u\n" . "using (doctype,prjm_id) where doctype={$doctype} and prjm_id={$prjm_id} and version_limit > 0 group by version_limit";
$resultSet = $dbConn->Execute($sql);
$dbConn->log($sql);
if ($resultSet === false) {
die('cannot get version data:' . $dbConn->ErrorMsg() . ' with ' . $sql);
}
if (!$resultSet->EOF) {
$vers = $resultSet->fields['vers'];
$version_limit = $resultSet->fields['version_limit'];
// echo "vers = $vers<br/>\n";
} else {
$vers = 1;
$version_limit = 0;
}
$version_acceptable = $vers <= $version_limit;
$basename = sanitizeFilename($_FILES['userfile']['name']);
$rel_file_dir = $snummer . '/' . $uafko . '_' . $myear . '_M' . $milestone . '/' . $doctype;
if ($vers > 1) {
$filename_pieces = explode('.', $basename);
if (count($filename_pieces) >= 2) {
$filename_pieces[count($filename_pieces) - 2] .= '_V' . $vers;
$basename = implode('.', $filename_pieces);
} else {
$basename .= '_V' . $vers;
}
}
$rel_file_path = $rel_file_dir . '/' . $basename;
$user_upload_dir = $upload_path_prefix . '/' . $rel_file_dir;
$user_upload_path = $user_upload_dir . '/' . $basename;
$file_size = $_FILES['userfile']['size'];
$tmp_file = $_FILES['userfile']['tmp_name'];
示例8: exit
<?php
if (!isset($_REQUEST['acct']) || $_REQUEST['acct'] == '') {
exit(0);
}
$acct = sanitizeFilename($_REQUEST['acct']);
if (isset($_REQUEST['cmd']) && $_REQUEST['cmd'] == 'upload_files') {
if (!empty($_FILES)) {
$dst = "/home/oonline/ftp-dropbox/{$acct}";
// first make our directory
if (!is_dir("{$dst}")) {
mkdir("{$dst}", 0755);
}
$file_name = sanitizeFilename($_FILES["Filedata"]["name"]);
// Check the upload
if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
file_put_contents("{$dst}/{$file_name}.log", "Upload appears to me invalid.", FILE_APPEND);
echo "ERROR: invalid upload";
exit(0);
}
if (!move_uploaded_file($_FILES['Filedata']['tmp_name'], "{$dst}/{$file_name}")) {
file_put_contents("{$dst}/{$file_name}.log", "Error attempting to execute move_uploaded_file().", FILE_APPEND);
echo "ERROR: error in upload";
exit(0);
}
echo '1';
exit;
}
}
echo '0';
// *************************************************************************************
示例9: toHTML
}
$html .= toHTML($newText);
} else {
if ($action == "rename") {
$html = "<form id=\"rename\" method=\"post\" action=\"" . SELF . "\">";
$html .= "<p>Title: <input id=\"title\" type=\"text\" name=\"page\" value=\"" . htmlspecialchars($page) . "\" />";
$html .= "<input id=\"rename\" type=\"submit\" value=\"Rename\">";
$html .= "<input id=\"cancel\" type=\"button\" onclick=\"history.go(-1);\" value=\"Cancel\" />\n";
$html .= "<input type=\"hidden\" name=\"action\" value=\"renamed\" />";
$html .= "<input type=\"hidden\" name=\"prevpage\" value=\"" . htmlspecialchars($page) . "\" />";
$html .= "</p></form>";
} else {
if ($action == "renamed") {
$pp = $_REQUEST['prevpage'];
$pg = $_REQUEST['page'];
$prevpage = sanitizeFilename($pp);
$prevpage = urlencode($prevpage);
$prevfilename = PAGES_PATH . "/{$prevpage}.txt";
if (rename($prevfilename, $filename)) {
// Success. Change links in all pages to point to new page
if ($dh = opendir(PAGES_PATH)) {
while (($file = readdir($dh)) !== false) {
$content = file_get_contents($file);
$pattern = "/\\[\\[" . $pp . "\\]\\]/g";
preg_replace($pattern, "[[{$pg}]]", $content);
file_put_contents($file, $content);
}
}
} else {
$html = "<p class=\"note\">Error renaming file</p>\n";
}
示例10: print_subdomain
/*
Template Name: Dropbox
*/
// added by Ben Kaplan - 10/28/11 - prints out dev or www depending upon environment
$subdomain = print_subdomain();
$a = explode('/', $_SERVER['REQUEST_URI']);
$acct = $a[2];
if ($acct) {
$acct = sanitizeFilename($acct);
}
if ($_REQUEST['submitted'] == '1') {
if ($_REQUEST['comp'] == '') {
$acct = '';
} else {
header('Location: http://' . $subdomain . '.occasionsonline.com/dropbox/' . sanitizeFilename($_REQUEST['comp']));
exit;
}
}
get_header();
?>
<div class="ruled left"><span class="head2 ruled-text-left">FTP Dropbox</span></div>
<?php
if ($acct == '') {
?>
<form method="POST" name="searchform" id="searchform" action="/dropbox/" >
<p>Enter the name of your company and the project name:</p>
<input type="text" class="vendor_txt" value="" name="comp" size="50" />
<p class="oo-color-slate"><i>e.g. ABC Photography, Smith-Jones Atlanta Wedding</i></p>
<input type="hidden" name="submitted" value="1"/>
<p> <br /><input id="vendor_submit" type="submit" value="Proceed to upload..." /></p>
示例11: createPdf
private function createPdf($doc)
{
$pdf = PDF::loadView('pdf.workmethod', compact('doc'));
$file = sanitizeFilename($doc->name) . '-v' . $doc->version . '-ref-' . $doc->id . '.pdf';
$file_path = public_path('filebank/company/' . $doc->for_company_id . '/wms/' . $file);
if (file_exists($file_path)) {
unlink($file_path);
}
$pdf->save($file_path);
return $file;
}
示例12: unlink
{
$value['completeTemp']
}*/
//rename(,"movedContent.xml");
}
//Cleanup
unlink('movedContent.xml');
//Create zip
$zip = new ZipArchive();
$zip->open('createdZIP.zip', ZipArchive::CREATE);
foreach ($documentFilePaths as $file) {
$zip->addFile($file);
}
$zip->close();
//Move zip-archive
$documentFilePaths['zip'] = $meetingFolder . "arsmote." . sanitizeFilename($orgName) . "." . date('Y') . ".zip";
rename('createdZIP.zip', $documentFilePaths['zip']);
/*
//print_r(array_keys(get_defined_vars()));
foreach(get_defined_vars() as $key => $value)
{
if(is_array($value))
{
foreach($value as $key2 => $value2)
{
if(is_array($value2))
{
foreach($value as $key3 => $value3)
{
echo "$key3 = $value3 <br>";
}
示例13: update
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function update(SiteDocRequest $request, $id)
{
$site_id = $request->get('site_id');
$type = $request->get('type');
// Redirect on 'back' button
if ($request->has('back')) {
return view('/site/doc/list', compact('site_id', 'type'));
}
$doc = SiteDoc::findOrFail($id);
// Check authorisation and throw 404 if not
if (!Auth::user()->allowedTo('edit', 'site.doc', $doc)) {
return view('errors/404');
}
// Get Original report filename path
$orig_site = $doc->site_id;
$orig_type = $doc->type;
$orig_reportfile = $doc->reportUrl;
//dd($request->all());
$doc_request = $request->only('name', 'type', 'site_id', 'notes');
$doc->update($doc_request);
// if doc has altered 'site_id' or 'type' move the file to the new file location
if ($doc->type != $orig_type || $doc->site_id != $orig_site) {
// Make directory if non-existant
if (!file_exists(public_path(pathinfo($doc->reportUrl, PATHINFO_DIRNAME)))) {
mkdir(public_path(pathinfo($doc->reportUrl, PATHINFO_DIRNAME), 0755));
}
rename(public_path($orig_reportfile), public_path($doc->reportUrl));
$orig_reportfile = $doc->reportUrl;
}
if ($doc->type == 'RISK') {
$type = 'risk';
}
if ($doc->type == 'HAZ') {
$type = 'hazard';
}
if ($doc->type == 'PLAN') {
$type = 'plan';
}
// Handle attached file
if ($request->hasFile('uploadfile')) {
$file = $request->file('uploadfile');
$path = "filebank/site/" . $doc->site_id . '/' . $type;
$name = sanitizeFilename(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) . '.' . strtolower($file->getClientOriginalExtension());
// Ensure filename is unique by adding counter to similiar filenames
$count = 1;
while (file_exists(public_path("{$path}/{$name}"))) {
$name = $doc->site_id . '-' . sanitizeFilename(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) . '-' . $count++ . '.' . strtolower($file->getClientOriginalExtension());
}
$file->move($path, $name);
$doc->reportfile = $name;
$doc->save();
// Delete previous file
if (file_exists(public_path($orig_reportfile))) {
unlink(public_path($orig_reportfile));
}
}
Toastr::success("Updated document");
return view('site/doc/edit', compact('doc', 'site_id', 'type'));
}
示例14: extract
include_once './peerlib/peerutils.inc';
require_once './peerlib/validators.inc';
require_once 'component.inc';
$debug = false;
$class_id = 1;
extract($_SESSION);
if (isset($_REQUEST['class_id'])) {
$class_id = validate($_REQUEST['class_id'], 'integer', $class_id);
}
$sql = "select substr(now()::text,1,16) as ts,rtrim(sclass) as sclass," . "rtrim(faculty_short) as faculty_short from student_class join faculty using(faculty_id)\n" . "where class_id={$class_id}";
$resultSet = $dbConn->Execute($sql);
extract($resultSet->fields);
$classname = "{$faculty_short}.{$sclass}";
$texdir = $site_home . '/tex/out';
$basename = sanitizeFilename('photolist_' . trim(preg_replace('/\\s+/', '_', $classname)));
$filename = $basename . '.tex';
$pdfname = $basename . '.pdf';
$fp = fopen($texdir . '/' . $filename, "w");
fwrite($fp, "\\documentclass[10pt]{article}\n" . "\\usepackage[utf8]{inputenc}\n" . "\\usepackage[a4paper,scale={0.9,0.88}]{geometry}\n" . "\\usepackage{array}\n" . "\\usepackage{longtable}\n" . "\\usepackage{times}\n" . "\\usepackage{color}\n" . "\\usepackage{graphicx}\n" . "\\usepackage{colortbl}\n" . "\\usepackage{fancyhdr}\n" . "\\usepackage[pdftex,colorlinks=true,\n pdfstartview=FitV,\n linkcolor=blue,\n citecolor=blue,\n urlcolor=blue,]{hyperref}\n" . "\\setlength\\voffset{.2in}\n" . "\\renewcommand\\footrulewidth{1pt}\n" . "\\newcommand\\tabletail{\\end{longtable}}\n" . "\\renewcommand\\arraystretch{1.2}\n" . "\\def\\mystrut(#1,#2){\\vrule height #1 depth #2 width 0pt}\n" . "\\newcolumntype{C}[1]{%" . " >{\\mystrut(30mm,20mm)\\centering}%\n" . " p{#1}%\n" . " <{}}\n " . "\\newcommand\\tablehead[1]{\n" . "\\begin{longtable}{C{35mm}C{35mm}C{35mm}C{35mm}C{35mm}}%\n" . " \\endhead%\n" . " \\endfoot%\n" . " \\endlastfoot%\n" . "}\n" . " \n" . "\\chead[" . $classname . "]{" . $classname . "}\n" . "\\rhead[" . $ts . "]{" . $ts . "}\n" . "\\lhead[Student Class]{student class}\n" . "\\lfoot[Fontys Venlo peerweb]{Fontys Venlo peerweb}\n" . "\\rfoot[\\url{https://www.fontysvenlo.org/peerweb}]{\\url{https://www.fontysvenlo.org/peerweb}}\n" . "\\begin{document}\n" . "\\pagestyle{fancy}\n" . "\\setlength{\\parindent}{0pt}\n" . "\\setlength{\\parskip}{0pt}\n ");
$sql = "select snummer,roepnaam||coalesce(' '||voorvoegsel||' ',' ')||achternaam as name,\n" . " photo, coalesce(tutor,'---') as slb\n" . " from student " . " natural join portrait " . " left join tutor on(slb=userid) \n" . " where class_id={$class_id}\n" . " order by achternaam,roepnaam\n";
$resultSet = $dbConn->Execute($sql);
if ($debug) {
echo $sql;
}
if (!$resultSet->EOF) {
fwrite($fp, "\\tablehead{" . $classname . "}\n");
}
$fotodir = '../../peer/';
$colcount = 0;
$cont = '';
示例15: extract
<?php
include_once './peerlib/peerutils.inc';
require_once './peerlib/validators.inc';
require_once 'component.inc';
$debug = false;
$act_id = 11;
extract($_SESSION);
if (isset($_REQUEST['act_id'])) {
$act_id = validate($_REQUEST['act_id'], 'integer', $act_id);
}
$sql = "select act_id,rtrim(afko) as afko,short,datum,act_type_descr,to_char(start_time,'HH24:MI') as time," . "part from activity natural join activity_type join all_prj_tutor using(prjm_id) where act_id={$act_id}";
$resultSet = $dbConn->Execute($sql);
extract($resultSet->fields);
$texdir = $site_home . '/tex';
$basename = sanitizeFilename('attendancelist_' . trim(preg_replace('/\\s+/', '_', $afko . '_' . $short)) . '_' . $datum . '_' . $time);
$filename = $basename . '.tex';
$pdfname = $basename . '.pdf';
$fp = fopen($texdir . '/' . $filename, "w");
fwrite($fp, "\\documentclass[11pt]{article}\n" . "\\usepackage[utf8]{inputenc}\n" . "\\usepackage[a4paper,scale={0.8,0.85}]{geometry}\n" . "\\usepackage{longtable}\n" . "\\usepackage{times}\n" . "\\usepackage{color}\n" . "\\usepackage{colortbl}\n" . "\\usepackage{fancyhdr}\n" . "\\setlength\\voffset{.25in}\n" . "\\newcommand\\tabletail{\\end{longtable}}\n" . "\\renewcommand\\arraystretch{3}\n" . "\\newcommand\\tablehead[1]{\n" . "\\begin{longtable}{|l|p{35mm}||p{25mm}|p{85mm}|}%\n" . " \\caption{Presence list for class/group #1}\\\\\\hline%\n" . " \\rowcolor[gray]{0.8}\\textbf{class}&\\textbf{name}&\\textbf{Student number}&\\textbf{signature}\\\\\\hline%\n" . " \\endhead%\n" . " \\hline \\multicolumn{4}{r}{\\emph{List for class #1 continued on next page}} \n" . " \\endfoot%\n" . " \\hline \\multicolumn{4}{c}{\\textbf{End of report}}%\n" . " \\endlastfoot%\n" . "}\n" . " \n" . "\\chead[Presence list for {$afko} {$short} on {$datum}, {$time}]" . "{Presence list for {$afko} {$short} on {$datum}, {$time}}\n" . "\\rfoot[Presence list for activity {$act_id}.]" . "{Presence list for activity {$act_id}}\n" . "" . "\\begin{document}\n" . "\\pagestyle{fancy}\n");
$sql = "select coalesce(grp_name,'g'||grp_num) as sgroup,tutor,apt.grp_num,\n" . " achternaam||', '||roepnaam||coalesce(' '||voorvoegsel,'') as name, reason," . " case when reason notnull then 'excused' else null end as check" . " from prj_grp pg join all_prj_tutor apt using(prjtg_id)\n" . " join activity a using(prjm_id) \n" . " join student st using(snummer) \n" . " left join absence_reason using(act_id,snummer)\n" . " where act_id={$act_id}\n" . " order by grp_num,achternaam,roepnaam\n";
$resultSet = $dbConn->Execute($sql);
if ($debug) {
echo $sql;
}
if (!$resultSet->EOF) {
$oldSgroup = $resultSet->fields['sgroup'];
$tutor = $resultSet->fields['tutor'];
fwrite($fp, "\\tablehead{" . $oldSgroup . '/' . $tutor . "}\n");
}
while (!$resultSet->EOF) {