From 351ace3031cf063cef346027ae209d218225242a Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Tue, 24 Mar 2020 15:53:18 +0100 Subject: Rev: 4632 --- mayor-orig/mayor-base/log/mayor-base.rev | 2 +- .../mayor-base/www/include/share/net/upload.php | 262 ++++++++++++++++++++- .../www/policy/parent/session/download-pre.php | 1 + .../www/policy/parent/session/download.php | 1 + .../www/policy/private/session/download-pre.php | 2 +- mayor-orig/mayor-felveteli/log/mayor-felveteli.rev | 2 +- mayor-orig/mayor-fenntarto/log/mayor-fenntarto.rev | 2 +- .../mayor-installer-orig/log/mayor-installer.rev | 2 +- .../log/mayor-installer-sulix.rev | 2 +- mayor-orig/mayor-jatek/log/mayor-jatek.rev | 2 +- .../log/mayor-locales-de_DE.rev | 2 +- .../log/mayor-locales-en_US.rev | 2 +- .../log/mayor-locales-jp_JP.rev | 2 +- .../install/module-naplo/mysql/tanev.sql | 2 + mayor-orig/mayor-naplo/log/mayor-naplo.rev | 2 +- .../mayor-naplo/update/pre004630-1-naplo.sql | 26 ++ mayor-orig/mayor-naplo/update/pre004630-2.sh | 17 ++ .../hu_HU/module-naplo/haladasi/hazifeladat.php | 2 +- .../private/naplo/haladasi/hazifeladat-pre.php | 75 +++++- .../module-naplo/css/haladasi/hazifeladat.css | 34 ++- .../module-naplo/html/haladasi/hazifeladat.phtml | 109 +++++++-- mayor-orig/mayor-portal/log/mayor-portal.rev | 2 +- mayor-orig/mayor-wiki/log/mayor-wiki.rev | 2 +- mayor-orig/md5sum | 26 +- mayor-orig/rev.txt | 2 +- rev.txt | 2 +- 26 files changed, 526 insertions(+), 59 deletions(-) create mode 120000 mayor-orig/mayor-base/www/policy/parent/session/download-pre.php create mode 120000 mayor-orig/mayor-base/www/policy/parent/session/download.php create mode 100644 mayor-orig/mayor-naplo/update/pre004630-1-naplo.sql create mode 100644 mayor-orig/mayor-naplo/update/pre004630-2.sh diff --git a/mayor-orig/mayor-base/log/mayor-base.rev b/mayor-orig/mayor-base/log/mayor-base.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-base/log/mayor-base.rev +++ b/mayor-orig/mayor-base/log/mayor-base.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-base/www/include/share/net/upload.php b/mayor-orig/mayor-base/www/include/share/net/upload.php index bbc90db8..7181c94e 100644 --- a/mayor-orig/mayor-base/www/include/share/net/upload.php +++ b/mayor-orig/mayor-base/www/include/share/net/upload.php @@ -1,6 +1,6 @@ 1000000) { + if ($_FILES['upfile']['size'] > file_upload_max_size()) { throw new RuntimeException('Túl nagy a file!'); } $finfo = new finfo(FILEINFO_MIME_TYPE); + + if ($csakKep===true) { if (false === $ext = array_search( $finfo->file($_FILES['upfile']['tmp_name']), array( @@ -43,16 +45,268 @@ try { )) { throw new RuntimeException('Nem kép!'); } - + } // You should name it uniquely. // DO NOT USE $_FILES['upfile']['name'] WITHOUT ANY VALIDATION !! // On this example, obtain safe unique name from its binary data. - if (!move_uploaded_file($_FILES['upfile']['tmp_name'],$WHERE['subdir'].'/'.$WHERE['filename'])) { + if (!move_uploaded_file($_FILES['upfile']['tmp_name'],$ADAT['subdir'].'/'.$ADAT['filename'])) { throw new RuntimeException('Nem tudtuk átmozgatni. Van jogunk írni a célkönyvtárba?'); } } catch (RuntimeException $e) { $_SESSION['alert'][] = 'info::'.$e->getMessage(); } + return true; + +} + +function file_upload_max_size() { + static $max_size = -1; + + if ($max_size < 0) { + $post_max_size = parse_size(ini_get('post_max_size')); + if ($post_max_size > 0) { + $max_size = $post_max_size; + } + $upload_max = parse_size(ini_get('upload_max_filesize')); + if ($upload_max > 0 && $upload_max < $max_size) { + $max_size = $upload_max; + } + } + return $max_size; +} + +function parse_size($size) { + $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); + $size = preg_replace('/[^0-9\.]/', '', $size); + if ($unit) { + return round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))); + } + else { + return round($size); + } +} + +function human_filesize($bytes, $dec = 2) +{ + $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); + $factor = floor((strlen($bytes) - 1) / 3); + return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . @$size[$factor]; +} + +function filename2ext($filename) { + $ext = end(explode('.', $filename)); + $ext = substr(strrchr($filename, '.'), 1); + $ext = substr($filename, strrpos($filename, '.') + 1); + $ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename); + $exts = split("[/\\.]", $filename); + $n = count($exts)-1; + $ext = $exts[$n]; + return $ext; +} + +function filemime2ext($mime) { + $mime_map = [ + 'video/3gpp2' => '3g2', + 'video/3gp' => '3gp', + 'video/3gpp' => '3gp', + 'application/x-compressed' => '7zip', + 'audio/x-acc' => 'aac', + 'audio/ac3' => 'ac3', + 'application/postscript' => 'ai', + 'audio/x-aiff' => 'aif', + 'audio/aiff' => 'aif', + 'audio/x-au' => 'au', + 'video/x-msvideo' => 'avi', + 'video/msvideo' => 'avi', + 'video/avi' => 'avi', + 'application/x-troff-msvideo' => 'avi', + 'application/macbinary' => 'bin', + 'application/mac-binary' => 'bin', + 'application/x-binary' => 'bin', + 'application/x-macbinary' => 'bin', + 'image/bmp' => 'bmp', + 'image/x-bmp' => 'bmp', + 'image/x-bitmap' => 'bmp', + 'image/x-xbitmap' => 'bmp', + 'image/x-win-bitmap' => 'bmp', + 'image/x-windows-bmp' => 'bmp', + 'image/ms-bmp' => 'bmp', + 'image/x-ms-bmp' => 'bmp', + 'application/bmp' => 'bmp', + 'application/x-bmp' => 'bmp', + 'application/x-win-bitmap' => 'bmp', + 'application/cdr' => 'cdr', + 'application/coreldraw' => 'cdr', + 'application/x-cdr' => 'cdr', + 'application/x-coreldraw' => 'cdr', + 'image/cdr' => 'cdr', + 'image/x-cdr' => 'cdr', + 'zz-application/zz-winassoc-cdr' => 'cdr', + 'application/mac-compactpro' => 'cpt', + 'application/pkix-crl' => 'crl', + 'application/pkcs-crl' => 'crl', + 'application/x-x509-ca-cert' => 'crt', + 'application/pkix-cert' => 'crt', + 'text/css' => 'css', + 'text/x-comma-separated-values' => 'csv', + 'text/comma-separated-values' => 'csv', + 'application/vnd.msexcel' => 'csv', + 'application/x-director' => 'dcr', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', + 'application/x-dvi' => 'dvi', + 'message/rfc822' => 'eml', + 'application/x-msdownload' => 'exe', + 'video/x-f4v' => 'f4v', + 'audio/x-flac' => 'flac', + 'video/x-flv' => 'flv', + 'image/gif' => 'gif', + 'application/gpg-keys' => 'gpg', + 'application/x-gtar' => 'gtar', + 'application/x-gzip' => 'gzip', + 'application/mac-binhex40' => 'hqx', + 'application/mac-binhex' => 'hqx', + 'application/x-binhex40' => 'hqx', + 'application/x-mac-binhex40' => 'hqx', + 'text/html' => 'html', + 'image/x-icon' => 'ico', + 'image/x-ico' => 'ico', + 'image/vnd.microsoft.icon' => 'ico', + 'text/calendar' => 'ics', + 'application/java-archive' => 'jar', + 'application/x-java-application' => 'jar', + 'application/x-jar' => 'jar', + 'image/jp2' => 'jp2', + 'video/mj2' => 'jp2', + 'image/jpx' => 'jp2', + 'image/jpm' => 'jp2', + 'image/jpeg' => 'jpeg', + 'image/pjpeg' => 'jpeg', + 'application/x-javascript' => 'js', + 'application/json' => 'json', + 'text/json' => 'json', + 'application/vnd.google-earth.kml+xml' => 'kml', + 'application/vnd.google-earth.kmz' => 'kmz', + 'text/x-log' => 'log', + 'audio/x-m4a' => 'm4a', + 'audio/mp4' => 'm4a', + 'application/vnd.mpegurl' => 'm4u', + 'audio/midi' => 'mid', + 'application/vnd.mif' => 'mif', + 'video/quicktime' => 'mov', + 'video/x-sgi-movie' => 'movie', + 'audio/mpeg' => 'mp3', + 'audio/mpg' => 'mp3', + 'audio/mpeg3' => 'mp3', + 'audio/mp3' => 'mp3', + 'video/mp4' => 'mp4', + 'video/mpeg' => 'mpeg', + 'application/oda' => 'oda', + 'audio/ogg' => 'ogg', + 'video/ogg' => 'ogg', + 'application/ogg' => 'ogg', + 'application/x-pkcs10' => 'p10', + 'application/pkcs10' => 'p10', + 'application/x-pkcs12' => 'p12', + 'application/x-pkcs7-signature' => 'p7a', + 'application/pkcs7-mime' => 'p7c', + 'application/x-pkcs7-mime' => 'p7c', + 'application/x-pkcs7-certreqresp' => 'p7r', + 'application/pkcs7-signature' => 'p7s', + 'application/pdf' => 'pdf', + 'application/octet-stream' => 'pdf', + 'application/x-x509-user-cert' => 'pem', + 'application/x-pem-file' => 'pem', + 'application/pgp' => 'pgp', + 'application/x-httpd-php' => 'php', + 'application/php' => 'php', + 'application/x-php' => 'php', + 'text/php' => 'php', + 'text/x-php' => 'php', + 'application/x-httpd-php-source' => 'php', + 'image/png' => 'png', + 'image/x-png' => 'png', + 'application/powerpoint' => 'ppt', + 'application/vnd.ms-powerpoint' => 'ppt', + 'application/vnd.ms-office' => 'ppt', + 'application/msword' => 'ppt', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', + 'application/x-photoshop' => 'psd', + 'image/vnd.adobe.photoshop' => 'psd', + 'audio/x-realaudio' => 'ra', + 'audio/x-pn-realaudio' => 'ram', + 'application/x-rar' => 'rar', + 'application/rar' => 'rar', + 'application/x-rar-compressed' => 'rar', + 'audio/x-pn-realaudio-plugin' => 'rpm', + 'application/x-pkcs7' => 'rsa', + 'text/rtf' => 'rtf', + 'text/richtext' => 'rtx', + 'video/vnd.rn-realvideo' => 'rv', + 'application/x-stuffit' => 'sit', + 'application/smil' => 'smil', + 'text/srt' => 'srt', + 'image/svg+xml' => 'svg', + 'application/x-shockwave-flash' => 'swf', + 'application/x-tar' => 'tar', + 'application/x-gzip-compressed' => 'tgz', + 'image/tiff' => 'tiff', + 'text/plain' => 'txt', + 'text/x-vcard' => 'vcf', + 'application/videolan' => 'vlc', + 'text/vtt' => 'vtt', + 'audio/x-wav' => 'wav', + 'audio/wave' => 'wav', + 'audio/wav' => 'wav', + 'application/wbxml' => 'wbxml', + 'video/webm' => 'webm', + 'image/webp' => 'webp', + 'audio/x-ms-wma' => 'wma', + 'application/wmlc' => 'wmlc', + 'video/x-ms-wmv' => 'wmv', + 'video/x-ms-asf' => 'wmv', + 'application/xhtml+xml' => 'xhtml', + 'application/excel' => 'xl', + 'application/msexcel' => 'xls', + 'application/x-msexcel' => 'xls', + 'application/x-ms-excel' => 'xls', + 'application/x-excel' => 'xls', + 'application/x-dos_ms_excel' => 'xls', + 'application/xls' => 'xls', + 'application/x-xls' => 'xls', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', + 'application/vnd.ms-excel' => 'xlsx', + 'application/xml' => 'xml', + 'text/xml' => 'xml', + 'text/xsl' => 'xsl', + 'application/xspf+xml' => 'xspf', + 'application/x-compress' => 'z', + 'application/x-zip' => 'zip', + 'application/zip' => 'zip', + 'application/x-zip-compressed' => 'zip', + 'application/s-compressed' => 'zip', + 'multipart/x-zip' => 'zip', + 'text/x-scriptzsh' => 'zsh', + ]; + + return isset($mime_map[$mime]) ? $mime_map[$mime] : false; +} + +// --TODO not used +/* +function filenameNorm ($str = '') +{ + $str = strip_tags($str); + $str = preg_replace('/[\r\n\t ]+/', ' ', $str); + $str = preg_replace('/[\"\*\/\:\<\>\?\'\|]+/', ' ', $str); + $str = strtolower($str); + $str = html_entity_decode( $str, ENT_QUOTES, "utf-8" ); + $str = htmlentities($str, ENT_QUOTES, "utf-8"); + $str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str); + $str = str_replace(' ', '-', $str); + $str = rawurlencode($str); + $str = str_replace('%', '-', $str); + return $str; } +*/ ?> \ No newline at end of file diff --git a/mayor-orig/mayor-base/www/policy/parent/session/download-pre.php b/mayor-orig/mayor-base/www/policy/parent/session/download-pre.php new file mode 120000 index 00000000..2b5f8422 --- /dev/null +++ b/mayor-orig/mayor-base/www/policy/parent/session/download-pre.php @@ -0,0 +1 @@ +../../private/session/download-pre.php \ No newline at end of file diff --git a/mayor-orig/mayor-base/www/policy/parent/session/download.php b/mayor-orig/mayor-base/www/policy/parent/session/download.php new file mode 120000 index 00000000..2cff0143 --- /dev/null +++ b/mayor-orig/mayor-base/www/policy/parent/session/download.php @@ -0,0 +1 @@ +../../private/session/download.php \ No newline at end of file diff --git a/mayor-orig/mayor-base/www/policy/private/session/download-pre.php b/mayor-orig/mayor-base/www/policy/private/session/download-pre.php index 6b396143..1fdd916f 100644 --- a/mayor-orig/mayor-base/www/policy/private/session/download-pre.php +++ b/mayor-orig/mayor-base/www/policy/private/session/download-pre.php @@ -26,7 +26,7 @@ // Jogosultságok ellenőzése dir alapján if (__DIAK===true) { - if (strstr($dir,'naplo/face/')===false) return false; + if (strstr($dir,'naplo/face/')===false && strstr($dir,'naplo/haladasi/hazifeladat')===false) return false; } // Titkarsag, Tanar, Naploadmin letoltheti, amit szeretne diff --git a/mayor-orig/mayor-felveteli/log/mayor-felveteli.rev b/mayor-orig/mayor-felveteli/log/mayor-felveteli.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-felveteli/log/mayor-felveteli.rev +++ b/mayor-orig/mayor-felveteli/log/mayor-felveteli.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-fenntarto/log/mayor-fenntarto.rev b/mayor-orig/mayor-fenntarto/log/mayor-fenntarto.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-fenntarto/log/mayor-fenntarto.rev +++ b/mayor-orig/mayor-fenntarto/log/mayor-fenntarto.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-installer-orig/log/mayor-installer.rev b/mayor-orig/mayor-installer-orig/log/mayor-installer.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-installer-orig/log/mayor-installer.rev +++ b/mayor-orig/mayor-installer-orig/log/mayor-installer.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-installer-sulix/log/mayor-installer-sulix.rev b/mayor-orig/mayor-installer-sulix/log/mayor-installer-sulix.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-installer-sulix/log/mayor-installer-sulix.rev +++ b/mayor-orig/mayor-installer-sulix/log/mayor-installer-sulix.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-jatek/log/mayor-jatek.rev b/mayor-orig/mayor-jatek/log/mayor-jatek.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-jatek/log/mayor-jatek.rev +++ b/mayor-orig/mayor-jatek/log/mayor-jatek.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-locales-de_DE/log/mayor-locales-de_DE.rev b/mayor-orig/mayor-locales-de_DE/log/mayor-locales-de_DE.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-locales-de_DE/log/mayor-locales-de_DE.rev +++ b/mayor-orig/mayor-locales-de_DE/log/mayor-locales-de_DE.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-locales-en_US/log/mayor-locales-en_US.rev b/mayor-orig/mayor-locales-en_US/log/mayor-locales-en_US.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-locales-en_US/log/mayor-locales-en_US.rev +++ b/mayor-orig/mayor-locales-en_US/log/mayor-locales-en_US.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-locales-jp_JP/log/mayor-locales-jp_JP.rev b/mayor-orig/mayor-locales-jp_JP/log/mayor-locales-jp_JP.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-locales-jp_JP/log/mayor-locales-jp_JP.rev +++ b/mayor-orig/mayor-locales-jp_JP/log/mayor-locales-jp_JP.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-naplo/install/module-naplo/mysql/tanev.sql b/mayor-orig/mayor-naplo/install/module-naplo/mysql/tanev.sql index 59ee0c39..65b3a584 100644 --- a/mayor-orig/mayor-naplo/install/module-naplo/mysql/tanev.sql +++ b/mayor-orig/mayor-naplo/install/module-naplo/mysql/tanev.sql @@ -159,6 +159,8 @@ CREATE TABLE `oraHazifeladatDiak` ( `tanarLattamDt` datetime DEFAULT NULL, `hazifeladatDiakStatus` enum('','kész') COLLATE utf8_hungarian_ci DEFAULT '', `hazifeladatDiakMegjegyzes` varchar(255) COLLATE utf8_hungarian_ci NOT NULL, + `hazifeladatDiakFilename` varchar(255) COLLATE utf8_hungarian_ci DEFAULT NULL, + `hazifeladatDiakOrigFilename` varchar(255) COLLATE utf8_hungarian_ci DEFAULT NULL, PRIMARY KEY (`hazifeladatId`,`diakId`), UNIQUE KEY `oraHazifeladatDiak_UK` (`hazifeladatId`,`diakId`), KEY `oraHazifeladatDiak_ibfk_2` (`diakId`), diff --git a/mayor-orig/mayor-naplo/log/mayor-naplo.rev b/mayor-orig/mayor-naplo/log/mayor-naplo.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-naplo/log/mayor-naplo.rev +++ b/mayor-orig/mayor-naplo/log/mayor-naplo.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-naplo/update/pre004630-1-naplo.sql b/mayor-orig/mayor-naplo/update/pre004630-1-naplo.sql new file mode 100644 index 00000000..1d9798ae --- /dev/null +++ b/mayor-orig/mayor-naplo/update/pre004630-1-naplo.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +DROP PROCEDURE IF EXISTS upgrade_database_4630 $$ + +CREATE PROCEDURE upgrade_database_4630() +BEGIN +SET NAMES utf8 COLLATE utf8_hungarian_ci; + +IF NOT EXISTS ( + SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() and TABLE_NAME='oraHazifeladatDiak' and COLUMN_NAME='hazifeladatDiakFilename' +) THEN + +ALTER TABLE `oraHazifeladatDiak` ADD `hazifeladatDiakFilename` varchar(255) COLLATE utf8_hungarian_ci DEFAULT NULL; + +END IF; + +IF NOT EXISTS ( + SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() and TABLE_NAME='oraHazifeladatDiak' and COLUMN_NAME='hazifeladatDiakOrigFilename' +) THEN + +ALTER TABLE `oraHazifeladatDiak` ADD `hazifeladatDiakOrigFilename` varchar(255) COLLATE utf8_hungarian_ci DEFAULT NULL; + +END IF; + +END $$ +DELIMITER ; +CALL upgrade_database_4630(); diff --git a/mayor-orig/mayor-naplo/update/pre004630-2.sh b/mayor-orig/mayor-naplo/update/pre004630-2.sh new file mode 100644 index 00000000..4ba7e643 --- /dev/null +++ b/mayor-orig/mayor-naplo/update/pre004630-2.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +#BASEDIR="/var/mayor" + +DIR="$BASEDIR/download/parent/naplo/haladasi/" +mkdir -p $DIR +chown -R www-data $DIR +echo "$DIR Kész." + +DIR="$BASEDIR/download/private/naplo/haladasi/hazifeladat" +mkdir -p $DIR +chown -R www-data $DIR +echo "$DIR Kész." + +LNDIR="$BASEDIR/download/parent/naplo/haladasi/" +ln -s $DIR $LNDIR +echo "$LNDIR Kész." diff --git a/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php b/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php index 6799d19e..c9767f65 100644 --- a/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php +++ b/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php @@ -37,5 +37,5 @@ define('_ALAPADATOK','Óra adatok'); define('_HAZIFELADAT','Házi feladat, Részletek, Referenciák, Hivatkozások'); - + define('_HAZIFELTOLTES','Házi feltöltés (max. 1 file)'); ?> diff --git a/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php b/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php index 28a02d5a..d0f4cb6b 100644 --- a/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php +++ b/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php @@ -18,12 +18,36 @@ require_once('include/modules/naplo/share/hetes.php'); require_once('include/modules/naplo/share/helyettesitesModifier.php'); require_once('include/modules/naplo/share/file.php'); + require_once('include/share/net/upload.php'); require_once('include/share/date/names.php'); +// config + define('FILE_UPLOAD_DIR',_DOWNLOADDIR.'/private/naplo/haladasi/hazifeladat/'); + $config['lowfreespacelimit'] = 335617790; // 330MB +/* + dump(disk_free_space($config['dir'])); + dump($file_uploads = ini_get('file_uploads')); // must be On + dump($post_max_size = ini_get('post_max_size')); // recommended: 64M + dump($upload_max_filesize = ini_get('upload_max_filesize')); // recommended: 60M + dump(human_filesize(file_upload_max_size())); +*/ + + if (disk_free_space(FILE_UPLOAD_DIR)<$config['lowfreespacelimit']) { + $disableUpload = true; + if (__NAPLOADMIN === true) $_SESSION['alert'][] = 'info:nincs elég szabad hely, ezért nem tudsz filet feltölteni'; + } + if (!ini_get('file_uploads')) { + $disableUpload = true; + if (__NAPLOADMIN === true) $_SESSION['alert'][] = 'info:feltöltés kikapcsolva (file_uploads)'; + } + if ($disableUpload===true) define('FILE_UPLOAD_ENABLED',false); + else define('FILE_UPLOAD_ENABLED',true); +// -- + $ADAT['oraId' ] = $oraId = readVariable($_POST['oraId'],'id',readVariable($_GET['oraId'],'id')); // $ADAT['hazifeladatId' ] = $hazifeladatId = readVariable($_POST['hazifeladatId'],'id', readVariable($_GET['hazifeladatId'],'id')); $ADAT['hazifeladatLeiras' ] = readVariable($_POST['hazifeladatLeiras'],'string'); - $action = readVariable($_POST['action'],'strictstring',null,array('hazifeladatBeiras','hazifeladatKesz')); + $action = readVariable($_POST['action'],'strictstring',null,array('hazifeladatBeiras','hazifeladatKesz','hazifeladatFeltoltes','lattam')); $q = "SELECT hazifeladatId FROM oraHazifeladat WHERE oraId=%u"; $values = array($ADAT['oraId']); @@ -46,12 +70,24 @@ $leiras = readVariable($_POST['oraLeiras'],'string'); updateHaladasiNaploOra($oraId, $leiras); } + } elseif (__TANAR===true && $action=='lattam') { + $lattamDiakIds = readVariable($_POST['lattam'],'id'); + $q = "UPDATE oraHazifeladatDiak SET tanarLattamDt=null WHERE hazifeladatId=%u"; + $values = array($ADAT['hazifeladatId'], $_diakId); + db_query($q, array('modul'=>'naplo','result'=>'update','values'=>$values)); + for ($i=0; $i'naplo','result'=>'update','values'=>$values)); + } } elseif (__DIAK===true) { if (defined('__USERDIAKID') && __USERDIAKID>0) { $diakId=__USERDIAKID; } elseif (defined('__SZULODIAKID') && __SZULODIAKID>0) { $diakId=__SZULODIAKID; } + if ($diakId>0) { $q = "INSERT IGNORE INTO oraHazifeladatDiak (hazifeladatId,diakId,diakLattamDt) VALUES (%u,%u,NOW())"; $values = array($ADAT['hazifeladatId'], $diakId); @@ -64,6 +100,41 @@ db_query($q, array('modul'=>'naplo','result'=>'update','values'=>$values)); } } + + if (FILE_UPLOAD_ENABLED===true && $action=='hazifeladatFeltoltes') { + if (is_array($_FILES) && $_FILES['upfile']['name']!='') { + $FILEADAT['subdir'] = FILE_UPLOAD_DIR; + $ext = filename2ext($_FILES['upfile']['name']); + $ext2 = filemime2ext($_FILES['upfile']['type']); + if ($ext != $ext2) { + // $_SESSION['alert'][] = 'info:file_mime_type_extension_mismatch:'.$ext.':'.$ext2; + if ($ext2!='') $ext = $ext2; + } + $FILEADAT['filename'] = $hazifeladatId.'_'.$diakId.'_'.uniqid().'.'.$ext; + try { + $sikeresFeltoltes = mayorFileUpload($FILEADAT, false); + } catch (Exception $e) { + dump($e); + } + + if ($sikeresFeltoltes===true) { + // --todo unlink existing?-- + + $q = "SELECT hazifeladatDiakFilename FROM oraHazifeladatDiak WHERE hazifeladatId=%u AND diakId=%u"; + $values = array($ADAT['hazifeladatId'],$diakId); + $oldFilename = db_query($q, array('modul'=>'naplo','result'=>'value','values'=>$values)); + + if (file_exists(FILE_UPLOAD_DIR.$oldFilename)) unlink(FILE_UPLOAD_DIR.$oldFilename); + + $origFilename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $_FILES['upfile']['name']); + $origFilename = mb_ereg_replace("([\.]{2,})", '', $_FILES['upfile']['name']); + if ($origFilename=='') $origFilename = $FILEADAT['filename']; + $q = "UPDATE oraHazifeladatDiak SET hazifeladatDiakFilename='%s',hazifeladatDiakOrigFilename='%s' WHERE hazifeladatId=%u AND diakId=%u"; + $values = array($FILEADAT['filename'],$origFilename,$ADAT['hazifeladatId'], $diakId); + db_query($q, array('modul'=>'naplo','result'=>'update','values'=>$values)); + } + } + } $q = "SELECT * FROM oraHazifeladatDiak WHERE hazifeladatId=%u AND diakId=%u"; $values = array($ADAT['hazifeladatId'],$diakId); $ADAT['hazifeladatDiak'] = db_query($q, array('modul'=>'naplo','result'=>'record','values'=>$values)); @@ -78,7 +149,7 @@ if (__TANAR===true || __NAPLOADMIN===true || __VEZETOSEG===true) { $q = "SELECT *,getNev(diakId,'diak') AS diakNev FROM oraHazifeladatDiak WHERE hazifeladatId=%u ORDER BY diakNev"; $values = array($ADAT['hazifeladatId']); - $ADAT['hazifeladatDiak'] = db_query($q, array('debug'=>true,'modul'=>'naplo','result'=>'indexed','values'=>$values)); + $ADAT['hazifeladatDiak'] = db_query($q, array('debug'=>false,'modul'=>'naplo','result'=>'indexed','values'=>$values)); } $ADAT['oraAdat'] = getOraadatById($oraId); diff --git a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css index 1cce1e3e..1169d008 100644 --- a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css +++ b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css @@ -13,7 +13,6 @@ } form button.btnHfStatusz span { color:#eee; } form button.btnHfStatusz.kesz span { color: lightgreen; } - form button.btnHfStatusz:hover { background-color:lightgreen; color:black; @@ -23,9 +22,38 @@ background-color: orange; } form button.btnHfStatusz:hover span { color: white; } - form button.btnHfStatusz.kesz:hover span { color: orange } + + + +/*---*/ + form button.btnLattamStatusz { + background-color: #eee; + border-radius: 2px; + border: solid 1px #888; + color: #888; + padding:2px 18px 2px 4px; + } + form button.btnLattamStatusz:hover { + background-color:lightgreen; + color:black; + border-color:black; + } + form button.btnLattamStatusz span { color:#eee; } + form button.btnLattamStatusz:hover span { color: white; } + + form button.btnLattamStatusz.lattam { background-color: lightgreen; color:white; } + form button.btnLattamStatusz.lattam span { color: white; } + form button.btnLattamStatusz.lattam:hover {background-color: orange;} + form button.btnLattamStatusz.lattam:hover span { color: orange } + + table.hazifeladatDiak { margin:auto; background-color: #eee;} - table.hazifeladatDiak thead tr th { background-color: #4caf50; color:white; font-weight:normal;} + table.hazifeladatDiak thead tr th { background-color: #4caf50; color:white; font-weight:normal; padding: 2px 4px;} table.hazifeladatDiak tbody tr td { background-color: white; font-weight:normal; padding: 2px 4px;} + + + table.hazifeladatDiak tr td a, fieldset.adatok a { color: black; } + table.hazifeladatDiak tr td a:hover, fieldset.adatok a:hover { text-decoration:underline; color: cornflowerblue; } + diff --git a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml index c5a26c13..a8540faa 100644 --- a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml +++ b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml @@ -2,25 +2,21 @@ function putHazifeladat($ADAT) { -/* echo ''; -*/ echo '
'._ALAPADATOK.''."\n"; - echo ($ADAT['oraAdat']['dt']).' ('.$ADAT['oraAdat']['dt'].'), '.$ADAT['oraAdat']['ora'].'. '._ORA.' – '.$ADAT['oraAdat']['tankorNev'].' – '.$ADAT['oraAdat']['kiCn']; + echo ''; + echo ($ADAT['oraAdat']['dt']).' ('.$ADAT['oraAdat']['dt'].'), '.$ADAT['oraAdat']['ora'].'. '._ORA; + echo ''; + echo ' – '.$ADAT['oraAdat']['tankorNev'].''; + echo ' – '.$ADAT['oraAdat']['kiCn'].''; // echo '

'.$ADAT['oraAdat']['leiras'].'

'; echo '
'."\n"; - if (__DIAK===true) { + if (__DIAK===true) { //////////////////////////////////////////////////////////////////////////////////////////////// if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') $_class = "kesz"; - if ($skin != 'ajax') formBegin(array('class'=>'hazifeladat')); echo '
'.ucfirst(_TANANYAG).''."\n"; if ($ADAT['oraAdat']['leiras']=='') { echo '

még nincs kitöltve

'; } @@ -33,19 +29,64 @@ else { echo ($ADAT['hazifeladatAdat']['hazifeladatLeiras']); } echo '
'."\n"; - if ($ADAT['hazifeladatId']>0) { - echo '
'; - echo ''; - if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { - echo ''; + + + if ($ADAT['hazifeladatDiak']['hazifeladatId']>0) { + + echo '
'._HAZIFELTOLTES.''."\n"; + echo formBegin(array('enctype'=>'multipart/form-data')); + + if (FILE_UPLOAD_ENABLED===false || $ADAT['hazifeladatDiak']['tanarLattamDt']!='' || $ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { + if (FILE_UPLOAD_ENABLED===false) $mert = ', mert a feltöltés le van tiltva'; + elseif ($ADAT['hazifeladatDiak']['tanarLattamDt']!='') $mert = ', mert már láttamozta a tanár'; + elseif ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') $mert = ', mert már késznek jelölted a feladatot'; + echo '

nem tudsz új filet feltölteni'.$mert.'

'; } else { - echo ''; + echo '
'; + echo ''; + echo ' (maximum méret: '.human_filesize(file_upload_max_size()).')'; + if ($ADAT['hazifeladatDiak']['hazifeladatDiakFilename']!='') { + $submitSzoveg = 'a korábbi feltöltés cseréje'; + } else { + $submitSzoveg = 'feltöltés'; + } + echo ' '; + echo '
'; + } + + if ($ADAT['hazifeladatDiak']['hazifeladatDiakFilename']!='') { + $ADAT['dir'] = 'naplo/haladasi/hazifeladat'; + $ADAT['file'] = $ADAT['hazifeladatDiak']['hazifeladatDiakFilename']; + $href = href('index.php?page=session&f=download&dir='.$ADAT['dir'].'&file='.$ADAT['file'].'&download=true'); + echo '

Feltöltve:

'; + echo ''; + } + + echo formEnd(); + echo '
'; + + formBegin(array('class'=>'hazifeladat')); + if ($ADAT['hazifeladatId']>0) { + echo '
'; + echo ''; + if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { + echo ''; + } else { + echo ''; + } + echo '
'; } - echo '
'; + echo formEnd(); + + } - - echo formEnd(); - } else { + + } else { //////////////////////////////////////////////////////////////////////////////////// echo ''; if ($skin != 'ajax') formBegin(array('class'=>'hazifeladat')); echo ''; @@ -108,9 +149,12 @@ if (count($ADAT['hazifeladatDiak'])==0) return false; + echo formBegin(); + echo ''; + echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; for ($i=0; $i'.$D['diakLattamDt'].''; echo ''; echo ''; + + $ADAT['dir'] = 'naplo/haladasi/hazifeladat'; + $ADAT['file'] = $D['hazifeladatDiakFilename']; + $href = href('index.php?page=session&f=download&dir='.$ADAT['dir'].'&file='.$ADAT['file'].'&download=true'); + echo ''; + echo ''; echo ''; } echo '
diákláttastátusz
diákláttastátuszcsatolmányláttam
'.$D['hazifeladatDiakStatus'].''.$D['hazifeladatDiakMegjegyzes'].''; + if ($D['hazifeladatDiakOrigFilename']!='') { + echo ''.htmlspecialchars($D['hazifeladatDiakOrigFilename']).' '; + } + echo ''; +// if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { + if (__TANAR===true) { + if ($D['tanarLattamDt']=='') { + echo ''; + } else { + echo ''; + } + } else { + if ($D['tanarLattamDt']!='') {echo '';} + } +// } + echo '
'; + echo formEnd(); } ?> diff --git a/mayor-orig/mayor-portal/log/mayor-portal.rev b/mayor-orig/mayor-portal/log/mayor-portal.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-portal/log/mayor-portal.rev +++ b/mayor-orig/mayor-portal/log/mayor-portal.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/mayor-wiki/log/mayor-wiki.rev b/mayor-orig/mayor-wiki/log/mayor-wiki.rev index 686eea15..5becefaa 100644 --- a/mayor-orig/mayor-wiki/log/mayor-wiki.rev +++ b/mayor-orig/mayor-wiki/log/mayor-wiki.rev @@ -1 +1 @@ -4630 +4632 diff --git a/mayor-orig/md5sum b/mayor-orig/md5sum index 5abcd006..f05e11a2 100644 --- a/mayor-orig/md5sum +++ b/mayor-orig/md5sum @@ -1,13 +1,13 @@ -Revision 4630 -ca14e8acf08091be07c8458889e64676 mayor-fenntarto-rev4630.tgz -fa5f16d2c7845082dbc1f4dacd24379b mayor-installer-sulix-rev4630.tgz -a715381fc31e27fa458de72ae5cab78d mayor-wiki-rev4630.tgz -be0210d48558f957c6e4b42e50e08a30 mayor-installer-rev4630.tgz -c97610239b886f8c6756a47058c09bb4 mayor-portal-rev4630.tgz -b5dd78ccfcd93ae8edb935716dc615f6 mayor-felveteli-rev4630.tgz -6251466609c204b02d2b72c2b9ee496f mayor-jatek-rev4630.tgz -23d74d73ae51e0f2ca83425794c43955 mayor-locales-jp_JP-rev4630.tgz -7987e5b502cb1629499f3ffeb1efa390 mayor-locales-de_DE-rev4630.tgz -7e5e8800bd8bf09e631d160b73642c87 mayor-locales-en_US-rev4630.tgz -50c3e938dcf60b49a29b46dba03db83c mayor-naplo-rev4630.tgz -f6abbe257447f162c12af8d6f099eacc mayor-base-rev4630.tgz +Revision 4632 +44a5b90dd6fabb18bb59eeadd4c4eda8 mayor-fenntarto-rev4632.tgz +5e9912753257eb8957b2d86c5ffffd32 mayor-installer-sulix-rev4632.tgz +19c632c43d212a3593cfe10e8845024f mayor-wiki-rev4632.tgz +5a1159e11a29a4cdeed5178ed8a8ce42 mayor-installer-rev4632.tgz +7c2ae17a4dfaf7c07cfe4059441451d1 mayor-portal-rev4632.tgz +6713324c051247ac2c1cd4fbb0611cae mayor-felveteli-rev4632.tgz +770ad6103604bdc22def1727846d4f14 mayor-jatek-rev4632.tgz +87a235db8d603de9e06bc4af76c79926 mayor-locales-jp_JP-rev4632.tgz +5353bfe9f7235d49716def67f67bea6a mayor-locales-de_DE-rev4632.tgz +1cd40690736747a537f2c6d2410b2f36 mayor-locales-en_US-rev4632.tgz +e3e81709ad75ea33baa40c2950597f8e mayor-naplo-rev4632.tgz +55b7840fc9d2fc09ea03e5c3952aaafc mayor-base-rev4632.tgz diff --git a/mayor-orig/rev.txt b/mayor-orig/rev.txt index 686eea15..5becefaa 100644 --- a/mayor-orig/rev.txt +++ b/mayor-orig/rev.txt @@ -1 +1 @@ -4630 +4632 diff --git a/rev.txt b/rev.txt index 686eea15..5becefaa 100644 --- a/rev.txt +++ b/rev.txt @@ -1 +1 @@ -4630 +4632 -- cgit v1.2.3