一款自动竞拍出价程序

 更新时间:2016年11月25日 16:26  点击:1234

用户提交自己的信息后,保存在数据库教程中,程序每一次读取当前结果时都要判断一次,如用户可设置几秒钟时参加竞拍,竞拍多少次,并且可以设置前面有多少人竞拍后我才参加,都是一些人性化的功能//自动出价

function auto($second,$gid,$shutuid)
{
        global $table_prefix;
        //取出此商品已经竞拍次数
        $maxnumber=0;
        $unumber=array();
        $query=mysql教程_query("select id,uid from `".$table_prefix."buylog` where gid=".$gid);
        while($rows=mysql_fetch_assoc($query))
        {
                $maxnumber++;
                if(isset($unumber[$rows['uid']]))
                {
                        $unumber[$rows['uid']]++;
                }
                else
                {
                        $unumber[$rows['uid']]=0;
                }
        }
       
        //取出自动竞拍的会员
        $sql="select uid,username,number,second,maxnumber,gid,ip from `".$table_prefix."autobuy` where gid=".$gid;
        $query=mysql_query($sql);
        $allow=array();
        $shutuid=explode(',',$shutuid);
        while($rows=mysql_fetch_assoc($query))
        {
                $seconds=explode(',',$rows['second']);
                $unumber[$rows['uid']]=isset($unumber[$rows['uid']])?$unumber[$rows['uid']]:0;
                if(in_array($second,$seconds) && !in_array($rows['uid'],$shutuid) && $rows['maxnumber']<=$maxnumber && $rows['number']>$unumber[$rows['uid']]) //包含时刻,并且不在黑名单,符合此会员竞拍次数设置
                {
                        $allow[]=$rows['uid'];
                }
        }
        $allowuser=array();
        if($allow)
        {
                $query=mysql_query('select uid,username,money,ip from `'.$table_prefix.'user` where uid in ('.implode(',',$allow).')');
                while($rows=mysql_fetch_assoc($query))
                {
                        $allowuser[]=$rows;
                }
        }
        unset($allow,$sql,$number,$maxnumber,$shutuid,$query,$u);
        return $allowuser;
}

用php教程可扩展特性实现可以远程保存游戏用户日志信息,这里我暂时叫他tlog(与文件服务器建立tcp/ip连接,当然最好是udp),目前定义了三个函数
tlog_init,tlog_record,tlog_close
tlog_init(ip,port)用来连接文件服务器其中ip,port分别为文件服务器地址和端口
tlog_record(message,file)用户发送要记录的日志内容和日志保存的文件
tlog_close为关闭发送日志产生的socket链接

<?php
$result = tlog_init("127.0.0.1", 9734);
if ($result) {
    tlog_record("hello" . time(), '1.log');
    tlog_record("hello world" . time(), '2.log');
    tlog_close();
}
?>

我们主要修改config.m4,tlog.c,php_tlog.h实现我们要的功能
   打开config.m4,
  删除 php_arg_enable(tlog, whether to enable tlog support, 行开始注释dnl
  删除[  --enable-tlog           enable tlog support]) 行开始注释dnl
  打开php_tlog.h 增加


php_function(tlog_init);
php_function(tlog_record);
php_function(tlog_close);

外t_log.c见包
  以上步骤后进入tlog目录执行
   ./你的php安装目录/bin/phpize 我的目录为/usr/local/webserver/php5.3.3,则该命令./usr/local/webserver/php5.3.3/bin/phpize
./configure --with-php-config=/usr/local/webserver/php5.3.3/bin/php-config
make
sudo make install  (因为我使用的ubuntu,所以带了sudo主要是php安装目录创建扩展时的权限问题)

修改php.ini增加tlog.so扩展

查看phpinfo();

这是一款简单PHP图片上传类带图片显示代码,应该可以说是上传文件最简单的上传类了,可以设置要显示图片高度与宽度,文件大小等。

uploadimg.class.php文件

 代码如下 复制代码

