Exemplo n.º 1
0
 public function decode_route()
 {
     $this->params = new _hx_array(array());
     if (system_base_Router::$regexp->match($this->query_string)) {
         throw new HException(new system_base_Http_exception("Illegal character(s) in URI: " . _hx_string_or_null($this->query_string), 400, _hx_anonymous(array("fileName" => "Router.hx", "lineNumber" => 119, "className" => "system.base.Router", "methodName" => "decode_route"))));
     }
     if (strlen($this->query_string) === 0) {
         $this->controller = system_base_Router::$FRONT_CONTROLLER;
         $s = strtolower($this->controller);
         $this->controller = _hx_string_or_null(strtoupper(_hx_substr($s, 0, 1))) . _hx_string_or_null(_hx_substr($s, 1, null));
         $this->method = strtolower(system_base_Router::$DEFAULT_METHOD);
         $this->query_string = _hx_string_or_null($this->controller) . "/" . _hx_string_or_null($this->method);
         return true;
     }
     if (_hx_index_of($this->query_string, "/", null) === -1) {
         $this->params->push(strtolower($this->query_string));
     } else {
         $this->params = _hx_explode("/", strtolower($this->query_string));
     }
     if ($this->params[0] !== null && strlen($this->params[0]) > 0) {
         $s1 = $this->params[0];
         $this->controller = _hx_string_or_null(strtoupper(_hx_substr($s1, 0, 1))) . _hx_string_or_null(_hx_substr($s1, 1, null));
     } else {
         $this->controller = system_base_Router::$FRONT_CONTROLLER;
     }
     if ($this->params[1] !== null && strlen($this->params[0]) > 0) {
         $this->method = $this->params[1];
     } else {
         $this->method = system_base_Router::$DEFAULT_METHOD;
     }
     if ($this->controller === "_load") {
         return false;
     }
     return true;
 }
	static function getPublicAndProtectedVars($fileData) {
		$results = (new _hx_array(array()));
		$searchIndex = 0;
		while($searchIndex < strlen($fileData)) {
			$searchIndex = _hx_index_of($fileData, "public \$", $searchIndex);
			if($searchIndex === -1) {
				break;
			}
			$semiColonIndex = _hx_index_of($fileData, ";", $searchIndex);
			$varName = _hx_substring($fileData, $searchIndex + 8, $semiColonIndex);
			$results->push(_hx_anonymous(array("varName" => $varName, "isPublic" => true)));
			$searchIndex = $semiColonIndex;
			unset($varName,$semiColonIndex);
		}
		$searchIndex = 0;
		while($searchIndex < strlen($fileData)) {
			$searchIndex = _hx_index_of($fileData, "protected \$", $searchIndex);
			if($searchIndex === -1) {
				break;
			}
			$semiColonIndex1 = _hx_index_of($fileData, ";", $searchIndex);
			$varName1 = _hx_substring($fileData, $searchIndex + 11, $semiColonIndex1);
			$results->push(_hx_anonymous(array("varName" => $varName1, "isPublic" => false)));
			$searchIndex = $semiColonIndex1;
			unset($varName1,$semiColonIndex1);
		}
		return $results;
	}
 public function addStats($url)
 {
     $saveMode = $this->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$SAVE_MODE, "xml");
     $version = null;
     try {
         $version = com_wiris_system_Storage::newResourceStorage("VERSION")->read();
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $ex = $_ex_;
         $version = "Missing version";
     }
     $tech = null;
     try {
         $tech = com_wiris_system_Storage::newResourceStorage("tech.txt")->read();
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $ex2 = $_ex_;
         $tech = "Missing tech";
     }
     if (_hx_index_of($url, "?", null) !== -1) {
         return $url . "&stats-mode=" . $saveMode . "&stats-version=" . $version . "&stats-scriptlang=" . $tech;
     } else {
         return $url . "?stats-mode=" . $saveMode . "&stats-version=" . $version . "&stats-scriptlang=" . $tech;
     }
 }
 public function quote($s)
 {
     if (_hx_index_of($s, "", null) >= 0) {
         return "x'" . $this->base16_encode($s) . "'";
     }
     return "'" . (sqlite_escape_string($s) . "'");
 }
 public function render($format, $mml, $latex, $properties, $outProperties)
 {
     $servicesClass = Type::resolveClass("com.wiris.editor.services.PublicServices");
     $getInstance = Reflect::field($servicesClass, "getInstance");
     $publicServices = Reflect::callMethod($servicesClass, $getInstance, null);
     $args = new _hx_array(array());
     $args->push($mml);
     $args->push($latex);
     $args->push($properties);
     $args->push($outProperties);
     try {
         if (_hx_index_of($format, "png", null) !== -1) {
             $renderPngMethod = Reflect::field($publicServices, "renderPng");
             $pngObject = Reflect::callMethod($publicServices, $renderPngMethod, $args);
             $pngBytes = $pngObject;
             return haxe_io_Bytes::ofData($pngBytes);
         } else {
             if (_hx_index_of($format, "svg", null) !== -1) {
                 $renderSvgMethod = Reflect::field($publicServices, "renderSvg");
                 $svgObject = Reflect::callMethod($publicServices, $renderSvgMethod, $args);
                 $svgString = $svgObject;
                 return haxe_io_Bytes::ofString($svgString);
             } else {
                 throw new HException("Unexpected image format.");
             }
         }
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $e = $_ex_;
         throw new HException($e->getMessage());
     }
 }
 public function getMathML($digest, $latex)
 {
     if ($digest !== null) {
         $content = $this->plugin->getStorageAndCache()->decodeDigest($digest);
         if ($content !== null) {
             if (StringTools::startsWith($content, "<")) {
                 $breakline = null;
                 $breakline = _hx_index_of($content, "\n", 0);
                 return _hx_substr($content, 0, $breakline);
             } else {
                 $iniFile = com_wiris_util_sys_IniFile::newIniFileFromString($content);
                 $mathml = $iniFile->getProperties()->get("mml");
                 if ($mathml !== null) {
                     return $mathml;
                 } else {
                     return "Error: mathml not found.";
                 }
             }
         } else {
             return "Error: formula not found.";
         }
     } else {
         if ($latex !== null) {
             return $this->latex2mathml($latex);
         } else {
             return "Error: no digest or latex has been sent.";
         }
     }
 }
Exemplo n.º 7
0
 public function external_status($param)
 {
     $status = $param->get("dispo");
     $url = "http://xpress.mein-dialer.com/agc/api.php?source=flyCRM&user="******"&pass="******"&function=external_status&value=" . _hx_string_or_null($status) . "&agent_user="******"agent_user"));
     haxe_Log::trace($url, _hx_anonymous(array("fileName" => "AgcApi.hx", "lineNumber" => 71, "className" => "model.AgcApi", "methodName" => "external_status")));
     $agcResponse = haxe_Http::requestUrl($url);
     return $this->json_response(_hx_index_of($agcResponse, "SUCCESS", null) === 0 ? "OK" : $agcResponse);
 }
