Exemple #1
0
 public function __construct()
 {
     parent::__construct();
     $this->setMasterData($this->tbl, $this->fields, $this->prefix, $this->update_fields, $this->_uploadUrl);
     $this->setUserData();
     //var_dump($this->current_user);// $this->current_user;//die();
 }
 public static function createFromConf($conf)
 {
     if (!isset($conf["str"]) || !isset($conf["user"]) or !isset($conf["password"])) {
         throw new ServiceException("INVALID_CONFIGURATION", "No PDO database information defined");
     }
     if (isset($conf["table_prefix"])) {
         $tablePrefix = $conf["table_prefix"];
     } else {
         $tablePrefix = "";
     }
     $db = new PDODatabase($conf["str"], $conf["user"], $conf["password"], $tablePrefix);
     $db->connect();
     if (isset($conf["charset"])) {
         $db->setCharset($conf["charset"]);
     }
     return $db;
 }
Exemple #3
0
 protected function getBackend()
 {
     Logging::initialize(self::$CONFIGURATION, "Test");
     $this->responseHandler = new TestResponseHandler();
     $db = PDODatabase::createFromObj(self::$pdo, "sqlite");
     $settings = new Settings(self::$CONFIGURATION);
     $backend = new MollifyBackend($settings, $db, $this->responseHandler);
     //$backend->processRequest(new Request());
     return $backend;
 }
Exemple #4
0
 public function update($id, $arr)
 {
     //var_dump($_SESSION);
     //$objUser= new Users();
     global $objUser;
     $user = $objUser->getCurrentUser();
     $arr['updatedBy'] = $user['us01uin'];
     $arr['updatedOn'] = date('Y-m-d H:i:s');
     //var_dump('arr',$arr);
     return parent::update($id, $arr);
     //$this->update_core($id);
 }
Exemple #5
0
 function sendMailFromSytem($reciever_email, $sub, $msg)
 {
     //$objStoreSetting = new StoreSettings();
     //$row_store_setting = $objStoreSetting->selectStoreSettings();
     $objSetting = new PDODatabase();
     $objSetting->setMasterData('set01settings', array('uin', 'email', 'name'), 'set01');
     $setringData = $objSetting->getByID_v2(1);
     //echo $reciever_email;die();
     $sender_name = 'Itech Nepal ';
     //$row_store_setting['name'];
     $sender_email = '<' . $setringData['set01email'] . '>';
     //$row_store_setting['outgoing_mail'];
     $headers = 'MIME-Version: 1.0' . "\r\n";
     //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     $headers .= 'From: ' . $sender_name . '<' . $sender_email . '>' . "\r\n";
     //echo $msg;
     if (mail($reciever_email, $sub, $msg)) {
         return true;
     } else {
         return false;
     }
 }
Exemple #6
0
 public function __construct()
 {
     //$this->db = new PDODatabase();
     parent::__construct();
     $this->setMasterData_v2($this->tbl, $this->fields, $this->prefix, $this->uploadUrl, $this->file_fields);
     $x = $this->getById(1);
     //$x=$this->getFieldValues();
     //var_dump($this->db);
     //$x = ($this->getData());
     //var_dump($x);
     if (empty($x)) {
         die('Application Error');
     }
 }
 public function createConnection($settings)
 {
     if (!$settings->hasSetting("db")) {
         throw new ServiceException("INVALID_CONFIGURATION", "No database settings defined");
     }
     $db = $settings->setting("db");
     if (!isset($db["type"])) {
         throw new ServiceException("INVALID_CONFIGURATION", "No database type defined");
     }
     $type = $db["type"];
     if (strcasecmp($type, 'pdo') == 0) {
         require_once "db/pdo/PDODatabase.class.php";
         return PDODatabase::createFromConf($db);
     } else {
         if (strcasecmp($type, 'mysql') == 0) {
             require_once "db/mysql/MySQLIDatabase.class.php";
             return MySQLIDatabase::createFromConf($db);
         } else {
             if (strcasecmp($type, 'postgresql') == 0) {
                 require_once "db/postgresql/PostgresqlDatabase.class.php";
                 return PostgresqlDatabase::createFromConf($db);
             } else {
                 if (strcasecmp($type, 'sqlite3') == 0) {
                     require_once "db/sqlite/SQLite3Database.class.php";
                     return KloudspeakerSQLite3Database::createFromConf($db);
                 } else {
                     if (strcasecmp($type, 'sqlite') == 0) {
                         require_once "db/sqlite/SQLiteDatabase.class.php";
                         return KloudspeakerSQLiteDatabase::createFromConf($db);
                     } else {
                         throw new ServiceException("INVALID_CONFIGURATION", "Unsupported database type: [" . $type . "]");
                     }
                 }
             }
         }
     }
 }
Exemple #8
0
 /**
  * Basic Function to get value from get/post method in a recursive way along with array_walk
  * */
 public function __construct()
 {
     parent::__construct();
     $this->setMasterData($this->tbl, $this->fields, $this->prefix, $this->update_fields, $this->_uploadUrl, $this->file_fields);
 }
Exemple #9
0
 public static function createFromObj($db, $type)
 {
     $db = new PDODatabase($type, "", "", "", $db);
     $db->init();
     return $db;
 }
Exemple #10
0
<?php

$obj = new WatchList();
$objDb = new PDODatabase();
$tables = $objDb->Query('SHOW TABLES FROM ' . DB_NAME);
$data['module_Title'] = 'List of tables';
foreach ($tables as $table) {
    $tableData = $obj->getByTableName($table['Tables_in_db_hacker']);
    //var_dump('<pre>', $tableData, $table);
    if (empty($tableData)) {
        $result = $obj->insert(array('table' => $table['Tables_in_db_hacker']));
        //var_dump($result);
    }
}
/* * *************** these fields are required *********************************** */
//die();
//var_dump($MyModules);
$id = 0;
$message = '';
$data['module_Title'] = 'List of table';
$data['message'] = '';
if (isset($_GET['_Id'])) {
    $id = $_GET['_Id'];
    $data['_data'] = $obj->getByID($id);
} else {
    $data['_data'] = $obj->get();
    $data['list_fields'] = $obj->getListField();
}
//var_dump($data);
//$data['_extraModule'] = array(array('Commitments', 'Commit&action = Commitlist'));
$data['prefix'] = $obj->getPrefix();
Exemple #11
0
 public function init()
 {
     $this->db = PDODatabase::createFromConf($this->settings["db"]);
     $this->db->connect(FALSE);
     $this->dbUtil = new DatabaseUtil($this->db);
 }
