linux调整系统时间和时区的方法

Standard

linux调整系统时间和时区的方法

1) 找到相应的时区文件 /usr/share/zoneinfo/Asia/Shanghai

用这个文件替换当前的/etc/localtime文件。

2) 修改/etc/sysconfig/clock文件,修改为:
Z O N E=”Asia/Shanghai”
UTC=false
ARC=false

3)
时间设定成2007年11月13日的命令如下:
#date -s 11/13/2007

将系统时间设定成下午6点38分0秒的命令如下。
#date -s 18:38:00

4)
同步BIOS时钟,强制把系统时间写入CMOS,命令如下:
#clock -w

5)重启。

PS:
把时间及时区调整完后samba service突然莫明奇妙的出问题了,config文件说是被异常关闭过了,害得我又要重新配一次-_-

Winxp上配Apache Mysql PHP及Linux上一些问题的备注

Standard

1.如果PHP5按网上的教程还认不出Mysql Module的话就在Apache的httpd.conf头上加一句”loadfile c:/php/libmysql.dll”

2.如果Apache mod_rewrite.so注释去掉重启后还没能认出网站目录下.htaccess文件的话,记得看一下目录配置中是否为”AllowOverride All”及”Options Indexes FollowSymLinks”

3.如果Mysql开了远程连接用户还连不上的话,记得确认一下是不是自己IP地址打错了,呵呵:)

4.解决PHP Warning: Cannot modify header information – headers already sent by ……打开 php.ini 然后把 output_buffering 设为 on .重起appache,OK.

5.fedora装好后鼠标箭头找不着可以修改/etc/X11/xorg.conf文件,在Section Device 中最后部分 添加Option “HWCursor” “false”后重新启动

6.samba服务配好后在window中可以看到主机及目录但不到登录时就检查SELinux配置

公司考勤系统的数据结构及SQL

Standard

CREATE TABLE IF NOT EXISTS tb_timecard (
timecard_id bigint(20) unsigned NOT NULL auto_increment,
timecard_user int(10) unsigned NOT NULL DEFAULT ” ,
timecard_ip varchar(16) NOT NULL DEFAULT ” ,
timecard_onduty datetime NOT NULL DEFAULT ” ,
timecard_offduty datetime NOT NULL DEFAULT ” ,
timecard_overtime datetime NOT NULL DEFAULT ” ,
timecard_memo tinytext ,
timecard_state tinyint(3) unsigned NOT NULL DEFAULT ‘0’ ,
PRIMARY KEY (timecard_id),
UNIQUE KEY timecard_id (timecard_id),
KEY timecard_id_2 (timecard_id),
KEY idx_datetime (timecard_offduty,timecard_onduty,timecard_overtime),
KEY idx_user (timecard_user)
);
<?php
$sql=”SELECT user_name,timecard_memo,timecard_ip,”;
$sql.=”CASE WHEN DATE_FORMAT(timecard_offduty,’%k:%i’)=’0:00′ “;
$sql.=”THEN “;
$sql.=”IF(DATE_FORMAT(timecard_overtime,’%k:%i’)<>’0:00′,TIME_FORMAT(TIMEDIFF(timecard_overtime,timecard_onduty),’%H:%i’),’00:00′) “;
$sql.=”ELSE TIME_FORMAT(TIMEDIFF(timecard_offduty,timecard_onduty),’%H:%i’) “;
$sql.=”END as t_worktime,”;
$sql.=”DATE_FORMAT(timecard_onduty,’%k:%i’) as t_onduty,”;
$sql.=”IF(DATE_FORMAT(timecard_offduty,’%k:%i’)<>’0:00′,DATE_FORMAT(timecard_offduty,’%k:%i’),”) as t_offduty,”;
$sql.=”IF(DATE_FORMAT(timecard_overtime,’%k:%i’)<>’0:00′,DATE_FORMAT(timecard_overtime,’%k:%i’),”) as t_overtime,”;
$sql.=”IF(DATE_FORMAT(timecard_overtime,’%k:%i’)<>’0:00′,TIME_FORMAT(TIMEDIFF(timecard_overtime,CONCAT(DATE_FORMAT(timecard_onduty,’%Y-%c-%d’),’ 18:00:00′)),’%H:%i’),”) as t_overtimeworktime,”;
$sql.=”DATE_FORMAT(timecard_onduty,’%Y-%m-%d %W’) as t_dateweek “;
$sql.=”FROM tb_timecard “;
$sql.=”INNER JOIN tb_user ON user_id=timecard_user “;
$sql.=”WHERE YEAR(NOW())=YEAR(timecard_onduty) and MONTH(timecard_onduty)=”.$_POST[‘select_month’].” and timecard_user=”.$_POST[‘select_user’].” “;
$sql.=”GROUP BY date_format(timecard_onduty,’%Y-%m-%d’) order by timecard_onduty”;
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo “总工作时间:”.$row[‘t_worktime’];
echo “上班考勤时间:”.$row[‘t_onduty’];
echo “下班考勤时间:”.$row[‘t_offduty’];
echo “加班时间:”.$row[‘t_overtimeworktime’];
}
?>