class upload
{
var $upload_name;
var $upload_tmp_address;
var $upload_server_name;
var $upload_filetype ;
var $file_type;
var $file_server_address;
var $image_w=900; //要显示图片的宽
var $image_h=350; //要显示图片的高
var $upload_file_size;
var $upload_must_size= 50000; //允许上传文件的大小,自己设置
function upload_file()
{
$this->upload_name = $_files["file"]["name"]; //取得上传文件名
$this->upload_filetype = $_files["file"]["type"];
$this->upload_server_name = date("y_m_dh_i_s").$this->upload_name;
$this->upload_tmp_address = $_files["file"]["tmp_name"]; //取得临时地址
$this->file_type = array("image/gif","image/pjpeg"); //允许上传文件的类型
$this->upload_file_size = $_files["file"]["size"]; //上传文件的大小
if(in_array($this->upload_filetype,$this->file_type))
{ if($this->upload_file_size < $this->upload_must_size)
{
echo("上传成功,谢谢支持");
$this->file_server_address = "d:www.111cn.netupload/".$this->upload_server_name;
move_uploaded_file($this->upload_tmp_address,$this->file_server_address);//从temp目录移出
echo("<img src=$this->file_server_address width=$this->image_w height=$this->image_h/>"); //显示图片


}
else
{
echo("文件容量太大");
}
}
else
{
echo("不支持此文件类型,请重新选择");
}

}

}


html上传代码

 代码如下 复制代码

<form id="form1" name="upload" enctype="multipart/form-data" method="post" action="upload.php">
<input type="hidden" name="max_file_size " />
<input type="file" name="file" />
<input type="submit" name="submit" value="提交" />
</form>


调用方法
upload.php

 代码如下 复制代码

inlcude('uploadimg.class.php');

$dd = new upload;
$dd->upload_file();

 

文章收藏了三款php计数器代码,他们三个都有一个同共点就是全部无需数据库,而是利用了文本文件来实例网页浏览计数哦。
 代码如下 复制代码
<?php
//计数器
function countx($file="count.dat"){
if(file_exists($file)){
$fp=fopen($file,"r");
$numx=fgets($fp,10);
fclose($fp);
$numx++;
//以上四行代码可以用一条表达式代替:$numx=file_get_contents($file)+1;
}
else{
$numx=1;}
file_put_contents($file,$numx);//当文件不存在时,这函数会自动创建文件,而且会自动把参数转成字符串写入。
echo $numx;
/*整个函数体可以用两条表达式代替:file_exists($file)?file_put_contents($file,file_get_contents($file)+1):file_put_contents($file,"1");readfile($file);
*/
}
//函数调用
countx();
?>

代码二

 代码如下 复制代码

<?php
  
  
  $counterfile = "balong.txt";//存储数值的文件名几路径
  
  function displaycounter($counterfile) {
   $fp = fopen($counterfile,"rw");
   $num = fgets($fp,5);
   $num += 1;
   print "您是第 "."$num"." 个看巴泷计数器的家伙";
   exec( "rm -rf $counterfile");
   exec( "echo $num > $counterfile");
  }
  
  if (!file_exists($counterfile)) {
   exec( "echo 0 > $counterfile");
  }
  
  displaycounter($counterfile);
  
  ?>


代码三

 代码如下 复制代码

<?php
  
  
  $counterfile = "www.111cn.net.txt";//存储数值的文件名几路径
  
  function displaycounter($counterfile) {
   $fp = fopen($counterfile,"rw");
   $num = fgets($fp,5);
   $num += 1;
   print "您是第 "."$num"." 个看巴泷计数器的家伙";
   exec( "rm -rf $counterfile");
   exec( "echo $num > $counterfile");
  }
  
  if (!file_exists($counterfile)) {
   exec( "echo 0 > $counterfile");
  }
  
  displaycounter($counterfile);
  
  ?>

提供一款国人写的留言板,他是利用了jquery php mysql ajax来实现php ajax 局部刷新留方板实例的喜欢就下载吧。

*/

 代码如下 复制代码

$link = @mysql_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');

mysql_query("set names 'utf8'");
mysql_select_db($db_database,$link);

class comment
{
 private $data = array();
 
 public function __construct($row)
 {
  /*
  / the constructor
  */
  
  $this->data = $row;
 }
 
