Home > Backend Development > PHP Tutorial > Create a website on php WEB_PHP tutorial

Create a website on php WEB_PHP tutorial

WBOY
Release: 2016-07-20 11:06:05
Original
1210 people have browsed it

我们用php来控制iis并且,在WEB上创建网站,管理删除等功能哦。

我们用php来控制iis并且,在WEB上创建网站,管理删除等功能哦。

# PHP控制站点程序
#
# 编写人:韩湘子
#
# 邮箱:hanxiangzi@gmail.com
#
# MSN:hanxiangzi@gmail.com
#
# QQ:220670
#
# 欢迎大家互相联系讨论
?> 



 
   
   
   
   
   
   

$LocalHostObject = New Com ("IIS://localhost/w3svc") ;

//Delete site
iF($Opt=="del"){
$LocalHostObject->Delete("IIsWebServer",$ServerID);
echo "";
}

//Start and stop the site
iF($Opt=="Status"){
$Site2 = New Com ("IIS://LocalHost/w3svc/".$ServerID);
$Site2->$Status;
}


//Create new Site
iF($Submit){

//Create directory
// mkdir(stripslashes($ServerDir));


//Add user
$usernameobj = New Com("WinNT://iim");
$user = $usernameobj->Create("user",$ServerComm);


//Set username
$user->SetInfo();

//Set password
$user->SetPassword($ServerComm);
// $user->UserFlags('&H0040 ');
$user->SetInfo();

$usernameobj1 = New Com("WinNT://iim/".$ServerComm);
$user->Description = "This username was created by iiM online management system.";
$user->SetInfo();

#The only problem is the permissions to load the user into the directory##### ################################################ #######################################


//Create site


$iissite = $LocalHostObject->Create("IIsWebServer",$ServerID);

$aa = explode(", ",$ServerBin);

// //Set the basic information of the site first
$iissite->ServerBindings = $aa;
$iissite->ServerComment = $ServerComment;
$iissite->AnonymousUserName = $ServerComm;
$iissite->AnonymousUserPass = $ServerComm;
$iissite->KeyType = "IIsWebServer";
$iissite->EnableDefaultDoc = True ;
$iissite->DefaultDoc = "default.htm,default.asp,index.htm,index.html";
$iissite->LogFileDirectory = "d:";
$iissite- >MaxBandwidth = '102400';
$iissite->MaxConnections = '100';
$iissite->LogType = "0";
$iissite->AppIsolated = 0;
$iissite->AuthBasic = False;
$iissite->AuthNTLM = True;
$iissite->HttpErrors = "404,*,FILE,C:WINDOWShelpiisHelpcommon404b.htm";
/ /Add script mapping
foreach($scriptmapsubmit as $script){
Switch($script){
Case "asp";
$sc[] = ".asa,C:WINDOWSsystem32inetsrvasp. dll,5";
$sc[] = ".asp,C:WINDOWSsystem32inetsrvasp.dll,5";
break;
Case "php";
$sc[] = ".php ,E:softphp-5.2.3-Win32(1)php5isapi.dll,5";
$sc[] = ".php3,E:softphp-5.2.3-Win32(1)php5isapi.dll,5" ;
$sc[] = ".php4,E:softphp-5.2.3-Win32(1)php5isapi.dll,5";
$sc[] = ".php5,E:softphp-5.2. 3-Win32(1)php5isapi.dll,5";
$sc[] = ".php6,E:softphp-5.2.3-Win32(1)php5isapi.dll,5";
break;
Case "cgi";
echo "cgi
";
break;
Case "aspnet";
echo "asp.net
";
break;
Case “html”;
echo “html”;
break;

}

}
$iissite->ScriptMaps = $sc; $iissite->SetInfo();

  //再设定站点目录
  $iisdir = $iissite->Create("IIsWebVirtualDir","ROOT");
  $ServerDir1 = stripslashes($ServerDir);
  $iisdir->Path = $ServerDir1;
  $iisdir->AppCreate(True) ;
  $iisdir->AccessRead = True;
  $iisdir->EnableDirBrowsing = False;

  //允许父路径,也就是允许.
  $iisdir->AspEnableParentPaths = True;
  $iisdir->AccessScript = True;
  $iisdir->AppFriendlyName = "默认应用程序";
  $iisdir->SetInfo();
 
  //启动站点
  $Site1->Start;

  echo "<script>window.location='3.php';</script>";

 }

 //列出所有网站
 ForEach($LocalHostObject as $WebSiteName){
  iF($WebSiteName->Class == "IIsWebServer"){
   $Site = New Com ("IIS://localhost/w3svc/".$WebSiteName->Name) ;
   //站点状态
   $SiteStatus1 = $Site->Status ;
   Switch($SiteStatus1){
    Case "2" ;
     $SiteStatus = "Name>正常" ;
     break;
    Case "6" ;
     $SiteStatus = "Name>暂停" ;
     break;
    Case "4" ;
     $SiteStatus = "Name>停止" ;
     break;
   }


?>
 


   
   
   
   
   
   
   
 
  }
 }
 unset($LocalHostObject);
 unset($Site);
 unset($Site1);
 unset($Site2);
?>
站点名称绑定域名网站目录标识符站点状态
管理
ServerComment ; ?>
//得出绑定的域名
$BinDings = $Site->ServerBinDings;
   ForEach($BinDings as $BinDing){
    List($ip, $Port, $Domain) = Explode(":",$BinDing);
    Echo $Domain ."
";
   }

?> 


//网站目录

$getRootDir = $Site->GetObject("IIsWebVirtualDir","ROOT");
 echo $getRootDir->Path;
?>

Name ; ?>

 

  
    
      
      
    
    
      
      
    
    
      
      
    
    
      
      
    
    
      
      
    
    
      
      
    
  
站点名称
站点目录
站点ID号
Serverbin
脚本映射
ASP
 
PHP

CGI

ASP.NET

HTML
 


 


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445061.htmlTechArticle我们用php来控制iis并且,在WEB上创建网站,管理删除等功能哦。 ? 我们用php来控制iis并且,在WEB上创建网站,管理删除等功能哦。 #PHP控制站...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template