Ejemplo n.º 1
0
 public function connect($func, $CDSA)
 {
     $conn = inf()->sap->conn;
     $conn["USER"] = $_SESSION["SAP_USERNAME"];
     $conn["PASSWD"] = $_SESSION["SAP_PASSWORD"];
     $this->user = $conn["USER"];
     $this->conn = saprfc_open($conn);
     if (!$this->conn) {
         throw new Exception("SAPRFC CONNECTION FAILED");
     }
     $this->func = saprfc_function_discover($this->conn, $func);
     if (!$this->func) {
         throw new Exception(sprintf("DISCOVERING INTERFACE OF FUNCTION %s MODULE FAILED", $func));
     }
     $this->conf = inf()->sap->conf;
     $rs = DB::lookup("vfs")->executeQuery("SELECT * FROM sap_conf WHERE AREA_SUB='%s'", $CDSA);
     if ($rs->next()) {
         $this->conf["BUS_AREA"] = $rs->get("BUS_AREA");
         $this->VR = $rs->get("VENDOR");
         $this->VC = $rs->get("VENDOR_CO");
         $this->CC = $rs->get("COST_CENTER");
         $this->PC = $rs->get("PROFIT_CENTER");
     } else {
         throw new Exception(sprintf("LOADING SAP CONFIG FOR FUNCTION %s MODULE FAILED", $func));
     }
 }
Ejemplo n.º 2
0
 /**
  * @ajax
  * @conn    vfs
  */
 public function POST($conn)
 {
     extract(dbm()->argv(inf()->rows->push("USR", array("type" => "alnum"))->getMap()));
     $_sql = "SELECT * FROM vfs_users";
     if (isset($USR)) {
         $_arg = array();
         array_push($_arg, sprintf("USR LIKE '%s'", "%" . $USR . "%"));
         array_push($_arg, sprintf("NAME LIKE '%s'", "%" . $USR . "%"));
         $_sql .= sprintf(" WHERE %s", implode(" OR ", $_arg));
     }
     $_sql .= sprintf(" LIMIT %s, %s", $offset, $limit);
     $rs = $conn->executeQuery($_sql);
     $rows = null;
     $no = $offset + 1;
     while ($rs->next()) {
         $rows[] = array(array("value" => $no++, "align" => "right"), array("value" => $rs->get("USR"), "lookup" => "vfs/forms/Users/", "observer" => "SEARCH", "publish" => sprintf("%s=>USR", $rs->get("USR")), "align" => "center"), array("value" => $rs->get("AREA"), "align" => "center"), array("value" => $rs->get("AREA_SUB"), "align" => "center"), $rs->get("NAME"), array("value" => $rs->getInt("SHR") == 1 ? "Y" : "N", "align" => "center"), array("value" => $rs->get("DEF"), "align" => "center"), array("value" => $rs->get("EXP"), "align" => "center"), array("value" => $rs->get("C_USER"), "align" => "center"), array("value" => $rs->get("C_DATE"), "align" => "center"));
     }
     $re = array("rows" => $rows);
     if ($offset == 0) {
         $rs = $conn->executeQuery(sprintf("SELECT COUNT(*) T FROM (%s) SQLT", $_sql));
         $re["total"] = $rs->next() ? $rs->getInt("T") : 0;
         $re["limit"] = $limit;
     }
     return $re;
 }
Ejemplo n.º 3
0
 /**
  * @ajax
  * @conn    vfs
  */
 public function POST($conn)
 {
     extract(dbm()->argv(inf()->rows->getMap()));
     $re = $rows = null;
     $no = $offset + 1;
     $rs = $conn->vfs_positions()->orderBy("ID_POSITION ASC")->limit($limit, $offset)->select();
     while ($rs->next()) {
         $rows[] = array($rs->setCell($no++, "right"), $rs->getCell("ID_POSITION", null, "center", "vfs/parameters/Positions/GET", $rs->httpQuery("ID_POSITION")), $rs->get("NAME"), $rs->setCell(sprintf("%s/%s", $rs->get("BP"), $rs->get("KP")), "center"), $rs->getCell("BEGDA", null, "center"), $rs->getCell("ENDDA", null, "center"));
     }
     $re["rows"] = $rows;
     if ($offset == 0) {
         $rs = $conn->executeQuery("SELECT COUNT(*) T FROM vfs_positions");
         $re["total"] = $rs->next() ? $rs->getInt("T") : 0;
         $re["limit"] = $limit;
     }
     return $re;
 }
