3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php switch ($task) { case 'update': { if(isset($HTTP_POST_FILES['filename']['name'])) { echo "<h3>Uploading: ".$HTTP_POST_FILES['filename']['name']."</h3><br>"; $handle=fopen($HTTP_POST_FILES['filename']['tmp_name'],"r"); if ($handle) { if (!feof($handle)) $buffer = fgets($handle); while (!feof($handle)&&!stristr(iconv("WINDOWS-1251","UTF-8",$buffer),'Код')) { $buffer = fgets($handle); } if(!stristr(iconv("WINDOWS-1251","UTF-8",$buffer),'Код')) { echo "<h3>Incorrect file<h3>"; exit; } else { $columns=explode("\t",$buffer); $i=0; foreach ($columns as $column) { $column=iconv("WINDOWS-1251","UTF-8",$column); if ($column=="Розница") $price1=$i; if ($column=="Опт1") $price2=$i; if ($column=="Опт2") $price3=$i; if ($column=="Опт3") $price4=$i; if ($column=="Код") $code=$i; $i++; } } echo $database->doSQL("DROP TABLE IF EXISTS #__import"); echo $database->doSQL("CREATE TABLE IF NOT EXISTS #__import ( `code` bigint(20) unsigned NOT NULL, `price1` float NOT NULL default '0', `price2` float NOT NULL default '0', `price3` float NOT NULL default '0', `price4` float NOT NULL default '0', KEY `code` (`code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"); $buffer = fgets($handle); while (!feof($handle)) { $buffer = fgets($handle); $row = explode("\t",$buffer); if (array_key_exists(9,$row)) { $out=array("'"," руб."); $row[$price1] = str_replace($out,"",$row[$price1]); $row[$price2] = str_replace($out,"",$row[$price2]); $row[$price3] = str_replace($out,"",$row[$price3]); $row[$price4] = str_replace($out,"",$row[$price4]); $sql = "INSERT INTO #__import (`code`, `price1`, `price2`, `price3`, `price4`) VALUES ('$row[$code]', '$row[$price1]', '$row[$price2]', '$row[$price3]', '$row[$price4]');"; $result = $database->doSQL($sql); } } fclose($handle); } echo "<h3>Import completed</h3><br />"; $database->doSQL("UPDATE #__itemdetails SET `price1` = 0, `price2` = 0, `price3` = 0, `price4` = 0"); echo '<h3>Old prices was nulled</h3><br>'; $sql=""; $database->setQuery('select * from #__itemdetails'); $rows = $database->loadObjectList(); foreach ($rows as $row) { $database->setQuery("select * from #__import where code=$row->code"); $rows1=$database->loadObjectList(); if (!sizeof($rows1)) $errors.=$row->code.', '; else { $database->doSQL("UPDATE #__itemdetails SET `price1` = '".$rows1[0]->price1."', `price2` = '".$rows1[0]->price2."', `price3` = '".$rows1[0]->price3."', `price4` = '".$rows1[0]->price4."' WHERE `code` = ".$row->code); $completed.=$row->code.', '; } } echo '<div align=left><b>The following goods were updated:</b> '.substr($completed,0,strlen($completed)-2).'</div>'; if (isset($errors)) echo '<br><br><div align=left><b><font color=red>The following goods were not found:</b></font> '.substr($errors,0,strlen($errors)-2).'</div>'; exit; } } default: HTML_catalog::ShowUploadPriceForm(); break; } break; ?>
Output for 5.5.0 - 5.5.5
Notice: Undefined variable: task in /in/lirjG on line 2 Fatal error: Class 'HTML_catalog' not found in /in/lirjG on line 88
Process exited with code 255.
Output for 5.3.0 - 5.4.21
Fatal error: Class 'HTML_catalog' not found in /in/lirjG on line 88
Process exited with code 255.