/** * Fetches column values from database. * * Examples: * ```php * // fetches a single column * $col0 = $r->fetch("col0"); * * // fetches multiple columns * list($col0, $col1, $col2) = $this->fetch(["col0", "col1", "col2"]); * ``` * * @param array|mixed $colPaths Column paths * * @return mixed|mixed[] */ public function fetch($colPaths = []) { $ret = []; // method overloading $isArrayColPaths = is_array($colPaths); if (!$isArrayColPaths) { $colPaths = [$colPaths]; } if (count($colPaths) > 0) { // registers columns and fetches values $cols = $this->_regColumns($colPaths); foreach ($cols as $col) { array_push($ret, $col->getValue()); } if (!$isArrayColPaths) { $ret = $ret[0]; } } else { if ($this->_primaryKey->hasChanged()) { // gets the columns that haven't changed $columns = array_diff($this->_columns, $this->_getChangedColumns()); // fills columns if (count($columns) > 0) { $row = $this->_db->query($this->_getSelectStatement($columns)); foreach ($columns as $column) { $column->setDbValue($row[$column->getName()]); } } } $this->_isUpdated = true; } return $ret; }
function selectSomeSingle($page,$fileds,$field,$id){ $connector = new DbConnector(); $query = 'SELECT '.$fields.' FROM '.$page.' WHERE '.$field.'='.$id; $sqlrs=$connector->query($get_data); while ($row=$connector->fetchArray($sqlrs)) { $data['id'] = $row['id']; }; return $data; }
function updateField($table,$setFields,$where,$db_location, $db_user,$db_pass,$db_db){ $connector = new DbConnector($db_location, $db_user,$db_pass,$db_db); $query = 'UPDATE '.$table.' SET '.$setFields.' WHERE '.$where; if($connector->query($query)){ $data = 'Your update was successful!'; }else{ $data = 'Sorry, there was an error with your update :('; }; return $data; }
function deleteRow($table,$where,$db_location, $db_user,$db_pass,$db_db){ $connector = new DbConnector($db_location, $db_user,$db_pass,$db_db); $query = 'DELETE FROM '.$table.' WHERE '.$where; if($connector->query($query)){ $data = 'Your post was deleted succesfully'; }else{ $data = 'Sorry, there was an error with your deletion :(.'; }; return $data; }
function insertNew($table,$fields,$values,$db_location, $db_user,$db_pass,$db_db){ $connector = new DbConnector($db_location, $db_user,$db_pass,$db_db); $query = 'INSERT INTO '.$table.' ('.$fields.') VALUES('.$values.')'; if($connector->query($query)){ $data = 'Your post was entered succesfully'; }else{ $data = 'Sorry, there was an error with your post :(.'; }; return $data; }
/** * Fetches column values from database. * * @return void */ public function fetch() { if ($this->_primaryKey->hasChanged()) { // gets the columns that haven't changed $columns = array_diff($this->_columns, $this->_getChangedColumns()); // fills columns if (count($columns) > 0) { $row = $this->_db->query($this->_getSelectStatement($columns)); foreach ($columns as $column) { $column->setDbValue($row[$column->getName()]); } } } $this->_isUpdated = true; }
<td width="31%">Amount</td> <td width="25%">By</td> <td width="34%">Date</td> <td width="34%">Status</td> <td width="10%">Type</td> </tr> <tbody> <?php $perpage = 20; if (!isset($_GET['p']) || $_GET['p'] == 0) { $screen = 0; } else { $screen = $_GET['p'] - 1; } $start = $screen * $perpage; $db->query("select * from tbl_withdrawal order by date desc limit " . $start . "," . $perpage); if ($db->rownum() > 0) { while ($res = $db->Fetcharray()) { ?> <tr> <td width="31%"><?php echo $res['amount']; ?> </td> <td width="25%"> <?php $db2->queryres("select * from tbl_user where user_id='" . $res['user_id'] . "'"); echo $db2->res['username']; ?> </td> <td width="34%"><?php
$prepare->execute(); header('Location: prize.php'); } elseif (isset($_GET['a']) && $_GET['a'] == 'prize_downd') { $pid = $_GET['pid']; $prepare = $db->mysqli->prepare("update tbl_prize set chance=chance-2 where prize_id=? "); $prepare->bind_param('i', $pid); $prepare->execute(); header('Location: prize.php'); } elseif (isset($_GET['a']) && $_GET['a'] == 'prize_remove') { $pid = $_GET['pid']; $prepare = $db->mysqli->prepare("delete from tbl_prize where prize_id=? "); $prepare->bind_param('i', $pid); $prepare->execute(); header('Location: prize.php'); } else { $db->query("select * from tbl_prize order by chance desc"); /* q = select val, id from prizes order by val desc $t = 0; for each (a in q) { a.val = a.val * 100 + t; t += a; } int r = Random.Next(t); for each (a in q) { if (r < a.val)
<?php require_once "maincore.php"; require_once "includes/dbconnector.class.php"; $db = new DbConnector(); $pid = $_POST['PAYMENT_ID']; if ($_POST['PAYMENT_STATUS'] == 'Complete') { $db->query("update tbl_dobate set status=1 where md5(donate)='{$pid}' "); $_SESSION['succ']['donate'] = true; } else { $_SESSION['succ']['penging'] = true; } header('Location:donate.php');
require_once "includes/solvemedialib.php"; require_once "includes/dbconnector.class.php"; $db = new DbConnector(); if (isset($_POST['claim'])) { $solvemedia_response = solvemedia_check_answer($verkey, $_SERVER["REMOTE_ADDR"], $_POST['adcopy_challenge'], $_POST['adcopy_response'], $hashkey); if ($solvemedia_response->is_valid) { $db2->query("select * from tbl_prize order by chance desc "); while ($res2 = $db2->fetchArray()) { $prize .= $res2['prize'] . '*' . $res2['chance'] . ','; } if (!isset($_SESSION['prize'])) { $_SESSION['prize'] = chance_creator($prize); } $db->queryres("select * from tbl_config where header='timer'"); $timer = NOW + $db->res['value'] * 60; $db->query("update tbl_user set credit=credit+'" . $_SESSION['prize'] . "',reset='{$timer}',ip='{$ip}' where user_id='{$uid}'"); $rid = $userdet['parent_id']; if ($rid) { $db->queryres("select * from tbl_config where header='referral_percent'"); $profit = $_SESSION['prize'] * $db->res['value'] / 100; $db->query("update tbl_user set credit=credit+'{$profit}' where user_id='{$rid}'"); } $_SESSION['user']['win'] = $_SESSION['prize']; unset($_SESSION['prize']); header('Location:index.php'); } else { unset($_SESSION['succ']); unset($_SESSION['error']); $_SESSION['error']['capt'] = true; header('Location:index.php?er=captcha'); }
?> "><?php echo $v; ?> </a>, <? }?> </p> </div> </div> <hr /> <? }?> <div class="blog_pagination"> <? $connector = new DbConnector($db_location, $db_user,$db_pass,$db_db); $countquery="select id from blog_form"; $sqlr=$connector->query($countquery); $pageCount = ceil($connector->getNumrows($sqlr)/ $blog_limit); ?> <? if(($pageOn) != 0){?> <a href="<?php echo $base_url; ?> blog/<?php echo $_REQUEST['id'] - 1; ?> "><- PREVIOUS</a> <? }?> <? if($_REQUEST['id'] <= 3){ for($i=1;$i<=5;$i++){?> <? if($i == $_REQUEST['id']){?>
break; case "DRK": $fees = $amount - ($amount / 100.0 + 0.001); break; case "mDRK": $fees = $amount - ($amount / 100.0 + 1); break; } $db->queryres("SELECT * FROM tbl_config where header='currencymin' "); if ($amount >= $db->res['value']) { if ($userdet['credit'] >= $amount) { $prepare = $db->mysqli->prepare("insert into tbl_withdrawal (user_id,amount,type) values (?,?,1) "); $prepare->bind_param('id', $uid, $fees); $prepare->execute(); $prepare->close(); $db->query("update tbl_user set credit=credit-'{$amount}' where user_id='{$uid}'"); header('Location:withdrawal.php'); } else { $_SESSION['error']['over'] = true; } } else { $_SESSION['error']['less'] = true; } header('Location:withdrawal.php'); } elseif (isset($_POST['asmoney'])) { if (isset($_POST['wallet'])) { $ausername = $_POST['wallet']; $prepare = $db->mysqli->prepare("select user_id from tbl_user where ausername=?"); $prepare->bind_param('s', $ausername); $prepare->execute(); $prepare->store_result();
} } $db = new DbConnector(); $db->queryres("select * from tbl_config where header='currency'"); $faucetcurrency = $db->res['value']; $db->queryres("select * from tbl_config where header='pusername'"); $pusername = $db->res['value']; $db->queryres("select * from tbl_config where header='papiname'"); $papiname = $db->res['value']; $db->queryres("select * from tbl_config where header='ppassword'"); $ppassword = $db->res['value']; $db->queryres("select * from tbl_config where header='requestcount'"); $requestcount = $db->res['value']; $api = new AsmoneyAPI($pusername, $papiname, $ppassword); //Change to mili bitcoin because asmoney get currencies based on milicoin $db->query("select * from tbl_withdrawal where status=0"); $btcaddresses = array(); $btcamounts = array(); $withdrawalid = array(); while ($res = $db->fetchArray()) { $currency = $faucetcurrency; if ($res['type'] == 0) { $db2->queryres("select * from tbl_user where user_id='" . $res['user_id'] . "'"); $ausername = $db2->res['ausername']; $amount = ChangetoMili($res['amount'], $currency); $r = $api->Transfer($ausername, $amount, $currency, 'Withdrawal'); // Payment memo echo $r['result']; if ($r['result'] == APIerror::OK) { $batchno = $r['value']; $db2->query("update tbl_withdrawal set status=1,reccode='{$batchno}' where withdrawal_id='" . $res['withdrawal_id'] . "'"); echo "Withdrawal has been proceessed with bactch number " . $batchno . "<br>";
<input type="hidden" name="PAYMENT_MEMO" value="Donate" /> <input type="hidden" name="PAYMENT_ID" value="<?php echo md5($insid); ?> " /> <input type="hidden" class="form-control" name="PAYMENT_AMOUNT" value="<?php echo $_POST['PAYMENT_AMOUNT']; ?> "> </form> <script>document.getElementById('frm').submit();</script> Please wait... <?php } else { $with = array(); $db->query("select * from tbl_donate where user_id='{$uid}' order by date desc"); while ($res = $db->fetchArray()) { $ar = array('amount' => $res['amount'], 'date' => date('Y/m/d', $res['date']), 'status' => $res['status']); array_push($with, $ar); } $smarty->assign('with', $with); $db->queryres("select * from tbl_config where header='donate_min'"); $smarty->assign('dmin', $db->res['value']); if (isset($_SESSION['error']['over'])) { $smarty->assign('over', true); unset($_SESSION['error']); } if (isset($_SESSION['error']['donate'])) { $smarty->assign('ed', true); unset($_SESSION['error']); }
<?php include "dbConnector.php"; $connector = new DbConnector(); $idNewArtist = trim(strtolower($_POST['idNewArtist'])); //$idNewArtist = mysql_escape_string($idNewArtist); //$query = "SELECT username FROM usernameCheck WHERE username = '******' LIMIT 1"; $query = "SELECT Artist FROM Artist WHERE Artist LIKE '{$idNewArtist}%' LIMIT 1"; $result = $connector->query($query); $num = mysql_num_rows($result); echo $num; mysql_close();
protected function updatePassword() { $sql = "UPDATE " . $this->obj->dbTable() . " SET" . " password="******" WHERE " . $this->obj->dbUid() . " = '" . $this->obj->getUid() . "'"; DbConnector::query($sql); }
/* case 'get_categories': include_once('cl/DbConnector.php'); $con= new DbConnector(); $sql='SELECT catid,label FROM categories WHERE enable=1 ORDER BY sort'; $result=json_encode($con->query($sql)); //header('Content-type: application/json'); break; */ case 'get_dests': include 'cl/DbConnector.php'; $con = new DbConnector(); $out = new stdClass(); header('Content-type: application/json'); $cats = $con->query('SELECT * FROM categories WHERE enable=1 ORDER BY sort'); foreach ($cats as $val) { $val->id = (int) $val->id; } $out->cats = $cats; $dests = $con->query('SELECT * FROM destinations ORDER by LOWER(name)'); foreach ($dests as $val) { $val->id = (int) $val->id; } $out->dests = $dests; echo json_encode($out); break; } function inserClick($get, $db) { $type = substr($get['type'] . $get['val'], 0, 10);
public static function updateManyAtOnce($action, $arr) { if (!count($arr)) { return false; } $sta = ''; switch ($action) { case 'report': $sta = 'deadline = DATE_ADD(deadline, INTERVAL 1 DAY)'; break; case 'open': $sta = 'status=0'; break; case 'close': $sta = 'status=1'; break; case 'valid': $sta = 'status=2'; break; case 'archive': $sta = 'archived=1'; break; case 'unarchive': $sta = 'archived=0'; break; } if ($sta) { $filter = 'id IN (' . implode(',', $arr) . ')'; DbConnector::query('UPDATE task SET ' . $sta . ' WHERE ' . $filter); return true; } return false; }
<?php require_once "header.php"; require_once "../includes/dbconnector.class.php"; $db = new DbConnector(); if (isset($_POST['save'])) { $db->query("update tbl_config set value='" . $_POST['referral_percent'] . "' where header='referral_percent'"); $db->query("update tbl_config set value='" . $_POST['timer'] . "' where header='timer'"); $db->query("update tbl_config set value='" . $_POST['currency'] . "' where header='currency'"); $db->query("update tbl_config set value='" . $_POST['donate_type'] . "' where header='donate_type'"); $db->query("update tbl_config set value='" . $_POST['donate_min'] . "' where header='donate_min'"); $db->query("update tbl_config set value='" . $_POST['privkey'] . "' where header='privkey'"); $db->query("update tbl_config set value='" . $_POST['verkey'] . "' where header='verkey'"); $db->query("update tbl_config set value='" . $_POST['hashkey'] . "' where header='hashkey'"); $db->query("update tbl_config set value='" . $_POST['pusername'] . "' where header='pusername'"); $db->query("update tbl_config set value='" . $_POST['papiname'] . "' where header='papiname'"); $db->query("update tbl_config set value='" . $_POST['ppassword'] . "' where header='ppassword'"); $db->query("update tbl_config set value='" . $_POST['STORE_NAME'] . "' where header='STORE_NAME'"); $db->query("update tbl_config set value='" . $_POST['AsMoneymin'] . "' where header='AsMoneymin'"); $db->query("update tbl_config set value='" . $_POST['currencymin'] . "' where header='currencymin'"); $db->query("update tbl_config set value='" . $_POST['minimum_donate'] . "' where header='minimum_donate'"); $db->query("update tbl_config set value='" . $_POST['sci_username'] . "' where header='sci_username'"); $db->query("update tbl_config set value='" . $_POST['sci_pass'] . "' where header='sci_pass'"); $db->query("update tbl_config set value='" . $_POST['requestcount'] . "' where header='requestcount'"); header('Location:setting.php'); } else { ?> <section id="main-content"> <section class="wrapper">
<?php /** * @author asmalindi * @copyright 2011 */ // Get the PHP file containing the DbConnector class require_once 'DbConnector.php'; // Create an instance of DbConnector $connector = new DbConnector(); // Use the query function of DbConnector to run a database query $result = $connector->query('SELECT firstname FROM customers'); // Get the result $row = $connector->fetchArray($result); // Show it to the user echo $row['firstname'];
END; $fp = fopen('includes/system.class.php', "w"); fwrite($fp, $config); fclose($fp); include_once "includes/dbconnector.class.php"; $db = new DbConnector(); $filename = 'phpfaucet.sql'; $templine = ''; $lines = file($filename); foreach ($lines as $line) { if (substr($line, 0, 2) == '--' || $line == '') { continue; } $templine .= $line; if (substr(trim($line), -1, 1) == ';') { $db->query($templine); $templine = ''; } } echo "Tables imported successfully"; echo "<br>Do not resubmit this file.<br>DELETE IMMEDIATELY."; } else { ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head>
<?php require_once "header.php"; require_once "../includes/dbconnector.class.php"; $db = new DbConnector(); if (isset($_GET['a']) && $_GET['a'] == 'deac') { $did = $_GET['did']; $db->query("update tbl_donate set status=1 where donate='{$did}'"); header('Location:donate.php'); } elseif (isset($_GET['a']) && $_GET['a'] == 'ac') { $did = $_GET['did']; $db->query("update tbl_donate set status=2 where donate='{$did}'"); header('Location:donate.php'); } else { $db2->queryres("select * from tbl_config where header='minimum_donate'"); ?> <section id="main-content"> <section class="wrapper"> <div class="row"> <div class="col-lg-12"> <section class="panel"> <div class="panel-body progress-panel"> <div class="task-progress"> <h1>Donate</h1> </div> </div>
\t\treturn \$settings; \t} } END; chmod('templates_c', 0777); chmod('configs/dbinfo.php', 0666); $fp = fopen('configs/dbinfo.php', "w"); fwrite($fp, $content); fclose($fp); $sql = fopen('install.sql', 'r'); $schema = fread($sql, filesize("install.sql")); $queries = explode(';', $schema); $queries = array_filter($queries); array_pop($queries); foreach ($queries as $q) { $db->query($q); } fclose($sql); header('Location: install.php?step=3'); die; } else { $_SESSION['error']['db'] = true; header('Location: install.php?step=2'); die; } } else { ?> <div class="panel panel-primary"> <div class="panel-heading">Faucet Installer - Database</div> <form action="" method="post">