Ejemplo n.º 4
0
 /**
  * @ajax
  * @conn    vfs
  */
 public function POST($conn)
 {
     extract(dbm()->argv(inf()->rows->getMap()));
     $re = $rows = null;
     $no = $offset + 1;
     $rs = $conn->vfs_clients_users()->orderBy("ID_USR, CID")->limit($limit, $offset)->select();
     while ($rs->next()) {
         $rows[] = array($rs->getCell("CID", null, "right", "vfs/parameters/ClientsUsers/GET", $rs->httpQuery("CID")), $rs->get("ID_USR"), $rs->getCell("BEGDA", null, "center"), $rs->getCell("ENDDA", null, "center"));
     }
     $re["rows"] = $rows;
     if ($offset == 0) {
         $rs = $conn->executeQuery("SELECT COUNT(*) T FROM vfs_clients_users");
         $re["total"] = $rs->next() ? $rs->getInt("T") : 0;
         $re["limit"] = $limit;
     }
     return $re;
 }
Ejemplo n.º 5
0
 /**
  * @ajax
  * @conn    vfs
  */
 public function POST($conn)
 {
     extract(dbm()->argv(inf()->rows->push("USR", array("type" => "alnum"))->getMap()));
     $_sql = "SELECT s.*, u.NAME FROM vfs_users_sessions s, vfs_users u WHERE s.USR=u.USR";
     if (isset($USR)) {
         $_usr = $USR . "%";
         $_sql .= sprintf(" AND s.USR LIKE '%s' OR u.NAME LIKE '%s'", $_usr, $_usr);
     }
     $_sql .= sprintf(" ORDER BY s.SES_TIME LIMIT %s, %s", $offset, $limit);
     $rs = $conn->executeQuery($_sql);
     $rows = null;
     while ($rs->next()) {
         $rows[] = array(array("name" => "SID_" . $rs->get("SES"), "value" => "1", "type" => "checkbox"), array("value" => $rs->get("USR"), "align" => "center"), $rs->get("NAME"), array("value" => $rs->get("SES_ADDR"), "align" => "center"), array("value" => $rs->get("SES_TIME"), "align" => "center"), array("value" => $rs->get("SES_DATE"), "align" => "center"));
     }
     $re = array("rows" => $rows);
     if ($offset == 0) {
         $rs = $conn->executeQuery(sprintf("SELECT COUNT(*) T FROM (%s) SQLT", $_sql));
         $re["total"] = $rs->next() ? $rs->getInt("T") : 0;
         $re["limit"] = $limit;
     }
     return $re;
 }
Ejemplo n.º 6
0
 /**
  * @ajax
  */
 public function POST()
 {
     $rows = null;
     $rows[] = array(array("value" => "DATASOURCE", "colspan" => 3, "style" => array("fontWeight" => "bold")));
     $rs = inf()->datasource->getMap();
     foreach ($rs as $k => $v) {
         $rows[] = array(array("value" => $k, "align" => "right"), array("value" => $v, "colspan" => 2));
     }
     $rows[] = array(array("value" => "SAP CONFIG", "colspan" => 3, "style" => array("fontWeight" => "bold")));
     $rs = inf()->sap->getMap();
     foreach ($rs["conf"] as $k => $v) {
         $rows[] = array(array("value" => $k, "align" => "right"), array("value" => $v, "colspan" => 2));
     }
     foreach ($rs["conn"] as $k => $v) {
         $rows[] = array(array("value" => $k, "align" => "right"), array("value" => $v, "colspan" => 2));
     }
     $rs = ini_get_all();
     unset($rs["url_rewriter.tags"]);
     $rows[] = array(array("value" => "PHP INI", "colspan" => 3, "style" => array("fontWeight" => "bold")));
     foreach ($rs as $k => $v) {
         $rows[] = array(array("value" => $k, "align" => "right"), $v["global_value"], $v["local_value"]);
     }
     return array("rows" => $rows);
 }