Exemplo n.º 8
0
 public function appendElement2JavascriptArray($array, $value)
 {
     $arrayOpen = _hx_index_of($array, "[", null);
     $arrayClose = _hx_index_of($array, "]", null);
     if ($arrayOpen === -1 || $arrayClose === -1) {
         throw new HException("Array not valid");
     }
     return "[" . "'" . $value . "'" . com_wiris_plugin_impl_ConfigurationImpl_0($this, $array, $arrayClose, $arrayOpen, $value);
 }
Exemplo n.º 9
0
 static function systemName()
 {
     $s = php_uname("s");
     $p = null;
     if (($p = _hx_index_of($s, " ", null)) >= 0) {
         return _hx_substr($s, 0, $p);
     } else {
         return $s;
     }
 }
Exemplo n.º 10
0
 static function get_ROOT_URL()
 {
     if (zcale_core_path_targets_ServerPath::$rootUrl === null) {
         $protocol = "http://";
         $localhost = sys_net_Host::localhost();
         $protocol = $_SERVER["SERVER_PROTOCOL"];
         $protocol = _hx_string_or_null(strtolower(_hx_substr($protocol, 0, _hx_index_of($protocol, "/", null)))) . "://";
         zcale_core_path_targets_ServerPath::$rootUrl = _hx_string_or_null($protocol) . _hx_string_or_null($localhost) . _hx_string_or_null(zcale_core_path_targets_ServerPath::get_FILE_DIR());
     }
     return zcale_core_path_targets_ServerPath::$rootUrl;
 }
 static function searchString($data, $s)
 {
     $_g = 0;
     while ($_g < $data->length) {
         $d = $data[$_g];
         ++$_g;
         if (_hx_index_of($s, $d->subString, null) >= 0) {
             return _hx_anonymous(array("app" => $d->identity, "versionString" => ufront_web_UserAgent_0($_g, $d, $data, $s)));
         }
         unset($d);
     }
     return null;
 }
Exemplo n.º 12
0
 public function insert_before($needle, $text)
 {
     $start = null;
     if (strlen($this->body) === 0) {
         return false;
     }
     $start = _hx_index_of($this->body, $needle, null);
     if ($start === -1) {
         return false;
     }
     $this->body = _hx_string_or_null(_hx_substr($this->body, 0, $start)) . _hx_string_or_null($text) . _hx_string_or_null(_hx_substr($this->body, $start, null));
     return true;
 }
Exemplo n.º 13
0
 public function getValueForType($type, $name = null)
 {
     $mapping = $this->findMappingForType($type, $name);
     if ($mapping !== null) {
         return $mapping->getValue($this);
     }
     $index = _hx_index_of($type, "<", null);
     if ($index > -1) {
         $mapping = $this->findMappingForType(_hx_substr($type, 0, $index), $name);
     }
     if ($mapping !== null) {
         return $mapping->getValue($this);
     }
     return null;
 }
Exemplo n.º 14
0
 public function loadPropertiesLine($line, $count)
 {
     $line = trim($line);
     if (strlen($line) === 0) {
         return;
     }
     if (StringTools::startsWith($line, ";") || StringTools::startsWith($line, "#")) {
         return;
     }
     $equals = _hx_index_of($line, "=", null);
     if ($equals === -1) {
         throw new HException("Malformed INI file " . $this->filename . " in line " . _hx_string_rec($count, "") . " no equal sign found.");
     }
     $key = _hx_substr($line, 0, $equals);
     $key = trim($key);
     $value = _hx_substr($line, $equals + 1, null);
     $value = trim($value);
     if (StringTools::startsWith($value, "\"") && StringTools::endsWith($value, "\"")) {
         $value = _hx_substr($value, 1, strlen($value) - 2);
     }
     $backslash = 0;
     while (($backslash = _hx_index_of($value, "\\", $backslash)) !== -1) {
         if (strlen($value) <= $backslash + 1) {
             continue;
         }
         $letter = _hx_substr($value, $backslash + 1, 1);
         if ($letter === "n") {
             $letter = "\n";
         } else {
             if ($letter === "r") {
                 $letter = "\r";
             } else {
                 if ($letter === "t") {
                     $letter = "\t";
                 }
             }
         }
         $value = _hx_substr($value, 0, $backslash) . $letter . _hx_substr($value, $backslash + 2, null);
         $backslash++;
         unset($letter);
     }
     $this->props->set($key, $value);
 }
 public function updateConfiguration(&$configuration)
 {
     $configuration = $configuration;
     $confClass = com_wiris_system_PropertiesTools::getProperty($configuration, com_wiris_plugin_api_ConfigurationKeys::$CONFIGURATION_CLASS, null);
     if ($confClass !== null && _hx_index_of($confClass, "com.wiris.plugin.servlets.configuration.ParameterServletConfigurationUpdater", null) !== -1) {
         return;
     }
     if ($confClass !== null) {
         $cls = Type::resolveClass($confClass);
         if ($cls === null) {
             throw new HException("Class " . $confClass . " not found.");
         }
         $obj = Type::createInstance($cls, new _hx_array(array()));
         if ($obj === null) {
             throw new HException("Instance from " . Std::string($cls) . " cannot be created.");
         }
         $cu = $obj;
         $this->config->initialize($cu);
         $cu->updateConfiguration($configuration);
     }
 }
 public function updateFolderStructure($dir)
 {
     $folder = com_wiris_util_sys_Store::newStore($dir);
     $files = $folder->hlist();
     if ($files !== null) {
         $i = null;
         $_g1 = 0;
         $_g = $files->length;
         while ($_g1 < $_g) {
             $i1 = $_g1++;
             $digest = $this->isFormulaFileName($files[$i1]);
             if ($digest !== null) {
                 $newFolder = $this->getFolderStore($dir, $digest);
                 $newFolder->mkdirs();
                 $newFile = $this->getFileStoreWithParent($newFolder, $digest, _hx_substr($files[$i1], _hx_index_of($files[$i1], ".", null) + 1, null));
                 $file = com_wiris_util_sys_Store::newStoreWithParent($folder, $files[$i1]);
                 $file->moveTo($newFile);
                 unset($newFolder, $newFile, $file);
             }
             unset($i1, $digest);
         }
     }
 }
Exemplo n.º 17
0
 public function load_view_object($view, $vars = null)
 {
     $base = isset(system_base_Wet_base::$get_instance) ? system_base_Wet_base::$get_instance : array("system_base_Wet_base", "get_instance");
     $viewpath = _hx_string_or_null(system_base_Wet_base::$views_path) . _hx_string_or_null($view) . ".wtv";
     $view1 = null;
     $pos = 0;
     $left = null;
     $right = null;
     $uservar = null;
     $fieldname = null;
     try {
         $view1 = sys_io_File::getContent($viewpath);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         throw new HException(new system_base_NoFileError(_hx_string_or_null($viewpath) . " does not exist or cannot be opened for reading"));
     }
     if ($vars !== null) {
         $fields = Reflect::fields($vars);
         $_g = 0;
         while ($_g < $fields->length) {
             $fieldname1 = $fields[$_g];
             ++$_g;
             $uservar = Std::string(Reflect::field($vars, $fieldname1));
             $pos = 0;
             while (($pos = _hx_index_of($view1, "::" . _hx_string_or_null($fieldname1) . "::", $pos)) !== -1) {
                 $left = _hx_substr($view1, 0, $pos);
                 $right = _hx_substr($view1, $pos + strlen($fieldname1) + 4, null);
                 $view1 = _hx_string_or_null($left) . _hx_string_or_null($uservar) . _hx_string_or_null($right);
                 $pos += 1;
             }
             unset($fieldname1);
         }
     }
     $this->cache->append($view1);
 }
