Skip to content

Commit c3f375b

Browse files
committed
Copy from private repository
1 parent db2795d commit c3f375b

File tree

5 files changed

+197
-0
lines changed

5 files changed

+197
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
bin
2+
obj
3+
*.exe
4+
*.suo
5+
*.user
6+
*.dll
7+
*.pdb
8+
.git
9+
.vs
10+
*.log
11+
*.log.doc

AssemblyInfo.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("Starts instance(s) of php in background")]
5+
[assembly: AssemblyDescription("Starts instance(s) of php in background")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("JGhost")]
8+
[assembly: AssemblyProduct("HiddenPHP")]
9+
[assembly: AssemblyCopyright("© 2019-2022 JGhost")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: AssemblyCulture("")]
12+
[assembly: ComVisible(false)]
13+
14+
[assembly: AssemblyVersion("1.0.0.0")]
15+
[assembly: AssemblyFileVersion("1.0.0.0")]

HiddenPHP.csproj

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{CD2A07B0-4C21-457C-8DC5-F82D89141DCD}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>HiddenPHP</RootNamespace>
10+
<AssemblyName>HiddenPHP</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>.</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>.</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="Program.cs" />
46+
<Compile Include="AssemblyInfo.cs" />
47+
</ItemGroup>
48+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49+
</Project>

HiddenPHP.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31702.278
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HiddenPHP", "HiddenPHP.csproj", "{CD2A07B0-4C21-457C-8DC5-F82D89141DCD}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{CD2A07B0-4C21-457C-8DC5-F82D89141DCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{CD2A07B0-4C21-457C-8DC5-F82D89141DCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{CD2A07B0-4C21-457C-8DC5-F82D89141DCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{CD2A07B0-4C21-457C-8DC5-F82D89141DCD}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {8C4D0B96-ECA9-49F0-A08D-92CC4CCF3C64}
24+
EndGlobalSection
25+
EndGlobal

Program.cs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Reflection;
5+
6+
static class App {
7+
8+
private static bool StartPHP(string phpPath, UInt16 port) {
9+
try {
10+
ProcessStartInfo psi = new ProcessStartInfo();
11+
psi.FileName = phpPath;
12+
psi.Arguments = " -b 127.0.0.1:" + port;
13+
psi.CreateNoWindow = true;
14+
psi.LoadUserProfile = false;
15+
psi.RedirectStandardError = false;
16+
psi.RedirectStandardOutput = false;
17+
psi.UseShellExecute = false;
18+
psi.WindowStyle = ProcessWindowStyle.Hidden;
19+
//psi.WorkingDirectory = ".";
20+
Process process = new Process();
21+
process.StartInfo = psi;
22+
process.Start();
23+
return true;
24+
} catch (Exception ex) {
25+
Console.WriteLine(ex.Message);
26+
return false;
27+
}
28+
}
29+
30+
[STAThread]
31+
static int Main(string[] args) {
32+
if (args.Length < 1) {
33+
Console.WriteLine("Starts instance(s) of php in background.");
34+
Console.WriteLine("Usage:");
35+
Console.WriteLine(" HiddenPHP {Start Port[;End Port[;Increment]]");
36+
Console.WriteLine("Example:");
37+
Console.WriteLine(" HiddenPHP 9000 # starts one instance of php on port 9000");
38+
Console.WriteLine(" HiddenPHP 9000;9500;100 # starts 5 instances of php on ports 9000,9100,9200,9300,9400");
39+
return 0;
40+
}
41+
42+
UInt16 start_port = 0;
43+
UInt16 end_port = 0;
44+
UInt16 increment = 1;
45+
46+
string[] parts = args[0].Split(';');
47+
if (parts.Length < 1 || parts.Length > 3) {
48+
Console.WriteLine("Error: invalid usage");
49+
return -1;
50+
}
51+
52+
try {
53+
start_port = Convert.ToUInt16(parts[0]);
54+
} catch {
55+
Console.WriteLine(args[0] + " is not a valid port number");
56+
return -1;
57+
}
58+
59+
if (parts.Length > 1) {
60+
try {
61+
end_port = Convert.ToUInt16(parts[1]);
62+
} catch {
63+
Console.WriteLine(args[0] + " is not a valid port number");
64+
return -1;
65+
}
66+
} else {
67+
end_port = (ushort) (start_port + 1);
68+
}
69+
if (parts.Length > 2) {
70+
try {
71+
increment = Convert.ToUInt16(parts[2]);
72+
if (increment < 1)
73+
throw new Exception();
74+
} catch {
75+
Console.WriteLine("is not a valid increment number");
76+
return -1;
77+
}
78+
}
79+
if ((end_port - start_port) / increment > 32) {
80+
Console.WriteLine("This utility can spawn maximum 32");
81+
return -1;
82+
83+
}
84+
string phpPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\php-cgi.exe";
85+
if (!File.Exists(phpPath)) {
86+
Console.WriteLine("php-cgi not found at '" + phpPath + "', this executable should be in same php folder that you want to run");
87+
return 1;
88+
}
89+
Console.WriteLine("Executing PHP at " + phpPath);
90+
91+
for (UInt16 port = start_port;port < end_port;port += increment) {
92+
Console.WriteLine("starting php on port " + port);
93+
StartPHP(phpPath, port);
94+
}
95+
return 0;
96+
}
97+
}

0 commit comments

Comments
 (0)