Ejemplo n.º 7
0
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author  wilaheng@gmail.com
 */
if (!defined("ENV")) {
    die("Undefined_ENV_Exception");
}
if (sizeof($_SERVER["argv"]) > 1) {
    $conn = DB::lookup("vfs");
    try {
        $conn->begin();
        $methodName = inf()->execute;
        $execTime = DB::constant("CURRENT_TIMESTAMP");
        for ($i = 1, $j = sizeof($_SERVER["argv"]); $i < $j; $i++) {
            $className = $_SERVER["argv"][$i];
            $logMessage = Service::get($className, $methodName)->getInstance()->{$methodName}();
            $conn->vfs_crons_logs(array("CMD" => $className, "LOG_MESSAGE" => $logMessage, "EXEC_TIME" => $execTime))->insert();
        }
        $conn->commit();
    } catch (Exception $e) {
        $conn->rollback();
        dbg()->log(NS_ERROR, $e->getMessage());
    }
}
Ejemplo n.º 8
0
 public static function push($instance)
 {
     $n = get_class($instance);
     if (isset(self::$singleton[$n])) {
         throw new Exception(inf()->singletonException($n));
     }
     self::$singleton[$n] = $instance;
 }
Ejemplo n.º 9
0
 private function createNamespace($_USR, $NAME, $AREA_CODE, $AREA_SUB_CODE, $POSITION)
 {
     $c0 = DB::lookup("vfs", true);
     $_GID = array();
     $_PKG = array();
     $_CID = array();
     $_ACL = array();
     $r2 = $c0->executeQuery("SELECT GRP, NAME FROM vfs_groups WHERE GRP='1100'");
     while ($r2->next()) {
         $_GID[$r2->getInt("GRP")] = $r2->get("NAME");
     }
     // only if not expired
     if ($_SESSION["EXP"] == false) {
         $r2 = $c0->executeQuery("SELECT GRP, NAME FROM vfs_users_groups WHERE USR='******'", $_USR);
         while ($r2->next()) {
             $_GID[$r2->getInt("GRP")] = $r2->get("NAME");
         }
     }
     $r3 = $c0->executeQuery("SELECT * FROM vfs_users_groups_classes WHERE GRP IN (%s)", implode(",", array_keys($_GID)));
     while ($r3->next()) {
         $PKG = $r3->getInt("PKG");
         $PID = $r3->getInt("PID");
         $CID = $r3->getInt("PKC");
         if ($r3->getInt("FTR")) {
             $this->features[] = $CID;
         }
         if (!isset($this->CID[$PKG])) {
             $this->CID[$PKG] = array();
         }
         if (!isset($_PKG[$r3->get("CODE")])) {
             $_PKG[$r3->get("CODE")] = $r3->get("PKG_NAME");
         }
         if (!isset($_ACL[$PKG])) {
             $_ACL[$PKG] = array();
         }
         $_ACL[$PKG][$CID] = $r3->get("ACL");
         $Ga = $r3->get("DISP");
         $this->CID[$PKG][$CID] = array("B" => $PID, "C" => $CID, "D" => $_ACL[$PKG][$CID], "G" => $r3->get("PKC_NAME"), "Ga" => $Ga, "H" => $r3->get("TYPE"), "PT" => $r3->get("TITLE"), "PD" => $r3->get("DESC"), "P" => $PID == 0 ? $r3->get("CODE") : $r3->get("PKC_NAME"));
     }
     foreach ($this->CID as $a => $b) {
         foreach ($b as $k => $v) {
             if ($v["B"]) {
                 if (isset($this->CID[$a][$v["B"]])) {
                     if (is_null($v["Ga"]) || empty($v["Ga"])) {
                         $v["Ga"] = $v["G"];
                     }
                     $this->CID[$a][$k]["P"] = $this->CID[$a][$v["B"]]["P"] . "/" . $v["G"] . "|" . $v["Ga"] . "@" . $v["H"];
                 } else {
                     unset($this->CID[$a][$k]);
                 }
             }
         }
     }
     $this->node = new api_TreeHelper();
     foreach ($this->CID as $a => $thiz) {
         foreach ($thiz as $k => $v) {
             $key = $v["C"];
             $this->TDA[$key] = array("T" => $v["PT"], "D" => $v["PD"]);
             $clz = $this->configure($v);
             if ($v["H"] != "C" && $v["H"] != "O") {
                 $acl = $this->toACL($v["D"]);
                 if (isset($this->ACL[$key])) {
                     $tmp = $this->mergeACL($this->ACL[$key], $acl);
                     $acl = $tmp;
                 }
                 $this->ACL[$clz] = $acl;
             }
         }
     }
     $_SESSION["ACL"] = $this->ACL;
     $_SESSION["TrH"] = $this->postProccess($this->node->pack());
     $_SESSION["SPC"] = $this->SPC;
     $_SESSION["context"] = $_PKG;
     $_SESSION["ATR"] = array("NAME" => $NAME, "LOKER" => sprintf("%s: %s, %s: %s (%s)", inf()->term->AREA, $AREA_CODE, inf()->term->AREA_SUB, $AREA_SUB_CODE, vfs_Service::subAreaName($AREA_CODE, $AREA_SUB_CODE)), "UNIT" => $POSITION);
     $_SESSION["USR"] = $_USR;
     $_SESSION["EXT"] = null;
     $ex = $c0->executeQuery("SELECT * FROM vfs_users_ext WHERE USR='******'", $_USR);
     while ($ex->next()) {
         $_SESSION["EXT"][$ex->get("AREA")][] = $ex->get("AREA_SUB");
     }
 }
