Completed
Push — v3.0 ( 23635d...e28df5 )
by Samir
23s
created
web_interface/astpp/system/libraries/User_agent.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class CI_User_agent {
30 30
 
31
-	var $agent		= NULL;
31
+	var $agent = NULL;
32 32
 
33
-	var $is_browser	= FALSE;
34
-	var $is_robot	= FALSE;
33
+	var $is_browser = FALSE;
34
+	var $is_robot = FALSE;
35 35
 	var $is_mobile	= FALSE;
36 36
 
37 37
 	var $languages	= array();
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	var $mobiles	= array();
43 43
 	var $robots		= array();
44 44
 
45
-	var $platform	= '';
45
+	var $platform = '';
46 46
 	var $browser	= '';
47 47
 	var $version	= '';
48 48
 	var $mobile		= '';
49
-	var $robot		= '';
49
+	var $robot = '';
50 50
 
51 51
 	/**
52 52
 	 * Constructor
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/pdf.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@  discard block
 block discarded – undo
11 11
   
12 12
   
13 13
     $this->page++;
14
-    if(!isset($this->pages[$this->page])) // solves the problem of overwriting a page if it already exists
14
+    if ( ! isset($this->pages[$this->page])) // solves the problem of overwriting a page if it already exists
15 15
         $this->pages[$this->page] = '';
16
-    $this->state  =2;
16
+    $this->state = 2;
17 17
     $this->x = $this->lMargin;
18 18
     $this->y = $this->tMargin;
19 19
     $this->FontFamily = '';
20 20
     // Check page size and orientation
21
-    if($orientation=='')
21
+    if ($orientation == '')
22 22
         $orientation = $this->DefOrientation;
23 23
     else
24 24
         $orientation = strtoupper($orientation[0]);
25
-    if($size=='')
25
+    if ($size == '')
26 26
         $size = $this->DefPageSize;
27 27
     else
28 28
         $size = $this->_getpagesize($size);
29
-    if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
29
+    if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1])
30 30
     {
31 31
         // New size or orientation
32
-        if($orientation=='P')
32
+        if ($orientation == 'P')
33 33
         {
34 34
             $this->w = $size[0];
35 35
             $this->h = $size[1];
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
             $this->w = $size[1];
40 40
             $this->h = $size[0];
41 41
         }
42
-        $this->wPt = $this->w*$this->k;
43
-        $this->hPt = $this->h*$this->k;
44
-        $this->PageBreakTrigger = $this->h-$this->bMargin;
42
+        $this->wPt = $this->w * $this->k;
43
+        $this->hPt = $this->h * $this->k;
44
+        $this->PageBreakTrigger = $this->h - $this->bMargin;
45 45
         $this->CurOrientation = $orientation;
46 46
         $this->CurPageSize = $size;
47 47
     }
48
-    if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
48
+    if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1])
49 49
         $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
50 50
 }
51 51
 
52 52
 function Footer() {
53 53
     // Check if Footer for this page already exists (do the same for Header())
54
-    if(!isset($this->footerset[$this->page])) {
54
+    if ( ! isset($this->footerset[$this->page])) {
55 55
         $this->SetY(-15);
56 56
         // Page number
57
-        $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
57
+        $this->Cell(0, 10, 'Page '.$this->PageNo().'/{nb}', 0, 0, 'C');
58 58
         // set footerset
59 59
         $this->footerset[$this->page] = true;
60 60
     }
61 61
 }
62 62
 
63
-function morepagestable($datas, $lineheight=8) {
63
+function morepagestable($datas, $lineheight = 8) {
64 64
     // some things to set and 'remember'
65 65
     $l = $this->lMargin;
66 66
     $startheight = $h = $this->GetY();
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 
69 69
     // calculate the whole width
70 70
     $fullwidth = 0;
71
-    foreach($this->tablewidths AS $width) {
71
+    foreach ($this->tablewidths AS $width) {
72 72
         $fullwidth += $width;
73 73
     }
74 74
 
75 75
     // Now let's start to write the table
76
-    foreach($datas AS $row => $data) {
76
+    foreach ($datas AS $row => $data) {
77 77
         $this->page = $currpage;
78 78
         // write the horizontal borders
79 79
 	 
80 80
         // write the content and remember the height of the highest col
81
-        foreach($data AS $col => $txt) {
81
+        foreach ($data AS $col => $txt) {
82 82
             $this->page = $currpage;
83
-            $this->SetXY($l,$h);
83
+            $this->SetXY($l, $h);
84 84
 
85
-	    if($col == 5)
86
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
85
+	    if ($col == 5)
86
+	      $this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, "R");
87 87
             else
88
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
88
+	      $this->MultiCell($this->tablewidths[$col], $lineheight, $txt);
89 89
             $l += $this->tablewidths[$col];
90 90
 
91
-            if(!isset($tmpheight[$row.'-'.$this->page]))
91
+            if ( ! isset($tmpheight[$row.'-'.$this->page]))
92 92
                 $tmpheight[$row.'-'.$this->page] = 0;
93
-            if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
93
+            if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
94 94
                 $tmpheight[$row.'-'.$this->page] = $this->GetY();
95 95
             }
96
-            if($this->page > $maxpage)
96
+            if ($this->page > $maxpage)
97 97
                 $maxpage = $this->page;
98 98
         }
99 99
 
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
     // draw the borders
108 108
     // we start adding a horizontal line on the last page
109 109
     $this->page = $maxpage;
110
-    $this->Line($l,$h,$fullwidth+$l,$h);
110
+    $this->Line($l, $h, $fullwidth + $l, $h);
111 111
     // now we start at the top of the document and walk down
112
-    for($i = $startpage; $i <= $maxpage; $i++) {
112
+    for ($i = $startpage; $i <= $maxpage; $i++) {
113 113
         $this->page = $i;
114 114
         $l = $this->lMargin;
115 115
         $t  = ($i == $startpage) ? $startheight : $this->tMargin;
116
-        $lh = ($i == $maxpage)   ? $h : $this->h-$this->bMargin;
117
-        $this->Line($l,$t,$l,$lh);
118
-        foreach($this->tablewidths AS $width) {
116
+        $lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin;
117
+        $this->Line($l, $t, $l, $lh);
118
+        foreach ($this->tablewidths AS $width) {
119 119
             $l += $width;
120
-            $this->Line($l,$t,$l,$lh);
120
+            $this->Line($l, $t, $l, $lh);
121 121
         }
122 122
     }
123 123
     // set it to the last page, if not it'll cause some problems
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 
128 128
 
129
-function table_total($datas, $lineheight=8) {
129
+function table_total($datas, $lineheight = 8) {
130 130
     // some things to set and 'remember'
131 131
     $l = $this->lMargin;
132 132
     $startheight = $h = $this->GetY();
@@ -134,37 +134,37 @@  discard block
 block discarded – undo
134 134
 
135 135
     // calculate the whole width
136 136
     $fullwidth = 0;
137
-    foreach($this->tablewidths AS $width) {
137
+    foreach ($this->tablewidths AS $width) {
138 138
         $fullwidth += $width;
139 139
     }
140 140
 
141 141
     // Now let's start to write the table
142
-    foreach($datas AS $row => $data) {
142
+    foreach ($datas AS $row => $data) {
143 143
         $this->page = $currpage;
144 144
         // write the horizontal borders
145
-	if($data != "")
146
-        $this->Line(100,$h,200,$h);
145
+	if ($data != "")
146
+        $this->Line(100, $h, 200, $h);
147 147
         // write the content and remember the height of the highest col
148
-        foreach($data AS $col => $txt) {
148
+        foreach ($data AS $col => $txt) {
149 149
             $this->page = $currpage;
150
-            $this->SetXY($l,$h);
150
+            $this->SetXY($l, $h);
151 151
             
152
-            if($col == 3)
152
+            if ($col == 3)
153 153
 	      $this->SetFont('Arial', 'B', 8);
154 154
 	    else
155 155
 	      $this->SetFont('Arial', '', 8);
156
-	    if($col == 5)
157
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
156
+	    if ($col == 5)
157
+	      $this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, "R");
158 158
             else
159
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
159
+	      $this->MultiCell($this->tablewidths[$col], $lineheight, $txt);
160 160
             $l += $this->tablewidths[$col];
161 161
 
162
-            if(!isset($tmpheight[$row.'-'.$this->page]))
162
+            if ( ! isset($tmpheight[$row.'-'.$this->page]))
163 163
                 $tmpheight[$row.'-'.$this->page] = 0;
164
-            if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
164
+            if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
165 165
                 $tmpheight[$row.'-'.$this->page] = $this->GetY();
166 166
             }
167
-            if($this->page > $maxpage)
167
+            if ($this->page > $maxpage)
168 168
                 $maxpage = $this->page;
169 169
         }
170 170
 
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
     // we start adding a horizontal line on the last page
180 180
     $this->page = $maxpage;
181 181
     
182
-    $this->Line(100,$h,200,$h);
182
+    $this->Line(100, $h, 200, $h);
183 183
 
184 184
     // now we start at the top of the document and walk down
185
-    for($i = $startpage; $i <= $maxpage; $i++) {
185
+    for ($i = $startpage; $i <= $maxpage; $i++) {
186 186
         $this->page = $i;
187 187
         $l = $this->lMargin;
188 188
         $t  = ($i == $startpage) ? $startheight : $this->tMargin;
189
-        $lh = ($i == $maxpage)   ? $h : $this->h-$this->bMargin;
189
+        $lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin;
190 190
 
191
-        foreach($this->tablewidths AS $width) {
191
+        foreach ($this->tablewidths AS $width) {
192 192
 	    $l += $width;
193
-	    if($width != '30')
193
+	    if ($width != '30')
194 194
 	    {
195
-	      $this->Line(100,$t,100,$lh);
196
-	      $this->Line($l,$t,$l,$lh);
195
+	      $this->Line(100, $t, 100, $lh);
196
+	      $this->Line($l, $t, $l, $lh);
197 197
 	    }
198 198
         }
199 199
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 }
203 203
 
204 204
 
205
-function export_pdf($datas, $lineheight=8) {
205
+function export_pdf($datas, $lineheight = 8) {
206 206
     // some things to set and 'remember'
207 207
     $l = $this->lMargin;
208 208
     $startheight = $h = $this->GetY();
@@ -210,32 +210,32 @@  discard block
 block discarded – undo
210 210
 
211 211
     // calculate the whole width
212 212
     $fullwidth = 0;
213
-    foreach($this->tablewidths AS $width) {
213
+    foreach ($this->tablewidths AS $width) {
214 214
         $fullwidth += $width;
215 215
     }
216 216
 
217 217
     // Now let's start to write the table
218
-    foreach($datas AS $row => $data) {
218
+    foreach ($datas AS $row => $data) {
219 219
         $this->page = $currpage;
220 220
         // write the horizontal borders
221
-	 $this->Line($l,$h,$fullwidth+$l,$h); 
221
+	 $this->Line($l, $h, $fullwidth + $l, $h); 
222 222
         // write the content and remember the height of the highest col
223
-        foreach($data AS $col => $txt) {
223
+        foreach ($data AS $col => $txt) {
224 224
             $this->page = $currpage;
225
-            $this->SetXY($l,$h);
225
+            $this->SetXY($l, $h);
226 226
 
227
-	    if($col == 5)
228
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
227
+	    if ($col == 5)
228
+	      $this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, "R");
229 229
             else
230
-	      $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
230
+	      $this->MultiCell($this->tablewidths[$col], $lineheight, $txt);
231 231
             $l += $this->tablewidths[$col];
232 232
 
233
-            if(!isset($tmpheight[$row.'-'.$this->page]))
233
+            if ( ! isset($tmpheight[$row.'-'.$this->page]))
234 234
                 $tmpheight[$row.'-'.$this->page] = 0;
235
-            if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
235
+            if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
236 236
                 $tmpheight[$row.'-'.$this->page] = $this->GetY();
237 237
             }
238
-            if($this->page > $maxpage)
238
+            if ($this->page > $maxpage)
239 239
                 $maxpage = $this->page;
240 240
         }
241 241
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
     // draw the borders
250 250
     // we start adding a horizontal line on the last page
251 251
     $this->page = $maxpage;
252
-    $this->Line($l,$h,$fullwidth+$l,$h);
252
+    $this->Line($l, $h, $fullwidth + $l, $h);
253 253
     // now we start at the top of the document and walk down
254
-    for($i = $startpage; $i <= $maxpage; $i++) {
254
+    for ($i = $startpage; $i <= $maxpage; $i++) {
255 255
         $this->page = $i;
256 256
         $l = $this->lMargin;
257 257
         $t  = ($i == $startpage) ? $startheight : $this->tMargin;
258
-        $lh = ($i == $maxpage)   ? $h : $this->h-$this->bMargin;
259
-        $this->Line($l,$t,$l,$lh);
260
-        foreach($this->tablewidths AS $width) {
258
+        $lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin;
259
+        $this->Line($l, $t, $l, $lh);
260
+        foreach ($this->tablewidths AS $width) {
261 261
             $l += $width;
262
-            $this->Line($l,$t,$l,$lh);
262
+            $this->Line($l, $t, $l, $lh);
263 263
         }
264 264
     }
265 265
     // set it to the last page, if not it'll cause some problems
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Fpdf.php 1 patch
Spacing   +502 added lines, -502 removed lines patch added patch discarded remove patch
@@ -7,68 +7,68 @@  discard block
 block discarded – undo
7 7
 * Author:  Olivier PLATHEY                                                     *
8 8
 *******************************************************************************/
9 9
 
10
-if(!class_exists('FPDF'))
10
+if ( ! class_exists('FPDF'))
11 11
 {
12
-define('FPDF_VERSION','1.7');
12
+define('FPDF_VERSION', '1.7');
13 13
 
14 14
 class FPDF
15 15
 {
16
-var $page;               // current page number
17
-var $n;                  // current object number
18
-var $offsets;            // array of object offsets
19
-var $buffer;             // buffer holding in-memory PDF
20
-var $pages;              // array containing pages
21
-var $state;              // current document state
22
-var $compress;           // compression flag
23
-var $k;                  // scale factor (number of points in user unit)
24
-var $DefOrientation;     // default orientation
25
-var $CurOrientation;     // current orientation
26
-var $StdPageSizes;       // standard page sizes
27
-var $DefPageSize;        // default page size
28
-var $CurPageSize;        // current page size
29
-var $PageSizes;          // used for pages with non default sizes or orientations
30
-var $wPt, $hPt;          // dimensions of current page in points
31
-var $w, $h;              // dimensions of current page in user unit
32
-var $lMargin;            // left margin
33
-var $tMargin;            // top margin
34
-var $rMargin;            // right margin
35
-var $bMargin;            // page break margin
36
-var $cMargin;            // cell margin
37
-var $x, $y;              // current position in user unit
38
-var $lasth;              // height of last printed cell
39
-var $LineWidth;          // line width in user unit
40
-var $fontpath;           // path containing fonts
41
-var $CoreFonts;          // array of core font names
42
-var $fonts;              // array of used fonts
43
-var $FontFiles;          // array of font files
44
-var $diffs;              // array of encoding differences
45
-var $FontFamily;         // current font family
46
-var $FontStyle;          // current font style
47
-var $underline;          // underlining flag
48
-var $CurrentFont;        // current font info
49
-var $FontSizePt;         // current font size in points
50
-var $FontSize;           // current font size in user unit
51
-var $DrawColor;          // commands for drawing color
52
-var $FillColor;          // commands for filling color
53
-var $TextColor;          // commands for text color
54
-var $ColorFlag;          // indicates whether fill and text colors are different
55
-var $ws;                 // word spacing
56
-var $images;             // array of used images
57
-var $PageLinks;          // array of links in pages
58
-var $links;              // array of internal links
59
-var $AutoPageBreak;      // automatic page breaking
60
-var $PageBreakTrigger;   // threshold used to trigger page breaks
61
-var $InHeader;           // flag set when processing header
62
-var $InFooter;           // flag set when processing footer
63
-var $ZoomMode;           // zoom display mode
64
-var $LayoutMode;         // layout display mode
65
-var $title;              // title
66
-var $subject;            // subject
67
-var $author;             // author
68
-var $keywords;           // keywords
69
-var $creator;            // creator
70
-var $AliasNbPages;       // alias for total number of pages
71
-var $PDFVersion;         // PDF version number
16
+var $page; // current page number
17
+var $n; // current object number
18
+var $offsets; // array of object offsets
19
+var $buffer; // buffer holding in-memory PDF
20
+var $pages; // array containing pages
21
+var $state; // current document state
22
+var $compress; // compression flag
23
+var $k; // scale factor (number of points in user unit)
24
+var $DefOrientation; // default orientation
25
+var $CurOrientation; // current orientation
26
+var $StdPageSizes; // standard page sizes
27
+var $DefPageSize; // default page size
28
+var $CurPageSize; // current page size
29
+var $PageSizes; // used for pages with non default sizes or orientations
30
+var $wPt, $hPt; // dimensions of current page in points
31
+var $w, $h; // dimensions of current page in user unit
32
+var $lMargin; // left margin
33
+var $tMargin; // top margin
34
+var $rMargin; // right margin
35
+var $bMargin; // page break margin
36
+var $cMargin; // cell margin
37
+var $x, $y; // current position in user unit
38
+var $lasth; // height of last printed cell
39
+var $LineWidth; // line width in user unit
40
+var $fontpath; // path containing fonts
41
+var $CoreFonts; // array of core font names
42
+var $fonts; // array of used fonts
43
+var $FontFiles; // array of font files
44
+var $diffs; // array of encoding differences
45
+var $FontFamily; // current font family
46
+var $FontStyle; // current font style
47
+var $underline; // underlining flag
48
+var $CurrentFont; // current font info
49
+var $FontSizePt; // current font size in points
50
+var $FontSize; // current font size in user unit
51
+var $DrawColor; // commands for drawing color
52
+var $FillColor; // commands for filling color
53
+var $TextColor; // commands for text color
54
+var $ColorFlag; // indicates whether fill and text colors are different
55
+var $ws; // word spacing
56
+var $images; // array of used images
57
+var $PageLinks; // array of links in pages
58
+var $links; // array of internal links
59
+var $AutoPageBreak; // automatic page breaking
60
+var $PageBreakTrigger; // threshold used to trigger page breaks
61
+var $InHeader; // flag set when processing header
62
+var $InFooter; // flag set when processing footer
63
+var $ZoomMode; // zoom display mode
64
+var $LayoutMode; // layout display mode
65
+var $title; // title
66
+var $subject; // subject
67
+var $author; // author
68
+var $keywords; // keywords
69
+var $creator; // creator
70
+var $AliasNbPages; // alias for total number of pages
71
+var $PDFVersion; // PDF version number
72 72
 
73 73
 /*******************************************************************************
74 74
 *                                                                              *
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 *******************************************************************************/
78 78
 function FPDF($props = array())
79 79
 {
80
-     if(count($props) == 3)
80
+     if (count($props) == 3)
81 81
      {
82
-         list($orientation,$unit,$format) = $props;
83
-         $this->initialize($orientation,$unit,$format);
82
+         list($orientation, $unit, $format) = $props;
83
+         $this->initialize($orientation, $unit, $format);
84 84
      }	
85 85
 }
86 86
 
87
-function initialize($orientation='P',$unit='mm',$size='A4')
87
+function initialize($orientation = 'P', $unit = 'mm', $size = 'A4')
88 88
 {
89 89
 	// Some checks
90 90
 	$this->_dochecks();
@@ -113,44 +113,44 @@  discard block
 block discarded – undo
113 113
 	$this->ColorFlag = false;
114 114
 	$this->ws = 0;
115 115
 	// Font path
116
-	if(defined('FPDF_FONTPATH'))
116
+	if (defined('FPDF_FONTPATH'))
117 117
 	{
118 118
 		$this->fontpath = FPDF_FONTPATH;
119
-		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
119
+		if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\')
120 120
 			$this->fontpath .= '/';
121 121
 	}
122
-	elseif(is_dir(dirname(__FILE__).'/font'))
122
+	elseif (is_dir(dirname(__FILE__).'/font'))
123 123
 		$this->fontpath = dirname(__FILE__).'/font/';
124 124
 	else
125 125
 		$this->fontpath = '';	
126 126
 	// Core fonts
127 127
 	$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
128 128
 	// Scale factor
129
-	if($unit=='pt')
129
+	if ($unit == 'pt')
130 130
 		$this->k = 1;
131
-	elseif($unit=='mm')
132
-		$this->k = 72/25.4;
133
-	elseif($unit=='cm')
134
-		$this->k = 72/2.54;
135
-	elseif($unit=='in')
131
+	elseif ($unit == 'mm')
132
+		$this->k = 72 / 25.4;
133
+	elseif ($unit == 'cm')
134
+		$this->k = 72 / 2.54;
135
+	elseif ($unit == 'in')
136 136
 		$this->k = 72;
137 137
 	else
138 138
 		$this->Error('Incorrect unit: '.$unit);
139 139
 	// Page sizes
140
-	$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
141
-		'letter'=>array(612,792), 'legal'=>array(612,1008));
140
+	$this->StdPageSizes = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28),
141
+		'letter'=>array(612, 792), 'legal'=>array(612, 1008));
142 142
 	$size = $this->_getpagesize($size);
143 143
 	$this->DefPageSize = $size;
144 144
 	$this->CurPageSize = $size;
145 145
 	// Page orientation
146 146
 	$orientation = strtolower($orientation);
147
-	if($orientation=='p' || $orientation=='portrait')
147
+	if ($orientation == 'p' || $orientation == 'portrait')
148 148
 	{
149 149
 		$this->DefOrientation = 'P';
150 150
 		$this->w = $size[0];
151 151
 		$this->h = $size[1];
152 152
 	}
153
-	elseif($orientation=='l' || $orientation=='landscape')
153
+	elseif ($orientation == 'l' || $orientation == 'landscape')
154 154
 	{
155 155
 		$this->DefOrientation = 'L';
156 156
 		$this->w = $size[1];
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	else
160 160
 		$this->Error('Incorrect orientation: '.$orientation);
161 161
 	$this->CurOrientation = $this->DefOrientation;
162
-	$this->wPt = $this->w*$this->k;
163
-	$this->hPt = $this->h*$this->k;
162
+	$this->wPt = $this->w * $this->k;
163
+	$this->hPt = $this->h * $this->k;
164 164
 	// Page margins (1 cm)
165
-	$margin = 28.35/$this->k;
166
-	$this->SetMargins($margin,$margin);
165
+	$margin = 28.35 / $this->k;
166
+	$this->SetMargins($margin, $margin);
167 167
 	// Interior cell margin (1 mm)
168
-	$this->cMargin = $margin/10;
168
+	$this->cMargin = $margin / 10;
169 169
 	// Line width (0.2 mm)
170
-	$this->LineWidth = .567/$this->k;
170
+	$this->LineWidth = .567 / $this->k;
171 171
 	// Automatic page break
172
-	$this->SetAutoPageBreak(true,2*$margin);
172
+	$this->SetAutoPageBreak(true, 2 * $margin);
173 173
 	// Default display mode
174 174
 	$this->SetDisplayMode('default');
175 175
 	// Enable compression
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
 	$this->PDFVersion = '1.3';
179 179
 }
180 180
 
181
-function SetMargins($left, $top, $right=null)
181
+function SetMargins($left, $top, $right = null)
182 182
 {
183 183
 	// Set left, top and right margins
184 184
 	$this->lMargin = $left;
185 185
 	$this->tMargin = $top;
186
-	if($right===null)
186
+	if ($right === null)
187 187
 		$right = $left;
188 188
 	$this->rMargin = $right;
189 189
 }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 {
193 193
 	// Set left margin
194 194
 	$this->lMargin = $margin;
195
-	if($this->page>0 && $this->x<$margin)
195
+	if ($this->page > 0 && $this->x < $margin)
196 196
 		$this->x = $margin;
197 197
 }
198 198
 
@@ -208,22 +208,22 @@  discard block
 block discarded – undo
208 208
 	$this->rMargin = $margin;
209 209
 }