VB.NET更改域用户身份复制文件到域中的共享目录

Standard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Imports System.Management
Imports System.Security.Principal
 
Module modTemp
 
  Dim WITH_PROFILE As Integer = 5
  Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
  Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
  Const LOGON32_LOGON_NETWORK As Long = 3
 
  Dim impersonationContext As WindowsImpersonationContext
 
  Declare Function LogonUserA Lib "advapi32.dll" (ByVal lpszUsername As String, _
              ByVal lpszDomain As String, _
              ByVal lpszPassword As String, _
              ByVal dwLogonType As Integer, _
              ByVal dwLogonProvider As Integer, _
              ByRef phToken As IntPtr) As Integer
 
  Declare Auto Function DuplicateToken Lib "advapi32.dll" ( _
              ByVal ExistingTokenHandle As IntPtr, _
              ByVal ImpersonationLevel As Integer, _
              ByRef DuplicateTokenHandle As IntPtr) As Integer
 
  Declare Auto Function RevertToSelf Lib "advapi32.dll" () As Long
  Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal handle As IntPtr) As Long
 
  Public Function impersonateValidUser(ByVal userName As String, ByVal domain As String, _
  ByVal password As String) As Boolean
 
    Dim tempWindowsIdentity As WindowsIdentity
    Dim token As IntPtr = IntPtr.Zero
    Dim tokenDuplicate As IntPtr = IntPtr.Zero
    impersonateValidUse* = **lse
 
    If RevertToSelf() Then
      If LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, _
        LOGON32_PROVIDER_DEFAULT, token) &lt;&gt; 0 Then
        If DuplicateToken(token, 2, tokenDuplicate) &lt;&gt; 0 Then
          tempWindowsIdentity = New WindowsIdentity(tokenDuplicate)
          impersonationContext = tempWindowsIdentity.Impersonate()
          If Not impersonationContext Is Nothing Then
            impersonateValidUser = True
          End If
        End If
      End If
    End If
    If Not tokenDuplicate.Equals(IntPtr.Zero) Then
      CloseHandle(tokenDuplicate)
    End If
    If Not token.Equals(IntPtr.Zero) Then
      CloseHandle(token)
    End If
  End Function
 
  Public Sub undoImpersonation()
    impersonationContext.Undo()
  End Sub
 
End Module
 
  'www.yemaosheng.com
 
  Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
    If impersonateValidUser("username", "domainname", "password") Then
      Call ToCopyFile()
    Else
      MsgBox("Impersonation failed")
    End If
  End Sub
 
  Private Sub ToCopyFile()
    Try
      Dim strSource As String
      strSource = "C:\Documents and Settings\yemaosheng\桌面\test.txt"
 
      Dim strTarget As String
      strTarget = "\\domain-svr\temp\test_ye.txt"
 
      System.IO.File.Copy(strSource, strTarget, True)
 
    Catch ex A* **ception
      MsgBox(ex.Message.ToString, , "提示")
    End Try
  End Sub

SQLServer无法连接到服务器用户xxx登陆失败的解决方法

Standard

“无法连接到服务器,用户xxx登陆失败”
该错误产生的原因是由于SQL Server使用了”仅 Windows”的身份验证方式,
因此用户无法使用SQL Server的登录帐户(如 sa )进行连接.解决方法如下所示:

1.使用企业管理器,展开”SQL Server组”
2.鼠标右键点击SQL Server服务器的名称,选择”属性”
3.选择”安全性”选项卡,在”身份验证”下,选择”SQL Server和 Windows “,”确定”
4.重新启动SQL Server服务.

有时点了确定后仍然不生效,那就通过修改注册表来解决此问题:

1.点击”开始””运行”,输入regedit,回车进入注册表编辑器
2.依次展开注册表项,浏览到以下注册表键:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer]
3.在屏幕右方找到名称”LoginMode”,双击编辑双字节值
4.将原值从1改为2,点击”确定”
5.关闭注册表编辑器
6.重新启动SQL Server服务.

SQLServer的@@IDENTITY和Mysql的LAST_INSERT_ID()

Standard

CREATE PROCEDURE NewWeekPlan
@file_type numeric(1),
@file_department varchar(50),
@file_station varchar(50),
@file_owner numeric(9),

@weekplan_wk1plan varchar(255),
@weekplan_wk2plan varchar(255),
@weekplan_wk3plan varchar(255),
@weekplan_wk4plan varchar(255),
@weekplan_wk5plan varchar(255),
@weekplan_wk1result varchar(255),
@weekplan_wk2result varchar(255),
@weekplan_wk3result varchar(255),
@weekplan_wk4result varchar(255),
@weekplan_wk5result varchar(255),
@weekplan_wk1plannext varchar(255),
@weekplan_wk2plannext varchar(255),
@weekplan_wk3plannext varchar(255),
@weekplan_wk4plannext varchar(255),
@weekplan_wk5plannext varchar(255),
@weekplan_problem1 varchar(255),
@weekplan_problem2 varchar(255),
@weekplan_problem3 varchar(255),
@weekplan_suggest1 varchar(255),
@weekplan_suggest2 varchar(255),
@weekplan_suggest3 varchar(255)

AS INSERT INTO tb_file (file_type,file_department,file_station,file_owner) VALUES (@file_type,@file_department,@file_station,@file_owner)
if @@IDENTITY>0
INSERT INTO tb_file_weekplan (weekplan_file,weekplan_wk1plan,weekplan_wk2plan,weekplan_wk3plan,weekplan_wk4plan,weekplan_wk5plan) VALUES (@@IDENTITY,@weekplan_wk1plan,@weekplan_wk2plan,@weekplan_wk3plan,@weekplan_wk4plan,@weekplan_wk5plan)
GO

//———————-yemaosheng.com——————————–
用 last_insert_id() 函数这样来模拟一个 sequence 实现:

mysql> CREATE TABLE sequence (id INT NOT NULL);
mysql> INSERT INTO sequence VALUES (0);

mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1);

关于Apache2 VirtualHost二级域名只生效一个的问题

Standard

Apache2 config文件新增二级域名如下:
<VirtualHost *:80>
ServerName maillist.yemaosheng.com
ServerAlias maillist.yemaosheng.com
DocumentRoot /var/www/html/maillist.yemaosheng.com
</VirtualHost>
<VirtualHost *:80>
ServerName cms.yemaosheng.com
ServerAlias cms.yemaosheng.com
DocumentRoot /var/www/html/cms.yemaosheng.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.yemaosheng.com
DocumentRoot /var/www/html/www.yemaosheng.com
</VirtualHost>

本地电脑上hosts.ini文件已经添加
192.168.42.12 maillist.yemaosheng.com
192.168.42.12 cms.yemaosheng.com
192.168.42.12 www.yemaosheng.com

只能访问到maillist.yemaosheng.com
cms.yemaosheng.com还是指到maillist.yemaosheng.com上面了
而www.yemaosheng.com则显示You don”t have permission to access / on this server.
感觉后面加的二级域名只能匹配到maillist.yemaosheng.com

问题解决
vhost的config文件头上加一行 NamevirtualHost *:80 就OK了

Linux iptables 开放Mysql端口

Standard

修改防火墙配置文件:
vi /etc/sysconfig/iptables
增加下面一行:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
如果想开通21等端口,只需要将3306换成21等要开放的端口就可以了。
配置后,重新启动iptable
service iptables restart
这时就可以从外网访问Mysql了。

BLOG交换链接

Standard

链接要求如下:

链接名称:叶茂盛
链接地址:http://yemaosheng.com
链接说明:YeMaosheng’s Blog

1.网站被Google收录100条链接以上,且非采集站。
2.顶级域名,空间稳定。
3.谢绝想用链接来SEO某个关键字的网站。
4.请在您网站首页做好链接后留言,以便我看到后加上您的连接。
5.我会经常浏览您的网站,如发现链接超时或长时间不更新了就会删除。