要防止同一用户同时登陆,首页应该记录在线用户的信息(这里与用户名为例),然后判断正在登陆的用户里面是否已存在.在这里使用一个cache存放已经登陆的用户名.但是还有一个问题就是要知道用户是什么时候离开系统的呢?这就要定期清除cache中的内容了,也就是设置一个cache的时间.这个时间可以跟用户的session值联系起来.刚好当用户session值失效的时候该用户在cache里面的信息也会被清空.这样就达到了防止同时登陆的效果,具体代码如下: 放在登陆成功的地方 string key = TextBox1.Text; //用户名文本框设为cache关键字 string uer = Convert.ToString(Cache[key]); //读取cache中用户相应的值 //判断cache中是否有用户的信息,如果没有...
<?php
function UPCAbarcode($code) {
$lw = 2; $hi = 100;
$Lencode = array('0001101','0011001','0010011','0111101','0100011',
'0110001','0101111','0111011','0110111','0001011');
$Rencode = array('1110010','1100110','1101100','1000010','1011100',
'1001110','1010000','1000100','1001000','1110100');
$ends = '101'; $center = '01010';
/* UPC-A Must be 11 digits, we compute the checksum. */
if ( strlen($code) != 11 ) { die("UPC-A Must be 11 digits."); }
/* Compute the EAN-13 Checksum digit */
$ncode = '0'.$code;
$even = 0; $odd = 0;
for ($x=0;$x<12;$...
经常会有人问模拟登陆的问题,其实原理很简单,只要把SessionID保存下来就可以了,今天花了一个小时的时间写了一个函数,供大家参考,网站返回的头信息,具体网站具体分析。
源代码:
<?php
/*
* 得到网页内容
* 参数:$host [in] string
* 主机名称(例如: www.imsorry.com.cn)
* 参数:$method [in] string
* 提交方法:POST, GET, HEAD ... 并加上相应的参数( 具体语法参见 RFC1945,RFC2068 )
* 参数:$str [in] string
* 提交的内容
* 参数:$sessid [in] string
* PHP的SESSIONID
*
* @返回 网页内容 string
*/
function GetWebContent($host, $method, $str, $sess...
你可以这样做建一个模块在里面输入下列 Public conn As ADODB.Connection Sub main() Set conn = New ADODB.Connection conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _ + "User ID=sa;password=sa;Initial Catalog=您的数据库名;Data Source=127.0.0.1" conn.Open from1.Show '登录界面 End Sub 再在登录界面“确定”下写入如下代码: Private Sub Command1_Click() If id.Text = "" Then MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示" id.SetFocus Exit Sub E...
<?phpfunction UPCAbarcode($code) {$lw = 2; $hi = 100;$Lencode = array('0001101','0011001','0010011','0111101','0100011','0110001','0101111','0111011','0110111','0001011');$Rencode = array('1110010','1100110','1101100','1000010','1011100','1001110','1010000','1000100','1001000','1110100');$ends = '101'; $center = '01010';/* UPC-A Must be 11 digits, we compute the checksum. */if ( strlen($code) != 11 ) { die("UPC-A Must be 11 digits."); }/* Compute the EAN-13 Checksum digit */$ncode = '0'.$code;$even = 0; $odd = 0;for ($x=0;$x<12;$x ) {if ($x % 2) { $odd = $n...
'================================================== '函数名:PostHttpPage '作 用:登录 '参 数:RefererUr-----登录地址 '参 数:PostUrl-----提交地址 '参 数:PostData-----用户参数 '================================================== Function PostHttpPage(RefererUrl,PostUrl,PostData) Dim xmlHttp Dim RetStr 'Set xmlHttp = CreateObject("Msxml2.XMLHTTP") Set xmlHttp = CreateObject("Msx" & "ml2.XM" & "LHT" & "TP") xmlHttp.Open "POST", PostUrl, False XmlHT...