コード例 #1
0
ファイル: Login.class.php プロジェクト: xpeknw/vc
 public static function register($params)
 {
     if (!isset($GLOBALS[TUNA_RW]) || !$GLOBALS[TUNA_RW] || $GLOBALS[TUNA_RW] instanceof Error) {
         $GLOBALS[TUNA_RW] = WBB_Database::load(TUNA_RW);
     }
     $clean = array();
     $clean_update = array();
     $sql = "SELECT MAX(`id`) as id FROM  `" . DB_TUNA . "`.`users` ";
     $GLOBALS[TUNA_RW]->query($sql);
     while ($row = $GLOBALS[TUNA_RW]->fetchAssoc()) {
         $next_id = $row['id'];
     }
     $params['id'] = (string) ($next_id + 1);
     /* validate values using the "forswitch" technique */
     foreach ($params as $key => $value) {
         switch ($key) {
             case 'id':
             case 'email':
                 if (!is_string($value) || strlen($value) == 0) {
                     throw new Error(400, 'Incorrect ' . $key . ' Value');
                 }
                 $clean[$key] = '`' . $key . '` = "' . $GLOBALS[TUNA_RW]->escapeString($value) . '"';
                 break;
             case 'password':
                 if (!is_string($value) || strlen($value) == 0) {
                     throw new Error(400, 'Incorrect ' . $key . ' Value');
                 }
                 $clean[$key] = '`' . $key . '` = "' . crypt($value, 'armium') . '"';
                 break;
             default:
                 throw new Error(400, 'Incorrect Param ' . $key);
                 break;
         }
     }
     if (count($clean) <= 0) {
         throw new Error(400, 'No data to save');
     }
     $sql_set = implode(',', $clean);
     $sql_update = implode(',', $clean_update);
     $sql = 'INSERT INTO `' . DB_TUNA . '`.`users` SET ' . $sql_set . ", `creation` = NOW()";
     try {
         // return true;
         $GLOBALS[TUNA_RW]->query($sql);
         $permissions[] = 'grant';
         $permissions[] = 'is_med';
         $permissions[] = $params['id'];
         $profile['id'] = $params['id'];
         $profile['name'] = 'Cambiame por tu nombre';
         User::update_permissions($permissions);
         User::update_profile($profile);
     } catch (Error $e) {
         throw new Error(409, 'El Ususario ya existe!');
     }
 }