Exemple #12
0
 public function update($id, $arr)
 {
     //var_dump($_SESSION);
     //$objUser= new Users();
     global $objUser, $objDb;
     $user = $objUser->getCurrentUser();
     $row = $this->getByID($arr['uin']);
     if ($arr['create']) {
         $action = 'INSERT';
         $qryFields = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . DB_NAME . "' AND TABLE_NAME = '" . $row['log01table'] . "'";
         $targeFields = $this->Query($qryFields);
         $qryCheck = "select trigger_name from information_schema.triggers where event_object_table='" . $row['log01table'] . "';";
         $triggerList = $this->Query($qryCheck);
         if (!$triggerList) {
             $sqlTrigger = "CREATE TRIGGER  `trigger" . date('Y-m-d H:i:s') . "` AFTER " . $action . " ON `" . $row['log01table'] . "`\nFOR EACH ROW\nBEGIN ";
             foreach ($targeFields as $field) {
                 $sqlTrigger .= "IF( NEW." . $field['COLUMN_NAME'] . " ) THEN\nINSERT INTO log02log( `log02action` , `log02tablename` ,`log02field` , `log02before` , `log02after` ) VALUES ( 'insert', '" . $row['log01table'] . "', '" . $field['COLUMN_NAME'] . "', NEW." . $field['COLUMN_NAME'] . " );END IF ;";
             }
             $sqlTrigger .= "END;";
             $this->Query($sqlTrigger);
         }
         foreach ($triggerList as $trigger) {
             $triggerName = $trigger['trigger_name'];
             $sqlTriggerType = "select TRIGGER_NAME from information_schema.triggers where event_object_table='" . $row['log01table'] . "' and event_manipulation in('" . $action . "');";
             $triggerType = $this->Query($sqlTriggerType);
             if (!$triggerType) {
                 $arr['updatedBy'] = $user['us01uin'];
                 $arr['updatedOn'] = date('Y-m-d H:i:s');
                 $sqlTrigger = "CREATE TRIGGER  `trigger" . date('Y-m-d H:i:s') . "` AFTER " . $action . " ON `" . $row['log01table'] . "`\nFOR EACH ROW\nBEGIN ";
                 foreach ($targeFields as $field) {
                     $sqlTrigger .= "IF( NEW." . $field['COLUMN_NAME'] . " ) THEN\nINSERT INTO log02log( `log02action` , `log02tablename` ,`log02field` , `log02before` , `log02after` ) VALUES ( 'insert', '" . $row['log01table'] . "', '" . $field['COLUMN_NAME'] . "', NEW." . $field['COLUMN_NAME'] . " );END IF ;";
                 }
                 $sqlTrigger .= "END;";
                 $this->Query($sqlTrigger);
             }
         }
     } elseif (!isset($arr['create'])) {
         $action = 'INSERT';
         $qryCheck = "select trigger_name from information_schema.triggers where event_object_table='" . $row['log01table'] . "';";
         $triggerList = $this->Query($qryCheck);
         foreach ($triggerList as $trigger) {
             $triggerName = $trigger['trigger_name'];
             $sqlTriggerType = "select TRIGGER_NAME from information_schema.triggers where event_object_table='" . $row['log01table'] . "' and event_manipulation in('" . $action . "');";
             $triggerType = $this->Query($sqlTriggerType);
             if ($triggerType) {
                 $sqlDropTrigger = "Drop trigger `" . $triggerName . "`";
                 $result = $this->Query($sqlDropTrigger);
             }
         }
         $arr['create'] = '0';
     }
     if ($arr['update']) {
         $action = 'UPDATE';
         $qryCheck = "select trigger_name from information_schema.triggers where event_object_table='" . $row['log01table'] . "';";
         $triggerList = $this->Query($qryCheck);
         if (!$triggerList) {
             $sqlTrigger = "CREATE TRIGGER  `trigger" . date('Y-m-d H:i:s') . "` AFTER " . $action . " ON `" . $row['log01table'] . "`\nFOR EACH ROW\nBEGIN ";
             foreach ($targeFields as $field) {
                 $sqlTrigger .= "IF( NEW." . $field['COLUMN_NAME'] . " ) THEN\nINSERT INTO log02log( `log02action` , `log02tablename` ,`log02field` , `log02before` , `log02after` ) VALUES ( 'insert', '" . $row['log01table'] . "', '" . $field['COLUMN_NAME'] . "', NEW." . $field['COLUMN_NAME'] . " );END IF ;";
             }
             $sqlTrigger .= "END;";
             $this->Query($sqlTrigger);
         }
         foreach ($triggerList as $trigger) {
             $triggerName = $trigger['trigger_name'];
             $sqlTriggerType = "select TRIGGER_NAME from information_schema.triggers where event_object_table='" . $row['log01table'] . "' and event_manipulation in('" . $action . "');";
             $triggerType = $this->Query($sqlTriggerType);
             var_dump('inserting update trigger', $triggerType);
             if (!$triggerType) {
                 $qryFields = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . DB_NAME . "' AND TABLE_NAME = '" . $row['log01table'] . "'";
                 $targeFields = $this->Query($qryFields);
                 $arr['updatedBy'] = $user['us01uin'];
                 $arr['updatedOn'] = date('Y-m-d H:i:s');
                 $sqlTrigger = "CREATE TRIGGER  `trigger" . date('Y-m-d H:i:s') . "` AFTER " . $action . " ON `" . $row['log01table'] . "`\nFOR EACH ROW\nBEGIN ";
                 foreach ($targeFields as $field) {
                     $sqlTrigger .= "IF( NEW." . $field['COLUMN_NAME'] . " ) THEN\nINSERT INTO log02log( `log02action` , `log02tablename` ,`log02field` , `log02before` , `log02after` ) VALUES ( 'insert', '" . $row['log01table'] . "', '" . $field['COLUMN_NAME'] . "', NEW." . $field['COLUMN_NAME'] . " );END IF ;";
                 }
                 $sqlTrigger .= "END;";
                 $this->Query($sqlTrigger);
             }
         }
     } elseif (!isset($arr['udpate'])) {
         $action = 'UPDATE';
         $qryCheck = "select trigger_name from information_schema.triggers where event_object_table='" . $row['log01table'] . "';";
         $triggerList = $this->Query($qryCheck);
         //var_dump('here', $triggerList, $arr);
         foreach ($triggerList as $trigger) {
             $triggerName = $trigger['trigger_name'];
             $sqlTriggerType = "select TRIGGER_NAME from information_schema.triggers where event_object_table='" . $row['log01table'] . "' and event_manipulation in('" . $action . "');";
             $triggerType = $this->Query($sqlTriggerType);
             if ($triggerType) {
                 $sqlDropTrigger = "Drop trigger `" . $triggerName . "`";
                 $result = $this->Query($sqlDropTrigger);
             }
         }
         $arr['update'] = '0';
     }
     return parent::update($id, $arr);
 }