210 210
 
211
-function SetAutoPageBreak($auto, $margin=0)
211
+function SetAutoPageBreak($auto, $margin = 0)
212 212
 {
213 213
 	// Set auto page break mode and triggering margin
214 214
 	$this->AutoPageBreak = $auto;
215 215
 	$this->bMargin = $margin;
216
-	$this->PageBreakTrigger = $this->h-$margin;
216
+	$this->PageBreakTrigger = $this->h - $margin;
217 217
 }
218 218
 
219
-function SetDisplayMode($zoom, $layout='default')
219
+function SetDisplayMode($zoom, $layout = 'default')
220 220
 {
221 221
 	// Set display mode in viewer
222
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
222
+	if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || ! is_string($zoom))
223 223
 		$this->ZoomMode = $zoom;
224 224
 	else
225 225
 		$this->Error('Incorrect zoom display mode: '.$zoom);
226
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
226
+	if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default')
227 227
 		$this->LayoutMode = $layout;
228 228
 	else
229 229
 		$this->Error('Incorrect layout display mode: '.$layout);
@@ -232,53 +232,53 @@  discard block
 block discarded – undo
232 232
 function SetCompression($compress)
233 233
 {
234 234
 	// Set page compression
235
-	if(function_exists('gzcompress'))
235
+	if (function_exists('gzcompress'))
236 236
 		$this->compress = $compress;
237 237
 	else
238 238
 		$this->compress = false;
239 239
 }
240 240
 
241
-function SetTitle($title, $isUTF8=false)
241
+function SetTitle($title, $isUTF8 = false)
242 242
 {
243 243
 	// Title of document
244
-	if($isUTF8)
244
+	if ($isUTF8)
245 245
 		$title = $this->_UTF8toUTF16($title);
246 246
 	$this->title = $title;
247 247
 }
248 248
 
249
-function SetSubject($subject, $isUTF8=false)
249
+function SetSubject($subject, $isUTF8 = false)
250 250
 {
251 251
 	// Subject of document
252
-	if($isUTF8)
252
+	if ($isUTF8)
253 253
 		$subject = $this->_UTF8toUTF16($subject);
254 254
 	$this->subject = $subject;
255 255
 }
256 256
 
257
-function SetAuthor($author, $isUTF8=false)
257
+function SetAuthor($author, $isUTF8 = false)
258 258
 {
259 259
 	// Author of document
260
-	if($isUTF8)
260
+	if ($isUTF8)
261 261
 		$author = $this->_UTF8toUTF16($author);
262 262
 	$this->author = $author;
263 263
 }
264 264
 
265
-function SetKeywords($keywords, $isUTF8=false)
265
+function SetKeywords($keywords, $isUTF8 = false)
266 266
 {
267 267
 	// Keywords of document
268
-	if($isUTF8)
268
+	if ($isUTF8)
269 269
 		$keywords = $this->_UTF8toUTF16($keywords);
270 270
 	$this->keywords = $keywords;
271 271
 }
272 272
 
273
-function SetCreator($creator, $isUTF8=false)
273
+function SetCreator($creator, $isUTF8 = false)
274 274
 {
275 275
 	// Creator of document
276
-	if($isUTF8)
276
+	if ($isUTF8)
277 277
 		$creator = $this->_UTF8toUTF16($creator);
278 278
 	$this->creator = $creator;
279 279
 }
280 280
 
281
-function AliasNbPages($alias='{nb}')
281
+function AliasNbPages($alias = '{nb}')
282 282
 {
283 283
 	// Define an alias for total number of pages
284 284
 	$this->AliasNbPages = $alias;
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 function Close()
300 300
 {
301 301
 	// Terminate document
302
-	if($this->state==3)
302
+	if ($this->state == 3)
303 303
 		return;
304
-	if($this->page==0)
304
+	if ($this->page == 0)
305 305
 		$this->AddPage();
306 306
 	// Page footer
307 307
 	$this->InFooter = true;
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 	$this->_enddoc();
314 314
 }
315 315
 
316
-function AddPage($orientation='', $size='')
316
+function AddPage($orientation = '', $size = '')
317 317
 {
318 318
 	// Start a new page
319
-	if($this->state==0)
319
+	if ($this->state == 0)
320 320
 		$this->Open();
321 321
 	$family = $this->FontFamily;
322 322
 	$style = $this->FontStyle.($this->underline ? 'U' : '');
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	$fc = $this->FillColor;
327 327
 	$tc = $this->TextColor;
328 328
 	$cf = $this->ColorFlag;
329
-	if($this->page>0)
329
+	if ($this->page > 0)
330 330
 	{
331 331
 		// Page footer
332 332
 		$this->InFooter = true;
@@ -336,21 +336,21 @@  discard block
 block discarded – undo
336 336
 		$this->_endpage();
337 337
 	}
338 338
 	// Start new page
339
-	$this->_beginpage($orientation,$size);
339
+	$this->_beginpage($orientation, $size);
340 340
 	// Set line cap style to square
341 341
 	$this->_out('2 J');
342 342
 	// Set line width
343 343
 	$this->LineWidth = $lw;
344
-	$this->_out(sprintf('%.2F w',$lw*$this->k));
344
+	$this->_out(sprintf('%.2F w', $lw * $this->k));
345 345
 	// Set font
346
-	if($family)
347
-		$this->SetFont($family,$style,$fontsize);
346
+	if ($family)
347
+		$this->SetFont($family, $style, $fontsize);
348 348
 	// Set colors
349 349
 	$this->DrawColor = $dc;
350
-	if($dc!='0 G')
350
+	if ($dc != '0 G')
351 351
 		$this->_out($dc);
352 352
 	$this->FillColor = $fc;
353
-	if($fc!='0 g')
353
+	if ($fc != '0 g')
354 354
 		$this->_out($fc);
355 355
 	$this->TextColor = $tc;
356 356
 	$this->ColorFlag = $cf;
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
 	$this->Header();
360 360
 	$this->InHeader = false;
361 361
 	// Restore line width
362
-	if($this->LineWidth!=$lw)
362
+	if ($this->LineWidth != $lw)
363 363
 	{
364 364
 		$this->LineWidth = $lw;
365
-		$this->_out(sprintf('%.2F w',$lw*$this->k));
365
+		$this->_out(sprintf('%.2F w', $lw * $this->k));
366 366
 	}
367 367
 	// Restore font
368
-	if($family)
369
-		$this->SetFont($family,$style,$fontsize);
368
+	if ($family)
369
+		$this->SetFont($family, $style, $fontsize);
370 370
 	// Restore colors
371
-	if($this->DrawColor!=$dc)
371
+	if ($this->DrawColor != $dc)
372 372
 	{
373 373
 		$this->DrawColor = $dc;
374 374
 		$this->_out($dc);
375 375
 	}
376
-	if($this->FillColor!=$fc)
376
+	if ($this->FillColor != $fc)
377 377
 	{
378 378
 		$this->FillColor = $fc;
379 379
 		$this->_out($fc);
@@ -398,37 +398,37 @@  discard block
 block discarded – undo
398 398
 	return $this->page;
399 399
 }
400 400
 
401
-function SetDrawColor($r, $g=null, $b=null)
401
+function SetDrawColor($r, $g = null, $b = null)
402 402
 {
403 403
 	// Set color for all stroking operations
404
-	if(($r==0 && $g==0 && $b==0) || $g===null)
405
-		$this->DrawColor = sprintf('%.3F G',$r/255);
404
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
405
+		$this->DrawColor = sprintf('%.3F G', $r / 255);
406 406
 	else
407
-		$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
408
-	if($this->page>0)
407
+		$this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
408
+	if ($this->page > 0)
409 409
 		$this->_out($this->DrawColor);
410 410
 }
411 411
 
412
-function SetFillColor($r, $g=null, $b=null)
412
+function SetFillColor($r, $g = null, $b = null)
413 413
 {
414 414
 	// Set color for all filling operations
415
-	if(($r==0 && $g==0 && $b==0) || $g===null)
416
-		$this->FillColor = sprintf('%.3F g',$r/255);
415
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
416
+		$this->FillColor = sprintf('%.3F g', $r / 255);
417 417
 	else
418
-		$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
419
-	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
420
-	if($this->page>0)
418
+		$this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
419
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
420
+	if ($this->page > 0)
421 421
 		$this->_out($this->FillColor);
422 422
 }
423 423
 
424
-function SetTextColor($r, $g=null, $b=null)
424
+function SetTextColor($r, $g = null, $b = null)
425 425
 {
426 426
 	// Set color for text
427
-	if(($r==0 && $g==0 && $b==0) || $g===null)
428
-		$this->TextColor = sprintf('%.3F g',$r/255);
427
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
428
+		$this->TextColor = sprintf('%.3F g', $r / 255);
429 429
 	else
430
-		$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
431
-	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
430
+		$this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
431
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
432 432
 }
433 433
 
434 434
 function GetStringWidth($s)
@@ -438,66 +438,66 @@  discard block
 block discarded – undo
438 438
 	$cw = &$this->CurrentFont['cw'];
439 439
 	$w = 0;
440 440
 	$l = strlen($s);
441
-	for($i=0;$i<$l;$i++)
441
+	for ($i = 0; $i < $l; $i++)
442 442
 		$w += $cw[$s[$i]];
443
-	return $w*$this->FontSize/1000;
443
+	return $w * $this->FontSize / 1000;
444 444
 }
445 445
 
446 446
 function SetLineWidth($width)
447 447
 {
448 448
 	// Set line width
449 449
 	$this->LineWidth = $width;
450
-	if($this->page>0)
451
-		$this->_out(sprintf('%.2F w',$width*$this->k));
450
+	if ($this->page > 0)
451
+		$this->_out(sprintf('%.2F w', $width * $this->k));
452 452
 }
453 453
 
454 454
 function Line($x1, $y1, $x2, $y2)
455 455
 {
456 456
 	// Draw a line
457
-	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
457
+	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k));
458 458
 }
459 459
 
460
-function Rect($x, $y, $w, $h, $style='')
460
+function Rect($x, $y, $w, $h, $style = '')
461 461
 {
462 462
 	// Draw a rectangle
463
-	if($style=='F')
463
+	if ($style == 'F')
464 464
 		$op = 'f';
465
-	elseif($style=='FD' || $style=='DF')
465
+	elseif ($style == 'FD' || $style == 'DF')
466 466
 		$op = 'B';
467 467
 	else
468 468
 		$op = 'S';
469
-	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
469
+	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op));
470 470
 }
471 471
 