コード例 #2
0
ファイル: Calendar.class.php プロジェクト: xpeknw/vc
 public function remove_date($params)
 {
     if (!isset($GLOBALS[TUNA_RO]) || !$GLOBALS[TUNA_RO] || $GLOBALS[TUNA_RO] instanceof Error) {
         $GLOBALS[TUNA_RO] = WBB_Database::load(TUNA_RO);
     }
     $sql = 'DELETE FROM `' . DB_TUNA . '`.`user_calendar` WHERE id = "' . $params['id'] . '" LIMIT 1';
     if ($GLOBALS[TUNA_RO]->query($sql)) {
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: Inventory.class.php プロジェクト: xpeknw/vc
 public function add_qty($params)
 {
     if (!isset($GLOBALS[TUNA_RO]) || !$GLOBALS[TUNA_RO] || $GLOBALS[TUNA_RO] instanceof Error) {
         $GLOBALS[TUNA_RO] = WBB_Database::load(TUNA_RO);
     }
     $result = array();
     $sql = 'UPDATE `' . DB_TUNA . '`.`user_' . $params['list'] . '_inv` SET `' . $params['list'] . '_qty` = (`' . $params['list'] . '_qty` + 10) WHERE `id` = ' . $params['id'] . ' LIMIT 1';
     if ($GLOBALS[TUNA_RO]->query($sql)) {
         return true;
     }
     return false;
 }
コード例 #4
0
ファイル: Consult.class.php プロジェクト: xpeknw/vc
 public function get_list($params)
 {
     if (!isset($GLOBALS[TUNA_RO]) || !$GLOBALS[TUNA_RO] || $GLOBALS[TUNA_RO] instanceof Error) {
         $GLOBALS[TUNA_RO] = WBB_Database::load(TUNA_RO);
     }
     $condition = '';
     if (isset($params['id']) && $params['id'] != '') {
         $condition = ' AND paciente_id = ' . $params['id'];
     }
     $result = array();
     $sql = 'SELECT * FROM `' . DB_TUNA . '`.`consults` WHERE `consult_status` <> "deleted" ' . $condition;
     $GLOBALS[TUNA_RO]->query($sql);
     if ($GLOBALS[TUNA_RO]->numRows() > 0) {
         $result['data'] = $GLOBALS[TUNA_RO]->fetchAll();
     }
     return $result;
 }
コード例 #5
0
ファイル: Profile.class.php プロジェクト: xpeknw/vc
 public function get_sub_account($params)
 {
     if (!isset($GLOBALS[TUNA_RO]) || !$GLOBALS[TUNA_RO] || $GLOBALS[TUNA_RO] instanceof Error) {
         $GLOBALS[TUNA_RO] = WBB_Database::load(TUNA_RO);
     }
     $result = array('data' => array(), 'totals' => 0);
     $sql = 'SELECT SQL_CALC_FOUND_ROWS * FROM `' . DB_TUNA . '`.`user_sub_accounts` WHERE `user_id` = ' . $params['user_id'];
     //$sql .= $condition;
     //$sql .= ' ORDER BY `name` LIMIT '.$offset.','.$limit;
     $GLOBALS[TUNA_RO]->query($sql);
     if ($GLOBALS[TUNA_RO]->numRows() > 0) {
         while ($row = $GLOBALS[TUNA_RO]->fetchAssoc()) {
             if ($row != null) {
                 $result['data'][] = $row;
             }
         }
         $GLOBALS[TUNA_RO]->query('SELECT FOUND_ROWS() as `total`');
         $row = $GLOBALS[TUNA_RO]->fetchAssoc();
         $result['total'] = $row['total'];
     }
     return $result;
 }
コード例 #6
0
ファイル: Utils.class.php プロジェクト: xpeknw/vc
 public function __construct()
 {
     if (!isset($GLOBALS[DB_TUNA]) || !$GLOBALS[DB_TUNA] || $GLOBALS[DB_TUNA] instanceof Error) {
         $GLOBALS[DB_TUNA] = WBB_Database::load(DB_TUNA);
     }
 }
コード例 #7
0
ファイル: Product.class.php プロジェクト: xpeknw/vc
 public static function update($parameters)
 {
     $message = "";
     // $parameters['user'] = json_decode($parameters['user']);
     // foreach ($parameters['user']->permissions as $key => $value) {
     // 	$permissions[] = $value->description;
     // }
     // if(!in_array('is_shop_admin',$permissions ) && (int)($parameters['id']))
     // {
     // 	throw new Error( 400, 'You dont have the required permissions to add the Product Id');
     // }
     // if(!in_array('is_woa',$permissions ) && !(int)($parameters['id']))
     // {
     // 	throw new Error( 400, 'You dont have the required permissions to add the Gamespace');
     // }
     unset($parameters['user']);
     if (!isset($GLOBALS[TUNA_RW]) || !$GLOBALS[TUNA_RW] || $GLOBALS[TUNA_RW] instanceof Error) {
         $GLOBALS[TUNA_RW] = WBB_Database::load(TUNA_RW);
     }
     $clean = array();
     $clean_update = array();
     /* validate values using the "forswitch" technique */
     foreach ($parameters as $key => $value) {
         switch ($key) {
             case 'id':
             case 'name':
                 if (!is_string($value) || strlen($value) == 0) {
                     throw new Error(400, 'Incorrect Name Value');
                 }
                 $clean[$key] = '`' . $key . '` = "' . $GLOBALS[TUNA_RW]->escapeString($value) . '"';
                 break;
             case 'status':
                 if (!is_bool($value)) {
                     throw new Error(400, 'Incorrect Status Value');
                 }
                 $clean[$key] = '`' . $key . '` = "' . (bool) $value . '"';
                 break;
             default:
                 throw new Error(400, 'Incorrect Param ' . $key);
                 break;
         }
         /* Prepare "on duplicate key update" */
         $clean_update[$key] = '`' . $key . '` = VALUES(`' . $key . '`)';
     }
     if (count($clean) <= 0) {
         throw new Error(400, 'No data to save');
     }
     $sql = "SELECT * FROM  `%s`.`products` WHERE {$clean['name']} OR {$clean['id']}";
     $sql = sprintf($sql, DB_TUNA);
     $GLOBALS[TUNA_RW]->query($sql);
     /* name-id validation to avoid collisions on these */
     if ($var = $GLOBALS[TUNA_RW]->fetchALL()) {
         if (count($var) == 2) {
             throw new Error(409, 'One of your values (maybe both) is in use; try changing one of them.');
         }
         if (strtolower($var[0]["name"]) == strtolower($parameters["name"])) {
             if ($var[0]["status"] == "available") {
                 throw new Error(409, 'Product name already exist.');
             } else {
                 if ($var[0]["id"] == $parameters["id"]) {
                     $message .= "{$parameters['name']} rehabilitated; current status: {$var[0]['status']}.";
                     $found = true;
                 } else {
                     $message .= "id changed from {$var[0]['id']} to {$parameters['id']}; current status: {$var[0]['status']}.";
                 }
             }
         } else {
             $message .= "name changed from {$var[0]['name']} to {$parameters['name']}; current status: {$var[0]['status']}.";
         }
     }
     $sql_set = implode(',', $clean);
     $sql_update = implode(',', $clean_update);
     $sql = 'INSERT INTO `' . DB_TUNA . '`.`products` SET ' . $sql_set . ", `creation` = NOW()";
     $sql .= ' ON DUPLICATE KEY UPDATE ' . $sql_update . ", `status` = 'available'";
     if ($GLOBALS[TUNA_RW]->query($sql)) {
         if ($message) {
             $desc = array("Event" => "Product update", "Message" => $message);
             TunaLog::info_log(__CLASS__, __FUNCTION__, $_SERVER['REMOTE_USER'], $desc);
         }
         $desc = array('id' => $parameters['id'], 'name' => $parameters['name']);
     }
 }
コード例 #8
0
ファイル: User.class.php プロジェクト: xpeknw/vc
 public function get_subaccounts($params)
 {
     $condition = ' * ';
     if (isset($params['qty']) && $params['qty']) {
         $condition = ' COUNT(id) as accounts ';
     }
     if (!isset($GLOBALS[TUNA_RW]) || !$GLOBALS[TUNA_RW] || $GLOBALS[TUNA_RW] instanceof Error) {
         $GLOBALS[TUNA_RW] = WBB_Database::load(TUNA_RW);
     }
     $result = array();
     $sql = 'SELECT ' . $condition . ' FROM `' . DB_TUNA . '`.`user_sub_accounts` WHERE user_id = ' . $params['id'];
     $GLOBALS[TUNA_RW]->query($sql);
     $result = $GLOBALS[TUNA_RW]->fetchAssoc();
     return $result['accounts'];
 }
コード例 #9
0
ファイル: ClientId.class.php プロジェクト: xpeknw/vc
 public static function check_notifications($parameters)
 {
     try {
         $client_id = $parameters['client_id'];
         if (!isset($GLOBALS[TUNA_RO]) || !$GLOBALS[TUNA_RO] || $GLOBALS[TUNA_RO] instanceof Error) {
             $GLOBALS[TUNA_RO] = WBB_Database::load(TUNA_RO);
         }
         $sql = 'SELECT * FROM `' . DB_TUNA . '`.`client_ids_monitoring` WHERE `client_id`="' . $client_id . '" LIMIT 1';
         $GLOBALS[TUNA_RO]->query($sql);
         if ($GLOBALS[TUNA_RO]->numRows() > 0) {
             $sql = 'UPDATE `' . DB_TUNA . '`.`client_ids_monitoring` SET `status`="deleted" WHERE `client_id`="' . $client_id . '" LIMIT 1';
             $GLOBALS[TUNA_RW]->query($sql);
             return true;
         }
     } catch (Event $e) {
         throw new Error(400, 'Error generating notification!');
     }
 }
コード例 #10
0
ファイル: Registry.class.php プロジェクト: xpeknw/vc
 public function delete_registry($params)
 {
     if (!isset($GLOBALS[TUNA_RO]) || !$GLOBALS[TUNA_RO] || $GLOBALS[TUNA_RO] instanceof Error) {
         $GLOBALS[TUNA_RO] = WBB_Database::load(TUNA_RO);
     }
     $result = array();
     $sql = 'UPDATE `' . DB_TUNA . '`.`user_registry` SET `registry_status` = "deleted" WHERE `id` = ' . $params['id'] . ' LIMIT 1';
     if ($GLOBALS[TUNA_RO]->query($sql)) {
         return true;
     }
     return false;
 }