fixed milestone upload with bad char regex
This commit is contained in:
@@ -272,6 +272,10 @@ class milestone
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function is_valid($str) {
|
||||||
|
return !preg_match('/([A-ZÁÉÚŐÓÜŰÖÍa-z0-9áéúőóüűöí\_\-\ \,\.\:\?\;])/', $str);
|
||||||
|
}
|
||||||
|
|
||||||
public static function upload_file($file)
|
public static function upload_file($file)
|
||||||
{
|
{
|
||||||
global $sql;
|
global $sql;
|
||||||
@@ -293,9 +297,25 @@ class milestone
|
|||||||
|
|
||||||
|
|
||||||
$content = file($_FILES['fileToUpload']['tmp_name']); //makes array
|
$content = file($_FILES['fileToUpload']['tmp_name']); //makes array
|
||||||
|
$newcontent = [];
|
||||||
|
foreach ($content as $lineNo => $line) {
|
||||||
|
//$line = utf8_decode($line);
|
||||||
|
//$line = iconv("UTF-8", "UTF-8//IGNORE", $line);
|
||||||
|
$valid = self::is_valid($line);
|
||||||
|
if (!$valid) {
|
||||||
|
$correctedStr = preg_replace('/[^A-ZÁÉÚŐÓÜŰÖÍa-z0-9áéúőóüűöí\_\-\ \,\.\:\?\;]/', '', $line);
|
||||||
|
$newcontent[$lineNo] = $correctedStr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$newcontent[$lineNo] = $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
//$line = mb_convert_encoding($line, 'UTF-8', 'UTF-8');
|
||||||
//var_dump($content);
|
}
|
||||||
|
//x
|
||||||
|
//var_dump($newcontent);
|
||||||
|
//die();
|
||||||
|
//die();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Szerkezet:
|
Szerkezet:
|
||||||
@@ -341,11 +361,13 @@ class milestone
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$milestoneId = null;
|
$milestoneId = null;
|
||||||
//var_dump($content);
|
//var_dump($newcontent);
|
||||||
for ($lineNo = 0; $lineNo < count($content); ++$lineNo) {
|
for ($lineNo = 0; $lineNo < count($newcontent); ++$lineNo) {
|
||||||
//var_dump($lineNo);
|
//var_dump($lineNo);
|
||||||
$line = $content[$lineNo];
|
$line = $newcontent[$lineNo];
|
||||||
|
|
||||||
//var_dump($line);
|
//var_dump($line);
|
||||||
|
//var_dump(0 === $lineNo, substr($line, 0, 1));
|
||||||
|
|
||||||
//1. sor lekezelése: ha nem szezon, akkor hiba!
|
//1. sor lekezelése: ha nem szezon, akkor hiba!
|
||||||
if (0 === $lineNo && 's' != substr($line, 0, 1)) {
|
if (0 === $lineNo && 's' != substr($line, 0, 1)) {
|
||||||
@@ -373,14 +395,14 @@ class milestone
|
|||||||
$mss_text = "";
|
$mss_text = "";
|
||||||
|
|
||||||
$j = $lineNo;
|
$j = $lineNo;
|
||||||
while(isset($content[$j]) && !empty(trim($content[$j]))) {
|
while(isset($newcontent[$j]) && !empty(trim($newcontent[$j]))) {
|
||||||
//ha még csak a szezon első sorát olvassuk, akkor csak az "s" után rész kell
|
//ha még csak a szezon első sorát olvassuk, akkor csak az "s" után rész kell
|
||||||
if ($j == $lineNo) {
|
if ($j == $lineNo) {
|
||||||
//$content[$j] = substr($content[$j], 2);
|
//$newcontent[$j] = substr($newcontent[$j], 2);
|
||||||
$j++;
|
$j++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$mss_text .= trim($content[$j]) . '\n';
|
$mss_text .= trim($newcontent[$j]) . '\n';
|
||||||
//++$lineNo;
|
//++$lineNo;
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
@@ -396,16 +418,16 @@ class milestone
|
|||||||
$mst = new milestone_training;
|
$mst = new milestone_training;
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$mst_date = trim($content[$lineNo]);
|
$mst_date = trim($newcontent[$lineNo]);
|
||||||
//var_dump('date: ' . $mst_date);
|
//var_dump('date: ' . $mst_date);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$mst_count = trim($content[$lineNo]);
|
$mst_count = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
$j = $lineNo + 1;
|
$j = $lineNo + 1;
|
||||||
$mst_trainings = "";
|
$mst_trainings = "";
|
||||||
while(isset($content[$j]) && !empty(trim($content[$j]))) {
|
while(isset($newcontent[$j]) && !empty(trim($newcontent[$j]))) {
|
||||||
$mst_trainings .= trim($content[$j]) . '\n';
|
$mst_trainings .= trim($newcontent[$j]) . '\n';
|
||||||
++$j;
|
++$j;
|
||||||
}
|
}
|
||||||
$lineNo = $j;
|
$lineNo = $j;
|
||||||
@@ -419,10 +441,10 @@ class milestone
|
|||||||
$type = 3;
|
$type = 3;
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msca_date = trim($content[$lineNo]);
|
$msca_date = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msca_place = trim($content[$lineNo]);
|
$msca_place = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
$msca_id = milestone_camp::create_msca($msca_date, $msca_place);
|
$msca_id = milestone_camp::create_msca($msca_date, $msca_place);
|
||||||
|
|
||||||
@@ -433,29 +455,29 @@ class milestone
|
|||||||
$type = 2;
|
$type = 2;
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msc_date = trim($content[$lineNo]);
|
$msc_date = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msc_name = trim($content[$lineNo]);
|
$msc_name = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msc_location = trim($content[$lineNo]);
|
$msc_location = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msc_category = trim($content[$lineNo]);
|
$msc_category = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msc_place = trim($content[$lineNo]);
|
$msc_place = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
if (isset($content[$lineNo]) && !empty(trim($content[$lineNo]))) {
|
if (isset($newcontent[$lineNo]) && !empty(trim($newcontent[$lineNo]))) {
|
||||||
++$lineNo; //mérkőzések szöveg
|
++$lineNo; //mérkőzések szöveg
|
||||||
$matches = '';
|
$matches = '';
|
||||||
do {
|
do {
|
||||||
$matches .= trim($content[$lineNo]) . '\n';
|
$matches .= trim($newcontent[$lineNo]) . '\n';
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
} while (isset($content[$lineNo]) && !empty(trim($content[$lineNo])));
|
} while (isset($newcontent[$lineNo]) && !empty(trim($newcontent[$lineNo])));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$matches = 'null';
|
$matches = 'null';
|
||||||
@@ -471,17 +493,17 @@ class milestone
|
|||||||
$type = 4;
|
$type = 4;
|
||||||
|
|
||||||
//get season after 'r'
|
//get season after 'r'
|
||||||
$msr_season = trim(substr($content[$lineNo], 2));
|
$msr_season = trim(substr($newcontent[$lineNo], 2));
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$msr_date = trim($content[$lineNo]);
|
$msr_date = trim($newcontent[$lineNo]);
|
||||||
|
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
$rankings = '';
|
$rankings = '';
|
||||||
do {
|
do {
|
||||||
$rankings .= trim($content[$lineNo]) . '\n';
|
$rankings .= trim($newcontent[$lineNo]) . '\n';
|
||||||
++$lineNo;
|
++$lineNo;
|
||||||
} while (isset($content[$lineNo]) && !empty(trim($content[$lineNo])));
|
} while (isset($newcontent[$lineNo]) && !empty(trim($newcontent[$lineNo])));
|
||||||
|
|
||||||
$msr_id = milestone_ranking::create_msr($msr_date, $rankings, $msr_season);
|
$msr_id = milestone_ranking::create_msr($msr_date, $rankings, $msr_season);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user