472
-function AddFont($family, $style='', $file='')
472
+function AddFont($family, $style = '', $file = '')
473 473
 {
474 474
 	// Add a TrueType, OpenType or Type1 font
475 475
 	$family = strtolower($family);
476
-	if($file=='')
477
-		$file = str_replace(' ','',$family).strtolower($style).'.php';
476
+	if ($file == '')
477
+		$file = str_replace(' ', '', $family).strtolower($style).'.php';
478 478
 	$style = strtoupper($style);
479
-	if($style=='IB')
479
+	if ($style == 'IB')
480 480
 		$style = 'BI';
481 481
 	$fontkey = $family.$style;
482
-	if(isset($this->fonts[$fontkey]))
482
+	if (isset($this->fonts[$fontkey]))
483 483
 		return;
484 484
 	$info = $this->_loadfont($file);
485
-	$info['i'] = count($this->fonts)+1;
486
-	if(!empty($info['diff']))
485
+	$info['i'] = count($this->fonts) + 1;
486
+	if ( ! empty($info['diff']))
487 487
 	{
488 488
 		// Search existing encodings
489
-		$n = array_search($info['diff'],$this->diffs);
490
-		if(!$n)
489
+		$n = array_search($info['diff'], $this->diffs);
490
+		if ( ! $n)
491 491
 		{
492
-			$n = count($this->diffs)+1;
492
+			$n = count($this->diffs) + 1;
493 493
 			$this->diffs[$n] = $info['diff'];
494 494
 		}
495 495
 		$info['diffn'] = $n;
496 496
 	}
497
-	if(!empty($info['file']))
497
+	if ( ! empty($info['file']))
498 498
 	{
499 499
 		// Embedded font
500
-		if($info['type']=='TrueType')
500
+		if ($info['type'] == 'TrueType')
501 501
 			$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
502 502
 		else
503 503
 			$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
@@ -505,42 +505,42 @@  discard block
 block discarded – undo
505 505
 	$this->fonts[$fontkey] = $info;
506 506
 }
507 507
 
508
-function SetFont($family, $style='', $size=0)
508
+function SetFont($family, $style = '', $size = 0)
509 509
 {
510 510
 	// Select a font; size given in points
511
-	if($family=='')
511
+	if ($family == '')
512 512
 		$family = $this->FontFamily;
513 513
 	else
514 514
 		$family = strtolower($family);
515 515
 	$style = strtoupper($style);
516
-	if(strpos($style,'U')!==false)
516
+	if (strpos($style, 'U') !== false)
517 517
 	{
518 518
 		$this->underline = true;
519
-		$style = str_replace('U','',$style);
519
+		$style = str_replace('U', '', $style);
520 520
 	}
521 521
 	else
522 522
 		$this->underline = false;
523
-	if($style=='IB')
523
+	if ($style == 'IB')
524 524
 		$style = 'BI';
525
-	if($size==0)
525
+	if ($size == 0)
526 526
 		$size = $this->FontSizePt;
527 527
 	// Test if font is already selected
528
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
528
+	if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
529 529
 		return;
530 530
 	// Test if font is already loaded
531 531
 	$fontkey = $family.$style;
532
-	if(!isset($this->fonts[$fontkey]))
532
+	if ( ! isset($this->fonts[$fontkey]))
533 533
 	{
534 534
 		// Test if one of the core fonts
535
-		if($family=='arial')
535
+		if ($family == 'arial')
536 536
 			$family = 'helvetica';
537
-		if(in_array($family,$this->CoreFonts))
537
+		if (in_array($family, $this->CoreFonts))
538 538
 		{
539
-			if($family=='symbol' || $family=='zapfdingbats')
539
+			if ($family == 'symbol' || $family == 'zapfdingbats')
540 540
 				$style = '';
541 541
 			$fontkey = $family.$style;
542
-			if(!isset($this->fonts[$fontkey]))
543
-				$this->AddFont($family,$style);
542
+			if ( ! isset($this->fonts[$fontkey]))
543
+				$this->AddFont($family, $style);
544 544
 		}
545 545
 		else
546 546
 			$this->Error('Undefined font: '.$family.' '.$style);
@@ -549,37 +549,37 @@  discard block
 block discarded – undo
549 549
 	$this->FontFamily = $family;
550 550
 	$this->FontStyle = $style;
551 551
 	$this->FontSizePt = $size;
552
-	$this->FontSize = $size/$this->k;
552
+	$this->FontSize = $size / $this->k;
553 553
 	$this->CurrentFont = &$this->fonts[$fontkey];
554
-	if($this->page>0)
555
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
554
+	if ($this->page > 0)
555
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
556 556
 }
557 557
 
558 558
 function SetFontSize($size)
559 559
 {
560 560
 	// Set font size in points
561
-	if($this->FontSizePt==$size)
561
+	if ($this->FontSizePt == $size)
562 562
 		return;
563 563
 	$this->FontSizePt = $size;
564
-	$this->FontSize = $size/$this->k;
565
-	if($this->page>0)
566
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
564
+	$this->FontSize = $size / $this->k;
565
+	if ($this->page > 0)
566
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
567 567
 }
568 568
 
569 569
 function AddLink()
570 570
 {
571 571
 	// Create a new internal link
572
-	$n = count($this->links)+1;
572
+	$n = count($this->links) + 1;
573 573
 	$this->links[$n] = array(0, 0);
574 574
 	return $n;
575 575
 }
576 576
 
577
-function SetLink($link, $y=0, $page=-1)
577
+function SetLink($link, $y = 0, $page = -1)
578 578
 {
579 579
 	// Set destination of internal link
580
-	if($y==-1)
580
+	if ($y == -1)
581 581
 		$y = $this->y;
582
-	if($page==-1)
582
+	if ($page == -1)
583 583
 		$page = $this->page;
584 584
 	$this->links[$link] = array($page, $y);
585 585
 }
@@ -587,16 +587,16 @@  discard block
 block discarded – undo
587 587
 function Link($x, $y, $w, $h, $link)
588 588
 {
589 589
 	// Put a link on the page
590
-	$this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
590
+	$this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link);
591 591
 }
592 592
 
593 593
 function Text($x, $y, $txt)
594 594
 {
595 595
 	// Output a string
596
-	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
597
-	if($this->underline && $txt!='')
598
-		$s .= ' '.$this->_dounderline($x,$y,$txt);
599
-	if($this->ColorFlag)
596
+	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt));
597
+	if ($this->underline && $txt != '')
598
+		$s .= ' '.$this->_dounderline($x, $y, $txt);
599
+	if ($this->ColorFlag)
600 600
 		$s = 'q '.$this->TextColor.' '.$s.' Q';
601 601
 	$this->_out($s);
602 602
 }
@@ -607,100 +607,100 @@  discard block
 block discarded – undo
607 607
 	return $this->AutoPageBreak;
608 608
 }
609 609
 
610
-function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
610
+function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '')
611 611
 {
612 612
 	// Output a cell
613 613
 	$k = $this->k;
614
-	if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
614
+	if ($this->y + $h > $this->PageBreakTrigger && ! $this->InHeader && ! $this->InFooter && $this->AcceptPageBreak())
615 615
 	{
616 616
 		// Automatic page break
617 617
 		$x = $this->x;
618 618
 		$ws = $this->ws;
619
-		if($ws>0)
619
+		if ($ws > 0)
620 620
 		{
621 621
 			$this->ws = 0;
622 622
 			$this->_out('0 Tw');
623 623
 		}
624
-		$this->AddPage($this->CurOrientation,$this->CurPageSize);
624
+		$this->AddPage($this->CurOrientation, $this->CurPageSize);
625 625
 		$this->x = $x;
626
-		if($ws>0)
626
+		if ($ws > 0)
627 627
 		{
628 628
 			$this->ws = $ws;
629
-			$this->_out(sprintf('%.3F Tw',$ws*$k));
629
+			$this->_out(sprintf('%.3F Tw', $ws * $k));
630 630
 		}
631 631
 	}
632
-	if($w==0)
633
-		$w = $this->w-$this->rMargin-$this->x;
632
+	if ($w == 0)
633
+		$w = $this->w - $this->rMargin - $this->x;
634 634
 	$s = '';
635
-	if($fill || $border==1)
635
+	if ($fill || $border == 1)
636 636
 	{
637
-		if($fill)
638
-			$op = ($border==1) ? 'B' : 'f';
637
+		if ($fill)
638
+			$op = ($border == 1) ? 'B' : 'f';
639 639
 		else
640 640
 			$op = 'S';
641
-		$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
641
+		$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
642 642
 	}
643
-	if(is_string($border))
643
+	if (is_string($border))
644 644
 	{
645 645
 		$x = $this->x;
646 646
 		$y = $this->y;
647
-		if(strpos($border,'L')!==false)
648
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
649
-		if(strpos($border,'T')!==false)
650
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
651
-		if(strpos($border,'R')!==false)
652
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
653
-		if(strpos($border,'B')!==false)
654
-			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
647
+		if (strpos($border, 'L') !== false)
648
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
649
+		if (strpos($border, 'T') !== false)
650
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
651
+		if (strpos($border, 'R') !== false)
652
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
653
+		if (strpos($border, 'B') !== false)
654
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
655 655
 	}
656
-	if($txt!=='')
656
+	if ($txt !== '')
657 657
 	{
658
-		if($align=='R')
659
-			$dx = $w-$this->cMargin-$this->GetStringWidth($txt);
660
-		elseif($align=='C')
661
-			$dx = ($w-$this->GetStringWidth($txt))/2;
658
+		if ($align == 'R')
659
+			$dx = $w - $this->cMargin - $this->GetStringWidth($txt);
660
+		elseif ($align == 'C')
661
+			$dx = ($w - $this->GetStringWidth($txt)) / 2;
662 662
 		else
663 663
 			$dx = $this->cMargin;
664
-		if($this->ColorFlag)
664
+		if ($this->ColorFlag)
665 665
 			$s .= 'q '.$this->TextColor.' ';
666
-		$txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
667
-		$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
668
-		if($this->underline)
669
-			$s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
670
-		if($this->ColorFlag)
666
+		$txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
667
+		$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2);
668
+		if ($this->underline)
669
+			$s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
670
+		if ($this->ColorFlag)
671 671
 			$s .= ' Q';
672
-		if($link)
673
-			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
672
+		if ($link)
673
+			$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
674 674
 	}
675
-	if($s)
675
+	if ($s)
676 676
 		$this->_out($s);
677 677
 	$this->lasth = $h;
678
-	if($ln>0)
678
+	if ($ln > 0)
679 679
 	{
680 680
 		// Go to next line
681 681
 		$this->y += $h;
682
-		if($ln==1)
682
+		if ($ln == 1)
683 683
 			$this->x = $this->lMargin;
684 684
 	}
685 685
 	else
686 686
 		$this->x += $w;
687 687
 }
688 688
 
689
-function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
689
+function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
690 690
 {
691 691
 	// Output text with automatic or explicit line breaks
692 692
 	$cw = &$this->CurrentFont['cw'];
693
-	if($w==0)
694
-		$w = $this->w-$this->rMargin-$this->x;
695
-	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
696
-	$s = str_replace("\r",'',$txt);
693
+	if ($w == 0)
694
+		$w = $this->w - $this->rMargin - $this->x;
695
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
696
+	$s = str_replace("\r", '', $txt);
697 697
 	$nb = strlen($s);
698
-	if($nb>0 && $s[$nb-1]=="\n")
698
+	if ($nb > 0 && $s[$nb - 1] == "\n")
699 699
 		$nb--;
700 700
 	$b = 0;
701
-	if($border)
701
+	if ($border)
702 702
 	{
703
-		if($border==1)
703
+		if ($border == 1)
704 704
 		{
705 705
 			$border = 'LTRB';
706 706
 			$b = 'LRT';
@@ -709,11 +709,11 @@  discard block
 block discarded – undo
709 709
 		else
710 710
 		{
711 711
 			$b2 = '';
712
-			if(strpos($border,'L')!==false)
712
+			if (strpos($border, 'L') !== false)
713 713
 				$b2 .= 'L';
714
-			if(strpos($border,'R')!==false)
714
+			if (strpos($border, 'R') !== false)
715 715
 				$b2 .= 'R';
716
-			$b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
716
+			$b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2;
717 717
 		}
718 718
 	}
719 719
 	$sep = -1;
@@ -722,153 +722,153 @@  discard block
 block discarded – undo
722 722
 	$l = 0;
723 723
 	$ns = 0;
724 724
 	$nl = 1;
725
-	while($i<$nb)
725
+	while ($i < $nb)
726 726
 	{
727 727
 		// Get next character
728 728
 		$c = $s[$i];
729
-		if($c=="\n")
729
+		if ($c == "\n")
730 730
 		{
731 731
 			// Explicit line break
732
-			if($this->ws>0)
732
+			if ($this->ws > 0)
733 733
 			{
734 734
 				$this->ws = 0;
735 735
 				$this->_out('0 Tw');
736 736
 			}
737
-			$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
737
+			$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
738 738
 			$i++;
739 739
 			$sep = -1;
740 740
 			$j = $i;
741 741
 			$l = 0;
742 742
 			$ns = 0;
743 743
 			$nl++;
744
-			if($border && $nl==2)
744
+			if ($border && $nl == 2)
745 745
 				$b = $b2;
746 746
 			continue;
747 747
 		}
748
-		if($c==' ')
748
+		if ($c == ' ')
749 749
 		{
750 750
 			$sep = $i;
751 751
 			$ls = $l;
752 752
 			$ns++;
753 753
 		}
754 754
 		$l += $cw[$c];
755
-		if($l>$wmax)
755
+		if ($l > $wmax)
756 756
 		{
757 757
 			// Automatic line break
758
-			if($sep==-1)
758
+			if ($sep == -1)
759 759
 			{
760
-				if($i==$j)
760
+				if ($i == $j)
761 761
 					$i++;
762
-				if($this->ws>0)
762
+				if ($this->ws > 0)
763 763
 				{
764 764
 					$this->ws = 0;
765 765
 					$this->_out('0 Tw');
766 766
 				}
767
-				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
767
+				$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
768 768
 			}
769 769
 			else
770 770
 			{
771
-				if($align=='J')
771
+				if ($align == 'J')
772 772
 				{
773
-					$this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
774
-					$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
773
+					$this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0;
774
+					$this->_out(sprintf('%.3F Tw', $this->ws * $this->k));
775 775
 				}
776
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
777
-				$i = $sep+1;
776
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
777
+				$i = $sep + 1;
778 778
 			}
779 779
 			$sep = -1;
780 780
 			$j = $i;
781 781
 			$l = 0;
782 782
 			$ns = 0;
783 783
 			$nl++;
784
-			if($border && $nl==2)
784
+			if ($border && $nl == 2)
785 785
 				$b = $b2;
786 786
 		}
787 787
 		else
788 788
 			$i++;
789 789
 	}
790 790
 	// Last chunk
791
-	if($this->ws>0)
791
+	if ($this->ws > 0)
792 792
 	{
793 793
 		$this->ws = 0;
794 794
 		$this->_out('0 Tw');
795 795
 	}
796
-	if($border && strpos($border,'B')!==false)
796
+	if ($border && strpos($border, 'B') !== false)
797 797
 		$b .= 'B';
798
-	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
798
+	$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
799 799
 	$this->x = $this->lMargin;
800 800
 }
801 801
 
802
-function Write($h, $txt, $link='')
802
+function Write($h, $txt, $link = '')
803 803
 {
804 804
 	// Output text in flowing mode
805 805
 	$cw = &$this->CurrentFont['cw'];
806
-	$w = $this->w-$this->rMargin-$this->x;
807
-	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
808
-	$s = str_replace("\r",'',$txt);
806
+	$w = $this->w - $this->rMargin - $this->x;
807
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
808
+	$s = str_replace("\r", '', $txt);
809 809
 	$nb = strlen($s);
810 810
 	$sep = -1;
811 811
 	$i = 0;
812 812
 	$j = 0;
813 813
 	$l = 0;
814 814
 	$nl = 1;
815
-	while($i<$nb)
815
+	while ($i < $nb)
816 816
 	{
817 817
 		// Get next character
818 818
 		$c = $s[$i];
819
-		if($c=="\n")
819
+		if ($c == "\n")
820 820
 		{
821 821
 			// Explicit line break
822
-			$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
822
+			$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
823 823
 			$i++;
824 824
 			$sep = -1;
825 825
 			$j = $i;
826 826
 			$l = 0;
827
-			if($nl==1)
827
+			if ($nl == 1)
828 828
 			{
829 829
 				$this->x = $this->lMargin;
830
-				$w = $this->w-$this->rMargin-$this->x;
831
-				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
830
+				$w = $this->w - $this->rMargin - $this->x;
831
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
832 832
 			}
833 833
 			$nl++;
834 834
 			continue;
835 835
 		}
836
-		if($c==' ')
836
+		if ($c == ' ')
837 837
 			$sep = $i;
838 838
 		$l += $cw[$c];
839
-		if($l>$wmax)
839
+		if ($l > $wmax)
840 840
 		{
841 841
 			// Automatic line break
842
-			if($sep==-1)
842
+			if ($sep == -1)
843 843
 			{
844
-				if($this->x>$this->lMargin)
844
+				if ($this->x > $this->lMargin)
845 845
 				{
846 846
 					// Move to next line
847 847
 					$this->x = $this->lMargin;
848 848
 					$this->y += $h;
849
-					$w = $this->w-$this->rMargin-$this->x;
850
-					$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
849
+					$w = $this->w - $this->rMargin - $this->x;
850
+					$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
851 851
 					$i++;
852 852
 					$nl++;
853 853
 					continue;
854 854
 				}
855
-				if($i==$j)
855
+				if ($i == $j)
856 856
 					$i++;
857
-				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
857
+				$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
858 858
 			}
859 859
 			else
860 860
 			{
861
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
862
-				$i = $sep+1;
861
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
862
+				$i = $sep + 1;
863 863
 			}
864 864
 			$sep = -1;
865 865
 			$j = $i;
866 866
 			$l = 0;
867
-			if($nl==1)
867
+			if ($nl == 1)
868 868
 			{
869 869
 				$this->x = $this->lMargin;
870
-				$w = $this->w-$this->rMargin-$this->x;
871
-				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
870
+				$w = $this->w - $this->rMargin - $this->x;
871
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
872 872
 			}
873 873
 			$nl++;
874 874
 		}
@@ -876,81 +876,81 @@  discard block
 block discarded – undo
876 876
 			$i++;
877 877
 	}
878 878
 	// Last chunk
879
-	if($i!=$j)
880
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
879
+	if ($i != $j)
880
+		$this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link);
881 881
 }
882 882
 
883
-function Ln($h=null)
883
+function Ln($h = null)
884 884
 {
885 885
 	// Line feed; default value is last cell height
886 886
 	$this->x = $this->lMargin;
887
-	if($h===null)
887
+	if ($h === null)
888 888
 		$this->y += $this->lasth;
889 889
 	else
890 890
 		$this->y += $h;
891 891
 }
892 892
 
893
-function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
893
+function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '')
894 894
 {
895 895
 	// Put an image on the page
896
-	if(!isset($this->images[$file]))
896
+	if ( ! isset($this->images[$file]))
897 897
 	{
898 898
 		// First use of this image, get info
899
-		if($type=='')
899
+		if ($type == '')
900 900
 		{
901
-			$pos = strrpos($file,'.');
902
-			if(!$pos)
901
+			$pos = strrpos($file, '.');
902
+			if ( ! $pos)
903 903
 				$this->Error('Image file has no extension and no type was specified: '.$file);
904
-			$type = substr($file,$pos+1);
904
+			$type = substr($file, $pos + 1);
905 905
 		}
906 906
 		$type = strtolower($type);
907
-		if($type=='jpeg')
907
+		if ($type == 'jpeg')
908 908
 			$type = 'jpg';
909 909
 		$mtd = '_parse'.$type;
910
-		if(!method_exists($this,$mtd))
910
+		if ( ! method_exists($this, $mtd))
911 911
 			$this->Error('Unsupported image type: '.$type);
912 912
 		$info = $this->$mtd($file);
913
-		$info['i'] = count($this->images)+1;
913
+		$info['i'] = count($this->images) + 1;
914 914
 		$this->images[$file] = $info;
915 915
 	}
916 916
 	else
917 917
 		$info = $this->images[$file];
918 918
 
919 919
 	// Automatic width and height calculation if needed
920
-	if($w==0 && $h==0)
920
+	if ($w == 0 && $h == 0)
921 921
 	{
922 922
 		// Put image at 96 dpi
923 923
 		$w = -96;
924 924
 		$h = -96;
925 925
 	}
926
-	if($w<0)
927
-		$w = -$info['w']*72/$w/$this->k;
928
-	if($h<0)
929
-		$h = -$info['h']*72/$h/$this->k;
930
-	if($w==0)
931
-		$w = $h*$info['w']/$info['h'];
932
-	if($h==0)
933
-		$h = $w*$info['h']/$info['w'];
926
+	if ($w < 0)
927
+		$w = -$info['w'] * 72 / $w / $this->k;
928
+	if ($h < 0)
929
+		$h = -$info['h'] * 72 / $h / $this->k;
930
+	if ($w == 0)
931
+		$w = $h * $info['w'] / $info['h'];
932
+	if ($h == 0)
933
+		$h = $w * $info['h'] / $info['w'];
934 934
 
935 935
 	// Flowing mode
936
-	if($y===null)
936
+	if ($y === null)
937 937
 	{
938
-		if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
938
+		if ($this->y + $h > $this->PageBreakTrigger && ! $this->InHeader && ! $this->InFooter && $this->AcceptPageBreak())
939 939
 		{
940 940
 			// Automatic page break
941 941
 			$x2 = $this->x;
942
-			$this->AddPage($this->CurOrientation,$this->CurPageSize);
942
+			$this->AddPage($this->CurOrientation, $this->CurPageSize);
943 943
 			$this->x = $x2;
944 944
 		}
945 945
 		$y = $this->y;
946 946
 		$this->y += $h;
947 947
 	}
948 948
 
949
-	if($x===null)
949
+	if ($x === null)
950 950
 		$x = $this->x;
951
-	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
952
-	if($link)
953
-		$this->Link($x,$y,$w,$h,$link);
951
+	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i']));
952
+	if ($link)
953
+		$this->Link($x, $y, $w, $h, $link);
954 954
 }