 public function markup()
 {
  /*
  / this method outputs the xhtml markup of the comment
  */
  
  // setting up an alias, so we don't have to write $this->data every time:
  $d = &$this->data;
  
  $link_open = '';
  $link_close = '';
  
  if($d['url']){
   
   // if the person has entered a url when adding a comment,
   // define opening and closing hyperlink tags
   
   $link_open = '<a href="'.$d['url'].'">';
   $link_close =  '</a>';
  }
  
  // converting the time to a unix timestamp:
  $d['dt'] = strtotime($d['dt']);
  
  // needed for the default gravatar image:
  $url = 'http://'.dirname($_server['server_name'].$_server["request_uri"]).'/img/default_avatar.gif';
  
  return '
  
   <div class="comment">
    <div class="avatar">
     '.$link_open.'
     <img src="http://www.gravatar.com/avatar/'.md5($d['email']).'?size=50&amp;default='.urlencode($url).'" />
     '.$link_close.'
    </div>
    
    <div class="name">'.$link_open.$d['name'].$link_close.'</div>
    <div class="date" title="added at '.date('h:i on d m y',$d['dt']).'">'.date('d m y',$d['dt']).'</div>
    <p>'.$d['body'].'</p>
   </div>
  ';
 }
 
 public static function validate(&$arr)
 {
  /*
  / this method is used to validate the data sent via ajax.
  /
  / it return true/false depending on whether the data is valid, and populates
  / the $arr array passed as a paremter (notice the ampersand above) with
  / either the valid input data, or the error messages.
  */
  
  $errors = array();
  $data = array();
  
  // using the filter_input function introduced in php 5.2.0
  
  if(!($data['email'] = filter_input(input_post,'email',filter_validate_email)))
  {
   $errors['email'] = 'please enter a valid email.';
  }
  
  if(!($data['url'] = filter_input(input_post,'url',filter_validate_url)))
  {
   // if the url field was not populated with a valid url,
   // act as if no url was entered at all:
   
   $url = '';
  }
  
  // using the filter with a custom callback function:
  
  if(!($data['body'] = filter_input(input_post,'body',filter_callback,array('options'=>'comment::validate_text'))))
  {
   $errors['body'] = 'please enter a comment body.';
  }
  
  if(!($data['name'] = filter_input(input_post,'name',filter_callback,array('options'=>'comment::validate_text'))))
  {
   $errors['name'] = 'please enter a name.';
  }
  
  if(!empty($errors)){
   
   // if there are errors, copy the $errors array to $arr:
   
   $arr = $errors;
   return false;
  }
  
  // if the data is valid, sanitize all the data and copy it to $arr:
  
  foreach($data as $k=>$v){
   $arr[$k] = mysql_real_escape_string($v);
  }
  
  // ensure that the email is lower case:
  
  $arr['email'] = strtolower(trim($arr['email']));
  
  return true;
  
 }

 private static function validate_text($str)
 {
  /*
  / this method is used internally as a filter_callback
  */
  
  if(mb_strlen($str,'utf8')<1)
   return false;
  
  // encode all html special characters (<, >, ", & .. etc) and convert
  // the new line characters to <br> tags:
  
  $str = nl2br(htmlspecialchars($str));
  
  // remove the new line characters that are left
  $str = str_replace(array(chr(10),chr(13)),'',$str);
  
  return $str;
 }

}

$comments = array();
$result = mysql_query("select * from comments order by id asc");

while($row = mysql_fetch_assoc($result))
{
 $comments[] = new comment($row);
}

?>

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>simple ajax commenting system | tutorialzine demo</title>

<link rel="stylesheet" type="text/css教程" href="styles.css" />

</head>

<body>

 


<div id="main">

<?php

/*
/ output the comments one by one:
*/

foreach($comments as $c){
 echo $c->markup();
}

?>

<div id="addcommentcontainer">
 <p>add a comment</p>
 <form id="addcommentform" method="post" action="">
     <div>
         <label for="name">your name</label>
         <input type="text" name="name" id="name" />
           
            <label for="email">your email</label>
            <input type="text" name="email" id="email" />
           
            <label for="url">website (not required)</label>
            <input type="text" name="url" id="url" />
           
            <label for="body">comment body</label>
            <textarea name="body" id="body" cols="20" rows="5"></textarea>
           
            <input type="submit" id="submit" value="submit" />
        </div>
    </form>
</div>

</div>

<script type="text/网页特效" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>

</body>
</html>

数据库教程结构

 代码如下 复制代码

--
-- table structure for table `comments`
--

