Issues (1752)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/doc-restructuredtext.php (13 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @package		fwolflib
4
 * @subpackage	class
5
 * @copyright	Copyright © 2010, Fwolf
6
 * @author		Fwolf <[email protected]>
7
 * @since		2010-10-19
8
 */
9
10
11
require_once(dirname(__FILE__) . '/fwolflib.php');
12
require_once(FWOLFLIB . 'class/mvc-view.php');
13
require_once(FWOLFLIB . 'func/array.php');
14
15
16
/**
17
 * Display text document writing by reStructuredText markup language.
18
 *
19
 * Also include some other convert feature.
20
 *
21
 * Need jQuery, locate assigned in $aCfg['path_jquery']
22
 *
23
 * :TODO: Highlight: http://softwaremaniacs.org/soft/highlight/en/
24
 *
25
 * @deprecated  Use Fwlib\Html\TextDocument\Restructuredtext
26
 * @package		fwolflib
27
 * @subpackage	class
28
 * @copyright	Copyright © 2010, Fwolf
29
 * @author		Fwolf <[email protected]>
30
 * @since		2010-10-19
31
 */
32
class DocReStructuredText extends Fwolflib {
0 ignored issues
show
Deprecated Code introduced by
The class Fwolflib has been deprecated with message: Use classes in Fwlib namespace, see PSR-0/1/2

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
33
34
	/**
35
	 * Cmd options when used rst2xxx.py
36
	 *
37
	 * Param is combined in, eg: tab-width=4
38
	 * @var	array
39
	 */
40
	public $aCmdOption = array(
41
		'embed-stylesheet',
42
		//'link-stylesheet',
43
44
		// h1 is for title
45
		'initial-header-level=2',
46
47
		//'no-doc-title',
48
		//'no-xml-declaration',
49
50
		// Params why not support ?
51
		//'indents',
52
		//'newlines',
53
	);
54
55
	/**
56
	 * Result html
57
	 * @var	string
58
	 */
59
	public $sHtml = '';
60
61
	/**
62
	 * Actural path of docutils execute file.
63
	 * @var	string
64
	 * @see	SetPathDocutils()
65
	 */
66
	protected $sPathDocutils = '';
67
68
69
	/**
70
	 * construct
71
	 *
72
	 * @var param	string	$path_docutils	Path of docutils exec file
73
	 */
74
	public function __construct ($path_docutils = '') {
75
		parent::__construct();
76
77
		$this->GetPathDocutils($path_docutils);
78
79
		// Get docutils writer html4css1 path, and add to cmd param
80
		$this->aCmdOption[] = 'stylesheet-path="'
81
			. $this->GetDocutilsCssPath() . ','
82
			// Add my own css
83
			. dirname(__FILE__) . '/../css/doc-restructuredtext.css"';
84
85
		//$this->SetInfoFwolflib();
86
	} // end of class __construct
87
88
89
	/**
90
	 * Add my html footer
91
	 *
92
	 * Some code is cp from fwolfweb
93
	 *
94
	 * @param	string	$s_html
95
	 * @return	string
96
	 */
97
	public function AddFooter ($s_html) {
98
		$s = '';
99
		if ($this->aCfg['show_ads']) {
100
			$s .= '
101
				<div id="ads_bottom">
102
					<br />
103
					<script type="text/javascript">
104
					<!--//--><![CDATA[//>
105
					<!--
106
						google_ad_client = "pub-7916103707935920";
107
						google_ad_width = 728;
108
						google_ad_height = 90;
109
						google_ad_format = "728x90_as";
110
						google_ad_type = "text_image";
111
						//2006-10-28: independence_application
112
						google_ad_channel = "1115184146";
113
						google_color_border = "B4D0DC";
114
						google_color_bg = "FFFFFF";
115
						google_color_link = "0033FF";
116
						google_color_text = "6F6F6F";
117
						google_color_url = "008000";
118
					//--><!]]>
119
					</script>
120
					<script type="text/javascript"
121
					  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
122
					</script>
123
				</div>
124
			';
125
		}
126
127
		$s .= '
128
			<div id="footer">
129
				<hr />
130
				<a class="img" href="http://validator.w3.org/check?uri=referer">
131
					<img src="http://www.fwolf.com/icon/xhtml-1.0.png" alt="Valid XHTML 1.0!" />
132
				</a>
133
				<span class="spacer" >&nbsp;</span>
134
				<a class="img" href="http://jigsaw.w3.org/css-validator/check/referer">
135
					<img src="http://www.fwolf.com/icon/css.png" alt="Valid CSS!" />
136
				</a>
137
		';
138
139
		if ($this->aCfg['show_counter']) {
140
			$s .= '
141
				<span class="spacer" >&nbsp;</span>
142
				<script type="text/javascript" src="http://js.users.51.la/272422.js"></script>
143
				<noscript>
144
					<div>
145
						<a href="http://www.51.la/?272422">
146
							<img alt="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" src="http://img.users.51.la/272422.asp" style="border:none" />
147
						</a>
148
					</div>
149
				</noscript>
150
			';
151
		}
152
153
		$s .= '
154
				<span id="copyright">
155
					Copyright &copy; 2011 <a href="http://www.fwolf.com/">Fwolf</a>, All Rights Reserved.
156
				</span>
157
			</div>
158
		';
159
160
		$s_html = $this->AddToFooter($s_html, $s);
161
		return $s_html;
162
	} // end of func AddFooter
163
164
165
	/**
166
	 * Add jquery lib link in <head>
167
	 *
168
	 * @param	string	$s_html
169
	 * @return	string
170
	 */
171
	protected function AddJsJquery ($s_html) {
172
		$s_html = str_replace('</head>'
173
			, '<script type="text/javascript" src="'
174
					. $this->aCfg['path_jquery'] . '">'
175
				. '</script>'
176
				. "\n</head>"
177
			, $s_html);
178
179
		return $s_html;
180
	} // end of func AddJsJquery
181
182
183
	/**
184
	 * Add js code, which can show source of prefered part.
185
	 *
186
	 * Need: $this->aCfg['js_jquery'] = true;
187
	 *
188
	 * @return	string
189
	 */
190
	public function AddJsShowSource () {
191
		$s = '
192
			<script type="text/javascript">
193
			<!--//--><![CDATA[//>
194
			<!--
195
196
			// At first, hide all source code
197
			$(".show_source").next("pre").css("display", "none");
198
199
200
			// Click to show/hide source code
201
			$(".show_source").click(function() {
202
				obj = $(this).next();
203
				if ("none" == obj.css("display")) {
204
					// Show it
205
					obj.show("slow");
206
				}
207
				else {
208
					// Hide it
209
					obj.hide("fast");
210
				}
211
			});
212
213
			//--><!]]>
214
			</script>
215
		';
216
217
		$this->sHtml = $this->AddToFooterBefore($this->sHtml, $s);
218
		return $this->sHtml;
219
	} // end of func AddJsShowSource
220
221
222
	/**
223
	 * Put log bottom at document
224
	 *
225
	 * @param	$level	Only output log which's level >= $level
226
	 * @return	string
227
	 */
228
	public function AddLog ($level = 3) {
229
		$s_log = parent::LogGet($level);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (LogGet() instead of AddLog()). Are you sure this is correct? If so, you might want to change this to $this->LogGet().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
230
		$s_log = "<div class='log'>$s_log</div>";
231
232
		// Insert to document
233
		$this->sHtml = $this->AddToFooterBefore($this->sHtml, $s_log);
234
235
		return $this->sHtml;
236
	} // end of func AddLog
237
238
239
	/**
240
	 * Add some code to footer
241
	 *
242
	 * @param	string	$s_html
243
	 * @param	string	$s_add
244
	 * @return	stirng
245
	 */
246 View Code Duplication
	public function AddToFooter ($s_html, $s_add) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
247
		$i = strrpos($s_html, '</body>');
248
		if (! (false === $i)) {
249
			$s_html = substr($s_html, 0, $i) . $s_add
250
				. "\n</body>\n</html>";
251
		}
252
253
		return $s_html;
254
	} // end of func AddToFooter
255
256
257
	/**
258
	 * Add some code before footer div
259
	 *
260
	 * @param	string	$s_html
261
	 * @param	string	$s_add
262
	 * @return	stirng
263
	 */
264 View Code Duplication
	public function AddToFooterBefore ($s_html, $s_add) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
265
		$i = strrpos($s_html, '<div id="footer">');
266
		if (! (false === $i)) {
267
			$s_html = substr($s_html, 0, $i) . $s_add . "\n"
268
				. substr($s_html, $i);
269
		}
270
271
		return $s_html;
272
	} // end of func AddToFooterBefore
