public function tearDown() { $this->beforeApplicationDestroyed(function () { DB::disconnect(); }); parent::tearDown(); }
function test_1_create_table() { DB::query("CREATE TABLE `accounts` (\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `profile_id` INT NOT NULL,\n `username` VARCHAR( 255 ) NOT NULL ,\n `password` VARCHAR( 255 ) NULL ,\n `age` INT NOT NULL DEFAULT '10',\n `height` DOUBLE NOT NULL DEFAULT '10.0',\n `favorite_word` VARCHAR( 255 ) NULL DEFAULT 'hi',\n `birthday` TIMESTAMP NOT NULL\n ) ENGINE = InnoDB"); DB::query("CREATE TABLE `profile` (\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `signature` VARCHAR( 255 ) NULL DEFAULT 'donewriting'\n ) ENGINE = InnoDB"); $mysqli = DB::get(); DB::disconnect(); @$this->assert($mysqli->server_info === null); }
function smarty_modifier_getImg($string) { $db = new DB(); $db->connect(); $url = $db->getImg($string); $db->disconnect(); return $url; }
/** * Disconnects from the SQL server and cleans up the connection. */ protected function _disconnect() { if ($this->_connected) { $this->_connected = false; $this->_db->disconnect(); $this->_write_db->disconnect(); } }
/** * Disconnects from the SQL server and cleans up the connection. * * @access private * * @return boolean True on success, false on failure. */ function _disconnect() { if ($this->_connected) { $this->_connected = false; $this->_db->disconnect(); $this->_write_db->disconnect(); } return true; }
public function getTopology() { $conn = DB::connection('sqlsrvtest'); $select = "exec GetTopologyRing"; $result = $conn->select($select); $datos = json_encode($result); DB::disconnect('sqlsrvtest'); return $datos; }
public function test_successful_and_bad_login() { $db = new DB(); $db->connect(); $this->assertEquals($db->insertNewUserInTableUsers(new User("DavidTest", new Password("1234"))), true); $this->assertEquals($db->checkLogin(new User("DavidTest", new Password("1234"))), true); $this->assertEquals($db->checkLogin(new User("fake", new Password("1234"))), false); $this->assertEquals($db->checkLogin(new User("DavidTest", new Password("fake"))), false); $this->assertEquals($db->checkLogin(new User("fake", new Password("fake"))), false); $this->assertEquals($db->deleteUserWithName("DavidTest"), true); $db->disconnect(); }
function mystery_db_disconnect($connection = 'dbh') { // this rarely used function disconnects from the database. If you have non-persistent // connections, this is done automatically at the end of the script so there is no // reason to manually disconnect it. global $_MYSTERY; if (is_resource(@$_MYSTERY[$connection])) { $_MYSTERY[$connection] =& DB::disconnect(MYSTERY_DB_CONNECT_STRING); if (DB::isError($_MYSTERY[$connection])) { trigger_error('Could not connect to database: ' . $_MYSTERY[$connection]->getMessage() . "\n\n" . $_MYSTERY[$connection]->getDebugInfo(), E_USER_WARNING); } } }
public function __construct() { $this->TestSuite('All Tests'); $basedir = dirname(__FILE__) . '/'; foreach (self::$dirs as $dirname) { $this->addFile("{$basedir}{$dirname}/test_{$dirname}.php"); } Magnus::init('test'); DB::disconnect(); // since we auto-connect in Magnus::init() DB::$config['dbname'] = 'timber_test'; DB::connect(); }
private function resetearBD() { $db_final = Config::get('database.connections.migracion_sasyc.database'); $this->info("Verificando si sasyc_migracion existe"); $existe = DB::select("SELECT 1 FROM pg_database WHERE datname = '{$db_final}'"); if (!empty($existe)) { $this->info("Borrando base de datos " . $db_final); DB::statement('DROP DATABASE ' . $db_final); } $this->info("Cerrando conexion con la BD"); DB::disconnect('sasyc_migracion'); DB::disconnect('pgsql'); $this->info("Creando base de datos " . $db_final); DB::statement('CREATE DATABASE ' . $db_final); $this->info("Corriendo archivos de migrations y seeds"); $this->call('migrate', ['--database' => 'migracion_sasyc']); $this->call('db:seed', ['--database' => 'migracion_sasyc']); }
public function VerReportes() { $conn = DB::connection('DactoolDB'); $select = "select * from Reportes"; $result = $conn->select($select); $datos = array(); foreach ($result as $reporte) { $selectautor = "select NombreUsuario from Usuarios where IdUsuario = {$reporte->AutorReporte}"; $resultautor = $conn->select($selectautor); foreach ($resultautor as $autor) { $reporte->AutorReporte = $autor->NombreUsuario; } $datos[] = $reporte; } $datos = json_encode($datos); DB::disconnect('DactoolDB'); return View::make('ReportesController.listareportes', array('datos' => $datos)); }
public function VerNotificaciones() { $conn = DB::connection('DactoolDB'); $select = "select * from Notificaciones"; $result = $conn->select($select); $datos = array(); foreach ($result as $notificacion) { $selectautor = "select NombreUsuario from Usuarios where IdUsuario = {$notificacion->AutorNotificacion}"; $resultautor = $conn->select($selectautor); foreach ($resultautor as $autor) { $notificacion->AutorNotificacion = $autor->NombreUsuario; } $notificacion->Destinatarios = $this->GetDestinatarios($notificacion->IdNotificacion, $conn); $datos[] = $notificacion; } $datos = json_encode($datos); DB::disconnect('DactoolDB'); return View::make('NotificacionesController.listanotificaciones', array('datos' => $datos)); }
public function VerDependenciaScripts($idscript = null) { $conn = DB::connection('DactoolDB'); $select = "select * from ScriptsToScripts where IdScriptHijo = {$idscript}"; $result = $conn->select($select); $datos = array(); foreach ($result as $script) { $detalleScript = "select * from Scripts where IdScript = {$script->IdScriptPadre}"; $resultD = $conn->select($detalleScript); foreach ($resultD as $scriptD) { $scriptD->AutorScript = $this->getAuthor($scriptD->AutorScript, $conn); $datos[] = $scriptD; } } $selectS = "select * from Scripts where IdScript = {$idscript}"; $resultS = $conn->select($selectS); foreach ($resultS as $script) { $nameScript = $script->NombreScript; } $datosEncode = json_encode($datos); DB::disconnect('DactoolDB'); return View::make('ScriptsController.listascriptspadres', array('datos' => $datosEncode, 'hijo' => $nameScript)); }
function getSettings($p_mailbox) { global $g_use_database; global $g_voicemail_conf_path; global $g_db_host, $g_db_name, $g_db_user, $g_db_pass; if ($g_use_database == true) { // Authenticate with Database $my_db = new DB(); $my_db->construct($g_db_host, $g_db_name, $g_db_user, $g_db_pass); $my_db->connect(); $my_db->select(); $sql = "SELECT uniqueid,password,fullname,email,saycid,envelope,sendvoicemail,'delete' AS deleteafteremail FROM voicemail WHERE mailbox='{$p_mailbox}';"; //if ($g_debug) echo("SQL: $sql<br />\n"); $result = $my_db->query($sql); if ($result) { if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); $temp['FullName'] = $row['fullname']; $temp['Password'] = $row['password']; $temp['SayCallerId'] = $row['saycid']; $temp['Envelope'] = $row['envelope']; $temp['Email'] = $row['email']; $temp['SendToEmail'] = $row['sendvoicemail']; $temp['DeleteAfterEmail'] = $row['deleteafteremail']; } mysql_free_result($result); } $my_db->disconnect(); } else { // cat the voicemail.conf file, grep for mailbox $cmd = "cat " . $g_voicemail_conf_path . " | grep " . $p_mailbox; $last_line = exec($cmd, $retvalue); // parse out the info - 1001 => 1001,Chris Carey,chris@chriscarey.com list($mailbox, $everything_else) = split('=>', $last_line); list($password, $name, $email) = split(",", $everything_else); // Settings from voicemail.conf $temp['FullName'] = $name; $temp['Password'] = $password; $temp['SayCallerId'] = "true"; $temp['Envelope'] = "true"; $temp['Email'] = $email; $temp['SendToEmail'] = "true"; $temp['DeleteAfterEmail'] = "true"; } return $temp; }
public function getReporteEstadosGrafica() { $pais = Input::get('filtro') ? Input::get('filtro') : null; $conn = DB::connection('atlas'); $datosa = array(); $select = "SELECT DI.Location as Pais, TM.Description, COUNT(*) as Val \n FROM [dbo].[DashboardGraficasInterfaces] DI \n LEFT JOIN TypeMedio TM ON TM.ID = DI.IdTypeMedio\t\n WHERE CAST(DI.[Date] AS DATE) = (SELECT MAX(CAST(DI.[Date] AS DATE)) FROM [DashboardGraficasInterfaces] DI WITH (NOLOCK)) \n AND DI.Grafica = 0 "; if ($pais['Pais']) { $select .= "and DI.Location = '{$pais['Pais']}' "; } $select .= "GROUP BY DI.Location, TM.Description \n ORDER BY Pais "; $result = $conn->select($select); $labels = array('COLOMBIA', 'ARGENTINA', 'BRASIL', 'MEXICO', 'PERU', 'CHILE', 'ECUADOR', 'PANAMA', 'PUERTORICO', 'URUGUAY', 'USA', 'VENEZUELA'); $series = array('Cobre', 'Fibra', 'Wireless', 'NoAplica'); foreach ($result as $estado) { $datosa[$estado->Pais][$estado->Description] = $estado->Val; } $labels = isset($pais['Pais']) ? array($pais['Pais']) : $labels; $datospre = array(); foreach ($series as $serie) { foreach ($labels as $label) { if (isset($datosa[$label][$serie])) { $datospre[$serie][] = intval($datosa[$label][$serie]); } else { $datospre[$serie][] = null; } } } $datos = array(); foreach ($datospre as $value) { $datos['data'][] = $value; } $datos['labels'] = $labels; $datos['series'] = $series; $datos = json_encode($datos); DB::disconnect('atlas'); return $datos; }
| The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); /* |-------------------------------------------------------------------------- | CSRF Protection Filter |-------------------------------------------------------------------------- | | The CSRF filter is responsible for protecting your application against | cross-site request forgery attacks. If this special token in a user | session does not match the one given in this request, we'll bail. | */ Route::filter('csrf', function () { if (Session::token() !== Input::get('_token')) { throw new Illuminate\Session\TokenMismatchException(); } }); Route::filter('disconnect', function ($route, $request, $response, $parameter = '') { if ($parameter !== '') { // 手动断开数据库连接 DB::disconnect($parameter); } });
function goRecurseDatabases() { global $_CONFIG; include_once "classes/mysqlBackup.class.php"; $return = array(); $data['dbHostname'] = $_CONFIG['mysql_host']; $data['dbUsername'] = $_CONFIG['mysql_user']; $data['dbPassword'] = $_CONFIG['mysql_pass']; $data['dbDatabase'] = $_CONFIG['mysql_database']; $data['excludedTables'] = ""; $data['recordsPerSession'] = $_CONFIG['recordsPerSession']; $data['dbCompatibility'] = $_REQUEST['dbbackup_comp']; //version compatibility $data['dbDropSyntax'] = $_REQUEST['dbbackup_drop']; //Add DROP Syntax $data['TEMP_DUMP_FILE'] = $_CONFIG['temp_dir'] . "/database-sql.sql"; $data['TEMP_DBPROCESS_FILE'] = $_CONFIG['temp_dir'] . "/.database"; if ($_REQUEST['mode'] == "start") { //do the initial table readings //foreach($_REQUEST['excltables'] as $value) //check if any tables are excluded, we will only export their structure $data['excludedTables'] = $_REQUEST['excltables']; //foreach($_REQUEST['excltables'] as $value) //check if any other databases are included $extradb = $_REQUEST['databases_incl']; $db = new DB(); $db->init($data, 1); $db->writeTempFile(); $db->disconnect(); //building the .database temp file if (is_array($extradb)) { foreach ($extradb as $database) { $data['dbDatabase'] = $database; $data['TEMP_DUMP_FILE'] = $_CONFIG['temp_dir'] . "/" . $data['dbDatabase'] . "-sql.sql"; $db = new DB(); $db->init($data); $db->writeTempFile(); $db->disconnect(); } } return; } //we start the backup process for the actual database $data['dbDatabase'] = ""; $dumpfile = ""; $data['dbCompatibility'] = $_REQUEST['dbbackup_comp']; //version compatibility $data['dbDropSyntax'] = $_REQUEST['dbbackup_drop']; //Add DROP Syntax $startAtLine = intval($_REQUEST['startAtLine']); $startAtRecord = intval($_REQUEST['startAtRecord']); $dumpfile = $_REQUEST['dumpfile']; $db = new DB(); $db->init($data); $records = $db->resetcountRecords(); while ($records < $_CONFIG['recordsPerSession'] and !$return['finished'] and !$return['newDump'] and !$return['endDump']) { $return = $db->processIncremental($startAtLine, $startAtRecord, $dumpfile); $records = $db->getcountRecords(); $startAtLine = $return['startAtLine']; $startAtRecord = $return['startAtRecord']; $dumpfile = $return['dumpfile']; } /*if($return['newDump']) print_r($return);*/ /*$startAtLine = $return['startAtLine']; $startAtRecord = $return['startAtRecord']; $dumpfile = $return['dumpfile'];*/ $return['dbbackup_comp'] = $_REQUEST['dbbackup_comp']; $return['dbbackup_drop'] = $_REQUEST['dbbackup_drop']; if ($return['databaseName'] == "###enddump###") { $return['databaseName'] = ""; } $db->disconnect(); echo json_encode($return); exit; }
function mailSend($Data, $tempData) { global $clientMailto, $clientSubject, $clientMailBody, $guestMailFrom, $guestMailFromName, $guestSubject, $guestMailBody, $cliantEnv, $guestMailBodyMobile, $mailcc; //DBからclientMailtoを取得・DBに内容を書き込み if ($this->extramode == "online") { //DB接続 global $dbHost, $dbId, $dbPassword, $dbName, $userTb, $qaTb; $db = new DB(); $db->connect($dbHost, $dbId, $dbPassword, $dbName); //個別データを取得 $sql = 'SELECT mailAddress FROM ' . $userTb; $dataArray = $db->getArray($sql, 'ASSOC'); if (is_array($dataArray)) { foreach ($dataArray as $line) { $mailtoArray[] = $line['mailAddress']; } $clientMailto = implode(",", $mailtoArray); } else { //DBから取れない時はエラー return false; } //書き込み $insertData['name'] = sqlite_escape_string($Data['name']); $insertData['pref'] = sqlite_escape_string($Data['pref']); $insertData['mail'] = sqlite_escape_string($Data['mail']); $insertData['categoryID'] = sqlite_escape_string($Data['categoryID']); $insertData['title'] = sqlite_escape_string($Data['title']); $insertData['question'] = sqlite_escape_string($Data['question']); $insertData['entryDay'] = date("Y/m/d"); $insertData['dbUpDay'] = date("Y/m/d"); if (!insertDB($dbName, $qaTb, $insertData)) { return false; } $db->disconnect(); } //送信内容作成 $clientText = $this->tempReplace($clientMailBody, $tempData); $Data['email'] = isset($Data['email']) && $Data['email'] ? $Data['email'] : $Data['mail']; if ($cliantEnv == 'PC' && $guestMailBodyMobile) { if (isset($Data['domain']) && $Data['domain']) { if ($this->mailAddressMobileCheck($Data['email'] . '@' . $Data['domain'])) { $guestText = $this->tempReplace($guestMailBodyMobile, $tempData); } else { $guestText = $this->tempReplace($guestMailBody, $tempData); } } else { if ($this->mailAddressMobileCheck($Data['email'])) { $guestText = $this->tempReplace($guestMailBodyMobile, $tempData); } else { $guestText = $this->tempReplace($guestMailBody, $tempData); } } } else { $guestText = $this->tempReplace($guestMailBody, $tempData); } //mailfrom $Data['name'] = isset($Data['nameA']) && $Data['nameA'] ? $Data['nameA'] . " " . $Data['nameB'] : $Data['name']; if (isset($Data['domain']) && $Data['domain']) { $clientMailFrom = 'From: ' . mb_encode_mimeheader($Data['name'] . '様') . '<' . ($Data['email'] . '@' . $Data['domain'] ? $Data['email'] . '@' . $Data['domain'] : $clientMailto) . '>'; } else { $clientMailFrom = 'From: ' . mb_encode_mimeheader($Data['name'] . '様') . '<' . ($Data['email'] ? $Data['email'] : $clientMailto) . '>'; } $guestMailTo = $Data['email']; $guestMailFrom = 'From: ' . mb_encode_mimeheader($guestMailFromName) . '<' . $guestMailFrom . '>'; //mailcc if ($mailcc != false) { mb_send_mail($mailcc, $clientSubject, mb_convert_kana($clientText, "KV"), $clientMailFrom); usleep(100000); } //メール送信 if (mb_send_mail($clientMailto, $clientSubject, mb_convert_kana($clientText, "KV"), $clientMailFrom)) { usleep(100000); if ($guestText) { if (mb_send_mail($guestMailTo, $guestSubject, mb_convert_kana($guestText, "KV"), $guestMailFrom)) { return true; } else { return false; } } else { return true; } } else { return false; } }
* https://developers.google.com/apis-explorer/#p/youtube/v3/ * https://developers.google.com/youtube/v3/ * https://console.developers.google.com */ ini_set('max_execution_time', 60 * 15); require_once 'autoload.php'; set_include_path(get_include_path() . PATH_SEPARATOR . 'libs/google-api/src'); require_once 'Google/autoload.php'; $view = new stdClass(); try { DB::connect(); $y = new YoutubeFinder(); $singers = DataManager::getAllSingers(); foreach ($singers as $singer) { $videos = $y->findVideoByTitle($singer['name']); DataManager::addClipsForSinger($singer['id'], $videos); } unset($singer); $viewCount = array(); $clips = DataManager::getAllClips(); foreach ($clips as $clip) { $viewCount[$clip['id']] = $y->getViewCountForVideo($clip['youtube_id']); } unset($clip); DataManager::updateViewCount($viewCount); $view->data = DataManager::getClipsBySinger(); DB::disconnect(); include 'index.tpl'; } catch (\Exception $e) { exit($e->getMessage()); }
public function tearDown() { \DB::disconnect(); parent::tearDown(); }
extract($_POST); $sql = 'SELECT u.id_usuario, u.id_tipo_usuario, u.nombre, u.correo, u.telefono, u.activo FROM usuarios u WHERE u.usuario="' . $login_username . '" AND u.pass="******" LIMIT 1'; #echo $sql; $bd->query($sql); if ($bd->resultExist()) { $user = @$bd->fetchObj(); if ($user->activo == 0) { echo 2; } else { $_SESSION['userid'] = $user->id_usuario; $_SESSION['nombreUser'] = $user->nombre; $_SESSION['correoUser'] = $user->correo; $_SESSION['tipoUser'] = $user->id_tipo_usuario; $_SESSION['time_login'] = time(); echo 1; } } else { echo 0; } $bd->disconnect(); } else { echo "error: " . $bd->get_errors(); } } else { echo "error2: " . $bd->get_errors(); }
<?php set_include_path(__DIR__); require_once 'lib/db.php'; require_once 'lib/competition.php'; include 'header.php'; //session_start(); //printf("Session username = %s\n", $_SESSION['username']); $con = DB::connect(); $result = competition::selectCompetitions($con); $year = "2014"; echo "<h1>Competitions " . $year . "</h1>"; while ($row = mysqli_fetch_array($result)) { $date = date_create($row['Start']); if (date_format($date, 'Y') == $year) { printf("\n <a href='view-matches.php?id=%s'>%s</a><br/>\n <label>%s - %s</label></br>\n", $row['ID'], $row['Name'], $row['Start'], $row['End']); } } mysqli_free_result($result); DB::disconnect($con); include 'footer.php';
public function autoServiceid() { $conn = DB::connection('sqlsrv'); $select = "select top 100 id from Services s where s.stateid not in(4,7)"; $result = $conn->select($select); foreach ($result as $value) { $datos[] = $value->id; } $datos = json_encode($datos); DB::disconnect('mysql'); return $datos; }
public function __destruct() { if (!DB::isError($this->conn)) { $this->conn->disconnect(); } }
$db->set_session_picked_champion_id($session_id, $role, $champ_id); break; case "setpickedplayerid": $session_id = urlvar("session_id"); $role = urlvar("role"); $player_id = urlvar("player_id"); $db->set_session_picked_player_id($session_id, $role, $player_id); break; case "setstarterid": $session_id = urlvar("session_id"); $role = urlvar("role"); $starter_id = urlvar("starter_id"); $starter_number = urlvar("starter_number"); $db->set_session_starter_id($session_id, $role, $starter_id, $starter_number); break; case "setenemychampid": $session_id = urlvar("session_id"); $enemy_champion_id = urlvar("enemy_champion_id"); $champion_number = urlvar("champion_number"); $db->set_session_enemy_champion_id($session_id, $enemy_champion_id, $champion_number); break; case "setbanid": $session_id = urlvar("session_id"); $ban_champ_id = urlvar("ban_champ_id"); $teamban = urlvar("teamban"); $ban_number = urlvar("ban_number"); $db->set_session_ban_id($session_id, $ban_champ_id, $teamban, $ban_number); break; } $db->disconnect();
public static function disconnect() { if (Dal::$_connection) { DB::disconnect(); } }
/** * 清除缓存,按需重载 * @param string $cachename * @return boolean */ protected function removeCache($cachename) { $db = new DB(); $db->connect(); if ($db->removeCache($cachename)) { $db->disconnect(); return true; } return false; }
/** * Validate database credentials for SQLite * Try to connect and verify if database name exists */ public function ajax_check_sqlite_credentials() { $db_file = $_POST['file']; $xml = new \SimpleXMLElement('<response></response>'); // Missing anything? if (!isset($db_file)) { $xml->addChild('status', 0); $xml_error = $xml->addChild('error'); $xml_error->addChild('id', '#databasefile'); $xml_error->addChild('message', _t('The database file was left empty.')); } if (!isset($xml_error)) { if ($db_file == basename($db_file)) { // The filename was given without a path $db_file = Site::get_path('user', true) . $db_file; } if (!is_writable(dirname($db_file))) { $xml->addChild('status', 0); $xml_error = $xml->addChild('error'); $xml_error->addChild('id', '#databasefile'); $xml_error->addChild('message', _t('Cannot write to %s directory. SQLite requires that the directory that holds the DB file be writable by the web server.', array(dirname($db_file)))); } elseif (file_exists(Site::get_path('user', true) . $db_file) && !is_writable(Site::get_path('user', true) . $db_file)) { $xml->addChild('status', 0); $xml_error = $xml->addChild('error'); $xml_error->addChild('id', '#databasefile'); $xml_error->addChild('message', _t('Cannot write to %s. The SQLite data file is not writable by the web server.', array($db_file))); } else { // Can we connect to the DB? $pdo = 'sqlite:' . $db_file; $connect = DB::connect($pdo, null, null); // Disconnect, but no longer delete the file - it could already have contents! DB::disconnect(); switch ($connect) { case true: // We were able to connect to an existing database file. $xml->addChild('status', 1); break; default: // We can't create the database file, send an error message. $xml->addChild('status', 0); $xml_error = $xml->addChild('error'); // TODO: Add error codes handling for user-friendly messages $xml_error->addChild('id', '#databasefile'); $xml_error->addChild('message', $connect->getMessage()); } } } $xml = $xml->asXML(); ob_clean(); header("Content-type: application/xml"); header("Cache-Control: no-cache"); print $xml; }
public function SysLogEquipo() { $device = Input::get('id'); $ip = Equipos::find($device)->ifaddr; $conn = DB::connection('SysLog'); $select = "select fo, host, facility, priority, level, program, msg from logs where host='{$ip}' order by fo"; $result = $conn->select($select); $datos = array(); foreach ($result as $syslog) { $datos[] = $syslog; } $datos = json_encode($datos); DB::disconnect('SysLog'); return $datos; }
/** * Disconnect */ private function disconnect() { \DB::disconnect(); }