955 955
 
956 956
 function GetX()
@@ -962,10 +962,10 @@  discard block
 block discarded – undo
962 962
 function SetX($x)
963 963
 {
964 964
 	// Set x position
965
-	if($x>=0)
965
+	if ($x >= 0)
966 966
 		$this->x = $x;
967 967
 	else
968
-		$this->x = $this->w+$x;
968
+		$this->x = $this->w + $x;
969 969
 }
970 970
 
971 971
 function GetY()
@@ -978,10 +978,10 @@  discard block
 block discarded – undo
978 978
 {
979 979
 	// Set y position and reset x
980 980
 	$this->x = $this->lMargin;
981
-	if($y>=0)
981
+	if ($y >= 0)
982 982
 		$this->y = $y;
983 983
 	else
984
-		$this->y = $this->h+$y;
984
+		$this->y = $this->h + $y;
985 985
 }
986 986
 
987 987
 function SetXY($x, $y)
@@ -991,15 +991,15 @@  discard block
 block discarded – undo
991 991
 	$this->SetX($x);
992 992
 }
993 993
 
994
-function Output($name='', $dest='')
994
+function Output($name = '', $dest = '')
995 995
 {
996 996
 	// Output PDF to some destination
997
-	if($this->state<3)
997
+	if ($this->state < 3)
998 998
 		$this->Close();
999 999
 	$dest = strtoupper($dest);
1000
-	if($dest=='')
1000
+	if ($dest == '')
1001 1001
 	{
1002
-		if($name=='')
1002
+		if ($name == '')
1003 1003
 		{
1004 1004
 			$name = 'doc.pdf';
1005 1005
 			$dest = 'I';
@@ -1007,12 +1007,12 @@  discard block
 block discarded – undo
1007 1007
 		else
1008 1008
 			$dest = 'F';
1009 1009
 	}
1010
-	switch($dest)
1010
+	switch ($dest)
1011 1011
 	{
1012 1012
 		case 'I':
1013 1013
 			// Send to standard output
1014 1014
 			$this->_checkoutput();
1015
-			if(PHP_SAPI!='cli')
1015
+			if (PHP_SAPI != 'cli')
1016 1016
 			{
1017 1017
 				// We send to a browser
1018 1018
 				header('Content-Type: application/pdf');
@@ -1034,10 +1034,10 @@  discard block
 block discarded – undo
1034 1034
 			break;
1035 1035
 		case 'F':
1036 1036
 			// Save to local file
1037
-			$f = fopen($name,'wb');
1038
-			if(!$f)
1037
+			$f = fopen($name, 'wb');
1038
+			if ( ! $f)
1039 1039
 				$this->Error('Unable to create output file: '.$name);
1040
-			fwrite($f,$this->buffer,strlen($this->buffer));
1040
+			fwrite($f, $this->buffer, strlen($this->buffer));
1041 1041
 			fclose($f);
1042 1042
 			break;
1043 1043
 		case 'S':
@@ -1057,27 +1057,27 @@  discard block
 block discarded – undo
1057 1057
 function _dochecks()
1058 1058
 {
1059 1059
 	// Check availability of %F
1060
-	if(sprintf('%.1F',1.0)!='1.0')
1060
+	if (sprintf('%.1F', 1.0) != '1.0')
1061 1061
 		$this->Error('This version of PHP is not supported');
1062 1062
 	// Check mbstring overloading
1063
-	if(ini_get('mbstring.func_overload') & 2)
1063
+	if (ini_get('mbstring.func_overload') & 2)
1064 1064
 		$this->Error('mbstring overloading must be disabled');
1065 1065
 	// Ensure runtime magic quotes are disabled
1066
-	if(get_magic_quotes_runtime())
1066
+	if (get_magic_quotes_runtime())
1067 1067
 		@set_magic_quotes_runtime(0);
1068 1068
 }
1069 1069
 
1070 1070
 function _checkoutput()
1071 1071
 {
1072
-	if(PHP_SAPI!='cli')
1072
+	if (PHP_SAPI != 'cli')
1073 1073
 	{
1074
-		if(headers_sent($file,$line))
1074
+		if (headers_sent($file, $line))
1075 1075
 			$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1076 1076
 	}
1077
-	if(ob_get_length())
1077
+	if (ob_get_length())
1078 1078
 	{
1079 1079
 		// The output buffer is not empty
1080
-		if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents()))
1080
+		if (preg_match('/^(\xEF\xBB\xBF)?\s*$/', ob_get_contents()))
1081 1081
 		{
1082 1082
 			// It contains only a UTF-8 BOM and/or whitespace, let's clean it
1083 1083
 			ob_clean();
@@ -1089,17 +1089,17 @@  discard block
 block discarded – undo
1089 1089
 
1090 1090
 function _getpagesize($size)
1091 1091
 {
1092
-	if(is_string($size))
1092
+	if (is_string($size))
1093 1093
 	{
1094 1094
 		$size = strtolower($size);
1095
-		if(!isset($this->StdPageSizes[$size]))
1095
+		if ( ! isset($this->StdPageSizes[$size]))
1096 1096
 			$this->Error('Unknown page size: '.$size);
1097 1097
 		$a = $this->StdPageSizes[$size];
1098
-		return array($a[0]/$this->k, $a[1]/$this->k);
1098
+		return array($a[0] / $this->k, $a[1] / $this->k);
1099 1099
 	}
1100 1100
 	else
1101 1101
 	{
1102
-		if($size[0]>$size[1])
1102
+		if ($size[0] > $size[1])
1103 1103
 			return array($size[1], $size[0]);
1104 1104
 		else
1105 1105
 			return $size;
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
 	$this->y = $this->tMargin;
1116 1116
 	$this->FontFamily = '';
1117 1117
 	// Check page size and orientation
1118
-	if($orientation=='')
1118
+	if ($orientation == '')
1119 1119
 		$orientation = $this->DefOrientation;
1120 1120
 	else
1121 1121
 		$orientation = strtoupper($orientation[0]);
1122
-	if($size=='')
1122
+	if ($size == '')
1123 1123
 		$size = $this->DefPageSize;
1124 1124
 	else
1125 1125
 		$size = $this->_getpagesize($size);
1126
-	if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
1126
+	if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1])
1127 1127
 	{
1128 1128
 		// New size or orientation
1129
-		if($orientation=='P')
1129
+		if ($orientation == 'P')
1130 1130
 		{
1131 1131
 			$this->w = $size[0];
1132 1132
 			$this->h = $size[1];
@@ -1136,13 +1136,13 @@  discard block
 block discarded – undo
1136 1136
 			$this->w = $size[1];
1137 1137
 			$this->h = $size[0];
1138 1138
 		}
1139
-		$this->wPt = $this->w*$this->k;
1140
-		$this->hPt = $this->h*$this->k;
1141
-		$this->PageBreakTrigger = $this->h-$this->bMargin;
1139
+		$this->wPt = $this->w * $this->k;
1140
+		$this->hPt = $this->h * $this->k;
1141
+		$this->PageBreakTrigger = $this->h - $this->bMargin;
1142 1142
 		$this->CurOrientation = $orientation;
1143 1143
 		$this->CurPageSize = $size;
1144 1144
 	}
1145
-	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
1145
+	if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1])
1146 1146
 		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1147 1147
 }
1148 1148
 
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 	// Load a font definition file from the font directory
1157 1157
 	include($this->fontpath.$font);
1158 1158
 	$a = get_defined_vars();
1159
-	if(!isset($a['name']))
1159
+	if ( ! isset($a['name']))
1160 1160
 		$this->Error('Could not include font definition file');
1161 1161
 	return $a;
1162 1162
 }
@@ -1164,10 +1164,10 @@  discard block
 block discarded – undo
1164 1164
 function _escape($s)
1165 1165
 {
1166 1166
 	// Escape special characters in strings
1167
-	$s = str_replace('\\','\\\\',$s);
1168
-	$s = str_replace('(','\\(',$s);
1169
-	$s = str_replace(')','\\)',$s);
1170
-	$s = str_replace("\r",'\\r',$s);
1167
+	$s = str_replace('\\', '\\\\', $s);
1168
+	$s = str_replace('(', '\\(', $s);
1169
+	$s = str_replace(')', '\\)', $s);
1170
+	$s = str_replace("\r", '\\r', $s);
1171 1171
 	return $s;
1172 1172
 }
1173 1173
 
@@ -1183,23 +1183,23 @@  discard block
 block discarded – undo
1183 1183
 	$res = "\xFE\xFF";
1184 1184
 	$nb = strlen($s);
1185 1185
 	$i = 0;
1186
-	while($i<$nb)
1186
+	while ($i < $nb)
1187 1187
 	{
1188 1188
 		$c1 = ord($s[$i++]);
1189
-		if($c1>=224)
1189
+		if ($c1 >= 224)
1190 1190
 		{
1191 1191
 			// 3-byte character
1192 1192
 			$c2 = ord($s[$i++]);
1193 1193
 			$c3 = ord($s[$i++]);
1194
-			$res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1195
-			$res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1194
+			$res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2));
1195
+			$res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F));
1196 1196
 		}
1197
-		elseif($c1>=192)
1197
+		elseif ($c1 >= 192)
1198 1198
 		{
1199 1199
 			// 2-byte character
1200 1200
 			$c2 = ord($s[$i++]);
1201
-			$res .= chr(($c1 & 0x1C)>>2);
1202
-			$res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1201
+			$res .= chr(($c1 & 0x1C) >> 2);
1202
+			$res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F));
1203 1203
 		}
1204 1204
 		else
1205 1205
 		{
@@ -1215,21 +1215,21 @@  discard block
 block discarded – undo
1215 1215
 	// Underline text
1216 1216
 	$up = $this->CurrentFont['up'];
1217 1217
 	$ut = $this->CurrentFont['ut'];
1218
-	$w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
1219
-	return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
1218
+	$w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' ');
1219
+	return sprintf('%.2F %.2F %.2F %.2F re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt);
1220 1220
 }
1221 1221
 
1222 1222
 function _parsejpg($file)