273
274
275
	/**
276
	 * Gen cmd options
277
	 *
278
	 * @return	string
279
	 */
280 View Code Duplication
	protected function GenCmdOption () {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
281
		if (empty($this->aCmdOption)) {
282
			return '';
283
		}
284
		else {
285
			$s = ' ';
286
			foreach ($this->aCmdOption as $v) {
287
				// Single char param without '-'
288
				if (1 == strlen($v))
289
					$v = '-' . $v;
290
				// Multi char param without '--'
291
				if (1 < strlen($v) && '--' != substr($v, 0, 2))
292
					$v = '--' . $v;
293
294
				$s .= $v . ' ';
295
			}
296
			return $s;
297
		}
298
	} // end of func GenCmdOption
299
300
301
	/**
302
	 * Gen magic comment including mode, coding
303
	 *
304
	 * @return	string
305
	 */
306
	public function GenRstMagicComment () {
307
		return "..	-*- mode: rst -*-\n"
308
			. "..	-*- coding: utf-8 -*-\n\n";
309
	} // end of func GenRstMagicComment
310
311
312
	/**
313
	 * Gen simple table by rst syntax
314
	 *
315
	 * Param $ar_thead[] format:
316
	 * array(
317
	 *	idx, index of data in $ar_data
318
	 *	title, text display in <th>, can be empty.
319
	 *	width, possible max length of text display in <td>
320
	 * )
321
	 * All text in th/td will be cut short if length > width.
322
	 * Columns' width will become td's width by their proportion,
323
	 * so it should make narrow col a bit wider.
324
	 *
325
	 * $ar_data is 2-dim array, index of 1st dim is ignored,
326
	 * index of 2st dim will be called by $ar_thead[][idx].
327
	 *
328
	 * @param	array	$ar_thead
329
	 * @param	array	$ar_data
330
	 * @return	string
331
	 */