Exemplo n.º 18
0
 public function run($args, $io = null)
 {
     if ($io === null) {
         $io = new coopy_TableIO();
     }
     if ($io === null) {
         haxe_Log::trace("No system interface available", _hx_anonymous(array("fileName" => "Coopy.hx", "lineNumber" => 693, "className" => "coopy.Coopy", "methodName" => "run")));
         return 1;
     }
     $this->init();
     $this->io = $io;
     $more = true;
     $output = null;
     $inplace = false;
     $git = false;
     $this->flags = new coopy_CompareFlags();
     $this->flags->always_show_header = true;
     while ($more) {
         $more = false;
         $_g1 = 0;
         $_g = $args->length;
         while ($_g1 < $_g) {
             $i = $_g1++;
             $tag = $args[$i];
             if ($tag === "--output") {
                 $more = true;
                 $output = $args[$i + 1];
                 $args->splice($i, 2);
                 break;
             } else {
                 if ($tag === "--css") {
                     $more = true;
                     $this->fragment = true;
                     $this->css_output = $args[$i + 1];
                     $args->splice($i, 2);
                     break;
                 } else {
                     if ($tag === "--fragment") {
                         $more = true;
                         $this->fragment = true;
                         $args->splice($i, 1);
                         break;
                     } else {
                         if ($tag === "--plain") {
                             $more = true;
                             $this->pretty = false;
                             $args->splice($i, 1);
                             break;
                         } else {
                             if ($tag === "--all") {
                                 $more = true;
                                 $this->flags->show_unchanged = true;
                                 $this->flags->show_unchanged_columns = true;
                                 $args->splice($i, 1);
                                 break;
                             } else {
                                 if ($tag === "--all-rows") {
                                     $more = true;
                                     $this->flags->show_unchanged = true;
                                     $args->splice($i, 1);
                                     break;
                                 } else {
                                     if ($tag === "--all-columns") {
                                         $more = true;
                                         $this->flags->show_unchanged_columns = true;
                                         $args->splice($i, 1);
                                         break;
                                     } else {
                                         if ($tag === "--act") {
                                             $more = true;
                                             if ($this->flags->acts === null) {
                                                 $this->flags->acts = new haxe_ds_StringMap();
                                             }
                                             $this->flags->acts->set($args[$i + 1], true);
                                             true;
                                             $args->splice($i, 2);
                                             break;
                                         } else {
                                             if ($tag === "--context") {
                                                 $more = true;
                                                 $context = Std::parseInt($args[$i + 1]);
                                                 if ($context >= 0) {
                                                     $this->flags->unchanged_context = $context;
                                                 }
                                                 $args->splice($i, 2);
                                                 break;
                                                 unset($context);
                                             } else {
                                                 if ($tag === "--inplace") {
                                                     $more = true;
                                                     $inplace = true;
                                                     $args->splice($i, 1);
                                                     break;
                                                 } else {
                                                     if ($tag === "--git") {
                                                         $more = true;
                                                         $git = true;
                                                         $args->splice($i, 1);
                                                         break;
                                                     } else {
                                                         if ($tag === "--unordered") {
                                                             $more = true;
                                                             $this->flags->ordered = false;
                                                             $this->flags->unchanged_context = 0;
                                                             $this->order_set = true;
                                                             $args->splice($i, 1);
                                                             break;
                                                         } else {
                                                             if ($tag === "--ordered") {
                                                                 $more = true;
                                                                 $this->flags->ordered = true;
                                                                 $this->order_set = true;
                                                                 $args->splice($i, 1);
                                                                 break;
                                                             } else {
                                                                 if ($tag === "--color") {
                                                                     $more = true;
                                                                     $this->flags->terminal_format = "ansi";
                                                                     $args->splice($i, 1);
                                                                     break;
                                                                 } else {
                                                                     if ($tag === "--no-color") {
                                                                         $more = true;
                                                                         $this->flags->terminal_format = "plain";
                                                                         $args->splice($i, 1);
                                                                         break;
                                                                     } else {
                                                                         if ($tag === "--input-format") {
                                                                             $more = true;
                                                                             $this->setFormat($args[$i + 1]);
                                                                             $args->splice($i, 2);
                                                                             break;
                                                                         } else {
                                                                             if ($tag === "--output-format") {
                                                                                 $more = true;
                                                                                 $this->output_format = $args[$i + 1];
                                                                                 $this->output_format_set = true;
                                                                                 $args->splice($i, 2);
                                                                                 break;
                                                                             } else {
                                                                                 if ($tag === "--id") {
                                                                                     $more = true;
                                                                                     if ($this->flags->ids === null) {
                                                                                         $this->flags->ids = new _hx_array(array());
                                                                                     }
                                                                                     $this->flags->ids->push($args[$i + 1]);
                                                                                     $args->splice($i, 2);
                                                                                     break;
                                                                                 } else {
                                                                                     if ($tag === "--ignore") {
                                                                                         $more = true;
                                                                                         $this->flags->ignoreColumn($args[$i + 1]);
                                                                                         $args->splice($i, 2);
                                                                                         break;
                                                                                     } else {
                                                                                         if ($tag === "--index") {
                                                                                             $more = true;
                                                                                             $this->flags->always_show_order = true;
                                                                                             $this->flags->never_show_order = false;
                                                                                             $args->splice($i, 1);
                                                                                             break;
                                                                                         } else {
                                                                                             if ($tag === "--www") {
                                                                                                 $more = true;
                                                                                                 $this->output_format = "www";
                                                                                                 $this->output_format_set = true;
                                                                                                 $args->splice($i, 1);
                                                                                             } else {
                                                                                                 if ($tag === "--table") {
                                                                                                     $more = true;
                                                                                                     $this->flags->addTable($args[$i + 1]);
                                                                                                     $args->splice($i, 2);
                                                                                                     break;
                                                                                                 } else {
                                                                                                     if ($tag === "-w" || $tag === "--ignore-whitespace") {
                                                                                                         $more = true;
                                                                                                         $this->flags->ignore_whitespace = true;
                                                                                                         $args->splice($i, 1);
                                                                                                         break;
                                                                                                     } else {
                                                                                                         if ($tag === "-i" || $tag === "--ignore-case") {
                                                                                                             $more = true;
                                                                                                             $this->flags->ignore_case = true;
                                                                                                             $args->splice($i, 1);
                                                                                                             break;
                                                                                                         } else {
                                                                                                             if ($tag === "--padding") {
                                                                                                                 $more = true;
                                                                                                                 $this->flags->padding_strategy = $args[$i + 1];
                                                                                                                 $args->splice($i, 2);
                                                                                                                 break;
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             unset($tag, $i);
         }
         unset($_g1, $_g);
     }
     $cmd = $args[0];
     if ($args->length < 2) {
         if ($cmd === "version") {
             $io->writeStdout(_hx_string_or_null(coopy_Coopy::$VERSION) . "\n");
             return 0;
         }
         if ($cmd === "git") {
             $io->writeStdout("You can use daff to improve git's handling of csv files, by using it as a\ndiff driver (for showing what has changed) and as a merge driver (for merging\nchanges between multiple versions).\n");
             $io->writeStdout("\n");
             $io->writeStdout("Automatic setup\n");
             $io->writeStdout("---------------\n\n");
             $io->writeStdout("Run:\n");
             $io->writeStdout("  daff git csv\n");
             $io->writeStdout("\n");
             $io->writeStdout("Manual setup\n");
             $io->writeStdout("------------\n\n");
             $io->writeStdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n");
             $io->writeStdout("  *.csv diff=daff-csv\n");
             $io->writeStdout("  *.csv merge=daff-csv\n");
             $io->writeStdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n");
             $io->writeStdout("  [diff \"daff-csv\"]\n");
             $io->writeStdout("  command = daff diff --git\n");
             $io->writeStderr("\n");
             $io->writeStdout("  [merge \"daff-csv\"]\n");
             $io->writeStdout("  name = daff tabular merge\n");
             $io->writeStdout("  driver = daff merge --output %A %O %A %B\n\n");
             $io->writeStderr("Make sure you can run daff from the command-line as just \"daff\" - if not,\nreplace \"daff\" in the driver and command lines above with the correct way\nto call it. Add --no-color if your terminal does not support ANSI colors.");
             $io->writeStderr("\n");
             return 0;
         }
         $io->writeStderr("daff can produce and apply tabular diffs.\n");
         $io->writeStderr("Call as:\n");
         $io->writeStderr("  daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n");
         $io->writeStderr("  daff [--output OUTPUT.html] a.csv b.csv\n");
         $io->writeStderr("  daff [--output OUTPUT.csv] parent.csv a.csv b.csv\n");
         $io->writeStderr("  daff [--output OUTPUT.ndjson] a.ndjson b.ndjson\n");
         $io->writeStderr("  daff [--www] a.csv b.csv\n");
         $io->writeStderr("  daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv\n");
         $io->writeStderr("  daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n");
         $io->writeStderr("  daff trim [--output OUTPUT.csv] source.csv\n");
         $io->writeStderr("  daff render [--output OUTPUT.html] diff.csv\n");
         $io->writeStderr("  daff copy in.csv out.tsv\n");
         $io->writeStderr("  daff git\n");
         $io->writeStderr("  daff version\n");
         $io->writeStderr("\n");
         $io->writeStderr("The --inplace option to patch and merge will result in modification of a.csv.\n");
         $io->writeStderr("\n");
         $io->writeStderr("If you need more control, here is the full list of flags:\n");
         $io->writeStderr("  daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n");
         $io->writeStderr("     --act ACT:     show only a certain kind of change (update, insert, delete)\n");
         $io->writeStderr("     --all:         do not prune unchanged rows or columns\n");
         $io->writeStderr("     --all-rows:    do not prune unchanged rows\n");
         $io->writeStderr("     --all-columns: do not prune unchanged columns\n");
         $io->writeStderr("     --color:       highlight changes with terminal colors (default in terminals)\n");
         $io->writeStderr("     --context NUM: show NUM rows of context\n");
         $io->writeStderr("     --id:          specify column to use as primary key (repeat for multi-column key)\n");
         $io->writeStderr("     --ignore:      specify column to ignore completely (can repeat)\n");
         $io->writeStderr("     --index:       include row/columns numbers from original tables\n");
         $io->writeStderr("     --input-format [csv|tsv|ssv|json]: set format to expect for input\n");
         $io->writeStderr("     --no-color:    make sure terminal colors are not used\n");
         $io->writeStderr("     --ordered:     assume row order is meaningful (default for CSV)\n");
         $io->writeStderr("     --output-format [csv|tsv|ssv|json|copy|html]: set format for output\n");
         $io->writeStderr("     --padding [dense|sparse|smart]: set padding method for aligning columns\n");
         $io->writeStderr("     --table NAME:  compare the named table, used with SQL sources\n");
         $io->writeStderr("     --unordered:   assume row order is meaningless (default for json formats)\n");
         $io->writeStderr("     -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n");
         $io->writeStderr("     -i / --ignore-case: ignore differences in case\n");
         $io->writeStderr("\n");
         $io->writeStderr("  daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n");
         $io->writeStderr("     --css CSS.css: generate a suitable css file to go with the html\n");
         $io->writeStderr("     --fragment:    generate just a html fragment rather than a page\n");
         $io->writeStderr("     --plain:       do not use fancy utf8 characters to make arrows prettier\n");
         $io->writeStderr("     --www:         send output to a browser\n");
         return 1;
     }
     $cmd1 = $args[0];
     $offset = 1;
     if (!Lambda::has(new _hx_array(array("diff", "patch", "merge", "trim", "render", "git", "version", "copy")), $cmd1)) {
         if (_hx_index_of($cmd1, ".", null) !== -1 || _hx_index_of($cmd1, "--", null) === 0) {
             $cmd1 = "diff";
             $offset = 0;
         }
     }
     if ($cmd1 === "git") {
         $types = $args->splice($offset, $args->length - $offset);
         return $this->installGitDriver($io, $types);
     }
     if ($git) {
         $ct = $args->length - $offset;
         if ($ct !== 7 && $ct !== 9) {
             $io->writeStderr("Expected 7 or 9 parameters from git, but got " . _hx_string_rec($ct, "") . "\n");
             return 1;
         }
         $git_args = $args->splice($offset, $ct);
         $args->splice(0, $args->length);
         $offset = 0;
         $old_display_path = $git_args[0];
         $new_display_path = $git_args[0];
         $old_file = $git_args[1];
         $new_file = $git_args[4];
         if ($ct === 9) {
             $io->writeStdout($git_args[8]);
             $new_display_path = $git_args[7];
         }
         $io->writeStdout("--- a/" . _hx_string_or_null($old_display_path) . "\n");
         $io->writeStdout("+++ b/" . _hx_string_or_null($new_display_path) . "\n");
         $args->push($old_file);
         $args->push($new_file);
     }
     $parent = null;
     if ($args->length - $offset >= 3) {
         $parent = $this->loadTable($args[$offset]);
         $offset++;
     }
     $aname = $args[$offset];
     $a = $this->loadTable($aname);
     $b = null;
     if ($args->length - $offset >= 2) {
         if ($cmd1 !== "copy") {
             $b = $this->loadTable($args[1 + $offset]);
         } else {
             $output = $args[1 + $offset];
         }
     }
     $this->flags->diff_strategy = $this->strategy;
     if ($inplace) {
         if ($output !== null) {
             $io->writeStderr("Please do not use --inplace when specifying an output.\n");
         }
         $output = $aname;
         return 1;
     }
     if ($output === null) {
         $output = "-";
     }
     $ok = true;
     if ($cmd1 === "diff") {
         if (!$this->order_set) {
             $this->flags->ordered = $this->order_preference;
             if (!$this->flags->ordered) {
                 $this->flags->unchanged_context = 0;
             }
         }
         $this->flags->allow_nested_cells = $this->nested_output;
         $this->runDiff($parent, $a, $b, $this->flags, $output);
     } else {
         if ($cmd1 === "patch") {
             $patcher = new coopy_HighlightPatch($a, $b, null);
             $patcher->apply();
             $this->saveTable($output, $a, null);
         } else {
             if ($cmd1 === "merge") {
                 $merger = new coopy_Merger($parent, $a, $b, $this->flags);
                 $conflicts = $merger->apply();
                 $ok = $conflicts === 0;
                 if ($conflicts > 0) {
                     $io->writeStderr(_hx_string_rec($conflicts, "") . " conflict" . _hx_string_or_null($conflicts > 1 ? "s" : "") . "\n");
                 }
                 $this->saveTable($output, $a, null);
             } else {
                 if ($cmd1 === "trim") {
                     $this->saveTable($output, $a, null);
                 } else {
                     if ($cmd1 === "render") {
                         $this->renderTable($output, $a);
                     } else {
                         if ($cmd1 === "copy") {
                             $this->saveTable($output, $a, null);
                         }
                     }
                 }
             }
         }
     }
     if ($ok) {
         return 0;
     } else {
         return 1;
     }
 }
 static function formatPartial($dti, $format)
 {
     $result = new _hx_array(array());
     $pos = 0;
     $str = "";
     $_g1 = 0;
     $_g = $format->length;
     while ($_g1 < $_g) {
         $f = $_g1++;
         $pos = _hx_index_of($format[$f], "%", null);
         if ($pos >= 0) {
             $_g2 = ord(substr($format[$f], $pos + 1, 1));
             switch ($_g2) {
                 case 89:
                     if ($dti->getYears() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_or_null(datetime_utils_DateTimeIntervalUtils_0($_g, $_g1, $_g2, $dti, $f, $format, $pos, $result, $str)) . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 121:
                     if ($dti->getYears() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getYears(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 77:
                     if ($dti->getMonths() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_or_null(datetime_utils_DateTimeIntervalUtils_1($_g, $_g1, $_g2, $dti, $f, $format, $pos, $result, $str)) . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 109:
                     if ($dti->getMonths() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getMonths(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 98:
                     if ($dti->getTotalMonths() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getTotalMonths(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 68:
                     if ($dti->getDays() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_or_null(datetime_utils_DateTimeIntervalUtils_2($_g, $_g1, $_g2, $dti, $f, $format, $pos, $result, $str)) . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 100:
                     if ($dti->getDays() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getDays(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 97:
                     if ($dti->getTotalDays() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getTotalDays(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 72:
                     if ($dti->getHours() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_or_null(datetime_utils_DateTimeIntervalUtils_3($_g, $_g1, $_g2, $dti, $f, $format, $pos, $result, $str)) . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 104:
                     if ($dti->getHours() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getHours(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 99:
                     if ($dti->getTotalHours() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getTotalHours(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 73:
                     if ($dti->getMinutes() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_or_null(datetime_utils_DateTimeIntervalUtils_4($_g, $_g1, $_g2, $dti, $f, $format, $pos, $result, $str)) . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 105:
                     if ($dti->getMinutes() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getMinutes(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 101:
                     if ($dti->getTotalMinutes() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getTotalMinutes(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 83:
                     if ($dti->getSeconds() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_or_null(datetime_utils_DateTimeIntervalUtils_5($_g, $_g1, $_g2, $dti, $f, $format, $pos, $result, $str)) . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 115:
                     if ($dti->getSeconds() === 0) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getSeconds(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 case 102:
                     if (_hx_equal($dti->getTotalSeconds(), 0)) {
                         continue 2;
                     }
                     $str = _hx_string_or_null(_hx_substring($format[$f], 0, $pos)) . _hx_string_rec($dti->getTotalSeconds(), "") . _hx_string_or_null(_hx_substring($format[$f], $pos + 2, null));
                     break;
                 default:
                     continue 2;
                     break;
             }
             unset($_g2);
             $result->push($str);
         }
         unset($f);
     }
     return $result;
 }
 public function serviceText($serviceName, $param)
 {
     $servicesClass = Type::resolveClass("com.wiris.editor.services.PublicServices");
     $getInstance = Reflect::field($servicesClass, "getInstance");
     $publicServices = Reflect::callMethod($servicesClass, $getInstance, null);
     $serviceMethod = Reflect::field($publicServices, $serviceName);
     $args = new _hx_array(array());
     try {
         if (_hx_index_of($serviceName, "mathml2accessible", null) !== -1) {
             $mml = com_wiris_system_PropertiesTools::getProperty($param, "mml", null);
             if ($mml === null) {
                 throw new HException("Missing mml");
             } else {
                 $args->push($mml);
             }
             $lang = com_wiris_system_PropertiesTools::getProperty($param, "lang", "en");
             $args->push($lang);
             $args->push($param);
             $serviceText = Reflect::callMethod($publicServices, $serviceMethod, $args);
             return $serviceText;
         } else {
             if (_hx_index_of($serviceName, "mathml2latex", null) !== -1) {
                 $mml = com_wiris_system_PropertiesTools::getProperty($param, "mml", null);
                 if ($mml === null) {
                     throw new HException("Missing mml");
                 } else {
                     $args->push($mml);
                 }
                 $keepMathml = com_wiris_system_PropertiesTools::getProperty($param, "keepMathml", "false");
                 if (_hx_index_of($keepMathml, "true", null) !== -1) {
                     $args->push(true);
                 } else {
                     $args->push(false);
                 }
                 $args->push($param);
                 $serviceText = Reflect::callMethod($publicServices, $serviceMethod, $args);
                 return $serviceText;
             } else {
                 if (_hx_index_of($serviceName, "latex2mathml", null) !== -1) {
                     $latex = com_wiris_system_PropertiesTools::getProperty($param, "latex", null);
                     if ($latex === null) {
                         throw new HException("Missing LaTeX");
                     } else {
                         $args->push($latex);
                     }
                     $keepLatex = com_wiris_system_PropertiesTools::getProperty($param, "saveLatex", "false");
                     if (_hx_index_of($keepLatex, "false", null) !== -1) {
                         $args->push(false);
                     } else {
                         $args->push(true);
                     }
                     $args->push($param);
                     $serviceText = Reflect::callMethod($publicServices, $serviceMethod, $args);
                     return $serviceText;
                 } else {
                     throw new HException("Unknow service " . $serviceName);
                 }
             }
         }
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $e = $_ex_;
         throw new HException($e->getMessage());
     }
 }
Exemplo n.º 21
0
 public function applyRow($r)
 {
     $this->currentRow = $r;
     $code = $this->actions[$r];
     $done = false;
     if ($r === 0 && $this->rcOffset > 0) {
         $done = true;
     } else {
         if ($code === "@@") {
             $this->preambleRow = $this->headerRow = $r;
             $this->applyHeader();
             $this->applyAction("@@");
             $done = true;
         } else {
             if ($code === "!") {
                 $this->preambleRow = $this->headerRow = $r;
                 $this->applyMeta();
                 $done = true;
             } else {
                 if (_hx_index_of($code, "@", null) === 0) {
                     $this->flags->addWarning("cannot usefully apply diffs with metadata yet: '" . _hx_string_or_null($code) . "'");
                     $this->preambleRow = $r;
                     $this->applyMetaRow($code);
                     if ($this->process_meta) {
                         $codes = _hx_explode("@", $code);
                         if ($codes->length > 0) {
                             $code = $codes[$codes->length - 1];
                         }
                     } else {
                         $this->meta_change = true;
                         $done = true;
                     }
                     $this->meta_change = true;
                     $done = true;
                 }
             }
         }
     }
     if ($this->process_meta) {
         return;
     }
     if (!$done) {
         $this->finishColumns();
         if ($code === "+++") {
             $this->applyAction($code);
         } else {
             if ($code === "---") {
                 $this->applyAction($code);
             } else {
                 if ($code === "+" || $code === ":") {
                     $this->applyAction($code);
                 } else {
                     if (_hx_index_of($code, "->", null) >= 0) {
                         $this->applyAction("->");
                     } else {
                         $this->lastSourceRow = -1;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 22
0
 static function cleanPath($path, $delimiter = null)
 {
     if ($delimiter === null) {
         $delimiter = "/";
     }
     $doubleDelimiter = _hx_string_or_null($delimiter) . _hx_string_or_null($delimiter);
     while (_hx_index_of($path, $doubleDelimiter, null) > -1) {
         if ($doubleDelimiter === "") {
             $path = implode(str_split($path), $delimiter);
         } else {
             $path = str_replace($doubleDelimiter, $delimiter, $path);
         }
     }
     return $path;
 }
Exemplo n.º 23
0
 static function indentXml($xml, $space)
 {
     $depth = 0;
     $opentag = new EReg("^<([\\w-_]+)[^>]*>\$", "");
     $autotag = new EReg("^<([\\w-_]+)[^>]*/>\$", "");
     $closetag = new EReg("^</([\\w-_]+)>\$", "");
     $cdata = new EReg("^<!\\[CDATA\\[[^\\]]*\\]\\]>\$", "");
     $res = new StringBuf();
     $end = 0;
     $start = null;
     $text = null;
     while ($end < strlen($xml) && ($start = _hx_index_of($xml, "<", $end)) !== -1) {
         $text = $start > $end;
         if ($text) {
             $res->add(_hx_substr($xml, $end, $start - $end));
         }
         $end = _hx_index_of($xml, ">", $start) + 1;
         $aux = _hx_substr($xml, $start, $end - $start);
         if ($autotag->match($aux)) {
             $res->add("\n");
             $i = null;
             $_g = 0;
             while ($_g < $depth) {
                 $i1 = $_g++;
                 $res->add($space);
                 unset($i1);
             }
             unset($_g);
             $res->add($aux);
             unset($i);
         } else {
             if ($opentag->match($aux)) {
                 $res->add("\n");
                 $i = null;
                 $_g = 0;
                 while ($_g < $depth) {
                     $i1 = $_g++;
                     $res->add($space);
                     unset($i1);
                 }
                 unset($_g);
                 $res->add($aux);
                 $depth++;
                 unset($i);
             } else {
                 if ($closetag->match($aux)) {
                     $depth--;
                     if (!$text) {
                         $res->add("\n");
                         $i = null;
                         $_g = 0;
                         while ($_g < $depth) {
                             $i1 = $_g++;
                             $res->add($space);
                             unset($i1);
                         }
                         unset($_g);
                         unset($i);
                     }
                     $res->add($aux);
                 } else {
                     if ($cdata->match($aux)) {
                         $res->add($aux);
                     } else {
                         haxe_Log::trace("WARNING! malformed XML at character " . _hx_string_rec($end, "") . ":" . $xml, _hx_anonymous(array("fileName" => "WXmlUtils.hx", "lineNumber" => 583, "className" => "com.wiris.util.xml.WXmlUtils", "methodName" => "indentXml")));
                         $res->add($aux);
                     }
                 }
             }
         }
         unset($aux);
     }
     return trim($res->b);
 }
Exemplo n.º 24
0
 static function greek2Latin($g)
 {
     $index = -1;
     if ($g < 100) {
         $index = _hx_index_of(com_wiris_util_xml_WCharacterBase::$greekLetters, "@00" . _hx_string_rec($g, "") . "@", null);
     } else {
         if ($g < 1000) {
             $index = _hx_index_of(com_wiris_util_xml_WCharacterBase::$greekLetters, "@0" . _hx_string_rec($g, "") . "@", null);
         } else {
             $index = _hx_index_of(com_wiris_util_xml_WCharacterBase::$greekLetters, "@" . _hx_string_rec($g, "") . "@", null);
         }
     }
     if ($index !== -1) {
         $s = _hx_substr(com_wiris_util_xml_WCharacterBase::$latinLetters, $index + 1, 4);
         return Std::parseInt($s);
     }
     return $g;
 }
Exemplo n.º 25
0
function _hx_string_call($s, $method, $params)
{
    if (!is_string($s)) {
        return call_user_func_array(array($s, $method), $params);
    }
    switch ($method) {
        case 'toUpperCase':
            return strtoupper($s);
        case 'toLowerCase':
            return strtolower($s);
        case 'charAt':
            return substr($s, $params[0], 1);
        case 'charCodeAt':
            return _hx_char_code_at($s, $params[0]);
        case 'indexOf':
            return _hx_index_of($s, $params[0], count($params) > 1 ? $params[1] : null);
        case 'lastIndexOf':
            return _hx_last_index_of($s, count($params) > 1 ? $params[1] : null, null);
        case 'split':
            return _hx_explode($params[0], $s);
        case 'substr':
            return _hx_substr($s, $params[0], count($params) > 1 ? $params[1] : null);
        case 'toString':
            return $s;
        default:
            throw new HException('Invalid Operation: ' . $method);
    }
}
 static function getMultiValueMapFromString($s)
 {
     $map = new haxe_ds_StringMap();
     $_g = 0;
     $_g1 = _hx_explode("&", $s);
     while ($_g < $_g1->length) {
         $part = $_g1[$_g];
         ++$_g;
         $index = _hx_index_of($part, "=", null);
         if ($index > 0) {
             $name = _hx_substr($part, 0, $index);
             $val = _hx_substr($part, $index + 1, null);
             ufront_core__MultiValueMap_MultiValueMap_Impl_::add($map, $name, $val);
             unset($val, $name);
         }
         unset($part, $index);
     }
     return $map;
 }
Exemplo n.º 27
0
 public function getSeparator($t, $t2, $root)
 {
     $sep = $root;
     $w = $t->get_width();
     $h = $t->get_height();
     $view = $t->getCellView();
     $_g = 0;
     while ($_g < $h) {
         $y = $_g++;
         $_g1 = 0;
         while ($_g1 < $w) {
             $x = $_g1++;
             $txt = $view->toString($t->getCell($x, $y));
             if ($txt === null) {
                 continue;
             }
             while (_hx_index_of($txt, $sep, null) >= 0) {
                 $sep = "-" . _hx_string_or_null($sep);
             }
             unset($x, $txt);
         }
         unset($_g1);
         unset($y);
     }
     if ($t2 !== null) {
         $w = $t2->get_width();
         $h = $t2->get_height();
         $_g2 = 0;
         while ($_g2 < $h) {
             $y1 = $_g2++;
             $_g11 = 0;
             while ($_g11 < $w) {
                 $x1 = $_g11++;
                 $txt1 = $view->toString($t2->getCell($x1, $y1));
                 if ($txt1 === null) {
                     continue;
                 }
                 while (_hx_index_of($txt1, $sep, null) >= 0) {
                     $sep = "-" . _hx_string_or_null($sep);
                 }
                 unset($x1, $txt1);
             }
             unset($_g11);
             unset($y1);
         }
     }
     return $sep;
 }
Exemplo n.º 28
0
 public function buildLimit($limitParam, $sb)
 {
     $sb->add(" LIMIT " . _hx_string_or_null(_hx_index_of($limitParam, ",", null) > -1 ? _hx_explode(",", $limitParam)->map(array(new _hx_lambda(array(&$limitParam, &$sb), "Model_17"), 'execute'))->join(",") : Std::string(Std::parseInt($limitParam))));
     return true;
 }
Exemplo n.º 29
0
 public function customRequest($post, $api, $sock = null, $method = null)
 {
     $url_regexp = new EReg("^(https?://)?([a-zA-Z\\.0-9-]+)(:[0-9]+)?(.*)\$", "");
     if (!$url_regexp->match($this->url)) {
         $this->onError("Invalid URL");
         return;
     }
     $secure = $url_regexp->matched(1) === "https://";
     if ($sock === null) {
         if ($secure) {
             $sock = new php_net_SslSocket();
         } else {
             $sock = new sys_net_Socket();
         }
     }
     $host = $url_regexp->matched(2);
     $portString = $url_regexp->matched(3);
     $request = $url_regexp->matched(4);
     if ($request === "") {
         $request = "/";
     }
     $port = $portString === null || $portString === "" ? $secure ? 443 : 80 : Std::parseInt(_hx_substr($portString, 1, strlen($portString) - 1));
     $data = null;
     $multipart = _hx_field($this, "file") !== null;
     $boundary = null;
     $uri = null;
     if ($multipart) {
         $post = true;
         $boundary = Std::string(Std::random(1000)) . Std::string(Std::random(1000)) . Std::string(Std::random(1000)) . Std::string(Std::random(1000));
         while (strlen($boundary) < 38) {
             $boundary = "-" . $boundary;
         }
         $b = new StringBuf();
         if (null == $this->params) {
             throw new HException('null iterable');
         }
         $»it = $this->params->keys();
         while ($»it->hasNext()) {
             $p = $»it->next();
             $b->add("--");
             $b->add($boundary);
             $b->add("\r\n");
             $b->add("Content-Disposition: form-data; name=\"");
             $b->add($p);
             $b->add("\"");
             $b->add("\r\n");
             $b->add("\r\n");
             $b->add($this->params->get($p));
             $b->add("\r\n");
         }
         $b->add("--");
         $b->add($boundary);
         $b->add("\r\n");
         $b->add("Content-Disposition: form-data; name=\"");
         $b->add($this->file->param);
         $b->add("\"; filename=\"");
         $b->add($this->file->filename);
         $b->add("\"");
         $b->add("\r\n");
         $b->add("Content-Type: " . "application/octet-stream" . "\r\n" . "\r\n");
         $uri = $b->b;
     } else {
         if (null == $this->params) {
             throw new HException('null iterable');
         }
         $»it = $this->params->keys();
         while ($»it->hasNext()) {
             $p = $»it->next();
             if ($uri === null) {
                 $uri = "";
             } else {
                 $uri .= "&";
             }
             $uri .= rawurlencode($p) . "=" . rawurlencode($this->params->get($p));
         }
     }
     $b = new StringBuf();
     if ($method !== null) {
         $b->add($method);
         $b->add(" ");
     } else {
         if ($post) {
             $b->add("POST ");
         } else {
             $b->add("GET ");
         }
     }
     if (_hx_field(_hx_qtype("haxe.Http"), "PROXY") !== null) {
         $b->add("http://");
         $b->add($host);
         if ($port !== 80) {
             $b->add(":");
             $b->add($port);
         }
     }
     $b->add($request);
     if (!$post && $uri !== null) {
         if (_hx_index_of($request, "?", 0) >= 0) {
             $b->add("&");
         } else {
             $b->add("?");
         }
         $b->add($uri);
     }
     $b->add(" HTTP/1.1\r\nHost: " . $host . "\r\n");
     if ($this->postData !== null) {
         $b->add("Content-Length: " . _hx_string_rec(strlen($this->postData), "") . "\r\n");
     } else {
         if ($post && $uri !== null) {
             if ($multipart || $this->headers->get("Content-Type") === null) {
                 $b->add("Content-Type: ");
                 if ($multipart) {
                     $b->add("multipart/form-data");
                     $b->add("; boundary=");
                     $b->add($boundary);
                 } else {
                     $b->add("application/x-www-form-urlencoded");
                 }
                 $b->add("\r\n");
             }
             if ($multipart) {
                 $b->add("Content-Length: " . _hx_string_rec(strlen($uri) + $this->file->size + strlen($boundary) + 6, "") . "\r\n");
             } else {
                 $b->add("Content-Length: " . _hx_string_rec(strlen($uri), "") . "\r\n");
             }
         }
     }
     if (null == $this->headers) {
         throw new HException('null iterable');
     }
     $»it = $this->headers->keys();
     while ($»it->hasNext()) {
         $h = $»it->next();
         $b->add($h);
         $b->add(": ");
         $b->add($this->headers->get($h));
         $b->add("\r\n");
     }
     $b->add("\r\n");
     if ($this->postData !== null) {
         $b->add($this->postData);
     } else {
         if ($post && $uri !== null) {
             $b->add($uri);
         }
     }
     try {
         if (_hx_field(_hx_qtype("haxe.Http"), "PROXY") !== null) {
             $sock->connect(new sys_net_Host(haxe_Http::$PROXY->host), haxe_Http::$PROXY->port);
         } else {
             $sock->connect(new sys_net_Host($host), $port);
         }
         $sock->write($b->b);
         if ($multipart) {
             $bufsize = 4096;
             $buf = haxe_io_Bytes::alloc($bufsize);
             while ($this->file->size > 0) {
                 $size = haxe_Http_4($this, $api, $b, $boundary, $buf, $bufsize, $data, $host, $method, $multipart, $port, $portString, $post, $request, $secure, $sock, $uri, $url_regexp);
                 $len = 0;
                 try {
                     $len = $this->file->io->readBytes($buf, 0, $size);
                 } catch (Exception $»e) {
                     $_ex_ = $»e instanceof HException ? $»e->e : $»e;
                     if (($e = $_ex_) instanceof haxe_io_Eof) {
                         break;
                     } else {
                         throw $»e;
                     }
                 }
                 $sock->output->writeFullBytes($buf, 0, $len);
                 $this->file->size -= $len;
                 unset($size, $len, $e);
             }
             $sock->write("\r\n");
             $sock->write("--");
             $sock->write($boundary);
             $sock->write("--");
         }
         $this->readHttpResponse($api, $sock);
         $sock->close();
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $e = $_ex_;
         try {
             $sock->close();
         } catch (Exception $»e) {
             $_ex_ = $»e instanceof HException ? $»e->e : $»e;
             $e1 = $_ex_;
         }
         $this->onError(Std::string($e));
     }
 }
Exemplo n.º 30
0
 public function findClient($param, $dataOnly = null)
 {
     $sql = new StringBuf();
     $phValues = new _hx_array(array());
     $cond = "";
     $limit = $param->get("limit");
     if (!Util::any2bool($limit)) {
         $limit = _hx_array_get(S::$conf->get("sql"), "LIMIT");
         if (!Util::any2bool($limit)) {
             $limit = 15;
         }
     }
     $globalCond = "";
     $reasons = "";
     $where = $param->get("where");
     if (strlen($where) > 0) {
         $where1 = _hx_explode(",", $where);
         $whereElements = $where1->filter(array(new _hx_lambda(array(&$cond, &$dataOnly, &$globalCond, &$limit, &$param, &$phValues, &$reasons, &$sql, &$where, &$where1), "model_ClientHistory_2"), 'execute'));
         $_g = 0;
         while ($_g < $where1->length) {
             $w = $where1[$_g];
             ++$_g;
             $wData = _hx_string_call($w, "split", array("|"));
             $_g1 = $wData[0];
             switch ($_g1) {
                 case "reason":
                     $reasons = $wData->slice(1, null)->join(" ");
                     break;
             }
             unset($_g1);
             unset($wData, $w);
         }
         if ($whereElements->length > 0) {
             $globalCond = $this->addCond($whereElements, $phValues);
         }
     }
     $sql->add("SELECT SQL_CALC_FOUND_ROWS * FROM(");
     $first = true;
     if (_hx_index_of($reasons, "AC04", null) > -1) {
         if ($first) {
             $first = false;
         }
         $sql->add("(SELECT d, e AS amount, SUBSTR(j,17,8) AS m_ID, z AS IBAN, \"AC04\" AS reason FROM `konto_auszug` WHERE i LIKE \"%AC04 KONTO AUFGELOEST%\" " . _hx_string_or_null($cond) . "  LIMIT 0,10000)");
         $sql->add("UNION ");
         $sql->add("(SELECT d, e AS amount, SUBSTR(k, 17, 8) AS m_ID, z AS IBAN, \"AC04\" AS reason FROM `konto_auszug` WHERE j LIKE \"%AC04 KONTO AUFGELOEST%\" " . _hx_string_or_null($cond) . "  LIMIT 0, 10000)");
     }
     if (_hx_index_of($reasons, "AC01", null) > -1) {
         if ($first) {
             $first = false;
         } else {
             $sql->add("UNION ");
         }
         $sql->add("(SELECT d, e AS amount, SUBSTR(j,17,8) AS m_ID, z AS IBAN, \"AC01\" AS reason FROM `konto_auszug` WHERE i LIKE \"%AC01 IBAN FEHLERHAFT%\" " . _hx_string_or_null($cond) . "  LIMIT 0,10000)");
         $sql->add("UNION ");
         $sql->add("(SELECT d, e AS amount, SUBSTR(k, 17, 8) AS m_ID, z AS IBAN, \"AC01\" AS reason FROM `konto_auszug` WHERE j LIKE \"%AC01 IBAN FEHLERHAFT%\" " . _hx_string_or_null($cond) . "  LIMIT 0, 10000)");
     }
     if (_hx_index_of($reasons, "MD06", null) > -1) {
         if ($first) {
             $first = false;
         } else {
             $sql->add("UNION ");
         }
         $sql->add("(SELECT d, e AS amount, SUBSTR(j,17,8) AS m_ID, z AS IBAN, \"MD06\" AS reason FROM `konto_auszug` WHERE i LIKE \"%MD06 WIDERSPRUCH DURCH ZAHLER%\" " . _hx_string_or_null($cond) . "  LIMIT 0,10000)");
         $sql->add("UNION ");
         $sql->add("(SELECT d, e AS amount, SUBSTR(k, 17, 8) AS m_ID, z AS IBAN, \"MD06\" AS reason FROM `konto_auszug` WHERE j LIKE \"%MD06 WIDERSPRUCH DURCH ZAHLER%\" " . _hx_string_or_null($cond) . "  LIMIT 0, 10000)");
     }
     if (_hx_index_of($reasons, "MS03", null) > -1) {
         if ($first) {
             $first = false;
         } else {
             $sql->add("UNION ");
         }
         $sql->add("(SELECT d, e AS amount, SUBSTR(j,17,8) AS m_ID, z AS IBAN, \"MS03\" AS reason FROM `konto_auszug` WHERE i LIKE \"%MS03 SONSTIGE GRUENDE%\" " . _hx_string_or_null($cond) . "  LIMIT 0,10000)");
         $sql->add("UNION ");
         $sql->add("(SELECT d, e AS amount, SUBSTR(k, 17, 8) AS m_ID, z AS IBAN, \"MS03\" AS reason FROM `konto_auszug` WHERE j LIKE \"%MS03 SONSTIGE GRUENDE%\" " . _hx_string_or_null($cond) . "  LIMIT 0, 10000)");
     }
     $sql->add(" )_lim " . _hx_string_or_null($globalCond) . " LIMIT " . _hx_string_rec($limit, ""));
     S::$my->select_db("fly_crm");
     $rows = $this->execute($sql->b, $phValues);
     if ($dataOnly) {
         return $rows;
     }
     $this->data = _hx_anonymous(array("count" => _hx_array_get($this->query("SELECT FOUND_ROWS()"), 0)["FOUND_ROWS()"], "page" => $param->exists("page") ? Std::parseInt($param->get("page")) : 1, "rows" => $rows));
     return $this->json_encode();
 }