Example #1
3
 /**
  * Finish the processor
  * @param string $type finish type, supports: NORMAL, BROKEN, TIMEOUT
  */
 public function finish($type = 'NORMAL')
 {
     $this->finished = true;
     if ($type === 'BROKEN') {
         $this->res->error = Connection::getLastError();
     } else {
         if ($type !== 'NORMAL') {
             $this->res->error = ucfirst(strtolower($type));
         }
     }
     // gzip decode
     $encoding = $this->res->getHeader('content-encoding');
     if ($encoding !== null && strstr($encoding, 'gzip')) {
         $this->res->body = Client::gzdecode($this->res->body);
     }
     // parser
     $this->res->timeCost = microtime(true) - $this->timeBegin;
     $this->cli->runParser($this->res, $this->req, $this->key);
     // conn
     if ($this->conn) {
         // close conn
         $close = $this->res->getHeader('connection');
         $this->conn->close($type !== 'NORMAL' || !strcasecmp($close, 'close'));
         $this->conn = null;
         // redirect
         if (($this->res->status === 301 || $this->res->status === 302) && $this->res->numRedirected < $this->req->getMaxRedirect() && ($location = $this->res->getHeader('location')) !== null) {
             Client::debug('redirect to \'', $location, '\'');
             $req = $this->req;
             if (!preg_match('/^https?:\\/\\//i', $location)) {
                 $pa = $req->getUrlParams();
                 $url = $pa['scheme'] . '://' . $pa['host'];
                 if (isset($pa['port'])) {
                     $url .= ':' . $pa['port'];
                 }
                 if (substr($location, 0, 1) == '/') {
                     $url .= $location;
                 } else {
                     $url .= substr($pa['path'], 0, strrpos($pa['path'], '/') + 1) . $location;
                 }
                 $location = $url;
                 /// FIXME: strip relative '../../'
             }
             // change new url
             $prevUrl = $req->getUrl();
             $req->setUrl($location);
             if (!$req->getHeader('referer')) {
                 $req->setHeader('referer', $prevUrl);
             }
             if ($req->getMethod() !== 'HEAD') {
                 $req->setMethod('GET');
             }
             $req->clearCookie();
             $req->setHeader('host', null);
             $req->setHeader('x-server-ip', null);
             // reset response
             $this->res->numRedirected++;
             $this->finished = $this->headerOk = false;
             return $this->res->reset();
         }
     }
     Client::debug('finished', $this->res->hasError() ? ' (' . $this->res->error . ')' : '');
     $this->req = $this->cli = null;
 }
Example #2
0
 /**
  * @return null
  */
 public function tearDown()
 {
     $this->assertTrue($this->conn->close());
     unset($this->conn);
     unset($this->driver);
     unset($this->stmtDriver);
     unset($this->stmt);
 }
Example #3
0
 function login()
 {
     $authorized = false;
     $error = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (strlen($_POST['userid']) > 0) {
             $validation = new Validation();
             if ($message = $validation->userid($_POST['userid'], 'ユーザー名')) {
                 $error[] = $message;
             } else {
                 $userid = $_POST['userid'];
             }
             $_POST['password'] = trim($_POST['password']);
             if ($message = $validation->alphaNumeric($_POST['password'], 'パスワード')) {
                 $error[] = $message;
             } else {
                 $password = md5($_POST['password']);
             }
             if (count($error) <= 0) {
                 $connection = new Connection();
                 $query = sprintf("SELECT id,userid,password,realname,user_group,authority FROM %suser WHERE userid = '%s'", DB_PREFIX, $connection->quote($userid));
                 $data = $connection->fetchOne($query);
                 $connection->close();
                 if (count($data) > 0 && $data['userid'] === $userid && $data['password'] === $password) {
                     $authorized = true;
                 } else {
                     $error[] = 'ユーザー名もしくはパスワードが<br />異なります。';
                 }
             }
         } else {
             $error[] = 'ユーザー名を入力してください。';
         }
     } elseif (isset($_SESSION['status'])) {
         if ($_SESSION['status'] == 'idle') {
             $error[] = '自動的にログアウトしました。<br />ログインしなおしてください。';
         } elseif ($_SESSION['status'] == 'expire') {
             $error[] = 'ログインの有効期限が切れました。<br />ログインしなおしてください。';
         }
         session_unregister('status');
     }
     if ($authorized === true && count($error) <= 0) {
         session_regenerate_id();
         $_SESSION['logintime'] = time();
         $_SESSION['accesstime'] = $_SESSION['logintime'];
         $_SESSION['authorized'] = md5(__FILE__ . $_SESSION['logintime']);
         $_SESSION['userid'] = $data['userid'];
         $_SESSION['realname'] = $data['realname'];
         $_SESSION['group'] = $data['user_group'];
         $_SESSION['authority'] = $data['authority'];
         if (isset($_SESSION['referer'])) {
             header('Location: ' . $_SESSION['referer']);
             session_unregister('referer');
         } else {
             header('Location: index.php');
         }
         exit;
     } else {
         return $error;
     }
 }
 private function tryMethod($method, $args)
 {
     try {
         return call_user_func_array([$this->connection, $method], $args);
     } catch (\Exception $exception) {
         $e = $exception;
         while ($e->getPrevious() && !$e instanceof \PDOException) {
             $e = $e->getPrevious();
         }
         if ($e instanceof \PDOException && $e->errorInfo[1] == self::MYSQL_CONNECTION_TIMED_WAIT_CODE) {
             $this->connection->close();
             $this->connection->connect();
             $this->logger->notice('Connection to MySQL lost, reconnect okay.');
             return call_user_func_array([$this->connection, $method], $args);
         }
         if (false !== strpos($exception->getMessage(), 'MySQL server has gone away') || false !== strpos($exception->getMessage(), 'Error while sending QUERY packet') || false !== strpos($exception->getMessage(), 'errno=32 Broken pipe')) {
             $this->connection->close();
             $this->connection->connect();
             $this->logger->notice('Connection to MySQL lost, reconnect okay.');
             return call_user_func_array([$this->connection, $method], $args);
         }
         $this->logger->critical('Connection to MySQL lost, unable to reconnect.', ['exception' => $exception]);
         throw $e;
     }
 }