332
	public function GenRstTable ($ar_thead, $ar_data) {
333
		// Split between column
334
		$s_split = str_repeat(' ', 4);
335
		//$s_split = "\t";
336
337
		// Table split line, total 3, 2 on/under th, 1 in table bottom line.
338
		$s_line = '';
339
		foreach ($ar_thead as $col) {
340
			$s_line .= str_repeat('=', $col['width']) . $s_split;
341
		}
342
		$s_line .= "\n";
343
344
		// Begin, th first
345
		$s_table = $s_line;
346 View Code Duplication
		foreach ($ar_thead as $col) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
347
			// Make them length = width
348
			$s = mb_strimwidth(ArrayRead($col, 'title', '')
0 ignored issues
show
Deprecated Code introduced by
The function ArrayRead() has been deprecated with message: Use Fwlib\Util\ArrayUtil::getIdx(), getEdx()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
349
					. str_repeat(' ', $col['width'])
350
				, 0, $col['width'], '', 'utf-8');
351
			$s_table .= $s . $s_split;
352
		}
353
		$s_table .= "\n" . $s_line;
354
355
		// Then, td
356
		foreach ($ar_data as $row) {
357 View Code Duplication
			foreach ($ar_thead as $col) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
358
				// Trim/fill length
359
				$s = mb_strimwidth(ArrayRead($row, $col['idx'], '')
0 ignored issues
show
Deprecated Code introduced by
The function ArrayRead() has been deprecated with message: Use Fwlib\Util\ArrayUtil::getIdx(), getEdx()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
360
						. str_repeat(' ', $col['width'])
361
					, 0, $col['width'], '', 'utf-8');
362
				$s_table .= $s . $s_split;
363
			}
364
			$s_table .= "\n";
365
		}
366
367
		// Table bottom
368
		$s_table .= $s_line;
369
370
		return $s_table;
371
	} // end of func GenRstTable
372
373
374
	/**
375
	 * Gen title by rst syntax
376
	 *
377
	 * @param	string	$s_title
378
	 * @return	string
379
	 */
380
	public function GenRstTitle ($s_title) {
381
		return str_repeat('=', 70) . "\n"
382
			. $s_title . "\n"
383
			. str_repeat('=', 70) . "\n\n";
384
	} // end of func GenRstTitle
385
386
387
	/**
388
	 * Get default path of docutils writer html4css1
389
	 *
390
	 * @return	string
391
	 */