1223 1223
 {
1224 1224
 	// Extract info from a JPEG file
1225 1225
 	$a = getimagesize($file);
1226
-	if(!$a)
1226
+	if ( ! $a)
1227 1227
 		$this->Error('Missing or incorrect image file: '.$file);
1228
-	if($a[2]!=2)
1228
+	if ($a[2] != 2)
1229 1229
 		$this->Error('Not a JPEG file: '.$file);
1230
-	if(!isset($a['channels']) || $a['channels']==3)
1230
+	if ( ! isset($a['channels']) || $a['channels'] == 3)
1231 1231
 		$colspace = 'DeviceRGB';
1232
-	elseif($a['channels']==4)
1232
+	elseif ($a['channels'] == 4)
1233 1233
 		$colspace = 'DeviceCMYK';
1234 1234
 	else
1235 1235
 		$colspace = 'DeviceGray';
@@ -1241,10 +1241,10 @@  discard block
 block discarded – undo
1241 1241
 function _parsepng($file)
1242 1242
 {
1243 1243
 	// Extract info from a PNG file
1244
-	$f = fopen($file,'rb');
1245
-	if(!$f)
1244
+	$f = fopen($file, 'rb');
1245
+	if ( ! $f)
1246 1246
 		$this->Error('Can\'t open image file: '.$file);
1247
-	$info = $this->_parsepngstream($f,$file);
1247
+	$info = $this->_parsepngstream($f, $file);
1248 1248
 	fclose($f);
1249 1249
 	return $info;
1250 1250
 }
@@ -1252,35 +1252,35 @@  discard block
 block discarded – undo
1252 1252
 function _parsepngstream($f, $file)
1253 1253
 {
1254 1254
 	// Check signature
1255
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1255
+	if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1256 1256
 		$this->Error('Not a PNG file: '.$file);
1257 1257
 
1258 1258
 	// Read header chunk
1259
-	$this->_readstream($f,4);
1260
-	if($this->_readstream($f,4)!='IHDR')
1259
+	$this->_readstream($f, 4);
1260
+	if ($this->_readstream($f, 4) != 'IHDR')
1261 1261
 		$this->Error('Incorrect PNG file: '.$file);
1262 1262
 	$w = $this->_readint($f);
1263 1263
 	$h = $this->_readint($f);
1264
-	$bpc = ord($this->_readstream($f,1));
1265
-	if($bpc>8)
1264
+	$bpc = ord($this->_readstream($f, 1));
1265
+	if ($bpc > 8)
1266 1266
 		$this->Error('16-bit depth not supported: '.$file);
1267
-	$ct = ord($this->_readstream($f,1));
1268
-	if($ct==0 || $ct==4)
1267
+	$ct = ord($this->_readstream($f, 1));
1268
+	if ($ct == 0 || $ct == 4)
1269 1269
 		$colspace = 'DeviceGray';
1270
-	elseif($ct==2 || $ct==6)
1270
+	elseif ($ct == 2 || $ct == 6)
1271 1271
 		$colspace = 'DeviceRGB';
1272
-	elseif($ct==3)
1272
+	elseif ($ct == 3)
1273 1273
 		$colspace = 'Indexed';
1274 1274
 	else
1275 1275
 		$this->Error('Unknown color type: '.$file);
1276
-	if(ord($this->_readstream($f,1))!=0)
1276
+	if (ord($this->_readstream($f, 1)) != 0)
1277 1277
 		$this->Error('Unknown compression method: '.$file);
1278
-	if(ord($this->_readstream($f,1))!=0)
1278
+	if (ord($this->_readstream($f, 1)) != 0)
1279 1279
 		$this->Error('Unknown filter method: '.$file);
1280
-	if(ord($this->_readstream($f,1))!=0)
1280
+	if (ord($this->_readstream($f, 1)) != 0)
1281 1281
 		$this->Error('Interlacing not supported: '.$file);
1282
-	$this->_readstream($f,4);
1283
-	$dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1282
+	$this->_readstream($f, 4);
1283
+	$dp = '/Predictor 15 /Colors '.($colspace == 'DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1284 1284
 
1285 1285
 	// Scan chunks looking for palette, transparency and image data
1286 1286
 	$pal = '';
@@ -1289,85 +1289,85 @@  discard block
 block discarded – undo
1289 1289
 	do
1290 1290
 	{
1291 1291
 		$n = $this->_readint($f);
1292
-		$type = $this->_readstream($f,4);
1293
-		if($type=='PLTE')
1292
+		$type = $this->_readstream($f, 4);
1293
+		if ($type == 'PLTE')
1294 1294
 		{
1295 1295
 			// Read palette
1296
-			$pal = $this->_readstream($f,$n);
1297
-			$this->_readstream($f,4);
1296
+			$pal = $this->_readstream($f, $n);
1297
+			$this->_readstream($f, 4);
1298 1298
 		}
1299
-		elseif($type=='tRNS')
1299
+		elseif ($type == 'tRNS')
1300 1300
 		{
1301 1301
 			// Read transparency info
1302
-			$t = $this->_readstream($f,$n);
1303
-			if($ct==0)
1304
-				$trns = array(ord(substr($t,1,1)));
1305
-			elseif($ct==2)
1306
-				$trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1302
+			$t = $this->_readstream($f, $n);
1303
+			if ($ct == 0)
1304
+				$trns = array(ord(substr($t, 1, 1)));
1305
+			elseif ($ct == 2)
1306
+				$trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1307 1307
 			else
1308 1308
 			{
1309
-				$pos = strpos($t,chr(0));
1310
-				if($pos!==false)
1309
+				$pos = strpos($t, chr(0));
1310
+				if ($pos !== false)
1311 1311
 					$trns = array($pos);
1312 1312
 			}
1313
-			$this->_readstream($f,4);
1313
+			$this->_readstream($f, 4);
1314 1314
 		}
1315
-		elseif($type=='IDAT')
1315
+		elseif ($type == 'IDAT')
1316 1316
 		{
1317 1317
 			// Read image data block
1318
-			$data .= $this->_readstream($f,$n);
1319
-			$this->_readstream($f,4);
1318
+			$data .= $this->_readstream($f, $n);
1319
+			$this->_readstream($f, 4);
1320 1320
 		}
1321
-		elseif($type=='IEND')
1321
+		elseif ($type == 'IEND')
1322 1322
 			break;
1323 1323
 		else
1324
-			$this->_readstream($f,$n+4);
1324
+			$this->_readstream($f, $n + 4);
1325 1325
 	}
1326
-	while($n);
1326
+	while ($n);
1327 1327
 
1328
-	if($colspace=='Indexed' && empty($pal))
1328
+	if ($colspace == 'Indexed' && empty($pal))
1329 1329
 		$this->Error('Missing palette in '.$file);
1330 1330
 	$info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
1331
-	if($ct>=4)
1331
+	if ($ct >= 4)
1332 1332
 	{
1333 1333
 		// Extract alpha channel
1334
-		if(!function_exists('gzuncompress'))
1334
+		if ( ! function_exists('gzuncompress'))
1335 1335
 			$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1336 1336
 		$data = gzuncompress($data);
1337 1337
 		$color = '';
1338 1338
 		$alpha = '';
1339
-		if($ct==4)
1339
+		if ($ct == 4)
1340 1340
 		{
1341 1341
 			// Gray image
1342
-			$len = 2*$w;
1343
-			for($i=0;$i<$h;$i++)
1342
+			$len = 2 * $w;
1343
+			for ($i = 0; $i < $h; $i++)
1344 1344
 			{
1345
-				$pos = (1+$len)*$i;
1345
+				$pos = (1 + $len) * $i;
1346 1346
 				$color .= $data[$pos];
1347 1347
 				$alpha .= $data[$pos];
1348
-				$line = substr($data,$pos+1,$len);
1349
-				$color .= preg_replace('/(.)./s','$1',$line);
1350
-				$alpha .= preg_replace('/.(.)/s','$1',$line);
1348
+				$line = substr($data, $pos + 1, $len);
1349
+				$color .= preg_replace('/(.)./s', '$1', $line);
1350
+				$alpha .= preg_replace('/.(.)/s', '$1', $line);
1351 1351
 			}
1352 1352
 		}
1353 1353
 		else
1354 1354
 		{
1355 1355
 			// RGB image
1356
-			$len = 4*$w;
1357
-			for($i=0;$i<$h;$i++)
1356
+			$len = 4 * $w;
1357
+			for ($i = 0; $i < $h; $i++)
1358 1358
 			{
1359
-				$pos = (1+$len)*$i;
1359
+				$pos = (1 + $len) * $i;
1360 1360
 				$color .= $data[$pos];
1361 1361
 				$alpha .= $data[$pos];
1362
-				$line = substr($data,$pos+1,$len);
1363
-				$color .= preg_replace('/(.{3})./s','$1',$line);
1364
-				$alpha .= preg_replace('/.{3}(.)/s','$1',$line);
1362
+				$line = substr($data, $pos + 1, $len);
1363
+				$color .= preg_replace('/(.{3})./s', '$1', $line);
1364
+				$alpha .= preg_replace('/.{3}(.)/s', '$1', $line);
1365 1365
 			}
1366 1366
 		}
1367 1367
 		unset($data);
1368 1368
 		$data = gzcompress($color);
1369 1369
 		$info['smask'] = gzcompress($alpha);
1370
-		if($this->PDFVersion<'1.4')
1370
+		if ($this->PDFVersion < '1.4')
1371 1371
 			$this->PDFVersion = '1.4';
1372 1372
 	}
1373 1373
 	$info['data'] = $data;
@@ -1378,15 +1378,15 @@  discard block
 block discarded – undo
1378 1378
 {
1379 1379
 	// Read n bytes from stream
1380 1380
 	$res = '';
1381
-	while($n>0 && !feof($f))
1381
+	while ($n > 0 && ! feof($f))
1382 1382
 	{
1383
-		$s = fread($f,$n);
1384
-		if($s===false)
1383
+		$s = fread($f, $n);
1384
+		if ($s === false)
1385 1385
 			$this->Error('Error while reading stream');
1386 1386
 		$n -= strlen($s);
1387 1387
 		$res .= $s;
1388 1388
 	}
1389
-	if($n>0)
1389
+	if ($n > 0)
1390 1390
 		$this->Error('Unexpected end of stream');
1391 1391
 	return $res;
1392 1392
 }
@@ -1394,41 +1394,41 @@  discard block
 block discarded – undo
1394 1394
 function _readint($f)
1395 1395
 {
1396 1396
 	// Read a 4-byte integer from stream
1397
-	$a = unpack('Ni',$this->_readstream($f,4));
1397
+	$a = unpack('Ni', $this->_readstream($f, 4));
1398 1398
 	return $a['i'];
1399 1399
 }
1400 1400
 
1401 1401
 function _parsegif($file)
1402 1402
 {
1403 1403
 	// Extract info from a GIF file (via PNG conversion)
1404
-	if(!function_exists('imagepng'))
1404
+	if ( ! function_exists('imagepng'))
1405 1405
 		$this->Error('GD extension is required for GIF support');
1406
-	if(!function_exists('imagecreatefromgif'))
1406
+	if ( ! function_exists('imagecreatefromgif'))
1407 1407
 		$this->Error('GD has no GIF read support');
1408 1408
 	$im = imagecreatefromgif($file);
1409
-	if(!$im)
1409
+	if ( ! $im)
1410 1410
 		$this->Error('Missing or incorrect image file: '.$file);
1411
-	imageinterlace($im,0);
1412
-	$f = @fopen('php://temp','rb+');
1413
-	if($f)
1411
+	imageinterlace($im, 0);
1412
+	$f = @fopen('php://temp', 'rb+');
1413
+	if ($f)
1414 1414
 	{
1415 1415
 		// Perform conversion in memory
1416 1416
 		ob_start();
1417 1417
 		imagepng($im);
1418 1418
 		$data = ob_get_clean();
1419 1419
 		imagedestroy($im);
1420
-		fwrite($f,$data);
1420
+		fwrite($f, $data);
1421 1421
 		rewind($f);
1422
-		$info = $this->_parsepngstream($f,$file);
1422
+		$info = $this->_parsepngstream($f, $file);
1423 1423
 		fclose($f);
1424 1424
 	}
1425 1425
 	else
1426 1426
 	{
1427 1427
 		// Use temporary file
1428
-		$tmp = tempnam('.','gif');
1429
-		if(!$tmp)
1428
+		$tmp = tempnam('.', 'gif');
1429
+		if ( ! $tmp)
1430 1430
 			$this->Error('Unable to create a temporary file');
1431
-		if(!imagepng($im,$tmp))
1431
+		if ( ! imagepng($im, $tmp))
1432 1432
 			$this->Error('Error while saving to temporary file');
1433 1433
 		imagedestroy($im);
1434 1434
 		$info = $this->_parsepng($tmp);
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 function _out($s)
1456 1456
 {
1457 1457
 	// Add a line to the document
1458
-	if($this->state==2)
1458
+	if ($this->state == 2)
1459 1459
 		$this->pages[$this->page] .= $s."\n";
1460 1460
 	else
1461 1461
 		$this->buffer .= $s."\n";
@@ -1464,54 +1464,54 @@  discard block
 block discarded – undo
1464 1464
 function _putpages()
1465 1465
 {
1466 1466
 	$nb = $this->page;
1467
-	if(!empty($this->AliasNbPages))
1467
+	if ( ! empty($this->AliasNbPages))
1468 1468
 	{
1469 1469
 		// Replace number of pages
1470
-		for($n=1;$n<=$nb;$n++)
1471
-			$this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1470
+		for ($n = 1; $n <= $nb; $n++)
1471
+			$this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]);
1472 1472
 	}
1473
-	if($this->DefOrientation=='P')
1473
+	if ($this->DefOrientation == 'P')
1474 1474
 	{
1475
-		$wPt = $this->DefPageSize[0]*$this->k;
1476
-		$hPt = $this->DefPageSize[1]*$this->k;
1475
+		$wPt = $this->DefPageSize[0] * $this->k;
1476
+		$hPt = $this->DefPageSize[1] * $this->k;
1477 1477
 	}
1478 1478
 	else
1479 1479
 	{
1480
-		$wPt = $this->DefPageSize[1]*$this->k;
1481
-		$hPt = $this->DefPageSize[0]*$this->k;
1480
+		$wPt = $this->DefPageSize[1] * $this->k;
1481
+		$hPt = $this->DefPageSize[0] * $this->k;
1482 1482
 	}
1483 1483
 	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1484
-	for($n=1;$n<=$nb;$n++)
1484
+	for ($n = 1; $n <= $nb; $n++)
1485 1485
 	{
1486 1486
 		// Page
1487 1487
 		$this->_newobj();
1488 1488
 		$this->_out('<</Type /Page');
1489 1489
 		$this->_out('/Parent 1 0 R');
1490
-		if(isset($this->PageSizes[$n]))
1491
-			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1490
+		if (isset($this->PageSizes[$n]))
1491
+			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1]));
1492 1492
 		$this->_out('/Resources 2 0 R');
1493
-		if(isset($this->PageLinks[$n]))
1493
+		if (isset($this->PageLinks[$n]))
1494 1494
 		{
1495 1495
 			// Links
1496 1496
 			$annots = '/Annots [';
1497
-			foreach($this->PageLinks[$n] as $pl)
1497
+			foreach ($this->PageLinks[$n] as $pl)
1498 1498
 			{
1499
-				$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1499
+				$rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1500 1500
 				$annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1501
-				if(is_string($pl[4]))
1501
+				if (is_string($pl[4]))
1502 1502
 					$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1503 1503
 				else
1504 1504
 				{
1505 1505
 					$l = $this->links[$pl[4]];
1506 1506
 					$h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1507
-					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
1507
+					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k);
1508 1508
 				}
1509 1509
 			}
1510 1510
 			$this->_out($annots.']');
1511 1511
 		}
1512
-		if($this->PDFVersion>'1.3')
1512
+		if ($this->PDFVersion > '1.3')
1513 1513
 			$this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1514
-		$this->_out('/Contents '.($this->n+1).' 0 R>>');
1514
+		$this->_out('/Contents '.($this->n + 1).' 0 R>>');
1515 1515
 		$this->_out('endobj');
1516 1516
 		// Page content
1517 1517
 		$p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
@@ -1525,11 +1525,11 @@  discard block
 block discarded – undo
1525 1525
 	$this->_out('1 0 obj');
1526 1526
 	$this->_out('<</Type /Pages');
1527 1527
 	$kids = '/Kids [';
1528
-	for($i=0;$i<$nb;$i++)
1529
-		$kids .= (3+2*$i).' 0 R ';
1528
+	for ($i = 0; $i < $nb; $i++)
1529
+		$kids .= (3 + 2 * $i).' 0 R ';
1530 1530
 	$this->_out($kids.']');
1531 1531
 	$this->_out('/Count '.$nb);
1532
-	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
1532
+	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt));
1533 1533
 	$this->_out('>>');
1534 1534
 	$this->_out('endobj');
1535 1535
 }
@@ -1537,53 +1537,53 @@  discard block
 block discarded – undo
1537 1537
 function _putfonts()