Example #5
0
 /**
  * @return null
  */
 public function testConnectClose()
 {
     $this->assertTrue($this->conn->connect());
     $this->assertEquals('connected', $this->conn->getStatus());
     $this->assertTrue($this->conn->isConnected());
     $this->assertFalse($this->conn->isError());
     $this->assertTrue($this->conn->close());
     $this->assertEquals('closed', $this->conn->getStatus());
     $this->assertFalse($this->conn->isDriver());
     $this->assertFalse($this->conn->isConnected());
     $this->assertFalse($this->conn->isError());
     /* lets see if we can connect again */
     $this->assertFalse($this->conn->connect());
     $this->assertEquals('closed', $this->conn->getStatus());
     $this->assertFalse($this->conn->isConnected());
     $this->assertTrue($this->conn->isError());
 }
 public function remove($id_mensaje)
 {
     $db = new Connection();
     $dateLeaving = date("m.d.y");
     $query = "UPDATE MENSAJE SET fecha_baja = {$dateLeaving} where id_mensaje = {$id_mensaje}";
     $results = $db->query($query) or die('Error dando de baja el mensaje: ' . mysqli_error($this->db));
     $db->close();
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function handle(\Request $request)
 {
     $responseObject = new \Response();
     self::$response = $responseObject;
     self::$request = $request;
     \DI::addInstance($responseObject);
     \Route::map();
     $connection = new \Connection(self::$request, self::$response);
     return $connection->close();
 }
 public function modifyLimitAllWall($limit)
 {
     $myConnection = new Connection();
     //verifico que sea un número positivo
     if (is_numeric($limit)) {
         if ($limit >= 0) {
             $myConnection->query("UPDATE MURO SET MURO.limite_muro = '{$limit}';");
         }
     } else {
         header('location: ../../indexAdmin.php?malahi');
     }
     $myConnection->close();
     header('location: ../../indexAdmin.php');
 }
 public static function all()
 {
     $aCategories = [];
     $oCon = new Connection();
     $sSQL = 'SELECT CategoryID FROM tbcategory WHERE Active=1';
     $oResultSet = $oCon->query($sSQL);
     while ($aRow = $oCon->fetchArray($oResultSet)) {
         $iCategoryID = $aRow['CategoryID'];
         $oCategory = new Category();
         $oCategory->load($iCategoryID);
         $aCategories[] = $oCategory;
     }
     $oCon->close();
     return $aCategories;
 }
 public static function all()
 {
     $aGenres = array();
     $oCon = new Connection();
     $sSQL = "SELECT GenreID FROM tbgenres";
     $oResultSet = $oCon->query($sSQL);
     while ($aRow = $oCon->fetchArray($oResultSet)) {
         $iGenreID = $aRow["GenreID"];
         $oGenre = new Genre();
         $oGenre->load($iGenreID);
         $aGenres[] = $oGenre;
     }
     $oCon->close();
     return $aGenres;
 }
 public function save()
 {
     $oCon = new Connection();
     if ($this->iPostID == 0) {
         $sSQL = "INSERT INTO tbposts (PostContent, TopicID, MemberID) VALUES (\n            '" . $this->sPostContent . "',\n            '" . $this->iTopicID . "',\n            '" . $this->iMemberID . "')";
         $bResult = $oCon->query($sSQL);
         if ($bResult == true) {
             $this->iPostID = $oCon->getInsertID();
         } else {
             die($sSQL . " did not run");
         }
     } else {
         $sSQL = 'UPDATE tbposts SET Active = ' . $this->iActive . ' WHERE PostID=' . $this->iPostID;
         $bResult = $oCon->query($sSQL);
     }
     $oCon->close();
 }
Example #12
0
 public function selectAll()
 {
     $resultArrayWithUsers = array();
     $db = Connection::getConnection();
     $rows = $db->query("SELECT * FROM `users`");
     $count = 0;
     while ($row = $rows->fetch(PDO::FETCH_ASSOC)) {
         $user = new User();
         $user->setLogin($row[User::$LOGIN]);
         $user->setPassword($row[User::$PASSWORD]);
         $user->setUserId($row[User::$USER_ID]);
         $resultArrayWithUsers[$count] = $user;
         $count++;
     }
     Connection::close();
     return $resultArrayWithUsers;
 }
Example #13
0
 public function load($iGenreID)
 {
     $oCon = new Connection();
     $sSQL = "SELECT GenreID, GenreName, DisplayOrder \n\t\t\tFROM tbgenres \n\t\t\tWHERE GenreID = " . $iGenreID;
     $oResultSet = $oCon->query($sSQL);
     $aRow = $oCon->fetchArray($oResultSet);
     $this->iGenreID = $aRow['GenreID'];
     $this->sGenreName = $aRow['GenreName'];
     $this->iDisplayOrder = $aRow['DisplayOrder'];
     $sSQL = "SELECT RecordID\n\t\t\tFROM tbrecords \n\t\t\tWHERE GenreID = " . $iGenreID;
     $oResultSet = $oCon->query($sSQL);
     while ($aRow = $oCon->fetchArray($oResultSet)) {
         $iRecordID = $aRow["RecordID"];
         $oRecord = new Record();
         $oRecord->load($iRecordID);
         $this->aRecords[] = $oRecord;
     }
     $oCon->close();
 }
 public function save()
 {
     $oCon = new Connection();
     if ($this->iMemberID == 0) {
         $sSQL = "INSERT INTO tbmember\n            (MemberName, MemberPassword, MemberEmail) VALUES             ('" . $this->sMemberName . "',\n                    '" . $this->sMemberPassword . "',\n                    '" . $this->sMemberEmail . "')";
         $bResult = $oCon->query($sSQL);
         if ($bResult == true) {
             $this->iMemberID = $oCon->getInsertID();
         } else {
             die($sSQL . " did not run");
         }
     } else {
         $sSQL = "UPDATE tbmember SET MemberName = '" . $this->sMemberName . "'WHERE MemberID = " . $this->iMemberID;
         $bResult = $oCon->query($sSQL);
         if (bResult == false) {
             die($sSQL . " did not run");
         }
     }
     $oCon->close();
 }
 public function save()
 {
     $oCon = new Connection();
     if ($this->iCategoryID == 0) {
         $sSQL = 'INSERT INTO tbcategory (CategoryName, CategoryDesc)
         VALUES(
             "' . $this->sCategoryName . '",
             "' . $this->sCategoryDesc . '")';
         $bResult = $oCon->query($sSQL);
         if ($bResult == true) {
             $this->iCategoryID = $oCon->getInsertID();
         } else {
             die($sSQL . " did not run");
         }
     } else {
         $sSQL = 'UPDATE tbcategory SET Active = ' . $this->iActive . ' WHERE CategoryID=' . $this->iCategoryID;
         $bResult = $oCon->query($sSQL);
     }
     $oCon->close();
 }
Example #16
0
 public function save()
 {
     $oCon = new Connection();
     if ($this->iCustomerID == 0) {
         $sSQL = "INSERT INTO tbcustomer (Name, Address, Phone, Email, Password) \n\t\t\t\tVALUES ('" . $this->sName . "', '" . $this->sAddress . "', '" . $this->sPhone . "', '" . $this->sEmail . "', '" . $this->sPassword . "')";
         $bResult = $oCon->query($sSQL);
         if ($bResult == true) {
             $this->iCustomerID = $oCon->getInsertID();
         } else {
             die($sSQL . " Did not run");
         }
     } else {
         $sSQL = "UPDATE tbcustomer \n\t\t\t\t\tSET Name = '" . $this->sName . "',\n\t\t\t\t\t \tAddress = '" . $this->sAddress . "',\n\t\t\t\t\t \tPhone = '" . $this->sPhone . "',\n\t\t\t\t\t \tEmail = '" . $this->sEmail . "',\n\t\t\t\t\t \tPassword = '******'\n\t\t\t\t\t \tWHERE CustomerID = " . $this->iCustomerID;
         $bResult = $oCon->query($sSQL);
         if ($bResult == false) {
             die($sSQL . " Did not run");
         }
     }
     $oCon->close();
 }
Example #17
0
 protected function getChunkedResponse($connection)
 {
     $body = '';
     $start_time = time();
     while (true) {
         if ($this->response_timeout > 0 && time() - $start_time > $this->response_timeout) {
             $this->Connection->close();
             return false;
         }
         $data = '';
         do {
             $read = fread($connection, 1);
             if ($read === false) {
                 $this->Connection->close();
                 return false;
             }
             $data .= $read;
         } while (strpos($data, "\r\n") === false);
         if (strpos($data, ' ') !== false) {
             list($chunksize, $chunkext) = explode(' ', $data, 2);
         } else {
             $chunksize = $data;
         }
         $chunksize = (int) base_convert($chunksize, 16, 10);
         if ($chunksize === 0) {
             fread($connection, 2);
             // read trailing "\r\n"
             return $body;
         } else {
             $data = $this->stream_get_contents($connection, $chunksize + 2);
             if ($data === false) {
                 $this->Connection->close();
                 return false;
             }
             $body .= substr($data, 0, -2);
             // -2 to remove the "\r\n" before the next chunk
         }
     }
     return false;
 }
 public function save()
 {
     $oCon = new Connection();
     if ($this->iTopicID == 0) {
         $sSQL = 'INSERT INTO tbtopics (TopicSubject, TopicDesc, CategoryID, MemberID)
         VALUES(
             "' . $this->sTopicSubject . '",
             "' . $this->sTopicDesc . '",
             "' . $this->iCategoryID . '",
             "' . $this->iMemberID . '")';
         $bResult = $oCon->query($sSQL);
         if ($bResult == true) {
             $this->iTopicID = $oCon->getInsertID();
         } else {
             die($sSQL . " did not run");
         }
     } else {
         $sSQL = 'UPDATE tbtopics SET Active = ' . $this->iActive . ' WHERE TopicID=' . $this->iTopicID;
         $bResult = $oCon->query($sSQL);
     }
     $oCon->close();
 }
Example #19
0
<?php

//include the connection page
include './connect_to_db.php';
//get an instance
$db = new Connection();
//connect to database
$db->connect();
$item_id = $_POST['remove'];
$query = "SELECT * FROM POST\n\t\t\tWHERE item_id = '{$item_id}'";
//query the database
$result = mysql_query($query);
$post = mysql_fetch_assoc($result);
$post_id = $post['post_id'];
$query = "DELETE FROM POST\n\t\t\tWHERE item_id = '{$item_id}'";
//query the database
mysql_query($query);
$query = "DELETE FROM ITEMS\n\t\t\tWHERE item_id = '{$item_id}'";
//query the database
mysql_query($query);
$query = "DELETE FROM COMMENTS\n\t\t\tWHERE post_id = '{$post_id}'";
//query the database
mysql_query($query);
//close once finished to free up resources
$db->close();
header("Location: view-item.php?remove_item={$item_id}", true);
exit;
<?php

header("Content-Type: text/html; charset=ISO-8859-1");
require_once "../server/Connection.class.php";
require_once "../server/lib.php";
$conn = new Connection();
$login = mysql_query("SELECT `{$_POST['NOME_COLUNA']}` FROM `{$_POST['NOME_TABELA']}` WHERE `{$_POST['CHAVE']}`='{$_POST['CODIGO']}'");
$login = mysql_fetch_object($login);
if ($login->{$_POST}['NOME_COLUNA']) {
    mysql_query("UPDATE `{$_POST['NOME_TABELA']}` SET `{$_POST['NOME_COLUNA']}`='0' WHERE `{$_POST['CHAVE']}`='{$_POST['CODIGO']}'");
    $ref = trim("{$_POST['LABEL']}");
} else {
    mysql_query("UPDATE `{$_POST['NOME_TABELA']}` SET `{$_POST['NOME_COLUNA']}`='1' WHERE `{$_POST['CHAVE']}`='{$_POST['CODIGO']}'");
    $ref = trim("{$_POST['LABEL']}");
}
$conn->close();
print $ref;
 private function verify($mail, $userName)
 {
     $myConnection = new Connection();
     $errorMessageView = "";
     $result1 = $myConnection->query("SELECT * FROM USUARIO WHERE nombre_usuario = '{$userName}';");
     $numberOfRows1 = mysqli_num_rows($result1);
     if ($numberOfRows1 > 0) {
         $userExist = true;
         $errorMessageView = "El usuario ingresado ya existe<br>";
     } else {
         $userExist = false;
     }
     $result2 = $myConnection->query("SELECT * FROM USUARIO WHERE mail = '{$mail}';");
     $numberOfRows2 = mysqli_num_rows($result2);
     if ($numberOfRows2 > 0) {
         $mailExist = true;
         $errorMessageView = "El mail ingresado ya existe<br>";
     } else {
         $mailExist = false;
     }
     $myConnection->close();
     return $errorMessageView;
 }
 /**
  * @see Connection::close()
  */
 public function close()
 {
     $this->log("close(): Closing connection.");
     return $this->childConnection->close();
 }
Example #23
0
 /**
  * Limits the given connection
  *
  * @param Connection $connection
  * @param string $limit Reason
  */
 protected function limit($connection, $limit)
 {
     $this->logger->info(sprintf('Limiting connection %s: %s', $connection->getIp(), $limit));
     $connection->close(new RateLimiterException($limit));
 }
Example #24
0
 /**
  * Disconnect from Gearman
  *
  * @return      void
  */
 public function disconnect()
 {
     if (!is_array($this->conn) || !count($this->conn)) {
         return;
     }
     foreach ($this->conn as $conn) {
         Connection::close($conn);
     }
 }
Example #25
0
             $log->Conn($connFailureText . " - in  Error:(File: " . $_SERVER['PHP_SELF'] . ")");
             // logg to file
             $jsonArray['failTelnetConnMsg'] = $text;
             echo json_encode($jsonArray);
             continue;
             // continue; probably not needed now per device connection check at start of foreach loop - failsafe?
         }
         $jsonArray['telnetConnMsg'] = $connSuccessText . '<br /><br />';
         $log->Conn($connSuccessText . " - in (File: " . $_SERVER['PHP_SELF'] . ")");
         // log to file
         // iterate over snippet lines and get output from telnet session
         foreach ($snippetArr as $k => $command) {
             $conn->writeSnippetTelnet($command, $result);
             $cliOutputArray[] = nl2br($result);
         }
         $conn->close('40');
         // close telnet connection - ssh already closed at this point
     } elseif ($device['deviceAccessMethodId'] == '3') {
         //SSHv2 - cause SSHv2 is likely to come before SSHv1
         // SSH conn failure
         $jsonArray['telnetConnMsg'] = $connSuccessText . '<br /><br />';
         $log->Conn($connSuccessText . " - in (File: " . $_SERVER['PHP_SELF'] . ")");
         // log to file
         $result = $conn->writeSnippetSSH($snippetArr, $prompt);
         $cliOutputArray[] = nl2br($result);
     } else {
         continue;
     }
 }
 //end foreach
 $cliOutputArray = implode(", ", $cliOutputArray);