392
	public function GetDocutilsCssPath () {
393
		$s_cmd = $this->GetPathRst2Html()
394
			. '--help |grep -A7 stylesheet-path=';
395
		exec($s_cmd, $ar_out);
396
		$s_out = implode('', $ar_out);
397
		$s_out = str_replace('                        ', '', $s_out);
398
399
		// Find the css path
400
		if (0 < preg_match('/Default: \"(\S+?)\"/i', $s_out, $ar)) {
401
			$s_out = $ar[1];
402
			$this->Log("Got docutils css path: $s_out", 1);
403
		}
404
		else {
405
			$s_out = '';
406
			$this->Log('Can\'t find docutils css path.', 4);
407
		}
408
409
		return $s_out;
410
	} // end of func GetDocutilsCssPath
411
412
413
	/**
414
	 * Detect and set path of docutils
415
	 *
416
	 * @param	$s_path		Manual additional path
417
	 * @return	string
418
	 */
419
	public function GetPathDocutils ($s_path) {
420
		// Possible path of docutils execute file for choose
421
		$ar_path = array(
422
			'/usr/bin/',
423
			'/usr/local/bin/',
424
			'/bin/',
425
		);
426
427
		if (!empty($s_path)) {
428
			// Add to array
429
			array_unshift($ar_path, $s_path);
430
		}
431
432
		// Find a usable path
433
		$b_found = false;
434
		while (!$b_found && !empty($ar_path)) {
435
			$this->sPathDocutils = $ar_path[0];
436 View Code Duplication
			if (is_executable($this->sPathDocutils . 'rst2html.py')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
437
				$b_found = true;
438
				$this->aCfg['cmd_.py'] = true;
439
				break;
440
			}
441
			// In some env like my (MT) Centos5, cmd hasn't .py extension
442 View Code Duplication
			if (is_executable($this->sPathDocutils . 'rst2html')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
443
				$b_found = true;
444
				$this->aCfg['cmd_.py'] = false;
445
				break;
446
			}
447
			array_shift($ar_path);
448
		}
449
		if ($b_found) {
450
			$this->Log('Got docutils execute file in '
451
				. $this->sPathDocutils, 1);
452
		}
453
		else {
454
			$this->sPathDocutils = '';
455
			$this->Log('Can\' find docutils execute file.', 5);
456
		}
457
458
		return $this->sPathDocutils;
459
	} // end of func GetPathDocutils
460
461
462
	/**
463
	 * Got path of rst2html.py cmd
464
	 *
465
	 * @return	string
466
	 */
467
	public function GetPathRst2Html () {
468
		if ($this->aCfg['cmd_.py'])
469
			$s = $this->sPathDocutils . "rst2html.py ";
470
		else
471
			$s = $this->sPathDocutils . "rst2html ";
472
		return $s;
473
	} // end of func GetPathRst2Html
474
475
476
	/**
477
	 * Init config vars, give default value.
478
	 *
479
	 * @return	this
480
	 */
481
	public function Init () {
482
		parent::Init();
483
484
		// Will set in GetPathDocutils()
485
		$this->aCfg['cmd_.py']	= true;
486
		// Use pipe to exec cmd instead of tmp file ?
487
		$this->aCfg['cmd_pipe']	= true;
488
489
		// Use script jquery ?
490
		$this->aCfg['js_jquery']	= false;
491
492
		// Tidy output html ?
493
		$this->aCfg['output_tidy'] = false;
494
495
		// Using 'Google AJAX Libraries API' now
496
		// http://code.google.com/apis/ajaxlibs/
497
		$this->aCfg['path_jquery']
498
			= 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js';
499
		//	= '/js/jquery.js';
500
501
		// Show opiton, default
502
		$this->aCfg['show_ads']		= false;
503
		$this->aCfg['show_counter']	= true;
504
505
		return $this;
506
	} // end of func InitConfig
507
508
509
	/**
510
	 * Modify html doctype declare
511
	 *
512
	 * @param	string	$s_html
513
	 * @return	string
514
	 */
515
	protected function ModifyHtmlDoctype ($s_html) {
516
		$s_html = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
517
			, "<!DOCTYPE html\n	PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n	\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
518
			, $s_html);
519
		return $s_html;
520
	} // end of func ModifyHtmlDoctype
521
522
523
	/**
524
	 * Modify html <style> tag, to met validator.w3.org
525
	 *
526
	 * @param	string	$s_html
527
	 * @return	string
528
	 */
