• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getClientIP函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkChinaIP

function checkChinaIP()
{
    $ip = getClientIP();
    $cIP = explode(".", $ip);
    $ipList = split("\n", file_get_contents(__DIR__ . "/china_ip"));
    foreach ($ipList as $value) {
        if (!$value) {
            continue;
        }
        $ips = explode(" ", $value);
        $minIP = explode(".", $ips[0]);
        $maxIP = explode(".", $ips[1]);
        $match = true;
        foreach ($cIP as $idx => $part) {
            if ($part < $minIP[$idx] || $part > $maxIP[$idx]) {
                $match = false;
                break;
            }
        }
        if ($match) {
            return true;
        }
    }
    return false;
    //return true;
}
开发者ID:jimmyshen007,项目名称:webproject,代码行数:26,代码来源:checkip.php


示例2: tg

 /**
  * 推广连接
  * www.xxx.com/action/Method/站长ID/游戏ID/cpa、cps、。。。/子ID/?ref=url
  * yy.51yx.com/index/tg/12312312/13/2/11/?ref=url
  */
 public function tg()
 {
     $master_id = $_GET[2];
     //站长ID
     $game_id = $_GET[3];
     //游戏ID
     $type = $_GET[4];
     //推广类型 cpa/cps
     $sub_code = $_GET[5];
     //子站长ID
     $ref = $_GET['ref'];
     setcookie(WEBMASTER, $master_id, 0, '/', DOMAIN);
     setcookie(AD_GAME_ID, $game_id, 0, '/', DOMAIN);
     setcookie(SPREAD_TYPE, $type, 0, '/', DOMAIN);
     //CPS 为2	CPA:1   其它:0
     setcookie(SUB_CODE, $sub_code, 0, '/', DOMAIN);
     $ip = getClientIP();
     //记点击日志
     //站长ID,游戏ID,子站长ID,访问IP
     $content = $master_id . ',' . $game_id . ',\'' . $sub_code . '\' ' . $ip;
     @log_info($content, $file = "tg_click_");
     if ($ref) {
         $this->gotourl($ref);
     } else {
         $this->gotourl('/member/register');
     }
     exit;
 }
开发者ID:noikiy,项目名称:webgame,代码行数:33,代码来源:index.php


示例3: setSessionFile

function setSessionFile($data)
{
    $dir = getSysDir();
    $handle = fopen($dir . '/etc/session/sess' . md5(getClientIP()), 'wt');
    $res = fwrite($handle, $data);
    fclose($handle);
    return $res;
}
开发者ID:jokopurnomoa,项目名称:OSJ-X,代码行数:8,代码来源:DefaultIO.php


示例4: addToLog

function addToLog($userid, $action, $description)
{
    $userid = makeStringSafe($userid);
    $action = makeStringSafe($action);
    $description = makeStringSafe($description);
    $mysqldate = getCurrentMySQLDateTime();
    $ip = getClientIP();
    $hostname = getClientHostname();
    doQuery("INSERT INTO " . getDBPrefix() . "_log SET user_id = '" . $userid . "', action_type = '" . $action . "', action_description = '" . $description . "', date = '" . $mysqldate . "', ip = '" . $ip . "', hostname='" . $hostname . "'");
}
开发者ID:ramielrowe,项目名称:Reservation-System-V1,代码行数:10,代码来源:db_log_functions.php


示例5: createInstantReport

 public static function createInstantReport($message, $senderid, $requestid, $route, array $response)
 {
     // Request id
     $dataToInsert['user_id'] = 1;
     // active user id
     $dataToInsert['request_id'] = $requestid;
     $dataToInsert['request_route'] = $route;
     $dataToInsert['senderid'] = $senderid;
     $dataToInsert['message'] = $message;
     $dataToInsert['data'] = $response;
     //json
     $dataToInsert['sender_ip'] = getClientIP();
     CloudsmsReports::create($dataToInsert);
 }
开发者ID:leelam,项目名称:cloudsms,代码行数:14,代码来源:CloudsmsReports.php