Example #26
0
 public function endWork()
 {
     foreach ($this->connection as $conn) {
         Connection::close($conn);
     }
 }
Example #27
0
 /**
  * Encerra o projeto e a conexão
  * @return void
  */
 public static function close()
 {
     if (CRUDQuery::isPDOMode()) {
         Connection::close();
     } elseif (CRUDQuery::isMySqliMode()) {
         ConnectionMySqli::close();
     }
 }
 public function rollback()
 {
     $this->connection->executeQuery('ROLLBACK');
     $this->connection->close();
     Transaction::$transactions->removeLast();
 }
Example #29
0
//                       stakeholders.ComputingID = TRIM('".$q_2."')";
//        }
//   }
//  elseif (isset($_REQUEST["seeq"])){
$lastname = $_REQUEST["lastname"];
$sql4 = "\n          SELECT max(Stakeholder_id) FROM stakeholders WHERE LastName LIKE TRIM('.{$lastname}.')\n           ";
$r = $c->query($sql4);
$col = count($c->getArray($r)) - 1;
if ($c->getNumRows($r) != 0) {
    while ($col) {
        $row1 = $c->getArray($r);
        $l = $row1;
        $col = $col - 1;
    }
}
$c->close();
echo $l;
//////////////////////////////
// else {
// $ar=array();
// $ar = explode('-',$q_2);
// $arrayLenght= count($ar)-1;
// $sthid= $ar[$arrayLenght];
session_start();
$_SESSION["sta_id"] = $sthid;
// $ar = array_pop($ar);
// if(intval($ar[0]) == 0) {
// $q = $ar[0];
//   foreach ($ar as $val)
//      {  //echo " val= ".$val;
//          if (intval($val)>10){ $emplid=$val;}
Example #30
0
                <!-- Links Rodape --
                <ul class="footer-links">
                  <li><a href="http://blog.getbootstrap.com">Blog</a></li>
                  <li class="muted">·</li>
                  <li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
                  <li class="muted">·</li>
                  <li><a href="https://github.com/twitter/bootstrap/wiki">Roadmap e changelog</a></li>
                </ul>
                            // Links Rodape --
            </div-->
        </footer>
        <!-- //Fim Rodape -->
    </body>
</html>
<?php 
Connection::close();
unset($user);
unset($company);
/*	<script src="components/js/google-code-prettify/prettify.js"></script>
        <script src="components/js/bootstrap-dropdown.js"></script>
        <script src="components/js/bootstrap-transition.js"></script>
        <script src="components/js/bootstrap-alert.js"></script>
        <script src="components/js/bootstrap-modal.js"></script>
        <script src="components/js/bootstrap-scrollspy.js"></script>
        <script src="components/js/bootstrap-tab.js"></script>
        <script src="components/js/bootstrap-tooltip.js"></script>
        <script src="components/js/bootstrap-popover.js"></script>
        <script src="components/js/bootstrap-balloon.js"></script>
        <script src="components/js/bootstrap-button.js"></script>
        <script src="components/js/bootstrap-collapse.js"></script>
        <script src="components/js/bootstrap-carousel.js"></script>