529
	protected function ModifyHtmlTagStyle ($s_html) {
530
		$s_html = str_replace('</style>'
531
			, "-->\n</style>", $s_html);
532
		$s_html = str_replace('<style type="text/css">'
533
			, "<style type=\"text/css\" media=\"screen, print\">\n<!--"
534
			, $s_html);
535
		return $s_html;
536
	} // end of func ModifyHtmlTagStyle
537
538
539
	/**
540
	 * Tidy output html
541
	 *
542
	 * @param	&$s_html
543
	 * @return	string
544
	 */
545
	protected function Tidy (&$s_html) {
546
		return View::Tidy($s_html);
547
	} // end of func Tidy
548
549
550
	/**
551
	 * Convert reStructuredText content to html format
552
	 *
553
	 * Note: I had run benchmark to compare pipe and tmpfile,
554
	 * 		result is, they are almost same.
555
	 *
556
	 * @param	string	$s_rst
557
	 * @return	string
558
	 */
559
	public function ToHtml ($s_rst) {
560
		$s_cmd = $this->GetPathRst2Html()
561
				. $this->GenCmdOption();
562
		$s_cmd = escapeshellcmd($s_cmd);
563
564
		if ($this->aCfg['cmd_pipe']) {
565
			// Use pipe
566
			$desc = array(
567
				0 => array('pipe', 'r'),
568
				1 => array('pipe', 'w'),
569
			);
570
571
			$proc = proc_open($s_cmd, $desc, $pipes);
572
573
			if (!is_resource($proc))
574
				$this->Log('Pipe can\'t open !', 5);
575
			else
576
				$this->Log("Tohtml using pipe by cmd: $s_cmd", 1);
577
578
			$fp = $pipes[0];
579
			fwrite($fp, $s_rst);
580
			fflush($fp);
581
			fclose($fp);
582
583
			$s_out = '';
584
			while (!feof($pipes[1])) {
585
				$s_out .= fgets($pipes[1]);
586
			}
587
			fclose($pipes[1]);
588
589
			proc_close($proc);
590
		}
591 View Code Duplication
		else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
592
			// Use tmp file
593
			$f_tmp = tempnam(sys_get_temp_dir(), 'fwolflib.doc-restructuredtext.');
594
			file_put_contents($f_tmp, $s_rst);
595
596
			// Execute cmd, got result.
597
			$s_cmd .= " $f_tmp";
598
			$this->Log("ToHtml by cmd: $s_cmd", 1);
599
			exec($s_cmd, $ar_out);
600
601
			unlink($f_tmp);
602
			$s_out = implode("\n", $ar_out);
603
		}
604
605
		$this->sHtml = $s_out;
606
		return $s_out;
607
	} // end of func ToHtml
608
609
610
	/**
611
	 * Convert reStructuredText content to html, and adjust
612
	 *
613
	 * @param	string	$s_rst
614
	 * @return	string
615
	 */
616
	public function ToHtmlFull ($s_rst) {
617
		$s_out = $this->ToHtml($s_rst);
618
619
		// Fix html
620
		$s_out = $this->ModifyHtmlDoctype($s_out);
621
		$s_out = $this->ModifyHtmlTagStyle($s_out);
622
623
		// Need jQuery ?
624
		if ($this->aCfg['js_jquery'])
625
			$s_out = $this->AddJsJquery($s_out);
626
627
		// Add my footer
628
		$s_out = $this->AddFooter($s_out);
629
630
		// Tidy ?
631
		if ($this->aCfg['output_tidy'])
632
			$s_out = $this->Tidy($s_out);
633
634
		$this->sHtml = $s_out;
635
		return $s_out;
636
	} // end of func ToHtmlFull
637
638
639
	/**
640
	 * Convert reStructuredText to html, only html body part.
641
	 *
642
	 * Without <body> tag.
643
	 *
644
	 * @param	string	$s_rst
645
	 * @return	string
646
	 */
647
	public function ToHtmlSimple ($s_rst) {
648
		$s_out = $this->ToHtml($s_rst);
649
650
		// Trim html before <body>
651
		$i = strpos($s_out, '<body>');
652
		if (!(false === $i))
653
			$s_out = substr($s_out, $i + 6);
654
655
		// Trim html after <body>
656
		$i = strrpos($s_out, '</body>');
657
		if (!(false === $i))
658
			$s_out = substr($s_out, 0, $i );
659
660
		$this->sHtml = $s_out;
661
		return $s_out;
662
	} // end of func ToHtmlSimple
663
664
665
} // end of class DocReStructuredText
666
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
667