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