Ejemplo n.º 10
0
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author  wilaheng@gmail.com
 */
if (!defined("REQUEST_URI")) {
    die("Undefined_ENV_Exception");
}
$inf = inf();
$className = $inf->session;
$methodName = $inf->execute;
$p = strpos(REQUEST_URI, "?");
$q = $p > 0 ? substr(REQUEST_URI, 0, $p) : REQUEST_URI;
$u = trim($q, FILE_SEPARATOR);
if (!empty($u)) {
    if (substr($q, -1) == FILE_SEPARATOR || strpos($u, FILE_SEPARATOR) === false) {
        $u .= "/HEAD";
    }
    $p = strrpos($u, FILE_SEPARATOR);
    $methodName = substr($u, $p + 1);
    $className = substr($u, 0, $p);
}
$req = req();
$chk = $req->ajax() ? false : REQUEST_METHOD == "POST";
Ejemplo n.º 11
0
Archivo: DB.php Proyecto: wilaheng/wila
 public static function lookup($n, $u = false)
 {
     $v = new stdClass();
     if (!isset(inf()->datasource->{$n})) {
         throw new Exception(sprintf("DataSource '%s' does not exist", $n));
     }
     if ($u) {
         if (isset(self::$_map[$n])) {
             return self::$_map[$n];
         }
     }
     $x = inf()->datasource->{$n};
     $i = parse_url($x);
     if (!isset($i["scheme"]) || !isset($i["path"])) {
         throw new Exception(sprintf("InvalidURL: %s", $x));
     }
     $q = null;
     if (isset($i["query"])) {
         parse_str($i["query"], $q);
     }
     $v = (object) array("u" => $i["user"], "p" => isset($i["pass"]) ? $i["pass"] : null, "h" => $i["host"], "c" => isset($i["port"]) ? $i["port"] : null, "d" => substr($i["path"], 1), "q" => $q, "f" => isset($i["fragment"]) ? $i["fragment"] : null);
     $t = $i["scheme"];
     require_once sprintf("api/DB.%s.php", $t);
     $n = sprintf("api_%s_Connection", $t);
     $c = new $n($v, $x);
     array_push(self::$conn, $c);
     if ($u) {
         self::$_map[$n] = $c;
     }
     return $c;
 }