Skip to content

Commit

Permalink
Dev: Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 10, 2017
2 parents bfea6fa + 31fc1cd commit 74c533b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
23 changes: 8 additions & 15 deletions application/helpers/admin/import_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2111,19 +2111,15 @@ function TSVImportSurvey($sFullFilePath)

$file = stream_get_contents($handle);
fclose($handle);

// fix Excel non-breaking space
$file = str_replace("0xC20xA0",' ',$file);
// Replace all different newlines styles with \n
$file = preg_replace('~\R~u', "\n", $file);
$filelines = explode("\n",$file);
$row = array_shift($filelines);
$headers = explode("\t",$row);
$rowheaders = array();
foreach ($headers as $header)
{
$rowheaders[] = trim($header);
}
$tmp = fopen('php://temp', 'r+');
fwrite($tmp,$file);
rewind($tmp);
$rowheaders = fgetcsv($tmp,0,"\t",'"');
$rowheaders = array_map('trim',$rowheaders);
// remove BOM from the first header cell, if needed
$rowheaders[0] = preg_replace("/^\W+/","",$rowheaders[0]);
if (preg_match('/class$/',$rowheaders[0]))
Expand All @@ -2132,12 +2128,9 @@ function TSVImportSurvey($sFullFilePath)
}

$adata = array();
foreach ($filelines as $rowline)
{
while (($row = fgetcsv($tmp,0,"\t",'"')) !== FALSE) {
$rowarray = array();
$row = explode("\t",$rowline);
for ($i = 0; $i < count($rowheaders); ++$i)
{
for ($i = 0; $i < count($rowheaders); ++$i) {
$val = (isset($row[$i]) ? $row[$i] : '');
// if Excel was used, it surrounds strings with quotes and doubles internal double quotes. Fix that.
if (preg_match('/^".*"$/',$val))
Expand All @@ -2148,7 +2141,7 @@ function TSVImportSurvey($sFullFilePath)
}
$adata[] = $rowarray;
}

fclose($tmp);
$results['defaultvalues']=0;
$results['answers']=0;
$results['surveys']=0;
Expand Down
11 changes: 7 additions & 4 deletions application/third_party/pclzip/pclzip.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1837,14 +1837,17 @@ function privOptionDefaultThreshold(&$p_options)
$v_memory_limit = trim($v_memory_limit);
$last = strtolower(substr($v_memory_limit, -1));

if($last == 'g')
if($last == 'g') {
//$v_memory_limit = $v_memory_limit*1024*1024*1024;
$v_memory_limit = $v_memory_limit*1073741824;
if($last == 'm')
}
if($last == 'm') {
//$v_memory_limit = $v_memory_limit*1024*1024;
$v_memory_limit = $v_memory_limit*1048576;
if($last == 'k')
$v_memory_limit = ((int) $v_memory_limit) * 1048576;
}
if($last == 'k') {
$v_memory_limit = $v_memory_limit*1024;
}

$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);

Expand Down

0 comments on commit 74c533b

Please sign in to comment.