function ping($dominio) { $comando = strstr(PHP_OS, 'LINUX') ? '-c 4' : NULL; system("ping {$comando} " . escapeshellarg($dominio), $dados); if ($dados[0] == '') { print_("{$op} Sem informações\n"); return FALSE; } return print_r($dados); }
function Start() { $form1 = $this->CreateForm(); $form2 = new jForm(); if (isset($_POST)) { $form1->SetData(); print_($form1->IsValid()); } $this->Widget = $form1; return $this->Present(); }
/** * Returns ID of a path * * @todo this has a limit of 1000 characters on $Path * @param string $Path * such as /role1/role2/role3 ( a single slash is root) * @return integer NULL */ function PathID($Path) { $Path = "root" . $Path; if ($Path[strlen($Path) - 1] == "/") { $Path = substr($Path, 0, strlen($Path) - 1); } $Parts = explode("/", $Path); $res = jf::SQL("SELECT node.ID,GROUP_CONCAT(parent.Title ORDER BY parent.Lft SEPARATOR '/' ) AS Path\n\t\t\t\tFROM {$this->TablePrefix()}rbac_{$this->Type()} AS node,\n\t\t\t\t{$this->TablePrefix()}rbac_{$this->Type()} AS parent\n\t\t\t\tWHERE node.Lft BETWEEN parent.Lft AND parent.Rght\n\t\t\t\tAND node.Title=?\n\t\t\t\tGROUP BY node.ID\n\t\t\t\tHAVING Path = ?\n\t\t\t\tORDER BY parent.Lft\n\t\t\t\t", $Parts[count($Parts) - 1], $Path); if ($res) { return $res[0]['ID']; } else { return null; } // TODO: make the below SQL work, so that 1024 limit is over $QueryBase = "SELECT n0.ID \nFROM {$this->TablePrefix()}rbac_{$this->Type()} AS n0"; $QueryCondition = "\nWHERE \tn0.Title=?"; for ($i = 1; $i < count($Parts); ++$i) { $j = $i - 1; $QueryBase .= "\nJOIN \t\t{$this->TablePrefix()}rbac_{$this->Type()} AS n{$i} ON (n{$j}.Lft BETWEEN n{$i}.Lft+1 AND n{$i}.Rght)"; $QueryCondition .= "\nAND \tn{$i}.Title=?"; // Forcing middle elements $QueryBase .= "\nLEFT JOIN \t{$this->TablePrefix()}rbac_{$this->Type()} AS nn{$i} ON (nn{$i}.Lft BETWEEN n{$i}.Lft+1 AND n{$j}.Lft-1)"; $QueryCondition .= "\nAND \tnn{$i}.Lft IS NULL"; } $Query = $QueryBase . $QueryCondition; $PartsRev = array_reverse($Parts); array_unshift($PartsRev, $Query); print_($PartsRev); $res = call_user_func_array("jf::SQL", $PartsRev); if ($res) { return $res[0]['ID']; } else { return null; } }
/** * Returns ID of a path * * @todo this has a limit of 1000 characters on $Path * @param string $Path * such as /role1/role2/role3 ( a single slash is root) * @return integer NULL */ public function pathId($Path) { $Path = "root" . $Path; if ($Path[strlen($Path) - 1] == "/") { $Path = substr($Path, 0, strlen($Path) - 1); } $Parts = explode("/", $Path); $Adapter = get_class(Jf::$Db); if ($Adapter == "mysqli" or $Adapter == "PDO" and Jf::$Db->getAttribute(PDO::ATTR_DRIVER_NAME) == "mysql") { $GroupConcat = "GROUP_CONCAT(parent.Title ORDER BY parent.Lft SEPARATOR '/')"; } elseif ($Adapter == "PDO" and Jf::$Db->getAttribute(PDO::ATTR_DRIVER_NAME) == "sqlite") { $GroupConcat = "GROUP_CONCAT(parent.Title,'/')"; } else { throw new \Exception("Unknown Group_Concat on this type of database: {$Adapter}"); } $res = Jf::sql("SELECT node.ID,{$GroupConcat} AS Path\n FROM {$this->tablePrefix()}{$this->type()} AS node,\n {$this->tablePrefix()}{$this->type()} AS parent\n WHERE node.Lft BETWEEN parent.Lft AND parent.Rght\n AND node.Title=?\n GROUP BY node.ID\n HAVING Path = ?\n ", $Parts[count($Parts) - 1], $Path); if ($res) { return $res[0]['ID']; } else { return null; } // TODO: make the below SQL work, so that 1024 limit is over $QueryBase = "SELECT n0.ID \nFROM {$this->tablePrefix()}{$this->type()} AS n0"; $QueryCondition = "\nWHERE n0.Title=?"; for ($i = 1; $i < count($Parts); ++$i) { $j = $i - 1; $QueryBase .= "\nJOIN {$this->tablePrefix()}{$this->type()} AS n{$i} ON (n{$j}.Lft BETWEEN n{$i}.Lft+1 AND n{$i}.Rght)"; $QueryCondition .= "\nAND n{$i}.Title=?"; // Forcing middle elements $QueryBase .= "\nLEFT JOIN {$this->tablePrefix()}{$this->type()} AS nn{$i} ON (nn{$i}.Lft BETWEEN n{$i}.Lft+1 AND n{$j}.Lft-1)"; $QueryCondition .= "\nAND nn{$i}.Lft IS NULL"; } $Query = $QueryBase . $QueryCondition; $PartsRev = array_reverse($Parts); array_unshift($PartsRev, $Query); print_($PartsRev); $res = call_user_func_array("Jf::sql", $PartsRev); if ($res) { return $res[0]['ID']; } else { return null; } }
<?php /** * Created by PhpStorm. * User: sp * Date: 24/11/15 * Time: 2:27 PM */ if ($_POST) { print_($_POST); }
private static function ListModules() { foreach (new \RecursiveIteratorIterator(self::$Archive) as $file) { print_($file->getPathname()); } }