>17 17
   <!-- <img src="{{placelist?.better_featured_image.source_url}}"> -->
18 18
   <ion-grid>
19
-    <ion-row>
19
+    <ion-row color="light">
20 20
       <ion-col size="12">
21 21
         <div class="txt-place-title">{{placelist?.title.rendered}}</div>
22 22
       </ion-col>
@@ -25,16 +25,22 @@
25 25
         <div>{{ placelist?.acf.openclose }}</div>
26 26
       </ion-col>
27 27
       <ion-col size="12">
28
-        {{ placelist?.acf.gmap.address }}
29
-        {{ placelist?.acf.gmap.lat }}
30
-        {{ placelist?.acf.gmap.lng }}
31
-        <img src="/assets/images/map-temp.jpg" alt="">
28
+        <!-- {{ placelist?.acf.gmap.address }} -->
29
+        <!-- {{ placelist?.acf.gmap.lat }}
30
+        {{ placelist?.acf.gmap.lng }} -->
31
+        <div class="map-wrapper">
32
+          <div id="map_center">
33
+            <img src="/assets/icon/location-marker.png" />
34
+          </div>
35
+          <div #map id="map"></div>
36
+        </div>
32 37
       </ion-col>
33 38
       <ion-col size="12">
34 39
         <ion-row>
35 40
           <ion-col size="4" class="ion-text-center">
36
-            <!-- <div [innerHTML]="placelist?.acf.phone"></div>                         -->
37
-            <fa-icon [icon]="['fas', 'phone-square-alt']" size="2x"></fa-icon>
41
+            <div (click)="callNow('{{placelist?.acf.phone}}')">
42
+              <fa-icon [icon]="['fas', 'phone-square-alt']" size="2x"></fa-icon>
43
+            </div>
38 44
           </ion-col>
39 45
           <ion-col size="4" class="ion-text-center">
40 46
             <!-- <div [innerHTML]="placelist?.acf.phone"></div>                         -->
@@ -42,29 +48,40 @@
42 48
           </ion-col>
43 49
           <ion-col size="4" class="ion-text-center">
44 50
             <!-- <div [innerHTML]="placelist?.acf.email"></div>             -->
45
-            <fa-icon [icon]="['fas', 'envelope']" size="2x"></fa-icon>
51
+            <div (click)="email2Place('{{placelist?.acf.email}}')">
52
+              <fa-icon [icon]="['fas', 'envelope']" size="2x"></fa-icon>
53
+            </div>
46 54
           </ion-col>
47 55
         </ion-row>
48 56
       </ion-col>
57
+
49 58
       <ion-col size="12">
50
-        <div class="txt-lead">ที่อยู่</div>
51
-        <div [innerHTML]="placelist?.acf.address"></div>
52
-      </ion-col>
53
-      <ion-col size="12">
54
-        <!-- <div class="txt-lead">รายละเอียด</div>
55
-        <div [innerHTML]="placelist?.content.rendered"></div> -->
56
-        <!-- <div>{{placelist?.content.rendered}}</div> -->
57
-        <!-- <ion-button (click)="loadMap()" shape="round" color="dark">
58
-          <ion-icon slot="start" name="locate"></ion-icon>
59
-          Where I Am
60
-        </ion-button> -->
61
-        <div class="map-wrapper">
62
-          <div id="map_center">
63
-            <img src="assets/icon/location-marker.png" />
64
-          </div>
65
-          <div #map id="map"></div>
66
-        </div>
67
-        
59
+        <ion-segment (ionChange)="segmentChanged($event)" value="list1">
60
+          <ion-segment-button value="list1">
61
+            <ion-label>
62
+              ที่อยู่
63
+            </ion-label>
64
+          </ion-segment-button>
65
+          <ion-segment-button value="list2">
66
+            <ion-label>
67
+              รายละเอียด
68
+            </ion-label>
69
+          </ion-segment-button>
70
+        </ion-segment>
71
+
72
+        <ion-list *ngIf="segment === 'list1'">
73
+          <ion-col size="12">
74
+            <!-- <div class="txt-lead">ที่อยู่</div> -->
75
+            <div [innerHTML]="placelist?.acf.address"></div>
76
+          </ion-col>
77
+        </ion-list>
78
+
79
+        <ion-list *ngIf="segment === 'list2'">
80
+          <ion-col size="12">
81
+            <!-- <div class="txt-lead">ที่อยู่</div> -->
82
+            <div [innerHTML]="placelist?.content.rendered"></div>
83
+          </ion-col>
84
+        </ion-list>
68 85
       </ion-col>
69 86
     </ion-row>
70 87
 

+ 0 - 17
src/app/placedetail/placedetail.page.scss

@@ -1,16 +1,3 @@
1
-// ion-toolbar{
2
-//     --background: transparent;
3
-//     --border-color: transparent;
4
-// }
5
-// ion-toolbar{
6
-//     --background: transparent;
7
-//     --border-color: transparent;
8
-// }
9
-// ion-content{
10
-//     --offset-top:0px;
11
-//     position: absolute;
12
-// }
13
-
14 1
 .bg {
15 2
   position: absolute;
16 3
   left: 0px;
@@ -29,10 +16,6 @@
29 16
     --background: white;
30 17
   }
31 18
 }
