由 myocean 在 05-23-2003 16:40 发表:
各位老大帮帮忙,APACHE出了问题.
我已经安装了httpd和mysql,是我的RH8自带的.也已经启动了他们,创建了数据库文件.可是我在浏览器里输入,127.0.0.1后出现错误如图.
我的config.php文件如下:
1
2
3// $Id: config.php,v 1.7
4
52003/01/04 08:43:21 larsneo
6
7Exp $
8
9//
10
11\----------------------------------------------------------------------
12
13// PostNuke Content
14
15Management System
16
17// Copyright (C) 2001 by the
18
19
20
21
22
23
24
25
26
27
28
29PostNuke Development Team.
30
31// http://www.postnuke.com/
32
33//
34
35\----------------------------------------------------------------------
36
37// Based on:
38
39// PHP-NUKE Web Portal
40
41System - http://phpnuke.org/
42
43// Thatware -
44
45http://thatware.org/
46
47//
48
49\----------------------------------------------------------------------
50
51// LICENSE
52
53//
54
55// This program is free
56
57software; you can
58
59redistribute it and/or
60
61// modify it under the terms
62
63
64
65
66
67
68
69
70
71
72
73of the GNU General Public
74
75License (GPL)
76
77// as published by the Free
78
79Software Foundation; either
80
81version 2
82
83// of the License, or (at
84
85your option) any later
86
87version.
88
89//
90
91// This program is
92
93distributed in the hope that
94
95
96
97
98
99
100
101
102
103
104
105it will be useful,
106
107// but WITHOUT ANY WARRANTY;
108
109
110
111
112
113
114
115
116
117
118
119without even the implied
120
121warranty of
122
123// MERCHANTABILITY or
124
125FITNESS FOR A PARTICULAR
126
127PURPOSE. See the
128
129// GNU General Public
130
131License for more details.
132
133//
134
135// To read the license
136
137please visit
138
139http://www.gnu.org/copyleft/gpl.html
140
141//
142
143\----------------------------------------------------------------------
144
145// Original Author of file:
146
147Everyone
148
149// Purpose of file:
150
151Configure database
152
153//
154
155\----------------------------------------------------------------------
156
157
158
159//
160
161\----------------------------------------------------------------------
162
163// Database & System Config
164
165//
166
167// dbtype: type of
168
169database, currently only
170
171mysql
172
173// dbhost: MySQL
174
175Database Hostname
176
177// dbuname: MySQL
178
179Username
180
181// dbpass: MySQL
182
183Password
184
185// dbname: MySQL
186
187Database Name
188
189// system: 0 for
190
191Unix/Linux, 1 for Windows
192
193// encoded: 0 for
194
195MySQL information unenccoded
196
197// 1 for
198
199encoded
200
201//
202
203\----------------------------------------------------------------------
204
205//
206
207$pnconfig['dbtype'] = 'mysql';
208
209$pnconfig['dbhost'] = '218.76.39.220';
210
211$pnconfig['dbuname'] = 'root';
212
213$pnconfig['dbpass'] = '';
214
215$pnconfig['dbname']='phoenix ';
216
217$pnconfig['system'] = '0';
218
219$pnconfig['prefix'] = 'phoenix';
220
221$pnconfig['encoded'] = '1';
222
223
224
225//
226
227\----------------------------------------------------------------------
228
229// For debugging (Pablo
230
231Roca)
232
233//
234
235// $debug - debugger windows
236
237
238
239
240
241
242
243
244
245
246
247active
248
249// 0 = No
250
251// 1 = Yes
252
253//
254
255// $debug_sql - show SQL in
256
257lens debug
258
259// 0 = No
260
261// 1 = Yes
262
263//
264
265\----------------------------------------------------------------------
266
267GLOBAL $pndebug;
268
269$pndebug['debug'] =
270
271
272
273
274
275
276
277
278
279
280
2810;
282
283$pndebug['debug_sql'] =
284
285
286
287
288
289
290
291
292
293
294
2950;
296
297
298
299//
300
301\----------------------------------------------------------------------
302
303// You have finished
304
305configuring the database.
306
307Now you can start to
308
309// change your site settings
310
311
312
313
314
315
316
317
318
319
320
321in the Administration
322
323Section.
324
325//
326
327// Thanks for choosing
328
329PostNuke.
330
331//
332
333\----------------------------------------------------------------------
334
335
336
337//
338
339\----------------------------------------------------------------------
340
341// if there is a
342
343personal_config.php in the
344
345folder where is config.php
346
347// we add it. (This HAS to
348
349be at the end, after all
350
351initialization.)
352
353//
354
355\----------------------------------------------------------------------
356
357if
358
359(@file_exists("personal_config.php"))
360
361{
362
363include("personal_config.php"); }
364
365//
366
367\----------------------------------------------------------------------
368
369// Make config file
370
371backwards compatible
372
373(deprecated)
374
375//
376
377\----------------------------------------------------------------------
378
379extract($pnconfig,
380
381EXTR_OVERWRITE);
382
我的pnAPI.php文件内容:
1
2
3
4
5// $Id: pnAPI.php,v 1.32 2003/01/18 13:14:16 class007 Exp $
6
7
8
9// ----------------------------------------------------------------------
10
11
12
13// PostNuke Content Management System
14
15
16
17// Copyright (C) 2001 by the Post-Nuke Development Team.
18
19
20
21// http://www.postnuke.com/
22
23
24
25// ----------------------------------------------------------------------
26
27
28
29// LICENSE
30
31
32
33//
34
35
36
37// This program is free software; you can redistribute it and/or
38
39
40
41// modify it under the terms of the GNU General Public License (GPL)
42
43
44
45// as published by the Free Software Foundation; either version 2
46
47
48
49// of the License, or (at your option) any later version.
50
51
52
53//
54
55
56
57// This program is distributed in the hope that it will be useful,
58
59
60
61// but WITHOUT ANY WARRANTY; without even the implied warranty of
62
63
64
65// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66
67
68
69// GNU General Public License for more details.
70
71
72
73//
74
75
76
77// To read the license please visit http://www.gnu.org/copyleft/gpl.html
78
79
80
81// ----------------------------------------------------------------------
82
83
84
85// Original Author of file: Jim McDonald
86
87
88
89// Purpose of file: The PostNuke API
90
91
92
93// ----------------------------------------------------------------------
94
95
96
97
98
99
100
101/*
102
103
104
105*
106
107
108
109* Defines
110
111
112
113*
114
115
116
117*/
118
119
120
121
122
123
124
125/* Allows Postnuke to work with register_globals set to off
126
127
128
129* Patch for php 4.2.x or greater
130
131
132
133*/
134
135
136
137
138
139
140
141if (phpversion() >= "4.2.0") {
142
143
144
145if ( ini_get('register_globals') != 1 ) {
146
147
148
149$supers = array('_REQUEST',
150
151
152
153'_ENV',
154
155
156
157'_SERVER',
158
159
160
161'_POST',
162
163
164
165'_GET',
166
167
168
169'_COOKIE',
170
171
172
173'_SESSION',
174
175
176
177'_FILES',
178
179
180
181'_GLOBALS' );
182
183
184
185
186
187
188
189foreach( $supers as $__s) {
190
191
192
193if ( (isset($$__s) == true) && (is_array( $$__s ) == true) ) extract( $$__s, EXTR_OVERWRITE );
194
195
196
197}
198
199
200
201unset($supers);
202
203
204
205}
206
207
208
209} else {
210
211
212
213if ( ini_get('register_globals') != 1 ) {
214
215
216
217
218
219
220
221$supers = array('HTTP_POST_VARS',
222
223
224
225'HTTP_GET_VARS',
226
227
228
229'HTTP_COOKIE_VARS',
230
231
232
233'GLOBALS',
234
235
236
237'HTTP_SESSION_VARS',
238
239
240
241'HTTP_SERVER_VARS',
242
243
244
245'HTTP_ENV_VARS'
246
247
248
249);
250
251
252
253
254
255
256
257foreach( $supers as $__s) {
258
259
260
261if ( (isset($$__s) == true) && (is_array( $$__s ) == true) ) extract( $$__s, EXTR_OVERWRITE );
262
263
264
265}
266
267
268
269unset($supers);
270
271
272
273}
274
275
276
277}
278
279
280
281
282
283
284
285/*
286
287
288
289* Yes/no integer
290
291
292
293*/
294
295
296
297define('_PNYES', 1);
298
299
300
301define('_PNNO', 0);
302
303
304
305
306
307
308
309/*
310
311
312
313* State of modules
314
315
316
317*/
318
319
320
321define('_PNMODULE_STATE_UNINITIALISED', 1);
322
323
324
325define('_PNMODULE_STATE_INACTIVE', 2);
326
327
328
329define('_PNMODULE_STATE_ACTIVE', 3);
330
331
332
333define('_PNMODULE_STATE_MISSING', 4);
334
335
336
337define('_PNMODULE_STATE_UPGRADED', 5);
338
339
340
341
342
343
344
345/*
346
347
348
349* 'All' and 'unregistered' for user and group permissions
350
351
352
353*/
354
355
356
357define('_PNPERMS_ALL', '-1');
358
359
360
361define('_PNPERMS_UNREGISTERED', '0');
362
363
364
365
366
367
368
369/*
370
371
372
373* Core version informations - should be upgraded on each release for
374
375
376
377* better control on config settings
378
379
380
381*/
382
383
384
385define('_PN_VERSION_NUM', "0.7.2.3-Phoenix");
386
387
388
389define('_PN_VERSION_ID', "PostNuke");
390
391
392
393define('_PN_VERSION_SUB', "Phoenix");
394
395
396
397
398
399
400
401/*
402
403
404
405* Fake module for config vars
406
407
408
409*/
410
411
412
413define('_PN_CONFIG_MODULE', '/PNConfig');
414
415
416
417
418
419
420
421/*
422
423
424
425*
426
427
428
429* Functions
430
431
432
433*
434
435
436
437*/
438
439
440
441
442
443
444
445/**
446
447
448
449* get all configuration variable into $pnconfig
450
451
452
453* will be removed on .8
454
455
456
457* @param none
458
459
460
461* @returns true|false
462
463
464
465* @return none
466
467
468
469*/
470
471
472
473function pnConfigInit() {
474
475
476
477global $pnconfig;
478
479
480
481
482
483
484
485list($dbconn) = pnDBGetConn();
486
487
488
489$pntable = pnDBGetTables();
490
491
492
493
494
495
496
497$table = $pntable['module_vars'];
498
499
500
501$columns = &$pntable['module_vars_column'];
502
503
504
505
506
507
508
509/*
510
511
512
513* Make query and go
514
515
516
517*/
518
519
520
521$query = "SELECT $columns[name],
522
523
524
525$columns[value]
526
527
528
529FROM $table
530
531
532
533WHERE $columns[modname]='" . pnVarPrepForStore(_PN_CONFIG_MODULE) . "'";
534
535
536
537$dbresult = $dbconn->Execute($query);
538
539
540
541if($dbconn->ErrorNo() != 0) {
542
543
544
545return false;
546
547
548
549}
550
551
552
553if ($dbresult->EOF) {
554
555
556
557$dbresult->Close();
558
559
560
561return false;
562
563
564
565}
566
567
568
569while(!$dbresult->EOF) {
570
571
572
573list($k, $v) = $dbresult->fields;
574
575
576
577$dbresult->MoveNext();
578
579
580
581if (($k != 'dbtype') && ($k != 'dbhost') && ($k != 'dbuname') && ($k != 'dbpass')
582
583
584
585&& ($k != 'dbname') && ($k != 'system') && ($k != 'prefix') && ($k != 'encoded')) {
586
587
588
589$v =@unserialize($v);
590
591
592
593$pnconfig[$k] = $v;
594
595
596
597}
598
599
600
601}
602
603
604
605$dbresult->Close();
606
607
608
609return true;
610
611
612
613}
614
615
616
617
618
619
620
621/**
622
623
624
625* get a configuration variable
626
627
628
629* @param name the name of the variable
630
631
632
633* @returns data
634
635
636
637* @return value of the variable, or false on failure
638
639
640
641*/
642
643
644
645function pnConfigGetVar($name)
646
647
648
649{
650
651
652
653global $pnconfig;
654
655
656
657if (isset($pnconfig[$name])) {
658
659
660
661$result = $pnconfig[$name];
662
663
664
665} else {
666
667
668
669/*
670
671
672
673* Fetch base data
674
675
676
677*/
678
679
680
681list($dbconn) = pnDBGetConn();
682
683
684
685$pntable = pnDBGetTables();
686
687
688
689
690
691
692
693$table = $pntable['module_vars'];
694
695
696
697$columns = &$pntable['module_vars_column'];
698
699
700
701
702
703
704
705/*
706
707
708
709* Make query and go
710
711
712
713*/
714
715
716
717$query = "SELECT $columns[value]
718
719
720
721FROM $table
722
723
724
725WHERE $columns[modname]='" . pnVarPrepForStore(_PN_CONFIG_MODULE) . "'
726
727
728
729AND $columns[name]='" . pnVarPrepForStore($name) . "'";
730
731
732
733$dbresult = $dbconn->Execute($query);
734
735
736
737
738
739
740
741/*
742
743
744
745* In any case of error return false
746
747
748
749*/
750
751
752
753if($dbconn->ErrorNo() != 0) {
754
755
756
757return false;
758
759
760
761}
762
763
764
765if ($dbresult->EOF) {
766
767
768
769$dbresult->Close();
770
771
772
773return false;
774
775
776
777}
778
779
780
781
782
783
784
785/*
786
787
788
789* Get data
790
791
792
793*/
794
795
796
797list ($result) = $dbresult->fields;
798
799
800
801$result = unserialize($result);
802
803
804
805
806
807
808
809/*
810
811
812
813* Some caching
814
815
816
817*/
818
819
820
821$pnconfig[$name] = $result;
822
823
824
825
826
827
828
829/*
830
831
832
833* That's all folks
834
835
836
837*/
838
839
840
841$dbresult->Close();
842
843
844
845}
846
847
848
849
850
851
852
853return $result;
854
855
856
857}
858
859
860
861
862
863
864
865/**
866
867
868
869* set a configuration variable
870
871
872
873* @param name the name of the variable
874
875
876
877* @param value the value of the variable
878
879
880
881* @returns bool
882
883
884
885* @return true on success, false on failure
886
887
888
889*/
890
891
892
893function pnConfigSetVar($name, $value)
894
895
896
897{
898
899
900
901/*
902
903
904
905* The database parameter are not allowed to change
906
907
908
909*/
910
911
912
913if (empty($name) || ($name == 'dbtype') || ($name == 'dbhost') || ($name == 'dbuname') || ($name == 'dbpass')
914
915
916
917|| ($name == 'dbname') || ($name == 'system') || ($name == 'prefix') || ($name == 'encoded')) {
918
919
920
921return false;
922
923
924
925}
926
927
928
929
930
931
932
933/*
934
935
936
937* Test on missing record
938
939
940
941*
942
943
944
945* Also solve SF-bug #580951
946
947
948
949*/
950
951
952
953$must_insert = true;
954
955
956
957global $pnconfig;
958
959
960
961foreach($pnconfig as $k => $v) {
962
963
964
965/*
966
967
968
969* Test if the key name is in the array
970
971
972
973*/
974
975
976
977if ($k == $name) {
978
979
980
981/*
982
983
984
985* Set flag
986
987
988
989*/
990
991
992
993$must_insert = false;
994
995
996
997/*
998
999
1000
1001* Test on change. If not, just quit now
1002
1003
1004
1005*/
1006
1007
1008
1009if ($v == $value) {
1010
1011
1012
1013return true;
1014
1015
1016
1017}
1018
1019
1020
1021/*
1022
1023
1024
1025* End loop after success
1026
1027
1028
1029*/
1030
1031
1032
1033break;
1034
1035
1036
1037}
1038
1039
1040
1041}
1042
1043
1044
1045
1046
1047
1048
1049/*
1050
1051
1052
1053* Fetch base data
1054
1055
1056
1057*/
1058
1059
1060
1061list($dbconn) = pnDBGetConn();
1062
1063
1064
1065$pntable = pnDBGetTables();
1066
1067
1068
1069$table = $pntable['module_vars'];
1070
1071
1072
1073$columns = &$pntable['module_vars_column'];
1074
1075
1076
1077
1078
1079
1080
1081/*
1082
1083
1084
1085* Update the table
1086
1087
1088
1089*/
1090
1091
1092
1093if ($must_insert) {
1094
1095
1096
1097/*
1098
1099
1100
1101* Insert
1102
1103
1104
1105*/
1106
1107
1108
1109$query = "INSERT INTO $table
1110
1111
1112
1113($columns[modname],
1114
1115
1116
1117$columns[name],
1118
1119
1120
1121$columns[value])
1122
1123
1124
1125VALUES ('" . pnVarPrepForStore(_PN_CONFIG_MODULE) . "',
1126
1127
1128
1129'" . pnVarPrepForStore($name) . "',
1130
1131
1132
1133'" . pnVarPrepForStore(serialize($value)). "')";
1134
1135
1136
1137} else {
1138
1139
1140
1141/*
1142
1143
1144
1145* Update
1146
1147
1148
1149*/
1150
1151
1152
1153$query = "UPDATE $table
1154
1155
1156
1157SET $columns[value]='" . pnVarPrepForStore(serialize($value)) . "'
1158
1159
1160
1161WHERE $columns[modname]='" . pnVarPrepForStore(_PN_CONFIG_MODULE) . "'
1162
1163
1164
1165AND $columns[name]='" . pnVarPrepForStore($name) . "'";
1166
1167
1168
1169}
1170
1171
1172
1173$dbconn->Execute($query);
1174
1175
1176
1177if($dbconn->ErrorNo() != 0) {
1178
1179
1180
1181return false;
1182
1183
1184
1185}
1186
1187
1188
1189
1190
1191
1192
1193/*
1194
1195
1196
1197* Update my vars
1198
1199
1200
1201*/
1202
1203
1204
1205$pnconfig[$name] = $value;
1206
1207
1208
1209
1210
1211
1212
1213return true;
1214
1215
1216
1217}
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229/**
1230
1231
1232
1233* delete a configuration variable
1234
1235
1236
1237* @param name the name of the variable
1238
1239
1240
1241* @returns bool
1242
1243
1244
1245* @return true on success, false on failure
1246
1247
1248
1249*/
1250
1251
1252
1253function pnConfigDelVar($name)
1254
1255
1256
1257{
1258
1259
1260
1261global $pnconfig;
1262
1263
1264
1265
1266
1267
1268
1269if (empty($name)) {
1270
1271
1272
1273return false;
1274
1275
1276
1277}
1278
1279
1280
1281
1282
1283
1284
1285// Don't allow deleting at current
1286
1287
1288
1289return false;
1290
1291
1292
1293}
1294
1295
1296
1297
1298
1299
1300
1301/**
1302
1303
1304
1305* Initialise PostNuke
1306
1307
1308
1309*
``` * Carries out a number of initialisation tasks to get PostNuke up and
running.
@returns void
*/
function pnInit()
{
// Proper error reporting Commented out for release
// error_reporting(E_ALL);
// Hack for some weird PHP systems that should have the
// LC_* constants defined, but don't
if (!defined('LC_TIME')) {
define('LC_TIME', 'LC_TIME');
}
// ADODB configuration
define('ADODB_DIR', 'pnadodb');
include 'pnadodb/adodb.inc.php';
// Temporary fix for hacking the hlpfile global
// TODO - remove with pre-0.71 code
global $hlpfile;
$hlpfile = '';
// Initialise and load configuration
global $pnconfig, $pndebug;
$pnconfig = array();
include 'config.php';
// Set up multisites
// added this @define for .71, ugly ?
// i guess the E_ALL stuff.
@define('WHERE_IS_PERSO', '');
// Initialise and load pntables
global $pntable;
$pntable = array();
// if a multisite has its own pntables.
if (file_exists(WHERE_IS_PERSO.'pntables.php')) {
include WHERE_IS_PERSO.'pntables.php';
} else {
include 'pntables.php';
}
// Decode encoded DB parameters
if ($pnconfig['encoded']) {
$pnconfig['dbuname'] = base64_decode($pnconfig['dbuname']);
$pnconfig['dbpass'] = base64_decode($pnconfig['dbpass']);
$pnconfig['encoded'] = 0;
}
// Connect to database
if (!pnDBInit()) {
die('Database initialisation failed');
}
// debugger if required
if ($pndebug['debug']){
include_once 'includes/lensdebug.inc.php';
global $dbg, $debug_sqlcalls;
$dbg = new LensDebug();
$debug_sqlcalls = 0;
}
// Build up old config array
pnConfigInit();
// Set compression on if desired
//
if (pnConfigGetVar('UseCompression') == 1) {
ob_start("ob_gzhandler");
}
// Other includes
include 'includes/pnSession.php';
include 'includes/pnUser.php';
// Start session
if (!pnSessionSetup()) {
die('Session setup failed');
}
if (!pnSessionInit()) {
die('Session initialisation failed');
}
include 'includes/security.php';
// See if a language update is required
$newlang = pnVarCleanFromInput('newlang');
if (!empty($newlang)) {
$lang = $newlang;
pnSessionSetVar('lang', $newlang);
} else {
$lang = pnSessionGetVar('lang');
}
// Load global language defines
if (isset ($lang) && file_exists('language/' . pnVarPrepForOS($lang) . '/global.php')) {
$currentlang = $lang;
} else {
$currentlang = pnConfigGetVar('language');
pnSessionSetVar('lang', $currentlang);
}
include 'language/' . pnVarPrepForOS($currentlang) . '/global.php';
include 'modules/NS-Languages/api.php';
// Cross-Site Scripting attack defense - Sent by larsneo
// some syntax checking against injected javascript
$pnAntiCrackerMode = pnConfigGetVar('pnAntiCracker');
if ( $pnAntiCrackerMode == 1 ) {
pnSecureInput();
}
// Banner system
include 'includes/pnBanners.php';
// Other other includes
include 'includes/advblocks.php';
include 'includes/counter.php';
include 'includes/pnHTML.php';
include 'includes/pnMod.php';
include 'includes/queryutil.php';
include 'includes/xhtml.php';
include 'includes/oldfuncs.php';
// Handle referer
if (pnConfigGetVar('httpref') == 1) {
include 'referer.php';
httpreferer();
}
return true;
}
function pninclude_once($file)
{
include_once($file);
}
function pnDBInit()
{
// Get database parameters
global $pnconfig;
$dbtype = $pnconfig['dbtype'];
$dbhost = $pnconfig['dbhost'];
$dbname = $pnconfig['dbname'];
$dbuname = $pnconfig['dbuname'];
$dbpass = $pnconfig['dbpass'];
// Database connection is a global (for now)
global $dbconn;
// Start connection
$dbconn = ADONewConnection($dbtype);
$dbh = $dbconn->Connect($dbhost, $dbuname, $dbpass, $dbname);
if (!$dbh) {
$dbpass = "";
die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect" . $dbconn->ErrorMsg());
}
global $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
// force oracle to a consistent date format for comparison methods later on
if (strcmp($dbtype, 'oci8') == 0) {
$dbconn->Execute("alter session set NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
}
return true;
}
/**
get a list of database connections
@returns array
@return array of database connections
*/
function pnDBGetConn()
{
global $dbconn;
return array($dbconn);
}
/**
get a list of database tables
@returns array
@return array of database tables
*/
function pnDBGetTables()
{
global $pntable;
return $pntable;
}
/**
clean user input
1<br/>
Gets a global variable, cleaning it up to try to ensure that
hack attacks don't work
@param var name of variable to get
@param ...
@returns string/array
@return prepared variable if only one variable passed
in, otherwise an array of prepared variables
*/
function pnVarCleanFromInput()
{
$search = array('|
|si',
'|
|si',
'|
|si',
'|
|si',
'|
|si',
'|
|si',
'|STYLE\s*=\s*"[^"]*"|si');
$replace = array('');
$resarray = array();
foreach (func_get_args() as $var) {
// Get var
global $$var;
if (empty($var)) {
return;
}
$ourvar = $$var;
if (!isset($ourvar)) {
array_push($resarray, NULL);
continue;
}
if (empty($ourvar)) {
array_push($resarray, $ourvar);
continue;
}
// Clean var
if (get_magic_quotes_gpc()) {
pnStripslashes($ourvar);
}
if (!pnSecAuthAction(0, '::', '::', ACCESS_ADMIN)) {
$ourvar = preg_replace($search, $replace, $ourvar);
}
// Add to result array
array_push($resarray, $ourvar);
}
// Return vars
if (func_num_args() == 1) {
return $resarray[0];
} else {
return $resarray;
}
}
/**
strip slashes
stripslashes on multidimensional arrays.
Used in conjunction with pnVarCleanFromInput
@access private
@param any variables or arrays to be stripslashed
*/
function pnStripslashes (&$value) {
if(!is_array($value)) {
$value = stripslashes($value);
} else {
array_walk($value,'pnStripslashes');
}
}
/**
ready user output
1<br/>
Gets a variable, cleaning it up such that the text is
shown exactly as expected
@param var variable to prepare
@param ...
@returns string/array
@return prepared variable if only one variable passed
in, otherwise an array of prepared variables
*/
function pnVarPrepForDisplay()
{
// This search and replace finds the text 'x@y' and replaces
// it with HTML entities, this provides protection against
// email harvesters
static $search = array('/(.)@(.)/se');
static $replace = array('"&#" .
sprintf("%03d", ord("\\1")) .
";@&#" .
sprintf("%03d", ord("\\2")) . ";";');
$resarray = array();
foreach (func_get_args() as $ourvar) {
// Prepare var
$ourvar = htmlspecialchars($ourvar);
$ourvar = preg_replace($search, $replace, $ourvar);
// Add to array
array_push($resarray, $ourvar);
}
// Return vars
if (func_num_args() == 1) {
return $resarray[0];
} else {
return $resarray;
}
}
/**
ready HTML output
<br>
Gets a variable, cleaning it up such that the text is
shown exactly as expected, except for allowed HTML tags which
are allowed through
@param var variable to prepare
@param ...
@returns string/array
@return prepared variable if only one variable passed
in, otherwise an array of prepared variables
*/
function pnVarPrepHTMLDisplay()
{
// This search and replace finds the text 'x@y' and replaces
// it with HTML entities, this provides protection against
// email harvesters
//
// Note that the use of \024 and \022 are needed to ensure that
// this does not break HTML tags that might be around either
// the username or the domain name
static $search = array('/([^\024])@([^\022])/se');
static $replace = array('"&#" .
sprintf("%03d", ord("\\1")) .
";@&#" .
sprintf("%03d", ord("\\2")) . ";";');
static $allowedhtml;
if (!isset($allowedhtml)) {
$allowedhtml = array();
foreach(pnConfigGetVar('AllowableHTML') as $k=>$v) {
switch($v) {
case 0:
break;
case 1:
$allowedhtml[] = "|<(/?$k)\s*/?>|i";
break;
case 2:
$allowedhtml[] = "|<(/?$k(\s+.*?)?)>|i";
break;
}
}
}
$resarray = array();
foreach (func_get_args() as $ourvar) {
// Preparse var to mark the HTML that we want
$ourvar = preg_replace($allowedhtml, "\022\\1\024", $ourvar);
// Prepare var
$ourvar = htmlspecialchars($ourvar);
$ourvar = preg_replace($search, $replace, $ourvar);
// Fix the HTML that we want
$ourvar = preg_replace('/\022([^\024]*)\024/e',
"'<' . strtr('\\1', array('>' => '>',
'<' => '<',
'"' => '"',
'&' => '&'))
. '>';", $ourvar);
// Fix entities if required
if (pnConfigGetVar('htmlentities')) {
$ourvar = preg_replace('/&([a-z#0-9]+);/i', "&\\1;", $ourvar);
}
// Add to array
array_push($resarray, $ourvar);
}
// Return vars
if (func_num_args() == 1) {
return $resarray[0];
} else {
return $resarray;
}
}
/**
ready databse output
<br>
Gets a variable, cleaning it up such that the text is
stored in a database exactly as expected
@param var variable to prepare
@param ...
@returns string/array
@return prepared variable if only one variable passed
in, otherwise an array of prepared variables
*/
function pnVarPrepForStore()
{
$resarray = array();
foreach (func_get_args() as $ourvar) {
// Prepare var
if (!get_magic_quotes_runtime()) {
$ourvar = addslashes($ourvar);
}
// Add to array
array_push($resarray, $ourvar);
}
// Return vars
if (func_num_args() == 1) {
return $resarray[0];
} else {
return $resarray;
}
}
/**
ready operating system output
<br>
Gets a variable, cleaning it up such that any attempts
to access files outside of the scope of the PostNuke
system is not allowed
@param var variable to prepare
@param ...
@returns string/array
@return prepared variable if only one variable passed
in, otherwise an array of prepared variables
*/
function pnVarPrepForOS()
{
static $search = array('!\.\./!si', // .. (directory traversal)
'!^.://!si', // .:// (start of URL)
'!/!si', // Forward slash (directory traversal)
'!\\\\!si'); // Backslash (directory traversal)
static $replace = array('',
'',
'_',
'_');
$resarray = array();
foreach (func_get_args() as $ourvar) {
// Parse out bad things
$ourvar = preg_replace($search, $replace, $ourvar);
// Prepare var
if (!get_magic_quotes_runtime()) {
$ourvar = addslashes($ourvar);
}
// Add to array
array_push($resarray, $ourvar);
}
// Return vars
if (func_num_args() == 1) {
return $resarray[0];
} else {
return $resarray;
}
}
/**
- remove censored words
*/
function pnVarCensor()
{
static $docensor;
if (!isset($docensor)) {
$docensor = pnConfigGetVar('CensorMode');
}
static $search = array();
if (empty($search)) {
$repsearch = array('/o/i',
'/e/i',
'/a/i',
'/i/i');
$repreplace = array('0',
'3',
'@',
'1');
$censoredwords = pnConfigGetVar('CensorList');
foreach ($censoredwords as $censoredword) {
// Simple word
$search[] = "/\b$censoredword\b/i";
// Common replacements
$mungedword = preg_replace($repsearch, $repreplace, $censoredword);
if ($mungedword != $censoredword) {
$search[] = "/\b$mungedword\b/";
}
}
}
$replace = pnConfigGetVar('CensorReplace');
$resarray = array();
foreach (func_get_args() as $ourvar) {
if ($docensor) {
// Parse out nasty words
$ourvar = preg_replace($search, $replace, $ourvar);
}
// Add to array
array_push($resarray, $ourvar);
}
// Return vars
if (func_num_args() == 1) {
return $resarray[0];
} else {
return $resarray;
}
}
/**
validate a user variable
@access public
@author Damien Bonvillain
@author Gregor J. Rothfuss
@since 1.23 - 2002/02/01
@param var the variable to validate
@param type the type of the validation to perform
@param args optional array with validation-specific settings
@returns bool
@return true if the validation was successful, false otherwise
*/
function pnVarValidate($var, $type, $args=0)
{
switch ($type) {
case 'email':
// all characters must be 7 bit ascii
$length = strlen($var);
$idx = 0;
while($length--) {
$c = $var[$idx++];
if(ord($c) > 127){
return false;
}
}
$regexp = '/^(?:[^\s\000-\037\177\(\)<>@,;:\"\[\]]\.?)+@(?:[^\s\000-\037\177\(\)<>@,;:\\"\[\]]\.?)+\.[a-z]{2,6}$/Ui';
if(preg_match($regexp,$var)) {
return true;
} else {
return false;
}
break;
case 'url':
// all characters must be 7 bit ascii
$length = strlen($var);
$idx = 0;
while($length--) {
$c = $var[$idx++];
if(ord($c) > 127){
return false;
}
}
$regexp = '/^([!$\046-\073=\077-\132_\141-\172~]|(?
[a-f0-9]{2}))+$/i';
if(!preg_match($regexp, $var)) {
return false;
}
$url_array = @parse_url($var);
if(empty($url_array)) {
return false;
} else {
return !empty($url_array['scheme']);
}
break;
}
}
/**
check an assertion
<br>
Check an assertion to ensure that it is valid. If not, then die
@param assertion the assertion
@param filename the filename the assertion occurs in
@param line the line number the assertion occurs in
*/
function pnAssert($assertion, $file='Unknown', $line='Unknown', $msg='')
{
if ($assertion) {
return;
}
// Assertion failed - log it
if (!empty($msg)) {
die("Assertion failed in $file at line $line - $msg");
} else {
die("Assertion failed in $file at line $line");
}
}
/**
get status message from previous operation
<br>
Obtains any status message, and also destroys
it from the session to prevent duplication
@returns string
@return the status message
*/
function pnGetStatusMsg()
{
$msg = pnSessionGetVar('statusmsg');
pnSessionDelVar('statusmsg');
$errmsg = pnSessionGetVar('errormsg');
pnSessionDelVar('errormsg');
// Error message overrides status message
if (!empty($errmsg)) {
return $errmsg;
}
return $msg;
}
function pnThemeLoad($thistheme)
{
static $loaded = 0;
if ($loaded) {
return true;
}
// Lots of nasty globals for back-compatability with older themes
global $bgcolor1;
global $bgcolor2;
global $bgcolor3;
global $bgcolor4;
global $bgcolor5;
global $sepcolor;
global $textcolor1;
global $textcolor2;
global $postnuke_theme;
global $thename;
// modification mouzaia .71
// is this really useful ?
/* $themefile = 'themes/' . pnVarPrepForOS(pnUserGetTheme()) . '/theme.php';
if (!file_exists($themefile)) {
return false;
}
*/
// eugenio themeover 20020413
if (@file(WHERE_IS_PERSO."themes/$thistheme/theme.php"))
{ include WHERE_IS_PERSO."themes/$thistheme/theme.php"; }
else
{
include "themes/$thistheme/theme.php";
}
// end of modification
$loaded = 1;
return true;
}
function pnThemeGetVar($name)
{
global $$name;
if (isset($$name)) {
return $$name;
}
}
/**
get base URI for PostNuke
@returns string
@return base URI for PostNuke
*/
function pnGetBaseURI()
{
global $HTTP_SERVER_VARS;
// Get the name of this URI
// Start of with REQUEST_URI
if (isset($HTTP_SERVER_VARS['REQUEST_URI'])) {
$path = $HTTP_SERVER_VARS['REQUEST_URI'];
} else {
$path = getenv('REQUEST_URI');
}
if ((empty($path)) ||
(substr($path, -1, 1) == '/')) {
// REQUEST_URI was empty or pointed to a path
// Try looking at PATH_INFO
$path = getenv('PATH_INFO');
if (empty($path)) {
// No luck there either
// Try SCRIPT_NAME
if (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
$path = $HTTP_SERVER_VARS['SCRIPT_NAME'];
} else {
$path = getenv('SCRIPT_NAME');
}
}
}
$path = preg_replace('/[#?].*/', '', $path);
$path = dirname($path);
if (preg_match('!^[/\\\]*$!', $path)) {
$path = '';
}
return $path;
}
/**
get base URL for PostNuke
@returns string
@return base URL for PostNuke
*/
function pnGetBaseURL()
{
global $HTTP_SERVER_VARS;
if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) {
$server = getenv('HTTP_HOST');
} else {
$server = $HTTP_SERVER_VARS['HTTP_HOST'];
}
// IIS sets HTTPS=off
if (isset($HTTP_SERVER_VARS['HTTPS']) && $HTTP_SERVER_VARS['HTTPS'] != 'off') {
$proto = 'https://';
} else {
$proto = 'http://';
}
$path = pnGetBaseURI();
return "$proto$server$path/";
}
/**
Carry out a redirect
@param the URL to redirect to
@returns void
*/
function pnRedirect($redirecturl)
{
// Always close session before redirect
if (function_exists('session_write_close')) {
session_write_close();
}
if (preg_match('!^http!', $redirecturl)) &