示例6: activation

 public function activation()
 {
     $this->loadModel('common_model');
     $json = $_GET['jsoncallback'];
     $user_name = $_REQUEST['user_name'];
     $game_id = $_REQUEST['game_id'];
     $card_no = $_REQUEST['card_no'];
     //判断激活码是否有效
     $query = $this->common_model->checkActivationCode($card_no);
     if ($query) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'e1'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'e1')) . ")";
         }
         exit;
     }
     //判断账号是否已经被激活过
     $query = $this->common_model->checkUserActivation($game_id, $user_name);
     if ($query) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'e3'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'e3')) . ")";
         }
         exit;
     }
     //判断用户或激活码是否可用
     $query = $this->common_model->checkActivation($game_id, $user_name, $card_no);
     if ($query) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'e2'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'e2')) . ")";
         }
         exit;
     }
     $active_ip = getClientIP();
     //IP地址
     $result = $this->common_model->activation($card_no, $user_name, $active_ip, $game_id);
     if ($result) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'succ'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'succ')) . ")";
         }
     }
     exit;
 }
开发者ID:noikiy,项目名称:webgame,代码行数:49,代码来源:ajax.php


示例7: check_formlimitation

 public function check_formlimitation($formID, $dayrange = 1, $limitation = 5)
 {
     $WebSiteID = $this->session->userdata('WebSiteID');
     $sql = "SELECT COUNT(*) Total FROM tbl_restrictions_form_limitations WHERE WebSiteID='" . $WebSiteID . "' AND FormID='" . $formID . "' AND ClientIP='" . getClientIP() . "' AND CreateTime> DATEADD(day,-" . $dayrange . ",GETDATE())";
     $query = $this->db->query($sql);
     $row = $query->row();
     $Total = $row->Total;
     $sql = "INSERT INTO tbl_restrictions_form_limitations (WebSiteID, FormID, ClientIP) VALUES ('" . $WebSiteID . "','" . $formID . "','" . getClientIP() . "')";
     $query = $this->db->query($sql);
     if ($Total >= $limitation) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:mdbhk,项目名称:retailersurvey.themdbfamily.com,代码行数:15,代码来源:restriction_model.php


示例8: writeLog

function writeLog($msg)
{
    $time = Date('Y-m-d h:i:s');
    $ip = getClientIP();
    $info = "{$time}--{$ip} ------>{$msg}";
    //echo  $info;
    $fp = fopen("/data/web/open.valsun.cn/log.txt", "a+");
    //追加写入
    if ($fp) {
        $flag = fwrite($fp, $info . "\r\n");
        if (!$flag) {
            echo "写入文件失败<br>";
        }
    } else {
        echo "打开文件失败";
    }
    fclose($fp);
}
开发者ID:ohjack,项目名称:newErp,代码行数:18,代码来源:functions.php


示例9: writeLog

function writeLog($msg)
{
    $time = Date('Y-m-d h:i:s');
    $log_path = WEB_PATH . 'log.txt';
    $ip = getClientIP();
    $info = "{$time}--{$ip} ------>{$msg}";
    //echo  $info;
    $fp = fopen($log_path, "a+");
    //追加写入
    if ($fp) {
        $flag = fwrite($fp, $info . "\r\n");
        if (!$flag) {
            echo "写入文件失败<br>";
        }
    } else {
        echo "打开文件失败";
    }
    fclose($fp);
}
开发者ID:ohjack,项目名称:newErp,代码行数:19,代码来源:functions.php


示例10: userInfoCache

 public static function userInfoCache($token, $userid)
 {
     self::initDB();
     $data = Auth::getUserInfo($token);
     //鉴权系统拉取权限
     $userinfo = json_decode($data, TRUE);
     if (json_last_error() != JSON_ERROR_NONE) {
         //json数据解析出错
         $errCode = 1;
         $errMsg = '解析鉴权系统返回json出错!';
         return false;
     }
     $sql = "select lastUpdateTime from pc_user where userPowerId = {$userid}";
     $row = self::$dbConn->fetch_first($sql);
     $time = time();
     $ip = getClientIP();
     //客户端ip
     //var_dump($userinfo);exit;
     $username = mysql_real_escape_string($userinfo['userName']);
     $phone = mysql_real_escape_string($userinfo['phone']);
     $email = mysql_real_escape_string($userinfo['email']);
     if (!empty($row)) {
         if (json_decode(intval($userinfo['lastUpdateTime']), TRUE) > $row['lastUpdateTime']) {
             //鉴权系统信息已更新 更新本地数据
             $up_sql = "update pc_user set userName = '{$username}', userTel='{$phone}', userMail='{$email}', userIp = '{$ip}', userActive = userActive+1, lastUpdateTime={$time} where userPowerId={$userid}";
             self::$dbConn->query($up_sql);
         } else {
             //信息没有更新 则只更新登陆次数
             $up_sql = "update pc_user set userActive=userActive+1 where userPowerId={$userid}";
             //echo $up_sql;exit;
             self::$dbConn->query($up_sql);
         }
     } else {
         //没找到结果集 新增用户数据
         $in_sql = "insert into pc_user values (null, {$userid}, '{$username}', '', '' , '' , '' , '', '', '', '{$phone}', '{$email}', '{$ip}', 1, '', {$time}, 0, {$time})";
         self::$dbConn->query($up_sql);
     }
     //存储用户权限信息到memcache
     self::cacheUserInfoToMemcache($userid, $userinfo['power']);
     return $userinfo;
 }
开发者ID:ohjack,项目名称:newErp,代码行数:41,代码来源:userCache.model.php


示例11: getGlobal

 public function getGlobal()
 {
     $m_user = $this->load("User");
     //判断cookie是否有-自动登录
     $cookie_auth = $this->getCookie('auth');
     if ($cookie_auth) {
         $clean = array();
         list($identifier, $token) = explode(':', $cookie_auth);
         if (ctype_alnum($identifier) && ctype_alnum($token)) {
             $clean['identifier'] = $identifier;
             $clean['token'] = $token;
         }
         $record = $m_user->Where(array("identifier" => $clean['identifier']))->Field("id,email,identifier,identifier_token,login_time,point,refuse")->SelectOne();
         if ($record && $record["refuse"]) {
             if ($clean['token'] != $record['identifier_token']) {
                 //$this->redirect("Login/index");
             } elseif ($clean['identifier'] != md5("SALTISDIFFCULT" . md5($record["email"] . "SALTISDIFFCULT"))) {
                 //$this->redirect("Login/index");
             } else {
                 //更新
                 if ($record["login_time"] < strtotime(date("Y-m-d"))) {
                     $m_user->UpdateByID(array("login_time" => time(), "login_ip" => getClientIP(), "point" => $record["point"] + 2), $record["id"]);
                 }
                 $this->setSession('uid', $record["id"]);
                 $this->setSession('email', $record["email"]);
             }
         }
     }
     //根据session uid 获取该用户的信息
     $session_uid = $this->getSession("uid");
     $session_email = $this->getSession("email");
     if (isset($session_uid) && !empty($session_uid)) {
         $current_user_info = $m_user->Where(array("id" => $session_uid))->Field("id,email,username")->SelectOne();
         $current_user_info = deep_htmlspecialchars_decode($current_user_info);
         $this->getView()->assign("current_user_info", $current_user_info);
     }
 }
开发者ID:GobYang,项目名称:thaidh,代码行数:37,代码来源:C_Basic.php


示例12: getClientIP

<?php

//测试负载均衡的ip地址
echo 'HTTP_HOST'.$_SERVER['HTTP_HOST'].',REMOTE_ADDR '.$_SERVER["REMOTE_ADDR"].',SERVER_NAME'.$_SERVER['SERVER_NAME'].',getClientIP'.getClientIP();


/** 
 * 获取客户端ip 
 */   
 function getClientIP() {
    $ip = "unknown";  
    /* 
     * 访问时用localhost访问的,读出来的是“::1”是正常情况。 
     * ::1说明开启了ipv6支持,这是ipv6下的本地回环地址的表示。 
     * 使用ip地址访问或者关闭ipv6支持都可以不显示这个。 
     * */  
    if (isset($_SERVER)) {  
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {  
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];  
        } elseif (isset($_SERVER["HTTP_CLIENT_ip"])) {  
            $ip = $_SERVER["HTTP_CLIENT_ip"];  
        } else {  
            $ip = $_SERVER["REMOTE_ADDR"];  
        }  
    } else {  
        if (getenv('HTTP_X_FORWARDED_FOR')) {  
            $ip = getenv('HTTP_X_FORWARDED_FOR');  
        } elseif (getenv('HTTP_CLIENT_ip')) {  
            $ip = getenv('HTTP_CLIENT_ip');  
        } else {  
            $ip = getenv('REMOTE_ADDR');  
开发者ID:bajian,项目名称:js-web-skills,代码行数:31,代码来源:remoteIp.php


示例13: detectCountry

function detectCountry($mysqli, $cod_pais = '')
{
    /*$url = "http://ipinfo.io/";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_HEADER, 0);*/
    //Con esta opcion almaceno el resultado en una variable
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //session_start();
    if (isset($cod_pais) && $cod_pais != '') {
        $pais = $cod_pais;
    } else {
        // Usamos la API de GEO plugin + mas el header TTP_X_FORWARDED_FOR
        $data = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . getClientIP()));
        $pais = $data['geoplugin_countryCode'];
    }
    if ($pais) {
        //$resp = json_decode(curl_exec($ch));
        $cod_pais = $pais;
        //$resp->country;
        $query = "SELECT id, pais, flag FROM paises WHERE cod_pais='{$cod_pais}'";
        $result = $mysqli->query($query);
        $tablaPaisdatos = $result->fetch_assoc();
        $tablaPais = array('id' => $tablaPaisdatos['id'], 'cod_pais' => $cod_pais, 'pais' => $tablaPaisdatos['pais'], 'flag' => $tablaPaisdatos['flag']);
        if ($cod_pais != 'US') {
            $query2 = "SELECT id, idioma, cod_idioma FROM idiomas WHERE idiomas.id = (select id_idioma from pais_idioma where pais_idioma.id_pais = {$tablaPaisdatos['id']})";
            $result2 = $mysqli->query($query2);
            $idioma = $result2->fetch_assoc();
            $idioma_sel = $idioma['idioma'];
        } else {
            $idioma = array("id" => "2", "idioma" => "Ingles", "cod_idioma" => "IN");
            $idioma_sel = "Ingles";
        }
        $_SESSION['pais'] = array('id' => $tablaPais['id'], 'cod_pais' => $tablaPais['cod_pais'], 'pais' => $tablaPais['pais'], 'flag' => $tablaPais['flag'], 'idioma' => $idioma_sel, 'cod_idioma' => $idioma['cod_idioma'], 'id_idioma' => $idioma['id']);
    } else {
        $_SESSION['pais'] = array('pais' => 'Argentina', 'cod_pais' => "AR", 'idioma' => 'ES', 'flag' => 'images/flags/ar.png', 'id_idioma' => '1', 'cod_idioma' => 'ES', 'id' => '1');
        $_SESSION['ciudad'] = 'Rosario';
    }
    //curl_close($ch);
}
开发者ID:sebasnob,项目名称:iga-la,代码行数:40,代码来源:functions.php


示例14: getClientIP

 $txtAuthorizeLoginId = $row["authorize_loginid"];
 $txtAuthorizeTransKey = $row["authorize_transkey"];
 $txtCurrency = "USD";
 $txtAuthorizeEmail = $row["authorize_email"];
 $txtAuthorizeTestMode = $row["authorize_test_mode"];
 if ($txtAuthorizeTestMode == "Y") {
     $txtAuthorizeTestMode = "on";
 } else {
     $txtAuthorizeTestMode = "off";
 }
 $gift_coupon_flag = 0;
 $message = "";
 $paymentsuccessful = false;
 $paymenterror = "";
 $referrer = $_SERVER["HTTP_REFERER"];
 $Cust_ip = getClientIP();
 $txtAddress = $txtAddress1;
 if (!$ddlCountry) {
     $ddlCountry = $bill_country;
 }
 if (!$txtState) {
     $txtState = $bill_state;
 }
 $Company = "-NA-";
 $Phone = $txtPhone;
 if ($txtLastName == "") {
     $txtLastName = "-NA-";
 }
 require "../authorize-product-listing.php";
 //process the card and return result. Comment this line and uncomment the two lines below to make payment test mode
 //$paymentsuccessful = true;
开发者ID:kevinsmasters,项目名称:purecatskillsmarketplace,代码行数:31,代码来源:product-listing-payment-cc.php


示例15: strAddslashes

 $loginUser = strAddslashes(trim($_POST['login-user']));
 $loginPwd = stripslashes(trim($_POST['login-pwd']));
 if (strlen($loginUser) < 2 || strlen($loginUser) > 45 || strlen($loginPwd) < 6 || strlen($loginPwd) > 18) {
     echo "0 用户名或者密码不符合要求";
 } else {
     $DB->connect($mysql_host, $mysql_user, $mysql_pass, $mysql_dbname);
     if (!emailcheck($loginUser)) {
         $LoginType = "lower(`name`)";
     } else {
         $LoginType = "`email`";
     }
     $userArr = $TB->getMemberInfo($LoginType, strtolower($loginUser));
     if (!empty($userArr['uid'])) {
         if ($userArr['password'] == md5($loginPwd)) {
             $loginTime = time();
             $loginIp = getClientIP();
             loginCookie($userArr['uid'], $userArr['name'], $userArr['groupid'], $loginIp, $loginTime);
             $loginInfo['securekey'] = createSecureKey(10);
             $loginInfo['lastdate'] = $loginTime;
             $loginInfo['lastip'] = $loginIp;
             if ($userArr['lastdate'] != date("Y.m.d")) {
                 $loginInfo['integral'] = array("`integral`+1");
             }
             $DB->query($DB->update_sql("`" . $table_member . "`", $loginInfo, "`uid`=" . $userArr['uid']));
             echo "1 登录成功";
         } else {
             echo "0 您输入的密码不正确";
         }
     } else {
         echo "0 通行证账号不存在";
     }
开发者ID:tanny2015,项目名称:DataStructure,代码行数:31,代码来源:login.php


示例16: explode

     //							   echo "<br>varuploadfiles(3)==".$var_uploaded_files;
     if ($var_uploaded_files != "") {
         $vAttacharr = explode("|", $var_uploaded_files);
         foreach ($vAttacharr as $key => $value) {
             $split_name_url = explode("*", $value);
             $mime->fattach("../attachments/" . $split_name_url[0], "Attached here is " . $split_name_url[1]);
         }
     }
     $mime->send_mail();
 }
 //insert into reply table
 $sql = "insert into sptbl_replies(nReplyId,nTicketId,nStaffId,vStaffLogin,";
 $sql .= " dDate,tReply,tPvtMessage,vReplyTime,vMachineIP) values('','" . mysql_real_escape_string($var_tid) . "',";
 $sql .= "'" . mysql_real_escape_string($_SESSION["sess_staffid"]) . "',";
 $sql .= "'" . mysql_real_escape_string($_SESSION["sess_staffname"]) . "',now(),'" . mysql_real_escape_string($var_replymatter) . "','" . mysql_real_escape_string($var_pvtmessage) . "',";
 $sql .= "'" . mysql_real_escape_string($var_timespent) . "','" . mysql_real_escape_string(getClientIP()) . "')";
 executeQuery($sql, $conn);
 $var_insert_id = mysql_insert_id($conn);
 //Insert the actionlog
 if (logActivity()) {
     $sql = "Insert into sptbl_actionlog(nALId,nStaffId,vAction,vArea,nRespId,dDate) Values('','" . $_SESSION["sess_staffid"] . "','" . TEXT_ADDITION . "','Reply','" . mysql_real_escape_string($var_insert_id) . "',now())";
     executeQuery($sql, $conn);
 }
 //save attachment
 $sql_insert_attach = "insert into sptbl_attachments(nReplyId,vAttachReference,vAttachUrl) values";
 //						 echo "<br>varuploadfiles(4)==".$var_uploaded_files;
 if ($var_uploaded_files != "") {
     $vAttacharr = explode("|", $var_uploaded_files);
     foreach ($vAttacharr as $key => $value) {
         $split_name_url = explode("*", $value);
         $sql_insert_attach .= "('{$var_insert_id}','" . mysql_real_escape_string($split_name_url[1]) . "','" . mysql_real_escape_string($split_name_url[0]) . "'),";
开发者ID:ACSAUruguay,项目名称:helpdesk,代码行数:31,代码来源:replies.php.BASE.php


示例17: login

 function login()
 {
     if ($this->Session->read('Auth.User')) {
         $this->User->id = $this->Session->read('Auth.User.id');
         $this->User->saveField('last_login_ip', getClientIP());
         $this->User->saveField('last_login_time', date('Y-m-d H:i:s'));
         //$this->Session->setFlash('You are logged in!');
         $this->redirect('/users/profile', null, false);
     }
 }
开发者ID:nayha,项目名称:SocialNetwork,代码行数:10,代码来源:users_controller.php


示例18: getClientHostnameFromIP

function getClientHostnameFromIP()
{
    return gethostbyaddr(getClientIP());
}
开发者ID:ramielrowe,项目名称:Reservation-System-V1,代码行数:4,代码来源:functions.php


示例19: die

     die("1 " . $checkname);
 }
 $passwd = stripslashes(trim($_POST['userpwd']));
 $repasswd = stripslashes(trim($_POST['repwd']));
 if (strlen($passwd) < 6 || strlen($passwd) > 18) {
     die("1 密码长度应控制在6至18个字符之间。");
 }
 if ($passwd != $repasswd) {
     die("1 两次输入的密码不一致。");
 }
 $email = strtolower(trim($_POST['useremail']));
 if (strlen($email) > 45 || !emailcheck($email)) {
     die("1 电子邮件地址不合法。");
 }
 $actionTime = time();
 $actionIp = getClientIP();
 $DB->connect($mysql_host, $mysql_user, $mysql_pass, $mysql_dbname);
 if ($DB->fetch_one("SELECT COUNT(`bid`) FROM `" . $table_black . "` WHERE `uname`='" . $actionIp . "'") != 0) {
     echo "1 很抱歉,系统拒绝了您的注册!请与管理员联系。";
 } else {
     if ($DB->fetch_one("SELECT COUNT(`uid`) FROM `" . $table_member . "` WHERE lower(`name`)='" . strtolower($uname) . "'") != 0) {
         echo "1 用户昵称已被占用";
     } else {
         if ($DB->fetch_one("SELECT COUNT(`uid`) FROM `" . $table_member . "` WHERE `email` = '" . $email . "'") != 0) {
             echo "1 电子邮箱地址已被注册";
         } else {
             $passport_info['name'] = $uname;
             $passport_info['email'] = $email;
             $passport_info['password'] = md5($passwd);
             $passport_info['securekey'] = createSecureKey(8);
             $passport_info['regdate'] = $actionTime;
开发者ID:tanny2015,项目名称:DataStructure,代码行数:31,代码来源:register.php


示例20: session_start

<?php

//file that has the main logic for the php and the webapp
//including the nesesary things for the database connection
require_once "../secure/database.php";
//include the helper functions
require_once "helperFunctions.php";
//starting the session
session_start();
if (isset($_POST['HomeDescription'])) {
    //create connection with database
    $conn = pg_connect(HOST . " " . DBNAME . " " . USERNAME . " " . PASSWORD) or die('Could not connect: ' . pg_last_error());
    //set up varibles
    $description = htmlspecialchars($_POST['HomeDescription']);
    //updateprepare stamtnet
    $resultForUpdating = pg_prepare($conn, "updating", 'UPDATE lab8.user_info
        SET description = $1 WHERE username LIKE $2') or die("Updating prepare Fail: " . pg_last_error());
    //update execute stamtnet
    $resultForUpdating = pg_execute($conn, "updating", array($description, $_SESSION['user'])) or die("Updating Execute fail: " . pg_last_error());
    //update the log with the action that just occured
    $resultForlog = pg_prepare($conn, "logUpdate", "INSERT INTO lab8.log\n          VALUES(DEFAULT,\$1,\$2,DEFAULT,\$3)") or die("logUpdate prepare fail: " . pg_last_error());
    $resultForlog = pg_execute($conn, "logUpdate", array($_SESSION['user'], getClientIP(), "Updated Description")) or die("logupdate execute fail: " . pg_last_error());
    //close all the connections
    pg_free_result($resultForUpdating);
    pg_free_result($resultForlog);
    pg_close($conn);
}
开发者ID:samkreter,项目名称:PHP-Postgresql-work,代码行数:27,代码来源:homelogic.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getClientIp函数代码示例发布时间:2022-05-15
下一篇:
PHP getClient函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap