public function run() { $params = array('help' => true, 'version' => 'php-auto-format 0.1'); $args = \Docopt::handle(get_doc(), $params); if (isset($args['<filepath>'])) { $filepath = $args['<filepath>']; if (!file_exists($filepath)) { die("File {$filepath} does not exist\n"); } $out = $this->formatter->parseFile($filepath); if ($args['--inplace']) { $handler = fopen($filepath, 'w+'); fwrite($handler, $out); fclose($handler); } else { echo $out; } } }
function confirm() { extract($_POST); if (!isset($calloutid) or strlen($calloutid) < 1) { return "Invalid use of module"; } if (is_uploaded_file($_FILES["uploaddoc"]["tmp_name"])) { $type = $_FILES["uploaddoc"]["type"]; // open file in "read, binary" mode $img = ""; $file = fopen($_FILES['uploaddoc']['tmp_name'], "rb"); while (!feof($file)) { // fread is binary safe $img .= fread($file, 1024); } fclose($file); # base 64 encoding $img = base64_encode($img); db_connect(); #write this doc to Cubit here ... #remove any current entries $rem_sql = "DELETE FROM callout_docs_scanned WHERE calloutid = '{$calloutid}' AND div = '" . USER_DIV . "'"; $run_rem = db_exec($rem_sql) or errDie("Unable to remove current scanned entry"); #add the new one ... $write_sql = "INSERT INTO callout_docs_scanned (calloutid,image,image_type,div) VALUES ('{$calloutid}','{$img}','{$type}','" . USER_DIV . "')"; $run_write = db_exec($write_sql) or errDie("Unable to add new call out document scanned image"); header("Location: callout-view.php"); } else { return get_doc($_POST, "<li class='err'>Please select a document to upload</li><br>"); } }