1538 1538
 {
1539 1539
 	$nf = $this->n;
1540
-	foreach($this->diffs as $diff)
1540
+	foreach ($this->diffs as $diff)
1541 1541
 	{
1542 1542
 		// Encodings
1543 1543
 		$this->_newobj();
1544 1544
 		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1545 1545
 		$this->_out('endobj');
1546 1546
 	}
1547
-	foreach($this->FontFiles as $file=>$info)
1547
+	foreach ($this->FontFiles as $file=>$info)
1548 1548
 	{
1549 1549
 		// Font file embedding
1550 1550
 		$this->_newobj();
1551 1551
 		$this->FontFiles[$file]['n'] = $this->n;
1552
-		$font = file_get_contents($this->fontpath.$file,true);
1553
-		if(!$font)
1552
+		$font = file_get_contents($this->fontpath.$file, true);
1553
+		if ( ! $font)
1554 1554
 			$this->Error('Font file not found: '.$file);
1555
-		$compressed = (substr($file,-2)=='.z');
1556
-		if(!$compressed && isset($info['length2']))
1557
-			$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
1555
+		$compressed = (substr($file, -2) == '.z');
1556
+		if ( ! $compressed && isset($info['length2']))
1557
+			$font = substr($font, 6, $info['length1']).substr($font, 6 + $info['length1'] + 6, $info['length2']);
1558 1558
 		$this->_out('<</Length '.strlen($font));
1559
-		if($compressed)
1559
+		if ($compressed)
1560 1560
 			$this->_out('/Filter /FlateDecode');
1561 1561
 		$this->_out('/Length1 '.$info['length1']);
1562
-		if(isset($info['length2']))
1562
+		if (isset($info['length2']))
1563 1563
 			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1564 1564
 		$this->_out('>>');
1565 1565
 		$this->_putstream($font);
1566 1566
 		$this->_out('endobj');
1567 1567
 	}
1568
-	foreach($this->fonts as $k=>$font)
1568
+	foreach ($this->fonts as $k=>$font)
1569 1569
 	{
1570 1570
 		// Font objects
1571
-		$this->fonts[$k]['n'] = $this->n+1;
1571
+		$this->fonts[$k]['n'] = $this->n + 1;
1572 1572
 		$type = $font['type'];
1573 1573
 		$name = $font['name'];
1574
-		if($type=='Core')
1574
+		if ($type == 'Core')
1575 1575
 		{
1576 1576
 			// Core font
1577 1577
 			$this->_newobj();
1578 1578
 			$this->_out('<</Type /Font');
1579 1579
 			$this->_out('/BaseFont /'.$name);
1580 1580
 			$this->_out('/Subtype /Type1');
1581
-			if($name!='Symbol' && $name!='ZapfDingbats')
1581
+			if ($name != 'Symbol' && $name != 'ZapfDingbats')
1582 1582
 				$this->_out('/Encoding /WinAnsiEncoding');
1583 1583
 			$this->_out('>>');
1584 1584
 			$this->_out('endobj');
1585 1585
 		}
1586
-		elseif($type=='Type1' || $type=='TrueType')
1586
+		elseif ($type == 'Type1' || $type == 'TrueType')
1587 1587
 		{
1588 1588
 			// Additional Type1 or TrueType/OpenType font
1589 1589
 			$this->_newobj();
@@ -1591,10 +1591,10 @@  discard block
 block discarded – undo
1591 1591
 			$this->_out('/BaseFont /'.$name);
1592 1592
 			$this->_out('/Subtype /'.$type);
1593 1593
 			$this->_out('/FirstChar 32 /LastChar 255');
1594
-			$this->_out('/Widths '.($this->n+1).' 0 R');
1595
-			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1596
-			if(isset($font['diffn']))
1597
-				$this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
1594
+			$this->_out('/Widths '.($this->n + 1).' 0 R');
1595
+			$this->_out('/FontDescriptor '.($this->n + 2).' 0 R');
1596
+			if (isset($font['diffn']))
1597
+				$this->_out('/Encoding '.($nf + $font['diffn']).' 0 R');
1598 1598
 			else
1599 1599
 				$this->_out('/Encoding /WinAnsiEncoding');
1600 1600
 			$this->_out('>>');
@@ -1603,17 +1603,17 @@  discard block
 block discarded – undo
1603 1603
 			$this->_newobj();
1604 1604
 			$cw = &$font['cw'];
1605 1605
 			$s = '[';
1606
-			for($i=32;$i<=255;$i++)
1606
+			for ($i = 32; $i <= 255; $i++)
1607 1607
 				$s .= $cw[chr($i)].' ';
1608 1608
 			$this->_out($s.']');
1609 1609
 			$this->_out('endobj');
1610 1610
 			// Descriptor
1611 1611
 			$this->_newobj();
1612 1612
 			$s = '<</Type /FontDescriptor /FontName /'.$name;
1613
-			foreach($font['desc'] as $k=>$v)
1613
+			foreach ($font['desc'] as $k=>$v)
1614 1614
 				$s .= ' /'.$k.' '.$v;
1615
-			if(!empty($font['file']))
1616
-				$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1615
+			if ( ! empty($font['file']))
1616
+				$s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1617 1617
 			$this->_out($s.'>>');
1618 1618
 			$this->_out('endobj');
1619 1619
 		}
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 		{
1622 1622
 			// Allow for additional types
1623 1623
 			$mtd = '_put'.strtolower($type);
1624
-			if(!method_exists($this,$mtd))
1624
+			if ( ! method_exists($this, $mtd))
1625 1625
 				$this->Error('Unsupported font type: '.$type);
1626 1626
 			$this->$mtd($font);
1627 1627
 		}
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 
1631 1631
 function _putimages()
1632 1632
 {
1633
-	foreach(array_keys($this->images) as $file)
1633
+	foreach (array_keys($this->images) as $file)
1634 1634
 	{
1635 1635
 		$this->_putimage($this->images[$file]);
1636 1636
 		unset($this->images[$file]['data']);
@@ -1646,40 +1646,40 @@  discard block
 block discarded – undo
1646 1646
 	$this->_out('/Subtype /Image');
1647 1647
 	$this->_out('/Width '.$info['w']);
1648 1648
 	$this->_out('/Height '.$info['h']);
1649
-	if($info['cs']=='Indexed')
1650
-		$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1649
+	if ($info['cs'] == 'Indexed')
1650
+		$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]');
1651 1651
 	else
1652 1652
 	{
1653 1653
 		$this->_out('/ColorSpace /'.$info['cs']);
1654
-		if($info['cs']=='DeviceCMYK')
1654
+		if ($info['cs'] == 'DeviceCMYK')
1655 1655
 			$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1656 1656
 	}
1657 1657
 	$this->_out('/BitsPerComponent '.$info['bpc']);
1658
-	if(isset($info['f']))
1658
+	if (isset($info['f']))
1659 1659
 		$this->_out('/Filter /'.$info['f']);
1660
-	if(isset($info['dp']))
1660
+	if (isset($info['dp']))
1661 1661
 		$this->_out('/DecodeParms <<'.$info['dp'].'>>');
1662
-	if(isset($info['trns']) && is_array($info['trns']))
1662
+	if (isset($info['trns']) && is_array($info['trns']))
1663 1663
 	{
1664 1664
 		$trns = '';
1665
-		for($i=0;$i<count($info['trns']);$i++)
1665
+		for ($i = 0; $i < count($info['trns']); $i++)
1666 1666
 			$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1667 1667
 		$this->_out('/Mask ['.$trns.']');
1668 1668
 	}
1669
-	if(isset($info['smask']))
1670
-		$this->_out('/SMask '.($this->n+1).' 0 R');
1669
+	if (isset($info['smask']))
1670
+		$this->_out('/SMask '.($this->n + 1).' 0 R');
1671 1671
 	$this->_out('/Length '.strlen($info['data']).'>>');
1672 1672
 	$this->_putstream($info['data']);
1673 1673
 	$this->_out('endobj');
1674 1674
 	// Soft mask
1675
-	if(isset($info['smask']))
1675
+	if (isset($info['smask']))
1676 1676
 	{
1677 1677
 		$dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
1678 1678
 		$smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']);
1679 1679
 		$this->_putimage($smask);
1680 1680
 	}
1681 1681
 	// Palette
1682
-	if($info['cs']=='Indexed')
1682
+	if ($info['cs'] == 'Indexed')
1683 1683
 	{
1684 1684
 		$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1685 1685
 		$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 
1693 1693
 function _putxobjectdict()
1694 1694
 {
1695
-	foreach($this->images as $image)
1695
+	foreach ($this->images as $image)
1696 1696
 		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1697 1697
 }
1698 1698
 
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 {
1701 1701
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1702 1702
 	$this->_out('/Font <<');
1703
-	foreach($this->fonts as $font)
1703
+	foreach ($this->fonts as $font)
1704 1704
 		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1705 1705
 	$this->_out('>>');
1706 1706
 	$this->_out('/XObject <<');
@@ -1724,15 +1724,15 @@  discard block
 block discarded – undo
1724 1724
 function _putinfo()
1725 1725
 {
1726 1726
 	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1727
-	if(!empty($this->title))
1727
+	if ( ! empty($this->title))
1728 1728
 		$this->_out('/Title '.$this->_textstring($this->title));
1729
-	if(!empty($this->subject))
1729
+	if ( ! empty($this->subject))
1730 1730
 		$this->_out('/Subject '.$this->_textstring($this->subject));
1731
-	if(!empty($this->author))
1731
+	if ( ! empty($this->author))
1732 1732
 		$this->_out('/Author '.$this->_textstring($this->author));
1733
-	if(!empty($this->keywords))
1733
+	if ( ! empty($this->keywords))
1734 1734
 		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1735
-	if(!empty($this->creator))
1735
+	if ( ! empty($this->creator))
1736 1736
 		$this->_out('/Creator '.$this->_textstring($this->creator));
1737 1737
 	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1738 1738
 }
@@ -1741,19 +1741,19 @@  discard block
 block discarded – undo
1741 1741
 {
1742 1742
 	$this->_out('/Type /Catalog');
1743 1743
 	$this->_out('/Pages 1 0 R');
1744
-	if($this->ZoomMode=='fullpage')
1744
+	if ($this->ZoomMode == 'fullpage')
1745 1745
 		$this->_out('/OpenAction [3 0 R /Fit]');
1746
-	elseif($this->ZoomMode=='fullwidth')
1746
+	elseif ($this->ZoomMode == 'fullwidth')
1747 1747
 		$this->_out('/OpenAction [3 0 R /FitH null]');
1748
-	elseif($this->ZoomMode=='real')
1748
+	elseif ($this->ZoomMode == 'real')
1749 1749
 		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1750
-	elseif(!is_string($this->ZoomMode))
1751
-		$this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
1752
-	if($this->LayoutMode=='single')
1750
+	elseif ( ! is_string($this->ZoomMode))
1751
+		$this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']');
1752
+	if ($this->LayoutMode == 'single')
1753 1753
 		$this->_out('/PageLayout /SinglePage');
1754
-	elseif($this->LayoutMode=='continuous')
1754
+	elseif ($this->LayoutMode == 'continuous')
1755 1755
 		$this->_out('/PageLayout /OneColumn');
1756
-	elseif($this->LayoutMode=='two')
1756
+	elseif ($this->LayoutMode == 'two')
1757 1757
 		$this->_out('/PageLayout /TwoColumnLeft');
1758 1758
 }
1759 1759
 
@@ -1764,9 +1764,9 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
 function _puttrailer()
1766 1766
 {
1767
-	$this->_out('/Size '.($this->n+1));
1767
+	$this->_out('/Size '.($this->n + 1));
1768 1768
 	$this->_out('/Root '.$this->n.' 0 R');
1769
-	$this->_out('/Info '.($this->n-1).' 0 R');
1769
+	$this->_out('/Info '.($this->n - 1).' 0 R');
1770 1770
 }
1771 1771
 
1772 1772
 function _enddoc()
@@ -1789,10 +1789,10 @@  discard block
 block discarded – undo
1789 1789
 	// Cross-ref
1790 1790
 	$o = strlen($this->buffer);
1791 1791
 	$this->_out('xref');
1792
-	$this->_out('0 '.($this->n+1));
1792
+	$this->_out('0 '.($this->n + 1));
1793 1793
 	$this->_out('0000000000 65535 f ');
1794
-	for($i=1;$i<=$this->n;$i++)
1795
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1794
+	for ($i = 1; $i <= $this->n; $i++)
1795
+		$this->_out(sprintf('%010d 00000 n ', $this->offsets[$i]));
1796 1796
 	// Trailer
1797 1797
 	$this->_out('trailer');
1798 1798
 	$this->_out('<<');
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 }
1808 1808
 
1809 1809
 // Handle special IE contype request
1810
-if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
1810
+if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype')
1811 1811
 {
1812 1812
 	header('Content-Type: application/pdf');
1813 1813
 	exit;
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Form_validation.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 class CI_Form_validation {
28 28
 
29 29
 	protected $CI;
30
-	protected $_field_data			= array();
30
+	protected $_field_data = array();
31 31
 	protected $_config_rules		= array();
32 32
 	protected $_error_array			= array();
33
-	protected $_error_messages		= array();
33
+	protected $_error_messages = array();
34 34
 	protected $_error_prefix		= '<p>';
35 35
 	protected $_error_suffix		= '</p>';
36 36
 	protected $error_string			= '';
37
-	protected $_safe_form_data		= FALSE;
37
+	protected $_safe_form_data = FALSE;
38 38
 
39 39
 	/**
40 40
 	 * Constructor
41 41
 	 */
42 42
 	public function __construct($rules = array())
43 43
 	{
44
-		$this->CI =& get_instance();
44
+		$this->CI = & get_instance();
45 45
 
46 46
 		// Validation rules can be stored in a config file.
47 47
 		$this->_config_rules = $rules;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 
103 103
 		// No fields? Nothing to do...
104
-		if ( ! is_string($field) OR  ! is_string($rules) OR $field == '')
104
+		if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
105 105
 		{
106 106
 			return $this;
107 107
 		}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 		}
132 132
 		else
133 133
 		{
134
-			$indexes	= array();
135
-			$is_array	= FALSE;
134
+			$indexes = array();
135
+			$is_array = FALSE;
136 136
 		}
137 137
 
138 138
 		// Build our master array
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 			{
413 413
 				if (isset($array[$keys[$i]]))
414 414
 				{
415
-					$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
415
+					$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i + 1));
416 416
 				}
417 417
 				else
418 418
 				{
@@ -452,18 +452,18 @@  discard block
 block discarded – undo
452 452
 				else
453 453
 				{
454 454
 					// start with a reference
455
-					$post_ref =& $_POST;
455
+					$post_ref = & $_POST;
456 456
 
457 457
 					// before we assign values, make a reference to the right POST key
458 458
 					if (count($row['keys']) == 1)
459 459
 					{
460
-						$post_ref =& $post_ref[current($row['keys'])];
460
+						$post_ref = & $post_ref[current($row['keys'])];
461 461
 					}
462 462
 					else
463 463
 					{
464 464
 						foreach ($row['keys'] as $val)
465 465
 						{
466
-							$post_ref =& $post_ref[$val];
466
+							$post_ref = & $post_ref[$val];
467 467
 						}
468 468
 					}
469 469
 
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 */
501 501
 	protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
502 502
 	{
503
-	$custom_label=explode("<",$row['label']);
504
-	$row['label']=(isset($custom_label[1]) && !empty($custom_label[1])) ? $custom_label[0] : $row['label'];
503
+	$custom_label = explode("<", $row['label']);
504
+	$row['label'] = (isset($custom_label[1]) && ! empty($custom_label[1])) ? $custom_label[0] : $row['label'];
505 505
 		// If the $_POST data is an array we will run a recursive call
506 506
 		if (is_array($postdata))
507 507
 		{
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 
519 519
 		// If the field is blank, but NOT required, no further tests are necessary
520 520
 		$callback = FALSE;
521
-		if ( (! in_array('required', $rules) AND ! in_array('dropdown', $rules)) AND is_null($postdata))
521
+		if (( ! in_array('required', $rules) AND ! in_array('dropdown', $rules)) AND is_null($postdata))
522 522
 		{
523 523
 			// Before we bail out, does the rule contain a callback?
524 524
 			if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match))
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			
542 542
 				// Set the message type
543 543
                             
544
-				$type = (in_array('required', $rules)) ? 'required' : ((in_array('dropdown',$rules)) ? 'dropdown':'isset' );
544
+				$type = (in_array('required', $rules)) ? 'required' : ((in_array('dropdown', $rules)) ? 'dropdown' : 'isset');
545 545
 				if ( ! isset($this->_error_messages[$type]))
546 546
 				{
547 547
 					if (FALSE === ($line = $this->CI->lang->line($type)))
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 			if (preg_match("/(.*?)\[(.*)\]/", $rule, $match))
611 611
 			{
612 612
 				$rule	= $match[1];
613
-				$param	= $match[2];
613
+				$param = $match[2];
614 614
 			}
615 615
 
616 616
 			// Call the function that corresponds to the rule
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 					// Users can use any native PHP function call that has one param.
649 649
 					if (function_exists($rule))
650 650
 					{
651
-					  $str=null;
652
-					  if(is_array($postdata)){
653
-					    foreach($postdata as $key=>$value){
654
-					      $str.=$value.",";
651
+					  $str = null;
652
+					  if (is_array($postdata)) {
653
+					    foreach ($postdata as $key=>$value) {
654
+					      $str .= $value.",";
655 655
 					    }
656
-					    $str=rtrim($str,',');
657
-					    $postdata=$str;  
656
+					    $str = rtrim($str, ',');
657
+					    $postdata = $str;  
658 658
 					  }
659 659
 						$result = $rule($postdata);
660 660
 
@@ -990,20 +990,20 @@  discard block
 block discarded – undo
990 990
 	 */
991 991
 	public function is_unique($str, $field)
992 992
 	{
993
-                $id='';
994
-		$data =explode('.', $field);
995
-                $table=$data[0];
996
-                $field=$data[1];
997
-                if(isset($data[2]))
998
-                $id=$data[2];
999
-                $where=array($field => $str);
1000
-                if($id != ''){
1001
-                 $where['id !=']=$id;
993
+                $id = '';
994
+		$data = explode('.', $field);
995
+                $table = $data[0];
996
+                $field = $data[1];
997
+                if (isset($data[2]))
998
+                $id = $data[2];
999
+                $where = array($field => $str);
1000
+                if ($id != '') {
1001
+                 $where['id !='] = $id;
1002 1002
                 }
1003
-                if($table == 'accounts'){
1004
-		  $where['deleted']=0;
1003
+                if ($table == 'accounts') {
1004
+		  $where['deleted'] = 0;
1005 1005
                 }
1006
-                $query = $this->CI->db->limit(1)->get_where($table,$where );
1006
+                $query = $this->CI->db->limit(1)->get_where($table, $where);
1007 1007
 		return $query->num_rows() > 0 ? FALSE : TRUE;
1008 1008
          }
1009 1009
 
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 	 */
1191 1191
 	public function numeric($str)
1192 1192
 	{
1193
-		return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
1193
+		return (bool)preg_match('/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
1194 1194
 
1195 1195
 	}
1196 1196
 
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 	 */
1220 1220
 	public function integer($str)
1221 1221
 	{
1222
-		return (bool) preg_match('/^[\-+]?[0-9]+$/', $str);
1222
+		return (bool)preg_match('/^[\-+]?[0-9]+$/', $str);
1223 1223
 	}
1224 1224
 
1225 1225
 	// --------------------------------------------------------------------
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	 */
1234 1234
 	public function decimal($str)
1235 1235
 	{
1236
-		return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
1236
+		return (bool)preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
1237 1237
 	}
1238 1238
 
1239 1239
 	// --------------------------------------------------------------------
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 	 */
1284 1284
 	public function is_natural($str)
1285 1285
 	{
1286
-		return (bool) preg_match( '/^[0-9]+$/', $str);
1286
+		return (bool)preg_match('/^[0-9]+$/', $str);
1287 1287
 	}
1288 1288
 
1289 1289
 	// --------------------------------------------------------------------
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 	 */
1298 1298
 	public function is_natural_no_zero($str)
1299 1299
 	{
1300
-		if ( ! preg_match( '/^[0-9]+$/', $str))
1300
+		if ( ! preg_match('/^[0-9]+$/', $str))
1301 1301
 		{
1302 1302
 			return FALSE;
1303 1303
 		}
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
 	 */
1325 1325
 	public function valid_base64($str)
1326 1326
 	{
1327
-		return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
1327
+		return (bool)! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
1328 1328
 	}
1329 1329
 
1330 1330
 	// --------------------------------------------------------------------
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 	 */
1423 1423
 	public function encode_php_tags($str)
1424 1424
 	{
1425
-		return str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
1425
+		return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
1426 1426
 	}
1427 1427
 	         public function destination($str)
1428 1428
         {
@@ -1436,54 +1436,54 @@  discard block
 block discarded – undo
1436 1436
 	{
1437 1437
 		    return ( ! preg_match("/^([.a-z0-9])+$/i", $str)) ? FALSE : TRUE;
1438 1438
 	}
1439
-	public function valid_decimal($str){
1440
-            return (bool) preg_match('#^\d+(?:\.\d{1,5})?$#', $str);
1439
+	public function valid_decimal($str) {
1440
+            return (bool)preg_match('#^\d+(?:\.\d{1,5})?$#', $str);
1441 1441
         }
1442 1442
         public function alpha_numeric_space($str)
1443 1443
 	{
1444 1444
 		return ( ! preg_match("/^[A-Za-z0-9\s]+$/", $str)) ? FALSE : TRUE;
1445 1445
 	}
1446
-        public function alpha_space($str){
1446
+        public function alpha_space($str) {
1447 1447
 		return ( ! preg_match("/^[A-Za-z\s]+$/", $str)) ? FALSE : TRUE;
1448 1448
 //                return ( ! preg_match("/^([-a-z0-9_-\s])+$/i", $str)) ? FALSE : TRUE;
1449 1449
 	}
1450
-        public function currency_decimal($str){
1451
-            return (bool) preg_match('#^\d{0,5}+(?:\.\d{1,5})?$#', $str);
1450
+        public function currency_decimal($str) {
1451
+            return (bool)preg_match('#^\d{0,5}+(?:\.\d{1,5})?$#', $str);
1452 1452
 //            test(num)
1453 1453
         }
1454 1454
         /* ASTPP  3.0 
1455 1455
          * For Old Password checking
1456 1456
          */
1457
-        public function password_check($str,$table){
1457
+        public function password_check($str, $table) {
1458 1458
           $this->CI->db->select('password');
1459
-          $this->CI->db->where('id',$_POST['id']);
1460
-          $result=$this->CI->db->get($table);
1461
-          if($result->num_rows() > 0 ){
1462
-              $result=(array)$result->first_row();
1463
-              $password=$this->CI->common->decode($result['password']);
1464
-              if($password && $password == $str){
1459
+          $this->CI->db->where('id', $_POST['id']);
1460
+          $result = $this->CI->db->get($table);
1461
+          if ($result->num_rows() > 0) {
1462
+              $result = (array)$result->first_row();
1463
+              $password = $this->CI->common->decode($result['password']);
1464
+              if ($password && $password == $str) {
1465 1465
                   return true;
1466
-              }else{
1466
+              } else {
1467 1467
                   return false;
1468 1468
               }
1469
-          }else{
1469
+          } else {
1470 1470
               return false;
1471 1471
           }
1472 1472
         }
1473
-        public function did_account_checking($str){
1474
-          $post_array=$this->CI->input->post();
1475
-          if($str > 0){
1476
-	      $this->CI->db->where("id",$str);
1473
+        public function did_account_checking($str) {
1474
+          $post_array = $this->CI->input->post();
1475
+          if ($str > 0) {
1476
+	      $this->CI->db->where("id", $str);
1477 1477
 	      $this->CI->db->select('posttoexternal,balance,credit_limit');
1478
-	      $acc_result=$this->CI->db->get('accounts');
1479
-	      $customer_info=(array)$acc_result->first_row();
1478
+	      $acc_result = $this->CI->db->get('accounts');
1479
+	      $customer_info = (array)$acc_result->first_row();
1480 1480
 	      $available_bal = ($customer_info["balance"]) + $customer_info["posttoexternal"] * ($customer_info["credit_limit"]);
1481
-	      if($available_bal >= $post_array['setup']){
1481
+	      if ($available_bal >= $post_array['setup']) {
1482 1482
 	       return TRUE;
1483
-	      }else{
1483
+	      } else {
1484 1484
 	       return FALSE;
1485 1485
 	      }
1486
-          }else{
1486
+          } else {
1487 1487
            return TRUE;
1488 1488
           }
1489 1489
         }
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Calendar.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	var $lang;
33 33
 	var $local_time;
34 34
 	var $template		= '';
35
-	var $start_day		= 'sunday';
36
-	var $month_type		= 'long';
35
+	var $start_day = 'sunday';
36
+	var $month_type = 'long';
37 37
 	var $day_type		= 'abr';
38
-	var $show_next_prev	= FALSE;
39
-	var $next_prev_url	= '';
38
+	var $show_next_prev = FALSE;
39
+	var $next_prev_url = '';
40 40
 
41 41
 	/**
42 42
 	 * Constructor
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function __construct($config = array())
47 47
 	{
48
-		$this->CI =& get_instance();
48
+		$this->CI = & get_instance();
49 49
 
50 50
 		if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE))
51 51
 		{
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 
116 116
 		$adjusted_date = $this->adjust_date($month, $year);
117 117
 
118
-		$month	= $adjusted_date['month'];
119
-		$year	= $adjusted_date['year'];
118
+		$month = $adjusted_date['month'];
119
+		$year = $adjusted_date['year'];
120 120
 
121 121
 		// Determine the total days in the month
122 122
 		$total_days = $this->get_total_days($month, $year);
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 
138 138
 		// Set the current month/year/day
139 139
 		// We use this to determine the "today" date
140
-		$cur_year	= date("Y", $this->local_time);
141
-		$cur_month	= date("m", $this->local_time);
142
-		$cur_day	= date("j", $this->local_time);
140
+		$cur_year = date("Y", $this->local_time);
141
+		$cur_month = date("m", $this->local_time);
142
+		$cur_day = date("j", $this->local_time);
143 143
 
144 144
 		$is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
145 145
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		if ($this->show_next_prev == TRUE)
159 159
 		{
160 160
 			// Add a trailing slash to the  URL if needed
161
-			$this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/",  $this->next_prev_url);
161
+			$this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
162 162
 
163 163
 			$adjusted_date = $this->adjust_date($month - 1, $year);
164 164
 			$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$day_names = $this->get_day_names();
194 194
 
195
-		for ($i = 0; $i < 7; $i ++)
195
+		for ($i = 0; $i < 7; $i++)
196 196
 		{
197
-			$out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
197
+			$out .= str_replace('{week_day}', $day_names[($start_day + $i) % 7], $this->temp['week_day_cell']);
198 198
 		}
199 199
 
200 200
 		$out .= "\n";
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	{
339 339
 		$date = array();
340 340
 
341
-		$date['month']	= $month;
342
-		$date['year']	= $year;
341
+		$date['month'] = $month;
342
+		$date['year'] = $year;
343 343
 
344 344
 		while ($date['month'] > 12)
345 345
 		{
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	function get_total_days($month, $year)
375 375
 	{
376
-		$days_in_month	= array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
376
+		$days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
377 377
 
378 378
 		if ($month < 1 OR $month > 12)
379 379
 		{
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	function default_template()
406 406
 	{
407
-		return  array (
407
+		return  array(
408 408
 						'table_open'				=> '<table border="0" cellpadding="4" cellspacing="0">',
409 409
 						'heading_row_start'			=> '<tr>',
410 410
 						'heading_previous_cell'		=> '<th><a href="{previous_url}">&lt;&lt;</a></th>',
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 
452 452
 		$today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
453 453
 
454
-		foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content',  'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
454
+		foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
455 455
 		{
456 456
 			if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
457 457
 			{
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Migration.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 		foreach ($config as $key => $val)
47 47
 		{
48
-			$this->{'_' . $key} = $val;
48
+			$this->{'_'.$key} = $val;
49 49
 		}
50 50
 
51 51
 		log_message('debug', 'Migrations class initialized');
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 
59 59
 		// If not set, set it
60
-		$this->_migration_path == '' OR $this->_migration_path = APPPATH . 'migrations/';
60
+		$this->_migration_path == '' OR $this->_migration_path = APPPATH.'migrations/';
61 61
 
62 62
 		// Add trailing slash if not set
63 63
 		$this->_migration_path = rtrim($this->_migration_path, '/').'/';
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		// But first let's make sure that everything is the way it should be
120 120
 		for ($i = $start; $i != $stop; $i += $step)
121 121
 		{
122
-			$f = glob(sprintf($this->_migration_path . '%03d_*.php', $i));
122
+			$f = glob(sprintf($this->_migration_path.'%03d_*.php', $i));
123 123
 
124 124
 			// Only one migration per step is permitted
125 125
 			if (count($f) > 1)
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 				}
161 161
 
162 162
 				include $f[0];
163
-				$class = 'Migration_' . ucfirst($match[1]);
163
+				$class = 'Migration_'.ucfirst($match[1]);
164 164
 
165 165
 				if ( ! class_exists($class))
166 166
 				{
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			}
184 184
 		}
185 185
 
186
-		log_message('debug', 'Current migration: ' . $current_version);
186
+		log_message('debug', 'Current migration: '.$current_version);
187 187
 
188 188
 		$version = $i + ($step == 1 ? -1 : 0);
189 189
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 			return TRUE;
194 194
 		}
195 195
 
196
-		log_message('debug', 'Migrating from ' . $method . ' to version ' . $version);
196
+		log_message('debug', 'Migrating from '.$method.' to version '.$version);
197 197
 
198 198
 		// Loop through the migrations
199 199
 		foreach ($migrations AS $migration)
200 200
 		{
201 201
 			// Run the migration class
202
-			$class = 'Migration_' . ucfirst(strtolower($migration));
202
+			$class = 'Migration_'.ucfirst(strtolower($migration));
203 203
 			call_user_func(array(new $class, $method));
204 204
 
205 205
 			$current_version += $step;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		
232 232
 		// Calculate the last migration step from existing migration
233 233
 		// filenames and procceed to the standard version migration
234
-		return $this->version((int) substr($last_migration, 0, 3));
234
+		return $this->version((int)substr($last_migration, 0, 3));
235 235
 	}
236 236
 
237 237
 	// --------------------------------------------------------------------
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	protected function find_migrations()
272 272
 	{
273 273
 		// Load all *_*.php files in the migrations path
274
-		$files = glob($this->_migration_path . '*_*.php');
274
+		$files = glob($this->_migration_path.'*_*.php');
275 275
 		$file_count = count($files);
276 276
 		
277 277
 		for ($i = 0; $i < $file_count; $i++)
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Trackback.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class CI_Trackback {
30 30
 
31
-	var $time_format	= 'local';
32
-	var $charset		= 'UTF-8';
33
-	var $data			= array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
34
-	var $convert_ascii	= TRUE;
35
-	var $response		= '';
36
-	var $error_msg		= array();
31
+	var $time_format = 'local';
32
+	var $charset = 'UTF-8';
33
+	var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
34
+	var $convert_ascii = TRUE;
35
+	var $response = '';
36
+	var $error_msg = array();
37 37
 
38 38
 	/**
39 39
 	 * Constructor
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
 		}
252 252
 
253 253
 		// Transfer the data
254
-		fputs ($fp, "POST " . $path . " HTTP/1.0\r\n" );
255
-		fputs ($fp, "Host: " . $target['host'] . "\r\n" );
256
-		fputs ($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
257
-		fputs ($fp, "Content-length: " . strlen($data) . "\r\n" );
258
-		fputs ($fp, "Connection: close\r\n\r\n" );
259
-		fputs ($fp, $data);
254
+		fputs($fp, "POST ".$path." HTTP/1.0\r\n");
255
+		fputs($fp, "Host: ".$target['host']."\r\n");
256
+		fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
257
+		fputs($fp, "Content-length: ".strlen($data)."\r\n");
258
+		fputs($fp, "Connection: close\r\n\r\n");
259
+		fputs($fp, $data);
260 260
 
261 261
 		// Was it successful?
262 262
 		$this->response = "";
@@ -359,30 +359,30 @@  discard block
 block discarded – undo
359 359
 		if (strpos($url, '?') !== FALSE)
360 360
 		{
361 361
 			$tb_array = explode('/', $url);
362
-			$tb_end   = $tb_array[count($tb_array)-1];
362
+			$tb_end   = $tb_array[count($tb_array) - 1];
363 363
 
364 364
 			if ( ! is_numeric($tb_end))
365 365
 			{
366
-				$tb_end  = $tb_array[count($tb_array)-2];
366
+				$tb_end  = $tb_array[count($tb_array) - 2];
367 367
 			}
368 368
 
369 369
 			$tb_array = explode('=', $tb_end);
370
-			$tb_id	= $tb_array[count($tb_array)-1];
370
+			$tb_id = $tb_array[count($tb_array) - 1];
371 371
 		}
372 372
 		else
373 373
 		{
374 374
 			$url = rtrim($url, '/');
375 375
 
376 376
 			$tb_array = explode('/', $url);
377
-			$tb_id	= $tb_array[count($tb_array)-1];
377
+			$tb_id = $tb_array[count($tb_array) - 1];
378 378
 
379 379
 			if ( ! is_numeric($tb_id))
380 380
 			{
381
-				$tb_id  = $tb_array[count($tb_array)-2];
381
+				$tb_id = $tb_array[count($tb_array) - 2];
382 382
 			}
383 383
 		}
384 384
 
385
-		if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
385
+		if ( ! preg_match("/^([0-9]+)$/", $tb_id))
386 386
 		{
387 387
 			return FALSE;
388 388
 		}
@@ -406,14 +406,14 @@  discard block
 block discarded – undo
406 406
 		$temp = '__TEMP_AMPERSANDS__';
407 407
 
408 408
 		$str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
409
-		$str = preg_replace("/&(\w+);/",  "$temp\\1;", $str);
409
+		$str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
410 410
 
411
-		$str = str_replace(array("&","<",">","\"", "'", "-"),
411
+		$str = str_replace(array("&", "<", ">", "\"", "'", "-"),
412 412
 							array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
413 413
 							$str);
414 414
 
415
-		$str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
416
-		$str = preg_replace("/$temp(\w+);/","&\\1;", $str);
415
+		$str = preg_replace("/$temp(\d+);/", "&#\\1;", $str);
416
+		$str = preg_replace("/$temp(\w+);/", "&\\1;", $str);
417 417
 
418 418
 		return $str;
419 419
 	}
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 	 */
471 471
 	function convert_ascii($str)
472 472
 	{
473
-		$count	= 1;
474
-		$out	= '';
475
-		$temp	= array();
473
+		$count = 1;
474
+		$out = '';
475
+		$temp = array();
476 476
 
477 477
 		for ($i = 0, $s = strlen($str); $i < $s; $i++)
478 478
 		{
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Upload.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class CI_Upload {
28 28
 
29
-	public $max_size				= 0;
30
-	public $max_width				= 0;
31
-	public $max_height				= 0;
32
-	public $max_filename			= 0;
33
-	public $allowed_types			= "";
29
+	public $max_size = 0;
30
+	public $max_width = 0;
31
+	public $max_height = 0;
32
+	public $max_filename = 0;
33
+	public $allowed_types = "";
34 34
 	public $file_temp				= "";
35 35
 	public $file_name				= "";
36 36
 	public $orig_name				= "";
37 37
 	public $file_type				= "";
38 38
 	public $file_size				= "";
39
-	public $file_ext				= "";
39
+	public $file_ext = "";
40 40
 	public $upload_path				= "";
41 41
 	public $overwrite				= FALSE;
42 42
 	public $encrypt_name			= FALSE;
43
-	public $is_image				= FALSE;
43
+	public $is_image = FALSE;
44 44
 	public $image_width				= '';
45 45
 	public $image_height			= '';
46
-	public $image_type				= '';
47
-	public $image_size_str			= '';
46
+	public $image_type = '';
47
+	public $image_size_str = '';
48 48
 	public $error_msg				= array();
49
-	public $mimes					= array();
50
-	public $remove_spaces			= TRUE;
49
+	public $mimes = array();
50
+	public $remove_spaces = TRUE;
51 51
 	public $xss_clean				= FALSE;
52 52
 	public $temp_prefix				= "temp_file_";
53 53
 	public $client_name				= '';
54 54
 
55
-	protected $_file_name_override	= '';
55
+	protected $_file_name_override = '';
56 56
 
57 57
 	/**
58 58
 	 * Constructor
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		{
163 163
 			$error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
164 164
 
165
-			switch($error)
165
+			switch ($error)
166 166
 			{
167 167
 				case 1:	// UPLOAD_ERR_INI_SIZE
168 168
 					$this->set_error('upload_file_exceeds_limit');
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			// An extension was provided, lets have it!
225 225
 			else
226 226
 			{
227
-				$this->file_ext	 = $this->get_extension($this->_file_name_override);
227
+				$this->file_ext = $this->get_extension($this->_file_name_override);
228 228
 			}
229 229
 
230 230
 			if ( ! $this->is_allowed_filetype(TRUE))
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		// Convert the file size to kilobytes
238 238
 		if ($this->file_size > 0)
239 239
 		{
240
-			$this->file_size = round($this->file_size/1024, 2);
240
+			$this->file_size = round($this->file_size / 1024, 2);
241 241
 		}
242 242
 
243 243
 		// Is the file size within the allowed maximum?
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 */
343 343
 	public function data()
344 344
 	{
345
-		return array (
345
+		return array(
346 346
 						'file_name'			=> $this->file_name,
347 347
 						'file_type'			=> $this->file_type,
348 348
 						'file_path'			=> $this->upload_path,
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 */
434 434
 	public function set_max_filesize($n)
435 435
 	{
436
-		$this->max_size = ((int) $n < 0) ? 0: (int) $n;
436
+		$this->max_size = ((int)$n < 0) ? 0 : (int)$n;
437 437
 	}
438 438
 
439 439
 	// --------------------------------------------------------------------
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	 */
447 447
 	public function set_max_filename($n)
448 448
 	{
449
-		$this->max_filename = ((int) $n < 0) ? 0: (int) $n;
449
+		$this->max_filename = ((int)$n < 0) ? 0 : (int)$n;
450 450
 	}
451 451
 
452 452
 	// --------------------------------------------------------------------
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function set_max_width($n)
461 461
 	{
462
-		$this->max_width = ((int) $n < 0) ? 0: (int) $n;
462
+		$this->max_width = ((int)$n < 0) ? 0 : (int)$n;
463 463
 	}
464 464
 
465 465
 	// --------------------------------------------------------------------
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 */
473 473
 	public function set_max_height($n)
474 474
 	{
475
-		$this->max_height = ((int) $n < 0) ? 0: (int) $n;
475
+		$this->max_height = ((int)$n < 0) ? 0 : (int)$n;
476 476
 	}
477 477
 
478 478
 	// --------------------------------------------------------------------
@@ -516,10 +516,10 @@  discard block
 block discarded – undo
516 516
 			{
517 517
 				$types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
518 518
 
519
-				$this->image_width		= $D['0'];
520
-				$this->image_height		= $D['1'];
521
-				$this->image_type		= ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
522
-				$this->image_size_str	= $D['3'];  // string containing height and width
519
+				$this->image_width = $D['0'];
520
+				$this->image_height = $D['1'];
521
+				$this->image_type = ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
522
+				$this->image_size_str = $D['3']; // string containing height and width
523 523
 			}
524 524
 		}
525 525
 	}
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 	 */
644 644
 	public function is_allowed_filesize()
645 645
 	{
646
-		if ($this->max_size != 0  AND  $this->file_size > $this->max_size)
646
+		if ($this->max_size != 0 AND $this->file_size > $this->max_size)
647 647
 		{
648 648
 			return FALSE;
649 649
 		}
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 			return FALSE;
723 723
 		}
724 724
 
725
-		$this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/",  $this->upload_path);
725
+		$this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
726 726
 		return TRUE;
727 727
 	}
728 728
 
@@ -765,17 +765,17 @@  discard block
 block discarded – undo
765 765
 						'/',
766 766
 						"%20",
767 767
 						"%22",
768
-						"%3c",		// <
769
-						"%253c",	// <
770
-						"%3e",		// >
771
-						"%0e",		// >
772
-						"%28",		// (
773
-						"%29",		// )
774
-						"%2528",	// (
775
-						"%26",		// &
776
-						"%24",		// $
777
-						"%3f",		// ?
778
-						"%3b",		// ;
768
+						"%3c", // <
769
+						"%253c", // <
770
+						"%3e", // >
771
+						"%0e", // >
772
+						"%28", // (
773
+						"%29", // )
774
+						"%2528", // (
775
+						"%26", // &
776
+						"%24", // $
777
+						"%3f", // ?
778
+						"%3b", // ;
779 779
 						"%3d"		// =
780 780
 					);
781 781
 
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
 		$ext = '';
803 803
 		if (strpos($filename, '.') !== FALSE)
804 804
 		{
805
-			$parts		= explode('.', $filename);
806
-			$ext		= '.'.array_pop($parts);
807
-			$filename	= implode('.', $parts);
805
+			$parts = explode('.', $filename);
806
+			$ext = '.'.array_pop($parts);
807
+			$filename = implode('.', $parts);
808 808
 		}
809 809
 
810 810
 		return substr($filename, 0, ($length - strlen($ext))).$ext;
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 			return FALSE;
876 876
 		}
877 877
 
878
-		$CI =& get_instance();
878
+		$CI = & get_instance();
879 879
 		return $CI->security->xss_clean($data, TRUE);
880 880
 	}
881 881
 
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 	 */
890 890
 	public function set_error($msg)
891 891
 	{
892
-		$CI =& get_instance();
892
+		$CI = & get_instance();
893 893
 		$CI->lang->load('upload');
894 894
 
895 895
 		if (is_array($msg))
@@ -984,9 +984,9 @@  discard block
 block discarded – undo
984 984
 			return $filename;
985 985
 		}
986 986
 
987
-		$parts		= explode('.', $filename);
988
-		$ext		= array_pop($parts);
989
-		$filename	= array_shift($parts);
987
+		$parts = explode('.', $filename);
988
+		$ext = array_pop($parts);
989
+		$filename = array_shift($parts);
990 990
 
991 991
 		foreach ($parts as $part)
992 992
 		{
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 	protected function _file_mime_type($file)
1020 1020
 	{
1021 1021
 		// Use if the Fileinfo extension, if available (only versions above 5.3 support the FILEINFO_MIME_TYPE flag)
1022
-		if ( (float) substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file'))
1022
+		if ((float)substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file'))
1023 1023
 		{
1024 1024
 			$finfo = new finfo(FILEINFO_MIME_TYPE);
1025 1025
 			if ($finfo !== FALSE) // This is possible, if there is no magic MIME database file found on the system
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 		if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec'))
1056 1056
 		{
1057 1057
 			$output = array();
1058
-			@exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code);
1058
+			@exec('file --brief --mime-type '.escapeshellarg($file['tmp_path']), $output, $return_code);
1059 1059
 			if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution
1060 1060
 			{
1061 1061
 				$this->file_type = rtrim($output[0]);
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Email.php 1 patch
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -29,51 +29,51 @@  discard block
 block discarded – undo
29 29
 class CI_Email {
30 30
 
31 31
 	var	$useragent		= "CodeIgniter";
32
-	var	$mailpath		= "/usr/sbin/sendmail";	// Sendmail path
33
-	var	$protocol		= "mail";	// mail/sendmail/smtp
34
-	var	$smtp_host		= "";		// SMTP Server.  Example: mail.earthlink.net
35
-	var	$smtp_user		= "";		// SMTP Username
36
-	var	$smtp_pass		= "";		// SMTP Password
37
-	var	$smtp_port		= "25";		// SMTP Port
38
-	var	$smtp_timeout	= 5;		// SMTP Timeout in seconds
39
-	var	$smtp_crypto	= "";		// SMTP Encryption. Can be null, tls or ssl.
40
-	var	$wordwrap		= TRUE;		// TRUE/FALSE  Turns word-wrap on/off
41
-	var	$wrapchars		= "76";		// Number of characters to wrap at.
42
-	var	$mailtype		= "text";	// text/html  Defines email formatting
43
-	var	$charset		= "utf-8";	// Default char set: iso-8859-1 or us-ascii
44
-	var	$multipart		= "mixed";	// "mixed" (in the body) or "related" (separate)
45
-	var $alt_message	= '';		// Alternative message for HTML emails
46
-	var	$validate		= FALSE;	// TRUE/FALSE.  Enables email validation
47
-	var	$priority		= "3";		// Default priority (1 - 5)
48
-	var	$newline		= "\n";		// Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
49
-	var $crlf			= "\n";		// The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
32
+	var	$mailpath		= "/usr/sbin/sendmail"; // Sendmail path
33
+	var	$protocol		= "mail"; // mail/sendmail/smtp
34
+	var	$smtp_host		= ""; // SMTP Server.  Example: mail.earthlink.net
35
+	var	$smtp_user		= ""; // SMTP Username
36
+	var	$smtp_pass		= ""; // SMTP Password
37
+	var	$smtp_port		= "25"; // SMTP Port
38
+	var	$smtp_timeout = 5; // SMTP Timeout in seconds
39
+	var	$smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
40
+	var	$wordwrap		= TRUE; // TRUE/FALSE  Turns word-wrap on/off
41
+	var	$wrapchars		= "76"; // Number of characters to wrap at.
42
+	var	$mailtype		= "text"; // text/html  Defines email formatting
43
+	var	$charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
44
+	var	$multipart		= "mixed"; // "mixed" (in the body) or "related" (separate)
45
+	var $alt_message = ''; // Alternative message for HTML emails
46
+	var	$validate		= FALSE; // TRUE/FALSE.  Enables email validation
47
+	var	$priority		= "3"; // Default priority (1 - 5)
48
+	var	$newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
49
+	var $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
50 50
 									// even on the receiving end think they need to muck with CRLFs, so using "\n", while
51 51
 									// distasteful, is the only thing that seems to work for all environments.
52
-	var $send_multipart	= TRUE;		// TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
53
-	var	$bcc_batch_mode	= FALSE;	// TRUE/FALSE  Turns on/off Bcc batch feature
54
-	var	$bcc_batch_size	= 200;		// If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
52
+	var $send_multipart	= TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
53
+	var	$bcc_batch_mode	= FALSE; // TRUE/FALSE  Turns on/off Bcc batch feature
54
+	var	$bcc_batch_size	= 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
55 55
 	var $_safe_mode		= FALSE;
56
-	var	$_subject		= "";
57
-	var	$_body			= "";
56
+	var	$_subject = "";
57
+	var	$_body = "";
58 58
 	var	$_finalbody		= "";
59 59
 	var	$_alt_boundary	= "";
60 60
 	var	$_atc_boundary	= "";
61 61
 	var	$_header_str	= "";
62 62
 	var	$_smtp_connect	= "";
63
-	var	$_encoding		= "8bit";
64
-	var $_IP			= FALSE;
63
+	var	$_encoding = "8bit";
64
+	var $_IP = FALSE;
65 65
 	var	$_smtp_auth		= FALSE;
66
-	var $_replyto_flag	= FALSE;
66
+	var $_replyto_flag = FALSE;
67 67
 	var	$_debug_msg		= array();
68 68
 	var	$_recipients	= array();
69
-	var	$_cc_array		= array();
69
+	var	$_cc_array = array();
70 70
 	var	$_bcc_array		= array();
71
-	var	$_headers		= array();
71
+	var	$_headers = array();
72 72
 	var	$_attach_name	= array();
73 73
 	var	$_attach_type	= array();
74 74
 	var	$_attach_disp	= array();
75 75
 	var	$_protocols		= array('mail', 'sendmail', 'smtp');
76
-	var	$_base_charsets	= array('us-ascii', 'iso-2022-');	// 7-bit charsets (excluding language suffix)
76
+	var	$_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
77 77
 	var	$_bit_depths	= array('7bit', '8bit');
78 78
 	var	$_priorities	= array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
79 79
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function clear($clear_attachments = FALSE)
145 145
 	{
146
-		$this->_subject		= "";
147
-		$this->_body		= "";
148
-		$this->_finalbody	= "";
146
+		$this->_subject = "";
147
+		$this->_body = "";
148
+		$this->_finalbody = "";
149 149
 		$this->_header_str	= "";
150 150
 		$this->_replyto_flag = FALSE;
151 151
 		$this->_recipients	= array();
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function from($from, $name = '')
181 181
 	{
182
-		if (preg_match( '/\<(.*)\>/', $from, $match))
182
+		if (preg_match('/\<(.*)\>/', $from, $match))
183 183
 		{
184 184
 			$from = $match['1'];
185 185
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function reply_to($replyto, $name = '')
224 224
 	{
225
-		if (preg_match( '/\<(.*)\>/', $replyto, $match))
225
+		if (preg_match('/\<(.*)\>/', $replyto, $match))
226 226
 		{
227 227
 			$replyto = $match['1'];
228 228
 		}
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 	{
555 555
 		if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
556 556
 		{
557
-			$this->newline	= "\n";
557
+			$this->newline = "\n";
558 558
 			return;
559 559
 		}
560 560
 
561
-		$this->newline	= $newline;
561
+		$this->newline = $newline;
562 562
 
563 563
 		return $this;
564 564
 	}
@@ -576,11 +576,11 @@  discard block
 block discarded – undo
576 576
 	{
577 577
 		if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
578 578
 		{
579
-			$this->crlf	= "\n";
579
+			$this->crlf = "\n";
580 580
 			return;
581 581
 		}
582 582
 
583
-		$this->crlf	= $crlf;
583
+		$this->crlf = $crlf;
584 584
 
585 585
 		return $this;
586 586
 	}
@@ -673,15 +673,15 @@  discard block
 block discarded – undo
673 673
 	 */
674 674
 	protected function _get_content_type()
675 675
 	{
676
-		if	($this->mailtype == 'html' &&  count($this->_attach_name) == 0)
676
+		if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
677 677
 		{
678 678
 			return 'html';
679 679
 		}
680
-		elseif	($this->mailtype == 'html' &&  count($this->_attach_name)  > 0)
680
+		elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
681 681
 		{
682 682
 			return 'html-attach';
683 683
 		}
684
-		elseif	($this->mailtype == 'text' &&  count($this->_attach_name)  > 0)
684
+		elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
685 685
 		{
686 686
 			return 'plain-attach';
687 687
 		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		$timezone = date("Z");
705 705
 		$operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
706 706
 		$timezone = abs($timezone);
707
-		$timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60;
707
+		$timezone = floor($timezone / 3600) * 100 + ($timezone % 3600) / 60;
708 708
 
709 709
 		return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
710 710
 	}
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 
793 793
 		foreach ($email as $addy)
794 794
 		{
795
-			if (preg_match( '/\<(.*)\>/', $addy, $match))
795
+			if (preg_match('/\<(.*)\>/', $addy, $match))
796 796
 			{
797 797
 				$clean_email[] = $match['1'];
798 798
 			}
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
 		}
836 836
 
837 837
 		$body = trim(strip_tags($body));
838
-		$body = preg_replace( '#<!--(.*)--\>#', "", $body);
838
+		$body = preg_replace('#<!--(.*)--\>#', "", $body);
839 839
 		$body = str_replace("\t", "", $body);
840 840
 
841 841
 		for ($i = 20; $i >= 3; $i--)
842 842
 		{
843 843
 			$n = "";
844 844
 
845
-			for ($x = 1; $x <= $i; $x ++)
845
+			for ($x = 1; $x <= $i; $x++)
846 846
 			{
847 847
 				$n .= "\n";
848 848
 			}
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
 				}
920 920
 
921 921
 				// Trim the word down
922
-				$temp .= substr($line, 0, $charlim-1);
923
-				$line = substr($line, $charlim-1);
922
+				$temp .= substr($line, 0, $charlim - 1);
923
+				$line = substr($line, $charlim - 1);
924 924
 			}
925 925
 
926 926
 			// If $temp contains data it means we had to split up an over-length
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 	 */
1013 1013
 	protected function _build_message()
1014 1014
 	{
1015
-		if ($this->wordwrap === TRUE  AND  $this->mailtype != 'html')
1015
+		if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
1016 1016
 		{
1017 1017
 			$this->_body = $this->word_wrap($this->_body);
1018 1018
 		}
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 		{
1028 1028
 			case 'plain' :
1029 1029
 
1030
-				$hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1031
-				$hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
1030
+				$hdr .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1031
+				$hdr .= "Content-Transfer-Encoding: ".$this->_get_encoding();
1032 1032
 
1033 1033
 				if ($this->_get_protocol() == 'mail')
1034 1034
 				{
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 				}
1038 1038
 				else
1039 1039
 				{
1040
-					$this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body;
1040
+					$this->_finalbody = $hdr.$this->newline.$this->newline.$this->_body;
1041 1041
 				}
1042 1042
 
1043 1043
 				return;
@@ -1047,25 +1047,25 @@  discard block
 block discarded – undo
1047 1047
 
1048 1048
 				if ($this->send_multipart === FALSE)
1049 1049
 				{
1050
-					$hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1050
+					$hdr .= "Content-Type: text/html; charset=".$this->charset.$this->newline;
1051 1051
 					$hdr .= "Content-Transfer-Encoding: quoted-printable";
1052 1052
 				}
1053 1053
 				else
1054 1054
 				{
1055
-					$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
1055
+					$hdr .= "Content-Type: multipart/alternative; boundary=\"".$this->_alt_boundary."\"".$this->newline.$this->newline;
1056 1056
 
1057
-					$body .= $this->_get_mime_message() . $this->newline . $this->newline;
1058
-					$body .= "--" . $this->_alt_boundary . $this->newline;
1057
+					$body .= $this->_get_mime_message().$this->newline.$this->newline;
1058
+					$body .= "--".$this->_alt_boundary.$this->newline;
1059 1059
 
1060
-					$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1061
-					$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
1062
-					$body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
1060
+					$body .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1061
+					$body .= "Content-Transfer-Encoding: ".$this->_get_encoding().$this->newline.$this->newline;
1062
+					$body .= $this->_get_alt_message().$this->newline.$this->newline."--".$this->_alt_boundary.$this->newline;
1063 1063
 
1064
-					$body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1065
-					$body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
1064
+					$body .= "Content-Type: text/html; charset=".$this->charset.$this->newline;
1065
+					$body .= "Content-Transfer-Encoding: quoted-printable".$this->newline.$this->newline;
1066 1066
 				}
1067 1067
 
1068
-				$this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
1068
+				$this->_finalbody = $body.$this->_prep_quoted_printable($this->_body).$this->newline.$this->newline;
1069 1069
 
1070 1070
 
1071 1071
 				if ($this->_get_protocol() == 'mail')
@@ -1074,13 +1074,13 @@  discard block
 block discarded – undo
1074 1074
 				}
1075 1075
 				else
1076 1076
 				{
1077
-					$this->_finalbody = $hdr . $this->_finalbody;
1077
+					$this->_finalbody = $hdr.$this->_finalbody;
1078 1078
 				}
1079 1079
 
1080 1080
 
1081 1081
 				if ($this->send_multipart !== FALSE)
1082 1082
 				{
1083
-					$this->_finalbody .= "--" . $this->_alt_boundary . "--";
1083
+					$this->_finalbody .= "--".$this->_alt_boundary."--";
1084 1084
 				}
1085 1085
 
1086 1086
 				return;
@@ -1088,46 +1088,46 @@  discard block
 block discarded – undo
1088 1088
 			break;
1089 1089
 			case 'plain-attach' :
1090 1090
 
1091
-				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
1091
+				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"".$this->_atc_boundary."\"".$this->newline.$this->newline;
1092 1092
 
1093 1093
 				if ($this->_get_protocol() == 'mail')
1094 1094
 				{
1095 1095
 					$this->_header_str .= $hdr;
1096 1096
 				}
1097 1097
 
1098
-				$body .= $this->_get_mime_message() . $this->newline . $this->newline;
1099
-				$body .= "--" . $this->_atc_boundary . $this->newline;
1098
+				$body .= $this->_get_mime_message().$this->newline.$this->newline;
1099
+				$body .= "--".$this->_atc_boundary.$this->newline;
1100 1100
 
1101
-				$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1102
-				$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
1101
+				$body .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1102
+				$body .= "Content-Transfer-Encoding: ".$this->_get_encoding().$this->newline.$this->newline;
1103 1103
 
1104
-				$body .= $this->_body . $this->newline . $this->newline;
1104
+				$body .= $this->_body.$this->newline.$this->newline;
1105 1105
 
1106 1106
 			break;
1107 1107
 			case 'html-attach' :
1108 1108
 
1109
-				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
1109
+				$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"".$this->_atc_boundary."\"".$this->newline.$this->newline;
1110 1110
 
1111 1111
 				if ($this->_get_protocol() == 'mail')
1112 1112
 				{
1113 1113
 					$this->_header_str .= $hdr;
1114 1114
 				}
1115 1115
 
1116
-				$body .= $this->_get_mime_message() . $this->newline . $this->newline;
1117
-				$body .= "--" . $this->_atc_boundary . $this->newline;
1116
+				$body .= $this->_get_mime_message().$this->newline.$this->newline;
1117
+				$body .= "--".$this->_atc_boundary.$this->newline;
1118 1118
 
1119
-				$body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
1120
-				$body .= "--" . $this->_alt_boundary . $this->newline;
1119
+				$body .= "Content-Type: multipart/alternative; boundary=\"".$this->_alt_boundary."\"".$this->newline.$this->newline;
1120
+				$body .= "--".$this->_alt_boundary.$this->newline;
1121 1121
 
1122
-				$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
1123
-				$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
1124
-				$body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
1122
+				$body .= "Content-Type: text/plain; charset=".$this->charset.$this->newline;
1123
+				$body .= "Content-Transfer-Encoding: ".$this->_get_encoding().$this->newline.$this->newline;
1124
+				$body .= $this->_get_alt_message().$this->newline.$this->newline."--".$this->_alt_boundary.$this->newline;
1125 1125
 
1126
-				$body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
1127
-				$body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
1126
+				$body .= "Content-Type: text/html; charset=".$this->charset.$this->newline;
1127
+				$body .= "Content-Transfer-Encoding: quoted-printable".$this->newline.$this->newline;
1128 1128
 
1129
-				$body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
1130
-				$body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
1129
+				$body .= $this->_prep_quoted_printable($this->_body).$this->newline.$this->newline;
1130
+				$body .= "--".$this->_alt_boundary."--".$this->newline.$this->newline;
1131 1131
 
1132 1132
 			break;
1133 1133
 		}
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 
1137 1137
 		$z = 0;
1138 1138
 
1139
-		for ($i=0; $i < count($this->_attach_name); $i++)
1139
+		for ($i = 0; $i < count($this->_attach_name); $i++)
1140 1140
 		{
1141 1141
 			$filename = $this->_attach_name[$i];
1142 1142
 			$basename = basename($filename);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$h .= "Content-Transfer-Encoding: base64".$this->newline;
1156 1156
 
1157 1157
 			$attachment[$z++] = $h;
1158
-			$file = filesize($filename) +1;
1158
+			$file = filesize($filename) + 1;
1159 1159
 
1160 1160
 			if ( ! $fp = fopen($filename, FOPEN_READ))
1161 1161
 			{
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 		}
1177 1177
 		else
1178 1178
 		{
1179
-			$this->_finalbody = $hdr . $body;
1179
+			$this->_finalbody = $hdr.$body;
1180 1180
 		}
1181 1181
 
1182 1182
 		return;
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 				// encode = signs
1251 1251
 				if ($ascii == '61')
1252 1252
 				{
1253
-					$char = $escape.strtoupper(sprintf('%02s', dechex($ascii)));  // =3D
1253
+					$char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D
1254 1254
 				}
1255 1255
 
1256 1256
 				// If we're at the character limit, add the line to the output,
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 			$this->reply_to($this->_headers['From']);
1363 1363
 		}
1364 1364
 
1365
-		if (( ! isset($this->_recipients) AND ! isset($this->_headers['To']))  AND
1365
+		if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND
1366 1366
 			( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
1367 1367
 			( ! isset($this->_headers['Cc'])))
1368 1368
 		{
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
 		$this->_build_headers();
1374 1374
 
1375
-		if ($this->bcc_batch_mode  AND  count($this->_bcc_array) > 0)
1375
+		if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
1376 1376
 		{
1377 1377
 			if (count($this->_bcc_array) > $this->bcc_batch_size)
1378 1378
 				return $this->batch_bcc_send();
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	 */
1401 1401
 	public function batch_bcc_send()
1402 1402
 	{
1403
-		$float = $this->bcc_batch_size -1;
1403
+		$float = $this->bcc_batch_size - 1;
1404 1404
 
1405 1405
 		$set = "";
1406 1406
 
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 				$set = "";
1421 1421
 			}
1422 1422
 
1423
-			if ($i == count($this->_bcc_array)-1)
1423
+			if ($i == count($this->_bcc_array) - 1)
1424 1424
 			{
1425 1425
 				$chunk[] = substr($set, 1);
1426 1426
 			}
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 	 */
1572 1572
 	protected function _send_with_sendmail()
1573 1573
 	{
1574
-		$fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
1574
+		$fp = @popen($this->mailpath." -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
1575 1575
 
1576 1576
 		if ($fp === FALSE OR $fp === NULL)
1577 1577
 		{
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 		$this->_send_command('data');
1651 1651
 
1652 1652
 		// perform dot transformation on any lines that begin with a dot
1653
-		$this->_send_data($this->_header_str . preg_replace('/^\./m', '..$1', $this->_finalbody));
1653
+		$this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody));
1654 1654
 
1655 1655
 		$this->_send_data('.');
1656 1656
 
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 			return TRUE;
1795 1795
 		}
1796 1796
 
1797
-		if ($this->smtp_user == ""  AND  $this->smtp_pass == "")
1797
+		if ($this->smtp_user == "" AND $this->smtp_pass == "")
1798 1798
 		{
1799 1799
 			$this->_set_error_message('lang:email_no_smtp_unpw');
1800 1800
 			return FALSE;
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
 	 */
1844 1844
 	protected function _send_data($data)
1845 1845
 	{
1846
-		if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
1846
+		if ( ! fwrite($this->_smtp_connect, $data.$this->newline))
1847 1847
 		{
1848 1848
 			$this->_set_error_message('lang:email_smtp_data_failure', $data);
1849 1849
 			return FALSE;
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 			$this->_IP = end($x);
1923 1923
 		}
1924 1924
 
1925
-		if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
1925
+		if ( ! preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
1926 1926
 		{
1927 1927
 			$this->_IP = '0.0.0.0';
1928 1928
 		}
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 	 */
1970 1970
 	protected function _set_error_message($msg, $val = '')
1971 1971
 	{
1972
-		$CI =& get_instance();
1972
+		$CI = & get_instance();
1973 1973
 		$CI->lang->load('email');
1974 1974
 
1975 1975
 		if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
 	 */
1994 1994
 	protected function _mime_types($ext = "")
1995 1995
 	{
1996
-		$mimes = array(	'hqx'	=>	'application/mac-binhex40',
1996
+		$mimes = array('hqx'	=>	'application/mac-binhex40',
1997 1997
 						'cpt'	=>	'application/mac-compactpro',
1998 1998
 						'doc'	=>	'application/msword',
1999 1999
 						'bin'	=>	'application/macbinary',
Please login to merge, or discard this patch.