VB+PHPはオンラインでWindowsサーバーのプロファイルを修正することを実現する

13815 ワード

*本書は記録、保存記録用のみです.
用途:ある電話転送システムは、毎日プロファイルを変更し、サービス側プログラムを再起動する必要がある.
原理:WEBはインタフェースを修正することを展示するために用いて、配置ファイルの関連データを提出して保存します
VB端子は、タイミングローテーションWEB上に保存されているデータに用いられ、ローカルと一致しないことを発見した場合に同期し、WEB端子にログをフィードバックする.
拡張:VB端子はPython、Shellなどで書き換えられ、マルチプラットフォーム環境に適応できる.
WEB端末の主なコード:
<?php

//--------------      ,    --------------
function ty1921($phonenum,$date){
	$open=fopen("E:\WAMP\WWWROOT\XXXXXXXXX_callout.txt","w" );
	$open2=fopen("E:\WAMP\WWWROOT\XXXXXXXXX_callout_log.txt","a" );
	$open3=fopen("E:\WAMP\WWWROOT\XXXXXXXXX_callout_date.txt","w" );

	if(fwrite($open,$phonenum)){//     
		if(fwrite($open2,$phonenum."  ".date("Y-m-d H:i:s")."\r
")){// if(!fwrite($open3,$date)){ echo "ok"; }else{ $err="XXXXXXXXX_callout_date :".$date; } }else{ $err=" "; }; }else{ $err=" XXXXXXXXX_callout.txt "; }; fclose($open); } //-------------- -------------- $phonenum=trim($_REQUEST['phonenum']); // 、 if(!empty($_REQUEST['type']) and !empty($_REQUEST['phonenum'])){ if(strlen($phonenum) == "11") { // 11 $n = preg_match_all("/13[0-9]{1}\d{8}|15[0-9]\d{8}|18[0-9]\d{8}/",$phonenum,$array); ty1921($_REQUEST['phonenum'],$_REQUEST['date']); $err=" ! "; }else { $err=" :".$_REQUEST['phonenum']; } } ?> <form method="post" action="?type=web&date=<?=date("Y-m-d")?>"> <table align="center"><tr><td align="left"> <div style="width:500px;height:500px;background-color:eeeeee;text-align:left"> <h2>XXXXXXXXX </h2> :<input id="phonenum" name="phonenum" maxlength="11" onkeyup="value=value.replace('0','0').replace('1','1').replace('2','2').replace('3', '3').replace('4','4').replace('5','5').replace('6','6').replace('7', '7').replace('8','8').replace('9','9');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace('0','0').replace('1','1').replace('2','2').replace('3', '3').replace('4','4').replace('5','5').replace('6','6').replace('7', '7').replace('8','8').replace('9','9'))" /> <br><font size="2" color="555555">* , <b>2</b> , 2 </font> <br><br> <input type="submit" value=" " > <? $file_name="E:\WAMP\WWWROOT\XXXXXXXXX_callout.txt"; $file_name2="E:\WAMP\WWWROOT\XXXXXXXXX_callout_log.txt"; $fp=fopen($file_name,'r'); if(!feof($fp)){ $buffer=fgets($fp,32); echo "<hr> : ".date("Y-m-d H:i:s")."    :【 XXXXXXXXX → <font color='red'>".$buffer."</font> 】<hr>"; $file2=file($file_name2); $start=count($file2)-1; $end=count($file2)-16; for ($i=$start;$i>$end;$i--) { //$arr[]=fgets($file2);// 100~200 if(!empty($file2[$i])){ echo $file2[$i]."<br>"; } } } fclose($fp); echo "</div>"; echo "<hr>".date("Y-m-d H:i:s")." →".$err."<hr>"; ?> </td></tr></table> </form>

VB端FRMコード、form 1として保存する.frm:
VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form Form1 
   Caption         =   "XXXXXXXXX      "
   ClientHeight    =   7035
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6705
   LinkTopic       =   "Form1"
   ScaleHeight     =   7035
   ScaleWidth      =   6705
   StartUpPosition =   1  '     
   Begin VB.CommandButton Command3 
      Caption         =   "     "
      BeginProperty Font 
         Name            =   "   "
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5400
      TabIndex        =   11
      Top             =   6600
      Width           =   1215
   End
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   4440
      Top             =   6480
   End
   Begin InetCtlsObjects.Inet Inet1 
      Left            =   3720
      Top             =   6360
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
   End
   Begin VB.Frame Frame2 
      Caption         =   "     "
      Height          =   4575
      Left            =   120
      TabIndex        =   1
      Top             =   1920
      Width           =   6495
      Begin VB.TextBox Text1 
         BorderStyle     =   0  'None
         Height          =   4215
         Left            =   120
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         TabIndex        =   2
         Text            =   "Form1.frx":0000
         Top             =   240
         Width           =   6255
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "      (http://192.168.*.*/XXXXXXXXX_callout.php)"
      Height          =   1695
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6495
      Begin VB.CommandButton Command1 
         Caption         =   "    "
         BeginProperty Font 
            Name            =   "  -PUA"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4800
         TabIndex        =   9
         Top             =   960
         Width           =   1455
      End
      Begin VB.CommandButton Command2 
         Caption         =   "    "
         BeginProperty Font 
            Name            =   "  -PUA"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2880
         TabIndex        =   10
         Top             =   960
         Width           =   1935
      End
      Begin VB.CheckBox Check1 
         Caption         =   "    "
         BeginProperty Font 
            Name            =   "  "
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   8
         Top             =   960
         Value           =   1  'Checked
         Width           =   1695
      End
      Begin VB.Label Label2 
         BeginProperty Font 
            Name            =   "  "
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   255
         Left            =   1440
         TabIndex        =   4
         Top             =   360
         Width           =   4455
      End
      Begin VB.Label Label4 
         BeginProperty Font 
            Name            =   "  "
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   255
         Left            =   1440
         TabIndex        =   6
         Top             =   600
         Width           =   4935
      End
      Begin VB.Label Label3 
         Caption         =   "    :"
         BeginProperty Font 
            Name            =   "  "
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000011&
         Height          =   255
         Left            =   360
         TabIndex        =   5
         Top             =   600
         Width           =   1455
      End
      Begin VB.Label Label1 
         Caption         =   "    :"
         BeginProperty Font 
            Name            =   "  "
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00808080&
         Height          =   255
         Left            =   360
         TabIndex        =   3
         Top             =   360
         Width           =   1335
      End
   End
   Begin VB.Label Label5 
      Caption         =   "Copyright(c) 2013 ty1921 "
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   6600
      Width           =   3015
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileStringByKeyName& Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String)
Public I As Integer
Public Callout_date

Private Sub Command2_Click()
    Call Ty1921
End Sub

Private Sub Command3_Click()
    End
End Sub

Private Sub Form_Load()

    Call Ty1921
    I = 60

End Sub



Private Sub Command1_Click()
   '    
   I = 3

End Sub





Private Sub Timer1_Timer()
    
    I = I - 1
    
    If I <= 0 Then
        Call Ty1921
            
        If Left(Label2.Caption, 11) <> Left(Label4.Caption, 11) Then
            '     ,        
            Call ReBoot(Left(Trim(Label2.Caption), 11))
        End If
        
        '      
        If Check1.Value = 1 And Time <= "00:06:00" Then
            
            '    
            Callout_date = Inet1.OpenURL("http://192.168.*.*/XXXXXXXXX_callout_date.txt")
            If Date <> Callout_date Then
            '    
                If Left(Label2.Caption, 11) = "181XXXXXXXX" Then
                    Call ReBoot("181XXXXXXXX")
                ElseIf Left(Label2.Caption, 11) = "189XXXXXXXX" Then
                    Call ReBoot("181XXXXXXXX")
                Else
                    Call ReBoot("XXXXXXXX")'    
                End If
            End If
        End If
        
        '  
        I = 120
        
        
    Else
        Command2.Caption = "     (" & I & ")"
    End If
    
    
    
End Sub


Sub Ty1921()

    Dim CallOut As String * 32
    GetPrivateProfileString "DATABASE", "callout", "  ,    ", CallOut, 255, "d:\zhai\IvrConfig.ini"
    Label4.Caption = Trim(Str(CallOut)) & " | " & Now
    
    Label2.Caption = Inet1.OpenURL("http://192.168.*.*/XXXXXXXXX_callout.txt") & " | " & Now
    
    Text1.Text = Inet1.OpenURL("http://192.168.*.*/XXXXXXXXX_callout_log.txt")

End Sub

Sub ReBoot(ByVal PhoneNum As String)

    Dim Result_i
    WritePrivateProfileStringByKeyName& "DATABASE", "callout", PhoneNum, "d:\zhai\IvrConfig.ini"
    '      
    Result_i = Inet1.OpenURL("http://192.168.*.*/XXXXXXXXX_callout.php?type=vb&date=" & Date & "&phonenum=" & PhoneNum)
    If Result_i = "ok" Then
        Call Ty1921
    End If

            
    '    
    Shell ("cmd /c taskkill /f /im demo.exe"), vbHide
    '    
    Shell ("D:\zhai\demo.exe"), vbNormalFocus

End Sub