32
-
33
-.asd {
34
-}
35
-
36 19
 .asd .country {
37 20
   position: absolute;
38 21
   top: 50px;

+ 19 - 19
src/app/placedetail/placedetail.page.ts

@@ -4,6 +4,8 @@ import { WpServiceService } from '../wp-service.service';
4 4
 
5 5
 import { Geolocation } from '@ionic-native/geolocation/ngx';
6 6
 import { NativeGeocoder, NativeGeocoderResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';
7
+import { CallNumber } from '@ionic-native/call-number/ngx';
8
+import { EmailComposer } from '@ionic-native/email-composer/ngx';
7 9
 
8 10
 declare var google;
9 11
 
@@ -17,6 +19,8 @@ export class PlacedetailPage implements OnInit {
17 19
   data: any;
18 20
   placelist: any;
19 21
 
22
+  public segment: string = "list1";
23
+
20 24
   @ViewChild('map', { static: false }) mapElement: ElementRef;
21 25
   map: any;
22 26
   address: string;
@@ -24,9 +28,9 @@ export class PlacedetailPage implements OnInit {
24 28
   longitude: number;
25 29
   latdynamic: any;
26 30
   londynamic: any;
27
-  
28 31
 
29
-  constructor(private wpservice: WpServiceService, private route: ActivatedRoute, private router: Router, private geolocation: Geolocation, private nativeGeocoder: NativeGeocoder) { }
32
+
33
+  constructor(private wpservice: WpServiceService, private route: ActivatedRoute, private router: Router, private geolocation: Geolocation, private nativeGeocoder: NativeGeocoder,private callNumber: CallNumber, private emailComposer: EmailComposer) { }
30 34
   @Input() id: string;
31 35
   showDiss = false;
32 36
 
@@ -121,21 +125,17 @@ export class PlacedetailPage implements OnInit {
121 125
 
122 126
   }
123 127
 
124
-  // getAddressFromCoords2(lattitude, longitude) {
125
-  //   console.log("getAddressFromCoords2 " + lattitude + " " + longitude);
126
-  //   let options: NativeGeocoderOptions = {
127
-  //     useLocale: true,
128
-  //     maxResults: 5
129
-  //   };
130
-  // }
131
-
132
-  // getGeoencoder(latitude, longitude) {
133
-  //   this.nativeGeocoder.reverseGeocode(latitude, longitude, this.geoencoderOptions)
134
-  //     .then((result: NativeGeocoderResult[]) => {
135
-  //       this.address = this.generateAddress(result[0]);
136
-  //     })
137
-  //     .catch((error: any) => {
138
-  //       alert('Error getting location' + JSON.stringify(error));
139
-  //     });
140
-  // }
128
+  segmentChanged(ev: any) {
129
+    this.segment = ev.detail.value;
130
+  }
131
+
132
+  callNow(number) {
133
+    this.callNumber.callNumber(number, true)
134
+      .then(res => console.log('Launched dialer!', res))
135
+      .catch(err => console.log('Error launching dialer', err));
136
+  }
137
+
138
+  email2Place(mail) {
139
+    this.emailComposer.open(mail)
140
+  }
141 141
 }

+ 18 - 11
src/app/profile/profile.page.html

@@ -1,10 +1,14 @@
1 1
 <ion-header>
2
-  <ion-toolbar>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="start" color="light">
4
+      <ion-back-button></ion-back-button>
5
+    </ion-buttons>
3 6
     <ion-title>Wellness Route</ion-title>
4 7
   </ion-toolbar>
5 8
 </ion-header>
6
-<ion-content fullscreen="true">
7
-  <!-- <div *ngIf="(user2 | async) as user; else loading"> -->
9
+<ion-content>
10
+  <ion-grid>
11
+    <!-- <div *ngIf="(user2 | async) as user; else loading"> -->
8 12
     <ion-row>
9 13
       <ion-col>
10 14
         <div class="ion-text-center">
@@ -17,32 +21,35 @@
17 21
         <div class="card">
18 22
           <div class="header">
19 23
             <div class="avatar">
20
-              <img [src]="$any(user).picture_large.data.url" *ngIf="user['picture_large'] != undefined" />
21
-              <img src="/assets/images/icon-user.png" *ngIf="user['picture_large'] == undefined" />
24
+              <!-- <img [src]="$any(user).picture_large.data.url" *ngIf="user['picture_large'] != undefined" /> -->
25
+              <!-- <img src="/assets/images/icon-user.png" *ngIf="user['picture_large'] == undefined" /> -->
26
+              <img src="/assets/images/icon-user.png">
22 27
             </div>
23 28
           </div>
24 29
         </div>
25 30
         <div class="card-body">
26 31
           <div class="user-meta ion-text-center">
27
-            <h3 class="playername">{{ $any(user).name }}</h3>
32
+            <!-- <h3 class="playername">{{ $any(user).name }}</h3> -->
28 33
           </div>
29 34
           <form>
30 35
             <ion-item lines="full">
31 36
               <ion-label>ชื่อ</ion-label>
32
-              {{ $any(user).name }}
37
+              <!-- {{ $any(user).name }} -->
33 38
             </ion-item>
34 39
             <ion-item lines="full">
35
-              <ion-label>Email</ion-label>{{ $any(user).email }}
40
+              <ion-label>อีเมล์</ion-label>
41
+              <!-- {{ $any(user).email }} -->
36 42
             </ion-item>
37 43
             <div class="ion-padding-vertical">
38
-              <ion-button type="submit" color="danger" expand="block" (click)="logout()">Log Out</ion-button>
44
+              <!-- <ion-button type="submit" color="danger" expand="block" (click)="logout()">Log Out</ion-button> -->
39 45
             </div>
40 46
           </form>
41 47
         </div>
42 48
       </ion-col>
43 49
     </ion-row>
44
-  <!-- </div> -->
45
-  <!-- <ng-template #loading>
50
+    <!-- </div> -->
51
+    <!-- <ng-template #loading>
46 52
     Loading stuff...
47 53
   </ng-template> -->
54
+  </ion-grid>
48 55
 </ion-content>

+ 1 - 0
src/app/profile/profile.page.ts

@@ -8,6 +8,7 @@ import { Component, OnInit } from '@angular/core';
8 8
 export class ProfilePage implements OnInit {
9 9
 
10 10
   user2: any;
11
+  user: any;
11 12
   
12 13
   constructor() { }
13 14
 

+ 28 - 29
src/app/province/province.page.html

@@ -6,34 +6,33 @@
6 6
     <ion-title>Wellnewss Route</ion-title>
7 7
   </ion-toolbar>
8 8
 </ion-header>
9
-
10 9
 <ion-content>
11
-  <img src="/assets/images/welcome_drone.jpeg" alt="">
12
-  <div class="holidaycard">
13
-    <ion-grid>
14
-      <ion-row>
15
-        <ion-col size="12">
16
-          <div class="txt-place-title">Province Name</div>
17
-        </ion-col>
18
-      </ion-row>
19
-      <ion-row>
20
-        <ion-col>
21
-          <ion-toolbar class="search">
22
-            <ion-searchbar placeholder="ค้นหา"></ion-searchbar>
23
-          </ion-toolbar>
24
-        </ion-col>
25
-      </ion-row>
26
-      <ion-card *ngFor="let provlist of provicelist">
27
-        <div *ngIf="$any(provlist).better_featured_image != null">
28
-          <img src="{{$any(provlist).better_featured_image.source_url}}" alt="">
29
-        </div>
30
-        <div *ngIf="$any(provlist).better_featured_image == null">
31
-          <img src="/assets/images/temp.png" />
32
-        </div>
33
-        <ion-card-header>
34
-          <a [routerLink]="['/tabs/place/', provlist.id]"><ion-card-title [innerHTML]="provlist.title.rendered"></ion-card-title></a>
35
-        </ion-card-header>
36
-      </ion-card>
37
-    </ion-grid>
38
-  </div>
10
+  <img src="/assets/images/image-004.jpg" alt="">
11
+  <ion-grid>
12
+    <ion-row>
13
+      <ion-col size="12">
14
+        <div class="txt-place-title">Province Name</div>
15
+      </ion-col>
16
+    </ion-row>
17
+    <ion-row>
18
+      <ion-col>
19
+        <ion-toolbar class="search">
20
+          <ion-searchbar placeholder="ค้นหา"></ion-searchbar>
21
+        </ion-toolbar>
22
+      </ion-col>
23
+    </ion-row>
24
+    <ion-card *ngFor="let provlist of provicelist">
25
+      <div *ngIf="$any(provlist).better_featured_image != null">
26
+        <img src="{{$any(provlist).better_featured_image.source_url}}" alt="">
27
+      </div>
28
+      <div *ngIf="$any(provlist).better_featured_image == null">
29
+        <img src="/assets/images/temp.png" />
30
+      </div>
31
+      <ion-card-header>
32
+        <a [routerLink]="['/tabs/place/', provlist.id]">
33
+          <ion-card-title [innerHTML]="provlist.title.rendered"></ion-card-title>
34
+        </a>
35
+      </ion-card-header>
36
+    </ion-card>
37
+  </ion-grid>
39 38
 </ion-content>

+ 12 - 12
src/app/province/province.page.scss

@@ -1,16 +1,16 @@
1 1
 
2
-.holidaycard {
3
-  position: absolute;
4
-  left: 0px;
5
-  // bottom: 0px;
6
-  top:200px;
7
-  min-height: 48%;
8
-  width: 100%;
9
-  padding: 5px;
10
-  border-radius: 15px ;
11
-  background: white;
12
-  --background: white;
13
-}
2
+// .holidaycard {
3
+//   position: absolute;
4
+//   left: 0px;
5
+//   // bottom: 0px;
6
+//   top:200px;
7
+//   min-height: 48%;
8
+//   width: 100%;
9
+//   padding: 5px;
10
+//   border-radius: 15px ;
11
+//   background: white;
12
+//   --background: white;
13
+// }
14 14
 
15 15
 ion-card-title {
16 16
   font-family: "IBM Plex Sans Thai", sans-serif !important;

+ 10 - 7
src/app/register-form/register-form.page.html

@@ -1,10 +1,13 @@
1 1
 <ion-header>
2
-  <ion-toolbar>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="start" color="light">
4
+      <ion-back-button></ion-back-button>
5
+    </ion-buttons>
3 6
     <ion-title>Wellness Route</ion-title>
4 7
   </ion-toolbar>
5 8
 </ion-header>
6
-
7 9
 <ion-content>
10
+  <div><img src="/assets/images/image-001.jpg"></div>
8 11
   <ion-row>
9 12
     <ion-col>
10 13
       <div class="ion-text-center">
@@ -13,9 +16,9 @@
13 16
     </ion-col>
14 17
   </ion-row>
15 18
   <ion-row>
16
-    <ion-col>      
19
+    <ion-col>
17 20
       <form>
18
-        <ion-text *ngIf="errorText" color="primary" style='background-color:#fff'>
21
+        <ion-text *ngIf="errorText" color="primary">
19 22
           {{ errorText }}
20 23
         </ion-text>
21 24
         <ion-item lines="full">
@@ -45,9 +48,9 @@
45 48
         </ion-item>
46 49
 
47 50
         <div class="ion-padding-vertical">
48
-          <ion-button type="submit" color="success" expand="block" (click)="register()">ลงทะเบียน</ion-button>
51
+          <ion-button type="submit" color="success" expand="block">ลงทะเบียน</ion-button>
49 52
         </div>
50 53
       </form>
51 54
     </ion-col>
52
-  </ion-row>  
53
-</ion-content>
55
+  </ion-row>
56
+</ion-content>

+ 10 - 7
src/app/register/register.page.html

@@ -1,20 +1,23 @@
1 1
 <ion-header>
2
-  <ion-toolbar>
3
-    <ion-title>ลงทะเบียน</ion-title>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="start" color="light">
4
+      <ion-back-button></ion-back-button>
5
+    </ion-buttons>
6
+    <ion-title>Wellness Route</ion-title>
4 7
   </ion-toolbar>
5 8
 </ion-header>
6
-
7 9
 <ion-content class="auth-form">
10
+  <div><img src="/assets/images/image-001.jpg"></div>
8 11
   <ion-grid>
9 12
     <ion-row>
10 13
       <ion-col align-self-center>
11
-        <ion-button [routerLink]="['/registration']" expand="block" color="primary">Register</ion-button>
14
+        <ion-button [routerLink]="['/register-form']" expand="block" color="primary">ลงทะเบียนผู้ใช้งาน</ion-button>
12 15
 
13
-        <span class="divider line one-line">or</span>
16
+        <span class="divider line one-line">หรือ</span>
14 17
 
15
-        <span class="already">Already a user?</span>
18
+        <span class="already">มีชื่อผู้ใช้งานแล้ว</span>
16 19
 
17
-        <ion-button [routerLink]="['/login']" expand="block" color="danger">Sign In</ion-button>
20
+        <ion-button [routerLink]="['/login']" expand="block" color="danger">เข้าสู่ระบบ</ion-button>
18 21
       </ion-col>
19 22
     </ion-row>
20 23
   </ion-grid>

+ 2 - 2
src/app/register/register.page.scss

@@ -12,7 +12,7 @@
12 12
   .line {
13 13
     align-items: center;
14 14
     margin: 1em -1em;
15
-    color: #cccccc;
15
+    color: #5f5e5e;
16 16
     
17 17
     &:before,
18 18
     &:after {
@@ -24,7 +24,7 @@
24 24
   .one-line {
25 25
     &:before,
26 26
     &:after {
27
-       background: #cccccc;
27
+       background: #5f5e5e;
28 28
     }
29 29
   }
30 30
   

+ 29 - 24
src/app/reset-password/reset-password.page.html

@@ -1,33 +1,38 @@
1 1
 <ion-header>
2
-  <ion-toolbar>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="start" color="light">
4
+      <ion-back-button></ion-back-button>
5
+    </ion-buttons>
3 6
     <ion-title>Wellness Route</ion-title>
4 7
   </ion-toolbar>
5 8
 </ion-header>
6
-
7 9
 <ion-content>
8
-  <ion-row>
9
-    <ion-col class="ion-text-center">
10
-      <h1>กรุณาใส่รหัสผ่านใหม่</h1>
11
-    </ion-col>
12
-  </ion-row>
13
-  <form>
14
-    <ion-row>
15
-      <ion-col>
16
-        <ion-item lines="full">
17
-          <ion-label position="floating">รหัสผ่าน</ion-label>
18
-          <ion-input type="password" required></ion-input>
19
-        </ion-item>
20
-
21
-        <ion-item lines="full">
22
-          <ion-label position="floating">ยืนยัน รหัสผ่าน</ion-label>
23
-          <ion-input type="password" required></ion-input>
24
-        </ion-item>
25
-      </ion-col>
26
-    </ion-row>
10
+  <div><img src="/assets/images/image-007.jpg"></div>
11
+  <ion-grid>
27 12
     <ion-row>
28
-      <ion-col>
29
-        <ion-button type="submit" color="success" expand="block">ส่ง</ion-button>
13
+      <ion-col class="ion-text-center">
14
+        <h1>กรุณาใส่รหัสผ่านใหม่</h1>
30 15
       </ion-col>
31 16
     </ion-row>
32
-  </form>
17
+    <form>
18
+      <ion-row>
19
+        <ion-col>
20
+          <ion-item lines="full">
21
+            <ion-label position="floating">รหัสผ่าน</ion-label>
22
+            <ion-input type="password" required></ion-input>
23
+          </ion-item>
24
+
25
+          <ion-item lines="full">
26
+            <ion-label position="floating">ยืนยัน รหัสผ่าน</ion-label>
27
+            <ion-input type="password" required></ion-input>
28
+          </ion-item>
29
+        </ion-col>
30
+      </ion-row>
31
+      <ion-row>
32
+        <ion-col>
33
+          <ion-button type="submit" color="success" expand="block">ส่ง</ion-button>
34
+        </ion-col>
35
+      </ion-row>
36
+    </form>
37
+  </ion-grid>
33 38
 </ion-content>

+ 2 - 2
src/app/tabs/tabs.page.html

@@ -1,9 +1,9 @@
1 1
 <ion-tabs>
2
-  <ion-fab vertical="bottom" horizontal="center" translucent="true">
2
+  <!-- <ion-fab vertical="bottom" horizontal="center" translucent="true">
3 3
     <ion-fab-button routerLink="nearme" routerDirection="forward">
4 4
     <ion-icon name="navigate"></ion-icon>
5 5
     </ion-fab-button>
6
-  </ion-fab>
6
+  </ion-fab> -->
7 7
   <ion-tab-bar slot="bottom">
8 8
     <ion-tab-button tab="home">
9 9
       <ion-icon name="home"></ion-icon>

+ 2 - 1
src/app/wp-service.service.ts

@@ -31,7 +31,8 @@ export class WpServiceService {
31 31
 
32 32
   getPlaceDetail(id) {
33 33
     return this.http.get(
34
-      "http://tamtime.iamarray.xyz/wp-json/wp/v2/place/"+id+"/?_embed"
34
+      // "http://tamtime.iamarray.xyz/wp-json/wp/v2/place/"+id+"/?_embed"
35
+      "/assets/json/place173.json"
35 36
     );
36 37
   }
37 38
 

BIN
src/assets/images/image-001.jpg


BIN
src/assets/images/image-002.jpg


BIN
src/assets/images/image-003.jpg


BIN
src/assets/images/image-004.jpg


BIN
src/assets/images/image-005.jpg


BIN
src/assets/images/image-006.jpg


BIN
src/assets/images/image-007.jpg


BIN
src/assets/images/image-008.jpg


BIN
src/assets/images/image-009.jpg


BIN
src/assets/images/image-010.jpg


BIN
src/assets/images/image-011.jpg


BIN
src/assets/images/image-012.jpg


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
src/assets/json/place173.json


+ 18 - 7
src/global.scss

@@ -116,6 +116,17 @@
116 116
   --color: #ffffff;
117 117
 }
118 118
 
119
+// ion-content {
120
+//   --background: linear-gradient(
121
+//     to bottom,
122
+//     #a7e9ff,
123
+//     #8fd8fd,
124
+//     #7ec7fb,
125
+//     #78b4f6,
126
+//     #7c9fee
127
+//   );
128
+// }
129
+
119 130
 ion-title {
120 131
   font-family: "Kanit", sans-serif !important;
121 132
   font-weight: 500;
@@ -160,12 +171,12 @@ ion-button {
160 171
 
161 172
 a {
162 173
   text-decoration: none;
163
- }
164
- 
165
-// ion-content {
166
-//   --background: url(/assets/images/wnr-bg.jpg) no-repeat center/cover fixed;
167
-// }
174
+}
175
+
176
+.image-page-cover {
177
+  height: 200px;
178
+}
168 179
 .ios ion-fab-button {
169
-  position:absolute;
180
+  position: absolute;
170 181
   bottom: 25px;
171
-}
182
+}

tum/whitesports - Gogs: Simplico Git Service

Нет описания

network.php 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php
  2. /**
  3. * WordPress Network Administration API.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. * @since 4.4.0
  8. */
  9. /**
  10. * Check for an existing network.
  11. *
  12. * @since 3.0.0
  13. *
  14. * @global wpdb $wpdb WordPress database abstraction object.
  15. *
  16. * @return string|false Base domain if network exists, otherwise false.
  17. */
  18. function network_domain_check() {
  19. global $wpdb;
  20. $sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
  21. if ( $wpdb->get_var( $sql ) ) {
  22. return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
  23. }
  24. return false;
  25. }
  26. /**
  27. * Allow subdomain installation
  28. *
  29. * @since 3.0.0
  30. * @return bool Whether subdomain installation is allowed
  31. */
  32. function allow_subdomain_install() {
  33. $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
  34. if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
  35. return false;
  36. }
  37. return true;
  38. }
  39. /**
  40. * Allow subdirectory installation.
  41. *
  42. * @since 3.0.0
  43. *
  44. * @global wpdb $wpdb WordPress database abstraction object.
  45. *
  46. * @return bool Whether subdirectory installation is allowed
  47. */
  48. function allow_subdirectory_install() {
  49. global $wpdb;
  50. /**
  51. * Filters whether to enable the subdirectory installation feature in Multisite.
  52. *
  53. * @since 3.0.0
  54. *
  55. * @param bool $allow Whether to enable the subdirectory installation feature in Multisite.
  56. * Default false.
  57. */
  58. if ( apply_filters( 'allow_subdirectory_install', false ) ) {
  59. return true;
  60. }
  61. if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
  62. return true;
  63. }
  64. $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
  65. if ( empty( $post ) ) {
  66. return true;
  67. }
  68. return false;
  69. }
  70. /**
  71. * Get base domain of network.
  72. *
  73. * @since 3.0.0
  74. * @return string Base domain.
  75. */
  76. function get_clean_basedomain() {
  77. $existing_domain = network_domain_check();
  78. if ( $existing_domain ) {
  79. return $existing_domain;
  80. }
  81. $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
  82. $slash = strpos( $domain, '/' );
  83. if ( $slash ) {
  84. $domain = substr( $domain, 0, $slash );
  85. }
  86. return $domain;
  87. }
  88. /**
  89. * Prints step 1 for Network installation process.
  90. *
  91. * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such.
  92. * Navigating to Tools > Network should not be a sudden "Welcome to a new install process!
  93. * Fill this out and click here." See also contextual help todo.
  94. *
  95. * @since 3.0.0
  96. *
  97. * @global bool $is_apache
  98. *
  99. * @param false|WP_Error $errors Optional. Error object. Default false.
  100. */
  101. function network_step1( $errors = false ) {
  102. global $is_apache;
  103. if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
  104. echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . sprintf(
  105. /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
  106. __( 'The constant %s cannot be defined when creating a network.' ),
  107. '<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
  108. ) . '</p></div>';
  109. echo '</div>';
  110. require_once ABSPATH . 'wp-admin/admin-footer.php';
  111. die();
  112. }
  113. $active_plugins = get_option( 'active_plugins' );
  114. if ( ! empty( $active_plugins ) ) {
  115. echo '<div class="notice notice-warning"><p><strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
  116. /* translators: %s: URL to Plugins screen. */
  117. __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
  118. admin_url( 'plugins.php?plugin_status=active' )
  119. ) . '</p></div>';
  120. echo '<p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
  121. echo '</div>';
  122. require_once ABSPATH . 'wp-admin/admin-footer.php';
  123. die();
  124. }
  125. $hostname = get_clean_basedomain();
  126. $has_ports = strstr( $hostname, ':' );
  127. if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
  128. echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
  129. echo '<p>' . sprintf(
  130. /* translators: %s: Port number. */
  131. __( 'You cannot use port numbers such as %s.' ),
  132. '<code>' . $has_ports . '</code>'
  133. ) . '</p>';
  134. echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Go to Dashboard' ) . '</a>';
  135. echo '</div>';
  136. require_once ABSPATH . 'wp-admin/admin-footer.php';
  137. die();
  138. }
  139. echo '<form method="post">';
  140. wp_nonce_field( 'install-network-1' );
  141. $error_codes = array();
  142. if ( is_wp_error( $errors ) ) {
  143. echo '<div class="error"><p><strong>' . __( 'Error: The network could not be created.' ) . '</strong></p>';
  144. foreach ( $errors->get_error_messages() as $error ) {
  145. echo "<p>$error</p>";
  146. }
  147. echo '</div>';
  148. $error_codes = $errors->get_error_codes();
  149. }
  150. if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes, true ) ) {
  151. $site_name = $_POST['sitename'];
  152. } else {
  153. /* translators: %s: Default network title. */
  154. $site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) );
  155. }
  156. if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes, true ) ) {
  157. $admin_email = $_POST['email'];
  158. } else {
  159. $admin_email = get_option( 'admin_email' );
  160. }
  161. ?>
  162. <p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
  163. <p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
  164. <?php
  165. if ( isset( $_POST['subdomain_install'] ) ) {
  166. $subdomain_install = (bool) $_POST['subdomain_install'];
  167. } elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // Assume nothing.
  168. $subdomain_install = true;
  169. } elseif ( ! allow_subdirectory_install() ) {
  170. $subdomain_install = true;
  171. } else {
  172. $subdomain_install = false;
  173. $got_mod_rewrite = got_mod_rewrite();
  174. if ( $got_mod_rewrite ) { // Dangerous assumptions.
  175. echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
  176. printf(
  177. /* translators: %s: mod_rewrite */
  178. __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
  179. '<code>mod_rewrite</code>'
  180. );
  181. echo '</p>';
  182. } elseif ( $is_apache ) {
  183. echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
  184. printf(
  185. /* translators: %s: mod_rewrite */
  186. __( 'It looks like the Apache %s module is not installed.' ),
  187. '<code>mod_rewrite</code>'
  188. );
  189. echo '</p>';
  190. }
  191. if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
  192. echo '<p>';
  193. printf(
  194. /* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
  195. __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
  196. '<code>mod_rewrite</code>',
  197. 'https://httpd.apache.org/docs/mod/mod_rewrite.html',
  198. 'https://www.google.com/search?q=apache+mod_rewrite'
  199. );
  200. echo '</p></div>';
  201. }
  202. }
  203. if ( allow_subdomain_install() && allow_subdirectory_install() ) :
  204. ?>
  205. <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
  206. <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
  207. <strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
  208. <p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
  209. <?php // @todo Link to an MS readme? ?>
  210. <table class="form-table" role="presentation">
  211. <tr>
  212. <th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
  213. <td>
  214. <?php
  215. printf(
  216. /* translators: 1: Host name. */
  217. _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
  218. $hostname
  219. );
  220. ?>
  221. </td>
  222. </tr>
  223. <tr>
  224. <th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
  225. <td>
  226. <?php
  227. printf(
  228. /* translators: 1: Host name. */
  229. _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
  230. $hostname
  231. );
  232. ?>
  233. </td>
  234. </tr>
  235. </table>
  236. <?php
  237. endif;
  238. if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
  239. echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
  240. }
  241. $is_www = ( 0 === strpos( $hostname, 'www.' ) );
  242. if ( $is_www ) :
  243. ?>
  244. <h3><?php esc_html_e( 'Server Address' ); ?></h3>
  245. <p>
  246. <?php
  247. printf(
  248. /* translators: 1: Site URL, 2: Host name, 3: www. */
  249. __( 'We recommend you change your site domain to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
  250. '<code>' . substr( $hostname, 4 ) . '</code>',
  251. '<code>' . $hostname . '</code>',
  252. '<code>www</code>'
  253. );
  254. ?>
  255. </p>
  256. <table class="form-table" role="presentation">
  257. <tr>
  258. <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
  259. <td>
  260. <?php
  261. printf(
  262. /* translators: %s: Host name. */
  263. __( 'The internet address of your network will be %s.' ),
  264. '<code>' . $hostname . '</code>'
  265. );
  266. ?>
  267. </td>
  268. </tr>
  269. </table>
  270. <?php endif; ?>
  271. <h3><?php esc_html_e( 'Network Details' ); ?></h3>
  272. <table class="form-table" role="presentation">
  273. <?php if ( 'localhost' === $hostname ) : ?>
  274. <tr>
  275. <th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
  276. <td>
  277. <?php
  278. printf(
  279. /* translators: 1: localhost, 2: localhost.localdomain */
  280. __( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
  281. '<code>localhost</code>',
  282. '<code>localhost.localdomain</code>'
  283. );
  284. // Uh oh:
  285. if ( ! allow_subdirectory_install() ) {
  286. echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
  287. }
  288. ?>
  289. </td>
  290. </tr>
  291. <?php elseif ( ! allow_subdomain_install() ) : ?>
  292. <tr>
  293. <th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
  294. <td>
  295. <?php
  296. _e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
  297. // Uh oh:
  298. if ( ! allow_subdirectory_install() ) {
  299. echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
  300. }
  301. ?>
  302. </td>
  303. </tr>
  304. <?php elseif ( ! allow_subdirectory_install() ) : ?>
  305. <tr>
  306. <th scope="row"><?php esc_html_e( 'Sub-domain Installation' ); ?></th>
  307. <td>
  308. <?php
  309. _e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
  310. echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
  311. ?>
  312. </td>
  313. </tr>
  314. <?php endif; ?>
  315. <?php if ( ! $is_www ) : ?>
  316. <tr>
  317. <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
  318. <td>
  319. <?php
  320. printf(
  321. /* translators: %s: Host name. */
  322. __( 'The internet address of your network will be %s.' ),
  323. '<code>' . $hostname . '</code>'
  324. );
  325. ?>
  326. </td>
  327. </tr>
  328. <?php endif; ?>
  329. <tr>
  330. <th scope='row'><label for="sitename"><?php esc_html_e( 'Network Title' ); ?></label></th>
  331. <td>
  332. <input name='sitename' id='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
  333. <p class="description">
  334. <?php _e( 'What would you like to call your network?' ); ?>
  335. </p>
  336. </td>
  337. </tr>
  338. <tr>
  339. <th scope='row'><label for="email"><?php esc_html_e( 'Network Admin Email' ); ?></label></th>
  340. <td>
  341. <input name='email' id='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
  342. <p class="description">
  343. <?php _e( 'Your email address.' ); ?>
  344. </p>
  345. </td>
  346. </tr>
  347. </table>
  348. <?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
  349. </form>
  350. <?php
  351. }
  352. /**
  353. * Prints step 2 for Network installation process.
  354. *
  355. * @since 3.0.0
  356. *
  357. * @global wpdb $wpdb WordPress database abstraction object.
  358. * @global bool $is_nginx Whether the server software is Nginx or something else.
  359. *
  360. * @param false|WP_Error $errors Optional. Error object. Default false.
  361. */
  362. function network_step2( $errors = false ) {
  363. global $wpdb, $is_nginx;
  364. $hostname = get_clean_basedomain();
  365. $slashed_home = trailingslashit( get_option( 'home' ) );
  366. $base = parse_url( $slashed_home, PHP_URL_PATH );
  367. $document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
  368. $abspath_fix = str_replace( '\\', '/', ABSPATH );
  369. $home_path = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
  370. $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
  371. $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
  372. $location_of_wp_config = $abspath_fix;
  373. if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
  374. $location_of_wp_config = dirname( $abspath_fix );
  375. }
  376. $location_of_wp_config = trailingslashit( $location_of_wp_config );
  377. // Wildcard DNS message.
  378. if ( is_wp_error( $errors ) ) {
  379. echo '<div class="error">' . $errors->get_error_message() . '</div>';
  380. }
  381. if ( $_POST ) {
  382. if ( allow_subdomain_install() ) {
  383. $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
  384. } else {
  385. $subdomain_install = false;
  386. }
  387. } else {
  388. if ( is_multisite() ) {
  389. $subdomain_install = is_subdomain_install();
  390. ?>
  391. <p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
  392. <?php
  393. } else {
  394. $subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
  395. ?>
  396. <div class="error"><p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
  397. <p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
  398. <?php
  399. }
  400. }
  401. $subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
  402. $subdir_replacement_01 = $subdomain_install ? '' : '$1';
  403. $subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
  404. if ( $_POST || ! is_multisite() ) {
  405. ?>
  406. <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
  407. <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
  408. <div class="notice notice-warning inline"><p>
  409. <?php
  410. if ( file_exists( $home_path . '.htaccess' ) ) {
  411. echo '<strong>' . __( 'Caution:' ) . '</strong> ';
  412. printf(
  413. /* translators: 1: wp-config.php, 2: .htaccess */
  414. __( 'We recommend you back up your existing %1$s and %2$s files.' ),
  415. '<code>wp-config.php</code>',
  416. '<code>.htaccess</code>'
  417. );
  418. } elseif ( file_exists( $home_path . 'web.config' ) ) {
  419. echo '<strong>' . __( 'Caution:' ) . '</strong> ';
  420. printf(
  421. /* translators: 1: wp-config.php, 2: web.config */
  422. __( 'We recommend you back up your existing %1$s and %2$s files.' ),
  423. '<code>wp-config.php</code>',
  424. '<code>web.config</code>'
  425. );
  426. } else {
  427. echo '<strong>' . __( 'Caution:' ) . '</strong> ';
  428. printf(
  429. /* translators: %s: wp-config.php */
  430. __( 'We recommend you back up your existing %s file.' ),
  431. '<code>wp-config.php</code>'
  432. );
  433. }
  434. ?>
  435. </p></div>
  436. <?php
  437. }
  438. ?>
  439. <ol>
  440. <li><p>
  441. <?php
  442. printf(
  443. /* translators: 1: wp-config.php, 2: Location of wp-config file, 3: Translated version of "That's all, stop editing! Happy publishing." */
  444. __( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
  445. '<code>wp-config.php</code>',
  446. '<code>' . $location_of_wp_config . '</code>',
  447. /*
  448. * translators: This string should only be translated if wp-config-sample.php is localized.
  449. * You can check the localized release package or
  450. * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
  451. */
  452. '<code>/* ' . __( 'That&#8217;s all, stop editing! Happy publishing.' ) . ' */</code>'
  453. );
  454. ?>
  455. </p>
  456. <textarea class="code" readonly="readonly" cols="100" rows="7">
  457. define( 'MULTISITE', true );
  458. define( 'SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> );
  459. define( 'DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>' );
  460. define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
  461. define( 'SITE_ID_CURRENT_SITE', 1 );
  462. define( 'BLOG_ID_CURRENT_SITE', 1 );
  463. </textarea>
  464. <?php
  465. $keys_salts = array(
  466. 'AUTH_KEY' => '',
  467. 'SECURE_AUTH_KEY' => '',
  468. 'LOGGED_IN_KEY' => '',
  469. 'NONCE_KEY' => '',
  470. 'AUTH_SALT' => '',
  471. 'SECURE_AUTH_SALT' => '',
  472. 'LOGGED_IN_SALT' => '',
  473. 'NONCE_SALT' => '',
  474. );
  475. foreach ( $keys_salts as $c => $v ) {
  476. if ( defined( $c ) ) {
  477. unset( $keys_salts[ $c ] );
  478. }
  479. }
  480. if ( ! empty( $keys_salts ) ) {
  481. $keys_salts_str = '';
  482. $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
  483. if ( is_wp_error( $from_api ) ) {
  484. foreach ( $keys_salts as $c => $v ) {
  485. $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
  486. }
  487. } else {
  488. $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
  489. foreach ( $keys_salts as $c => $v ) {
  490. $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
  491. }
  492. }
  493. $num_keys_salts = count( $keys_salts );
  494. ?>
  495. <p>
  496. <?php
  497. if ( 1 === $num_keys_salts ) {
  498. printf(
  499. /* translators: %s: wp-config.php */
  500. __( 'This unique authentication key is also missing from your %s file.' ),
  501. '<code>wp-config.php</code>'
  502. );
  503. } else {
  504. printf(
  505. /* translators: %s: wp-config.php */
  506. __( 'These unique authentication keys are also missing from your %s file.' ),
  507. '<code>wp-config.php</code>'
  508. );
  509. }
  510. ?>
  511. <?php _e( 'To make your installation more secure, you should also add:' ); ?>
  512. </p>
  513. <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
  514. <?php
  515. }
  516. ?>
  517. </li>
  518. <?php
  519. if ( iis7_supports_permalinks() ) :
  520. // IIS doesn't support RewriteBase, all your RewriteBase are belong to us.
  521. $iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
  522. $iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
  523. $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
  524. $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
  525. <configuration>
  526. <system.webServer>
  527. <rewrite>
  528. <rules>
  529. <rule name="WordPress Rule 1" stopProcessing="true">
  530. <match url="^index\.php$" ignoreCase="false" />
  531. <action type="None" />
  532. </rule>';
  533. if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
  534. $web_config_file .= '
  535. <rule name="WordPress Rule for Files" stopProcessing="true">
  536. <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
  537. <action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
  538. </rule>';
  539. }
  540. $web_config_file .= '
  541. <rule name="WordPress Rule 2" stopProcessing="true">
  542. <match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
  543. <action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
  544. </rule>
  545. <rule name="WordPress Rule 3" stopProcessing="true">
  546. <match url="^" ignoreCase="false" />
  547. <conditions logicalGrouping="MatchAny">
  548. <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
  549. <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
  550. </conditions>
  551. <action type="None" />
  552. </rule>
  553. <rule name="WordPress Rule 4" stopProcessing="true">
  554. <match url="^' . $iis_subdir_match . '(wp-(content|admin|includes).*)" ignoreCase="false" />
  555. <action type="Rewrite" url="' . $iis_rewrite_base . '{R:1}" />
  556. </rule>
  557. <rule name="WordPress Rule 5" stopProcessing="true">
  558. <match url="^' . $iis_subdir_match . '([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
  559. <action type="Rewrite" url="' . $iis_rewrite_base . '{R:2}" />
  560. </rule>
  561. <rule name="WordPress Rule 6" stopProcessing="true">
  562. <match url="." ignoreCase="false" />
  563. <action type="Rewrite" url="index.php" />
  564. </rule>
  565. </rules>
  566. </rewrite>
  567. </system.webServer>
  568. </configuration>
  569. ';
  570. echo '<li><p>';
  571. printf(
  572. /* translators: 1: File name (.htaccess or web.config), 2: File path. */
  573. __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
  574. '<code>web.config</code>',
  575. '<code>' . $home_path . '</code>'
  576. );
  577. echo '</p>';
  578. if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
  579. echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
  580. }
  581. ?>
  582. <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?></textarea>
  583. </li>
  584. </ol>
  585. <?php
  586. elseif ( $is_nginx ) : // End iis7_supports_permalinks(). Link to Nginx documentation instead:
  587. echo '<li><p>';
  588. printf(
  589. /* translators: %s: Documentation URL. */
  590. __( 'It seems your network is running with Nginx web server. <a href="%s">Learn more about further configuration</a>.' ),
  591. __( 'https://wordpress.org/support/article/nginx/' )
  592. );
  593. echo '</p></li>';
  594. else : // End $is_nginx. Construct an .htaccess file instead:
  595. $ms_files_rewriting = '';
  596. if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
  597. $ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
  598. $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
  599. }
  600. $htaccess_file = <<<EOF
  601. RewriteEngine On
  602. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  603. RewriteBase {$base}
  604. RewriteRule ^index\.php$ - [L]
  605. {$ms_files_rewriting}
  606. # add a trailing slash to /wp-admin
  607. RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement_01}wp-admin/ [R=301,L]
  608. RewriteCond %{REQUEST_FILENAME} -f [OR]
  609. RewriteCond %{REQUEST_FILENAME} -d
  610. RewriteRule ^ - [L]
  611. RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L]
  612. RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$subdir_replacement_12 [L]
  613. RewriteRule . index.php [L]
  614. EOF;
  615. echo '<li><p>';
  616. printf(
  617. /* translators: 1: File name (.htaccess or web.config), 2: File path. */
  618. __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
  619. '<code>.htaccess</code>',
  620. '<code>' . $home_path . '</code>'
  621. );
  622. echo '</p>';
  623. if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
  624. echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
  625. }
  626. ?>
  627. <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>"><?php echo esc_textarea( $htaccess_file ); ?></textarea>
  628. </li>
  629. </ol>
  630. <?php
  631. endif; // End IIS/Nginx/Apache code branches.
  632. if ( ! is_multisite() ) {
  633. ?>
  634. <p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
  635. <?php
  636. }
  637. }