forked from asxzy/Program-O
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.php
More file actions
58 lines (51 loc) · 1.7 KB
/
Copy pathhelp.php
File metadata and controls
58 lines (51 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/***************************************
* http://www.program-o.com
* PROGRAM O
* Version: 2.6.11
* FILE: help.php
* AUTHOR: Elizabeth Perreau and Dave Morton
* DATE: 13-11-2014
* DETAILS: Provides halp information for the Program O install script
***************************************/
ini_set("display_errors", false);
ini_set("log_errors", true);
ini_set("error_log", "../logs/error.log");
define('SECTION_START', '<!-- Section [section] Start -->'); # search params for start and end of sections
define('SECTION_END', '<!-- Section [section] End -->'); # search params for start and end of sections
$template = file_get_contents('help.tpl.htm');
$content = help_getSection('HelpPage', $template, false);
$helpContent = help_getSection('HelpMain', $template);
$content = str_replace('[helpContent]', $helpContent, $content);
echo($content);
/**
* Function help_getSection
*
* @param $sectionName
* @param $page_template
* @param bool $notFoundReturn
* @return string
*/
function help_getSection($sectionName, $page_template, $notFoundReturn = true)
{
$sectionStart = str_replace('[section]', $sectionName, SECTION_START);
$sectionStartLen = strlen($sectionStart);
$sectionEnd = str_replace('[section]', $sectionName, SECTION_END);
$startPos = strpos($page_template, $sectionStart, 0);
if ($startPos === false)
{
if ($notFoundReturn) {
return '';
}
else {
$startPos = 0;
}
}
else {
$startPos += $sectionStartLen;
}
$endPos = strpos($page_template, $sectionEnd, $startPos) - 1;
$sectionLen = $endPos - $startPos;
$out = substr($page_template, $startPos, $sectionLen);
return trim($out);
}