$cmdRes = ""; $update_target = $_POST["update_target"]; if (strcmp($update_target, "kernel") == 0) { $firmwareFilename = "uImage"; $upgradeCmdArg = "upgrade-kernel-"; } echo "<i>** upgrading: {$update_target} **</i><br>"; if ($fileError == 0) { $upload_fname = $_FILES["file"]["name"]; $temp_name = $_FILES["file"]["tmp_name"]; if (strcmp($upload_fname, $firmwareFilename) != 0) { echo "<br><p><font color=\"red\"> <b>Firmware, upgrade failed! (unsupported filename, expected {$firmwareFilename}) </b> </font></p>"; } else { if (move_uploaded_file($temp_name, "/tmp/{$upload_fname}")) { echo "<p><font color=\"red\"> <b>Firmware upgrade in-progress, please wait!</b></font></p>"; buffer_flush(); $cmdRes = exec("{$cmdpath} {$upgradeCmdArg}/tmp/{$upload_fname}"); if (strncmp($cmdRes, "OK", 2) == 0) { echo "<p><font color=\"red\"> <b>Firmware, upgrade {$cmdRes}. Click \"Reboot\" to reload the device </b></font></p>"; } else { echo "<p><font color=\"red\"> <b>Firmware, upgrade failed: {$cmdRes} </b> </font></p>"; } } else { echo "<p><font color=\"red\"> <b>Firmware, upgrade failed! (save failed) </b> </font></p>"; } } } else { $error_types = array(1 => 'File exceeds maximum size supported by device', 'File exceeds maximum allowed size', 'File upload did not finish', 'No file uploaded', 6 => 'Missing a temp folder', 'Failed to save file to disk', 'A PHP extension stopped the file upload'); $error_message = $error_types[$fileError]; echo "<p><font color=\"red\"> <b>Firmware, upgrade failed! ({$error_message})</b> </font></p>"; }
function displayStartupUserInfo() { if (!isPhpCli() && !isAjaxRequest()) { @ob_start(); $version = KOALA_VERSION; echo <<<END <style type="text/css"> body { \ttext-align: center; \tfont-family: "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; \tfont-size: 17px; \tfont-weight: bold; } div#container { \tposition:relative; \ttop:30%; } </style> <div id="container"> <h1>Initializing System. Please wait ...</h1> <small style="font-weight: normal;">koala framework v{$version}</small> </div> END; buffer_flush(); } else { if (isPhpCli()) { echo "Initializing System. Please wait ...\n"; } } }