create table `comments` (
  `id` int(10) unsigned not null auto_increment,
  `name` varchar(128) collate utf8_unicode_ci not null default '',
  `url` varchar(255) collate utf8_unicode_ci not null default '',
  `email` varchar(255) collate utf8_unicode_ci not null default '',
  `body` text collate utf8_unicode_ci not null,
  `dt` timestamp not null default '0000-00-00',
  primary key  (`id`)
) engine=myisam  default charset=utf8 collate=utf8_unicode_ci;

[!--infotagslink--]

相关文章

  • C#开发Windows窗体应用程序的简单操作步骤

    这篇文章主要介绍了C#开发Windows窗体应用程序的简单操作步骤,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-04-12
  • C++调用C#的DLL程序实现方法

    本文通过例子,讲述了C++调用C#的DLL程序的方法,作出了以下总结,下面就让我们一起来学习吧。...2020-06-25
  • 微信小程序 页面传值详解

    这篇文章主要介绍了微信小程序 页面传值详解的相关资料,需要的朋友可以参考下...2017-03-13
  • MyBatis-Plus自动填充功能失效导致的原因及解决

    这篇文章主要介绍了MyBatis-Plus自动填充功能失效导致的原因及解决,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-02-04
  • C#使用Process类调用外部exe程序

    本文通过两个示例讲解了一下Process类调用外部应用程序的基本用法,并简单讲解了StartInfo属性,有需要的朋友可以参考一下。...2020-06-25
  • 使用GruntJS构建Web程序之构建篇

    大概有如下步骤 新建项目Bejs 新建文件package.json 新建文件Gruntfile.js 命令行执行grunt任务 一、新建项目Bejs源码放在src下,该目录有两个js文件,selector.js和ajax.js。编译后代码放在dest,这个grunt会...2014-06-07
  • 微信小程序二维码生成工具 weapp-qrcode详解

    这篇文章主要介绍了微信小程序 二维码生成工具 weapp-qrcode详解,教大家如何在项目中引入weapp-qrcode.js文件,通过实例代码给大家介绍的非常详细,需要的朋友可以参考下...2021-10-23
  • uniapp微信小程序:key失效的解决方法

    这篇文章主要介绍了uniapp微信小程序:key失效的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-20
  • 将c#编写的程序打包成应用程序的实现步骤分享(安装,卸载) 图文

    时常会写用c#一些程序,但如何将他们和photoshop一样的大型软件打成一个压缩包,以便于发布....2020-06-25
  • PHP常用的小程序代码段

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
  • 微信小程序 网络请求(GET请求)详解

    这篇文章主要介绍了微信小程序 网络请求(GET请求)详解的相关资料,需要的朋友可以参考下...2016-11-22
  • 微信小程序自定义tabbar组件

    这篇文章主要为大家详细介绍了微信小程序自定义tabbar组件,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-03-14
  • 微信小程序如何获取图片宽度与高度

    这篇文章主要给大家介绍了关于微信小程序如何获取图片宽度与高度的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
  • 微信小程序实现点击导航条切换页面

    这篇文章主要为大家详细介绍了微信小程序实现点击导航条切换页面,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-11-19
  • 微信小程序手势操作之单触摸点与多触摸点

    这篇文章主要介绍了微信小程序手势操作之单触摸点与多触摸点的相关资料,需要的朋友可以参考下...2017-03-13
  • C#实现延时并自动关闭MessageBox的方法

    这篇文章主要介绍了C#实现延时并自动关闭MessageBox的方法,非常实用的功能,需要的朋友可以参考下...2020-06-25
  • 微信小程序(应用号)开发新闻客户端实例

    这篇文章主要介绍了微信小程序(应用号)开发新闻客户端实例的相关资料,需要的朋友可以参考下...2016-10-25
  • 微信小程序实现canvas分享朋友圈海报

    这篇文章主要为大家详细介绍了微信小程序实现canvas分享朋友圈海报,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-06-21
  • Python爬取微信小程序通用方法代码实例详解

    这篇文章主要介绍了Python爬取微信小程序通用方法代码实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-09-29
  • 微信小程序 页面跳转传递值几种方法详解

    这篇文章主要介绍了微信小程序 页面跳转传递值几种方法详解的相关资料,需要的朋友可以参考下...2017-01-16