Quiz And Survey Master (Formerly Quiz Master Next) - Version 3.4.1

Version Description

Upgrade for new preview mode, many design changes, and more!

Download this release

Release Info

Developer fpcorso
Plugin Icon 128x128 Quiz And Survey Master (Formerly Quiz Master Next)
Version 3.4.1
Comparing to
See all releases

Code changes from version 3.3.3 to 3.4.1

README.md CHANGED
@@ -1,4 +1,6 @@
1
- quiz_master_next
2
- ================
3
-
4
- Attempting to use github for my plugin
 
 
1
+ Quiz Master Next For WordPress
2
+ ================
3
+
4
+ The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website.
5
+
6
+ Feel free to browse the code and make suggestions/requests. Thanks!
includes/WriteHTML.php CHANGED
@@ -1,110 +1,110 @@
1
- <?php
2
- require('fpdf.php');
3
-
4
- class PDF_HTML extends FPDF
5
- {
6
- var $B=0;
7
- var $I=0;
8
- var $U=0;
9
- var $HREF='';
10
- var $ALIGN='';
11
-
12
- function WriteHTML($html)
13
- {
14
- //HTML parser
15
- $html=str_replace("\n",' ',$html);
16
- $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
17
- foreach($a as $i=>$e)
18
- {
19
- if($i%2==0)
20
- {
21
- //Text
22
- if($this->HREF)
23
- $this->PutLink($this->HREF,$e);
24
- elseif($this->ALIGN=='center')
25
- $this->Cell(0,5,$e,0,1,'C');
26
- else
27
- $this->Write(5,$e);
28
- }
29
- else
30
- {
31
- //Tag
32
- if($e[0]=='/')
33
- $this->CloseTag(strtoupper(substr($e,1)));
34
- else
35
- {
36
- //Extract properties
37
- $a2=explode(' ',$e);
38
- $tag=strtoupper(array_shift($a2));
39
- $prop=array();
40
- foreach($a2 as $v)
41
- {
42
- if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
43
- $prop[strtoupper($a3[1])]=$a3[2];
44
- }
45
- $this->OpenTag($tag,$prop);
46
- }
47
- }
48
- }
49
- }
50
-
51
- function OpenTag($tag,$prop)
52
- {
53
- //Opening tag
54
- if($tag=='B' || $tag=='I' || $tag=='U')
55
- $this->SetStyle($tag,true);
56
- if($tag=='A')
57
- $this->HREF=$prop['HREF'];
58
- if($tag=='BR')
59
- $this->Ln(5);
60
- if($tag=='P')
61
- $this->ALIGN=$prop['ALIGN'];
62
- if($tag=='HR')
63
- {
64
- if( !empty($prop['WIDTH']) )
65
- $Width = $prop['WIDTH'];
66
- else
67
- $Width = $this->w - $this->lMargin-$this->rMargin;
68
- $this->Ln(2);
69
- $x = $this->GetX();
70
- $y = $this->GetY();
71
- $this->SetLineWidth(0.4);
72
- $this->Line($x,$y,$x+$Width,$y);
73
- $this->SetLineWidth(0.2);
74
- $this->Ln(2);
75
- }
76
- }
77
-
78
- function CloseTag($tag)
79
- {
80
- //Closing tag
81
- if($tag=='B' || $tag=='I' || $tag=='U')
82
- $this->SetStyle($tag,false);
83
- if($tag=='A')
84
- $this->HREF='';
85
- if($tag=='P')
86
- $this->ALIGN='';
87
- }
88
-
89
- function SetStyle($tag,$enable)
90
- {
91
- //Modify style and select corresponding font
92
- $this->$tag+=($enable ? 1 : -1);
93
- $style='';
94
- foreach(array('B','I','U') as $s)
95
- if($this->$s>0)
96
- $style.=$s;
97
- $this->SetFont('',$style);
98
- }
99
-
100
- function PutLink($URL,$txt)
101
- {
102
- //Put a hyperlink
103
- $this->SetTextColor(0,0,255);
104
- $this->SetStyle('U',true);
105
- $this->Write(5,$txt,$URL);
106
- $this->SetStyle('U',false);
107
- $this->SetTextColor(0);
108
- }
109
- }
110
- ?>
1
+ <?php
2
+ require('fpdf.php');
3
+
4
+ class PDF_HTML extends FPDF
5
+ {
6
+ var $B=0;
7
+ var $I=0;
8
+ var $U=0;
9
+ var $HREF='';
10
+ var $ALIGN='';
11
+
12
+ function WriteHTML($html)
13
+ {
14
+ //HTML parser
15
+ $html=str_replace("\n",' ',$html);
16
+ $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
17
+ foreach($a as $i=>$e)
18
+ {
19
+ if($i%2==0)
20
+ {
21
+ //Text
22
+ if($this->HREF)
23
+ $this->PutLink($this->HREF,$e);
24
+ elseif($this->ALIGN=='center')
25
+ $this->Cell(0,5,$e,0,1,'C');
26
+ else
27
+ $this->Write(5,$e);
28
+ }
29
+ else
30
+ {
31
+ //Tag
32
+ if($e[0]=='/')
33
+ $this->CloseTag(strtoupper(substr($e,1)));
34
+ else
35
+ {
36
+ //Extract properties
37
+ $a2=explode(' ',$e);
38
+ $tag=strtoupper(array_shift($a2));
39
+ $prop=array();
40
+ foreach($a2 as $v)
41
+ {
42
+ if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
43
+ $prop[strtoupper($a3[1])]=$a3[2];
44
+ }
45
+ $this->OpenTag($tag,$prop);
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ function OpenTag($tag,$prop)
52
+ {
53
+ //Opening tag
54
+ if($tag=='B' || $tag=='I' || $tag=='U')
55
+ $this->SetStyle($tag,true);
56
+ if($tag=='A')
57
+ $this->HREF=$prop['HREF'];
58
+ if($tag=='BR')
59
+ $this->Ln(5);
60
+ if($tag=='P')
61
+ $this->ALIGN=$prop['ALIGN'];
62
+ if($tag=='HR')
63
+ {
64
+ if( !empty($prop['WIDTH']) )
65
+ $Width = $prop['WIDTH'];
66
+ else
67
+ $Width = $this->w - $this->lMargin-$this->rMargin;
68
+ $this->Ln(2);
69
+ $x = $this->GetX();
70
+ $y = $this->GetY();
71
+ $this->SetLineWidth(0.4);
72
+ $this->Line($x,$y,$x+$Width,$y);
73
+ $this->SetLineWidth(0.2);
74
+ $this->Ln(2);
75
+ }
76
+ }
77
+
78
+ function CloseTag($tag)
79
+ {
80
+ //Closing tag
81
+ if($tag=='B' || $tag=='I' || $tag=='U')
82
+ $this->SetStyle($tag,false);
83
+ if($tag=='A')
84
+ $this->HREF='';
85
+ if($tag=='P')
86
+ $this->ALIGN='';
87
+ }
88
+
89
+ function SetStyle($tag,$enable)
90
+ {
91
+ //Modify style and select corresponding font
92
+ $this->$tag+=($enable ? 1 : -1);
93
+ $style='';
94
+ foreach(array('B','I','U') as $s)
95
+ if($this->$s>0)
96
+ $style.=$s;
97
+ $this->SetFont('',$style);
98
+ }
99
+
100
+ function PutLink($URL,$txt)
101
+ {
102
+ //Put a hyperlink
103
+ $this->SetTextColor(0,0,255);
104
+ $this->SetStyle('U',true);
105
+ $this->Write(5,$txt,$URL);
106
+ $this->SetStyle('U',false);
107
+ $this->SetTextColor(0);
108
+ }
109
+ }
110
+ ?>
includes/font/courier.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Courier';
4
- $up = -100;
5
- $ut = 50;
6
- for($i=0;$i<=255;$i++)
7
- $cw[chr($i)] = 600;
8
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Courier';
4
+ $up = -100;
5
+ $ut = 50;
6
+ for($i=0;$i<=255;$i++)
7
+ $cw[chr($i)] = 600;
8
+ ?>
includes/font/courierb.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Courier-Bold';
4
- $up = -100;
5
- $ut = 50;
6
- for($i=0;$i<=255;$i++)
7
- $cw[chr($i)] = 600;
8
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Courier-Bold';
4
+ $up = -100;
5
+ $ut = 50;
6
+ for($i=0;$i<=255;$i++)
7
+ $cw[chr($i)] = 600;
8
+ ?>
includes/font/courierbi.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Courier-BoldOblique';
4
- $up = -100;
5
- $ut = 50;
6
- for($i=0;$i<=255;$i++)
7
- $cw[chr($i)] = 600;
8
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Courier-BoldOblique';
4
+ $up = -100;
5
+ $ut = 50;
6
+ for($i=0;$i<=255;$i++)
7
+ $cw[chr($i)] = 600;
8
+ ?>
includes/font/courieri.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Courier-Oblique';
4
- $up = -100;
5
- $ut = 50;
6
- for($i=0;$i<=255;$i++)
7
- $cw[chr($i)] = 600;
8
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Courier-Oblique';
4
+ $up = -100;
5
+ $ut = 50;
6
+ for($i=0;$i<=255;$i++)
7
+ $cw[chr($i)] = 600;
8
+ ?>
includes/font/helvetica.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Helvetica';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
- chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
- ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
10
- 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
- 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
12
- 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
13
- chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
- chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
16
- chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
18
- chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Helvetica';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
10
+ 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
12
+ 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
13
+ chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
+ chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
16
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
18
+ chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
19
+ ?>
includes/font/helveticab.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Helvetica-Bold';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
- chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
- ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
10
- 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
- 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
12
- 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
13
- chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
- chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
- chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
18
- chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Helvetica-Bold';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
10
+ 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
12
+ 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
13
+ chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
+ chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
18
+ chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
19
+ ?>
includes/font/helveticabi.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Helvetica-BoldOblique';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
- chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
- ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
10
- 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
- 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
12
- 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
13
- chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
- chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
- chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
18
- chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Helvetica-BoldOblique';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
10
+ 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
12
+ 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
13
+ chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
+ chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
18
+ chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
19
+ ?>
includes/font/helveticai.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Helvetica-Oblique';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
- chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
- ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
10
- 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
- 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
12
- 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
13
- chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
- chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
16
- chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
18
- chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Helvetica-Oblique';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
8
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
9
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
10
+ 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
11
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
12
+ 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
13
+ chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
+ chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
16
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
18
+ chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
19
+ ?>
includes/font/symbol.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Symbol';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
- chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
9
- ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
10
- 'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
11
- 'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
12
- 'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
13
- chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
- chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
15
- chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
16
- chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
17
- chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
18
- chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Symbol';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
9
+ ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
10
+ 'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
11
+ 'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
12
+ 'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
13
+ chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
+ chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
15
+ chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
16
+ chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
17
+ chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
18
+ chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
19
+ ?>
includes/font/times.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Times-Roman';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
- chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
9
- ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
10
- 'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
11
- 'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
12
- 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
- chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
14
- chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
- chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
18
- chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Times-Roman';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
9
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
10
+ 'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
11
+ 'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
12
+ 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
+ chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
14
+ chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
+ chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
18
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
19
+ ?>
includes/font/timesb.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Times-Bold';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
- chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
9
- ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
10
- 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
11
- 'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
12
- 'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
- chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
- chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
- chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
18
- chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Times-Bold';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
9
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
10
+ 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
11
+ 'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
12
+ 'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
+ chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
+ chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
16
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
18
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
19
+ ?>
includes/font/timesbi.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Times-BoldItalic';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
- chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
9
- ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
10
- 'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
11
- 'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
12
- 'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
- chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
- chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
16
- chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
18
- chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Times-BoldItalic';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
9
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
10
+ 'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
11
+ 'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
12
+ 'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
+ chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
14
+ chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
16
+ chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
18
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
19
+ ?>
includes/font/timesi.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'Times-Italic';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
- chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
9
- ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
10
- 'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
11
- 'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
12
- 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
- chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
14
- chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
15
- chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
16
- chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
- chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
18
- chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'Times-Italic';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
8
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
9
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
10
+ 'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
11
+ 'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
12
+ 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
13
+ chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
14
+ chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
15
+ chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
16
+ chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
17
+ chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
18
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
19
+ ?>
includes/font/zapfdingbats.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- $type = 'Core';
3
- $name = 'ZapfDingbats';
4
- $up = -100;
5
- $ut = 50;
6
- $cw = array(
7
- chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
8
- chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
9
- ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
10
- 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
11
- 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
12
- 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
13
- chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
- chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
15
- chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
16
- chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
17
- chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
18
- chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
19
- ?>
1
+ <?php
2
+ $type = 'Core';
3
+ $name = 'ZapfDingbats';
4
+ $up = -100;
5
+ $ut = 50;
6
+ $cw = array(
7
+ chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
8
+ chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
9
+ ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
10
+ 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
11
+ 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
12
+ 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
13
+ chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
+ chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
15
+ chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
16
+ chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
17
+ chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
18
+ chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
19
+ ?>
includes/fpdf.php CHANGED
@@ -1,1804 +1,1804 @@
1
- <?php
2
- /*******************************************************************************
3
- * FPDF *
4
- * *
5
- * Version: 1.7 *
6
- * Date: 2011-06-18 *
7
- * Author: Olivier PLATHEY *
8
- *******************************************************************************/
9
-
10
- define('FPDF_VERSION','1.7');
11
-
12
- class FPDF
13
- {
14
- var $page; // current page number
15
- var $n; // current object number
16
- var $offsets; // array of object offsets
17
- var $buffer; // buffer holding in-memory PDF
18
- var $pages; // array containing pages
19
- var $state; // current document state
20
- var $compress; // compression flag
21
- var $k; // scale factor (number of points in user unit)
22
- var $DefOrientation; // default orientation
23
- var $CurOrientation; // current orientation
24
- var $StdPageSizes; // standard page sizes
25
- var $DefPageSize; // default page size
26
- var $CurPageSize; // current page size
27
- var $PageSizes; // used for pages with non default sizes or orientations
28
- var $wPt, $hPt; // dimensions of current page in points
29
- var $w, $h; // dimensions of current page in user unit
30
- var $lMargin; // left margin
31
- var $tMargin; // top margin
32
- var $rMargin; // right margin
33
- var $bMargin; // page break margin
34
- var $cMargin; // cell margin
35
- var $x, $y; // current position in user unit
36
- var $lasth; // height of last printed cell
37
- var $LineWidth; // line width in user unit
38
- var $fontpath; // path containing fonts
39
- var $CoreFonts; // array of core font names
40
- var $fonts; // array of used fonts
41
- var $FontFiles; // array of font files
42
- var $diffs; // array of encoding differences
43
- var $FontFamily; // current font family
44
- var $FontStyle; // current font style
45
- var $underline; // underlining flag
46
- var $CurrentFont; // current font info
47
- var $FontSizePt; // current font size in points
48
- var $FontSize; // current font size in user unit
49
- var $DrawColor; // commands for drawing color
50
- var $FillColor; // commands for filling color
51
- var $TextColor; // commands for text color
52
- var $ColorFlag; // indicates whether fill and text colors are different
53
- var $ws; // word spacing
54
- var $images; // array of used images
55
- var $PageLinks; // array of links in pages
56
- var $links; // array of internal links
57
- var $AutoPageBreak; // automatic page breaking
58
- var $PageBreakTrigger; // threshold used to trigger page breaks
59
- var $InHeader; // flag set when processing header
60
- var $InFooter; // flag set when processing footer
61
- var $ZoomMode; // zoom display mode
62
- var $LayoutMode; // layout display mode
63
- var $title; // title
64
- var $subject; // subject
65
- var $author; // author
66
- var $keywords; // keywords
67
- var $creator; // creator
68
- var $AliasNbPages; // alias for total number of pages
69
- var $PDFVersion; // PDF version number
70
-
71
- /*******************************************************************************
72
- * *
73
- * Public methods *
74
- * *
75
- *******************************************************************************/
76
- function FPDF($orientation='P', $unit='mm', $size='A4')
77
- {
78
- // Some checks
79
- $this->_dochecks();
80
- // Initialization of properties
81
- $this->page = 0;
82
- $this->n = 2;
83
- $this->buffer = '';
84
- $this->pages = array();
85
- $this->PageSizes = array();
86
- $this->state = 0;
87
- $this->fonts = array();
88
- $this->FontFiles = array();
89
- $this->diffs = array();
90
- $this->images = array();
91
- $this->links = array();
92
- $this->InHeader = false;
93
- $this->InFooter = false;
94
- $this->lasth = 0;
95
- $this->FontFamily = '';
96
- $this->FontStyle = '';
97
- $this->FontSizePt = 12;
98
- $this->underline = false;
99
- $this->DrawColor = '0 G';
100
- $this->FillColor = '0 g';
101
- $this->TextColor = '0 g';
102
- $this->ColorFlag = false;
103
- $this->ws = 0;
104
- // Font path
105
- if(defined('FPDF_FONTPATH'))
106
- {
107
- $this->fontpath = FPDF_FONTPATH;
108
- if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
109
- $this->fontpath .= '/';
110
- }
111
- elseif(is_dir(dirname(__FILE__).'/font'))
112
- $this->fontpath = dirname(__FILE__).'/font/';
113
- else
114
- $this->fontpath = '';
115
- // Core fonts
116
- $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
117
- // Scale factor
118
- if($unit=='pt')
119
- $this->k = 1;
120
- elseif($unit=='mm')
121
- $this->k = 72/25.4;
122
- elseif($unit=='cm')
123
- $this->k = 72/2.54;
124
- elseif($unit=='in')
125
- $this->k = 72;
126
- else
127
- $this->Error('Incorrect unit: '.$unit);
128
- // Page sizes
129
- $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
130
- 'letter'=>array(612,792), 'legal'=>array(612,1008));
131
- $size = $this->_getpagesize($size);
132
- $this->DefPageSize = $size;
133
- $this->CurPageSize = $size;
134
- // Page orientation
135
- $orientation = strtolower($orientation);
136
- if($orientation=='p' || $orientation=='portrait')
137
- {
138
- $this->DefOrientation = 'P';
139
- $this->w = $size[0];
140
- $this->h = $size[1];
141
- }
142
- elseif($orientation=='l' || $orientation=='landscape')
143
- {
144
- $this->DefOrientation = 'L';
145
- $this->w = $size[1];
146
- $this->h = $size[0];
147
- }
148
- else
149
- $this->Error('Incorrect orientation: '.$orientation);
150
- $this->CurOrientation = $this->DefOrientation;
151
- $this->wPt = $this->w*$this->k;
152
- $this->hPt = $this->h*$this->k;
153
- // Page margins (1 cm)
154
- $margin = 28.35/$this->k;
155
- $this->SetMargins($margin,$margin);
156
- // Interior cell margin (1 mm)
157
- $this->cMargin = $margin/10;
158
- // Line width (0.2 mm)
159
- $this->LineWidth = .567/$this->k;
160
- // Automatic page break
161
- $this->SetAutoPageBreak(true,2*$margin);
162
- // Default display mode
163
- $this->SetDisplayMode('default');
164
- // Enable compression
165
- $this->SetCompression(true);
166
- // Set default PDF version number
167
- $this->PDFVersion = '1.3';
168
- }
169
-
170
- function SetMargins($left, $top, $right=null)
171
- {
172
- // Set left, top and right margins
173
- $this->lMargin = $left;
174
- $this->tMargin = $top;
175
- if($right===null)
176
- $right = $left;
177
- $this->rMargin = $right;
178
- }
179
-
180
- function SetLeftMargin($margin)
181
- {
182
- // Set left margin
183
- $this->lMargin = $margin;
184
- if($this->page>0 && $this->x<$margin)
185
- $this->x = $margin;
186
- }
187
-
188
- function SetTopMargin($margin)
189
- {
190
- // Set top margin
191
- $this->tMargin = $margin;
192
- }
193
-
194
- function SetRightMargin($margin)
195
- {
196
- // Set right margin
197
- $this->rMargin = $margin;
198
- }
199
-
200
- function SetAutoPageBreak($auto, $margin=0)
201
- {
202
- // Set auto page break mode and triggering margin
203
- $this->AutoPageBreak = $auto;
204
- $this->bMargin = $margin;
205
- $this->PageBreakTrigger = $this->h-$margin;
206
- }
207
-
208
- function SetDisplayMode($zoom, $layout='default')
209
- {
210
- // Set display mode in viewer
211
- if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
212
- $this->ZoomMode = $zoom;
213
- else
214
- $this->Error('Incorrect zoom display mode: '.$zoom);
215
- if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
216
- $this->LayoutMode = $layout;
217
- else
218
- $this->Error('Incorrect layout display mode: '.$layout);
219
- }
220
-
221
- function SetCompression($compress)
222
- {
223
- // Set page compression
224
- if(function_exists('gzcompress'))
225
- $this->compress = $compress;
226
- else
227
- $this->compress = false;
228
- }
229
-
230
- function SetTitle($title, $isUTF8=false)
231
- {
232
- // Title of document
233
- if($isUTF8)
234
- $title = $this->_UTF8toUTF16($title);
235
- $this->title = $title;
236
- }
237
-
238
- function SetSubject($subject, $isUTF8=false)
239
- {
240
- // Subject of document
241
- if($isUTF8)
242
- $subject = $this->_UTF8toUTF16($subject);
243
- $this->subject = $subject;
244
- }
245
-
246
- function SetAuthor($author, $isUTF8=false)
247
- {
248
- // Author of document
249
- if($isUTF8)
250
- $author = $this->_UTF8toUTF16($author);
251
- $this->author = $author;
252
- }
253
-
254
- function SetKeywords($keywords, $isUTF8=false)
255
- {
256
- // Keywords of document
257
- if($isUTF8)
258
- $keywords = $this->_UTF8toUTF16($keywords);
259
- $this->keywords = $keywords;
260
- }
261
-
262
- function SetCreator($creator, $isUTF8=false)
263
- {
264
- // Creator of document
265
- if($isUTF8)
266
- $creator = $this->_UTF8toUTF16($creator);
267
- $this->creator = $creator;
268
- }
269
-
270
- function AliasNbPages($alias='{nb}')
271
- {
272
- // Define an alias for total number of pages
273
- $this->AliasNbPages = $alias;
274
- }
275
-
276
- function Error($msg)
277
- {
278
- // Fatal error
279
- die('<b>FPDF error:</b> '.$msg);
280
- }
281
-
282
- function Open()
283
- {
284
- // Begin document
285
- $this->state = 1;
286
- }
287
-
288
- function Close()
289
- {
290
- // Terminate document
291
- if($this->state==3)
292
- return;
293
- if($this->page==0)
294
- $this->AddPage();
295
- // Page footer
296
- $this->InFooter = true;
297
- $this->Footer();
298
- $this->InFooter = false;
299
- // Close page
300
- $this->_endpage();
301
- // Close document
302
- $this->_enddoc();
303
- }
304
-
305
- function AddPage($orientation='', $size='')
306
- {
307
- // Start a new page
308
- if($this->state==0)
309
- $this->Open();
310
- $family = $this->FontFamily;
311
- $style = $this->FontStyle.($this->underline ? 'U' : '');
312
- $fontsize = $this->FontSizePt;
313
- $lw = $this->LineWidth;
314
- $dc = $this->DrawColor;
315
- $fc = $this->FillColor;
316
- $tc = $this->TextColor;
317
- $cf = $this->ColorFlag;
318
- if($this->page>0)
319
- {
320
- // Page footer
321
- $this->InFooter = true;
322
- $this->Footer();
323
- $this->InFooter = false;
324
- // Close page
325
- $this->_endpage();
326
- }
327
- // Start new page
328
- $this->_beginpage($orientation,$size);
329
- // Set line cap style to square
330
- $this->_out('2 J');
331
- // Set line width
332
- $this->LineWidth = $lw;
333
- $this->_out(sprintf('%.2F w',$lw*$this->k));
334
- // Set font
335
- if($family)
336
- $this->SetFont($family,$style,$fontsize);
337
- // Set colors
338
- $this->DrawColor = $dc;
339
- if($dc!='0 G')
340
- $this->_out($dc);
341
- $this->FillColor = $fc;
342
- if($fc!='0 g')
343
- $this->_out($fc);
344
- $this->TextColor = $tc;
345
- $this->ColorFlag = $cf;
346
- // Page header
347
- $this->InHeader = true;
348
- $this->Header();
349
- $this->InHeader = false;
350
- // Restore line width
351
- if($this->LineWidth!=$lw)
352
- {
353
- $this->LineWidth = $lw;
354
- $this->_out(sprintf('%.2F w',$lw*$this->k));
355
- }
356
- // Restore font
357
- if($family)
358
- $this->SetFont($family,$style,$fontsize);
359
- // Restore colors
360
- if($this->DrawColor!=$dc)
361
- {
362
- $this->DrawColor = $dc;
363
- $this->_out($dc);
364
- }
365
- if($this->FillColor!=$fc)
366
- {
367
- $this->FillColor = $fc;
368
- $this->_out($fc);
369
- }
370
- $this->TextColor = $tc;
371
- $this->ColorFlag = $cf;
372
- }
373
-
374
- function Header()
375
- {
376
- // To be implemented in your own inherited class
377
- }
378
-
379
- function Footer()
380
- {
381
- // To be implemented in your own inherited class
382
- }
383
-
384
- function PageNo()
385
- {
386
- // Get current page number
387
- return $this->page;
388
- }
389
-
390
- function SetDrawColor($r, $g=null, $b=null)
391
- {
392
- // Set color for all stroking operations
393
- if(($r==0 && $g==0 && $b==0) || $g===null)
394
- $this->DrawColor = sprintf('%.3F G',$r/255);
395
- else
396
- $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
397
- if($this->page>0)
398
- $this->_out($this->DrawColor);
399
- }
400
-
401
- function SetFillColor($r, $g=null, $b=null)
402
- {
403
- // Set color for all filling operations
404
- if(($r==0 && $g==0 && $b==0) || $g===null)
405
- $this->FillColor = sprintf('%.3F g',$r/255);
406
- else
407
- $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
408
- $this->ColorFlag = ($this->FillColor!=$this->TextColor);
409
- if($this->page>0)
410
- $this->_out($this->FillColor);
411
- }
412
-
413
- function SetTextColor($r, $g=null, $b=null)
414
- {
415
- // Set color for text
416
- if(($r==0 && $g==0 && $b==0) || $g===null)
417
- $this->TextColor = sprintf('%.3F g',$r/255);
418
- else
419
- $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
420
- $this->ColorFlag = ($this->FillColor!=$this->TextColor);
421
- }
422
-
423
- function GetStringWidth($s)
424
- {
425
- // Get width of a string in the current font
426
- $s = (string)$s;
427
- $cw = &$this->CurrentFont['cw'];
428
- $w = 0;
429
- $l = strlen($s);
430
- for($i=0;$i<$l;$i++)
431
- $w += $cw[$s[$i]];
432
- return $w*$this->FontSize/1000;
433
- }
434
-
435
- function SetLineWidth($width)
436
- {
437
- // Set line width
438
- $this->LineWidth = $width;
439
- if($this->page>0)
440
- $this->_out(sprintf('%.2F w',$width*$this->k));
441
- }
442
-
443
- function Line($x1, $y1, $x2, $y2)
444
- {
445
- // Draw a line
446
- $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));
447
- }
448
-
449
- function Rect($x, $y, $w, $h, $style='')
450
- {
451
- // Draw a rectangle
452
- if($style=='F')
453
- $op = 'f';
454
- elseif($style=='FD' || $style=='DF')
455
- $op = 'B';
456
- else
457
- $op = 'S';
458
- $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
459
- }
460
-
461
- function AddFont($family, $style='', $file='')
462
- {
463
- // Add a TrueType, OpenType or Type1 font
464
- $family = strtolower($family);
465
- if($file=='')
466
- $file = str_replace(' ','',$family).strtolower($style).'.php';
467
- $style = strtoupper($style);
468
- if($style=='IB')
469
- $style = 'BI';
470
- $fontkey = $family.$style;
471
- if(isset($this->fonts[$fontkey]))
472
- return;
473
- $info = $this->_loadfont($file);
474
- $info['i'] = count($this->fonts)+1;
475
- if(!empty($info['diff']))
476
- {
477
- // Search existing encodings
478
- $n = array_search($info['diff'],$this->diffs);
479
- if(!$n)
480
- {
481
- $n = count($this->diffs)+1;
482
- $this->diffs[$n] = $info['diff'];
483
- }
484
- $info['diffn'] = $n;
485
- }
486
- if(!empty($info['file']))
487
- {
488
- // Embedded font
489
- if($info['type']=='TrueType')
490
- $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
491
- else
492
- $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
493
- }
494
- $this->fonts[$fontkey] = $info;
495
- }
496
-
497
- function SetFont($family, $style='', $size=0)
498
- {
499
- // Select a font; size given in points
500
- if($family=='')
501
- $family = $this->FontFamily;
502
- else
503
- $family = strtolower($family);
504
- $style = strtoupper($style);
505
- if(strpos($style,'U')!==false)
506
- {
507
- $this->underline = true;
508
- $style = str_replace('U','',$style);
509
- }
510
- else
511
- $this->underline = false;
512
- if($style=='IB')
513
- $style = 'BI';
514
- if($size==0)
515
- $size = $this->FontSizePt;
516
- // Test if font is already selected
517
- if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
518
- return;
519
- // Test if font is already loaded
520
- $fontkey = $family.$style;
521
- if(!isset($this->fonts[$fontkey]))
522
- {
523
- // Test if one of the core fonts
524
- if($family=='arial')
525
- $family = 'helvetica';
526
- if(in_array($family,$this->CoreFonts))
527
- {
528
- if($family=='symbol' || $family=='zapfdingbats')
529
- $style = '';
530
- $fontkey = $family.$style;
531
- if(!isset($this->fonts[$fontkey]))
532
- $this->AddFont($family,$style);
533
- }
534
- else
535
- $this->Error('Undefined font: '.$family.' '.$style);
536
- }
537
- // Select it
538
- $this->FontFamily = $family;
539
- $this->FontStyle = $style;
540
- $this->FontSizePt = $size;
541
- $this->FontSize = $size/$this->k;
542
- $this->CurrentFont = &$this->fonts[$fontkey];
543
- if($this->page>0)
544
- $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
545
- }
546
-
547
- function SetFontSize($size)
548
- {
549
- // Set font size in points
550
- if($this->FontSizePt==$size)
551
- return;
552
- $this->FontSizePt = $size;
553
- $this->FontSize = $size/$this->k;
554
- if($this->page>0)
555
- $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
556
- }
557
-
558
- function AddLink()
559
- {
560
- // Create a new internal link
561
- $n = count($this->links)+1;
562
- $this->links[$n] = array(0, 0);
563
- return $n;
564
- }
565
-
566
- function SetLink($link, $y=0, $page=-1)
567
- {
568
- // Set destination of internal link
569
- if($y==-1)
570
- $y = $this->y;
571
- if($page==-1)
572
- $page = $this->page;
573
- $this->links[$link] = array($page, $y);
574
- }
575
-
576
- function Link($x, $y, $w, $h, $link)
577
- {
578
- // Put a link on the page
579
- $this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
580
- }
581
-
582
- function Text($x, $y, $txt)
583
- {
584
- // Output a string
585
- $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
586
- if($this->underline && $txt!='')
587
- $s .= ' '.$this->_dounderline($x,$y,$txt);
588
- if($this->ColorFlag)
589
- $s = 'q '.$this->TextColor.' '.$s.' Q';
590
- $this->_out($s);
591
- }
592
-
593
- function AcceptPageBreak()
594
- {
595
- // Accept automatic page break or not
596
- return $this->AutoPageBreak;
597
- }
598
-
599
- function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
600
- {
601
- // Output a cell
602
- $k = $this->k;
603
- if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
604
- {
605
- // Automatic page break
606
- $x = $this->x;
607
- $ws = $this->ws;
608
- if($ws>0)
609
- {
610
- $this->ws = 0;
611
- $this->_out('0 Tw');
612
- }
613
- $this->AddPage($this->CurOrientation,$this->CurPageSize);
614
- $this->x = $x;
615
- if($ws>0)
616
- {
617
- $this->ws = $ws;
618
- $this->_out(sprintf('%.3F Tw',$ws*$k));
619
- }
620
- }
621
- if($w==0)
622
- $w = $this->w-$this->rMargin-$this->x;
623
- $s = '';
624
- if($fill || $border==1)
625
- {
626
- if($fill)
627
- $op = ($border==1) ? 'B' : 'f';
628
- else
629
- $op = 'S';
630
- $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
631
- }
632
- if(is_string($border))
633
- {
634
- $x = $this->x;
635
- $y = $this->y;
636
- if(strpos($border,'L')!==false)
637
- $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
638
- if(strpos($border,'T')!==false)
639
- $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
640
- if(strpos($border,'R')!==false)
641
- $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
642
- if(strpos($border,'B')!==false)
643
- $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
644
- }
645
- if($txt!=='')
646
- {
647
- if($align=='R')
648
- $dx = $w-$this->cMargin-$this->GetStringWidth($txt);
649
- elseif($align=='C')
650
- $dx = ($w-$this->GetStringWidth($txt))/2;
651
- else
652
- $dx = $this->cMargin;
653
- if($this->ColorFlag)
654
- $s .= 'q '.$this->TextColor.' ';
655
- $txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
656
- $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
657
- if($this->underline)
658
- $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
659
- if($this->ColorFlag)
660
- $s .= ' Q';
661
- if($link)
662
- $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
663
- }
664
- if($s)
665
- $this->_out($s);
666
- $this->lasth = $h;
667
- if($ln>0)
668
- {
669
- // Go to next line
670
- $this->y += $h;
671
- if($ln==1)
672
- $this->x = $this->lMargin;
673
- }
674
- else
675
- $this->x += $w;
676
- }
677
-
678
- function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
679
- {
680
- // Output text with automatic or explicit line breaks
681
- $cw = &$this->CurrentFont['cw'];
682
- if($w==0)
683
- $w = $this->w-$this->rMargin-$this->x;
684
- $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
685
- $s = str_replace("\r",'',$txt);
686
- $nb = strlen($s);
687
- if($nb>0 && $s[$nb-1]=="\n")
688
- $nb--;
689
- $b = 0;
690
- if($border)
691
- {
692
- if($border==1)
693
- {
694
- $border = 'LTRB';
695
- $b = 'LRT';
696
- $b2 = 'LR';
697
- }
698
- else
699
- {
700
- $b2 = '';
701
- if(strpos($border,'L')!==false)
702
- $b2 .= 'L';
703
- if(strpos($border,'R')!==false)
704
- $b2 .= 'R';
705
- $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
706
- }
707
- }
708
- $sep = -1;
709
- $i = 0;
710
- $j = 0;
711
- $l = 0;
712
- $ns = 0;
713
- $nl = 1;
714
- while($i<$nb)
715
- {
716
- // Get next character
717
- $c = $s[$i];
718
- if($c=="\n")
719
- {
720
- // Explicit line break
721
- if($this->ws>0)
722
- {
723
- $this->ws = 0;
724
- $this->_out('0 Tw');
725
- }
726
- $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
727
- $i++;
728
- $sep = -1;
729
- $j = $i;
730
- $l = 0;
731
- $ns = 0;
732
- $nl++;
733
- if($border && $nl==2)
734
- $b = $b2;
735
- continue;
736
- }
737
- if($c==' ')
738
- {
739
- $sep = $i;
740
- $ls = $l;
741
- $ns++;
742
- }
743
- $l += $cw[$c];
744
- if($l>$wmax)
745
- {
746
- // Automatic line break
747
- if($sep==-1)
748
- {
749
- if($i==$j)
750
- $i++;
751
- if($this->ws>0)
752
- {
753
- $this->ws = 0;
754
- $this->_out('0 Tw');
755
- }
756
- $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
757
- }
758
- else
759
- {
760
- if($align=='J')
761
- {
762
- $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
763
- $this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
764
- }
765
- $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
766
- $i = $sep+1;
767
- }
768
- $sep = -1;
769
- $j = $i;
770
- $l = 0;
771
- $ns = 0;
772
- $nl++;
773
- if($border && $nl==2)
774
- $b = $b2;
775
- }
776
- else
777
- $i++;
778
- }
779
- // Last chunk
780
- if($this->ws>0)
781
- {
782
- $this->ws = 0;
783
- $this->_out('0 Tw');
784
- }
785
- if($border && strpos($border,'B')!==false)
786
- $b .= 'B';
787
- $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
788
- $this->x = $this->lMargin;
789
- }
790
-
791
- function Write($h, $txt, $link='')
792
- {
793
- // Output text in flowing mode
794
- $cw = &$this->CurrentFont['cw'];
795
- $w = $this->w-$this->rMargin-$this->x;
796
- $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
797
- $s = str_replace("\r",'',$txt);
798
- $nb = strlen($s);
799
- $sep = -1;
800
- $i = 0;
801
- $j = 0;
802
- $l = 0;
803
- $nl = 1;
804
- while($i<$nb)
805
- {
806
- // Get next character
807
- $c = $s[$i];
808
- if($c=="\n")
809
- {
810
- // Explicit line break
811
- $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
812
- $i++;
813
- $sep = -1;
814
- $j = $i;
815
- $l = 0;
816
- if($nl==1)
817
- {
818
- $this->x = $this->lMargin;
819
- $w = $this->w-$this->rMargin-$this->x;
820
- $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
821
- }
822
- $nl++;
823
- continue;
824
- }
825
- if($c==' ')
826
- $sep = $i;
827
- $l += $cw[$c];
828
- if($l>$wmax)
829
- {
830
- // Automatic line break
831
- if($sep==-1)
832
- {
833
- if($this->x>$this->lMargin)
834
- {
835
- // Move to next line
836
- $this->x = $this->lMargin;
837
- $this->y += $h;
838
- $w = $this->w-$this->rMargin-$this->x;
839
- $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
840
- $i++;
841
- $nl++;
842
- continue;
843
- }
844
- if($i==$j)
845
- $i++;
846
- $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
847
- }
848
- else
849
- {
850
- $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
851
- $i = $sep+1;
852
- }
853
- $sep = -1;
854
- $j = $i;
855
- $l = 0;
856
- if($nl==1)
857
- {
858
- $this->x = $this->lMargin;
859
- $w = $this->w-$this->rMargin-$this->x;
860
- $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
861
- }
862
- $nl++;
863
- }
864
- else
865
- $i++;
866
- }
867
- // Last chunk
868
- if($i!=$j)
869
- $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
870
- }
871
-
872
- function Ln($h=null)
873
- {
874
- // Line feed; default value is last cell height
875
- $this->x = $this->lMargin;
876
- if($h===null)
877
- $this->y += $this->lasth;
878
- else
879
- $this->y += $h;
880
- }
881
-
882
- function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
883
- {
884
- // Put an image on the page
885
- if(!isset($this->images[$file]))
886
- {
887
- // First use of this image, get info
888
- if($type=='')
889
- {
890
- $pos = strrpos($file,'.');
891
- if(!$pos)
892
- $this->Error('Image file has no extension and no type was specified: '.$file);
893
- $type = substr($file,$pos+1);
894
- }
895
- $type = strtolower($type);
896
- if($type=='jpeg')
897
- $type = 'jpg';
898
- $mtd = '_parse'.$type;
899
- if(!method_exists($this,$mtd))
900
- $this->Error('Unsupported image type: '.$type);
901
- $info = $this->$mtd($file);
902
- $info['i'] = count($this->images)+1;
903
- $this->images[$file] = $info;
904
- }
905
- else
906
- $info = $this->images[$file];
907
-
908
- // Automatic width and height calculation if needed
909
- if($w==0 && $h==0)
910
- {
911
- // Put image at 96 dpi
912
- $w = -96;
913
- $h = -96;
914
- }
915
- if($w<0)
916
- $w = -$info['w']*72/$w/$this->k;
917
- if($h<0)
918
- $h = -$info['h']*72/$h/$this->k;
919
- if($w==0)
920
- $w = $h*$info['w']/$info['h'];
921
- if($h==0)
922
- $h = $w*$info['h']/$info['w'];
923
-
924
- // Flowing mode
925
- if($y===null)
926
- {
927
- if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
928
- {
929
- // Automatic page break
930
- $x2 = $this->x;
931
- $this->AddPage($this->CurOrientation,$this->CurPageSize);
932
- $this->x = $x2;
933
- }
934
- $y = $this->y;
935
- $this->y += $h;
936
- }
937
-
938
- if($x===null)
939
- $x = $this->x;
940
- $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']));
941
- if($link)
942
- $this->Link($x,$y,$w,$h,$link);
943
- }
944
-
945
- function GetX()
946
- {
947
- // Get x position
948
- return $this->x;
949
- }
950
-
951
- function SetX($x)
952
- {
953
- // Set x position
954
- if($x>=0)
955
- $this->x = $x;
956
- else
957
- $this->x = $this->w+$x;
958
- }
959
-
960
- function GetY()
961
- {
962
- // Get y position
963
- return $this->y;
964
- }
965
-
966
- function SetY($y)
967
- {
968
- // Set y position and reset x
969
- $this->x = $this->lMargin;
970
- if($y>=0)
971
- $this->y = $y;
972
- else
973
- $this->y = $this->h+$y;
974
- }
975
-
976
- function SetXY($x, $y)
977
- {
978
- // Set x and y positions
979
- $this->SetY($y);
980
- $this->SetX($x);
981
- }
982
-
983
- function Output($name='', $dest='')
984
- {
985
- // Output PDF to some destination
986
- if($this->state<3)
987
- $this->Close();
988
- $dest = strtoupper($dest);
989
- if($dest=='')
990
- {
991
- if($name=='')
992
- {
993
- $name = 'doc.pdf';
994
- $dest = 'I';
995
- }
996
- else
997
- $dest = 'F';
998
- }
999
- switch($dest)
1000
- {
1001
- case 'I':
1002
- // Send to standard output
1003
- $this->_checkoutput();
1004
- if(PHP_SAPI!='cli')
1005
- {
1006
- // We send to a browser
1007
- header('Content-Type: application/pdf');
1008
- header('Content-Disposition: inline; filename="'.$name.'"');
1009
- header('Cache-Control: private, max-age=0, must-revalidate');
1010
- header('Pragma: public');
1011
- }
1012
- echo $this->buffer;
1013
- break;
1014
- case 'D':
1015
- // Download file
1016
- $this->_checkoutput();
1017
- header('Content-Type: application/x-download');
1018
- header('Content-Disposition: attachment; filename="'.$name.'"');
1019
- header('Cache-Control: private, max-age=0, must-revalidate');
1020
- header('Pragma: public');
1021
- echo $this->buffer;
1022
- break;
1023
- case 'F':
1024
- // Save to local file
1025
- $f = fopen($name,'wb');
1026
- if(!$f)
1027
- $this->Error('Unable to create output file: '.$name);
1028
- fwrite($f,$this->buffer,strlen($this->buffer));
1029
- fclose($f);
1030
- break;
1031
- case 'S':
1032
- // Return as a string
1033
- return $this->buffer;
1034
- default:
1035
- $this->Error('Incorrect output destination: '.$dest);
1036
- }
1037
- return '';
1038
- }
1039
-
1040
- /*******************************************************************************
1041
- * *
1042
- * Protected methods *
1043
- * *
1044
- *******************************************************************************/
1045
- function _dochecks()
1046
- {
1047
- // Check availability of %F
1048
- if(sprintf('%.1F',1.0)!='1.0')
1049
- $this->Error('This version of PHP is not supported');
1050
- // Check mbstring overloading
1051
- if(ini_get('mbstring.func_overload') & 2)
1052
- $this->Error('mbstring overloading must be disabled');
1053
- // Ensure runtime magic quotes are disabled
1054
- if(get_magic_quotes_runtime())
1055
- @set_magic_quotes_runtime(0);
1056
- }
1057
-
1058
- function _checkoutput()
1059
- {
1060
- if(PHP_SAPI!='cli')
1061
- {
1062
- if(headers_sent($file,$line))
1063
- $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1064
- }
1065
- if(ob_get_length())
1066
- {
1067
- // The output buffer is not empty
1068
- if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents()))
1069
- {
1070
- // It contains only a UTF-8 BOM and/or whitespace, let's clean it
1071
- ob_clean();
1072
- }
1073
- else
1074
- $this->Error("Some data has already been output, can't send PDF file");
1075
- }
1076
- }
1077
-
1078
- function _getpagesize($size)
1079
- {
1080
- if(is_string($size))
1081
- {
1082
- $size = strtolower($size);
1083
- if(!isset($this->StdPageSizes[$size]))
1084
- $this->Error('Unknown page size: '.$size);
1085
- $a = $this->StdPageSizes[$size];
1086
- return array($a[0]/$this->k, $a[1]/$this->k);
1087
- }
1088
- else
1089
- {
1090
- if($size[0]>$size[1])
1091
- return array($size[1], $size[0]);
1092
- else
1093
- return $size;
1094
- }
1095
- }
1096
-
1097
- function _beginpage($orientation, $size)
1098
- {
1099
- $this->page++;
1100
- $this->pages[$this->page] = '';
1101
- $this->state = 2;
1102
- $this->x = $this->lMargin;
1103
- $this->y = $this->tMargin;
1104
- $this->FontFamily = '';
1105
- // Check page size and orientation
1106
- if($orientation=='')
1107
- $orientation = $this->DefOrientation;
1108
- else
1109
- $orientation = strtoupper($orientation[0]);
1110
- if($size=='')
1111
- $size = $this->DefPageSize;
1112
- else
1113
- $size = $this->_getpagesize($size);
1114
- if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
1115
- {
1116
- // New size or orientation
1117
- if($orientation=='P')
1118
- {
1119
- $this->w = $size[0];
1120
- $this->h = $size[1];
1121
- }
1122
- else
1123
- {
1124
- $this->w = $size[1];
1125
- $this->h = $size[0];
1126
- }
1127
- $this->wPt = $this->w*$this->k;
1128
- $this->hPt = $this->h*$this->k;
1129
- $this->PageBreakTrigger = $this->h-$this->bMargin;
1130
- $this->CurOrientation = $orientation;
1131
- $this->CurPageSize = $size;
1132
- }
1133
- if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
1134
- $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1135
- }
1136
-
1137
- function _endpage()
1138
- {
1139
- $this->state = 1;
1140
- }
1141
-
1142
- function _loadfont($font)
1143
- {
1144
- // Load a font definition file from the font directory
1145
- include($this->fontpath.$font);
1146
- $a = get_defined_vars();
1147
- if(!isset($a['name']))
1148
- $this->Error('Could not include font definition file');
1149
- return $a;
1150
- }
1151
-
1152
- function _escape($s)
1153
- {
1154
- // Escape special characters in strings
1155
- $s = str_replace('\\','\\\\',$s);
1156
- $s = str_replace('(','\\(',$s);
1157
- $s = str_replace(')','\\)',$s);
1158
- $s = str_replace("\r",'\\r',$s);
1159
- return $s;
1160
- }
1161
-
1162
- function _textstring($s)
1163
- {
1164
- // Format a text string
1165
- return '('.$this->_escape($s).')';
1166
- }
1167
-
1168
- function _UTF8toUTF16($s)
1169
- {
1170
- // Convert UTF-8 to UTF-16BE with BOM
1171
- $res = "\xFE\xFF";
1172
- $nb = strlen($s);
1173
- $i = 0;
1174
- while($i<$nb)
1175
- {
1176
- $c1 = ord($s[$i++]);
1177
- if($c1>=224)
1178
- {
1179
- // 3-byte character
1180
- $c2 = ord($s[$i++]);
1181
- $c3 = ord($s[$i++]);
1182
- $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1183
- $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1184
- }
1185
- elseif($c1>=192)
1186
- {
1187
- // 2-byte character
1188
- $c2 = ord($s[$i++]);
1189
- $res .= chr(($c1 & 0x1C)>>2);
1190
- $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1191
- }
1192
- else
1193
- {
1194
- // Single-byte character
1195
- $res .= "\0".chr($c1);
1196
- }
1197
- }
1198
- return $res;
1199
- }
1200
-
1201
- function _dounderline($x, $y, $txt)
1202
- {
1203
- // Underline text
1204
- $up = $this->CurrentFont['up'];
1205
- $ut = $this->CurrentFont['ut'];
1206
- $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
1207
- 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);
1208
- }
1209
-
1210
- function _parsejpg($file)
1211
- {
1212
- // Extract info from a JPEG file
1213
- $a = getimagesize($file);
1214
- if(!$a)
1215
- $this->Error('Missing or incorrect image file: '.$file);
1216
- if($a[2]!=2)
1217
- $this->Error('Not a JPEG file: '.$file);
1218
- if(!isset($a['channels']) || $a['channels']==3)
1219
- $colspace = 'DeviceRGB';
1220
- elseif($a['channels']==4)
1221
- $colspace = 'DeviceCMYK';
1222
- else
1223
- $colspace = 'DeviceGray';
1224
- $bpc = isset($a['bits']) ? $a['bits'] : 8;
1225
- $data = file_get_contents($file);
1226
- return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227
- }
1228
-
1229
- function _parsepng($file)
1230
- {
1231
- // Extract info from a PNG file
1232
- $f = fopen($file,'rb');
1233
- if(!$f)
1234
- $this->Error('Can\'t open image file: '.$file);
1235
- $info = $this->_parsepngstream($f,$file);
1236
- fclose($f);
1237
- return $info;
1238
- }
1239
-
1240
- function _parsepngstream($f, $file)
1241
- {
1242
- // Check signature
1243
- if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1244
- $this->Error('Not a PNG file: '.$file);
1245
-
1246
- // Read header chunk
1247
- $this->_readstream($f,4);
1248
- if($this->_readstream($f,4)!='IHDR')
1249
- $this->Error('Incorrect PNG file: '.$file);
1250
- $w = $this->_readint($f);
1251
- $h = $this->_readint($f);
1252
- $bpc = ord($this->_readstream($f,1));
1253
- if($bpc>8)
1254
- $this->Error('16-bit depth not supported: '.$file);
1255
- $ct = ord($this->_readstream($f,1));
1256
- if($ct==0 || $ct==4)
1257
- $colspace = 'DeviceGray';
1258
- elseif($ct==2 || $ct==6)
1259
- $colspace = 'DeviceRGB';
1260
- elseif($ct==3)
1261
- $colspace = 'Indexed';
1262
- else
1263
- $this->Error('Unknown color type: '.$file);
1264
- if(ord($this->_readstream($f,1))!=0)
1265
- $this->Error('Unknown compression method: '.$file);
1266
- if(ord($this->_readstream($f,1))!=0)
1267
- $this->Error('Unknown filter method: '.$file);
1268
- if(ord($this->_readstream($f,1))!=0)
1269
- $this->Error('Interlacing not supported: '.$file);
1270
- $this->_readstream($f,4);
1271
- $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1272
-
1273
- // Scan chunks looking for palette, transparency and image data
1274
- $pal = '';
1275
- $trns = '';
1276
- $data = '';
1277
- do
1278
- {
1279
- $n = $this->_readint($f);
1280
- $type = $this->_readstream($f,4);
1281
- if($type=='PLTE')
1282
- {
1283
- // Read palette
1284
- $pal = $this->_readstream($f,$n);
1285
- $this->_readstream($f,4);
1286
- }
1287
- elseif($type=='tRNS')
1288
- {
1289
- // Read transparency info
1290
- $t = $this->_readstream($f,$n);
1291
- if($ct==0)
1292
- $trns = array(ord(substr($t,1,1)));
1293
- elseif($ct==2)
1294
- $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1295
- else
1296
- {
1297
- $pos = strpos($t,chr(0));
1298
- if($pos!==false)
1299
- $trns = array($pos);
1300
- }
1301
- $this->_readstream($f,4);
1302
- }
1303
- elseif($type=='IDAT')
1304
- {
1305
- // Read image data block
1306
- $data .= $this->_readstream($f,$n);
1307
- $this->_readstream($f,4);
1308
- }
1309
- elseif($type=='IEND')
1310
- break;
1311
- else
1312
- $this->_readstream($f,$n+4);
1313
- }
1314
- while($n);
1315
-
1316
- if($colspace=='Indexed' && empty($pal))
1317
- $this->Error('Missing palette in '.$file);
1318
- $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
1319
- if($ct>=4)
1320
- {
1321
- // Extract alpha channel
1322
- if(!function_exists('gzuncompress'))
1323
- $this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1324
- $data = gzuncompress($data);
1325
- $color = '';
1326
- $alpha = '';
1327
- if($ct==4)
1328
- {
1329
- // Gray image
1330
- $len = 2*$w;
1331
- for($i=0;$i<$h;$i++)
1332
- {
1333
- $pos = (1+$len)*$i;
1334
- $color .= $data[$pos];
1335
- $alpha .= $data[$pos];
1336
- $line = substr($data,$pos+1,$len);
1337
- $color .= preg_replace('/(.)./s','$1',$line);
1338
- $alpha .= preg_replace('/.(.)/s','$1',$line);
1339
- }
1340
- }
1341
- else
1342
- {
1343
- // RGB image
1344
- $len = 4*$w;
1345
- for($i=0;$i<$h;$i++)
1346
- {
1347
- $pos = (1+$len)*$i;
1348
- $color .= $data[$pos];
1349
- $alpha .= $data[$pos];
1350
- $line = substr($data,$pos+1,$len);
1351
- $color .= preg_replace('/(.{3})./s','$1',$line);
1352
- $alpha .= preg_replace('/.{3}(.)/s','$1',$line);
1353
- }
1354
- }
1355
- unset($data);
1356
- $data = gzcompress($color);
1357
- $info['smask'] = gzcompress($alpha);
1358
- if($this->PDFVersion<'1.4')
1359
- $this->PDFVersion = '1.4';
1360
- }
1361
- $info['data'] = $data;
1362
- return $info;
1363
- }
1364
-
1365
- function _readstream($f, $n)
1366
- {
1367
- // Read n bytes from stream
1368
- $res = '';
1369
- while($n>0 && !feof($f))
1370
- {
1371
- $s = fread($f,$n);
1372
- if($s===false)
1373
- $this->Error('Error while reading stream');
1374
- $n -= strlen($s);
1375
- $res .= $s;
1376
- }
1377
- if($n>0)
1378
- $this->Error('Unexpected end of stream');
1379
- return $res;
1380
- }
1381
-
1382
- function _readint($f)
1383
- {
1384
- // Read a 4-byte integer from stream
1385
- $a = unpack('Ni',$this->_readstream($f,4));
1386
- return $a['i'];
1387
- }
1388
-
1389
- function _parsegif($file)
1390
- {
1391
- // Extract info from a GIF file (via PNG conversion)
1392
- if(!function_exists('imagepng'))
1393
- $this->Error('GD extension is required for GIF support');
1394
- if(!function_exists('imagecreatefromgif'))
1395
- $this->Error('GD has no GIF read support');
1396
- $im = imagecreatefromgif($file);
1397
- if(!$im)
1398
- $this->Error('Missing or incorrect image file: '.$file);
1399
- imageinterlace($im,0);
1400
- $f = @fopen('php://temp','rb+');
1401
- if($f)
1402
- {
1403
- // Perform conversion in memory
1404
- ob_start();
1405
- imagepng($im);
1406
- $data = ob_get_clean();
1407
- imagedestroy($im);
1408
- fwrite($f,$data);
1409
- rewind($f);
1410
- $info = $this->_parsepngstream($f,$file);
1411
- fclose($f);
1412
- }
1413
- else
1414
- {
1415
- // Use temporary file
1416
- $tmp = tempnam('.','gif');
1417
- if(!$tmp)
1418
- $this->Error('Unable to create a temporary file');
1419
- if(!imagepng($im,$tmp))
1420
- $this->Error('Error while saving to temporary file');
1421
- imagedestroy($im);
1422
- $info = $this->_parsepng($tmp);
1423
- unlink($tmp);
1424
- }
1425
- return $info;
1426
- }
1427
-
1428
- function _newobj()
1429
- {
1430
- // Begin a new object
1431
- $this->n++;
1432
- $this->offsets[$this->n] = strlen($this->buffer);
1433
- $this->_out($this->n.' 0 obj');
1434
- }
1435
-
1436
- function _putstream($s)
1437
- {
1438
- $this->_out('stream');
1439
- $this->_out($s);
1440
- $this->_out('endstream');
1441
- }
1442
-
1443
- function _out($s)
1444
- {
1445
- // Add a line to the document
1446
- if($this->state==2)
1447
- $this->pages[$this->page] .= $s."\n";
1448
- else
1449
- $this->buffer .= $s."\n";
1450
- }
1451
-
1452
- function _putpages()
1453
- {
1454
- $nb = $this->page;
1455
- if(!empty($this->AliasNbPages))
1456
- {
1457
- // Replace number of pages
1458
- for($n=1;$n<=$nb;$n++)
1459
- $this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1460
- }
1461
- if($this->DefOrientation=='P')
1462
- {
1463
- $wPt = $this->DefPageSize[0]*$this->k;
1464
- $hPt = $this->DefPageSize[1]*$this->k;
1465
- }
1466
- else
1467
- {
1468
- $wPt = $this->DefPageSize[1]*$this->k;
1469
- $hPt = $this->DefPageSize[0]*$this->k;
1470
- }
1471
- $filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1472
- for($n=1;$n<=$nb;$n++)
1473
- {
1474
- // Page
1475
- $this->_newobj();
1476
- $this->_out('<</Type /Page');
1477
- $this->_out('/Parent 1 0 R');
1478
- if(isset($this->PageSizes[$n]))
1479
- $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1480
- $this->_out('/Resources 2 0 R');
1481
- if(isset($this->PageLinks[$n]))
1482
- {
1483
- // Links
1484
- $annots = '/Annots [';
1485
- foreach($this->PageLinks[$n] as $pl)
1486
- {
1487
- $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1488
- $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1489
- if(is_string($pl[4]))
1490
- $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1491
- else
1492
- {
1493
- $l = $this->links[$pl[4]];
1494
- $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1495
- $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
1496
- }
1497
- }
1498
- $this->_out($annots.']');
1499
- }
1500
- if($this->PDFVersion>'1.3')
1501
- $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1502
- $this->_out('/Contents '.($this->n+1).' 0 R>>');
1503
- $this->_out('endobj');
1504
- // Page content
1505
- $p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1506
- $this->_newobj();
1507
- $this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
1508
- $this->_putstream($p);
1509
- $this->_out('endobj');
1510
- }
1511
- // Pages root
1512
- $this->offsets[1] = strlen($this->buffer);
1513
- $this->_out('1 0 obj');
1514
- $this->_out('<</Type /Pages');
1515
- $kids = '/Kids [';
1516
- for($i=0;$i<$nb;$i++)
1517
- $kids .= (3+2*$i).' 0 R ';
1518
- $this->_out($kids.']');
1519
- $this->_out('/Count '.$nb);
1520
- $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
1521
- $this->_out('>>');
1522
- $this->_out('endobj');
1523
- }
1524
-
1525
- function _putfonts()
1526
- {
1527
- $nf = $this->n;
1528
- foreach($this->diffs as $diff)
1529
- {
1530
- // Encodings
1531
- $this->_newobj();
1532
- $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1533
- $this->_out('endobj');
1534
- }
1535
- foreach($this->FontFiles as $file=>$info)
1536
- {
1537
- // Font file embedding
1538
- $this->_newobj();
1539
- $this->FontFiles[$file]['n'] = $this->n;
1540
- $font = file_get_contents($this->fontpath.$file,true);
1541
- if(!$font)
1542
- $this->Error('Font file not found: '.$file);
1543
- $compressed = (substr($file,-2)=='.z');
1544
- if(!$compressed && isset($info['length2']))
1545
- $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
1546
- $this->_out('<</Length '.strlen($font));
1547
- if($compressed)
1548
- $this->_out('/Filter /FlateDecode');
1549
- $this->_out('/Length1 '.$info['length1']);
1550
- if(isset($info['length2']))
1551
- $this->_out('/Length2 '.$info['length2'].' /Length3 0');
1552
- $this->_out('>>');
1553
- $this->_putstream($font);
1554
- $this->_out('endobj');
1555
- }
1556
- foreach($this->fonts as $k=>$font)
1557
- {
1558
- // Font objects
1559
- $this->fonts[$k]['n'] = $this->n+1;
1560
- $type = $font['type'];
1561
- $name = $font['name'];
1562
- if($type=='Core')
1563
- {
1564
- // Core font
1565
- $this->_newobj();
1566
- $this->_out('<</Type /Font');
1567
- $this->_out('/BaseFont /'.$name);
1568
- $this->_out('/Subtype /Type1');
1569
- if($name!='Symbol' && $name!='ZapfDingbats')
1570
- $this->_out('/Encoding /WinAnsiEncoding');
1571
- $this->_out('>>');
1572
- $this->_out('endobj');
1573
- }
1574
- elseif($type=='Type1' || $type=='TrueType')
1575
- {
1576
- // Additional Type1 or TrueType/OpenType font
1577
- $this->_newobj();
1578
- $this->_out('<</Type /Font');
1579
- $this->_out('/BaseFont /'.$name);
1580
- $this->_out('/Subtype /'.$type);
1581
- $this->_out('/FirstChar 32 /LastChar 255');
1582
- $this->_out('/Widths '.($this->n+1).' 0 R');
1583
- $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1584
- if(isset($font['diffn']))
1585
- $this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
1586
- else
1587
- $this->_out('/Encoding /WinAnsiEncoding');
1588
- $this->_out('>>');
1589
- $this->_out('endobj');
1590
- // Widths
1591
- $this->_newobj();
1592
- $cw = &$font['cw'];
1593
- $s = '[';
1594
- for($i=32;$i<=255;$i++)
1595
- $s .= $cw[chr($i)].' ';
1596
- $this->_out($s.']');
1597
- $this->_out('endobj');
1598
- // Descriptor
1599
- $this->_newobj();
1600
- $s = '<</Type /FontDescriptor /FontName /'.$name;
1601
- foreach($font['desc'] as $k=>$v)
1602
- $s .= ' /'.$k.' '.$v;
1603
- if(!empty($font['file']))
1604
- $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1605
- $this->_out($s.'>>');
1606
- $this->_out('endobj');
1607
- }
1608
- else
1609
- {
1610
- // Allow for additional types
1611
- $mtd = '_put'.strtolower($type);
1612
- if(!method_exists($this,$mtd))
1613
- $this->Error('Unsupported font type: '.$type);
1614
- $this->$mtd($font);
1615
- }
1616
- }
1617
- }
1618
-
1619
- function _putimages()
1620
- {
1621
- foreach(array_keys($this->images) as $file)
1622
- {
1623
- $this->_putimage($this->images[$file]);
1624
- unset($this->images[$file]['data']);
1625
- unset($this->images[$file]['smask']);
1626
- }
1627
- }
1628
-
1629
- function _putimage(&$info)
1630
- {
1631
- $this->_newobj();
1632
- $info['n'] = $this->n;
1633
- $this->_out('<</Type /XObject');
1634
- $this->_out('/Subtype /Image');
1635
- $this->_out('/Width '.$info['w']);
1636
- $this->_out('/Height '.$info['h']);
1637
- if($info['cs']=='Indexed')
1638
- $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1639
- else
1640
- {
1641
- $this->_out('/ColorSpace /'.$info['cs']);
1642
- if($info['cs']=='DeviceCMYK')
1643
- $this->_out('/Decode [1 0 1 0 1 0 1 0]');
1644
- }
1645
- $this->_out('/BitsPerComponent '.$info['bpc']);
1646
- if(isset($info['f']))
1647
- $this->_out('/Filter /'.$info['f']);
1648
- if(isset($info['dp']))
1649
- $this->_out('/DecodeParms <<'.$info['dp'].'>>');
1650
- if(isset($info['trns']) && is_array($info['trns']))
1651
- {
1652
- $trns = '';
1653
- for($i=0;$i<count($info['trns']);$i++)
1654
- $trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1655
- $this->_out('/Mask ['.$trns.']');
1656
- }
1657
- if(isset($info['smask']))
1658
- $this->_out('/SMask '.($this->n+1).' 0 R');
1659
- $this->_out('/Length '.strlen($info['data']).'>>');
1660
- $this->_putstream($info['data']);
1661
- $this->_out('endobj');
1662
- // Soft mask
1663
- if(isset($info['smask']))
1664
- {
1665
- $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
1666
- $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']);
1667
- $this->_putimage($smask);
1668
- }
1669
- // Palette
1670
- if($info['cs']=='Indexed')
1671
- {
1672
- $filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1673
- $pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
1674
- $this->_newobj();
1675
- $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
1676
- $this->_putstream($pal);
1677
- $this->_out('endobj');
1678
- }
1679
- }
1680
-
1681
- function _putxobjectdict()
1682
- {
1683
- foreach($this->images as $image)
1684
- $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1685
- }
1686
-
1687
- function _putresourcedict()
1688
- {
1689
- $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1690
- $this->_out('/Font <<');
1691
- foreach($this->fonts as $font)
1692
- $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1693
- $this->_out('>>');
1694
- $this->_out('/XObject <<');
1695
- $this->_putxobjectdict();
1696
- $this->_out('>>');
1697
- }
1698
-
1699
- function _putresources()
1700
- {
1701
- $this->_putfonts();
1702
- $this->_putimages();
1703
- // Resource dictionary
1704
- $this->offsets[2] = strlen($this->buffer);
1705
- $this->_out('2 0 obj');
1706
- $this->_out('<<');
1707
- $this->_putresourcedict();
1708
- $this->_out('>>');
1709
- $this->_out('endobj');
1710
- }
1711
-
1712
- function _putinfo()
1713
- {
1714
- $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1715
- if(!empty($this->title))
1716
- $this->_out('/Title '.$this->_textstring($this->title));
1717
- if(!empty($this->subject))
1718
- $this->_out('/Subject '.$this->_textstring($this->subject));
1719
- if(!empty($this->author))
1720
- $this->_out('/Author '.$this->_textstring($this->author));
1721
- if(!empty($this->keywords))
1722
- $this->_out('/Keywords '.$this->_textstring($this->keywords));
1723
- if(!empty($this->creator))
1724
- $this->_out('/Creator '.$this->_textstring($this->creator));
1725
- $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1726
- }
1727
-
1728
- function _putcatalog()
1729
- {
1730
- $this->_out('/Type /Catalog');
1731
- $this->_out('/Pages 1 0 R');
1732
- if($this->ZoomMode=='fullpage')
1733
- $this->_out('/OpenAction [3 0 R /Fit]');
1734
- elseif($this->ZoomMode=='fullwidth')
1735
- $this->_out('/OpenAction [3 0 R /FitH null]');
1736
- elseif($this->ZoomMode=='real')
1737
- $this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1738
- elseif(!is_string($this->ZoomMode))
1739
- $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
1740
- if($this->LayoutMode=='single')
1741
- $this->_out('/PageLayout /SinglePage');
1742
- elseif($this->LayoutMode=='continuous')
1743
- $this->_out('/PageLayout /OneColumn');
1744
- elseif($this->LayoutMode=='two')
1745
- $this->_out('/PageLayout /TwoColumnLeft');
1746
- }
1747
-
1748
- function _putheader()
1749
- {
1750
- $this->_out('%PDF-'.$this->PDFVersion);
1751
- }
1752
-
1753
- function _puttrailer()
1754
- {
1755
- $this->_out('/Size '.($this->n+1));
1756
- $this->_out('/Root '.$this->n.' 0 R');
1757
- $this->_out('/Info '.($this->n-1).' 0 R');
1758
- }
1759
-
1760
- function _enddoc()
1761
- {
1762
- $this->_putheader();
1763
- $this->_putpages();
1764
- $this->_putresources();
1765
- // Info
1766
- $this->_newobj();
1767
- $this->_out('<<');
1768
- $this->_putinfo();
1769
- $this->_out('>>');
1770
- $this->_out('endobj');
1771
- // Catalog
1772
- $this->_newobj();
1773
- $this->_out('<<');
1774
- $this->_putcatalog();
1775
- $this->_out('>>');
1776
- $this->_out('endobj');
1777
- // Cross-ref
1778
- $o = strlen($this->buffer);
1779
- $this->_out('xref');
1780
- $this->_out('0 '.($this->n+1));
1781
- $this->_out('0000000000 65535 f ');
1782
- for($i=1;$i<=$this->n;$i++)
1783
- $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1784
- // Trailer
1785
- $this->_out('trailer');
1786
- $this->_out('<<');
1787
- $this->_puttrailer();
1788
- $this->_out('>>');
1789
- $this->_out('startxref');
1790
- $this->_out($o);
1791
- $this->_out('%%EOF');
1792
- $this->state = 3;
1793
- }
1794
- // End of class
1795
- }
1796
-
1797
- // Handle special IE contype request
1798
- if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
1799
- {
1800
- header('Content-Type: application/pdf');
1801
- exit;
1802
- }
1803
-
1804
- ?>
1
+ <?php
2
+ /*******************************************************************************
3
+ * FPDF *
4
+ * *
5
+ * Version: 1.7 *
6
+ * Date: 2011-06-18 *
7
+ * Author: Olivier PLATHEY *
8
+ *******************************************************************************/
9
+
10
+ define('FPDF_VERSION','1.7');
11
+
12
+ class FPDF
13
+ {
14
+ var $page; // current page number
15
+ var $n; // current object number
16
+ var $offsets; // array of object offsets
17
+ var $buffer; // buffer holding in-memory PDF
18
+ var $pages; // array containing pages
19
+ var $state; // current document state
20
+ var $compress; // compression flag
21
+ var $k; // scale factor (number of points in user unit)
22
+ var $DefOrientation; // default orientation
23
+ var $CurOrientation; // current orientation
24
+ var $StdPageSizes; // standard page sizes
25
+ var $DefPageSize; // default page size
26
+ var $CurPageSize; // current page size
27
+ var $PageSizes; // used for pages with non default sizes or orientations
28
+ var $wPt, $hPt; // dimensions of current page in points
29
+ var $w, $h; // dimensions of current page in user unit
30
+ var $lMargin; // left margin
31
+ var $tMargin; // top margin
32
+ var $rMargin; // right margin
33
+ var $bMargin; // page break margin
34
+ var $cMargin; // cell margin
35
+ var $x, $y; // current position in user unit
36
+ var $lasth; // height of last printed cell
37
+ var $LineWidth; // line width in user unit
38
+ var $fontpath; // path containing fonts
39
+ var $CoreFonts; // array of core font names
40
+ var $fonts; // array of used fonts
41
+ var $FontFiles; // array of font files
42
+ var $diffs; // array of encoding differences
43
+ var $FontFamily; // current font family
44
+ var $FontStyle; // current font style
45
+ var $underline; // underlining flag
46
+ var $CurrentFont; // current font info
47
+ var $FontSizePt; // current font size in points
48
+ var $FontSize; // current font size in user unit
49
+ var $DrawColor; // commands for drawing color
50
+ var $FillColor; // commands for filling color
51
+ var $TextColor; // commands for text color
52
+ var $ColorFlag; // indicates whether fill and text colors are different
53
+ var $ws; // word spacing
54
+ var $images; // array of used images
55
+ var $PageLinks; // array of links in pages
56
+ var $links; // array of internal links
57
+ var $AutoPageBreak; // automatic page breaking
58
+ var $PageBreakTrigger; // threshold used to trigger page breaks
59
+ var $InHeader; // flag set when processing header
60
+ var $InFooter; // flag set when processing footer
61
+ var $ZoomMode; // zoom display mode
62
+ var $LayoutMode; // layout display mode
63
+ var $title; // title
64
+ var $subject; // subject
65
+ var $author; // author
66
+ var $keywords; // keywords
67
+ var $creator; // creator
68
+ var $AliasNbPages; // alias for total number of pages
69
+ var $PDFVersion; // PDF version number
70
+
71
+ /*******************************************************************************
72
+ * *
73
+ * Public methods *
74
+ * *
75
+ *******************************************************************************/
76
+ function FPDF($orientation='P', $unit='mm', $size='A4')
77
+ {
78
+ // Some checks
79
+ $this->_dochecks();
80
+ // Initialization of properties
81
+ $this->page = 0;
82
+ $this->n = 2;
83
+ $this->buffer = '';
84
+ $this->pages = array();
85
+ $this->PageSizes = array();
86
+ $this->state = 0;
87
+ $this->fonts = array();
88
+ $this->FontFiles = array();
89
+ $this->diffs = array();
90
+ $this->images = array();
91
+ $this->links = array();
92
+ $this->InHeader = false;
93
+ $this->InFooter = false;
94
+ $this->lasth = 0;
95
+ $this->FontFamily = '';
96
+ $this->FontStyle = '';
97
+ $this->FontSizePt = 12;
98
+ $this->underline = false;
99
+ $this->DrawColor = '0 G';
100
+ $this->FillColor = '0 g';
101
+ $this->TextColor = '0 g';
102
+ $this->ColorFlag = false;
103
+ $this->ws = 0;
104
+ // Font path
105
+ if(defined('FPDF_FONTPATH'))
106
+ {
107
+ $this->fontpath = FPDF_FONTPATH;
108
+ if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
109
+ $this->fontpath .= '/';
110
+ }
111
+ elseif(is_dir(dirname(__FILE__).'/font'))
112
+ $this->fontpath = dirname(__FILE__).'/font/';
113
+ else
114
+ $this->fontpath = '';
115
+ // Core fonts
116
+ $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
117
+ // Scale factor
118
+ if($unit=='pt')
119
+ $this->k = 1;
120
+ elseif($unit=='mm')
121
+ $this->k = 72/25.4;
122
+ elseif($unit=='cm')
123
+ $this->k = 72/2.54;
124
+ elseif($unit=='in')
125
+ $this->k = 72;
126
+ else
127
+ $this->Error('Incorrect unit: '.$unit);
128
+ // Page sizes
129
+ $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
130
+ 'letter'=>array(612,792), 'legal'=>array(612,1008));
131
+ $size = $this->_getpagesize($size);
132
+ $this->DefPageSize = $size;
133
+ $this->CurPageSize = $size;
134
+ // Page orientation
135
+ $orientation = strtolower($orientation);
136
+ if($orientation=='p' || $orientation=='portrait')
137
+ {
138
+ $this->DefOrientation = 'P';
139
+ $this->w = $size[0];
140
+ $this->h = $size[1];
141
+ }
142
+ elseif($orientation=='l' || $orientation=='landscape')
143
+ {
144
+ $this->DefOrientation = 'L';
145
+ $this->w = $size[1];
146
+ $this->h = $size[0];
147
+ }
148
+ else
149
+ $this->Error('Incorrect orientation: '.$orientation);
150
+ $this->CurOrientation = $this->DefOrientation;
151
+ $this->wPt = $this->w*$this->k;
152
+ $this->hPt = $this->h*$this->k;
153
+ // Page margins (1 cm)
154
+ $margin = 28.35/$this->k;
155
+ $this->SetMargins($margin,$margin);
156
+ // Interior cell margin (1 mm)
157
+ $this->cMargin = $margin/10;
158
+ // Line width (0.2 mm)
159
+ $this->LineWidth = .567/$this->k;
160
+ // Automatic page break
161
+ $this->SetAutoPageBreak(true,2*$margin);
162
+ // Default display mode
163
+ $this->SetDisplayMode('default');
164
+ // Enable compression
165
+ $this->SetCompression(true);
166
+ // Set default PDF version number
167
+ $this->PDFVersion = '1.3';
168
+ }
169
+
170
+ function SetMargins($left, $top, $right=null)
171
+ {
172
+ // Set left, top and right margins
173
+ $this->lMargin = $left;
174
+ $this->tMargin = $top;
175
+ if($right===null)
176
+ $right = $left;
177
+ $this->rMargin = $right;
178
+ }
179
+
180
+ function SetLeftMargin($margin)
181
+ {
182
+ // Set left margin
183
+ $this->lMargin = $margin;
184
+ if($this->page>0 && $this->x<$margin)
185
+ $this->x = $margin;
186
+ }
187
+
188
+ function SetTopMargin($margin)
189
+ {
190
+ // Set top margin
191
+ $this->tMargin = $margin;
192
+ }
193
+
194
+ function SetRightMargin($margin)
195
+ {
196
+ // Set right margin
197
+ $this->rMargin = $margin;
198
+ }
199
+
200
+ function SetAutoPageBreak($auto, $margin=0)
201
+ {
202
+ // Set auto page break mode and triggering margin
203
+ $this->AutoPageBreak = $auto;
204
+ $this->bMargin = $margin;
205
+ $this->PageBreakTrigger = $this->h-$margin;
206
+ }
207
+
208
+ function SetDisplayMode($zoom, $layout='default')
209
+ {
210
+ // Set display mode in viewer
211
+ if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
212
+ $this->ZoomMode = $zoom;
213
+ else
214
+ $this->Error('Incorrect zoom display mode: '.$zoom);
215
+ if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
216
+ $this->LayoutMode = $layout;
217
+ else
218
+ $this->Error('Incorrect layout display mode: '.$layout);
219
+ }
220
+
221
+ function SetCompression($compress)
222
+ {
223
+ // Set page compression
224
+ if(function_exists('gzcompress'))
225
+ $this->compress = $compress;
226
+ else
227
+ $this->compress = false;
228
+ }
229
+
230
+ function SetTitle($title, $isUTF8=false)
231
+ {
232
+ // Title of document
233
+ if($isUTF8)
234
+ $title = $this->_UTF8toUTF16($title);
235
+ $this->title = $title;
236
+ }
237
+
238
+ function SetSubject($subject, $isUTF8=false)
239
+ {
240
+ // Subject of document
241
+ if($isUTF8)
242
+ $subject = $this->_UTF8toUTF16($subject);
243
+ $this->subject = $subject;
244
+ }
245
+
246
+ function SetAuthor($author, $isUTF8=false)
247
+ {
248
+ // Author of document
249
+ if($isUTF8)
250
+ $author = $this->_UTF8toUTF16($author);
251
+ $this->author = $author;
252
+ }
253
+
254
+ function SetKeywords($keywords, $isUTF8=false)
255
+ {
256
+ // Keywords of document
257
+ if($isUTF8)
258
+ $keywords = $this->_UTF8toUTF16($keywords);
259
+ $this->keywords = $keywords;
260
+ }
261
+
262
+ function SetCreator($creator, $isUTF8=false)
263
+ {
264
+ // Creator of document
265
+ if($isUTF8)
266
+ $creator = $this->_UTF8toUTF16($creator);
267
+ $this->creator = $creator;
268
+ }
269
+
270
+ function AliasNbPages($alias='{nb}')
271
+ {
272
+ // Define an alias for total number of pages
273
+ $this->AliasNbPages = $alias;
274
+ }
275
+
276
+ function Error($msg)
277
+ {
278
+ // Fatal error
279
+ die('<b>FPDF error:</b> '.$msg);
280
+ }
281
+
282
+ function Open()
283
+ {
284
+ // Begin document
285
+ $this->state = 1;
286
+ }
287
+
288
+ function Close()
289
+ {
290
+ // Terminate document
291
+ if($this->state==3)
292
+ return;
293
+ if($this->page==0)
294
+ $this->AddPage();
295
+ // Page footer
296
+ $this->InFooter = true;
297
+ $this->Footer();
298
+ $this->InFooter = false;
299
+ // Close page
300
+ $this->_endpage();
301
+ // Close document
302
+ $this->_enddoc();
303
+ }
304
+
305
+ function AddPage($orientation='', $size='')
306
+ {
307
+ // Start a new page
308
+ if($this->state==0)
309
+ $this->Open();
310
+ $family = $this->FontFamily;
311
+ $style = $this->FontStyle.($this->underline ? 'U' : '');
312
+ $fontsize = $this->FontSizePt;
313
+ $lw = $this->LineWidth;
314
+ $dc = $this->DrawColor;
315
+ $fc = $this->FillColor;
316
+ $tc = $this->TextColor;
317
+ $cf = $this->ColorFlag;
318
+ if($this->page>0)
319
+ {
320
+ // Page footer
321
+ $this->InFooter = true;
322
+ $this->Footer();
323
+ $this->InFooter = false;
324
+ // Close page
325
+ $this->_endpage();
326
+ }
327
+ // Start new page
328
+ $this->_beginpage($orientation,$size);
329
+ // Set line cap style to square
330
+ $this->_out('2 J');
331
+ // Set line width
332
+ $this->LineWidth = $lw;
333
+ $this->_out(sprintf('%.2F w',$lw*$this->k));
334
+ // Set font
335
+ if($family)
336
+ $this->SetFont($family,$style,$fontsize);
337
+ // Set colors
338
+ $this->DrawColor = $dc;
339
+ if($dc!='0 G')
340
+ $this->_out($dc);
341
+ $this->FillColor = $fc;
342
+ if($fc!='0 g')
343
+ $this->_out($fc);
344
+ $this->TextColor = $tc;
345
+ $this->ColorFlag = $cf;
346
+ // Page header
347
+ $this->InHeader = true;
348
+ $this->Header();
349
+ $this->InHeader = false;
350
+ // Restore line width
351
+ if($this->LineWidth!=$lw)
352
+ {
353
+ $this->LineWidth = $lw;
354
+ $this->_out(sprintf('%.2F w',$lw*$this->k));
355
+ }
356
+ // Restore font
357
+ if($family)
358
+ $this->SetFont($family,$style,$fontsize);
359
+ // Restore colors
360
+ if($this->DrawColor!=$dc)
361
+ {
362
+ $this->DrawColor = $dc;
363
+ $this->_out($dc);
364
+ }
365
+ if($this->FillColor!=$fc)
366
+ {
367
+ $this->FillColor = $fc;
368
+ $this->_out($fc);
369
+ }
370
+ $this->TextColor = $tc;
371
+ $this->ColorFlag = $cf;
372
+ }
373
+
374
+ function Header()
375
+ {
376
+ // To be implemented in your own inherited class
377
+ }
378
+
379
+ function Footer()
380
+ {
381
+ // To be implemented in your own inherited class
382
+ }
383
+
384
+ function PageNo()
385
+ {
386
+ // Get current page number
387
+ return $this->page;
388
+ }
389
+
390
+ function SetDrawColor($r, $g=null, $b=null)
391
+ {
392
+ // Set color for all stroking operations
393
+ if(($r==0 && $g==0 && $b==0) || $g===null)
394
+ $this->DrawColor = sprintf('%.3F G',$r/255);
395
+ else
396
+ $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
397
+ if($this->page>0)
398
+ $this->_out($this->DrawColor);
399
+ }
400
+
401
+ function SetFillColor($r, $g=null, $b=null)
402
+ {
403
+ // Set color for all filling operations
404
+ if(($r==0 && $g==0 && $b==0) || $g===null)
405
+ $this->FillColor = sprintf('%.3F g',$r/255);
406
+ else
407
+ $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
408
+ $this->ColorFlag = ($this->FillColor!=$this->TextColor);
409
+ if($this->page>0)
410
+ $this->_out($this->FillColor);
411
+ }
412
+
413
+ function SetTextColor($r, $g=null, $b=null)
414
+ {
415
+ // Set color for text
416
+ if(($r==0 && $g==0 && $b==0) || $g===null)
417
+ $this->TextColor = sprintf('%.3F g',$r/255);
418
+ else
419
+ $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
420
+ $this->ColorFlag = ($this->FillColor!=$this->TextColor);
421
+ }
422
+
423
+ function GetStringWidth($s)
424
+ {
425
+ // Get width of a string in the current font
426
+ $s = (string)$s;
427
+ $cw = &$this->CurrentFont['cw'];
428
+ $w = 0;
429
+ $l = strlen($s);
430
+ for($i=0;$i<$l;$i++)
431
+ $w += $cw[$s[$i]];
432
+ return $w*$this->FontSize/1000;
433
+ }
434
+
435
+ function SetLineWidth($width)
436
+ {
437
+ // Set line width
438
+ $this->LineWidth = $width;
439
+ if($this->page>0)
440
+ $this->_out(sprintf('%.2F w',$width*$this->k));
441
+ }
442
+
443
+ function Line($x1, $y1, $x2, $y2)
444
+ {
445
+ // Draw a line
446
+ $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));
447
+ }
448
+
449
+ function Rect($x, $y, $w, $h, $style='')
450
+ {
451
+ // Draw a rectangle
452
+ if($style=='F')
453
+ $op = 'f';
454
+ elseif($style=='FD' || $style=='DF')
455
+ $op = 'B';
456
+ else
457
+ $op = 'S';
458
+ $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
459
+ }
460
+
461
+ function AddFont($family, $style='', $file='')
462
+ {
463
+ // Add a TrueType, OpenType or Type1 font
464
+ $family = strtolower($family);
465
+ if($file=='')
466
+ $file = str_replace(' ','',$family).strtolower($style).'.php';
467
+ $style = strtoupper($style);
468
+ if($style=='IB')
469
+ $style = 'BI';
470
+ $fontkey = $family.$style;
471
+ if(isset($this->fonts[$fontkey]))
472
+ return;
473
+ $info = $this->_loadfont($file);
474
+ $info['i'] = count($this->fonts)+1;
475
+ if(!empty($info['diff']))
476
+ {
477
+ // Search existing encodings
478
+ $n = array_search($info['diff'],$this->diffs);
479
+ if(!$n)
480
+ {
481
+ $n = count($this->diffs)+1;
482
+ $this->diffs[$n] = $info['diff'];
483
+ }
484
+ $info['diffn'] = $n;
485
+ }
486
+ if(!empty($info['file']))
487
+ {
488
+ // Embedded font
489
+ if($info['type']=='TrueType')
490
+ $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
491
+ else
492
+ $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
493
+ }
494
+ $this->fonts[$fontkey] = $info;
495
+ }
496
+
497
+ function SetFont($family, $style='', $size=0)
498
+ {
499
+ // Select a font; size given in points
500
+ if($family=='')
501
+ $family = $this->FontFamily;
502
+ else
503
+ $family = strtolower($family);
504
+ $style = strtoupper($style);
505
+ if(strpos($style,'U')!==false)
506
+ {
507
+ $this->underline = true;
508
+ $style = str_replace('U','',$style);
509
+ }
510
+ else
511
+ $this->underline = false;
512
+ if($style=='IB')
513
+ $style = 'BI';
514
+ if($size==0)
515
+ $size = $this->FontSizePt;
516
+ // Test if font is already selected
517
+ if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
518
+ return;
519
+ // Test if font is already loaded
520
+ $fontkey = $family.$style;
521
+ if(!isset($this->fonts[$fontkey]))
522
+ {
523
+ // Test if one of the core fonts
524
+ if($family=='arial')
525
+ $family = 'helvetica';
526
+ if(in_array($family,$this->CoreFonts))
527
+ {
528
+ if($family=='symbol' || $family=='zapfdingbats')
529
+ $style = '';
530
+ $fontkey = $family.$style;
531
+ if(!isset($this->fonts[$fontkey]))
532
+ $this->AddFont($family,$style);
533
+ }
534
+ else
535
+ $this->Error('Undefined font: '.$family.' '.$style);
536
+ }
537
+ // Select it
538
+ $this->FontFamily = $family;
539
+ $this->FontStyle = $style;
540
+ $this->FontSizePt = $size;
541
+ $this->FontSize = $size/$this->k;
542
+ $this->CurrentFont = &$this->fonts[$fontkey];
543
+ if($this->page>0)
544
+ $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
545
+ }
546
+
547
+ function SetFontSize($size)
548
+ {
549
+ // Set font size in points
550
+ if($this->FontSizePt==$size)
551
+ return;
552
+ $this->FontSizePt = $size;
553
+ $this->FontSize = $size/$this->k;
554
+ if($this->page>0)
555
+ $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
556
+ }
557
+
558
+ function AddLink()
559
+ {
560
+ // Create a new internal link
561
+ $n = count($this->links)+1;
562
+ $this->links[$n] = array(0, 0);
563
+ return $n;
564
+ }
565
+
566
+ function SetLink($link, $y=0, $page=-1)
567
+ {
568
+ // Set destination of internal link
569
+ if($y==-1)
570
+ $y = $this->y;
571
+ if($page==-1)
572
+ $page = $this->page;
573
+ $this->links[$link] = array($page, $y);
574
+ }
575
+
576
+ function Link($x, $y, $w, $h, $link)
577
+ {
578
+ // Put a link on the page
579
+ $this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
580
+ }
581
+
582
+ function Text($x, $y, $txt)
583
+ {
584
+ // Output a string
585
+ $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
586
+ if($this->underline && $txt!='')
587
+ $s .= ' '.$this->_dounderline($x,$y,$txt);
588
+ if($this->ColorFlag)
589
+ $s = 'q '.$this->TextColor.' '.$s.' Q';
590
+ $this->_out($s);
591
+ }
592
+
593
+ function AcceptPageBreak()
594
+ {
595
+ // Accept automatic page break or not
596
+ return $this->AutoPageBreak;
597
+ }
598
+
599
+ function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
600
+ {
601
+ // Output a cell
602
+ $k = $this->k;
603
+ if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
604
+ {
605
+ // Automatic page break
606
+ $x = $this->x;
607
+ $ws = $this->ws;
608
+ if($ws>0)
609
+ {
610
+ $this->ws = 0;
611
+ $this->_out('0 Tw');
612
+ }
613
+ $this->AddPage($this->CurOrientation,$this->CurPageSize);
614
+ $this->x = $x;
615
+ if($ws>0)
616
+ {
617
+ $this->ws = $ws;
618
+ $this->_out(sprintf('%.3F Tw',$ws*$k));
619
+ }
620
+ }
621
+ if($w==0)
622
+ $w = $this->w-$this->rMargin-$this->x;
623
+ $s = '';
624
+ if($fill || $border==1)
625
+ {
626
+ if($fill)
627
+ $op = ($border==1) ? 'B' : 'f';
628
+ else
629
+ $op = 'S';
630
+ $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
631
+ }
632
+ if(is_string($border))
633
+ {
634
+ $x = $this->x;
635
+ $y = $this->y;
636
+ if(strpos($border,'L')!==false)
637
+ $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
638
+ if(strpos($border,'T')!==false)
639
+ $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
640
+ if(strpos($border,'R')!==false)
641
+ $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
642
+ if(strpos($border,'B')!==false)
643
+ $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
644
+ }
645
+ if($txt!=='')
646
+ {
647
+ if($align=='R')
648
+ $dx = $w-$this->cMargin-$this->GetStringWidth($txt);
649
+ elseif($align=='C')
650
+ $dx = ($w-$this->GetStringWidth($txt))/2;
651
+ else
652
+ $dx = $this->cMargin;
653
+ if($this->ColorFlag)
654
+ $s .= 'q '.$this->TextColor.' ';
655
+ $txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
656
+ $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
657
+ if($this->underline)
658
+ $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
659
+ if($this->ColorFlag)
660
+ $s .= ' Q';
661
+ if($link)
662
+ $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
663
+ }
664
+ if($s)
665
+ $this->_out($s);
666
+ $this->lasth = $h;
667
+ if($ln>0)
668
+ {
669
+ // Go to next line
670
+ $this->y += $h;
671
+ if($ln==1)
672
+ $this->x = $this->lMargin;
673
+ }
674
+ else
675
+ $this->x += $w;
676
+ }
677
+
678
+ function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
679
+ {
680
+ // Output text with automatic or explicit line breaks
681
+ $cw = &$this->CurrentFont['cw'];
682
+ if($w==0)
683
+ $w = $this->w-$this->rMargin-$this->x;
684
+ $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
685
+ $s = str_replace("\r",'',$txt);
686
+ $nb = strlen($s);
687
+ if($nb>0 && $s[$nb-1]=="\n")
688
+ $nb--;
689
+ $b = 0;
690
+ if($border)
691
+ {
692
+ if($border==1)
693
+ {
694
+ $border = 'LTRB';
695
+ $b = 'LRT';
696
+ $b2 = 'LR';
697
+ }
698
+ else
699
+ {
700
+ $b2 = '';
701
+ if(strpos($border,'L')!==false)
702
+ $b2 .= 'L';
703
+ if(strpos($border,'R')!==false)
704
+ $b2 .= 'R';
705
+ $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
706
+ }
707
+ }
708
+ $sep = -1;
709
+ $i = 0;
710
+ $j = 0;
711
+ $l = 0;
712
+ $ns = 0;
713
+ $nl = 1;
714
+ while($i<$nb)
715
+ {
716
+ // Get next character
717
+ $c = $s[$i];
718
+ if($c=="\n")
719
+ {
720
+ // Explicit line break
721
+ if($this->ws>0)
722
+ {
723
+ $this->ws = 0;
724
+ $this->_out('0 Tw');
725
+ }
726
+ $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
727
+ $i++;
728
+ $sep = -1;
729
+ $j = $i;
730
+ $l = 0;
731
+ $ns = 0;
732
+ $nl++;
733
+ if($border && $nl==2)
734
+ $b = $b2;
735
+ continue;
736
+ }
737
+ if($c==' ')
738
+ {
739
+ $sep = $i;
740
+ $ls = $l;
741
+ $ns++;
742
+ }
743
+ $l += $cw[$c];
744
+ if($l>$wmax)
745
+ {
746
+ // Automatic line break
747
+ if($sep==-1)
748
+ {
749
+ if($i==$j)
750
+ $i++;
751
+ if($this->ws>0)
752
+ {
753
+ $this->ws = 0;
754
+ $this->_out('0 Tw');
755
+ }
756
+ $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
757
+ }
758
+ else
759
+ {
760
+ if($align=='J')
761
+ {
762
+ $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
763
+ $this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
764
+ }
765
+ $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
766
+ $i = $sep+1;
767
+ }
768
+ $sep = -1;
769
+ $j = $i;
770
+ $l = 0;
771
+ $ns = 0;
772
+ $nl++;
773
+ if($border && $nl==2)
774
+ $b = $b2;
775
+ }
776
+ else
777
+ $i++;
778
+ }
779
+ // Last chunk
780
+ if($this->ws>0)
781
+ {
782
+ $this->ws = 0;
783
+ $this->_out('0 Tw');
784
+ }
785
+ if($border && strpos($border,'B')!==false)
786
+ $b .= 'B';
787
+ $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
788
+ $this->x = $this->lMargin;
789
+ }
790
+
791
+ function Write($h, $txt, $link='')
792
+ {
793
+ // Output text in flowing mode
794
+ $cw = &$this->CurrentFont['cw'];
795
+ $w = $this->w-$this->rMargin-$this->x;
796
+ $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
797
+ $s = str_replace("\r",'',$txt);
798
+ $nb = strlen($s);
799
+ $sep = -1;
800
+ $i = 0;
801
+ $j = 0;
802
+ $l = 0;
803
+ $nl = 1;
804
+ while($i<$nb)
805
+ {
806
+ // Get next character
807
+ $c = $s[$i];
808
+ if($c=="\n")
809
+ {
810
+ // Explicit line break
811
+ $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
812
+ $i++;
813
+ $sep = -1;
814
+ $j = $i;
815
+ $l = 0;
816
+ if($nl==1)
817
+ {
818
+ $this->x = $this->lMargin;
819
+ $w = $this->w-$this->rMargin-$this->x;
820
+ $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
821
+ }
822
+ $nl++;
823
+ continue;
824
+ }
825
+ if($c==' ')
826
+ $sep = $i;
827
+ $l += $cw[$c];
828
+ if($l>$wmax)
829
+ {
830
+ // Automatic line break
831
+ if($sep==-1)
832
+ {
833
+ if($this->x>$this->lMargin)
834
+ {
835
+ // Move to next line
836
+ $this->x = $this->lMargin;
837
+ $this->y += $h;
838
+ $w = $this->w-$this->rMargin-$this->x;
839
+ $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
840
+ $i++;
841
+ $nl++;
842
+ continue;
843
+ }
844
+ if($i==$j)
845
+ $i++;
846
+ $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
847
+ }
848
+ else
849
+ {
850
+ $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
851
+ $i = $sep+1;
852
+ }
853
+ $sep = -1;
854
+ $j = $i;
855
+ $l = 0;
856
+ if($nl==1)
857
+ {
858
+ $this->x = $this->lMargin;
859
+ $w = $this->w-$this->rMargin-$this->x;
860
+ $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
861
+ }
862
+ $nl++;
863
+ }
864
+ else
865
+ $i++;
866
+ }
867
+ // Last chunk
868
+ if($i!=$j)
869
+ $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
870
+ }
871
+
872
+ function Ln($h=null)
873
+ {
874
+ // Line feed; default value is last cell height
875
+ $this->x = $this->lMargin;
876
+ if($h===null)
877
+ $this->y += $this->lasth;
878
+ else
879
+ $this->y += $h;
880
+ }
881
+
882
+ function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
883
+ {
884
+ // Put an image on the page
885
+ if(!isset($this->images[$file]))
886
+ {
887
+ // First use of this image, get info
888
+ if($type=='')
889
+ {
890
+ $pos = strrpos($file,'.');
891
+ if(!$pos)
892
+ $this->Error('Image file has no extension and no type was specified: '.$file);
893
+ $type = substr($file,$pos+1);
894
+ }
895
+ $type = strtolower($type);
896
+ if($type=='jpeg')
897
+ $type = 'jpg';
898
+ $mtd = '_parse'.$type;
899
+ if(!method_exists($this,$mtd))
900
+ $this->Error('Unsupported image type: '.$type);
901
+ $info = $this->$mtd($file);
902
+ $info['i'] = count($this->images)+1;
903
+ $this->images[$file] = $info;
904
+ }
905
+ else
906
+ $info = $this->images[$file];
907
+
908
+ // Automatic width and height calculation if needed
909
+ if($w==0 && $h==0)
910
+ {
911
+ // Put image at 96 dpi
912
+ $w = -96;
913
+ $h = -96;
914
+ }
915
+ if($w<0)
916
+ $w = -$info['w']*72/$w/$this->k;
917
+ if($h<0)
918
+ $h = -$info['h']*72/$h/$this->k;
919
+ if($w==0)
920
+ $w = $h*$info['w']/$info['h'];
921
+ if($h==0)
922
+ $h = $w*$info['h']/$info['w'];
923
+
924
+ // Flowing mode
925
+ if($y===null)
926
+ {
927
+ if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
928
+ {
929
+ // Automatic page break
930
+ $x2 = $this->x;
931
+ $this->AddPage($this->CurOrientation,$this->CurPageSize);
932
+ $this->x = $x2;
933
+ }
934
+ $y = $this->y;
935
+ $this->y += $h;
936
+ }
937
+
938
+ if($x===null)
939
+ $x = $this->x;
940
+ $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']));
941
+ if($link)
942
+ $this->Link($x,$y,$w,$h,$link);
943
+ }
944
+
945
+ function GetX()
946
+ {
947
+ // Get x position
948
+ return $this->x;
949
+ }
950
+
951
+ function SetX($x)
952
+ {
953
+ // Set x position
954
+ if($x>=0)
955
+ $this->x = $x;
956
+ else
957
+ $this->x = $this->w+$x;
958
+ }
959
+
960
+ function GetY()
961
+ {
962
+ // Get y position
963
+ return $this->y;
964
+ }
965
+
966
+ function SetY($y)
967
+ {
968
+ // Set y position and reset x
969
+ $this->x = $this->lMargin;
970
+ if($y>=0)
971
+ $this->y = $y;
972
+ else
973
+ $this->y = $this->h+$y;
974
+ }
975
+
976
+ function SetXY($x, $y)
977
+ {
978
+ // Set x and y positions
979
+ $this->SetY($y);
980
+ $this->SetX($x);
981
+ }
982
+
983
+ function Output($name='', $dest='')
984
+ {
985
+ // Output PDF to some destination
986
+ if($this->state<3)
987
+ $this->Close();
988
+ $dest = strtoupper($dest);
989
+ if($dest=='')
990
+ {
991
+ if($name=='')
992
+ {
993
+ $name = 'doc.pdf';
994
+ $dest = 'I';
995
+ }
996
+ else
997
+ $dest = 'F';
998
+ }
999
+ switch($dest)
1000
+ {
1001
+ case 'I':
1002
+ // Send to standard output
1003
+ $this->_checkoutput();
1004
+ if(PHP_SAPI!='cli')
1005
+ {
1006
+ // We send to a browser
1007
+ header('Content-Type: application/pdf');
1008
+ header('Content-Disposition: inline; filename="'.$name.'"');
1009
+ header('Cache-Control: private, max-age=0, must-revalidate');
1010
+ header('Pragma: public');
1011
+ }
1012
+ echo $this->buffer;
1013
+ break;
1014
+ case 'D':
1015
+ // Download file
1016
+ $this->_checkoutput();
1017
+ header('Content-Type: application/x-download');
1018
+ header('Content-Disposition: attachment; filename="'.$name.'"');
1019
+ header('Cache-Control: private, max-age=0, must-revalidate');
1020
+ header('Pragma: public');
1021
+ echo $this->buffer;
1022
+ break;
1023
+ case 'F':
1024
+ // Save to local file
1025
+ $f = fopen($name,'wb');
1026
+ if(!$f)
1027
+ $this->Error('Unable to create output file: '.$name);
1028
+ fwrite($f,$this->buffer,strlen($this->buffer));
1029
+ fclose($f);
1030
+ break;
1031
+ case 'S':
1032
+ // Return as a string
1033
+ return $this->buffer;
1034
+ default:
1035
+ $this->Error('Incorrect output destination: '.$dest);
1036
+ }
1037
+ return '';
1038
+ }
1039
+
1040
+ /*******************************************************************************
1041
+ * *
1042
+ * Protected methods *
1043
+ * *
1044
+ *******************************************************************************/
1045
+ function _dochecks()
1046
+ {
1047
+ // Check availability of %F
1048
+ if(sprintf('%.1F',1.0)!='1.0')
1049
+ $this->Error('This version of PHP is not supported');
1050
+ // Check mbstring overloading
1051
+ if(ini_get('mbstring.func_overload') & 2)
1052
+ $this->Error('mbstring overloading must be disabled');
1053
+ // Ensure runtime magic quotes are disabled
1054
+ if(get_magic_quotes_runtime())
1055
+ @set_magic_quotes_runtime(0);
1056
+ }
1057
+
1058
+ function _checkoutput()
1059
+ {
1060
+ if(PHP_SAPI!='cli')
1061
+ {
1062
+ if(headers_sent($file,$line))
1063
+ $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1064
+ }
1065
+ if(ob_get_length())
1066
+ {
1067
+ // The output buffer is not empty
1068
+ if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents()))
1069
+ {
1070
+ // It contains only a UTF-8 BOM and/or whitespace, let's clean it
1071
+ ob_clean();
1072
+ }
1073
+ else
1074
+ $this->Error("Some data has already been output, can't send PDF file");
1075
+ }
1076
+ }
1077
+
1078
+ function _getpagesize($size)
1079
+ {
1080
+ if(is_string($size))
1081
+ {
1082
+ $size = strtolower($size);
1083
+ if(!isset($this->StdPageSizes[$size]))
1084
+ $this->Error('Unknown page size: '.$size);
1085
+ $a = $this->StdPageSizes[$size];
1086
+ return array($a[0]/$this->k, $a[1]/$this->k);
1087
+ }
1088
+ else
1089
+ {
1090
+ if($size[0]>$size[1])
1091
+ return array($size[1], $size[0]);
1092
+ else
1093
+ return $size;
1094
+ }
1095
+ }
1096
+
1097
+ function _beginpage($orientation, $size)
1098
+ {
1099
+ $this->page++;
1100
+ $this->pages[$this->page] = '';
1101
+ $this->state = 2;
1102
+ $this->x = $this->lMargin;
1103
+ $this->y = $this->tMargin;
1104
+ $this->FontFamily = '';
1105
+ // Check page size and orientation
1106
+ if($orientation=='')
1107
+ $orientation = $this->DefOrientation;
1108
+ else
1109
+ $orientation = strtoupper($orientation[0]);
1110
+ if($size=='')
1111
+ $size = $this->DefPageSize;
1112
+ else
1113
+ $size = $this->_getpagesize($size);
1114
+ if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
1115
+ {
1116
+ // New size or orientation
1117
+ if($orientation=='P')
1118
+ {
1119
+ $this->w = $size[0];
1120
+ $this->h = $size[1];
1121
+ }
1122
+ else
1123
+ {
1124
+ $this->w = $size[1];
1125
+ $this->h = $size[0];
1126
+ }
1127
+ $this->wPt = $this->w*$this->k;
1128
+ $this->hPt = $this->h*$this->k;
1129
+ $this->PageBreakTrigger = $this->h-$this->bMargin;
1130
+ $this->CurOrientation = $orientation;
1131
+ $this->CurPageSize = $size;
1132
+ }
1133
+ if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
1134
+ $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1135
+ }
1136
+
1137
+ function _endpage()
1138
+ {
1139
+ $this->state = 1;
1140
+ }
1141
+
1142
+ function _loadfont($font)
1143
+ {
1144
+ // Load a font definition file from the font directory
1145
+ include($this->fontpath.$font);
1146
+ $a = get_defined_vars();
1147
+ if(!isset($a['name']))
1148
+ $this->Error('Could not include font definition file');
1149
+ return $a;
1150
+ }
1151
+
1152
+ function _escape($s)
1153
+ {
1154
+ // Escape special characters in strings
1155
+ $s = str_replace('\\','\\\\',$s);
1156
+ $s = str_replace('(','\\(',$s);
1157
+ $s = str_replace(')','\\)',$s);
1158
+ $s = str_replace("\r",'\\r',$s);
1159
+ return $s;
1160
+ }
1161
+
1162
+ function _textstring($s)
1163
+ {
1164
+ // Format a text string
1165
+ return '('.$this->_escape($s).')';
1166
+ }
1167
+
1168
+ function _UTF8toUTF16($s)
1169
+ {
1170
+ // Convert UTF-8 to UTF-16BE with BOM
1171
+ $res = "\xFE\xFF";
1172
+ $nb = strlen($s);
1173
+ $i = 0;
1174
+ while($i<$nb)
1175
+ {
1176
+ $c1 = ord($s[$i++]);
1177
+ if($c1>=224)
1178
+ {
1179
+ // 3-byte character
1180
+ $c2 = ord($s[$i++]);
1181
+ $c3 = ord($s[$i++]);
1182
+ $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1183
+ $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1184
+ }
1185
+ elseif($c1>=192)
1186
+ {
1187
+ // 2-byte character
1188
+ $c2 = ord($s[$i++]);
1189
+ $res .= chr(($c1 & 0x1C)>>2);
1190
+ $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1191
+ }
1192
+ else
1193
+ {
1194
+ // Single-byte character
1195
+ $res .= "\0".chr($c1);
1196
+ }
1197
+ }
1198
+ return $res;
1199
+ }
1200
+
1201
+ function _dounderline($x, $y, $txt)
1202
+ {
1203
+ // Underline text
1204
+ $up = $this->CurrentFont['up'];
1205
+ $ut = $this->CurrentFont['ut'];
1206
+ $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
1207
+ 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);
1208
+ }
1209
+
1210
+ function _parsejpg($file)
1211
+ {
1212
+ // Extract info from a JPEG file
1213
+ $a = getimagesize($file);
1214
+ if(!$a)
1215
+ $this->Error('Missing or incorrect image file: '.$file);
1216
+ if($a[2]!=2)
1217
+ $this->Error('Not a JPEG file: '.$file);
1218
+ if(!isset($a['channels']) || $a['channels']==3)
1219
+ $colspace = 'DeviceRGB';
1220
+ elseif($a['channels']==4)
1221
+ $colspace = 'DeviceCMYK';
1222
+ else
1223
+ $colspace = 'DeviceGray';
1224
+ $bpc = isset($a['bits']) ? $a['bits'] : 8;
1225
+ $data = file_get_contents($file);
1226
+ return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227
+ }
1228
+
1229
+ function _parsepng($file)
1230
+ {
1231
+ // Extract info from a PNG file
1232
+ $f = fopen($file,'rb');
1233
+ if(!$f)
1234
+ $this->Error('Can\'t open image file: '.$file);
1235
+ $info = $this->_parsepngstream($f,$file);
1236
+ fclose($f);
1237
+ return $info;
1238
+ }
1239
+
1240
+ function _parsepngstream($f, $file)
1241
+ {
1242
+ // Check signature
1243
+ if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1244
+ $this->Error('Not a PNG file: '.$file);
1245
+
1246
+ // Read header chunk
1247
+ $this->_readstream($f,4);
1248
+ if($this->_readstream($f,4)!='IHDR')
1249
+ $this->Error('Incorrect PNG file: '.$file);
1250
+ $w = $this->_readint($f);
1251
+ $h = $this->_readint($f);
1252
+ $bpc = ord($this->_readstream($f,1));
1253
+ if($bpc>8)
1254
+ $this->Error('16-bit depth not supported: '.$file);
1255
+ $ct = ord($this->_readstream($f,1));
1256
+ if($ct==0 || $ct==4)
1257
+ $colspace = 'DeviceGray';
1258
+ elseif($ct==2 || $ct==6)
1259
+ $colspace = 'DeviceRGB';
1260
+ elseif($ct==3)
1261
+ $colspace = 'Indexed';
1262
+ else
1263
+ $this->Error('Unknown color type: '.$file);
1264
+ if(ord($this->_readstream($f,1))!=0)
1265
+ $this->Error('Unknown compression method: '.$file);
1266
+ if(ord($this->_readstream($f,1))!=0)
1267
+ $this->Error('Unknown filter method: '.$file);
1268
+ if(ord($this->_readstream($f,1))!=0)
1269
+ $this->Error('Interlacing not supported: '.$file);
1270
+ $this->_readstream($f,4);
1271
+ $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1272
+
1273
+ // Scan chunks looking for palette, transparency and image data
1274
+ $pal = '';
1275
+ $trns = '';
1276
+ $data = '';
1277
+ do
1278
+ {
1279
+ $n = $this->_readint($f);
1280
+ $type = $this->_readstream($f,4);
1281
+ if($type=='PLTE')
1282
+ {
1283
+ // Read palette
1284
+ $pal = $this->_readstream($f,$n);
1285
+ $this->_readstream($f,4);
1286
+ }
1287
+ elseif($type=='tRNS')
1288
+ {
1289
+ // Read transparency info
1290
+ $t = $this->_readstream($f,$n);
1291
+ if($ct==0)
1292
+ $trns = array(ord(substr($t,1,1)));
1293
+ elseif($ct==2)
1294
+ $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1295
+ else
1296
+ {
1297
+ $pos = strpos($t,chr(0));
1298
+ if($pos!==false)
1299
+ $trns = array($pos);
1300
+ }
1301
+ $this->_readstream($f,4);
1302
+ }
1303
+ elseif($type=='IDAT')
1304
+ {
1305
+ // Read image data block
1306
+ $data .= $this->_readstream($f,$n);
1307
+ $this->_readstream($f,4);
1308
+ }
1309
+ elseif($type=='IEND')
1310
+ break;
1311
+ else
1312
+ $this->_readstream($f,$n+4);
1313
+ }
1314
+ while($n);
1315
+
1316
+ if($colspace=='Indexed' && empty($pal))
1317
+ $this->Error('Missing palette in '.$file);
1318
+ $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
1319
+ if($ct>=4)
1320
+ {
1321
+ // Extract alpha channel
1322
+ if(!function_exists('gzuncompress'))
1323
+ $this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
1324
+ $data = gzuncompress($data);
1325
+ $color = '';
1326
+ $alpha = '';
1327
+ if($ct==4)
1328
+ {
1329
+ // Gray image
1330
+ $len = 2*$w;
1331
+ for($i=0;$i<$h;$i++)
1332
+ {
1333
+ $pos = (1+$len)*$i;
1334
+ $color .= $data[$pos];
1335
+ $alpha .= $data[$pos];
1336
+ $line = substr($data,$pos+1,$len);
1337
+ $color .= preg_replace('/(.)./s','$1',$line);
1338
+ $alpha .= preg_replace('/.(.)/s','$1',$line);
1339
+ }
1340
+ }
1341
+ else
1342
+ {
1343
+ // RGB image
1344
+ $len = 4*$w;
1345
+ for($i=0;$i<$h;$i++)
1346
+ {
1347
+ $pos = (1+$len)*$i;
1348
+ $color .= $data[$pos];
1349
+ $alpha .= $data[$pos];
1350
+ $line = substr($data,$pos+1,$len);
1351
+ $color .= preg_replace('/(.{3})./s','$1',$line);
1352
+ $alpha .= preg_replace('/.{3}(.)/s','$1',$line);
1353
+ }
1354
+ }
1355
+ unset($data);
1356
+ $data = gzcompress($color);
1357
+ $info['smask'] = gzcompress($alpha);
1358
+ if($this->PDFVersion<'1.4')
1359
+ $this->PDFVersion = '1.4';
1360
+ }
1361
+ $info['data'] = $data;
1362
+ return $info;
1363
+ }
1364
+
1365
+ function _readstream($f, $n)
1366
+ {
1367
+ // Read n bytes from stream
1368
+ $res = '';
1369
+ while($n>0 && !feof($f))
1370
+ {
1371
+ $s = fread($f,$n);
1372
+ if($s===false)
1373
+ $this->Error('Error while reading stream');
1374
+ $n -= strlen($s);
1375
+ $res .= $s;
1376
+ }
1377
+ if($n>0)
1378
+ $this->Error('Unexpected end of stream');
1379
+ return $res;
1380
+ }
1381
+
1382
+ function _readint($f)
1383
+ {
1384
+ // Read a 4-byte integer from stream
1385
+ $a = unpack('Ni',$this->_readstream($f,4));
1386
+ return $a['i'];
1387
+ }
1388
+
1389
+ function _parsegif($file)
1390
+ {
1391
+ // Extract info from a GIF file (via PNG conversion)
1392
+ if(!function_exists('imagepng'))
1393
+ $this->Error('GD extension is required for GIF support');
1394
+ if(!function_exists('imagecreatefromgif'))
1395
+ $this->Error('GD has no GIF read support');
1396
+ $im = imagecreatefromgif($file);
1397
+ if(!$im)
1398
+ $this->Error('Missing or incorrect image file: '.$file);
1399
+ imageinterlace($im,0);
1400
+ $f = @fopen('php://temp','rb+');
1401
+ if($f)
1402
+ {
1403
+ // Perform conversion in memory
1404
+ ob_start();
1405
+ imagepng($im);
1406
+ $data = ob_get_clean();
1407
+ imagedestroy($im);
1408
+ fwrite($f,$data);
1409
+ rewind($f);
1410
+ $info = $this->_parsepngstream($f,$file);
1411
+ fclose($f);
1412
+ }
1413
+ else
1414
+ {
1415
+ // Use temporary file
1416
+ $tmp = tempnam('.','gif');
1417
+ if(!$tmp)
1418
+ $this->Error('Unable to create a temporary file');
1419
+ if(!imagepng($im,$tmp))
1420
+ $this->Error('Error while saving to temporary file');
1421
+ imagedestroy($im);
1422
+ $info = $this->_parsepng($tmp);
1423
+ unlink($tmp);
1424
+ }
1425
+ return $info;
1426
+ }
1427
+
1428
+ function _newobj()
1429
+ {
1430
+ // Begin a new object
1431
+ $this->n++;
1432
+ $this->offsets[$this->n] = strlen($this->buffer);
1433
+ $this->_out($this->n.' 0 obj');
1434
+ }
1435
+
1436
+ function _putstream($s)
1437
+ {
1438
+ $this->_out('stream');
1439
+ $this->_out($s);
1440
+ $this->_out('endstream');
1441
+ }
1442
+
1443
+ function _out($s)
1444
+ {
1445
+ // Add a line to the document
1446
+ if($this->state==2)
1447
+ $this->pages[$this->page] .= $s."\n";
1448
+ else
1449
+ $this->buffer .= $s."\n";
1450
+ }
1451
+
1452
+ function _putpages()
1453
+ {
1454
+ $nb = $this->page;
1455
+ if(!empty($this->AliasNbPages))
1456
+ {
1457
+ // Replace number of pages
1458
+ for($n=1;$n<=$nb;$n++)
1459
+ $this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1460
+ }
1461
+ if($this->DefOrientation=='P')
1462
+ {
1463
+ $wPt = $this->DefPageSize[0]*$this->k;
1464
+ $hPt = $this->DefPageSize[1]*$this->k;
1465
+ }
1466
+ else
1467
+ {
1468
+ $wPt = $this->DefPageSize[1]*$this->k;
1469
+ $hPt = $this->DefPageSize[0]*$this->k;
1470
+ }
1471
+ $filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1472
+ for($n=1;$n<=$nb;$n++)
1473
+ {
1474
+ // Page
1475
+ $this->_newobj();
1476
+ $this->_out('<</Type /Page');
1477
+ $this->_out('/Parent 1 0 R');
1478
+ if(isset($this->PageSizes[$n]))
1479
+ $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1480
+ $this->_out('/Resources 2 0 R');
1481
+ if(isset($this->PageLinks[$n]))
1482
+ {
1483
+ // Links
1484
+ $annots = '/Annots [';
1485
+ foreach($this->PageLinks[$n] as $pl)
1486
+ {
1487
+ $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1488
+ $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1489
+ if(is_string($pl[4]))
1490
+ $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1491
+ else
1492
+ {
1493
+ $l = $this->links[$pl[4]];
1494
+ $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1495
+ $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
1496
+ }
1497
+ }
1498
+ $this->_out($annots.']');
1499
+ }
1500
+ if($this->PDFVersion>'1.3')
1501
+ $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1502
+ $this->_out('/Contents '.($this->n+1).' 0 R>>');
1503
+ $this->_out('endobj');
1504
+ // Page content
1505
+ $p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1506
+ $this->_newobj();
1507
+ $this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
1508
+ $this->_putstream($p);
1509
+ $this->_out('endobj');
1510
+ }
1511
+ // Pages root
1512
+ $this->offsets[1] = strlen($this->buffer);
1513
+ $this->_out('1 0 obj');
1514
+ $this->_out('<</Type /Pages');
1515
+ $kids = '/Kids [';
1516
+ for($i=0;$i<$nb;$i++)
1517
+ $kids .= (3+2*$i).' 0 R ';
1518
+ $this->_out($kids.']');
1519
+ $this->_out('/Count '.$nb);
1520
+ $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
1521
+ $this->_out('>>');
1522
+ $this->_out('endobj');
1523
+ }
1524
+
1525
+ function _putfonts()
1526
+ {
1527
+ $nf = $this->n;
1528
+ foreach($this->diffs as $diff)
1529
+ {
1530
+ // Encodings
1531
+ $this->_newobj();
1532
+ $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1533
+ $this->_out('endobj');
1534
+ }
1535
+ foreach($this->FontFiles as $file=>$info)
1536
+ {
1537
+ // Font file embedding
1538
+ $this->_newobj();
1539
+ $this->FontFiles[$file]['n'] = $this->n;
1540
+ $font = file_get_contents($this->fontpath.$file,true);
1541
+ if(!$font)
1542
+ $this->Error('Font file not found: '.$file);
1543
+ $compressed = (substr($file,-2)=='.z');
1544
+ if(!$compressed && isset($info['length2']))
1545
+ $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
1546
+ $this->_out('<</Length '.strlen($font));
1547
+ if($compressed)
1548
+ $this->_out('/Filter /FlateDecode');
1549
+ $this->_out('/Length1 '.$info['length1']);
1550
+ if(isset($info['length2']))
1551
+ $this->_out('/Length2 '.$info['length2'].' /Length3 0');
1552
+ $this->_out('>>');
1553
+ $this->_putstream($font);
1554
+ $this->_out('endobj');
1555
+ }
1556
+ foreach($this->fonts as $k=>$font)
1557
+ {
1558
+ // Font objects
1559
+ $this->fonts[$k]['n'] = $this->n+1;
1560
+ $type = $font['type'];
1561
+ $name = $font['name'];
1562
+ if($type=='Core')
1563
+ {
1564
+ // Core font
1565
+ $this->_newobj();
1566
+ $this->_out('<</Type /Font');
1567
+ $this->_out('/BaseFont /'.$name);
1568
+ $this->_out('/Subtype /Type1');
1569
+ if($name!='Symbol' && $name!='ZapfDingbats')
1570
+ $this->_out('/Encoding /WinAnsiEncoding');
1571
+ $this->_out('>>');
1572
+ $this->_out('endobj');
1573
+ }
1574
+ elseif($type=='Type1' || $type=='TrueType')
1575
+ {
1576
+ // Additional Type1 or TrueType/OpenType font
1577
+ $this->_newobj();
1578
+ $this->_out('<</Type /Font');
1579
+ $this->_out('/BaseFont /'.$name);
1580
+ $this->_out('/Subtype /'.$type);
1581
+ $this->_out('/FirstChar 32 /LastChar 255');
1582
+ $this->_out('/Widths '.($this->n+1).' 0 R');
1583
+ $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1584
+ if(isset($font['diffn']))
1585
+ $this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
1586
+ else
1587
+ $this->_out('/Encoding /WinAnsiEncoding');
1588
+ $this->_out('>>');
1589
+ $this->_out('endobj');
1590
+ // Widths
1591
+ $this->_newobj();
1592
+ $cw = &$font['cw'];
1593
+ $s = '[';
1594
+ for($i=32;$i<=255;$i++)
1595
+ $s .= $cw[chr($i)].' ';
1596
+ $this->_out($s.']');
1597
+ $this->_out('endobj');
1598
+ // Descriptor
1599
+ $this->_newobj();
1600
+ $s = '<</Type /FontDescriptor /FontName /'.$name;
1601
+ foreach($font['desc'] as $k=>$v)
1602
+ $s .= ' /'.$k.' '.$v;
1603
+ if(!empty($font['file']))
1604
+ $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
1605
+ $this->_out($s.'>>');
1606
+ $this->_out('endobj');
1607
+ }
1608
+ else
1609
+ {
1610
+ // Allow for additional types
1611
+ $mtd = '_put'.strtolower($type);
1612
+ if(!method_exists($this,$mtd))
1613
+ $this->Error('Unsupported font type: '.$type);
1614
+ $this->$mtd($font);
1615
+ }
1616
+ }
1617
+ }
1618
+
1619
+ function _putimages()
1620
+ {
1621
+ foreach(array_keys($this->images) as $file)
1622
+ {
1623
+ $this->_putimage($this->images[$file]);
1624
+ unset($this->images[$file]['data']);
1625
+ unset($this->images[$file]['smask']);
1626
+ }
1627
+ }
1628
+
1629
+ function _putimage(&$info)
1630
+ {
1631
+ $this->_newobj();
1632
+ $info['n'] = $this->n;
1633
+ $this->_out('<</Type /XObject');
1634
+ $this->_out('/Subtype /Image');
1635
+ $this->_out('/Width '.$info['w']);
1636
+ $this->_out('/Height '.$info['h']);
1637
+ if($info['cs']=='Indexed')
1638
+ $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1639
+ else
1640
+ {
1641
+ $this->_out('/ColorSpace /'.$info['cs']);
1642
+ if($info['cs']=='DeviceCMYK')
1643
+ $this->_out('/Decode [1 0 1 0 1 0 1 0]');
1644
+ }
1645
+ $this->_out('/BitsPerComponent '.$info['bpc']);
1646
+ if(isset($info['f']))
1647
+ $this->_out('/Filter /'.$info['f']);
1648
+ if(isset($info['dp']))
1649
+ $this->_out('/DecodeParms <<'.$info['dp'].'>>');
1650
+ if(isset($info['trns']) && is_array($info['trns']))
1651
+ {
1652
+ $trns = '';
1653
+ for($i=0;$i<count($info['trns']);$i++)
1654
+ $trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1655
+ $this->_out('/Mask ['.$trns.']');
1656
+ }
1657
+ if(isset($info['smask']))
1658
+ $this->_out('/SMask '.($this->n+1).' 0 R');
1659
+ $this->_out('/Length '.strlen($info['data']).'>>');
1660
+ $this->_putstream($info['data']);
1661
+ $this->_out('endobj');
1662
+ // Soft mask
1663
+ if(isset($info['smask']))
1664
+ {
1665
+ $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
1666
+ $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']);
1667
+ $this->_putimage($smask);
1668
+ }
1669
+ // Palette
1670
+ if($info['cs']=='Indexed')
1671
+ {
1672
+ $filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1673
+ $pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
1674
+ $this->_newobj();
1675
+ $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
1676
+ $this->_putstream($pal);
1677
+ $this->_out('endobj');
1678
+ }
1679
+ }
1680
+
1681
+ function _putxobjectdict()
1682
+ {
1683
+ foreach($this->images as $image)
1684
+ $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1685
+ }
1686
+
1687
+ function _putresourcedict()
1688
+ {
1689
+ $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1690
+ $this->_out('/Font <<');
1691
+ foreach($this->fonts as $font)
1692
+ $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1693
+ $this->_out('>>');
1694
+ $this->_out('/XObject <<');
1695
+ $this->_putxobjectdict();
1696
+ $this->_out('>>');
1697
+ }
1698
+
1699
+ function _putresources()
1700
+ {
1701
+ $this->_putfonts();
1702
+ $this->_putimages();
1703
+ // Resource dictionary
1704
+ $this->offsets[2] = strlen($this->buffer);
1705
+ $this->_out('2 0 obj');
1706
+ $this->_out('<<');
1707
+ $this->_putresourcedict();
1708
+ $this->_out('>>');
1709
+ $this->_out('endobj');
1710
+ }
1711
+
1712
+ function _putinfo()
1713
+ {
1714
+ $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1715
+ if(!empty($this->title))
1716
+ $this->_out('/Title '.$this->_textstring($this->title));
1717
+ if(!empty($this->subject))
1718
+ $this->_out('/Subject '.$this->_textstring($this->subject));
1719
+ if(!empty($this->author))
1720
+ $this->_out('/Author '.$this->_textstring($this->author));
1721
+ if(!empty($this->keywords))
1722
+ $this->_out('/Keywords '.$this->_textstring($this->keywords));
1723
+ if(!empty($this->creator))
1724
+ $this->_out('/Creator '.$this->_textstring($this->creator));
1725
+ $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1726
+ }
1727
+
1728
+ function _putcatalog()
1729
+ {
1730
+ $this->_out('/Type /Catalog');
1731
+ $this->_out('/Pages 1 0 R');
1732
+ if($this->ZoomMode=='fullpage')
1733
+ $this->_out('/OpenAction [3 0 R /Fit]');
1734
+ elseif($this->ZoomMode=='fullwidth')
1735
+ $this->_out('/OpenAction [3 0 R /FitH null]');
1736
+ elseif($this->ZoomMode=='real')
1737
+ $this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1738
+ elseif(!is_string($this->ZoomMode))
1739
+ $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
1740
+ if($this->LayoutMode=='single')
1741
+ $this->_out('/PageLayout /SinglePage');
1742
+ elseif($this->LayoutMode=='continuous')
1743
+ $this->_out('/PageLayout /OneColumn');
1744
+ elseif($this->LayoutMode=='two')
1745
+ $this->_out('/PageLayout /TwoColumnLeft');
1746
+ }
1747
+
1748
+ function _putheader()
1749
+ {
1750
+ $this->_out('%PDF-'.$this->PDFVersion);
1751
+ }
1752
+
1753
+ function _puttrailer()
1754
+ {
1755
+ $this->_out('/Size '.($this->n+1));
1756
+ $this->_out('/Root '.$this->n.' 0 R');
1757
+ $this->_out('/Info '.($this->n-1).' 0 R');
1758
+ }
1759
+
1760
+ function _enddoc()
1761
+ {
1762
+ $this->_putheader();
1763
+ $this->_putpages();
1764
+ $this->_putresources();
1765
+ // Info
1766
+ $this->_newobj();
1767
+ $this->_out('<<');
1768
+ $this->_putinfo();
1769
+ $this->_out('>>');
1770
+ $this->_out('endobj');
1771
+ // Catalog
1772
+ $this->_newobj();
1773
+ $this->_out('<<');
1774
+ $this->_putcatalog();
1775
+ $this->_out('>>');
1776
+ $this->_out('endobj');
1777
+ // Cross-ref
1778
+ $o = strlen($this->buffer);
1779
+ $this->_out('xref');
1780
+ $this->_out('0 '.($this->n+1));
1781
+ $this->_out('0000000000 65535 f ');
1782
+ for($i=1;$i<=$this->n;$i++)
1783
+ $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1784
+ // Trailer
1785
+ $this->_out('trailer');
1786
+ $this->_out('<<');
1787
+ $this->_puttrailer();
1788
+ $this->_out('>>');
1789
+ $this->_out('startxref');
1790
+ $this->_out($o);
1791
+ $this->_out('%%EOF');
1792
+ $this->state = 3;
1793
+ }
1794
+ // End of class
1795
+ }
1796
+
1797
+ // Handle special IE contype request
1798
+ if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
1799
+ {
1800
+ header('Content-Type: application/pdf');
1801
+ exit;
1802
+ }
1803
+
1804
+ ?>
includes/mlw_alerts.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MlwQmnAlertManager {
3
+
4
+ public $alerts = array();
5
+
6
+ public function newAlert($message, $type)
7
+ {
8
+ $this->alerts[] = array( 'message' => $message, 'type' => $type );
9
+ }
10
+
11
+ public function showAlerts()
12
+ {
13
+ $alert_list = "";
14
+ foreach ($this->alerts as $alert)
15
+ {
16
+ if ($alert['type'] == "success")
17
+ {
18
+ $alert_list .= "<div id=\"message\" class=\"updated below-h2\"><p><strong>Success! </strong>".$alert["message"]."</p></div>";
19
+ }
20
+ if ($alert['type'] == "error")
21
+ {
22
+ $alert_list .= "<div id=\"message\" class=\"error below-h2\"><p><strong>Error! </strong>".$alert["message"]."</p></div>";
23
+ }
24
+ }
25
+ echo $alert_list;
26
+ }
27
+
28
+ }
29
+ $mlwQmnAlertManager = new MlwQmnAlertManager();
30
+ ?>
includes/mlw_qmn_credits.php CHANGED
@@ -1,149 +1,157 @@
1
- <?php
2
- /*
3
- This page shows the about page
4
- */
5
- /*
6
- Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
- */
8
-
9
- function mlw_generate_about_page()
10
- {
11
- //Page Variables
12
- $mlw_quiz_version = get_option('mlw_quiz_master_version');
13
-
14
-
15
- ?>
16
- <!-- css -->
17
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
18
- <!-- jquery scripts -->
19
- <?php
20
- wp_enqueue_script( 'jquery' );
21
- wp_enqueue_script( 'jquery-ui-core' );
22
- wp_enqueue_script( 'jquery-ui-dialog' );
23
- wp_enqueue_script( 'jquery-ui-button' );
24
- wp_enqueue_script( 'jquery-effects-blind' );
25
- wp_enqueue_script( 'jquery-effects-explode' );
26
- ?>
27
- <!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
28
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>-->
29
- <script type="text/javascript">
30
- var $j = jQuery.noConflict();
31
- // increase the default animation speed to exaggerate the effect
32
- $j.fx.speeds._default = 1000;
33
- function mlw_qmn_setTab(tab) {
34
- jQuery("a.nav-tab-active").toggleClass("nav-tab-active");
35
- if (tab == 1)
36
- {
37
- jQuery("#mlw_quiz_what_new").show();
38
- jQuery("#mlw_quiz_changelog").hide();
39
- jQuery("#mlw_quiz_requested").hide();
40
- jQuery("#mlw_qmn_tab_1").toggleClass("nav-tab-active");
41
- }
42
- if (tab == 2)
43
- {
44
- jQuery("#mlw_quiz_what_new").hide();
45
- jQuery("#mlw_quiz_changelog").show();
46
- jQuery("#mlw_quiz_requested").hide();
47
- jQuery("#mlw_qmn_tab_2").toggleClass("nav-tab-active");
48
- }
49
- if (tab == 3)
50
- {
51
- jQuery("#mlw_quiz_what_new").hide();
52
- jQuery("#mlw_quiz_changelog").hide();
53
- jQuery("#mlw_quiz_requested").show();
54
- jQuery("#mlw_qmn_tab_3").toggleClass("nav-tab-active");
55
- }
56
- }
57
- </script>
58
- <style>
59
- div.mlw_qmn_icon_wrap
60
- {
61
- background: <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
62
- background: none, <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
63
- position: absolute;
64
- top: 0;
65
- right: 0;
66
- background-color: #0d97d8;
67
- color: yellow;
68
- background-position: center 24px;
69
- background-size: 85px 85px;
70
- font-size: 14px;
71
- text-align: center;
72
- font-weight: 600;
73
- margin: 5px 0 0;
74
- padding-top: 120px;
75
- height: 40px;
76
- display: inline-block;
77
- width: 150px;
78
- text-rendering: optimizeLegibility;
79
- border: 5px solid #106daa;
80
- -moz-border-radius: 20px;
81
- -webkit-border-radius: 20px;
82
- -khtml-border-radius: 20px;
83
- border-radius: 20px;
84
- }
85
- </style>
86
- <div class="wrap about-wrap">
87
- <h1>Welcome To Quiz Master Next <?php echo $mlw_quiz_version; ?></h1>
88
- <div class="about-text">Thank you for updating!</div>
89
- <div class="mlw_qmn_icon_wrap">Version <?php echo $mlw_quiz_version; ?></div>
90
- <h2 class="nav-tab-wrapper">
91
- <a href="javascript:mlw_qmn_setTab(1);" id="mlw_qmn_tab_1" class="nav-tab nav-tab-active">
92
- What&#8217;s New In 3.3</a>
93
- <a href="javascript:mlw_qmn_setTab(2);" id="mlw_qmn_tab_2" class="nav-tab">
94
- Changelog For <?php echo $mlw_quiz_version; ?> </a>
95
- <a href="javascript:mlw_qmn_setTab(3);" id="mlw_qmn_tab_3" class="nav-tab">
96
- Requested Features</a>
97
- </h2>
98
- <div id="mlw_quiz_what_new">
99
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Duplicate Questions With Quizzes</h2>
100
- <p style="text-align: center;">You can now duplicate your questions with your quizzes when duplicating!</p>
101
- <br />
102
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">New Question Type</h2>
103
- <p style="text-align: center;">You can now use the new Horizontal Multiple Response type to have your multiple reponse check boxes go horizontally instead of vertically.</p>
104
- <br />
105
- <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Our Premium Add-Ons!</h2>
106
- <p style="text-align: center;">We have several new premium add-ons in our WordPress Store: MailPoet Integration (subscribes users to your MailPoet list), MailChimp Integration (subscribes users to your Mailchimp list), Export Results (exports your quiz results), Extra Shortcodes (gives you extra shortcodes to use), User Dashboard (allow users to see the results from all the quizzes they have taken), and Advertisement Be Gone (gets rid of blue-border ads). Visit our <a href="http://mylocalwebstop.com/shop/">WordPress Store</a> for details! </p>
107
- </div>
108
- <div id="mlw_quiz_changelog" style="display: none;">
109
- <h3><?php echo $mlw_quiz_version; ?> (November 14, 2014)</h3>
110
- <ul>
111
- <li>* Minor Backend Change To Quiz Validation</li>
112
- <li>* Disabled Enter Key On Quiz</li>
113
- <li>* Minor Bug Fixes</li>
114
- </ul>
115
- </div>
116
- <div id="mlw_quiz_requested" style="display: none;">
117
- <h3>Requested Features For Future Updates By Premium Support Users</h3>
118
- <ul>
119
- <li>None</li>
120
- </ul>
121
- <h3>Requested Features For Future Updates By Non-Premium Support Users</h3>
122
- <ul>
123
- <li>Importing Questions</li>
124
- <li>Stats For Each Quiz</li>
125
- <li>Force Login/Register Option</li>
126
- <li>Categories</li>
127
- <li>More Social Media Integration</li>
128
- <li>Show Question Amount On Pagination</li>
129
- <li>Required Questions</li>
130
- <li>Allow Quiz To Not Show Start Page</li>
131
- <li>Progress Bar For Timer</li>
132
- <li>Ability To Redirect User Instead Of Showing Results Page</li>
133
- <li>Multi-Delete Option For Quiz Results</li>
134
- <li>Spam Prevention</li>
135
- <li>Graphical Click Aware Questions</li>
136
- <li>Results Bar Graph For Users Taking Polls</li>
137
- <li>Head To Head Comparison Questions</li>
138
- <li>Enhanced Leaderboard</li>
139
- <li>Different Social Media Sharing Text For Different Social Media</li>
140
- <li>Ability To Highlight Incorrect Answers</li>
141
- <li>Set Default Question Type</li>
142
- <li>Show Pop-Up When Clicking Submit</li>
143
- <li>Conditional Continuation To Next Quiz</li>
144
- </ul>
145
- </div>
146
- </div>
147
- <?php
148
- }
149
- ?>
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This page shows the about page
4
+ */
5
+ /*
6
+ Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
7
+ */
8
+
9
+ function mlw_generate_about_page()
10
+ {
11
+ //Page Variables
12
+ $mlw_quiz_version = get_option('mlw_quiz_master_version');
13
+
14
+
15
+ ?>
16
+ <!-- css -->
17
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
18
+ <!-- jquery scripts -->
19
+ <?php
20
+ wp_enqueue_script( 'jquery' );
21
+ wp_enqueue_script( 'jquery-ui-core' );
22
+ wp_enqueue_script( 'jquery-ui-dialog' );
23
+ wp_enqueue_script( 'jquery-ui-button' );
24
+ wp_enqueue_script( 'jquery-effects-blind' );
25
+ wp_enqueue_script( 'jquery-effects-explode' );
26
+ ?>
27
+ <!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
28
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>-->
29
+ <script type="text/javascript">
30
+ var $j = jQuery.noConflict();
31
+ // increase the default animation speed to exaggerate the effect
32
+ $j.fx.speeds._default = 1000;
33
+ function mlw_qmn_setTab(tab) {
34
+ jQuery("a.nav-tab-active").toggleClass("nav-tab-active");
35
+ if (tab == 1)
36
+ {
37
+ jQuery("#mlw_quiz_what_new").show();
38
+ jQuery("#mlw_quiz_changelog").hide();
39
+ jQuery("#mlw_quiz_requested").hide();
40
+ jQuery("#mlw_qmn_tab_1").toggleClass("nav-tab-active");
41
+ }
42
+ if (tab == 2)
43
+ {
44
+ jQuery("#mlw_quiz_what_new").hide();
45
+ jQuery("#mlw_quiz_changelog").show();
46
+ jQuery("#mlw_quiz_requested").hide();
47
+ jQuery("#mlw_qmn_tab_2").toggleClass("nav-tab-active");
48
+ }
49
+ if (tab == 3)
50
+ {
51
+ jQuery("#mlw_quiz_what_new").hide();
52
+ jQuery("#mlw_quiz_changelog").hide();
53
+ jQuery("#mlw_quiz_requested").show();
54
+ jQuery("#mlw_qmn_tab_3").toggleClass("nav-tab-active");
55
+ }
56
+ }
57
+ </script>
58
+ <style>
59
+ div.mlw_qmn_icon_wrap
60
+ {
61
+ background: <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
62
+ background: none, <?php echo 'url("'.plugins_url( 'images/quiz_icon.png' , __FILE__ ).'")'; ?> no-repeat;
63
+ position: absolute;
64
+ top: 0;
65
+ right: 0;
66
+ background-color: #0d97d8;
67
+ color: yellow;
68
+ background-position: center 24px;
69
+ background-size: 85px 85px;
70
+ font-size: 14px;
71
+ text-align: center;
72
+ font-weight: 600;
73
+ margin: 5px 0 0;
74
+ padding-top: 120px;
75
+ height: 40px;
76
+ display: inline-block;
77
+ width: 150px;
78
+ text-rendering: optimizeLegibility;
79
+ border: 5px solid #106daa;
80
+ -moz-border-radius: 20px;
81
+ -webkit-border-radius: 20px;
82
+ -khtml-border-radius: 20px;
83
+ border-radius: 20px;
84
+ }
85
+ </style>
86
+ <div class="wrap about-wrap">
87
+ <h1>Welcome To Quiz Master Next <?php echo $mlw_quiz_version; ?></h1>
88
+ <div class="about-text">Thank you for updating!</div>
89
+ <div class="mlw_qmn_icon_wrap">Version <?php echo $mlw_quiz_version; ?></div>
90
+ <h2 class="nav-tab-wrapper">
91
+ <a href="javascript:mlw_qmn_setTab(1);" id="mlw_qmn_tab_1" class="nav-tab nav-tab-active">
92
+ What&#8217;s New In 3.4</a>
93
+ <a href="javascript:mlw_qmn_setTab(2);" id="mlw_qmn_tab_2" class="nav-tab">
94
+ Changelog For <?php echo $mlw_quiz_version; ?> </a>
95
+ <a href="javascript:mlw_qmn_setTab(3);" id="mlw_qmn_tab_3" class="nav-tab">
96
+ Requested Features</a>
97
+ </h2>
98
+ <div id="mlw_quiz_what_new">
99
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Preview Mode</h2>
100
+ <p style="text-align: center;">You can now preview your quiz while in the admin side by going to the new Preview tab on the Quiz Settings page!</p>
101
+ <br />
102
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Design Changes</h2>
103
+ <p style="text-align: center;">This version made several design changes to various pages as we continue to redesign our plugin. We also made many design changes in our code!</p>
104
+ <br />
105
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">We Are On GitHub Now</h2>
106
+ <p style="text-align: center;">We have had several users ask for this so we thought we would try it out. We now love github! Be sure to <a href="https://github.com/fpcorso/quiz_master_next/">make suggestions or contribute</a>.</p>
107
+ <br />
108
+ <h2 style="margin: 1.1em 0 .2em;font-size: 2.4em;font-weight: 300;line-height: 1.3;text-align: center;">Our Premium Add-Ons!</h2>
109
+ <p style="text-align: center;">We have several new premium add-ons in our WordPress Store: MailPoet Integration (subscribes users to your MailPoet list), MailChimp Integration (subscribes users to your Mailchimp list), Export Results (exports your quiz results), Extra Shortcodes (gives you extra shortcodes to use), User Dashboard (allow users to see the results from all the quizzes they have taken), and Advertisement Be Gone (gets rid of blue-border ads). Visit our <a href="http://mylocalwebstop.com/shop/">WordPress Store</a> for details! </p>
110
+ </div>
111
+ <div id="mlw_quiz_changelog" style="display: none;">
112
+ <h3><?php echo $mlw_quiz_version; ?> (November 20, 2014)</h3>
113
+ <ul>
114
+ <li>* Added Preview Mode (Beta)</li>
115
+ <li>* Several Design Changes To Quizzes Page</li>
116
+ <li>* Minor Design Changes To Quiz Settings Page</li>
117
+ <li>* Added Completion Time To Quiz Results Page</li>
118
+ <li>* Added Time Taken To Quiz Result Details Page</li>
119
+ <li>* Created New Hook On Quiz Settings Page</li>
120
+ <li>* Broke Apart Quiz Settings Backend Into Smaller Functions That Hook Into New Hook</li>
121
+ <li>* Created New Backend Alert Manager Class To Replace Archaic Old Error System</li>
122
+ </ul>
123
+ </div>
124
+ <div id="mlw_quiz_requested" style="display: none;">
125
+ <h3>Requested Features For Future Updates By Premium Support Users</h3>
126
+ <ul>
127
+ <li>None</li>
128
+ </ul>
129
+ <h3>Requested Features For Future Updates By Non-Premium Support Users</h3>
130
+ <ul>
131
+ <li>Importing Questions</li>
132
+ <li>Stats For Each Quiz</li>
133
+ <li>Force Login/Register Option</li>
134
+ <li>Categories</li>
135
+ <li>More Social Media Integration</li>
136
+ <li>Show Question Amount On Pagination</li>
137
+ <li>Required Questions</li>
138
+ <li>Allow Quiz To Not Show Start Page</li>
139
+ <li>Progress Bar For Timer</li>
140
+ <li>Ability To Redirect User Instead Of Showing Results Page</li>
141
+ <li>Multi-Delete Option For Quiz Results</li>
142
+ <li>Spam Prevention</li>
143
+ <li>Graphical Click Aware Questions</li>
144
+ <li>Results Bar Graph For Users Taking Polls</li>
145
+ <li>Head To Head Comparison Questions</li>
146
+ <li>Enhanced Leaderboard</li>
147
+ <li>Different Social Media Sharing Text For Different Social Media</li>
148
+ <li>Ability To Highlight Incorrect Answers</li>
149
+ <li>Set Default Question Type</li>
150
+ <li>Show Pop-Up When Clicking Submit</li>
151
+ <li>Conditional Continuation To Next Quiz</li>
152
+ </ul>
153
+ </div>
154
+ </div>
155
+ <?php
156
+ }
157
+ ?>
includes/mlw_quiz.php CHANGED
@@ -1,1569 +1,1569 @@
1
- <?php
2
- /*
3
- This function is the very heart of the plugin. This function displays the quiz to the user as well as handles all the scripts that are part of the quiz. Please be very careful if you are editing this script without my assistance.
4
- */
5
- function mlw_quiz_shortcode($atts)
6
- {
7
- extract(shortcode_atts(array(
8
- 'quiz' => 0
9
- ), $atts));
10
-
11
-
12
-
13
- /*
14
- Code before loading the quiz
15
- */
16
-
17
- //Variables needed throughout script
18
- $mlw_quiz_id = intval($quiz);
19
- $GLOBALS['mlw_qmn_quiz'] = $mlw_quiz_id;
20
- $mlw_display = "";
21
- global $wpdb;
22
- $mlw_qmn_isAllowed = true;
23
- $mlw_qmn_section_count = 1;
24
- $mlw_qmn_section_limit = 0;
25
-
26
-
27
- //Load quiz
28
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
29
- $mlw_quiz_options = $wpdb->get_results($sql);
30
-
31
- foreach($mlw_quiz_options as $mlw_eaches) {
32
- $mlw_quiz_options = $mlw_eaches;
33
- break;
34
- }
35
-
36
- //Check to see if there is limit on the amount of tries
37
- if ( $mlw_quiz_options->total_user_tries != 0 && is_user_logged_in() )
38
- {
39
- $current_user = wp_get_current_user();
40
- $mlw_qmn_user_try_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results WHERE email='%s' AND deleted='0' AND quiz_id=%d", $current_user->user_email, $mlw_quiz_id ) );
41
- if ($mlw_qmn_user_try_count >= $mlw_quiz_options->total_user_tries) { $mlw_qmn_isAllowed = false; }
42
- }
43
-
44
-
45
- //Load questions
46
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
47
- if ($mlw_quiz_options->randomness_order == 0)
48
- {
49
- $sql .= "ORDER BY question_order ASC";
50
- }
51
- if ($mlw_quiz_options->randomness_order == 1 || $mlw_quiz_options->randomness_order == 2)
52
- {
53
- $sql .= "ORDER BY rand()";
54
- }
55
- if ($mlw_quiz_options->question_from_total != 0)
56
- {
57
- $sql .= " LIMIT ".$mlw_quiz_options->question_from_total;
58
- }
59
- $mlw_questions = $wpdb->get_results($sql);
60
-
61
-
62
- //Load and prepare answer arrays
63
- $mlw_qmn_answer_arrays = array();
64
- foreach($mlw_questions as $mlw_question_info) {
65
- $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
66
- if ( !is_array($mlw_qmn_answer_array_each) )
67
- {
68
- $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
69
- $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
70
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
71
- array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
72
- array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
73
- array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
74
- array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
75
- array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
76
- array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
77
- }
78
- else
79
- {
80
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
81
- }
82
- }
83
-
84
-
85
- //Variables to load if quiz has been taken
86
- if (isset($_POST["complete_quiz"]) && $_POST["complete_quiz"] == "confirmation")
87
- {
88
- $mlw_success = $_POST["complete_quiz"];
89
- $mlw_user_name = isset($_POST["mlwUserName"]) ? $_POST["mlwUserName"] : 'None';
90
- $mlw_user_comp = isset($_POST["mlwUserComp"]) ? $_POST["mlwUserComp"] : 'None';
91
- $mlw_user_email = isset($_POST["mlwUserEmail"]) ? $_POST["mlwUserEmail"] : 'None';
92
- $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? $_POST["mlwUserPhone"] : 'None';
93
- $mlw_qmn_timer = isset($_POST["timer"]) ? $_POST["timer"] : 0;
94
- $mlw_spam_email = $_POST["email"];
95
- }
96
-
97
- wp_enqueue_script( 'json2' );
98
- wp_enqueue_script( 'jquery' );
99
- wp_enqueue_script( 'jquery-ui-core' );
100
- wp_enqueue_script( 'jquery-effects-core' );
101
- wp_enqueue_script( 'jquery-effects-slide' );
102
- wp_enqueue_script( 'jquery-ui-dialog' );
103
- wp_enqueue_script( 'jquery-ui-button' );
104
- wp_enqueue_script( 'jquery-ui-accordion' );
105
- wp_enqueue_script( 'jquery-ui-tooltip' );
106
- wp_enqueue_script( 'jquery-ui-tabs' );
107
- ?>
108
- <!-- css -->
109
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
110
- <script type="text/javascript">
111
- setTimeout(function(){
112
- var $j = jQuery.noConflict();
113
- // increase the default animation speed to exaggerate the effect
114
- $j.fx.speeds._default = 1000;
115
- $j(function() {
116
- $j( ".mlw_qmn_quiz" ).tooltip();
117
- });
118
- }, 100);
119
- setTimeout(function()
120
- {
121
- var $j = jQuery.noConflict();
122
- $j('.mlw_qmn_quiz input').on('keypress', function (e) {
123
- if (e.which === 13) {
124
- e.preventDefault();
125
- }
126
- });
127
- }, 100);
128
- </script>
129
- <style type="text/css">
130
- .ui-tooltip
131
- {
132
- /* tooltip container box */
133
- max-width: 500px !important;
134
- }
135
- .ui-tooltip-content
136
- {
137
- /* tooltip content */
138
- max-width: 500px !important;
139
- }
140
- </style>
141
-
142
- <?php
143
- if ($mlw_quiz_options->theme_selected == "default")
144
- {
145
- echo "<style type='text/css'>".$mlw_quiz_options->quiz_stye."</style>";
146
- }
147
- else
148
- {
149
- echo "<link type='text/css' href='".get_option('mlw_qmn_theme_'.$mlw_quiz_options->theme_selected)."' rel='stylesheet' />";
150
- }
151
-
152
- /*
153
- The following code is for displaying the quiz and completion screen
154
- */
155
-
156
- //If there is no quiz for the shortcode provided
157
- if ($mlw_quiz_options->quiz_name == "")
158
- {
159
- $mlw_display .= "It appears that this quiz is not set up correctly.";
160
- return $mlw_display;
161
- }
162
-
163
-
164
-
165
- //Display Quiz
166
- if (!isset($_POST["complete_quiz"]) && $mlw_quiz_options->quiz_name != "" && $mlw_qmn_isAllowed)
167
- {
168
- $mlw_qmn_total_questions = 0;
169
- //Calculate number of pages if pagination is turned on
170
- if ($mlw_quiz_options->pagination != 0)
171
- {
172
- $mlw_qmn_section_limit = 2 + count($mlw_questions);
173
- if ($mlw_quiz_options->comment_section == 0)
174
- {
175
- $mlw_qmn_section_limit = $mlw_qmn_section_limit + 1;
176
- }
177
-
178
- //Gather text for pagination buttons
179
- $mlw_qmn_pagination_text = "";
180
- $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
181
- if (!is_array($mlw_qmn_pagination_text)) {
182
- $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
183
- }
184
- ?>
185
- <script type="text/javascript">
186
- setTimeout(function(){
187
- var $j = jQuery.noConflict();
188
- $j( ".quiz_section" ).hide();
189
- $j( ".quiz_section" ).append( "<br />" );
190
- $j( ".mlw_qmn_quiz" ).append( "<a class=\"mlw_qmn_quiz_link mlw_previous\" href=\"javascript:prevSlide(<?php echo $mlw_quiz_options->pagination; ?>, 1);\"><?php echo $mlw_qmn_pagination_text[0]; ?></a>" );
191
- $j( ".mlw_qmn_quiz" ).append( "<a class=\"mlw_qmn_quiz_link mlw_next\" href=\"javascript:nextSlide(<?php echo $mlw_quiz_options->pagination; ?>, 1);\"><?php echo $mlw_qmn_pagination_text[1]; ?></a>" );
192
- window.mlw_quiz_slide = 0;
193
- window.mlw_previous = 0;
194
- window.mlw_quiz_total_slides = <?php echo $mlw_qmn_section_limit; ?>;
195
- nextSlide(1, 0);
196
- }, 100);
197
- function nextSlide(mlw_pagination, mlw_goto_top)
198
- {
199
- jQuery( ".quiz_section" ).hide();
200
- for (var i = 0; i < mlw_pagination; i++)
201
- {
202
- if (i == 0 && window.mlw_previous == 1 && window.mlw_quiz_slide > 1)
203
- {
204
- window.mlw_quiz_slide = window.mlw_quiz_slide + mlw_pagination;
205
- }
206
- else
207
- {
208
- window.mlw_quiz_slide++;
209
- }
210
- if (window.mlw_quiz_slide < 1)
211
- {
212
- window.mlw_quiz_slide = 1;
213
- }
214
- if (window.mlw_quiz_slide == 1)
215
- {
216
- jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).hide();
217
- }
218
- if (window.mlw_quiz_slide > 1)
219
- {
220
- jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).show();
221
- }
222
- if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
223
- {
224
- jQuery( ".mlw_qmn_quiz_link.mlw_next" ).hide();
225
- }
226
- if (window.mlw_quiz_slide < window.mlw_quiz_total_slides)
227
- {
228
- jQuery( ".mlw_qmn_quiz_link.mlw_next" ).show();
229
- }
230
- jQuery( ".quiz_section.slide"+window.mlw_quiz_slide ).show();
231
- }
232
- window.mlw_previous = 0;
233
- if (mlw_goto_top == 1)
234
- {
235
- window.location.hash = "mlw_does_not_exist";
236
- window.location.hash = "mlw_top_of_quiz";
237
- }
238
-
239
- }
240
- function prevSlide(mlw_pagination, mlw_goto_top)
241
- {
242
- jQuery( ".quiz_section" ).hide();
243
- for (var i = 0; i < mlw_pagination; i++)
244
- {
245
- if (i == 0 && window.mlw_previous == 0)
246
- {
247
- window.mlw_quiz_slide = window.mlw_quiz_slide - mlw_pagination;
248
- }
249
- else
250
- {
251
- window.mlw_quiz_slide--;
252
- }
253
- if (window.mlw_quiz_slide < 1)
254
- {
255
- window.mlw_quiz_slide = 1;
256
- }
257
- if (window.mlw_quiz_slide == 1)
258
- {
259
- jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).hide();
260
- }
261
- if (window.mlw_quiz_slide > 1)
262
- {
263
- jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).show();
264
- }
265
- if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
266
- {
267
- jQuery( ".mlw_qmn_quiz_link.mlw_next" ).hide();
268
- }
269
- if (window.mlw_quiz_slide < window.mlw_quiz_total_slides)
270
- {
271
- jQuery( ".mlw_qmn_quiz_link.mlw_next" ).show();
272
- }
273
- jQuery( ".quiz_section.slide"+window.mlw_quiz_slide ).show();
274
- }
275
- window.mlw_previous = 1;
276
- if (mlw_goto_top == 1)
277
- {
278
- window.location.hash = "mlw_does_not_exist";
279
- window.location.hash = "mlw_top_of_quiz";
280
- }
281
- }
282
- </script>
283
- <?php
284
- }
285
- if ($mlw_quiz_options->timer_limit != 0)
286
- {
287
- ?>
288
- <div id="mlw_qmn_timer" class="mlw_qmn_timer"></div>
289
- <script type="text/javascript">
290
- setTimeout(function(){
291
- var minutes = 0;
292
- if (window.sessionStorage.getItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>') == "yes" && window.sessionStorage.getItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>') >= 0)
293
- {
294
- minutes = window.sessionStorage.getItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>');
295
- }
296
- else
297
- {
298
- minutes = <?php echo $mlw_quiz_options->timer_limit; ?>;
299
- }
300
- window.amount = (minutes*60);
301
- window.titleText = window.document.title;
302
- document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
303
- window.counter=setInterval(timer, 1000);
304
- }, 100);
305
- function timer()
306
- {
307
- window.amount=window.amount-1;
308
- if (window.amount < 0)
309
- {
310
- window.amount = 0;
311
- }
312
- window.sessionStorage.setItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>', window.amount/60);
313
- window.sessionStorage.setItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>', "yes");
314
- document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
315
- window.document.title = minToSec(window.amount) + " " + window.titleText;
316
- if (window.amount <= 0)
317
- {
318
- clearInterval(window.counter);
319
- jQuery( ".mlw_qmn_quiz input:radio" ).attr('disabled',true);
320
- jQuery( ".mlw_qmn_quiz input:checkbox" ).attr('disabled',true);
321
- jQuery( ".mlw_qmn_quiz select" ).attr('disabled',true);
322
- jQuery( ".mlw_qmn_question_comment" ).attr('disabled',true);
323
- jQuery( ".mlw_answer_open_text" ).attr('disabled',true);
324
- //document.quizForm.submit();
325
- return;
326
- }
327
- }
328
- function minToSec(amount)
329
- {
330
- var minutes = Math.floor(amount/60);
331
- var seconds = amount - (minutes * 60);
332
- if (seconds == '0')
333
- {
334
- seconds = "00";
335
- }
336
- else if (seconds < 10)
337
- {
338
- seconds = '0' + seconds;
339
- }
340
- return minutes+":"+seconds;
341
- }
342
- </script>
343
- <?php
344
- }
345
-
346
- ?>
347
- <script type="text/javascript">
348
- var myVar=setInterval("mlwQmnTimer();",1000);
349
- function mlwQmnTimer()
350
- {
351
- var x = +document.getElementById("timer").value;
352
- x = x + 1;
353
- document.getElementById("timer").value = x;
354
- }
355
-
356
- </script>
357
- <?php
358
- //Update the quiz views
359
- $mlw_views = $mlw_quiz_options->quiz_views;
360
- $mlw_views += 1;
361
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views='".$mlw_views."' WHERE quiz_id=".$mlw_quiz_id;
362
- $results = $wpdb->query( $update );
363
-
364
- //Form validation script
365
- ?>
366
- <script>
367
- function clear_field(field)
368
- {
369
- if (field.defaultValue == field.value) field.value = '';
370
- }
371
-
372
- function mlw_validateForm()
373
- {
374
- mlw_validateResult = true;
375
- if (document.forms['quizForm']['mlwUserEmail'].value != '')
376
- {
377
- var x=document.forms['quizForm']['mlwUserEmail'].value;
378
- var atpos=x.indexOf('@');
379
- var dotpos=x.lastIndexOf('.');
380
- if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
381
- {
382
- document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**';
383
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**';
384
- mlw_validateResult = false;
385
- }
386
- }
387
-
388
- jQuery('#quizForm *').filter(':input').each(function(){
389
- jQuery(this).css("outline", "");
390
- if (jQuery(this).attr('class'))
391
- {
392
- if(jQuery(this).attr('class').indexOf('mlwRequiredNumber') > -1 && this.value == "" && +this.value != NaN)
393
- {
394
- document.getElementById('mlw_error_message').innerHTML = '**This field must be a number!**';
395
- document.getElementById('mlw_error_message_bottom').innerHTML = '**This field must be a number!**';
396
- jQuery(this).css("outline", "2px solid red");
397
- mlw_validateResult = false;
398
- }
399
- if(jQuery(this).attr('class').indexOf('mlwRequiredText') > -1 && this.value == "")
400
- {
401
- document.getElementById('mlw_error_message').innerHTML = '**Please complete all required fields!**';
402
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Please complete all required fields!**';
403
- jQuery(this).css("outline", "2px solid red");
404
- mlw_validateResult = false;
405
- }
406
- if(jQuery(this).attr('class').indexOf('mlwRequiredCaptcha') > -1 && this.value != mlw_code)
407
- {
408
- document.getElementById('mlw_error_message').innerHTML = '**The entered text is not correct!**';
409
- document.getElementById('mlw_error_message_bottom').innerHTML = '**The entered text is not correct!**';
410
- jQuery(this).css("outline", "2px solid red");
411
- mlw_validateResult = false;
412
- }
413
- if(jQuery(this).attr('class').indexOf('mlwRequiredCheck') > -1 && !this.checked)
414
- {
415
- document.getElementById('mlw_error_message').innerHTML = '**Please complete all required fields!**';
416
- document.getElementById('mlw_error_message_bottom').innerHTML = '**Please complete all required fields!**';
417
- jQuery(this).css("outline", "2px solid red");
418
- mlw_validateResult = false;
419
- }
420
- }
421
- });
422
-
423
- if (!mlw_validateResult) {return mlw_validateResult;}
424
-
425
- jQuery( '.mlw_qmn_quiz input:radio' ).attr('disabled',false);
426
- jQuery( '.mlw_qmn_quiz input:checkbox' ).attr('disabled',false);
427
- jQuery( '.mlw_qmn_quiz select' ).attr('disabled',false);
428
- jQuery( '.mlw_qmn_question_comment' ).attr('disabled',false);
429
- jQuery( '.mlw_answer_open_text' ).attr('disabled',false);
430
- }
431
- </script>
432
- <?php
433
-
434
- if ( $mlw_quiz_options->pagination != 0) { $mlw_display .= "<style>.quiz_section { display: none; }</style>"; }
435
-
436
- //Begin the quiz
437
- $mlw_display .= "<div class='mlw_qmn_quiz'>";
438
- $mlw_display .= "<form name='quizForm' id='quizForm' action='' method='post' class='mlw_quiz_form' onsubmit='return mlw_validateForm()' novalidate >";
439
- $mlw_display .= "<span id='mlw_top_of_quiz'></span>";
440
- $mlw_display .= "<div class='quiz_section quiz_begin slide".$mlw_qmn_section_count."'>";
441
- $mlw_message_before = htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES);
442
- $mlw_message_before = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_before);
443
- $mlw_message_before = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_before);
444
- $mlw_display .= "<span class='mlw_qmn_message_before'>".$mlw_message_before."</span><br />";
445
- $mlw_display .= "<span name='mlw_error_message' id='mlw_error_message' style='color: red;'></span><br />";
446
-
447
- if ($mlw_quiz_options->contact_info_location == 0)
448
- {
449
- $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
450
- }
451
- $mlw_display .= "</div>";
452
-
453
- //Display the questions
454
- foreach($mlw_questions as $mlw_question) {
455
- $mlw_question_settings = @unserialize($mlw_question->question_settings);
456
- if (!is_array($mlw_question_settings))
457
- {
458
- $mlw_question_settings = array();
459
- $mlw_question_settings['required'] = 1;
460
- }
461
- if ( !isset($mlw_question_settings['required']))
462
- {
463
- $mlw_question_settings['required'] = 1;
464
- }
465
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
466
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
467
- if ($mlw_question->question_type == 0)
468
- {
469
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
470
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
471
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
472
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
473
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
474
- if (is_array($mlw_qmn_answer_array))
475
- {
476
- if ($mlw_quiz_options->randomness_order == 2)
477
- {
478
- shuffle($mlw_qmn_answer_array);
479
- }
480
- $mlw_answer_total = 0;
481
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
482
- {
483
- $mlw_answer_total++;
484
- if ($mlw_qmn_answer_each[0] != "")
485
- {
486
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label>";
487
- $mlw_display .= "<br />";
488
- }
489
- }
490
- $mlw_display .= "<input type='radio' style='display: none;' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_none' checked='checked' value='No Answer Provided' />";
491
- }
492
- else
493
- {
494
- if ($mlw_question->answer_one != "")
495
- {
496
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_one' value='1' /> <label for='question".$mlw_question->question_id."_one'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</label>";
497
- $mlw_display .= "<br />";
498
- }
499
- if ($mlw_question->answer_two != "")
500
- {
501
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_two' value='2' /> <label for='question".$mlw_question->question_id."_two'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</label>";
502
- $mlw_display .= "<br />";
503
- }
504
- if ($mlw_question->answer_three != "")
505
- {
506
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_three' value='3' /> <label for='question".$mlw_question->question_id."_three'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</label>";
507
- $mlw_display .= "<br />";
508
- }
509
- if ($mlw_question->answer_four != "")
510
- {
511
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_four' value='4' /> <label for='question".$mlw_question->question_id."_four'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</label>";
512
- $mlw_display .= "<br />";
513
- }
514
- if ($mlw_question->answer_five != "")
515
- {
516
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_five' value='5' /> <label for='question".$mlw_question->question_id."_five'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</label>";
517
- $mlw_display .= "<br />";
518
- }
519
- if ($mlw_question->answer_six != "")
520
- {
521
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_six' value='6' /> <label for='question".$mlw_question->question_id."_six'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</label>";
522
- $mlw_display .= "<br />";
523
- }
524
- }
525
- }
526
- elseif ($mlw_question->question_type == 4)
527
- {
528
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
529
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
530
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
531
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
532
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
533
- if (is_array($mlw_qmn_answer_array))
534
- {
535
- if ($mlw_quiz_options->randomness_order == 2)
536
- {
537
- shuffle($mlw_qmn_answer_array);
538
- }
539
- $mlw_answer_total = 0;
540
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
541
- {
542
- $mlw_answer_total++;
543
- if ($mlw_qmn_answer_each[0] != "")
544
- {
545
- $mlw_display .= "<input type='hidden' name='question".$mlw_question->question_id."' value='This value does not matter' />";
546
- $mlw_display .= "<input type='checkbox' name='question".$mlw_question->question_id."_".$mlw_answer_total."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label>";
547
- $mlw_display .= "<br />";
548
- }
549
- }
550
- }
551
- }
552
- elseif ($mlw_question->question_type == 10)
553
- {
554
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
555
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
556
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
557
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
558
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
559
- if (is_array($mlw_qmn_answer_array))
560
- {
561
- if ($mlw_quiz_options->randomness_order == 2)
562
- {
563
- shuffle($mlw_qmn_answer_array);
564
- }
565
- $mlw_answer_total = 0;
566
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
567
- {
568
- $mlw_answer_total++;
569
- if ($mlw_qmn_answer_each[0] != "")
570
- {
571
- $mlw_display .= "<input type='hidden' name='question".$mlw_question->question_id."' value='This value does not matter' />";
572
- $mlw_display .= "<span class='mlw_horizontal_multiple'><input type='checkbox' name='question".$mlw_question->question_id."_".$mlw_answer_total."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."&nbsp;</label></span>";
573
- }
574
- }
575
- }
576
- }
577
- elseif ($mlw_question->question_type == 1)
578
- {
579
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
580
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
581
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
582
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
583
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
584
- if (is_array($mlw_qmn_answer_array))
585
- {
586
- if ($mlw_quiz_options->randomness_order == 2)
587
- {
588
- shuffle($mlw_qmn_answer_array);
589
- }
590
- $mlw_answer_total = 0;
591
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
592
- {
593
- $mlw_answer_total++;
594
- if ($mlw_qmn_answer_each[0] != "")
595
- {
596
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> ".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)." ";
597
- }
598
- }
599
- $mlw_display .= "<input type='radio' style='display: none;' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_none' checked='checked' value='No Answer Provided' />";
600
- }
601
- else
602
- {
603
- if ($mlw_question->answer_one != "")
604
- {
605
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='1' />".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES);
606
- }
607
- if ($mlw_question->answer_two != "")
608
- {
609
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='2' />".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES);
610
- }
611
- if ($mlw_question->answer_three != "")
612
- {
613
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='3' />".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES);
614
- }
615
- if ($mlw_question->answer_four != "")
616
- {
617
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='4' />".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES);
618
- }
619
- if ($mlw_question->answer_five != "")
620
- {
621
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='5' />".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES);
622
- }
623
- if ($mlw_question->answer_six != "")
624
- {
625
- $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='6' />".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES);
626
- }
627
- }
628
- $mlw_display .= "<br />";
629
- }
630
- elseif ($mlw_question->question_type == 2)
631
- {
632
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
633
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
634
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
635
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
636
- $mlw_display .= "<select name='question".$mlw_question->question_id."'>";
637
- $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
638
- if (is_array($mlw_qmn_answer_array))
639
- {
640
- if ($mlw_quiz_options->randomness_order == 2)
641
- {
642
- shuffle($mlw_qmn_answer_array);
643
- }
644
- $mlw_answer_total = 0;
645
- foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
646
- {
647
- $mlw_answer_total++;
648
- if ($mlw_qmn_answer_each[0] != "")
649
- {
650
- $mlw_display .= "<option value='".esc_attr($mlw_qmn_answer_each[0])."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</option>";
651
- }
652
- }
653
- }
654
- else
655
- {
656
- if ($mlw_question->answer_one != "")
657
- {
658
- $mlw_display .= "<option value='1'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</option>";
659
- }
660
- if ($mlw_question->answer_two != "")
661
- {
662
- $mlw_display .= "<option value='2'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</option>";
663
- }
664
- if ($mlw_question->answer_three != "")
665
- {
666
- $mlw_display .= "<option value='3'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</option>";
667
- }
668
- if ($mlw_question->answer_four != "")
669
- {
670
- $mlw_display .= "<option value='4'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</option>";
671
- }
672
- if ($mlw_question->answer_five != "")
673
- {
674
- $mlw_display .= "<option value='5'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</option>";
675
- }
676
- if ($mlw_question->answer_six != "")
677
- {
678
- $mlw_display .= "<option value='6'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</option>";
679
- }
680
- }
681
- $mlw_display .= "</select>";
682
- $mlw_display .= "<br />";
683
- }
684
- elseif ($mlw_question->question_type == 5)
685
- {
686
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
687
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
688
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
689
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
690
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
691
- $mlw_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$mlw_question->question_id."' /></textarea>";
692
- $mlw_display .= "<br />";
693
- }
694
- elseif ($mlw_question->question_type == 6)
695
- {
696
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES);
697
- $mlw_display .= "<br />";
698
- }
699
- elseif ($mlw_question->question_type == 7)
700
- {
701
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
702
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
703
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
704
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
705
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
706
- $mlw_display .= "<input type='number' class='mlw_answer_number $mlw_requireClass' name='question".$mlw_question->question_id."' />";
707
- $mlw_display .= "<br />";
708
- }
709
- elseif ($mlw_question->question_type == 8)
710
- {
711
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
712
- $mlw_display .= "<input type='checkbox' id='mlwAcceptance' class='$mlw_requireClass ' />";
713
- $mlw_display .= "<label for='mlwAcceptance'><span class='mlw_qmn_question' style='font-weight:bold;'>".htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span></label>";
714
- $mlw_display .= "<br />";
715
- }
716
- elseif ($mlw_question->question_type == 9)
717
- {
718
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredCaptcha";} else {$mlw_requireClass = "";}
719
- $mlw_display .= "<div class='mlw_captchaWrap'>";
720
- $mlw_display .= "<canvas alt='' id='mlw_captcha' class='mlw_captcha' width='100' height='50'></canvas>";
721
- $mlw_display .= "</div>";
722
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
723
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
724
- $mlw_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' id='mlw_captcha_text' name='mlw_user_captcha'/>";
725
- $mlw_display .= "<input type='hidden' name='mlw_code_captcha' id='mlw_code_captcha' value='none' />";
726
- $mlw_display .= "<br />";
727
- $mlw_display .= "<script>
728
- var mlw_code = '';
729
- var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
730
- var mlw_code_length = 5;
731
- for (var i=0; i<mlw_code_length; i++) {
732
- var rnum = Math.floor(Math.random() * mlw_chars.length);
733
- mlw_code += mlw_chars.substring(rnum,rnum+1);
734
- }
735
- var mlw_captchaCTX = document.getElementById('mlw_captcha').getContext('2d');
736
- mlw_captchaCTX.font = 'normal 24px Verdana';
737
- mlw_captchaCTX.strokeStyle = '#000000';
738
- mlw_captchaCTX.clearRect(0,0,100,50);
739
- mlw_captchaCTX.strokeText(mlw_code,10,30,70);
740
- mlw_captchaCTX.textBaseline = 'middle';
741
- document.getElementById('mlw_code_captcha').value = mlw_code;
742
- </script>
743
- ";
744
- }
745
- else
746
- {
747
- $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
748
- $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
749
- if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
750
- $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
751
- if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
752
- $mlw_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$mlw_question->question_id."' />";
753
- $mlw_display .= "<br />";
754
- }
755
- if ($mlw_question->comments == 0)
756
- {
757
- $mlw_display .= "<input type='text' class='mlw_qmn_question_comment' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".esc_attr(htmlspecialchars_decode($mlw_quiz_options->comment_field_text, ENT_QUOTES))."' onclick='clear_field(this)'/>";
758
- $mlw_display .= "<br />";
759
- }
760
- if ($mlw_question->comments == 2)
761
- {
762
- $mlw_display .= "<textarea cols='70' rows='5' class='mlw_qmn_question_comment' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='clear_field(this)'>".htmlspecialchars_decode($mlw_quiz_options->comment_field_text, ENT_QUOTES)."</textarea>";
763
- $mlw_display .= "<br />";
764
- }
765
- if ($mlw_question->hints != "")
766
- {
767
- $mlw_display .= "<span title=\"".htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)."\" style=\"text-decoration:underline;color:rgb(0,0,255);\" class='mlw_qmn_hint_link'>Hint</span>";
768
- $mlw_display .= "<br /><br />";
769
- }
770
- $mlw_display .= "</div>";
771
- if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br />"; }
772
- }
773
-
774
- //Display comment box if needed
775
- if ($mlw_quiz_options->comment_section == 0)
776
- {
777
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
778
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
779
- $mlw_message_comments = htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES);
780
- $mlw_message_comments = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_comments);
781
- $mlw_message_comments = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_comments);
782
- $mlw_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text' style='font-weight:bold;'>".$mlw_message_comments."</label><br />";
783
- $mlw_display .= "<textarea cols='70' rows='15' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
784
- $mlw_display .= "</div>";
785
- if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br /><br />"; }
786
- }
787
- $mlw_display .= "<br />";
788
- $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
789
- $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count." quiz_end'>";
790
- if ($mlw_quiz_options->message_end_template != '')
791
- {
792
- $mlw_message_end = htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES);
793
- $mlw_message_end = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_end);
794
- $mlw_message_end = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_end);
795
- $mlw_display .= "<span class='mlw_qmn_message_end'>".$mlw_message_end."</span>";
796
- $mlw_display .= "<br /><br />";
797
- }
798
- if ($mlw_quiz_options->contact_info_location == 1)
799
- {
800
- $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
801
- }
802
- ob_start();
803
- do_action('mlw_qmn_end_quiz_section');
804
- $mlw_display .= ob_get_contents();
805
- ob_end_clean();
806
- $mlw_display .= "<span style='display: none;'>If you are human, leave this field blank or you will be considered spam:</span>";
807
- $mlw_display .= "<input style='display: none;' type='text' name='email' id='email' />";
808
- $mlw_display .= "<input type='hidden' name='total_questions' id='total_questions' value='".$mlw_qmn_total_questions."'/>";
809
- $mlw_display .= "<input type='hidden' name='timer' id='timer' value='0'/>";
810
- $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
811
- $mlw_display .= "<input type='submit' value='".esc_attr(htmlspecialchars_decode($mlw_quiz_options->submit_button_text, ENT_QUOTES))."' />";
812
- $mlw_display .= "<span name='mlw_error_message_bottom' id='mlw_error_message_bottom' style='color: red;'></span><br />";
813
- $mlw_display .= "</form>";
814
- $mlw_display .= "</div>";
815
- $mlw_display .= "</div>";
816
-
817
- }
818
- //Display Completion Screen
819
- else
820
- {
821
- ?>
822
- <script type="text/javascript">
823
- window.sessionStorage.setItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>', 'completed');
824
- window.sessionStorage.setItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>', "no");
825
- </script>
826
- <?php
827
- if (empty($mlw_spam_email) && $mlw_qmn_isAllowed && ((!isset($_POST["mlw_code_captcha"])) || isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"]))
828
- {
829
-
830
- //Load questions
831
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
832
- if ($mlw_quiz_options->randomness_order == 0)
833
- {
834
- $sql .= "ORDER BY question_order ASC";
835
- }
836
- if ($mlw_quiz_options->randomness_order == 1 || $mlw_quiz_options->randomness_order == 2)
837
- {
838
- $sql .= "ORDER BY rand()";
839
- }
840
- $mlw_questions = $wpdb->get_results($sql);
841
-
842
- //Load and prepare answer arrays
843
- $mlw_qmn_loaded_answer_arrays = array();
844
- foreach($mlw_questions as $mlw_question_info) {
845
- $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
846
- if ( !is_array($mlw_qmn_answer_array_each) )
847
- {
848
- $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
849
- $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
850
- $mlw_qmn_loaded_answer_arrays[$mlw_question_info->question_id] = array(
851
- array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
852
- array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
853
- array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
854
- array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
855
- array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
856
- array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
857
- }
858
- else
859
- {
860
- $mlw_qmn_loaded_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
861
- }
862
- }
863
-
864
- //Variables needed for scoring
865
- $mlw_points = 0;
866
- $mlw_correct = 0;
867
- $mlw_total_questions = 0;
868
- $mlw_total_score = 0;
869
- $mlw_question_answers = "";
870
- isset($_POST["total_questions"]) ? $mlw_total_questions = intval($_POST["total_questions"]) : $mlw_total_questions = 0;
871
-
872
- //Update the amount of times the quiz has been taken
873
- $mlw_taken = $mlw_quiz_options->quiz_taken;
874
- $mlw_taken += 1;
875
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_taken='".$mlw_taken."' WHERE quiz_id=".$mlw_quiz_id;
876
- $results = $wpdb->query( $update );
877
-
878
- //See which answers were correct and award points if necessary
879
- $mlw_user_text = "";
880
- $mlw_correct_text = "";
881
- $mlw_qmn_answer_array = array();
882
- foreach($mlw_questions as $mlw_question) {
883
- $mlw_user_text = "";
884
- $mlw_correct_text = "";
885
- if ( isset($_POST["question".$mlw_question->question_id]) || isset($_POST["mlwComment".$mlw_question->question_id]) )
886
- {
887
- if ( $mlw_question->question_type == 0 || $mlw_question->question_type == 1 || $mlw_question->question_type == 2)
888
- {
889
- if (isset($_POST["question".$mlw_question->question_id]))
890
- {
891
- $mlw_user_answer = $_POST["question".$mlw_question->question_id];
892
- }
893
- else
894
- {
895
- $mlw_user_answer = " ";
896
- }
897
- $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
898
- foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
899
- {
900
- if (htmlspecialchars(stripslashes($mlw_user_answer), ENT_QUOTES) == esc_attr($mlw_qmn_question_answers_each[0]))
901
- {
902
- $mlw_points += $mlw_qmn_question_answers_each[1];
903
- $mlw_user_text .= strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES));
904
- if ($mlw_qmn_question_answers_each[2] == 1)
905
- {
906
- $mlw_correct += 1;
907
- }
908
- }
909
- if ($mlw_qmn_question_answers_each[2] == 1)
910
- {
911
- $mlw_correct_text .= htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES);
912
- }
913
- }
914
- }
915
- elseif ( $mlw_question->question_type == 3 || $mlw_question->question_type == 5 || $mlw_question->question_type == 7)
916
- {
917
- if (isset($_POST["question".$mlw_question->question_id]))
918
- {
919
- $mlw_user_answer = $_POST["question".$mlw_question->question_id];
920
- }
921
- else
922
- {
923
- $mlw_user_answer = " ";
924
- }
925
- $mlw_user_text .= strval(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
926
- $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
927
- foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
928
- {
929
- $mlw_correct_text = strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES));
930
- if (strtoupper($mlw_user_text) == strtoupper($mlw_correct_text))
931
- {
932
- $mlw_correct += 1;
933
- $mlw_points += $mlw_qmn_question_answers_each[1];
934
- break;
935
- }
936
- }
937
- }
938
- elseif ( $mlw_question->question_type == 4 || $mlw_question->question_type == 10)
939
- {
940
- $mlw_qmn_user_correct_answers = 0;
941
- $mlw_qmn_total_correct_answers = 0;
942
- $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
943
- $mlw_qmn_total_answers = count($mlw_qmn_question_answers_array);
944
- foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
945
- {
946
- for ($i = 1; $i <= $mlw_qmn_total_answers; $i++) {
947
- if (isset($_POST["question".$mlw_question->question_id."_".$i]) && htmlspecialchars(stripslashes($_POST["question".$mlw_question->question_id."_".$i]), ENT_QUOTES) == esc_attr($mlw_qmn_question_answers_each[0]))
948
- {
949
- $mlw_points += $mlw_qmn_question_answers_each[1];
950
- $mlw_user_text .= strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES)).".";
951
- if ($mlw_qmn_question_answers_each[2] == 1)
952
- {
953
- $mlw_qmn_user_correct_answers += 1;
954
- }
955
- else
956
- {
957
- $mlw_qmn_user_correct_answers = -1;
958
- }
959
- }
960
- }
961
- if ($mlw_qmn_question_answers_each[2] == 1)
962
- {
963
- $mlw_correct_text .= htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES).".";
964
- $mlw_qmn_total_correct_answers++;
965
- }
966
- }
967
- if ($mlw_qmn_user_correct_answers == $mlw_qmn_total_correct_answers)
968
- {
969
- $mlw_correct += 1;
970
- }
971
- }
972
- if (isset($_POST["mlwComment".$mlw_question->question_id]))
973
- {
974
- $mlw_qm_question_comment = $_POST["mlwComment".$mlw_question->question_id];
975
- }
976
- else
977
- {
978
- $mlw_qm_question_comment = "";
979
- }
980
-
981
- $mlw_question_answer_display = htmlspecialchars_decode($mlw_quiz_options->question_answer_template, ENT_QUOTES);
982
- $mlw_question_answer_display = str_replace( "%QUESTION%" , htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES), $mlw_question_answer_display);
983
- $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
984
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
985
- $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $mlw_qm_question_comment, $mlw_question_answer_display);
986
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($mlw_question->question_answer_info, ENT_QUOTES), $mlw_question_answer_display);
987
-
988
- $mlw_qmn_answer_array[] = array($mlw_question->question_name, htmlspecialchars($mlw_user_text, ENT_QUOTES), htmlspecialchars($mlw_correct_text, ENT_QUOTES), htmlspecialchars(stripslashes($mlw_qm_question_comment), ENT_QUOTES));
989
-
990
- $mlw_question_answers .= $mlw_question_answer_display;
991
- $mlw_question_answers .= "<br />";
992
- }
993
- }
994
-
995
- //Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
996
- if ($mlw_total_questions != 0)
997
- {
998
- $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
999
- $mlw_average_points = round(($mlw_points/$mlw_total_questions), 2);
1000
- }
1001
- else
1002
- {
1003
- $mlw_total_score = 0;
1004
- $mlw_average_points = 0;
1005
- }
1006
-
1007
- //Prepare comment section if set
1008
- if (isset($_POST["mlwQuizComments"]))
1009
- {
1010
- $mlw_qm_quiz_comments = $_POST["mlwQuizComments"];
1011
- }
1012
- else
1013
- {
1014
- $mlw_qm_quiz_comments = "";
1015
- }
1016
-
1017
-
1018
- //Prepare Certificate
1019
- $mlw_certificate_link = "";
1020
- $mlw_certificate_options = unserialize($mlw_quiz_options->certificate_template);
1021
- if (!is_array($mlw_certificate_options)) {
1022
- // something went wrong, initialize to empty array
1023
- $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
1024
- }
1025
- if ($mlw_certificate_options[4] == 0)
1026
- {
1027
- $mlw_message_certificate = $mlw_certificate_options[1];
1028
- $mlw_message_certificate = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_certificate);
1029
- $mlw_message_certificate = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_certificate);
1030
- $mlw_message_certificate = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_certificate);
1031
- $mlw_message_certificate = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_certificate);
1032
- $mlw_message_certificate = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_certificate);
1033
- $mlw_message_certificate = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_certificate);
1034
- $mlw_message_certificate = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_certificate);
1035
- $mlw_message_certificate = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_certificate);
1036
- $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_certificate);
1037
- $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_certificate);
1038
- $mlw_message_certificate = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_certificate);
1039
- $mlw_message_certificate = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_certificate);
1040
- $mlw_message_certificate = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_certificate);
1041
- $mlw_message_certificate = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_certificate);
1042
- $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
1043
- $mlw_plugindirpath = plugin_dir_path( __FILE__ );
1044
- $plugindirpath=plugin_dir_path( __FILE__ );
1045
- $mlw_qmn_certificate_file=<<<EOC
1046
- <?php
1047
- include("$plugindirpath/WriteHTML.php");
1048
- \$pdf=new PDF_HTML();
1049
- \$pdf->AddPage('L');
1050
- EOC;
1051
- $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
1052
- $mlw_qmn_certificate_file.=<<<EOC
1053
- \$pdf->Ln(20);
1054
- \$pdf->SetFont('Arial','B',24);
1055
- \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
1056
- \$pdf->Ln(15);
1057
- \$pdf->SetFont('Arial','',16);
1058
- \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
1059
- EOC;
1060
- $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
1061
- $mlw_qmn_certificate_file.=<<<EOC
1062
- \$pdf->Output('mlw_qmn_certificate.pdf','D');
1063
- unlink(__FILE__);
1064
- EOC;
1065
- $mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
1066
- file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
1067
- $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
1068
- $mlw_certificate_link = "<a href='".$mlw_qmn_certificate_filename."' style='color: blue;'>Download Certificate</a>";
1069
- }
1070
-
1071
- /*
1072
- Prepare the landing page
1073
- -First, unserialize message_after column
1074
- -Second, check for array in case user has not updated
1075
- Message array = (array( bottomvalue, topvalue, text),array( bottomvalue, topvalue, text), etc..., array(0,0,text))
1076
- */
1077
- $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
1078
- if (is_array($mlw_message_after_array))
1079
- {
1080
- //Cycle through landing pages
1081
- foreach($mlw_message_after_array as $mlw_each)
1082
- {
1083
- //Check to see if default
1084
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
1085
- {
1086
- $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1087
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1088
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1089
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1090
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1091
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1092
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1093
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1094
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1095
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1096
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1097
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1098
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1099
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1100
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1101
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1102
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1103
- $mlw_display .= $mlw_message_after;
1104
- break;
1105
- }
1106
- else
1107
- {
1108
- //Check to see if points fall in correct range
1109
- if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
1110
- {
1111
- $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1112
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1113
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1114
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1115
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1116
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1117
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1118
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1119
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1120
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1121
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1122
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1123
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1124
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1125
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1126
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1127
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1128
- $mlw_display .= $mlw_message_after;
1129
- break;
1130
- }
1131
- //Check to see if score fall in correct range
1132
- if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
1133
- {
1134
- $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1135
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1136
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1137
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1138
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1139
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1140
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1141
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1142
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1143
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1144
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1145
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1146
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1147
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1148
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1149
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1150
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1151
- $mlw_display .= $mlw_message_after;
1152
- break;
1153
- }
1154
- }
1155
- }
1156
- }
1157
- else
1158
- {
1159
- //Prepare the after quiz message
1160
- $mlw_message_after = htmlspecialchars_decode($mlw_quiz_options->message_after, ENT_QUOTES);
1161
- $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1162
- $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1163
- $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1164
- $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1165
- $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1166
- $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1167
- $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1168
- $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1169
- $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1170
- $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1171
- $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1172
- $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1173
- $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1174
- $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1175
- $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1176
- $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1177
- $mlw_display .= $mlw_message_after;
1178
- }
1179
-
1180
- if ($mlw_quiz_options->social_media == 1)
1181
- {
1182
- ?>
1183
- <script>
1184
- function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
1185
- {
1186
- var sTop = window.screen.height/2-(218);
1187
- var sLeft = window.screen.width/2-(313);
1188
- var sqShareOptions = "height=400,width=580,toolbar=0,status=0,location=0,menubar=0,directories=0,scrollbars=0,top=" + sTop + ",left=" + sLeft;
1189
- var pageUrl = window.location.href;
1190
- var pageUrlEncoded = encodeURIComponent(pageUrl);
1191
- if (network == 1)
1192
- {
1193
- var Url = "https://www.facebook.com/dialog/feed?"
1194
- + "display=popup&"
1195
- + "app_id=483815031724529&"
1196
- + "link=" + pageUrlEncoded + "&"
1197
- + "name=" + encodeURIComponent(mlw_qmn_social_text) + "&"
1198
- + "description= &"
1199
- + "redirect_uri=http://www.mylocalwebstop.com/mlw_qmn_close.html";
1200
- }
1201
- if (network == 2)
1202
- {
1203
- var Url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(mlw_qmn_social_text);
1204
- }
1205
- window.open(Url, "Share", sqShareOptions);
1206
- return false;
1207
- }
1208
- </script>
1209
- <?php
1210
- $mlw_social_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_quiz_options->social_media_text);
1211
- $mlw_social_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_social_message);
1212
- $mlw_social_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_social_message);
1213
- $mlw_social_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_social_message);
1214
- $mlw_social_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_social_message);
1215
- $mlw_social_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_social_message);
1216
- $mlw_social_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_social_message);
1217
- $mlw_social_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_social_message);
1218
- $mlw_display .= "<br />
1219
- <a class=\"mlw_qmn_quiz_link\" style=\"display: inline; vertical-align:top !important;font-weight: bold; cursor: pointer;text-decoration: none;\" onclick=\"mlw_qmn_share(1, '".esc_js($mlw_social_message)."', '".esc_js($mlw_quiz_options->quiz_name)."');\">Facebook</a>
1220
- <a class=\"mlw_qmn_quiz_link\" style=\"display: inline; vertical-align:top !important;font-weight: bold; cursor: pointer;text-decoration: none;\" onclick=\"mlw_qmn_share(2, '".esc_js($mlw_social_message)."', '".esc_js($mlw_quiz_options->quiz_name)."');\">Twitter</a>
1221
- <br />";
1222
- }
1223
-
1224
- //Switch email type to HTML
1225
- add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
1226
-
1227
- /*
1228
- Prepare and send the user email
1229
- - First, check to see if user_email_template is the newer array format, if not use it as the template
1230
- - If it is an array, check to see if the score meets the parameter of one of the templates. If, not send the default
1231
- */
1232
- $mlw_message = "";
1233
- if ($mlw_quiz_options->send_user_email == "0")
1234
- {
1235
- if ($mlw_user_email != "")
1236
- {
1237
- $mlw_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
1238
- if (is_array($mlw_user_email_array))
1239
- {
1240
- //Cycle through landing pages
1241
- foreach($mlw_user_email_array as $mlw_each)
1242
- {
1243
-
1244
- //Generate Email Subject
1245
- if (!isset($mlw_each[3]))
1246
- {
1247
- $mlw_each[3] = "Quiz Results For %QUIZ_NAME";
1248
- }
1249
- $mlw_each[3] = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_each[3]);
1250
- $mlw_each[3] = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_each[3]);
1251
- $mlw_each[3] = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_each[3]);
1252
- $mlw_each[3] = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_each[3]);
1253
- $mlw_each[3] = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_each[3]);
1254
- $mlw_each[3] = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_each[3]);
1255
- $mlw_each[3] = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_each[3]);
1256
- $mlw_each[3] = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_each[3]);
1257
- $mlw_each[3] = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_each[3]);
1258
- $mlw_each[3] = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_each[3]);
1259
- $mlw_each[3] = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_each[3]);
1260
- $mlw_each[3] = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_each[3]);
1261
-
1262
-
1263
- //Check to see if default
1264
- if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
1265
- {
1266
- $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1267
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1268
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1269
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1270
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1271
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1272
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1273
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1274
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1275
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1276
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1277
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1278
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1279
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1280
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1281
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1282
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1283
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1284
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1285
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1286
- wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1287
- break;
1288
- }
1289
- else
1290
- {
1291
- //Check to see if points fall in correct range
1292
- if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
1293
- {
1294
- $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1295
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1296
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1297
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1298
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1299
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1300
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1301
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1302
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1303
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1304
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1305
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1306
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1307
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1308
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1309
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1310
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1311
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1312
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1313
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1314
- wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1315
- break;
1316
- }
1317
-
1318
- //Check to see if score fall in correct range
1319
- if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
1320
- {
1321
- $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1322
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1323
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1324
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1325
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1326
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1327
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1328
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1329
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1330
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1331
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1332
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1333
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1334
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1335
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1336
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1337
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1338
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1339
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1340
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1341
- wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1342
- break;
1343
- }
1344
- }
1345
- }
1346
- }
1347
- else
1348
- {
1349
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->user_email_template, ENT_QUOTES);
1350
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1351
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1352
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1353
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1354
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1355
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1356
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1357
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1358
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1359
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1360
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1361
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1362
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1363
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1364
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1365
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1366
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1367
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1368
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1369
- wp_mail($mlw_user_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
1370
- }
1371
- }
1372
- }
1373
-
1374
- //Prepare and send the admin email
1375
- $mlw_message = "";
1376
- if ($mlw_quiz_options->send_admin_email == "0")
1377
- {
1378
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->admin_email_template, ENT_QUOTES);
1379
- $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1380
- $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1381
- $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1382
- $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1383
- $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1384
- $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1385
- $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1386
- $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1387
- $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1388
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1389
- $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1390
- $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1391
- $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1392
- $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1393
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1394
- if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "<br>This email was generated by the Quiz Master Next script by Frank Corso";}
1395
- $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1396
- $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1397
- $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1398
- $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1399
- $mlw_qmn_admin_emails = explode(",", $mlw_quiz_options->admin_email);
1400
- foreach($mlw_qmn_admin_emails as $admin_email)
1401
- {
1402
- wp_mail($admin_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
1403
- }
1404
- }
1405
-
1406
- //Remove HTML type for emails
1407
- remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
1408
-
1409
- //Save the results into database
1410
- $mlw_quiz_results_array = array( intval($mlw_qmn_timer), $mlw_qmn_answer_array, htmlspecialchars(stripslashes($mlw_qm_quiz_comments), ENT_QUOTES));
1411
- $mlw_quiz_results = serialize($mlw_quiz_results_array);
1412
-
1413
- global $wpdb;
1414
- $table_name = $wpdb->prefix . "mlw_results";
1415
- $results = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $table_name . " (result_id, quiz_id, quiz_name, quiz_system, point_score, correct_score, correct, total, name, business, email, phone, user, time_taken, time_taken_real, quiz_results, deleted) VALUES (NULL, %d, '%s', %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', 0)", $mlw_quiz_id, $mlw_quiz_options->quiz_name, $mlw_quiz_options->system, $mlw_points, $mlw_total_score, $mlw_correct, $mlw_total_questions, $mlw_user_name, $mlw_user_comp, $mlw_user_email, $mlw_user_phone, get_current_user_id(), date("h:i:s A m/d/Y"), date("Y-m-d H:i:s"), $mlw_quiz_results) );
1416
-
1417
- //Integration Action
1418
- do_action('mlw_qmn_load_results_page');
1419
- }
1420
- else
1421
- {
1422
- if (!$mlw_qmn_isAllowed)
1423
- {
1424
- $current_user = wp_get_current_user();
1425
- $mlw_message = htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES);
1426
- $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1427
- $mlw_message = str_replace( "%USER_NAME%" , $current_user->display_name, $mlw_message);
1428
- $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1429
- $mlw_display .= $mlw_message;
1430
- }
1431
- elseif (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] != $_POST["mlw_code_captcha"])
1432
- {
1433
- $mlw_display .= "There was an issue with the captcha verification. Please try again.";
1434
- }
1435
- else { $mlw_display .= "Thank you."; }
1436
- }
1437
- }
1438
- return $mlw_display;
1439
- }
1440
-
1441
-
1442
- /*
1443
- This function displays fields to ask for contact information
1444
- */
1445
- function mlwDisplayContactInfo($mlw_quiz_options)
1446
- {
1447
- $mlw_contact_display = "";
1448
- //Check to see if user is logged in, then ask for contact if not
1449
- if ( is_user_logged_in() )
1450
- {
1451
- //If this quiz does not let user edit contact information we hide this section
1452
- if ($mlw_quiz_options->loggedin_user_contact == 1)
1453
- {
1454
- $mlw_contact_display .= "<div style='display:none;'>";
1455
- }
1456
-
1457
- //Retrieve current user information and save into text fields for contact information
1458
- $current_user = wp_get_current_user();
1459
- if ($mlw_quiz_options->user_name != 2)
1460
- {
1461
- $mlw_contact_class = "class=\"\"";
1462
- if ($mlw_quiz_options->user_name == 1)
1463
- {
1464
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1465
- }
1466
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1467
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
1468
- $mlw_contact_display .= "<br /><br />";
1469
-
1470
- }
1471
- if ($mlw_quiz_options->user_comp != 2)
1472
- {
1473
- $mlw_contact_class = "class=\"\"";
1474
- if ($mlw_quiz_options->user_comp == 1)
1475
- {
1476
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1477
- }
1478
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1479
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1480
- $mlw_contact_display .= "<br /><br />";
1481
- }
1482
- if ($mlw_quiz_options->user_email != 2)
1483
- {
1484
- $mlw_contact_class = "class=\"\"";
1485
- if ($mlw_quiz_options->user_email == 1)
1486
- {
1487
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1488
- }
1489
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1490
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
1491
- $mlw_contact_display .= "<br /><br />";
1492
- }
1493
- if ($mlw_quiz_options->user_phone != 2)
1494
- {
1495
- $mlw_contact_class = "class=\"\"";
1496
- if ($mlw_quiz_options->user_phone == 1)
1497
- {
1498
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1499
- }
1500
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1501
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1502
- $mlw_contact_display .= "<br /><br />";
1503
- }
1504
-
1505
- //End of hidden section div
1506
- if ($mlw_quiz_options->loggedin_user_contact == 1)
1507
- {
1508
- $mlw_contact_display .= "</div>";
1509
- }
1510
- }
1511
- else
1512
- {
1513
- //See if the site wants to ask for any contact information, then ask for it
1514
- if ($mlw_quiz_options->user_name != 2)
1515
- {
1516
- $mlw_contact_class = "class=\"\"";
1517
- if ($mlw_quiz_options->user_name == 1)
1518
- {
1519
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1520
- }
1521
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1522
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='' />";
1523
- $mlw_contact_display .= "<br /><br />";
1524
- }
1525
- if ($mlw_quiz_options->user_comp != 2)
1526
- {
1527
- $mlw_contact_class = "class=\"\"";
1528
- if ($mlw_quiz_options->user_comp == 1)
1529
- {
1530
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1531
- }
1532
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1533
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1534
- $mlw_contact_display .= "<br /><br />";
1535
- }
1536
- if ($mlw_quiz_options->user_email != 2)
1537
- {
1538
- $mlw_contact_class = "class=\"\"";
1539
- if ($mlw_quiz_options->user_email == 1)
1540
- {
1541
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1542
- }
1543
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1544
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='' />";
1545
- $mlw_contact_display .= "<br /><br />";
1546
- }
1547
- if ($mlw_quiz_options->user_phone != 2)
1548
- {
1549
- $mlw_contact_class = "class=\"\"";
1550
- if ($mlw_quiz_options->user_phone == 1)
1551
- {
1552
- $mlw_contact_class = "class=\"mlwRequiredText\"";
1553
- }
1554
- $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1555
- $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1556
- $mlw_contact_display .= "<br /><br />";
1557
- }
1558
- }
1559
- return $mlw_contact_display;
1560
- }
1561
-
1562
- /*
1563
- This function helps set the email type to HTML
1564
- */
1565
- function mlw_qmn_set_html_content_type() {
1566
-
1567
- return 'text/html';
1568
- }
1569
  ?>
1
+ <?php
2
+ /*
3
+ This function is the very heart of the plugin. This function displays the quiz to the user as well as handles all the scripts that are part of the quiz. Please be very careful if you are editing this script without my assistance.
4
+ */
5
+ function mlw_quiz_shortcode($atts)
6
+ {
7
+ extract(shortcode_atts(array(
8
+ 'quiz' => 0
9
+ ), $atts));
10
+
11
+
12
+
13
+ /*
14
+ Code before loading the quiz
15
+ */
16
+
17
+ //Variables needed throughout script
18
+ $mlw_quiz_id = intval($quiz);
19
+ $GLOBALS['mlw_qmn_quiz'] = $mlw_quiz_id;
20
+ $mlw_display = "";
21
+ global $wpdb;
22
+ $mlw_qmn_isAllowed = true;
23
+ $mlw_qmn_section_count = 1;
24
+ $mlw_qmn_section_limit = 0;
25
+
26
+
27
+ //Load quiz
28
+ $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0'";
29
+ $mlw_quiz_options = $wpdb->get_results($sql);
30
+
31
+ foreach($mlw_quiz_options as $mlw_eaches) {
32
+ $mlw_quiz_options = $mlw_eaches;
33
+ break;
34
+ }
35
+
36
+ //Check to see if there is limit on the amount of tries
37
+ if ( $mlw_quiz_options->total_user_tries != 0 && is_user_logged_in() )
38
+ {
39
+ $current_user = wp_get_current_user();
40
+ $mlw_qmn_user_try_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results WHERE email='%s' AND deleted='0' AND quiz_id=%d", $current_user->user_email, $mlw_quiz_id ) );
41
+ if ($mlw_qmn_user_try_count >= $mlw_quiz_options->total_user_tries) { $mlw_qmn_isAllowed = false; }
42
+ }
43
+
44
+
45
+ //Load questions
46
+ $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
47
+ if ($mlw_quiz_options->randomness_order == 0)
48
+ {
49
+ $sql .= "ORDER BY question_order ASC";
50
+ }
51
+ if ($mlw_quiz_options->randomness_order == 1 || $mlw_quiz_options->randomness_order == 2)
52
+ {
53
+ $sql .= "ORDER BY rand()";
54
+ }
55
+ if ($mlw_quiz_options->question_from_total != 0)
56
+ {
57
+ $sql .= " LIMIT ".$mlw_quiz_options->question_from_total;
58
+ }
59
+ $mlw_questions = $wpdb->get_results($sql);
60
+
61
+
62
+ //Load and prepare answer arrays
63
+ $mlw_qmn_answer_arrays = array();
64
+ foreach($mlw_questions as $mlw_question_info) {
65
+ $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
66
+ if ( !is_array($mlw_qmn_answer_array_each) )
67
+ {
68
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
69
+ $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
70
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
71
+ array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
72
+ array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
73
+ array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
74
+ array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
75
+ array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
76
+ array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
77
+ }
78
+ else
79
+ {
80
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
81
+ }
82
+ }
83
+
84
+
85
+ //Variables to load if quiz has been taken
86
+ if (isset($_POST["complete_quiz"]) && $_POST["complete_quiz"] == "confirmation")
87
+ {
88
+ $mlw_success = $_POST["complete_quiz"];
89
+ $mlw_user_name = isset($_POST["mlwUserName"]) ? $_POST["mlwUserName"] : 'None';
90
+ $mlw_user_comp = isset($_POST["mlwUserComp"]) ? $_POST["mlwUserComp"] : 'None';
91
+ $mlw_user_email = isset($_POST["mlwUserEmail"]) ? $_POST["mlwUserEmail"] : 'None';
92
+ $mlw_user_phone = isset($_POST["mlwUserPhone"]) ? $_POST["mlwUserPhone"] : 'None';
93
+ $mlw_qmn_timer = isset($_POST["timer"]) ? $_POST["timer"] : 0;
94
+ $mlw_spam_email = $_POST["email"];
95
+ }
96
+
97
+ wp_enqueue_script( 'json2' );
98
+ wp_enqueue_script( 'jquery' );
99
+ wp_enqueue_script( 'jquery-ui-core' );
100
+ wp_enqueue_script( 'jquery-effects-core' );
101
+ wp_enqueue_script( 'jquery-effects-slide' );
102
+ wp_enqueue_script( 'jquery-ui-dialog' );
103
+ wp_enqueue_script( 'jquery-ui-button' );
104
+ wp_enqueue_script( 'jquery-ui-accordion' );
105
+ wp_enqueue_script( 'jquery-ui-tooltip' );
106
+ wp_enqueue_script( 'jquery-ui-tabs' );
107
+ ?>
108
+ <!-- css -->
109
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
110
+ <script type="text/javascript">
111
+ setTimeout(function(){
112
+ var $j = jQuery.noConflict();
113
+ // increase the default animation speed to exaggerate the effect
114
+ $j.fx.speeds._default = 1000;
115
+ $j(function() {
116
+ $j( ".mlw_qmn_quiz" ).tooltip();
117
+ });
118
+ }, 100);
119
+ setTimeout(function()
120
+ {
121
+ var $j = jQuery.noConflict();
122
+ $j('.mlw_qmn_quiz input').on('keypress', function (e) {
123
+ if (e.which === 13) {
124
+ e.preventDefault();
125
+ }
126
+ });
127
+ }, 100);
128
+ </script>
129
+ <style type="text/css">
130
+ .ui-tooltip
131
+ {
132
+ /* tooltip container box */
133
+ max-width: 500px !important;
134
+ }
135
+ .ui-tooltip-content
136
+ {
137
+ /* tooltip content */
138
+ max-width: 500px !important;
139
+ }
140
+ </style>
141
+
142
+ <?php
143
+ if ($mlw_quiz_options->theme_selected == "default")
144
+ {
145
+ echo "<style type='text/css'>".$mlw_quiz_options->quiz_stye."</style>";
146
+ }
147
+ else
148
+ {
149
+ echo "<link type='text/css' href='".get_option('mlw_qmn_theme_'.$mlw_quiz_options->theme_selected)."' rel='stylesheet' />";
150
+ }
151
+
152
+ /*
153
+ The following code is for displaying the quiz and completion screen
154
+ */
155
+
156
+ //If there is no quiz for the shortcode provided
157
+ if ($mlw_quiz_options->quiz_name == "")
158
+ {
159
+ $mlw_display .= "It appears that this quiz is not set up correctly.";
160
+ return $mlw_display;
161
+ }
162
+
163
+
164
+
165
+ //Display Quiz
166
+ if (!isset($_POST["complete_quiz"]) && $mlw_quiz_options->quiz_name != "" && $mlw_qmn_isAllowed)
167
+ {
168
+ $mlw_qmn_total_questions = 0;
169
+ //Calculate number of pages if pagination is turned on
170
+ if ($mlw_quiz_options->pagination != 0)
171
+ {
172
+ $mlw_qmn_section_limit = 2 + count($mlw_questions);
173
+ if ($mlw_quiz_options->comment_section == 0)
174
+ {
175
+ $mlw_qmn_section_limit = $mlw_qmn_section_limit + 1;
176
+ }
177
+
178
+ //Gather text for pagination buttons
179
+ $mlw_qmn_pagination_text = "";
180
+ $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
181
+ if (!is_array($mlw_qmn_pagination_text)) {
182
+ $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
183
+ }
184
+ ?>
185
+ <script type="text/javascript">
186
+ setTimeout(function(){
187
+ var $j = jQuery.noConflict();
188
+ $j( ".quiz_section" ).hide();
189
+ $j( ".quiz_section" ).append( "<br />" );
190
+ $j( ".mlw_qmn_quiz" ).append( "<a class=\"mlw_qmn_quiz_link mlw_previous\" href=\"javascript:prevSlide(<?php echo $mlw_quiz_options->pagination; ?>, 1);\"><?php echo $mlw_qmn_pagination_text[0]; ?></a>" );
191
+ $j( ".mlw_qmn_quiz" ).append( "<a class=\"mlw_qmn_quiz_link mlw_next\" href=\"javascript:nextSlide(<?php echo $mlw_quiz_options->pagination; ?>, 1);\"><?php echo $mlw_qmn_pagination_text[1]; ?></a>" );
192
+ window.mlw_quiz_slide = 0;
193
+ window.mlw_previous = 0;
194
+ window.mlw_quiz_total_slides = <?php echo $mlw_qmn_section_limit; ?>;
195
+ nextSlide(1, 0);
196
+ }, 100);
197
+ function nextSlide(mlw_pagination, mlw_goto_top)
198
+ {
199
+ jQuery( ".quiz_section" ).hide();
200
+ for (var i = 0; i < mlw_pagination; i++)
201
+ {
202
+ if (i == 0 && window.mlw_previous == 1 && window.mlw_quiz_slide > 1)
203
+ {
204
+ window.mlw_quiz_slide = window.mlw_quiz_slide + mlw_pagination;
205
+ }
206
+ else
207
+ {
208
+ window.mlw_quiz_slide++;
209
+ }
210
+ if (window.mlw_quiz_slide < 1)
211
+ {
212
+ window.mlw_quiz_slide = 1;
213
+ }
214
+ if (window.mlw_quiz_slide == 1)
215
+ {
216
+ jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).hide();
217
+ }
218
+ if (window.mlw_quiz_slide > 1)
219
+ {
220
+ jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).show();
221
+ }
222
+ if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
223
+ {
224
+ jQuery( ".mlw_qmn_quiz_link.mlw_next" ).hide();
225
+ }
226
+ if (window.mlw_quiz_slide < window.mlw_quiz_total_slides)
227
+ {
228
+ jQuery( ".mlw_qmn_quiz_link.mlw_next" ).show();
229
+ }
230
+ jQuery( ".quiz_section.slide"+window.mlw_quiz_slide ).show();
231
+ }
232
+ window.mlw_previous = 0;
233
+ if (mlw_goto_top == 1)
234
+ {
235
+ window.location.hash = "mlw_does_not_exist";
236
+ window.location.hash = "mlw_top_of_quiz";
237
+ }
238
+
239
+ }
240
+ function prevSlide(mlw_pagination, mlw_goto_top)
241
+ {
242
+ jQuery( ".quiz_section" ).hide();
243
+ for (var i = 0; i < mlw_pagination; i++)
244
+ {
245
+ if (i == 0 && window.mlw_previous == 0)
246
+ {
247
+ window.mlw_quiz_slide = window.mlw_quiz_slide - mlw_pagination;
248
+ }
249
+ else
250
+ {
251
+ window.mlw_quiz_slide--;
252
+ }
253
+ if (window.mlw_quiz_slide < 1)
254
+ {
255
+ window.mlw_quiz_slide = 1;
256
+ }
257
+ if (window.mlw_quiz_slide == 1)
258
+ {
259
+ jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).hide();
260
+ }
261
+ if (window.mlw_quiz_slide > 1)
262
+ {
263
+ jQuery( ".mlw_qmn_quiz_link.mlw_previous" ).show();
264
+ }
265
+ if (window.mlw_quiz_slide == window.mlw_quiz_total_slides)
266
+ {
267
+ jQuery( ".mlw_qmn_quiz_link.mlw_next" ).hide();
268
+ }
269
+ if (window.mlw_quiz_slide < window.mlw_quiz_total_slides)
270
+ {
271
+ jQuery( ".mlw_qmn_quiz_link.mlw_next" ).show();
272
+ }
273
+ jQuery( ".quiz_section.slide"+window.mlw_quiz_slide ).show();
274
+ }
275
+ window.mlw_previous = 1;
276
+ if (mlw_goto_top == 1)
277
+ {
278
+ window.location.hash = "mlw_does_not_exist";
279
+ window.location.hash = "mlw_top_of_quiz";
280
+ }
281
+ }
282
+ </script>
283
+ <?php
284
+ }
285
+ if ($mlw_quiz_options->timer_limit != 0)
286
+ {
287
+ ?>
288
+ <div id="mlw_qmn_timer" class="mlw_qmn_timer"></div>
289
+ <script type="text/javascript">
290
+ setTimeout(function(){
291
+ var minutes = 0;
292
+ if (window.sessionStorage.getItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>') == "yes" && window.sessionStorage.getItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>') >= 0)
293
+ {
294
+ minutes = window.sessionStorage.getItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>');
295
+ }
296
+ else
297
+ {
298
+ minutes = <?php echo $mlw_quiz_options->timer_limit; ?>;
299
+ }
300
+ window.amount = (minutes*60);
301
+ window.titleText = window.document.title;
302
+ document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
303
+ window.counter=setInterval(timer, 1000);
304
+ }, 100);
305
+ function timer()
306
+ {
307
+ window.amount=window.amount-1;
308
+ if (window.amount < 0)
309
+ {
310
+ window.amount = 0;
311
+ }
312
+ window.sessionStorage.setItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>', window.amount/60);
313
+ window.sessionStorage.setItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>', "yes");
314
+ document.getElementById("mlw_qmn_timer").innerHTML = minToSec(window.amount);
315
+ window.document.title = minToSec(window.amount) + " " + window.titleText;
316
+ if (window.amount <= 0)
317
+ {
318
+ clearInterval(window.counter);
319
+ jQuery( ".mlw_qmn_quiz input:radio" ).attr('disabled',true);
320
+ jQuery( ".mlw_qmn_quiz input:checkbox" ).attr('disabled',true);
321
+ jQuery( ".mlw_qmn_quiz select" ).attr('disabled',true);
322
+ jQuery( ".mlw_qmn_question_comment" ).attr('disabled',true);
323
+ jQuery( ".mlw_answer_open_text" ).attr('disabled',true);
324
+ //document.quizForm.submit();
325
+ return;
326
+ }
327
+ }
328
+ function minToSec(amount)
329
+ {
330
+ var minutes = Math.floor(amount/60);
331
+ var seconds = amount - (minutes * 60);
332
+ if (seconds == '0')
333
+ {
334
+ seconds = "00";
335
+ }
336
+ else if (seconds < 10)
337
+ {
338
+ seconds = '0' + seconds;
339
+ }
340
+ return minutes+":"+seconds;
341
+ }
342
+ </script>
343
+ <?php
344
+ }
345
+
346
+ ?>
347
+ <script type="text/javascript">
348
+ var myVar=setInterval("mlwQmnTimer();",1000);
349
+ function mlwQmnTimer()
350
+ {
351
+ var x = +document.getElementById("timer").value;
352
+ x = x + 1;
353
+ document.getElementById("timer").value = x;
354
+ }
355
+
356
+ </script>
357
+ <?php
358
+ //Update the quiz views
359
+ $mlw_views = $mlw_quiz_options->quiz_views;
360
+ $mlw_views += 1;
361
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views='".$mlw_views."' WHERE quiz_id=".$mlw_quiz_id;
362
+ $results = $wpdb->query( $update );
363
+
364
+ //Form validation script
365
+ ?>
366
+ <script>
367
+ function clear_field(field)
368
+ {
369
+ if (field.defaultValue == field.value) field.value = '';
370
+ }
371
+
372
+ function mlw_validateForm()
373
+ {
374
+ mlw_validateResult = true;
375
+ if (document.forms['quizForm']['mlwUserEmail'].value != '')
376
+ {
377
+ var x=document.forms['quizForm']['mlwUserEmail'].value;
378
+ var atpos=x.indexOf('@');
379
+ var dotpos=x.lastIndexOf('.');
380
+ if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
381
+ {
382
+ document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**';
383
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**';
384
+ mlw_validateResult = false;
385
+ }
386
+ }
387
+
388
+ jQuery('#quizForm *').filter(':input').each(function(){
389
+ jQuery(this).css("outline", "");
390
+ if (jQuery(this).attr('class'))
391
+ {
392
+ if(jQuery(this).attr('class').indexOf('mlwRequiredNumber') > -1 && this.value == "" && +this.value != NaN)
393
+ {
394
+ document.getElementById('mlw_error_message').innerHTML = '**This field must be a number!**';
395
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**This field must be a number!**';
396
+ jQuery(this).css("outline", "2px solid red");
397
+ mlw_validateResult = false;
398
+ }
399
+ if(jQuery(this).attr('class').indexOf('mlwRequiredText') > -1 && this.value == "")
400
+ {
401
+ document.getElementById('mlw_error_message').innerHTML = '**Please complete all required fields!**';
402
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Please complete all required fields!**';
403
+ jQuery(this).css("outline", "2px solid red");
404
+ mlw_validateResult = false;
405
+ }
406
+ if(jQuery(this).attr('class').indexOf('mlwRequiredCaptcha') > -1 && this.value != mlw_code)
407
+ {
408
+ document.getElementById('mlw_error_message').innerHTML = '**The entered text is not correct!**';
409
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**The entered text is not correct!**';
410
+ jQuery(this).css("outline", "2px solid red");
411
+ mlw_validateResult = false;
412
+ }
413
+ if(jQuery(this).attr('class').indexOf('mlwRequiredCheck') > -1 && !this.checked)
414
+ {
415
+ document.getElementById('mlw_error_message').innerHTML = '**Please complete all required fields!**';
416
+ document.getElementById('mlw_error_message_bottom').innerHTML = '**Please complete all required fields!**';
417
+ jQuery(this).css("outline", "2px solid red");
418
+ mlw_validateResult = false;
419
+ }
420
+ }
421
+ });
422
+
423
+ if (!mlw_validateResult) {return mlw_validateResult;}
424
+
425
+ jQuery( '.mlw_qmn_quiz input:radio' ).attr('disabled',false);
426
+ jQuery( '.mlw_qmn_quiz input:checkbox' ).attr('disabled',false);
427
+ jQuery( '.mlw_qmn_quiz select' ).attr('disabled',false);
428
+ jQuery( '.mlw_qmn_question_comment' ).attr('disabled',false);
429
+ jQuery( '.mlw_answer_open_text' ).attr('disabled',false);
430
+ }
431
+ </script>
432
+ <?php
433
+
434
+ if ( $mlw_quiz_options->pagination != 0) { $mlw_display .= "<style>.quiz_section { display: none; }</style>"; }
435
+
436
+ //Begin the quiz
437
+ $mlw_display .= "<div class='mlw_qmn_quiz'>";
438
+ $mlw_display .= "<form name='quizForm' id='quizForm' action='' method='post' class='mlw_quiz_form' onsubmit='return mlw_validateForm()' novalidate >";
439
+ $mlw_display .= "<span id='mlw_top_of_quiz'></span>";
440
+ $mlw_display .= "<div class='quiz_section quiz_begin slide".$mlw_qmn_section_count."'>";
441
+ $mlw_message_before = htmlspecialchars_decode($mlw_quiz_options->message_before, ENT_QUOTES);
442
+ $mlw_message_before = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_before);
443
+ $mlw_message_before = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_before);
444
+ $mlw_display .= "<span class='mlw_qmn_message_before'>".$mlw_message_before."</span><br />";
445
+ $mlw_display .= "<span name='mlw_error_message' id='mlw_error_message' style='color: red;'></span><br />";
446
+
447
+ if ($mlw_quiz_options->contact_info_location == 0)
448
+ {
449
+ $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
450
+ }
451
+ $mlw_display .= "</div>";
452
+
453
+ //Display the questions
454
+ foreach($mlw_questions as $mlw_question) {
455
+ $mlw_question_settings = @unserialize($mlw_question->question_settings);
456
+ if (!is_array($mlw_question_settings))
457
+ {
458
+ $mlw_question_settings = array();
459
+ $mlw_question_settings['required'] = 1;
460
+ }
461
+ if ( !isset($mlw_question_settings['required']))
462
+ {
463
+ $mlw_question_settings['required'] = 1;
464
+ }
465
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
466
+ $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
467
+ if ($mlw_question->question_type == 0)
468
+ {
469
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
470
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
471
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
472
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
473
+ $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
474
+ if (is_array($mlw_qmn_answer_array))
475
+ {
476
+ if ($mlw_quiz_options->randomness_order == 2)
477
+ {
478
+ shuffle($mlw_qmn_answer_array);
479
+ }
480
+ $mlw_answer_total = 0;
481
+ foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
482
+ {
483
+ $mlw_answer_total++;
484
+ if ($mlw_qmn_answer_each[0] != "")
485
+ {
486
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label>";
487
+ $mlw_display .= "<br />";
488
+ }
489
+ }
490
+ $mlw_display .= "<input type='radio' style='display: none;' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_none' checked='checked' value='No Answer Provided' />";
491
+ }
492
+ else
493
+ {
494
+ if ($mlw_question->answer_one != "")
495
+ {
496
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_one' value='1' /> <label for='question".$mlw_question->question_id."_one'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</label>";
497
+ $mlw_display .= "<br />";
498
+ }
499
+ if ($mlw_question->answer_two != "")
500
+ {
501
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_two' value='2' /> <label for='question".$mlw_question->question_id."_two'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</label>";
502
+ $mlw_display .= "<br />";
503
+ }
504
+ if ($mlw_question->answer_three != "")
505
+ {
506
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_three' value='3' /> <label for='question".$mlw_question->question_id."_three'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</label>";
507
+ $mlw_display .= "<br />";
508
+ }
509
+ if ($mlw_question->answer_four != "")
510
+ {
511
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_four' value='4' /> <label for='question".$mlw_question->question_id."_four'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</label>";
512
+ $mlw_display .= "<br />";
513
+ }
514
+ if ($mlw_question->answer_five != "")
515
+ {
516
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_five' value='5' /> <label for='question".$mlw_question->question_id."_five'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</label>";
517
+ $mlw_display .= "<br />";
518
+ }
519
+ if ($mlw_question->answer_six != "")
520
+ {
521
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_six' value='6' /> <label for='question".$mlw_question->question_id."_six'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</label>";
522
+ $mlw_display .= "<br />";
523
+ }
524
+ }
525
+ }
526
+ elseif ($mlw_question->question_type == 4)
527
+ {
528
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
529
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
530
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
531
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
532
+ $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
533
+ if (is_array($mlw_qmn_answer_array))
534
+ {
535
+ if ($mlw_quiz_options->randomness_order == 2)
536
+ {
537
+ shuffle($mlw_qmn_answer_array);
538
+ }
539
+ $mlw_answer_total = 0;
540
+ foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
541
+ {
542
+ $mlw_answer_total++;
543
+ if ($mlw_qmn_answer_each[0] != "")
544
+ {
545
+ $mlw_display .= "<input type='hidden' name='question".$mlw_question->question_id."' value='This value does not matter' />";
546
+ $mlw_display .= "<input type='checkbox' name='question".$mlw_question->question_id."_".$mlw_answer_total."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</label>";
547
+ $mlw_display .= "<br />";
548
+ }
549
+ }
550
+ }
551
+ }
552
+ elseif ($mlw_question->question_type == 10)
553
+ {
554
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
555
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
556
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
557
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
558
+ $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
559
+ if (is_array($mlw_qmn_answer_array))
560
+ {
561
+ if ($mlw_quiz_options->randomness_order == 2)
562
+ {
563
+ shuffle($mlw_qmn_answer_array);
564
+ }
565
+ $mlw_answer_total = 0;
566
+ foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
567
+ {
568
+ $mlw_answer_total++;
569
+ if ($mlw_qmn_answer_each[0] != "")
570
+ {
571
+ $mlw_display .= "<input type='hidden' name='question".$mlw_question->question_id."' value='This value does not matter' />";
572
+ $mlw_display .= "<span class='mlw_horizontal_multiple'><input type='checkbox' name='question".$mlw_question->question_id."_".$mlw_answer_total."' id='question".$mlw_question->question_id."_".$mlw_answer_total."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> <label for='question".$mlw_question->question_id."_".$mlw_answer_total."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."&nbsp;</label></span>";
573
+ }
574
+ }
575
+ }
576
+ }
577
+ elseif ($mlw_question->question_type == 1)
578
+ {
579
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
580
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
581
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
582
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
583
+ $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
584
+ if (is_array($mlw_qmn_answer_array))
585
+ {
586
+ if ($mlw_quiz_options->randomness_order == 2)
587
+ {
588
+ shuffle($mlw_qmn_answer_array);
589
+ }
590
+ $mlw_answer_total = 0;
591
+ foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
592
+ {
593
+ $mlw_answer_total++;
594
+ if ($mlw_qmn_answer_each[0] != "")
595
+ {
596
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='".esc_attr($mlw_qmn_answer_each[0])."' /> ".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)." ";
597
+ }
598
+ }
599
+ $mlw_display .= "<input type='radio' style='display: none;' name='question".$mlw_question->question_id."' id='question".$mlw_question->question_id."_none' checked='checked' value='No Answer Provided' />";
600
+ }
601
+ else
602
+ {
603
+ if ($mlw_question->answer_one != "")
604
+ {
605
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='1' />".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES);
606
+ }
607
+ if ($mlw_question->answer_two != "")
608
+ {
609
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='2' />".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES);
610
+ }
611
+ if ($mlw_question->answer_three != "")
612
+ {
613
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='3' />".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES);
614
+ }
615
+ if ($mlw_question->answer_four != "")
616
+ {
617
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='4' />".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES);
618
+ }
619
+ if ($mlw_question->answer_five != "")
620
+ {
621
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='5' />".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES);
622
+ }
623
+ if ($mlw_question->answer_six != "")
624
+ {
625
+ $mlw_display .= "<input type='radio' name='question".$mlw_question->question_id."' value='6' />".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES);
626
+ }
627
+ }
628
+ $mlw_display .= "<br />";
629
+ }
630
+ elseif ($mlw_question->question_type == 2)
631
+ {
632
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
633
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
634
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
635
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
636
+ $mlw_display .= "<select name='question".$mlw_question->question_id."'>";
637
+ $mlw_qmn_answer_array = $mlw_qmn_answer_arrays[$mlw_question->question_id];
638
+ if (is_array($mlw_qmn_answer_array))
639
+ {
640
+ if ($mlw_quiz_options->randomness_order == 2)
641
+ {
642
+ shuffle($mlw_qmn_answer_array);
643
+ }
644
+ $mlw_answer_total = 0;
645
+ foreach($mlw_qmn_answer_array as $mlw_qmn_answer_each)
646
+ {
647
+ $mlw_answer_total++;
648
+ if ($mlw_qmn_answer_each[0] != "")
649
+ {
650
+ $mlw_display .= "<option value='".esc_attr($mlw_qmn_answer_each[0])."'>".htmlspecialchars_decode($mlw_qmn_answer_each[0], ENT_QUOTES)."</option>";
651
+ }
652
+ }
653
+ }
654
+ else
655
+ {
656
+ if ($mlw_question->answer_one != "")
657
+ {
658
+ $mlw_display .= "<option value='1'>".htmlspecialchars_decode($mlw_question->answer_one, ENT_QUOTES)."</option>";
659
+ }
660
+ if ($mlw_question->answer_two != "")
661
+ {
662
+ $mlw_display .= "<option value='2'>".htmlspecialchars_decode($mlw_question->answer_two, ENT_QUOTES)."</option>";
663
+ }
664
+ if ($mlw_question->answer_three != "")
665
+ {
666
+ $mlw_display .= "<option value='3'>".htmlspecialchars_decode($mlw_question->answer_three, ENT_QUOTES)."</option>";
667
+ }
668
+ if ($mlw_question->answer_four != "")
669
+ {
670
+ $mlw_display .= "<option value='4'>".htmlspecialchars_decode($mlw_question->answer_four, ENT_QUOTES)."</option>";
671
+ }
672
+ if ($mlw_question->answer_five != "")
673
+ {
674
+ $mlw_display .= "<option value='5'>".htmlspecialchars_decode($mlw_question->answer_five, ENT_QUOTES)."</option>";
675
+ }
676
+ if ($mlw_question->answer_six != "")
677
+ {
678
+ $mlw_display .= "<option value='6'>".htmlspecialchars_decode($mlw_question->answer_six, ENT_QUOTES)."</option>";
679
+ }
680
+ }
681
+ $mlw_display .= "</select>";
682
+ $mlw_display .= "<br />";
683
+ }
684
+ elseif ($mlw_question->question_type == 5)
685
+ {
686
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
687
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
688
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
689
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
690
+ if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
691
+ $mlw_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$mlw_question->question_id."' /></textarea>";
692
+ $mlw_display .= "<br />";
693
+ }
694
+ elseif ($mlw_question->question_type == 6)
695
+ {
696
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES);
697
+ $mlw_display .= "<br />";
698
+ }
699
+ elseif ($mlw_question->question_type == 7)
700
+ {
701
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
702
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
703
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
704
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
705
+ if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
706
+ $mlw_display .= "<input type='number' class='mlw_answer_number $mlw_requireClass' name='question".$mlw_question->question_id."' />";
707
+ $mlw_display .= "<br />";
708
+ }
709
+ elseif ($mlw_question->question_type == 8)
710
+ {
711
+ if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
712
+ $mlw_display .= "<input type='checkbox' id='mlwAcceptance' class='$mlw_requireClass ' />";
713
+ $mlw_display .= "<label for='mlwAcceptance'><span class='mlw_qmn_question' style='font-weight:bold;'>".htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span></label>";
714
+ $mlw_display .= "<br />";
715
+ }
716
+ elseif ($mlw_question->question_type == 9)
717
+ {
718
+ if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredCaptcha";} else {$mlw_requireClass = "";}
719
+ $mlw_display .= "<div class='mlw_captchaWrap'>";
720
+ $mlw_display .= "<canvas alt='' id='mlw_captcha' class='mlw_captcha' width='100' height='50'></canvas>";
721
+ $mlw_display .= "</div>";
722
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
723
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
724
+ $mlw_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' id='mlw_captcha_text' name='mlw_user_captcha'/>";
725
+ $mlw_display .= "<input type='hidden' name='mlw_code_captcha' id='mlw_code_captcha' value='none' />";
726
+ $mlw_display .= "<br />";
727
+ $mlw_display .= "<script>
728
+ var mlw_code = '';
729
+ var mlw_chars = '0123456789ABCDEFGHIJKL!@#$%^&*()MNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
730
+ var mlw_code_length = 5;
731
+ for (var i=0; i<mlw_code_length; i++) {
732
+ var rnum = Math.floor(Math.random() * mlw_chars.length);
733
+ mlw_code += mlw_chars.substring(rnum,rnum+1);
734
+ }
735
+ var mlw_captchaCTX = document.getElementById('mlw_captcha').getContext('2d');
736
+ mlw_captchaCTX.font = 'normal 24px Verdana';
737
+ mlw_captchaCTX.strokeStyle = '#000000';
738
+ mlw_captchaCTX.clearRect(0,0,100,50);
739
+ mlw_captchaCTX.strokeText(mlw_code,10,30,70);
740
+ mlw_captchaCTX.textBaseline = 'middle';
741
+ document.getElementById('mlw_code_captcha').value = mlw_code;
742
+ </script>
743
+ ";
744
+ }
745
+ else
746
+ {
747
+ $mlw_display .= "<span class='mlw_qmn_question' style='font-weight:bold;'>";
748
+ $mlw_qmn_total_questions = $mlw_qmn_total_questions + 1;
749
+ if ($mlw_quiz_options->question_numbering == 1) { $mlw_display .= $mlw_qmn_total_questions.") "; }
750
+ $mlw_display .= htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES)."</span><br />";
751
+ if ($mlw_question_settings['required'] == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
752
+ $mlw_display .= "<input type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$mlw_question->question_id."' />";
753
+ $mlw_display .= "<br />";
754
+ }
755
+ if ($mlw_question->comments == 0)
756
+ {
757
+ $mlw_display .= "<input type='text' class='mlw_qmn_question_comment' x-webkit-speech id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' value='".esc_attr(htmlspecialchars_decode($mlw_quiz_options->comment_field_text, ENT_QUOTES))."' onclick='clear_field(this)'/>";
758
+ $mlw_display .= "<br />";
759
+ }
760
+ if ($mlw_question->comments == 2)
761
+ {
762
+ $mlw_display .= "<textarea cols='70' rows='5' class='mlw_qmn_question_comment' id='mlwComment".$mlw_question->question_id."' name='mlwComment".$mlw_question->question_id."' onclick='clear_field(this)'>".htmlspecialchars_decode($mlw_quiz_options->comment_field_text, ENT_QUOTES)."</textarea>";
763
+ $mlw_display .= "<br />";
764
+ }
765
+ if ($mlw_question->hints != "")
766
+ {
767
+ $mlw_display .= "<span title=\"".htmlspecialchars_decode($mlw_question->hints, ENT_QUOTES)."\" style=\"text-decoration:underline;color:rgb(0,0,255);\" class='mlw_qmn_hint_link'>Hint</span>";
768
+ $mlw_display .= "<br /><br />";
769
+ }
770
+ $mlw_display .= "</div>";
771
+ if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br />"; }
772
+ }
773
+
774
+ //Display comment box if needed
775
+ if ($mlw_quiz_options->comment_section == 0)
776
+ {
777
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
778
+ $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count."'>";
779
+ $mlw_message_comments = htmlspecialchars_decode($mlw_quiz_options->message_comment, ENT_QUOTES);
780
+ $mlw_message_comments = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_comments);
781
+ $mlw_message_comments = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_comments);
782
+ $mlw_display .= "<label for='mlwQuizComments' class='mlw_qmn_comment_section_text' style='font-weight:bold;'>".$mlw_message_comments."</label><br />";
783
+ $mlw_display .= "<textarea cols='70' rows='15' id='mlwQuizComments' name='mlwQuizComments' ></textarea>";
784
+ $mlw_display .= "</div>";
785
+ if ( $mlw_quiz_options->pagination == 0) { $mlw_display .= "<br /><br />"; }
786
+ }
787
+ $mlw_display .= "<br />";
788
+ $mlw_qmn_section_count = $mlw_qmn_section_count + 1;
789
+ $mlw_display .= "<div class='quiz_section slide".$mlw_qmn_section_count." quiz_end'>";
790
+ if ($mlw_quiz_options->message_end_template != '')
791
+ {
792
+ $mlw_message_end = htmlspecialchars_decode($mlw_quiz_options->message_end_template, ENT_QUOTES);
793
+ $mlw_message_end = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_end);
794
+ $mlw_message_end = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_end);
795
+ $mlw_display .= "<span class='mlw_qmn_message_end'>".$mlw_message_end."</span>";
796
+ $mlw_display .= "<br /><br />";
797
+ }
798
+ if ($mlw_quiz_options->contact_info_location == 1)
799
+ {
800
+ $mlw_display .= mlwDisplayContactInfo($mlw_quiz_options);
801
+ }
802
+ ob_start();
803
+ do_action('mlw_qmn_end_quiz_section');
804
+ $mlw_display .= ob_get_contents();
805
+ ob_end_clean();
806
+ $mlw_display .= "<span style='display: none;'>If you are human, leave this field blank or you will be considered spam:</span>";
807
+ $mlw_display .= "<input style='display: none;' type='text' name='email' id='email' />";
808
+ $mlw_display .= "<input type='hidden' name='total_questions' id='total_questions' value='".$mlw_qmn_total_questions."'/>";
809
+ $mlw_display .= "<input type='hidden' name='timer' id='timer' value='0'/>";
810
+ $mlw_display .= "<input type='hidden' name='complete_quiz' value='confirmation' />";
811
+ $mlw_display .= "<input type='submit' value='".esc_attr(htmlspecialchars_decode($mlw_quiz_options->submit_button_text, ENT_QUOTES))."' />";
812
+ $mlw_display .= "<span name='mlw_error_message_bottom' id='mlw_error_message_bottom' style='color: red;'></span><br />";
813
+ $mlw_display .= "</form>";
814
+ $mlw_display .= "</div>";
815
+ $mlw_display .= "</div>";
816
+
817
+ }
818
+ //Display Completion Screen
819
+ else
820
+ {
821
+ ?>
822
+ <script type="text/javascript">
823
+ window.sessionStorage.setItem('mlw_time_quiz<?php echo $mlw_quiz_id; ?>', 'completed');
824
+ window.sessionStorage.setItem('mlw_started_quiz<?php echo $mlw_quiz_id; ?>', "no");
825
+ </script>
826
+ <?php
827
+ if (empty($mlw_spam_email) && $mlw_qmn_isAllowed && ((!isset($_POST["mlw_code_captcha"])) || isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] == $_POST["mlw_code_captcha"]))
828
+ {
829
+
830
+ //Load questions
831
+ $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_questions" . " WHERE quiz_id=".$mlw_quiz_id." AND deleted='0' ";
832
+ if ($mlw_quiz_options->randomness_order == 0)
833
+ {
834
+ $sql .= "ORDER BY question_order ASC";
835
+ }
836
+ if ($mlw_quiz_options->randomness_order == 1 || $mlw_quiz_options->randomness_order == 2)
837
+ {
838
+ $sql .= "ORDER BY rand()";
839
+ }
840
+ $mlw_questions = $wpdb->get_results($sql);
841
+
842
+ //Load and prepare answer arrays
843
+ $mlw_qmn_loaded_answer_arrays = array();
844
+ foreach($mlw_questions as $mlw_question_info) {
845
+ $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
846
+ if ( !is_array($mlw_qmn_answer_array_each) )
847
+ {
848
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
849
+ $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
850
+ $mlw_qmn_loaded_answer_arrays[$mlw_question_info->question_id] = array(
851
+ array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
852
+ array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
853
+ array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
854
+ array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
855
+ array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
856
+ array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
857
+ }
858
+ else
859
+ {
860
+ $mlw_qmn_loaded_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
861
+ }
862
+ }
863
+
864
+ //Variables needed for scoring
865
+ $mlw_points = 0;
866
+ $mlw_correct = 0;
867
+ $mlw_total_questions = 0;
868
+ $mlw_total_score = 0;
869
+ $mlw_question_answers = "";
870
+ isset($_POST["total_questions"]) ? $mlw_total_questions = intval($_POST["total_questions"]) : $mlw_total_questions = 0;
871
+
872
+ //Update the amount of times the quiz has been taken
873
+ $mlw_taken = $mlw_quiz_options->quiz_taken;
874
+ $mlw_taken += 1;
875
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_taken='".$mlw_taken."' WHERE quiz_id=".$mlw_quiz_id;
876
+ $results = $wpdb->query( $update );
877
+
878
+ //See which answers were correct and award points if necessary
879
+ $mlw_user_text = "";
880
+ $mlw_correct_text = "";
881
+ $mlw_qmn_answer_array = array();
882
+ foreach($mlw_questions as $mlw_question) {
883
+ $mlw_user_text = "";
884
+ $mlw_correct_text = "";
885
+ if ( isset($_POST["question".$mlw_question->question_id]) || isset($_POST["mlwComment".$mlw_question->question_id]) )
886
+ {
887
+ if ( $mlw_question->question_type == 0 || $mlw_question->question_type == 1 || $mlw_question->question_type == 2)
888
+ {
889
+ if (isset($_POST["question".$mlw_question->question_id]))
890
+ {
891
+ $mlw_user_answer = $_POST["question".$mlw_question->question_id];
892
+ }
893
+ else
894
+ {
895
+ $mlw_user_answer = " ";
896
+ }
897
+ $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
898
+ foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
899
+ {
900
+ if (htmlspecialchars(stripslashes($mlw_user_answer), ENT_QUOTES) == esc_attr($mlw_qmn_question_answers_each[0]))
901
+ {
902
+ $mlw_points += $mlw_qmn_question_answers_each[1];
903
+ $mlw_user_text .= strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES));
904
+ if ($mlw_qmn_question_answers_each[2] == 1)
905
+ {
906
+ $mlw_correct += 1;
907
+ }
908
+ }
909
+ if ($mlw_qmn_question_answers_each[2] == 1)
910
+ {
911
+ $mlw_correct_text .= htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES);
912
+ }
913
+ }
914
+ }
915
+ elseif ( $mlw_question->question_type == 3 || $mlw_question->question_type == 5 || $mlw_question->question_type == 7)
916
+ {
917
+ if (isset($_POST["question".$mlw_question->question_id]))
918
+ {
919
+ $mlw_user_answer = $_POST["question".$mlw_question->question_id];
920
+ }
921
+ else
922
+ {
923
+ $mlw_user_answer = " ";
924
+ }
925
+ $mlw_user_text .= strval(stripslashes(htmlspecialchars_decode($mlw_user_answer, ENT_QUOTES)));
926
+ $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
927
+ foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
928
+ {
929
+ $mlw_correct_text = strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES));
930
+ if (strtoupper($mlw_user_text) == strtoupper($mlw_correct_text))
931
+ {
932
+ $mlw_correct += 1;
933
+ $mlw_points += $mlw_qmn_question_answers_each[1];
934
+ break;
935
+ }
936
+ }
937
+ }
938
+ elseif ( $mlw_question->question_type == 4 || $mlw_question->question_type == 10)
939
+ {
940
+ $mlw_qmn_user_correct_answers = 0;
941
+ $mlw_qmn_total_correct_answers = 0;
942
+ $mlw_qmn_question_answers_array = $mlw_qmn_loaded_answer_arrays[$mlw_question->question_id];
943
+ $mlw_qmn_total_answers = count($mlw_qmn_question_answers_array);
944
+ foreach($mlw_qmn_question_answers_array as $mlw_qmn_question_answers_each)
945
+ {
946
+ for ($i = 1; $i <= $mlw_qmn_total_answers; $i++) {
947
+ if (isset($_POST["question".$mlw_question->question_id."_".$i]) && htmlspecialchars(stripslashes($_POST["question".$mlw_question->question_id."_".$i]), ENT_QUOTES) == esc_attr($mlw_qmn_question_answers_each[0]))
948
+ {
949
+ $mlw_points += $mlw_qmn_question_answers_each[1];
950
+ $mlw_user_text .= strval(htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES)).".";
951
+ if ($mlw_qmn_question_answers_each[2] == 1)
952
+ {
953
+ $mlw_qmn_user_correct_answers += 1;
954
+ }
955
+ else
956
+ {
957
+ $mlw_qmn_user_correct_answers = -1;
958
+ }
959
+ }
960
+ }
961
+ if ($mlw_qmn_question_answers_each[2] == 1)
962
+ {
963
+ $mlw_correct_text .= htmlspecialchars_decode($mlw_qmn_question_answers_each[0], ENT_QUOTES).".";
964
+ $mlw_qmn_total_correct_answers++;
965
+ }
966
+ }
967
+ if ($mlw_qmn_user_correct_answers == $mlw_qmn_total_correct_answers)
968
+ {
969
+ $mlw_correct += 1;
970
+ }
971
+ }
972
+ if (isset($_POST["mlwComment".$mlw_question->question_id]))
973
+ {
974
+ $mlw_qm_question_comment = $_POST["mlwComment".$mlw_question->question_id];
975
+ }
976
+ else
977
+ {
978
+ $mlw_qm_question_comment = "";
979
+ }
980
+
981
+ $mlw_question_answer_display = htmlspecialchars_decode($mlw_quiz_options->question_answer_template, ENT_QUOTES);
982
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , htmlspecialchars_decode($mlw_question->question_name, ENT_QUOTES), $mlw_question_answer_display);
983
+ $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , $mlw_user_text, $mlw_question_answer_display);
984
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , $mlw_correct_text, $mlw_question_answer_display);
985
+ $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $mlw_qm_question_comment, $mlw_question_answer_display);
986
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($mlw_question->question_answer_info, ENT_QUOTES), $mlw_question_answer_display);
987
+
988
+ $mlw_qmn_answer_array[] = array($mlw_question->question_name, htmlspecialchars($mlw_user_text, ENT_QUOTES), htmlspecialchars($mlw_correct_text, ENT_QUOTES), htmlspecialchars(stripslashes($mlw_qm_question_comment), ENT_QUOTES));
989
+
990
+ $mlw_question_answers .= $mlw_question_answer_display;
991
+ $mlw_question_answers .= "<br />";
992
+ }
993
+ }
994
+
995
+ //Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
996
+ if ($mlw_total_questions != 0)
997
+ {
998
+ $mlw_total_score = round((($mlw_correct/$mlw_total_questions)*100), 2);
999
+ $mlw_average_points = round(($mlw_points/$mlw_total_questions), 2);
1000
+ }
1001
+ else
1002
+ {
1003
+ $mlw_total_score = 0;
1004
+ $mlw_average_points = 0;
1005
+ }
1006
+
1007
+ //Prepare comment section if set
1008
+ if (isset($_POST["mlwQuizComments"]))
1009
+ {
1010
+ $mlw_qm_quiz_comments = $_POST["mlwQuizComments"];
1011
+ }
1012
+ else
1013
+ {
1014
+ $mlw_qm_quiz_comments = "";
1015
+ }
1016
+
1017
+
1018
+ //Prepare Certificate
1019
+ $mlw_certificate_link = "";
1020
+ $mlw_certificate_options = unserialize($mlw_quiz_options->certificate_template);
1021
+ if (!is_array($mlw_certificate_options)) {
1022
+ // something went wrong, initialize to empty array
1023
+ $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
1024
+ }
1025
+ if ($mlw_certificate_options[4] == 0)
1026
+ {
1027
+ $mlw_message_certificate = $mlw_certificate_options[1];
1028
+ $mlw_message_certificate = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_certificate);
1029
+ $mlw_message_certificate = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_certificate);
1030
+ $mlw_message_certificate = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_certificate);
1031
+ $mlw_message_certificate = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_certificate);
1032
+ $mlw_message_certificate = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_certificate);
1033
+ $mlw_message_certificate = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_certificate);
1034
+ $mlw_message_certificate = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_certificate);
1035
+ $mlw_message_certificate = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_certificate);
1036
+ $mlw_message_certificate = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_certificate);
1037
+ $mlw_message_certificate = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_certificate);
1038
+ $mlw_message_certificate = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_certificate);
1039
+ $mlw_message_certificate = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_certificate);
1040
+ $mlw_message_certificate = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_certificate);
1041
+ $mlw_message_certificate = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_certificate);
1042
+ $mlw_message_certificate = str_replace( "\n" , "<br>", $mlw_message_certificate);
1043
+ $mlw_plugindirpath = plugin_dir_path( __FILE__ );
1044
+ $plugindirpath=plugin_dir_path( __FILE__ );
1045
+ $mlw_qmn_certificate_file=<<<EOC
1046
+ <?php
1047
+ include("$plugindirpath/WriteHTML.php");
1048
+ \$pdf=new PDF_HTML();
1049
+ \$pdf->AddPage('L');
1050
+ EOC;
1051
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[3] != '' ? '$pdf->Image("'.$mlw_certificate_options[3].'",0,0,$pdf->w, $pdf->h);' : '';
1052
+ $mlw_qmn_certificate_file.=<<<EOC
1053
+ \$pdf->Ln(20);
1054
+ \$pdf->SetFont('Arial','B',24);
1055
+ \$pdf->MultiCell(280,20,'$mlw_certificate_options[0]',0,'C');
1056
+ \$pdf->Ln(15);
1057
+ \$pdf->SetFont('Arial','',16);
1058
+ \$pdf->WriteHTML("<p align='center'>$mlw_message_certificate</p>");
1059
+ EOC;
1060
+ $mlw_qmn_certificate_file.=$mlw_certificate_options[2] != '' ? '$pdf->Image("'.$mlw_certificate_options[2].'",110,130);' : '';
1061
+ $mlw_qmn_certificate_file.=<<<EOC
1062
+ \$pdf->Output('mlw_qmn_certificate.pdf','D');
1063
+ unlink(__FILE__);
1064
+ EOC;
1065
+ $mlw_qmn_certificate_filename = str_replace(home_url()."/", '', plugin_dir_url( __FILE__ ))."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
1066
+ file_put_contents($mlw_qmn_certificate_filename, $mlw_qmn_certificate_file);
1067
+ $mlw_qmn_certificate_filename = plugin_dir_url( __FILE__ )."certificates/mlw_qmn_quiz".date("YmdHis").$mlw_qmn_timer.".php";
1068
+ $mlw_certificate_link = "<a href='".$mlw_qmn_certificate_filename."' style='color: blue;'>Download Certificate</a>";
1069
+ }
1070
+
1071
+ /*
1072
+ Prepare the landing page
1073
+ -First, unserialize message_after column
1074
+ -Second, check for array in case user has not updated
1075
+ Message array = (array( bottomvalue, topvalue, text),array( bottomvalue, topvalue, text), etc..., array(0,0,text))
1076
+ */
1077
+ $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
1078
+ if (is_array($mlw_message_after_array))
1079
+ {
1080
+ //Cycle through landing pages
1081
+ foreach($mlw_message_after_array as $mlw_each)
1082
+ {
1083
+ //Check to see if default
1084
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
1085
+ {
1086
+ $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1087
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1088
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1089
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1090
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1091
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1092
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1093
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1094
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1095
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1096
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1097
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1098
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1099
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1100
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1101
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1102
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1103
+ $mlw_display .= $mlw_message_after;
1104
+ break;
1105
+ }
1106
+ else
1107
+ {
1108
+ //Check to see if points fall in correct range
1109
+ if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
1110
+ {
1111
+ $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1112
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1113
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1114
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1115
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1116
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1117
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1118
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1119
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1120
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1121
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1122
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1123
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1124
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1125
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1126
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1127
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1128
+ $mlw_display .= $mlw_message_after;
1129
+ break;
1130
+ }
1131
+ //Check to see if score fall in correct range
1132
+ if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
1133
+ {
1134
+ $mlw_message_after = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1135
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1136
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1137
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1138
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1139
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1140
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1141
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1142
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1143
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1144
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1145
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1146
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1147
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1148
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1149
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1150
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1151
+ $mlw_display .= $mlw_message_after;
1152
+ break;
1153
+ }
1154
+ }
1155
+ }
1156
+ }
1157
+ else
1158
+ {
1159
+ //Prepare the after quiz message
1160
+ $mlw_message_after = htmlspecialchars_decode($mlw_quiz_options->message_after, ENT_QUOTES);
1161
+ $mlw_message_after = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message_after);
1162
+ $mlw_message_after = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message_after);
1163
+ $mlw_message_after = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message_after);
1164
+ $mlw_message_after = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message_after);
1165
+ $mlw_message_after = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message_after);
1166
+ $mlw_message_after = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message_after);
1167
+ $mlw_message_after = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message_after);
1168
+ $mlw_message_after = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message_after);
1169
+ $mlw_message_after = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message_after);
1170
+ $mlw_message_after = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message_after);
1171
+ $mlw_message_after = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message_after);
1172
+ $mlw_message_after = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message_after);
1173
+ $mlw_message_after = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message_after);
1174
+ $mlw_message_after = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message_after);
1175
+ $mlw_message_after = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message_after);
1176
+ $mlw_message_after = str_replace( "\n" , "<br>", $mlw_message_after);
1177
+ $mlw_display .= $mlw_message_after;
1178
+ }
1179
+
1180
+ if ($mlw_quiz_options->social_media == 1)
1181
+ {
1182
+ ?>
1183
+ <script>
1184
+ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title)
1185
+ {
1186
+ var sTop = window.screen.height/2-(218);
1187
+ var sLeft = window.screen.width/2-(313);
1188
+ var sqShareOptions = "height=400,width=580,toolbar=0,status=0,location=0,menubar=0,directories=0,scrollbars=0,top=" + sTop + ",left=" + sLeft;
1189
+ var pageUrl = window.location.href;
1190
+ var pageUrlEncoded = encodeURIComponent(pageUrl);
1191
+ if (network == 1)
1192
+ {
1193
+ var Url = "https://www.facebook.com/dialog/feed?"
1194
+ + "display=popup&"
1195
+ + "app_id=483815031724529&"
1196
+ + "link=" + pageUrlEncoded + "&"
1197
+ + "name=" + encodeURIComponent(mlw_qmn_social_text) + "&"
1198
+ + "description= &"
1199
+ + "redirect_uri=http://www.mylocalwebstop.com/mlw_qmn_close.html";
1200
+ }
1201
+ if (network == 2)
1202
+ {
1203
+ var Url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(mlw_qmn_social_text);
1204
+ }
1205
+ window.open(Url, "Share", sqShareOptions);
1206
+ return false;
1207
+ }
1208
+ </script>
1209
+ <?php
1210
+ $mlw_social_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_quiz_options->social_media_text);
1211
+ $mlw_social_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_social_message);
1212
+ $mlw_social_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_social_message);
1213
+ $mlw_social_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_social_message);
1214
+ $mlw_social_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_social_message);
1215
+ $mlw_social_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_social_message);
1216
+ $mlw_social_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_social_message);
1217
+ $mlw_social_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_social_message);
1218
+ $mlw_display .= "<br />
1219
+ <a class=\"mlw_qmn_quiz_link\" style=\"display: inline; vertical-align:top !important;font-weight: bold; cursor: pointer;text-decoration: none;\" onclick=\"mlw_qmn_share(1, '".esc_js($mlw_social_message)."', '".esc_js($mlw_quiz_options->quiz_name)."');\">Facebook</a>
1220
+ <a class=\"mlw_qmn_quiz_link\" style=\"display: inline; vertical-align:top !important;font-weight: bold; cursor: pointer;text-decoration: none;\" onclick=\"mlw_qmn_share(2, '".esc_js($mlw_social_message)."', '".esc_js($mlw_quiz_options->quiz_name)."');\">Twitter</a>
1221
+ <br />";
1222
+ }
1223
+
1224
+ //Switch email type to HTML
1225
+ add_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
1226
+
1227
+ /*
1228
+ Prepare and send the user email
1229
+ - First, check to see if user_email_template is the newer array format, if not use it as the template
1230
+ - If it is an array, check to see if the score meets the parameter of one of the templates. If, not send the default
1231
+ */
1232
+ $mlw_message = "";
1233
+ if ($mlw_quiz_options->send_user_email == "0")
1234
+ {
1235
+ if ($mlw_user_email != "")
1236
+ {
1237
+ $mlw_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
1238
+ if (is_array($mlw_user_email_array))
1239
+ {
1240
+ //Cycle through landing pages
1241
+ foreach($mlw_user_email_array as $mlw_each)
1242
+ {
1243
+
1244
+ //Generate Email Subject
1245
+ if (!isset($mlw_each[3]))
1246
+ {
1247
+ $mlw_each[3] = "Quiz Results For %QUIZ_NAME";
1248
+ }
1249
+ $mlw_each[3] = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_each[3]);
1250
+ $mlw_each[3] = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_each[3]);
1251
+ $mlw_each[3] = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_each[3]);
1252
+ $mlw_each[3] = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_each[3]);
1253
+ $mlw_each[3] = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_each[3]);
1254
+ $mlw_each[3] = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_each[3]);
1255
+ $mlw_each[3] = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_each[3]);
1256
+ $mlw_each[3] = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_each[3]);
1257
+ $mlw_each[3] = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_each[3]);
1258
+ $mlw_each[3] = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_each[3]);
1259
+ $mlw_each[3] = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_each[3]);
1260
+ $mlw_each[3] = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_each[3]);
1261
+
1262
+
1263
+ //Check to see if default
1264
+ if ($mlw_each[0] == 0 && $mlw_each[1] == 0)
1265
+ {
1266
+ $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1267
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1268
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1269
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1270
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1271
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1272
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1273
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1274
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1275
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1276
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1277
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1278
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1279
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1280
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1281
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1282
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1283
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1284
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1285
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1286
+ wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1287
+ break;
1288
+ }
1289
+ else
1290
+ {
1291
+ //Check to see if points fall in correct range
1292
+ if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each[0] && $mlw_points <= $mlw_each[1])
1293
+ {
1294
+ $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1295
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1296
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1297
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1298
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1299
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1300
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1301
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1302
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1303
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1304
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1305
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1306
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1307
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1308
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1309
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1310
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1311
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1312
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1313
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1314
+ wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1315
+ break;
1316
+ }
1317
+
1318
+ //Check to see if score fall in correct range
1319
+ if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each[0] && $mlw_total_score <= $mlw_each[1])
1320
+ {
1321
+ $mlw_message = htmlspecialchars_decode($mlw_each[2], ENT_QUOTES);
1322
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1323
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1324
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1325
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1326
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1327
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1328
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1329
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1330
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1331
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1332
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1333
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1334
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1335
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1336
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1337
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1338
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1339
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1340
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1341
+ wp_mail($mlw_user_email, $mlw_each[3], $mlw_message, $mlw_headers);
1342
+ break;
1343
+ }
1344
+ }
1345
+ }
1346
+ }
1347
+ else
1348
+ {
1349
+ $mlw_message = htmlspecialchars_decode($mlw_quiz_options->user_email_template, ENT_QUOTES);
1350
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1351
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1352
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1353
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1354
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1355
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1356
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1357
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1358
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1359
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1360
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1361
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1362
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1363
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1364
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1365
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1366
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1367
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1368
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1369
+ wp_mail($mlw_user_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
1370
+ }
1371
+ }
1372
+ }
1373
+
1374
+ //Prepare and send the admin email
1375
+ $mlw_message = "";
1376
+ if ($mlw_quiz_options->send_admin_email == "0")
1377
+ {
1378
+ $mlw_message = htmlspecialchars_decode($mlw_quiz_options->admin_email_template, ENT_QUOTES);
1379
+ $mlw_message = str_replace( "%POINT_SCORE%" , $mlw_points, $mlw_message);
1380
+ $mlw_message = str_replace( "%AVERAGE_POINT%" , $mlw_average_points, $mlw_message);
1381
+ $mlw_message = str_replace( "%AMOUNT_CORRECT%" , $mlw_correct, $mlw_message);
1382
+ $mlw_message = str_replace( "%TOTAL_QUESTIONS%" , $mlw_total_questions, $mlw_message);
1383
+ $mlw_message = str_replace( "%CORRECT_SCORE%" , $mlw_total_score, $mlw_message);
1384
+ $mlw_message = str_replace( "%USER_NAME%" , $mlw_user_name, $mlw_message);
1385
+ $mlw_message = str_replace( "%USER_BUSINESS%" , $mlw_user_comp, $mlw_message);
1386
+ $mlw_message = str_replace( "%USER_PHONE%" , $mlw_user_phone, $mlw_message);
1387
+ $mlw_message = str_replace( "%USER_EMAIL%" , $mlw_user_email, $mlw_message);
1388
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1389
+ $mlw_message = str_replace( "%QUESTIONS_ANSWERS%" , $mlw_question_answers, $mlw_message);
1390
+ $mlw_message = str_replace( "%COMMENT_SECTION%" , $mlw_qm_quiz_comments, $mlw_message);
1391
+ $mlw_message = str_replace( "%TIMER%" , $mlw_qmn_timer, $mlw_message);
1392
+ $mlw_message = str_replace( "%CERTIFICATE_LINK%" , $mlw_certificate_link, $mlw_message);
1393
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1394
+ if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "<br>This email was generated by the Quiz Master Next script by Frank Corso";}
1395
+ $mlw_message = str_replace( "\n" , "<br>", $mlw_message);
1396
+ $mlw_message = str_replace( "<br/>" , "<br>", $mlw_message);
1397
+ $mlw_message = str_replace( "<br />" , "<br>", $mlw_message);
1398
+ $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n";
1399
+ $mlw_qmn_admin_emails = explode(",", $mlw_quiz_options->admin_email);
1400
+ foreach($mlw_qmn_admin_emails as $admin_email)
1401
+ {
1402
+ wp_mail($admin_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers);
1403
+ }
1404
+ }
1405
+
1406
+ //Remove HTML type for emails
1407
+ remove_filter( 'wp_mail_content_type', 'mlw_qmn_set_html_content_type' );
1408
+
1409
+ //Save the results into database
1410
+ $mlw_quiz_results_array = array( intval($mlw_qmn_timer), $mlw_qmn_answer_array, htmlspecialchars(stripslashes($mlw_qm_quiz_comments), ENT_QUOTES));
1411
+ $mlw_quiz_results = serialize($mlw_quiz_results_array);
1412
+
1413
+ global $wpdb;
1414
+ $table_name = $wpdb->prefix . "mlw_results";
1415
+ $results = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $table_name . " (result_id, quiz_id, quiz_name, quiz_system, point_score, correct_score, correct, total, name, business, email, phone, user, time_taken, time_taken_real, quiz_results, deleted) VALUES (NULL, %d, '%s', %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', 0)", $mlw_quiz_id, $mlw_quiz_options->quiz_name, $mlw_quiz_options->system, $mlw_points, $mlw_total_score, $mlw_correct, $mlw_total_questions, $mlw_user_name, $mlw_user_comp, $mlw_user_email, $mlw_user_phone, get_current_user_id(), date("h:i:s A m/d/Y"), date("Y-m-d H:i:s"), $mlw_quiz_results) );
1416
+
1417
+ //Integration Action
1418
+ do_action('mlw_qmn_load_results_page');
1419
+ }
1420
+ else
1421
+ {
1422
+ if (!$mlw_qmn_isAllowed)
1423
+ {
1424
+ $current_user = wp_get_current_user();
1425
+ $mlw_message = htmlspecialchars_decode($mlw_quiz_options->total_user_tries_text, ENT_QUOTES);
1426
+ $mlw_message = str_replace( "%QUIZ_NAME%" , $mlw_quiz_options->quiz_name, $mlw_message);
1427
+ $mlw_message = str_replace( "%USER_NAME%" , $current_user->display_name, $mlw_message);
1428
+ $mlw_message = str_replace( "%CURRENT_DATE%" , date("F jS Y"), $mlw_message);
1429
+ $mlw_display .= $mlw_message;
1430
+ }
1431
+ elseif (isset($_POST["mlw_code_captcha"]) && $_POST["mlw_user_captcha"] != $_POST["mlw_code_captcha"])
1432
+ {
1433
+ $mlw_display .= "There was an issue with the captcha verification. Please try again.";
1434
+ }
1435
+ else { $mlw_display .= "Thank you."; }
1436
+ }
1437
+ }
1438
+ return $mlw_display;
1439
+ }
1440
+
1441
+
1442
+ /*
1443
+ This function displays fields to ask for contact information
1444
+ */
1445
+ function mlwDisplayContactInfo($mlw_quiz_options)
1446
+ {
1447
+ $mlw_contact_display = "";
1448
+ //Check to see if user is logged in, then ask for contact if not
1449
+ if ( is_user_logged_in() )
1450
+ {
1451
+ //If this quiz does not let user edit contact information we hide this section
1452
+ if ($mlw_quiz_options->loggedin_user_contact == 1)
1453
+ {
1454
+ $mlw_contact_display .= "<div style='display:none;'>";
1455
+ }
1456
+
1457
+ //Retrieve current user information and save into text fields for contact information
1458
+ $current_user = wp_get_current_user();
1459
+ if ($mlw_quiz_options->user_name != 2)
1460
+ {
1461
+ $mlw_contact_class = "class=\"\"";
1462
+ if ($mlw_quiz_options->user_name == 1)
1463
+ {
1464
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1465
+ }
1466
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1467
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='".$current_user->display_name."' />";
1468
+ $mlw_contact_display .= "<br /><br />";
1469
+
1470
+ }
1471
+ if ($mlw_quiz_options->user_comp != 2)
1472
+ {
1473
+ $mlw_contact_class = "class=\"\"";
1474
+ if ($mlw_quiz_options->user_comp == 1)
1475
+ {
1476
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1477
+ }
1478
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1479
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1480
+ $mlw_contact_display .= "<br /><br />";
1481
+ }
1482
+ if ($mlw_quiz_options->user_email != 2)
1483
+ {
1484
+ $mlw_contact_class = "class=\"\"";
1485
+ if ($mlw_quiz_options->user_email == 1)
1486
+ {
1487
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1488
+ }
1489
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1490
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='".$current_user->user_email."' />";
1491
+ $mlw_contact_display .= "<br /><br />";
1492
+ }
1493
+ if ($mlw_quiz_options->user_phone != 2)
1494
+ {
1495
+ $mlw_contact_class = "class=\"\"";
1496
+ if ($mlw_quiz_options->user_phone == 1)
1497
+ {
1498
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1499
+ }
1500
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1501
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1502
+ $mlw_contact_display .= "<br /><br />";
1503
+ }
1504
+
1505
+ //End of hidden section div
1506
+ if ($mlw_quiz_options->loggedin_user_contact == 1)
1507
+ {
1508
+ $mlw_contact_display .= "</div>";
1509
+ }
1510
+ }
1511
+ else
1512
+ {
1513
+ //See if the site wants to ask for any contact information, then ask for it
1514
+ if ($mlw_quiz_options->user_name != 2)
1515
+ {
1516
+ $mlw_contact_class = "class=\"\"";
1517
+ if ($mlw_quiz_options->user_name == 1)
1518
+ {
1519
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1520
+ }
1521
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->name_field_text, ENT_QUOTES)."</span><br />";
1522
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserName' value='' />";
1523
+ $mlw_contact_display .= "<br /><br />";
1524
+ }
1525
+ if ($mlw_quiz_options->user_comp != 2)
1526
+ {
1527
+ $mlw_contact_class = "class=\"\"";
1528
+ if ($mlw_quiz_options->user_comp == 1)
1529
+ {
1530
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1531
+ }
1532
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->business_field_text, ENT_QUOTES)."</span><br />";
1533
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserComp' value='' />";
1534
+ $mlw_contact_display .= "<br /><br />";
1535
+ }
1536
+ if ($mlw_quiz_options->user_email != 2)
1537
+ {
1538
+ $mlw_contact_class = "class=\"\"";
1539
+ if ($mlw_quiz_options->user_email == 1)
1540
+ {
1541
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1542
+ }
1543
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."</span><br />";
1544
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserEmail' value='' />";
1545
+ $mlw_contact_display .= "<br /><br />";
1546
+ }
1547
+ if ($mlw_quiz_options->user_phone != 2)
1548
+ {
1549
+ $mlw_contact_class = "class=\"\"";
1550
+ if ($mlw_quiz_options->user_phone == 1)
1551
+ {
1552
+ $mlw_contact_class = "class=\"mlwRequiredText\"";
1553
+ }
1554
+ $mlw_contact_display .= "<span style='font-weight:bold;';>".htmlspecialchars_decode($mlw_quiz_options->phone_field_text, ENT_QUOTES)."</span><br />";
1555
+ $mlw_contact_display .= "<input type='text' $mlw_contact_class x-webkit-speech name='mlwUserPhone' value='' />";
1556
+ $mlw_contact_display .= "<br /><br />";
1557
+ }
1558
+ }
1559
+ return $mlw_contact_display;
1560
+ }
1561
+
1562
+ /*
1563
+ This function helps set the email type to HTML
1564
+ */
1565
+ function mlw_qmn_set_html_content_type() {
1566
+
1567
+ return 'text/html';
1568
+ }
1569
  ?>
includes/mlw_quiz_admin.php CHANGED
@@ -9,13 +9,8 @@ Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
9
  function mlw_generate_quiz_admin()
10
  {
11
  global $wpdb;
 
12
  $table_name = $wpdb->prefix . "mlw_quizzes";
13
- $hasCreatedQuiz = false;
14
- $hasDeletedQuiz = false;
15
- $hasUpdatedQuizName = false;
16
- $hasDuplicatedQuiz = false;
17
- $mlw_qmn_isQueryError = false;
18
- $mlw_qmn_error_code = '0';
19
 
20
  //Create new quiz
21
  if ( isset( $_POST["create_quiz"] ) && $_POST["create_quiz"] == "confirmation" )
@@ -77,7 +72,7 @@ function mlw_generate_quiz_admin()
77
  $results = $wpdb->query( $insert );
78
  if ($results != false)
79
  {
80
- $hasCreatedQuiz = true;
81
  //Insert Action Into Audit Trail
82
  global $current_user;
83
  get_currentuserinfo();
@@ -89,8 +84,7 @@ function mlw_generate_quiz_admin()
89
  }
90
  else
91
  {
92
- $mlw_qmn_error_code = '0001';
93
- $mlw_qmn_isQueryError = true;
94
  }
95
 
96
  }
@@ -109,7 +103,7 @@ function mlw_generate_quiz_admin()
109
  $delete_question_results = $wpdb->query( $update );
110
  if ($results != false)
111
  {
112
- $hasDeletedQuiz = true;
113
 
114
  //Insert Action Into Audit Trail
115
  global $current_user;
@@ -122,8 +116,7 @@ function mlw_generate_quiz_admin()
122
  }
123
  else
124
  {
125
- $mlw_qmn_error_code = '0002';
126
- $mlw_qmn_isQueryError = true;
127
  }
128
 
129
  }
@@ -137,7 +130,7 @@ function mlw_generate_quiz_admin()
137
  $results = $wpdb->query( $mlw_update_quiz_table );
138
  if ($results != false)
139
  {
140
- $hasUpdatedQuizName = true;
141
 
142
  //Insert Action Into Audit Trail
143
  global $current_user;
@@ -150,8 +143,7 @@ function mlw_generate_quiz_admin()
150
  }
151
  else
152
  {
153
- $mlw_qmn_error_code = '0003';
154
- $mlw_qmn_isQueryError = true;
155
  }
156
  }
157
 
@@ -265,6 +257,7 @@ function mlw_generate_quiz_admin()
265
  //$results = $wpdb->query( "INSERT INTO ".$table_name." (quiz_id, quiz_name, message_before, message_after, message_comment, message_end_template, user_email_template, admin_email_template, submit_button_text, name_field_text, business_field_text, email_field_text, phone_field_text, comment_field_text, email_from_text, question_answer_template, leaderboard_template, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, admin_email, comment_section, question_from_total, total_user_tries, total_user_tries_text, certificate_template, social_media, social_media_text, pagination, pagination_text, timer_limit, quiz_stye, question_numbering, quiz_views, quiz_taken, deleted) VALUES (NULL , '".$mlw_duplicate_quiz_name."' , '".$mlw_qmn_duplicate_data->message_before."', '".$mlw_qmn_duplicate_data->message_after."', '".$mlw_qmn_duplicate_data->message_comment."', '".$mlw_qmn_duplicate_data->message_end_template."', '".$mlw_qmn_duplicate_data->user_email_template."', '".$mlw_qmn_duplicate_data->admin_email_template."', '".$mlw_qmn_duplicate_data->submit_button_text."', '".$mlw_qmn_duplicate_data->name_field_text."', '".$mlw_qmn_duplicate_data->business_field_text."', '".$mlw_qmn_duplicate_data->email_field_text."', '".$mlw_qmn_duplicate_data->phone_field_text."', '".$mlw_qmn_duplicate_data->comment_field_text."', '".$mlw_qmn_duplicate_data->email_from_text."', '".$mlw_qmn_duplicate_data->question_answer_template."', '".$mlw_qmn_duplicate_data->leaderboard_template."', ".$mlw_qmn_duplicate_data->system.", ".$mlw_qmn_duplicate_data->randomness_order.", ".$mlw_qmn_duplicate_data->loggedin_user_contact.", ".$mlw_qmn_duplicate_data->show_score.", ".$mlw_qmn_duplicate_data->send_user_email.", ".$mlw_qmn_duplicate_data->send_admin_email.", ".$mlw_qmn_duplicate_data->contact_info_location.", ".$mlw_qmn_duplicate_data->user_name.", ".$mlw_qmn_duplicate_data->user_comp.", ".$mlw_qmn_duplicate_data->user_email.", ".$mlw_qmn_duplicate_data->user_phone.", '".get_option( 'admin_email', 'Enter email' )."', ".$mlw_qmn_duplicate_data->comment_section.", ".$mlw_qmn_duplicate_data->question_from_total.", ".$mlw_qmn_duplicate_data->total_user_tries.", '".$mlw_qmn_duplicate_data->total_user_tries_text."', '".$mlw_qmn_duplicate_data->certificate_template."', ".$mlw_qmn_duplicate_data->social_media.", '".$mlw_qmn_duplicate_data->social_media_text."', ".$mlw_qmn_duplicate_data->pagination.", '".$mlw_qmn_duplicate_data->pagination_text."', ".$mlw_qmn_duplicate_data->timer_limit.", '".$mlw_qmn_duplicate_data->quiz_stye."', ".$mlw_qmn_duplicate_data->question_numbering.", 0, 0, 0)" );
266
  if ($results != false)
267
  {
 
268
  $hasDuplicatedQuiz = true;
269
 
270
  //Insert Action Into Audit Trail
@@ -278,8 +271,7 @@ function mlw_generate_quiz_admin()
278
  }
279
  else
280
  {
281
- $mlw_qmn_error_code = '0011';
282
- $mlw_qmn_isQueryError = true;
283
  }
284
  if (isset($_POST["duplicate_questions"]))
285
  {
@@ -342,8 +334,7 @@ function mlw_generate_quiz_admin()
342
  );
343
  if ($question_results == false)
344
  {
345
- $mlw_qmn_error_code = '0011';
346
- $mlw_qmn_isQueryError = true;
347
  }
348
  }
349
  }
@@ -386,30 +377,8 @@ function mlw_generate_quiz_admin()
386
  var $j = jQuery.noConflict();
387
  // increase the default animation speed to exaggerate the effect
388
  $j.fx.speeds._default = 1000;
389
- $j(function() {
390
- $j('#dialog').dialog({
391
- autoOpen: false,
392
- show: 'blind',
393
- hide: 'explode',
394
- buttons: {
395
- Ok: function() {
396
- $j(this).dialog('close');
397
- }
398
- }
399
- });
400
-
401
- $j('#opener').click(function() {
402
- $j('#dialog').dialog('open');
403
- return false;
404
- } );
405
- });
406
  $j(function() {
407
  $j("#prev_page, #next_page").button();
408
- $j("#new_quiz_button, #new_quiz_button_two").button({
409
- icons: {
410
- primary: "ui-icon-circle-plus"
411
- }
412
- });
413
  });
414
  $j(function() {
415
  $j('#new_quiz_dialog').dialog({
@@ -490,59 +459,26 @@ function mlw_generate_quiz_admin()
490
  cursor:hand;
491
  }
492
  </style>
493
- <div class="wrap">
494
- <div class='mlw_quiz_options'>
495
- <h2>Quizzes<a id="opener" href="">(?)</a></h2>
496
- <?php if ($hasCreatedQuiz)
497
  {
498
- ?>
499
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
500
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
501
- <strong>Hey!</strong> Your new quiz has been created successfully. To begin editing options and adding questions to your quiz, click on the edit link for that quiz.</p>
502
- </div>
503
- <?php
504
  }
505
- if ($hasDuplicatedQuiz)
506
  {
507
- ?>
508
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
509
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
510
- <strong>Hey!</strong> The quiz has been duplicated successfully.</p>
511
- </div>
512
- <?php
513
  }
514
- ?>
515
- <?php if ($mlw_qmn_isQueryError)
516
  {
517
- ?>
518
- <div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
519
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
520
- <strong>Uh-Oh!</strong> There has been an error in this action! Please share this with the developer: Error Code <?php echo $mlw_qmn_error_code; ?></p>
521
- </div>
522
- <?php
523
  }
524
- if ($hasDeletedQuiz)
525
- {
526
- ?>
527
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
528
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
529
- <strong>Hey!</strong> The quiz has been deleted.</p>
530
- </div>
531
- <?php
532
- }
533
- ?>
534
- <?php if ($hasUpdatedQuizName)
535
- {
536
- ?>
537
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
538
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
539
- <strong>Hey!</strong> The quiz name has been updated.</p>
540
- </div>
541
- <?php
542
- }
543
- ?>
544
- <button id="new_quiz_button_two">Create New Quiz</button>
545
  <?php
 
 
546
  $quotes_list = "";
547
  $display = "";
548
  $alternate = "";
@@ -551,7 +487,8 @@ function mlw_generate_quiz_admin()
551
  else $alternate = " class=\"alternate\"";
552
  $quotes_list .= "<tr{$alternate}>";
553
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
554
- $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . esc_html($mlw_quiz_info->quiz_name) ." </span><span style='color:green;font-size:12px;'><a onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>(Edit Name)</a></span><div><span style='color:green;font-size:12px;'><a href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>Edit</a> | <a onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a> | <a href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>Results</a> | <a href='#' onclick=\"duplicateQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\">Duplicate</a></span></div></td>";
 
555
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
556
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
557
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
@@ -607,9 +544,6 @@ function mlw_generate_quiz_admin()
607
  $display .= "</table>";
608
  echo $display;
609
  ?>
610
-
611
- <button id="new_quiz_button">Create New Quiz</button>
612
-
613
  <?php echo mlw_qmn_show_adverts(); ?>
614
  <!--Dialogs-->
615
 
@@ -685,17 +619,6 @@ function mlw_generate_quiz_admin()
685
  ?>
686
  </div>
687
 
688
- <!--Help Dialog-->
689
- <div id="dialog" title="Help" style="display:none;">
690
- <h3><b>Help</b></h3>
691
- <p>This page shows all of the quizzes currently on your website.</p>
692
- <p>The table shows the quiz id, the name of your quiz, the shortcode to use on your post or page to add the quiz, the shortcode to use on your post or page to add the leaderboard, the amount of views the quiz has had, and the amount of times the quiz was finished</p>
693
- <p>To create a new quiz, click the Create New Quiz button and fill out the name.</p>
694
- <p>To edit a quiz, click the Edit link underneath the name of the quiz.</p>
695
- <p>To edit a quiz's name, click the Edit Name link next to the name of the quiz.</p>
696
- <p>To delete a quiz, click the Delete link underneath the name of the quiz.</p>
697
- <p>To view the results of a quiz, click the Results link underneath the name of the quiz.</p>
698
- </div>
699
  </div>
700
  </div>
701
  <?php
9
  function mlw_generate_quiz_admin()
10
  {
11
  global $wpdb;
12
+ global $mlwQmnAlertManager;
13
  $table_name = $wpdb->prefix . "mlw_quizzes";
 
 
 
 
 
 
14
 
15
  //Create new quiz
16
  if ( isset( $_POST["create_quiz"] ) && $_POST["create_quiz"] == "confirmation" )
72
  $results = $wpdb->query( $insert );
73
  if ($results != false)
74
  {
75
+ $mlwQmnAlertManager->newAlert('Your new quiz has been created successfully. To begin editing your quiz, click the Edit link on the new quiz.', 'success');
76
  //Insert Action Into Audit Trail
77
  global $current_user;
78
  get_currentuserinfo();
84
  }
85
  else
86
  {
87
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0001.', 'error');
 
88
  }
89
 
90
  }
103
  $delete_question_results = $wpdb->query( $update );
104
  if ($results != false)
105
  {
106
+ $mlwQmnAlertManager->newAlert('Your quiz has been deleted successfully.', 'success');
107
 
108
  //Insert Action Into Audit Trail
109
  global $current_user;
116
  }
117
  else
118
  {
119
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0002.', 'error');
 
120
  }
121
 
122
  }
130
  $results = $wpdb->query( $mlw_update_quiz_table );
131
  if ($results != false)
132
  {
133
+ $mlwQmnAlertManager->newAlert('Your quiz name has been updated successfully.', 'success');
134
 
135
  //Insert Action Into Audit Trail
136
  global $current_user;
143
  }
144
  else
145
  {
146
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0003.', 'error');
 
147
  }
148
  }
149
 
257
  //$results = $wpdb->query( "INSERT INTO ".$table_name." (quiz_id, quiz_name, message_before, message_after, message_comment, message_end_template, user_email_template, admin_email_template, submit_button_text, name_field_text, business_field_text, email_field_text, phone_field_text, comment_field_text, email_from_text, question_answer_template, leaderboard_template, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, admin_email, comment_section, question_from_total, total_user_tries, total_user_tries_text, certificate_template, social_media, social_media_text, pagination, pagination_text, timer_limit, quiz_stye, question_numbering, quiz_views, quiz_taken, deleted) VALUES (NULL , '".$mlw_duplicate_quiz_name."' , '".$mlw_qmn_duplicate_data->message_before."', '".$mlw_qmn_duplicate_data->message_after."', '".$mlw_qmn_duplicate_data->message_comment."', '".$mlw_qmn_duplicate_data->message_end_template."', '".$mlw_qmn_duplicate_data->user_email_template."', '".$mlw_qmn_duplicate_data->admin_email_template."', '".$mlw_qmn_duplicate_data->submit_button_text."', '".$mlw_qmn_duplicate_data->name_field_text."', '".$mlw_qmn_duplicate_data->business_field_text."', '".$mlw_qmn_duplicate_data->email_field_text."', '".$mlw_qmn_duplicate_data->phone_field_text."', '".$mlw_qmn_duplicate_data->comment_field_text."', '".$mlw_qmn_duplicate_data->email_from_text."', '".$mlw_qmn_duplicate_data->question_answer_template."', '".$mlw_qmn_duplicate_data->leaderboard_template."', ".$mlw_qmn_duplicate_data->system.", ".$mlw_qmn_duplicate_data->randomness_order.", ".$mlw_qmn_duplicate_data->loggedin_user_contact.", ".$mlw_qmn_duplicate_data->show_score.", ".$mlw_qmn_duplicate_data->send_user_email.", ".$mlw_qmn_duplicate_data->send_admin_email.", ".$mlw_qmn_duplicate_data->contact_info_location.", ".$mlw_qmn_duplicate_data->user_name.", ".$mlw_qmn_duplicate_data->user_comp.", ".$mlw_qmn_duplicate_data->user_email.", ".$mlw_qmn_duplicate_data->user_phone.", '".get_option( 'admin_email', 'Enter email' )."', ".$mlw_qmn_duplicate_data->comment_section.", ".$mlw_qmn_duplicate_data->question_from_total.", ".$mlw_qmn_duplicate_data->total_user_tries.", '".$mlw_qmn_duplicate_data->total_user_tries_text."', '".$mlw_qmn_duplicate_data->certificate_template."', ".$mlw_qmn_duplicate_data->social_media.", '".$mlw_qmn_duplicate_data->social_media_text."', ".$mlw_qmn_duplicate_data->pagination.", '".$mlw_qmn_duplicate_data->pagination_text."', ".$mlw_qmn_duplicate_data->timer_limit.", '".$mlw_qmn_duplicate_data->quiz_stye."', ".$mlw_qmn_duplicate_data->question_numbering.", 0, 0, 0)" );
258
  if ($results != false)
259
  {
260
+ $mlwQmnAlertManager->newAlert('Your quiz has been duplicated successfully.', 'success');
261
  $hasDuplicatedQuiz = true;
262
 
263
  //Insert Action Into Audit Trail
271
  }
272
  else
273
  {
274
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0011.', 'error');
 
275
  }
276
  if (isset($_POST["duplicate_questions"]))
277
  {
334
  );
335
  if ($question_results == false)
336
  {
337
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0020.', 'error');
 
338
  }
339
  }
340
  }
377
  var $j = jQuery.noConflict();
378
  // increase the default animation speed to exaggerate the effect
379
  $j.fx.speeds._default = 1000;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  $j(function() {
381
  $j("#prev_page, #next_page").button();
 
 
 
 
 
382
  });
383
  $j(function() {
384
  $j('#new_quiz_dialog').dialog({
459
  cursor:hand;
460
  }
461
  </style>
462
+ <style>
463
+ .linkOptions
 
 
464
  {
465
+ font-size: 14px !important;
 
 
 
 
 
466
  }
467
+ .linkDelete
468
  {
469
+ color: red !important;
 
 
 
 
 
470
  }
471
+ .linkOptions:hover
 
472
  {
473
+ background-color: black;
 
 
 
 
 
474
  }
475
+ </style>
476
+ <div class="wrap">
477
+ <div class='mlw_quiz_options'>
478
+ <h2>Quizzes<a id="new_quiz_button" href="javascript:();" class="add-new-h2">Add New</a></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
  <?php
480
+ $mlwQmnAlertManager->showAlerts();
481
+
482
  $quotes_list = "";
483
  $display = "";
484
  $alternate = "";
487
  else $alternate = " class=\"alternate\"";
488
  $quotes_list .= "<tr{$alternate}>";
489
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_id . "</span></td>";
490
+ $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . esc_html($mlw_quiz_info->quiz_name) ." </span><span style='color:green;font-size:12px;'><a onclick=\"editQuizName('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(Edit Name)</a></span>";
491
+ $quotes_list .= "<div class=\"row-actions\"><a class='linkOptions' href='admin.php?page=mlw_quiz_options&&quiz_id=".$mlw_quiz_info->quiz_id."'>Edit</a> | <a class='linkOptions' href='admin.php?page=mlw_quiz_results&&quiz_id=".$mlw_quiz_info->quiz_id."'>Results</a> | <a href='javascript:();' class='linkOptions' onclick=\"duplicateQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\">Duplicate</a> | <a class='linkOptions linkDelete' onclick=\"deleteQuiz('".$mlw_quiz_info->quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>Delete</a></div></td>";
492
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
493
  $quotes_list .= "<td><span style='font-size:16px;'>[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]</span></td>";
494
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_views . "</span></td>";
544
  $display .= "</table>";
545
  echo $display;
546
  ?>
 
 
 
547
  <?php echo mlw_qmn_show_adverts(); ?>
548
  <!--Dialogs-->
549
 
619
  ?>
620
  </div>
621
 
 
 
 
 
 
 
 
 
 
 
 
622
  </div>
623
  </div>
624
  <?php
includes/mlw_quiz_options.php CHANGED
@@ -8,33 +8,152 @@ Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
8
 
9
  function mlw_generate_quiz_options()
10
  {
11
- $quiz_id = $_GET["quiz_id"];
12
  global $wpdb;
13
- $table_name = $wpdb->prefix . "mlw_questions";
14
- $is_new_quiz = 0;
15
- $hasUpdatedLeaderboardOptions = false;
16
- $hasCreatedQuestion = false;
17
- $hasUpdatedOptions = false;
18
- $hasUpdatedTemplates = false;
19
- $hasDeletedQuestion = false;
20
- $hasDuplicatedQuestion = false;
21
- $hasUpdatedQuestion = false;
22
- $mlw_UpdatedCertificate = false;
23
- $mlw_hasResetQuizStats = false;
24
- $mlw_hasAddedLanding = false;
25
- $mlw_hasSavedLanding = false;
26
- $mlw_hasAddedEmail = false;
27
- $mlw_hasSavedEmail = false;
28
- $mlw_hasSavedStyle = false;
29
- $mlw_qmn_isQueryError = false;
30
- $mlw_qmn_error_code = '0000';
31
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  if ($quiz_id != "")
33
  {
34
- /*
35
- Code for quiz questions tab
36
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  //Edit question
39
  if ( isset($_POST["edit_question"]) && $_POST["edit_question"] == "confirmation")
40
  {
@@ -83,7 +202,7 @@ function mlw_generate_quiz_options()
83
  $results = $wpdb->query( $update );
84
  if ($results != false)
85
  {
86
- $hasUpdatedQuestion = true;
87
 
88
  //Insert Action Into Audit Trail
89
  global $current_user;
@@ -96,8 +215,7 @@ function mlw_generate_quiz_options()
96
  }
97
  else
98
  {
99
- $mlw_qmn_isQueryError = true;
100
- $mlw_qmn_error_code = '0004';
101
  }
102
  }
103
 
@@ -112,7 +230,7 @@ function mlw_generate_quiz_options()
112
  $results = $wpdb->query( $update );
113
  if ($results != false)
114
  {
115
- $hasDeletedQuestion = true;
116
 
117
  //Insert Action Into Audit Trail
118
  global $current_user;
@@ -125,8 +243,7 @@ function mlw_generate_quiz_options()
125
  }
126
  else
127
  {
128
- $mlw_qmn_isQueryError = true;
129
- $mlw_qmn_error_code = '0002';
130
  }
131
  }
132
 
@@ -195,7 +312,7 @@ function mlw_generate_quiz_options()
195
 
196
  if ($results != false)
197
  {
198
- $hasDuplicatedQuestion = true;
199
 
200
  //Insert Action Into Audit Trail
201
  global $current_user;
@@ -208,8 +325,7 @@ function mlw_generate_quiz_options()
208
  }
209
  else
210
  {
211
- $mlw_qmn_isQueryError = true;
212
- $mlw_qmn_error_code = '0019';
213
  }
214
  }
215
 
@@ -252,7 +368,7 @@ function mlw_generate_quiz_options()
252
  $results = $wpdb->query( $insert );
253
  if ($results != false)
254
  {
255
- $hasCreatedQuestion = true;
256
 
257
  //Insert Action Into Audit Trail
258
  global $current_user;
@@ -265,1192 +381,238 @@ function mlw_generate_quiz_options()
265
  }
266
  else
267
  {
268
- $mlw_qmn_isQueryError = true;
269
- $mlw_qmn_error_code = '0006';
270
  }
271
  }
272
-
273
- //Get table of questions for this quiz
274
- if ($quiz_id != "")
275
  {
276
- global $wpdb;
277
- $mlw_qmn_table_limit = 10;
278
- $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) );
279
-
280
- if( isset($_GET{'mlw_question_page'} ) )
281
- {
282
- $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1;
283
- $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ;
284
- }
285
- else
286
- {
287
- $mlw_qmn_question_page = 0;
288
- $mlw_qmn_question_begin = 0;
289
- }
290
- $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit);
291
-
292
- $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'
293
- ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) );
294
- $is_new_quiz = $wpdb->num_rows;
295
  }
296
 
297
- /*
298
- Code for Quiz Text tab
299
- */
300
-
301
- //Submit saved templates into database
302
- if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation")
303
- {
304
- //Variables for save templates form
305
- $mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES);
306
- $mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES);
307
- $mlw_qmn_social_medi_text = htmlspecialchars($_POST["mlw_quiz_social_media_text_template"], ENT_QUOTES);
308
- $mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES);
309
- $mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES);
310
- $mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES);
311
- $mlw_business_field_text = htmlspecialchars($_POST["mlw_businessText"], ENT_QUOTES);
312
- $mlw_email_field_text = htmlspecialchars($_POST["mlw_emailText"], ENT_QUOTES);
313
- $mlw_phone_field_text = htmlspecialchars($_POST["mlw_phoneText"], ENT_QUOTES);
314
- $mlw_before_comments = htmlspecialchars($_POST["mlw_quiz_before_comments"], ENT_QUOTES);
315
- $mlw_comment_field_text = htmlspecialchars($_POST["mlw_commentText"], ENT_QUOTES);
316
- $mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] ));
317
- $mlw_email_from_text = $_POST["emailFromText"];
318
- $mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES);
319
- $quiz_id = $_POST["quiz_id"];
320
-
321
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$mlw_qmn_social_medi_text."', pagination_text='".$mlw_qmn_pagination_field."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id;
322
- $results = $wpdb->query( $update );
323
- if ($results != false)
324
- {
325
- $hasUpdatedTemplates = true;
326
-
327
- //Insert Action Into Audit Trail
328
- global $current_user;
329
- get_currentuserinfo();
330
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
331
- $insert = "INSERT INTO " . $table_name .
332
- "(trail_id, action_user, action, time) " .
333
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
334
- $results = $wpdb->query( $insert );
335
- }
336
- else
337
- {
338
- $mlw_qmn_isQueryError = true;
339
- $mlw_qmn_error_code = '0007';
340
- }
341
- }
342
 
343
-
344
- /*
345
- Code for Quiz Options tab
346
- */
347
-
348
- //Submit saved options into database
349
- if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation")
350
  {
351
- //Variables for save options form
352
- $mlw_system = $_POST["system"];
353
- $mlw_qmn_pagination = intval($_POST["pagination"]);
354
- $mlw_qmn_social_media = intval($_POST["social_media"]);
355
- $mlw_qmn_question_numbering = intval($_POST["question_numbering"]);
356
- $mlw_qmn_timer = intval($_POST["timer_limit"]);
357
- $mlw_qmn_questions_from_total = $_POST["question_from_total"];
358
- $mlw_randomness_order = $_POST["randomness_order"];
359
- $mlw_total_user_tries = intval($_POST["total_user_tries"]);
360
- $mlw_send_user_email = $_POST["sendUserEmail"];
361
- $mlw_send_admin_email = $_POST["sendAdminEmail"];
362
- $mlw_contact_location = $_POST["contact_info_location"];
363
- $mlw_user_name = $_POST["userName"];
364
- $mlw_user_comp = $_POST["userComp"];
365
- $mlw_user_email = $_POST["userEmail"];
366
- $mlw_user_phone = $_POST["userPhone"];
367
- $mlw_admin_email = $_POST["adminEmail"];
368
- $mlw_comment_section = $_POST["commentSection"];
369
- $mlw_qmn_loggedin_contact = $_POST["loggedin_user_contact"];
370
- $quiz_id = $_POST["quiz_id"];
371
-
372
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', loggedin_user_contact='".$mlw_qmn_loggedin_contact."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', admin_email='".$mlw_admin_email."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."', question_from_total=".$mlw_qmn_questions_from_total.", total_user_tries=".$mlw_total_user_tries.", social_media=".$mlw_qmn_social_media.", pagination=".$mlw_qmn_pagination.", timer_limit=".$mlw_qmn_timer.", question_numbering=".$mlw_qmn_question_numbering.", last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id;
373
- $results = $wpdb->query( $update );
374
- if ($results != false)
375
- {
376
- $hasUpdatedOptions = true;
377
-
378
- //Insert Action Into Audit Trail
379
- global $current_user;
380
- get_currentuserinfo();
381
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
382
- $insert = "INSERT INTO " . $table_name .
383
- "(trail_id, action_user, action, time) " .
384
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
385
- $results = $wpdb->query( $insert );
386
- }
387
- else
388
- {
389
- $mlw_qmn_isQueryError = true;
390
- $mlw_qmn_error_code = '0008';
391
- }
392
  }
393
-
394
- /*
395
- Code For Leaderboard Options tab
396
- */
397
-
398
- ///Submit saved leaderboard template into database
399
- if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation")
400
  {
401
- ///Variables for save leaderboard options form
402
- $mlw_leaderboard_template = $_POST["mlw_quiz_leaderboard_template"];
403
- $mlw_leaderboard_quiz_id = $_POST["leaderboard_quiz_id"];
404
- $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_leaderboard_quiz_id;
405
- $results = $wpdb->query( $update );
406
- if ($results != false)
407
- {
408
- $hasUpdatedLeaderboardOptions = true;
409
-
410
- //Insert Action Into Audit Trail
411
- global $current_user;
412
- get_currentuserinfo();
413
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
414
- $insert = "INSERT INTO " . $table_name .
415
- "(trail_id, action_user, action, time) " .
416
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
417
- $results = $wpdb->query( $insert );
418
- }
419
- else
420
- {
421
- $mlw_qmn_isQueryError = true;
422
- $mlw_qmn_error_code = '0009';
423
- }
424
  }
 
425
 
426
- /*
427
- Code For Certificate Tab
428
- */
429
-
430
- //Saved Certificate Options
431
- if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation")
432
- {
433
- $mlw_certificate_id = intval($_POST["certificate_quiz_id"]);
434
- $mlw_certificate_title = $_POST["certificate_title"];
435
- $mlw_certificate_text = $_POST["certificate_template"];
436
- $mlw_certificate_logo = $_POST["certificate_logo"];
437
- $mlw_certificate_background = $_POST["certificate_background"];
438
- $mlw_enable_certificates = intval($_POST["enableCertificates"]);
439
- $mlw_certificate = array($mlw_certificate_title, $mlw_certificate_text, $mlw_certificate_logo, $mlw_certificate_background, $mlw_enable_certificates);
440
- $mlw_certificate_serialized = serialize($mlw_certificate);
441
-
442
- $mlw_certificate_sql_results = $wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "mlw_quizzes SET certificate_template=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_certificate_serialized, $mlw_certificate_id ) );
443
-
444
 
445
- if ($mlw_certificate_sql_results != false)
 
 
 
 
446
  {
447
- $mlw_UpdatedCertificate = true;
448
-
449
- //Insert Action Into Audit Trail
450
- global $current_user;
451
- get_currentuserinfo();
452
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
453
- $insert = "INSERT INTO " . $table_name .
454
- "(trail_id, action_user, action, time) " .
455
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . date("h:i:s A m/d/Y") . "')";
456
- $results = $wpdb->query( $insert );
457
  }
458
  else
459
  {
460
- $mlw_qmn_isQueryError = true;
461
- $mlw_qmn_error_code = '0012';
462
  }
463
  }
464
-
465
- /*
466
- Code For Quiz Emails Tab
467
- */
468
-
469
- //Check to add new user email template
470
- if (isset($_POST["mlw_add_email_page"]) && $_POST["mlw_add_email_page"] == "confirmation")
471
- {
472
- //Function variables
473
- $mlw_qmn_add_email_id = intval($_POST["mlw_add_email_quiz_id"]);
474
- $mlw_qmn_user_email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) );
475
-
476
- //Load user email and check if it is array already. If not, turn it into one
477
- $mlw_qmn_email_array = @unserialize($mlw_qmn_user_email);
478
- if (is_array($mlw_qmn_email_array))
479
- {
480
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
481
- array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
482
- $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
483
-
484
- }
485
- else
486
- {
487
- $mlw_qmn_email_array = array(array(0, 0, $mlw_qmn_user_email, 'Quiz Results For %QUIZ_NAME%'));
488
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
489
- array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
490
- $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
491
- }
492
- //Update message_after with new array then check to see if worked
493
- $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) );
494
- if ($mlw_new_email_results != false)
495
- {
496
- $mlw_hasAddedEmail = true;
497
-
498
- //Insert Action Into Audit Trail
499
- global $current_user;
500
- get_currentuserinfo();
501
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
502
- $insert = "INSERT INTO " . $table_name .
503
- "(trail_id, action_user, action, time) " .
504
- "VALUES (NULL , '" . $current_user->display_name . "' , 'New User Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
505
- $results = $wpdb->query( $insert );
506
- }
507
- else
508
- {
509
- $mlw_qmn_isQueryError = true;
510
- $mlw_qmn_error_code = '0016';
511
- }
512
- }
513
-
514
- //Check to save email templates
515
- if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation")
516
- {
517
- //Function Variables
518
- $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]);
519
- $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]);
520
- $mlw_qmn_admin_email = htmlspecialchars(stripslashes($_POST["mlw_quiz_admin_email_template"]), ENT_QUOTES);
521
-
522
- //Create new array
523
- $i = 1;
524
- $mlw_qmn_new_email_array = array();
525
- while ($i <= $mlw_qmn_email_template_total)
526
- {
527
- if ($_POST["user_email_".$i] != "Delete")
528
- {
529
- $mlw_qmn_email_each = array(intval($_POST["user_email_begin_".$i]), intval($_POST["user_email_end_".$i]), htmlspecialchars(stripslashes($_POST["user_email_".$i]), ENT_QUOTES), htmlspecialchars(stripslashes($_POST["user_email_subject_".$i]), ENT_QUOTES));
530
- $mlw_qmn_new_email_array[] = $mlw_qmn_email_each;
531
- }
532
- $i++;
533
- }
534
- $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array);
535
- $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_admin_email, $mlw_qmn_email_id ) );
536
- if ($mlw_new_email_results != false)
537
- {
538
- $mlw_hasSavedEmail = true;
539
-
540
- //Insert Action Into Audit Trail
541
- global $current_user;
542
- get_currentuserinfo();
543
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
544
- $insert = "INSERT INTO " . $table_name .
545
- "(trail_id, action_user, action, time) " .
546
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Email Templates Have Been Saved For Quiz Number ".$mlw_qmn_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
547
- $results = $wpdb->query( $insert );
548
- }
549
- else
550
- {
551
- $mlw_qmn_isQueryError = true;
552
- $mlw_qmn_error_code = '0017';
553
- }
554
- }
555
-
556
- /*
557
- Code For Quiz Results Page Tab
558
- */
559
-
560
- //Check to add new results page
561
- if (isset($_POST["mlw_add_landing_page"]) && $_POST["mlw_add_landing_page"] == "confirmation")
562
- {
563
- //Function variables
564
- $mlw_qmn_landing_id = intval($_POST["mlw_add_landing_quiz_id"]);
565
- $mlw_qmn_message_after = $wpdb->get_var( $wpdb->prepare( "SELECT message_after FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_landing_id ) );
566
- //Load message_after and check if it is array already. If not, turn it into one
567
- $mlw_qmn_landing_array = @unserialize($mlw_qmn_message_after);
568
- if (is_array($mlw_qmn_landing_array))
569
- {
570
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
571
- array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
572
- $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
573
-
574
- }
575
- else
576
- {
577
- $mlw_qmn_landing_array = array(array(0, 0, $mlw_qmn_message_after));
578
- $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
579
- array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
580
- $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
581
- }
582
-
583
- //Update message_after with new array then check to see if worked
584
- $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) );
585
- if ($mlw_new_landing_results != false)
586
- {
587
- $mlw_hasAddedLanding = true;
588
-
589
- //Insert Action Into Audit Trail
590
- global $current_user;
591
- get_currentuserinfo();
592
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
593
- $insert = "INSERT INTO " . $table_name .
594
- "(trail_id, action_user, action, time) " .
595
- "VALUES (NULL , '" . $current_user->display_name . "' , 'New Landing Page Has Been Created For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
596
- $results = $wpdb->query( $insert );
597
- }
598
- else
599
- {
600
- $mlw_qmn_isQueryError = true;
601
- $mlw_qmn_error_code = '0013';
602
- }
603
- }
604
-
605
- //Check to save landing pages
606
- if (isset($_POST["mlw_save_landing_pages"]) && $_POST["mlw_save_landing_pages"] == "confirmation")
607
- {
608
- //Function Variables
609
- $mlw_qmn_landing_id = intval($_POST["mlw_landing_quiz_id"]);
610
- $mlw_qmn_landing_total = intval($_POST["mlw_landing_page_total"]);
611
-
612
- //Create new array
613
- $i = 1;
614
- $mlw_qmn_new_landing_array = array();
615
- while ($i <= $mlw_qmn_landing_total)
616
- {
617
- if ($_POST["message_after_".$i] != "Delete")
618
- {
619
- $mlw_qmn_landing_each = array(intval($_POST["message_after_begin_".$i]), intval($_POST["message_after_end_".$i]), htmlspecialchars(stripslashes($_POST["message_after_".$i]), ENT_QUOTES));
620
- $mlw_qmn_new_landing_array[] = $mlw_qmn_landing_each;
621
- }
622
- $i++;
623
- }
624
- $mlw_qmn_new_landing_array = serialize($mlw_qmn_new_landing_array);
625
- $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) );
626
- if ($mlw_new_landing_results != false)
627
- {
628
- $mlw_hasSavedLanding = true;
629
-
630
- //Insert Action Into Audit Trail
631
- global $current_user;
632
- get_currentuserinfo();
633
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
634
- $insert = "INSERT INTO " . $table_name .
635
- "(trail_id, action_user, action, time) " .
636
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Landing Pages Have Been Saved For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
637
- $results = $wpdb->query( $insert );
638
- }
639
- else
640
- {
641
- $mlw_qmn_isQueryError = true;
642
- $mlw_qmn_error_code = '0014';
643
- }
644
- }
645
-
646
- /*
647
- Code For Quiz Style Tab
648
- */
649
-
650
- if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation")
651
- {
652
- //Function Variables
653
- $mlw_qmn_style_id = intval($_POST["style_quiz_id"]);
654
- $mlw_qmn_theme = $_POST["save_quiz_theme"];
655
- $mlw_qmn_style = htmlspecialchars(stripslashes($_POST["quiz_css"]), ENT_QUOTES);
656
-
657
- //Save the new css
658
- $mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) );
659
- if ($mlw_save_stle_results != false)
660
- {
661
- $mlw_hasSavedStyle = true;
662
-
663
- //Insert Action Into Audit Trail
664
- global $current_user;
665
- get_currentuserinfo();
666
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
667
- $insert = "INSERT INTO " . $table_name .
668
- "(trail_id, action_user, action, time) " .
669
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')";
670
- $results = $wpdb->query( $insert );
671
- }
672
- else
673
- {
674
- $mlw_qmn_isQueryError = true;
675
- $mlw_qmn_error_code = '0015';
676
- }
677
- }
678
-
679
-
680
- /*
681
- Code For Quiz Tools Tab
682
- */
683
-
684
- //Update Quiz Table
685
- if (isset($_POST["mlw_reset_quiz_stats"]) && $_POST["mlw_reset_quiz_stats"] == "confirmation")
686
- {
687
- //Variables from reset stats form
688
- $mlw_reset_stats_quiz_id = $_POST["mlw_reset_quiz_id"];
689
- $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_reset_stats_quiz_id;
690
- $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql );
691
- if ($mlw_reset_sql_results != false)
692
- {
693
- $mlw_hasResetQuizStats = true;
694
-
695
- //Insert Action Into Audit Trail
696
- global $current_user;
697
- get_currentuserinfo();
698
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
699
- $insert = "INSERT INTO " . $table_name .
700
- "(trail_id, action_user, action, time) " .
701
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
702
- $results = $wpdb->query( $insert );
703
- }
704
- else
705
- {
706
- $mlw_qmn_isQueryError = true;
707
- $mlw_qmn_error_code = '0010';
708
- }
709
- }
710
-
711
-
712
- /*
713
- Code to load entire page
714
- */
715
-
716
- //Load all quiz data
717
- if ($quiz_id != "")
718
- {
719
- $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$quiz_id;
720
- $mlw_quiz_options = $wpdb->get_results($sql);
721
-
722
- foreach($mlw_quiz_options as $testing) {
723
- $mlw_quiz_options = $testing;
724
- break;
725
- }
726
- }
727
-
728
- //Load and prepare answer arrays
729
- $mlw_qmn_answer_arrays = array();
730
- foreach($mlw_question_data as $mlw_question_info) {
731
- $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
732
- if ( !is_array($mlw_qmn_answer_array_each) )
733
- {
734
- $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
735
- $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
736
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
737
- array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
738
- array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
739
- array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
740
- array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
741
- array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
742
- array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
743
- }
744
- else
745
- {
746
- $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
747
- }
748
- }
749
-
750
-
751
- //Load Certificate Options Variables
752
- $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template);
753
- if (!is_array($mlw_certificate_options)) {
754
- // something went wrong, initialize to empty array
755
- $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
756
- }
757
-
758
-
759
- //Load Email Templates
760
- $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
761
- if (!is_array($mlw_qmn_user_email_array)) {
762
- // something went wrong, initialize to empty array
763
- $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%'));
764
- }
765
-
766
- //Load Landing Pages
767
- $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
768
- if (!is_array($mlw_message_after_array)) {
769
- // something went wrong, initialize to empty array
770
- $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after));
771
- }
772
-
773
- //Load Pagination Text
774
- $mlw_qmn_pagination_text = "";
775
- $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
776
- if (!is_array($mlw_qmn_pagination_text)) {
777
- $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
778
- }
779
- ?>
780
- <!-- css -->
781
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
782
- <!-- jquery scripts -->
783
- <?php
784
- wp_enqueue_script( 'jquery' );
785
- wp_enqueue_script( 'jquery-ui-core' );
786
- wp_enqueue_script( 'jquery-ui-dialog' );
787
- wp_enqueue_script( 'jquery-ui-button' );
788
- wp_enqueue_script( 'jquery-ui-accordion' );
789
- wp_enqueue_script( 'jquery-ui-tooltip' );
790
- wp_enqueue_script( 'jquery-ui-tabs' );
791
- wp_enqueue_script( 'jquery-effects-blind' );
792
- wp_enqueue_script( 'jquery-effects-explode' );
793
- ?>
794
- <script type="text/javascript">
795
- var $j = jQuery.noConflict();
796
- // increase the default animation speed to exaggerate the effect
797
- $j.fx.speeds._default = 1000;
798
- $j(function() {
799
- $j('#dialog').dialog({
800
- autoOpen: false,
801
- show: 'blind',
802
- hide: 'explode',
803
- buttons: {
804
- Ok: function() {
805
- $j(this).dialog('close');
806
- }
807
- }
808
- });
809
-
810
- $j('#opener').click(function() {
811
- $j('#dialog').dialog('open');
812
- return false;
813
- } );
814
- });
815
- $j(function() {
816
- $j('#leaderboard_help_dialog').dialog({
817
- autoOpen: false,
818
- show: 'blind',
819
- width:700,
820
- hide: 'explode',
821
- buttons: {
822
- Ok: function() {
823
- $j(this).dialog('close');
824
- }
825
- }
826
- });
827
-
828
- $j('#leaderboard_tab_help').click(function() {
829
- $j('#leaderboard_help_dialog').dialog('open');
830
- return false;
831
- } );
832
- });
833
-
834
- $j(function() {
835
- $j('#landing_page_help_dialog').dialog({
836
- autoOpen: false,
837
- show: 'blind',
838
- width:700,
839
- hide: 'explode',
840
- buttons: {
841
- Ok: function() {
842
- $j(this).dialog('close');
843
- }
844
- }
845
- });
846
-
847
- $j('#landing_page_help').click(function() {
848
- $j('#landing_page_help_dialog').dialog('open');
849
- return false;
850
- } );
851
- });
852
-
853
- $j(function() {
854
- $j('#email_template_help_dialog').dialog({
855
- autoOpen: false,
856
- show: 'blind',
857
- width:700,
858
- hide: 'explode',
859
- buttons: {
860
- Ok: function() {
861
- $j(this).dialog('close');
862
- }
863
- }
864
- });
865
-
866
- $j('#email_tab_help').click(function() {
867
- $j('#email_template_help_dialog').dialog('open');
868
- return false;
869
- } );
870
- });
871
-
872
- $j(function() {
873
- $j('#mlw_reset_stats_dialog').dialog({
874
- autoOpen: false,
875
- show: 'blind',
876
- width:700,
877
- hide: 'explode',
878
- buttons: {
879
- Ok: function() {
880
- $j(this).dialog('close');
881
- }
882
- }
883
- });
884
-
885
- $j('#mlw_reset_stats_button').click(function() {
886
- $j('#mlw_reset_stats_dialog').dialog('open');
887
- return false;
888
- } );
889
- });
890
- $j(function() {
891
- $j( "#tabs" ).tabs();
892
- });
893
- $j(function() {
894
- //$j( document ).tooltip();
895
- });
896
- $j(function() {
897
- $j("#accordion").accordion({
898
- heightStyle: "content"
899
- });
900
- $j("#email_accordion").accordion({
901
- heightStyle: "content"
902
- });
903
- });
904
- $j(function() {
905
- $j( "#system" ).buttonset();
906
- });
907
- $j(function() {
908
- $j( "#randomness_order" ).buttonset();
909
- });
910
- $j(function() {
911
- $j( "#loggedin_user_contact" ).buttonset();
912
- });
913
- $j(function() {
914
- $j( "#sendUserEmail" ).buttonset();
915
- });
916
- $j(function() {
917
- $j( "#sendAdminEmail" ).buttonset();
918
- });
919
- $j(function() {
920
- $j( "#contact_info_location" ).buttonset();
921
- });
922
- $j(function() {
923
- $j( "#userName" ).buttonset();
924
- });
925
- $j(function() {
926
- $j( "#userComp" ).buttonset();
927
- });
928
- $j(function() {
929
- $j( "#userEmail" ).buttonset();
930
- });
931
- $j(function() {
932
- $j( "#userPhone" ).buttonset();
933
- });
934
- $j(function() {
935
- $j( "#pagination" ).buttonset();
936
- });
937
- $j(function() {
938
- $j( "#commentSection" ).buttonset();
939
- });
940
- $j(function() {
941
- $j( "#social_media" ).buttonset();
942
- $j( "#question_numbering" ).buttonset();
943
- });
944
- $j(function() {
945
- $j( "#comments" ).buttonset();
946
- });
947
- $j(function() {
948
- $j( "#enableCertificates" ).buttonset();
949
- });
950
- $j(function() {
951
- $j("button, #prev_page, #next_page, #new_email_button_top, #new_email_button_bottom, #new_answer_button").button();
952
-
953
- });
954
- $j(function() {
955
- $j('#new_question_dialog').dialog({
956
- autoOpen: false,
957
- show: 'blind',
958
- width:800,
959
- hide: 'explode',
960
- buttons: {
961
- Cancel: function() {
962
- $j(this).dialog('close');
963
- }
964
- }
965
- });
966
-
967
- $j('#new_question_button').click(function() {
968
- $j('#new_question_dialog').dialog('open');
969
- document.getElementById("question_name").focus();
970
- return false;
971
- } );
972
- $j('#new_question_button_two').click(function() {
973
- $j('#new_question_dialog').dialog('open');
974
- document.getElementById("question_name").focus();
975
- return false;
976
- } );
977
- });
978
- function deleteQuestion(id){
979
- $j("#delete_dialog").dialog({
980
- autoOpen: false,
981
- show: 'blind',
982
- hide: 'explode',
983
- buttons: {
984
- Cancel: function() {
985
- $j(this).dialog('close');
986
- }
987
- }
988
- });
989
- $j("#delete_dialog").dialog('open');
990
- var idText = document.getElementById("delete_question_id");
991
- var idHidden = document.getElementById("question_id");
992
- idText.innerHTML = id;
993
- idHidden.value = id;
994
- };
995
- function duplicateQuestion(id){
996
- $j("#duplicate_dialog").dialog({
997
- autoOpen: false,
998
- show: 'blind',
999
- hide: 'explode',
1000
- buttons: {
1001
- Cancel: function() {
1002
- $j(this).dialog('close');
1003
- }
1004
- }
1005
- });
1006
- $j("#duplicate_dialog").dialog('open');
1007
- var idHidden = document.getElementById("duplicate_question_id");
1008
- idHidden.value = id;
1009
- };
1010
- function editQuestion(id){
1011
- $j("#edit_question_dialog_"+id).dialog({
1012
- autoOpen: false,
1013
- show: 'blind',
1014
- width:800,
1015
- hide: 'explode',
1016
- buttons: {
1017
- Cancel: function() {
1018
- $j(this).dialog('close');
1019
- }
1020
- }
1021
- });
1022
- $j("#edit_question_dialog_"+id).dialog('open');
1023
- };
1024
- function delete_landing(id)
1025
- {
1026
- document.getElementById('message_after_'+id).value = "Delete";
1027
- document.mlw_quiz_save_landing_form.submit();
1028
- }
1029
- function delete_email(id)
1030
- {
1031
- document.getElementById('user_email_'+id).value = "Delete";
1032
- document.mlw_quiz_save_email_form.submit();
1033
- }
1034
- function mlw_add_new_question(id)
1035
- {
1036
- var total_answers = parseFloat(document.getElementById("question_"+id+"_answer_total").value);
1037
- total_answers = total_answers + 1;
1038
- document.getElementById("question_"+id+"_answer_total").value = total_answers;
1039
- jQuery("#question_"+id+"_answers").append("<tr valign='top'><td><span style='font-weight:bold;'>Answer "+total_answers+"</span></td><td><input type='text' name='edit_answer_"+total_answers+"' id='edit_answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='edit_answer_"+total_answers+"_points' id='edit_answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='edit_answer_"+total_answers+"_correct' name='edit_answer_"+total_answers+"_correct' value=1 /></td></tr>");
1040
- }
1041
- function mlw_add_answer_to_new_question()
1042
- {
1043
- var total_answers = parseFloat(document.getElementById("new_question_answer_total").value);
1044
- total_answers = total_answers + 1;
1045
- document.getElementById("new_question_answer_total").value = total_answers;
1046
- jQuery("#new_question_answers").append("<tr valign='top'><td><span style='font-weight:bold;'>Answer "+total_answers+"</span></td><td><input type='text' name='answer_"+total_answers+"' id='answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='answer_"+total_answers+"_points' id='answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='answer_"+total_answers+"_correct' name='answer_"+total_answers+"_correct' value=1 /></td></tr>");
1047
- }
1048
- function mlw_qmn_theme(theme)
1049
- {
1050
- document.getElementById('save_quiz_theme').value = theme;
1051
- jQuery("div.mlw_qmn_themeBlockActive").toggleClass("mlw_qmn_themeBlockActive");
1052
- jQuery("#mlw_qmn_theme_block_"+theme).toggleClass("mlw_qmn_themeBlockActive");
1053
-
1054
- }
1055
- </script>
1056
- <style>
1057
- .linkOptions
1058
- {
1059
- color: green !important;
1060
- font-size: 14px !important;
1061
- }
1062
- .linkOptions:hover
1063
- {
1064
- background-color: black;
1065
- }
1066
- </style>
1067
- <div class="wrap">
1068
- <div class='mlw_quiz_options'>
1069
- <h2>Quiz Settings For <?php echo $mlw_quiz_options->quiz_name; ?><a id="opener" href="">(?)</a></h2>
1070
- <?php if ($hasUpdatedLeaderboardOptions)
1071
- {
1072
- ?>
1073
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1074
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1075
- <strong>Success!</strong> Your leaderboard options for this quiz have been saved.</p>
1076
- </div>
1077
- <?php
1078
- }
1079
- if ($mlw_qmn_isQueryError)
1080
- {
1081
- ?>
1082
- <div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1083
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1084
- <strong>Uh-Oh!</strong> There has been an error in this action! Please share this with the developer: Error Code <?php echo $mlw_qmn_error_code; ?></p>
1085
- </div>
1086
- <?php
1087
- }
1088
- if ($hasCreatedQuestion)
1089
- {
1090
- ?>
1091
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1092
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1093
- <strong>Success!</strong> Your new question has been created successfully.</p>
1094
- </div>
1095
- <?php
1096
- }
1097
- if ($hasUpdatedTemplates)
1098
- {
1099
- ?>
1100
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1101
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1102
- <strong>Success!</strong> Your templates for this quiz have been saved.</p>
1103
- </div>
1104
- <?php
1105
- }
1106
- if ($hasUpdatedOptions)
1107
- {
1108
- ?>
1109
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1110
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1111
- <strong>Success!</strong> Your options for this quiz have been saved.</p>
1112
- </div>
1113
- <?php
1114
- }
1115
- if ($hasDeletedQuestion)
1116
- {
1117
- ?>
1118
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1119
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1120
- <strong>Success!</strong> The question has been deleted from this quiz.</p>
1121
- </div>
1122
- <?php
1123
- }
1124
- if ($hasDuplicatedQuestion)
1125
- {
1126
- ?>
1127
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1128
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1129
- <strong>Success!</strong> The question has been duplicated.</p>
1130
- </div>
1131
- <?php
1132
- }
1133
- if ($hasUpdatedQuestion)
1134
- {
1135
- ?>
1136
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1137
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1138
- <strong>Success!</strong> The question has been updated.</p>
1139
- </div>
1140
- <?php
1141
- }
1142
- if ($mlw_hasResetQuizStats)
1143
- {
1144
- ?>
1145
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1146
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1147
- <strong>Success!</strong> The stats for this quiz has been reset!</p>
1148
- </div>
1149
- <?php
1150
- }
1151
- if ($mlw_hasAddedLanding)
1152
- {
1153
- ?>
1154
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1155
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1156
- <strong>Success!</strong> A new results page has been added successfully!</p>
1157
- </div>
1158
- <?php
1159
- }
1160
- if ($mlw_hasSavedLanding)
1161
- {
1162
- ?>
1163
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1164
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1165
- <strong>Success!</strong> The results pages have been saved successfully!</p>
1166
- </div>
1167
- <?php
1168
- }
1169
- if ($mlw_hasAddedEmail)
1170
- {
1171
- ?>
1172
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1173
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1174
- <strong>Success!</strong> A new email has been added successfully!</p>
1175
- </div>
1176
- <?php
1177
- }
1178
- if ($mlw_hasSavedEmail)
1179
- {
1180
- ?>
1181
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1182
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1183
- <strong>Success!</strong> The email templates have been saved successfully!</p>
1184
- </div>
1185
- <?php
1186
- }
1187
- if ($mlw_UpdatedCertificate)
1188
- {
1189
- ?>
1190
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1191
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1192
- <strong>Success!</strong> The certificate options have been saved successfully!</p>
1193
- </div>
1194
- <?php
1195
- }
1196
- if ($mlw_hasSavedStyle)
1197
- {
1198
- ?>
1199
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
1200
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
1201
- <strong>Success!</strong> The styles have been saved successfully!</p>
1202
- </div>
1203
- <?php
1204
- }
1205
  ?>
1206
- <div id="tabs">
1207
- <ul>
1208
- <li><a href="#tabs-1">Quiz Questions</a></li>
1209
- <li><a href="#tabs-2">Quiz Text</a></li>
1210
- <li><a href="#tabs-3">Quiz Options</a></li>
1211
- <li><a href="#tabs-4">Quiz Leaderboard</a></li>
1212
- <li><a href="#tabs-5">Quiz Certificate (Beta)</a></li>
1213
- <li><a href="#tabs-9">Quiz Emails</a></li>
1214
- <li><a href="#tabs-6">Quiz Results Page</a></li>
1215
- <li><a href="#tabs-7">Quiz Styling</a></li>
1216
- <li><a href="#tabs-8">Quiz Tools/Add-Ons</a></li>
1217
- </ul>
1218
- <div id="tabs-1">
1219
- <button id="new_question_button_two">Add Question</button>
1220
- <br />
1221
- <?php
1222
- $question_list = "";
1223
- $display = "";
1224
- $alternate = "";
1225
- foreach($mlw_question_data as $mlw_question_info) {
1226
- $mlw_question_settings = @unserialize($mlw_question_info->question_settings);
1227
- if (!is_array($mlw_question_settings)) {
1228
- $mlw_question_settings = array();
1229
- $mlw_question_settings['required'] = 1;
1230
- }
1231
- $mlw_question_type_text = "";
1232
- switch ($mlw_question_info->question_type) {
1233
- case 0:
1234
- $mlw_question_type_text = "Multiple Choice";
1235
- break;
1236
- case 1:
1237
- $mlw_question_type_text = "Horizontal Multiple Choice";
1238
- break;
1239
- case 2:
1240
- $mlw_question_type_text = "Drop Down";
1241
- break;
1242
- case 3:
1243
- $mlw_question_type_text = "Small Open Answer";
1244
- break;
1245
- case 4:
1246
- $mlw_question_type_text = "Multiple Response";
1247
- break;
1248
- case 5:
1249
- $mlw_question_type_text = "Large Open Answer";
1250
- break;
1251
- case 6:
1252
- $mlw_question_type_text = "Text Block";
1253
- break;
1254
- case 7:
1255
- $mlw_question_type_text = "Number";
1256
- break;
1257
- case 8:
1258
- $mlw_question_type_text = "Accept";
1259
- break;
1260
- case 9:
1261
- $mlw_question_type_text = "Captcha";
1262
- break;
1263
- case 10:
1264
- $mlw_question_type_text = "Horizontal Multiple Response";
1265
- break;
1266
- default:
1267
- $mlw_question_type_text = "Error Code ";
1268
- }
1269
- if($alternate) $alternate = "";
1270
- else $alternate = " class=\"alternate\"";
1271
- $question_list .= "<tr{$alternate}>";
1272
- $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_order . "</span></td>";
1273
- $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_type_text . "</span></td>";
1274
- $question_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_question_info->question_name ."</span><div><a class='linkOptions' onclick=\"editQuestion('".$mlw_question_info->question_id."')\" href='#'>Edit</a> | <a class='linkOptions' onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a> | <a class='linkOptions' onclick=\"duplicateQuestion('".$mlw_question_info->question_id."')\" href='#'>Duplicate</a></span></div></td>";
1275
- $question_list .= "</tr>";
1276
-
1277
-
1278
- $mlw_question_answer_array = $mlw_qmn_answer_arrays[$mlw_question_info->question_id];
1279
- ?>
1280
- <div id="edit_question_dialog_<?php echo $mlw_question_info->question_id; ?>" title="Edit Question" style="display:none;">
1281
- <?php
1282
- echo "<form action='' method='post'>";
1283
- echo "<input type='hidden' name='edit_question' value='confirmation' />";
1284
- echo "<input type='hidden' id='edit_question_id' name='edit_question_id' value='".$mlw_question_info->question_id."' />";
1285
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
1286
- ?>
1287
- <table class="wide" style="text-align: left; white-space: nowrap;" id="question_<?php echo $mlw_question_info->question_id; ?>_answers" name="question_<?php echo $mlw_question_info->question_id; ?>_answers">
1288
- <tr>
1289
- <td><span style='font-weight:bold;'>Question</span></td>
1290
- <td colspan="3">
1291
- <textarea name="edit_question_name" id="edit_question_name" style="width: 500px; height: 150px;"><?php echo htmlspecialchars_decode($mlw_question_info->question_name, ENT_QUOTES); ?></textarea>
1292
- </td>
1293
- </tr>
1294
- <tr valign="top">
1295
- <td>&nbsp;</td>
1296
- <td>&nbsp;</td>
1297
- </tr>
1298
- <tr valign="top">
1299
- <td>&nbsp;</td>
1300
- <td><span style='font-weight:bold;'>Answers</span></td>
1301
- <td><span style='font-weight:bold;'>Points Worth</span></td>
1302
- <td><span style='font-weight:bold;'>Correct Answer</span></td>
1303
- </tr>
1304
- <?php
1305
- $mlw_answer_total = 0;
1306
- foreach($mlw_question_answer_array as $mlw_question_answer_each)
1307
- {
1308
- $mlw_answer_total = $mlw_answer_total + 1;
1309
- ?>
1310
- <tr valign="top">
1311
- <td><span style='font-weight:bold;'>Answer <?php echo $mlw_answer_total; ?></span></td>
1312
- <td>
1313
- <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>" id="edit_answer_<?php echo $mlw_answer_total; ?>" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_answer_each[0], ENT_QUOTES)); ?>" style="border-color:#000000;
1314
- color:#3300CC;
1315
- cursor:hand;
1316
- width: 250px;"/>
1317
- </td>
1318
- <td>
1319
- <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>_points" id="edit_answer_<?php echo $mlw_answer_total; ?>_points" value="<?php echo $mlw_question_answer_each[1]; ?>" style="border-color:#000000;
1320
- color:#3300CC;
1321
- cursor:hand;"/>
1322
- </td>
1323
- <td><input type="checkbox" id="edit_answer_<?php echo $mlw_answer_total; ?>_correct" name="edit_answer_<?php echo $mlw_answer_total; ?>_correct" <?php if ($mlw_question_answer_each[2] == 1) { echo 'checked="checked"'; } ?> value=1 /></td>
1324
- </tr>
1325
- <?php
1326
- }
1327
- ?>
1328
- </table>
1329
- <a href="#" id="new_answer_button" onclick="mlw_add_new_question(<?php echo $mlw_question_info->question_id; ?>);">Add New Answer!</a>
1330
- <br />
1331
- <br />
1332
- <table class="wide" style="text-align: left; white-space: nowrap;">
1333
- <tr>
1334
- <td><span style='font-weight:bold;'>Correct Answer Info:</span></td>
1335
- <td colspan="3"><input type="text" name="edit_correct_answer_info" id="edit_correct_answer_info" style="border-color:#000000;
1336
- color:#3300CC;
1337
- cursor:hand;
1338
- width:550px;" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_info->question_answer_info, ENT_QUOTES)); ?>"/></td>
1339
- </tr>
1340
- <tr valign="top">
1341
- <td><span style='font-weight:bold;'>Hint</span></td>
1342
- <td colspan="3">
1343
- <input type="text" name="edit_hint" id="edit_hint" style="border-color:#000000;
1344
- color:#3300CC;
1345
- cursor:hand;
1346
- width:550px;" value="<?php echo htmlspecialchars_decode($mlw_question_info->hints, ENT_QUOTES); ?>"/>
1347
- </td>
1348
- </tr>
1349
- <tr><td>&nbsp;</td></tr>
1350
- <tr><td>&nbsp;</td></tr>
1351
- <tr valign="top">
1352
- <td><span style='font-weight:bold;'>Question Type</span></td>
1353
- <td colspan="3">
1354
- <select name="edit_question_type">
1355
- <option value="0" <?php if ($mlw_question_info->question_type == 0) { echo 'selected="selected"'; } ?>>Normal Multiple Choice (Vertical Radio)</option>
1356
- <option value="1" <?php if ($mlw_question_info->question_type == 1) { echo 'selected="selected"'; } ?>>Horizontal Multiple Choice (Horizontal Radio)</option>
1357
- <option value="2" <?php if ($mlw_question_info->question_type == 2) { echo 'selected="selected"'; } ?>>Drop Down (Select)</option>
1358
- <option value="3" <?php if ($mlw_question_info->question_type == 3) { echo 'selected="selected"'; } ?>>Open Answer (Text Input)</option>
1359
- <option value="5" <?php if ($mlw_question_info->question_type == 5) { echo 'selected="selected"'; } ?>>Open Answer (Large Text Input)</option>
1360
- <option value="4" <?php if ($mlw_question_info->question_type == 4) { echo 'selected="selected"'; } ?>>Multiple Response (Checkbox)</option>
1361
- <option value="10" <?php if ($mlw_question_info->question_type == 10) { echo 'selected="selected"'; } ?>>Horizontal Multiple Response (Checkbox)</option>
1362
- <option value="6" <?php if ($mlw_question_info->question_type == 6) { echo 'selected="selected"'; } ?>>Text Block</option>
1363
- <option value="7" <?php if ($mlw_question_info->question_type == 7) { echo 'selected="selected"'; } ?>>Number</option>
1364
- <option value="8" <?php if ($mlw_question_info->question_type == 8) { echo 'selected="selected"'; } ?>>Accept</option>
1365
- <option value="9" <?php if ($mlw_question_info->question_type == 9) { echo 'selected="selected"'; } ?>>Captcha</option>
1366
- </select>
1367
- </div></td>
1368
- </tr>
1369
- <tr valign="top">
1370
- <td><span style='font-weight:bold;'>Comment Field</span></td>
1371
- <td colspan="3">
1372
- <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1" name="edit_comments" value=0 <?php if ($mlw_question_info->comments == 0) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1">Small Text Field</label>
1373
- <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3" name="edit_comments" value=2 <?php if ($mlw_question_info->comments == 2) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3">Large Text Field</label>
1374
- <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2" name="edit_comments" value=1 <?php if ($mlw_question_info->comments == 1) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2">None</label>
1375
- </td>
1376
- </tr>
1377
- <tr valign="top">
1378
- <td><span style='font-weight:bold;'>Question Order</span></td>
1379
- <td>
1380
- <input type="number" step="1" min="1" name="edit_question_order" value="<?php echo $mlw_question_info->question_order; ?>" id="edit_question_order" style="border-color:#000000;
1381
- color:#3300CC;
1382
- cursor:hand;"/>
1383
- </td>
1384
- </tr>
1385
- <tr valign="top">
1386
- <td><span style='font-weight:bold;'>Required?</span></td>
1387
- <td colspan="3">
1388
- <select name="edit_required">
1389
- <option value="0" <?php if ($mlw_question_settings['required'] == 0) { echo 'selected="selected"'; } ?>>Yes</option>
1390
- <option value="1" <?php if ($mlw_question_settings['required'] == 1) { echo 'selected="selected"'; } ?>>No</option>
1391
- </select>
1392
- </div></td>
1393
- </tr>
1394
- </table>
1395
- <p> *Required currently only works on open answer, number, and captcha question types</p>
1396
- <input type="hidden" name="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" id="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" value="<?php echo $mlw_answer_total; ?>" />
1397
- <p class='submit'><input type='submit' class='button-primary' value='Edit Question' /></p>
1398
- </form>
1399
- </div>
1400
-
1401
- <?php
1402
- }
1403
 
1404
- if( $mlw_qmn_question_page > 0 )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1405
  {
1406
- $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
1407
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
1408
- if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
1409
- {
1410
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
1411
- }
1412
  }
1413
- else if( $mlw_qmn_question_page == 0 )
1414
  {
1415
- if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
1416
- {
1417
- $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
1418
- }
1419
  }
1420
- else if( $mlw_qmn_question_left < $mlw_qmn_table_limit )
 
 
1421
  {
1422
- $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
1423
- $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
1424
  }
1425
-
1426
- $display .= "<table class=\"widefat\">";
1427
- $display .= "<thead><tr>
1428
- <th>Question Order</th>
1429
- <th>Question Type</th>
1430
- <th>Question</th>
1431
- </tr></thead>";
1432
- $display .= "<tbody id=\"the-list\">{$question_list}</tbody>";
1433
- $display .= "<tfoot><tr>
1434
- <th>Question Order</th>
1435
- <th>Question Type</th>
1436
- <th>Question</th>
1437
- </tr></tfoot>";
1438
- $display .= "</table>";
1439
- echo $display;
1440
- ?>
1441
- <button id="new_question_button">Add Question</button>
1442
- <div id="new_question_dialog" title="Create New Question" style="display:none;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1443
 
 
 
 
1444
  <?php
1445
  echo "<form action='' method='post'>";
1446
- echo "<input type='hidden' name='create_question' value='confirmation' />";
 
1447
  echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
1448
- ?>
1449
- <table class="wide" style="text-align: left; white-space: nowrap;" id="new_question_answers" name="new_question_answers">
1450
  <tr>
1451
  <td><span style='font-weight:bold;'>Question</span></td>
1452
  <td colspan="3">
1453
- <textarea name="question_name" id="question_name" style="width: 500px; height: 150px;"></textarea>
1454
  </td>
1455
  </tr>
1456
  <tr valign="top">
@@ -1465,42 +627,47 @@ function mlw_generate_quiz_options()
1465
  </tr>
1466
  <?php
1467
  $mlw_answer_total = 0;
1468
- $mlw_answer_total = $mlw_answer_total + 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1469
  ?>
1470
- <tr valign="top">
1471
- <td><span style='font-weight:bold;'>Answer <?php echo $mlw_answer_total; ?></span></td>
1472
- <td>
1473
- <input type="text" name="answer_<?php echo $mlw_answer_total; ?>" id="answer_<?php echo $mlw_answer_total; ?>" value="" style="border-color:#000000;
1474
- color:#3300CC;
1475
- cursor:hand;
1476
- width: 250px;"/>
1477
- </td>
1478
- <td>
1479
- <input type="text" name="answer_<?php echo $mlw_answer_total; ?>_points" id="answer_<?php echo $mlw_answer_total; ?>_points" value=0 style="border-color:#000000;
1480
- color:#3300CC;
1481
- cursor:hand;"/>
1482
- </td>
1483
- <td><input type="checkbox" id="answer_<?php echo $mlw_answer_total; ?>_correct" name="answer_<?php echo $mlw_answer_total; ?>_correct" checked="checked" value=1 /></td>
1484
- </tr>
1485
  </table>
1486
- <a href="#" id="new_answer_button" onclick="mlw_add_answer_to_new_question();">Add New Answer!</a>
1487
  <br />
1488
  <br />
1489
  <table class="wide" style="text-align: left; white-space: nowrap;">
1490
  <tr>
1491
- <td><span style='font-weight:bold;'>Correct Answer Info</span></td>
1492
- <td colspan="3"><input type="text" name="correct_answer_info" value="" id="correct_answer_info" style="border-color:#000000;
1493
  color:#3300CC;
1494
  cursor:hand;
1495
- width:550px;"/></td>
1496
  </tr>
1497
  <tr valign="top">
1498
  <td><span style='font-weight:bold;'>Hint</span></td>
1499
  <td colspan="3">
1500
- <input type="text" name="hint" value="" id="hint" style="border-color:#000000;
1501
  color:#3300CC;
1502
  cursor:hand;
1503
- width:550px;"/>
1504
  </td>
1505
  </tr>
1506
  <tr><td>&nbsp;</td></tr>
@@ -1508,33 +675,33 @@ function mlw_generate_quiz_options()
1508
  <tr valign="top">
1509
  <td><span style='font-weight:bold;'>Question Type</span></td>
1510
  <td colspan="3">
1511
- <select name="question_type">
1512
- <option value="0" selected="selected">Normal Multiple Choice (Vertical Radio)</option>
1513
- <option value="1">Horizontal Multiple Choice (Horizontal Radio)</option>
1514
- <option value="2">Drop Down (Select)</option>
1515
- <option value="3">Open Answer (Text Input)</option>
1516
- <option value="5">Open Answer (Large Text Input)</option>
1517
- <option value="4">Multiple Response (Checkbox)</option>
1518
- <option value="10">Horizontal Multiple Response (Checkbox)</option>
1519
- <option value="6">Text Block</option>
1520
- <option value="7">Number</option>
1521
- <option value="8">Accept</option>
1522
- <option value="9">Captcha</option>
1523
  </select>
1524
  </div></td>
1525
  </tr>
1526
  <tr valign="top">
1527
  <td><span style='font-weight:bold;'>Comment Field</span></td>
1528
- <td colspan="3"><div id="comments">
1529
- <input type="radio" id="commentsRadio1" name="comments" value=0 /><label for="commentsRadio1">Small Text Field</label>
1530
- <input type="radio" id="commentsRadio3" name="comments" value=2 /><label for="commentsRadio3">Large Text Field</label>
1531
- <input type="radio" id="commentsRadio2" name="comments" checked="checked" value=1 /><label for="commentsRadio2">None</label>
1532
- </div></td>
1533
  </tr>
1534
  <tr valign="top">
1535
  <td><span style='font-weight:bold;'>Question Order</span></td>
1536
  <td>
1537
- <input type="number" step="1" min="1" name="new_question_order" value="1" id="new_question_order" style="border-color:#000000;
1538
  color:#3300CC;
1539
  cursor:hand;"/>
1540
  </td>
@@ -1542,26 +709,265 @@ function mlw_generate_quiz_options()
1542
  <tr valign="top">
1543
  <td><span style='font-weight:bold;'>Required?</span></td>
1544
  <td colspan="3">
1545
- <select name="required">
1546
- <option value="0" selected="selected">Yes</option>
1547
- <option value="1">No</option>
1548
  </select>
1549
  </div></td>
1550
  </tr>
1551
  </table>
1552
  <p> *Required currently only works on open answer, number, and captcha question types</p>
1553
- <input type="hidden" name="new_question_answer_total" id="new_question_answer_total" value="<?php echo $mlw_answer_total; ?>" />
1554
- <?php
1555
- echo "<p class='submit'><input type='submit' class='button-primary' value='Create Question' /></p>";
1556
- echo "</form>";
1557
- ?>
1558
- </div>
1559
-
1560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1561
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1562
 
1563
- </div>
1564
- <div id="tabs-2">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1565
  <h3 style="text-align: center;">Template Variables</h3>
1566
  <table class="form-table">
1567
  <tr>
@@ -1741,7 +1147,71 @@ function mlw_generate_quiz_options()
1741
  <button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button>
1742
  <?php echo "</form>"; ?>
1743
  </div>
1744
- <div id="tabs-3">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1745
  <button id="save_options_button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button>
1746
  <?php
1747
  echo "<form action='' method='post' name='quiz_options_form'>";
@@ -1878,7 +1348,48 @@ function mlw_generate_quiz_options()
1878
  <button id="save_options_button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button>
1879
  <?php echo "</form>"; ?>
1880
  </div>
1881
- <div id="tabs-4">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1882
  <h3>Template Variables</h3>
1883
  <table class="form-table">
1884
  <tr>
@@ -1910,7 +1421,7 @@ function mlw_generate_quiz_options()
1910
  <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
1911
  </tr>
1912
  </table>
1913
- <button id="save_template_button" onclick="javascript: document.quiz_leaderboard_options_form.submit();">Save Leaderboard Options</button><button id="leaderboard_tab_help">Help</button>
1914
  <?php
1915
  echo "<form action='' method='post' name='quiz_leaderboard_options_form'>";
1916
  echo "<input type='hidden' name='save_leaderboard_options' value='confirmation' />";
@@ -1941,7 +1452,66 @@ function mlw_generate_quiz_options()
1941
  <button id="save_template_button" onclick="javascript: document.quiz_leaderboard_options_form.submit();">Save Leaderboard Options</button>
1942
  </form>
1943
  </div>
1944
- <div id="tabs-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1945
  <h3>Quiz Certificate (Beta)</h3>
1946
  <p>Enter in your text here to fill in the certificate for this quiz. Be sure to enter in the link variable into the templates on the Quiz Text tab so the user can access the certificate.</p>
1947
  <p>These fields cannot contain HTML.</p>
@@ -2004,7 +1574,129 @@ function mlw_generate_quiz_options()
2004
  <button id="save_certificate_button" onclick="javascript: document.quiz_certificate_options_form.submit();">Save Certificate Options</button>
2005
  </form>
2006
  </div>
2007
- <div id="tabs-9">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2008
  <h3>Template Variables</h3>
2009
  <table class="form-table">
2010
  <tr>
@@ -2046,7 +1738,6 @@ function mlw_generate_quiz_options()
2046
  <input type='hidden' name='mlw_add_email_quiz_id' value='<?php echo $quiz_id; ?>' />
2047
  </form>
2048
  <button id="save_email_button" onclick="javascript: document.mlw_quiz_save_email_form.submit();">Save Email Templates</button>
2049
- <button id="email_tab_help">Help</button>
2050
  <form method="post" action="" name="mlw_quiz_save_email_form">
2051
  <div id="email_accordion">
2052
  <h3><a href="#">Email Sent To User</a></h3>
@@ -2166,7 +1857,119 @@ function mlw_generate_quiz_options()
2166
  </form>
2167
  <button id="save_email_button" onclick="javascript: document.mlw_quiz_save_email_form.submit();">Save Email Templates</button>
2168
  </div>
2169
- <div id="tabs-6">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2170
  <h3>Template Variables</h3>
2171
  <table class="form-table">
2172
  <tr>
@@ -2209,7 +2012,6 @@ function mlw_generate_quiz_options()
2209
  </table>
2210
  <button id="save_landing_button" onclick="javascript: document.mlw_quiz_save_landing_form.submit();">Save Results Pages</button>
2211
  <button id="new_landing_button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();">Add New Results Page</button>
2212
- <button id="landing_page_help">Help</button>
2213
  <form method="post" action="" name="mlw_quiz_save_landing_form" style=" display:inline!important;">
2214
  <table class="widefat">
2215
  <thead>
@@ -2287,7 +2089,58 @@ function mlw_generate_quiz_options()
2287
  <button id="new_landing_button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();">Add New Results Page</button>
2288
  </form>
2289
  </div>
2290
- <div id="tabs-7">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2291
  <?php
2292
  echo "<form action='' method='post' name='quiz_style_form'>";
2293
  echo "<input type='hidden' name='save_style_options' value='confirmation' />";
@@ -2391,7 +2244,67 @@ function mlw_generate_quiz_options()
2391
  <button id="save_styles_button" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>
2392
  </form>
2393
  </div>
2394
- <div id="tabs-8">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2395
  <p>Use this button to reset all the stats collected for this quiz (Quiz Views and Times Quiz Has Been Taken). </p>
2396
  <button id="mlw_reset_stats_button">Reset Quiz Views And Taken Stats</button>
2397
  <?php do_action('mlw_qmn_quiz_tools'); ?>
@@ -2406,91 +2319,17 @@ function mlw_generate_quiz_options()
2406
  ?>
2407
  </div>
2408
  </div>
2409
- </div>
2410
-
2411
- <?php echo mlw_qmn_show_adverts(); ?>
2412
-
2413
 
2414
- <!--Dialogs-->
2415
- <div id="delete_dialog" title="Delete Question?" style="display:none;">
2416
- <h3><b>Are you sure you want to delete Question <span id="delete_question_id"></span>?</b></h3>
2417
- <?php
2418
- echo "<form action='' method='post'>";
2419
- echo "<input type='hidden' name='delete_question' value='confirmation' />";
2420
- echo "<input type='hidden' id='question_id' name='question_id' value='' />";
2421
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
2422
- echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Question' /></p>";
2423
- echo "</form>";
2424
- ?>
2425
- </div>
2426
-
2427
- <div id="duplicate_dialog" title="Duplicate Question?" style="display:none;">
2428
- <h3><b>Are you sure you want to duplicate this Question?</b></h3>
2429
  <?php
2430
- echo "<form action='' method='post'>";
2431
- echo "<input type='hidden' name='duplicate_question' value='confirmation' />";
2432
- echo "<input type='hidden' id='duplicate_question_id' name='duplicate_question_id' value='' />";
2433
- echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
2434
- echo "<p class='submit'><input type='submit' class='button-primary' value='Duplicate Question' /></p>";
2435
- echo "</form>";
2436
  ?>
2437
  </div>
2438
-
2439
- <div id="dialog" title="Help" style="display:none;">
2440
- <h3><b>Help</b></h3>
2441
- <p>Having trouble using this page? Be sure to check out our useful <a href='http://mylocalwebstop.com/plugin-documentation/' target="_blank" style="color:blue;">Plugin Documentation</a>!</p>
2442
- </div>
2443
-
2444
- <div id="leaderboard_help_dialog" title="Help" style="display:none;">
2445
- <p>This tab is used to edit the options for the leaderboard for this quiz.</p>
2446
- <p>Currently, you can edit the template for the leaderboard.</p>
2447
- <p>The template is able to have variables inside the text. When the quiz is run, these variables will change to their values.</p>
2448
- </div>
2449
-
2450
- <div id="landing_page_help_dialog" title="Help" style="display: none;">
2451
- <h3><b>Help</b></h3>
2452
- <p>This page allows you to add, edit, and delete results pages for your quiz!</p>
2453
- <p>You can have unlimited different results pages to show the user after he or she takes the quiz. For example, you can have a page shown if they pass, and then show the default if they fail.</p>
2454
- <p>If you only need the one results page, leave just the default and edit it and then click the Save button.</p>
2455
- <p>To add a new results page, click Add New Results Page. A new section will appear with the new page.</p>
2456
- <p>For your extra pages, you must designate what score the user must be above and what score the user must be below to see the page. If the user does not fall into any, the default page will be shown.</p>
2457
- <p>Be sure to save after any changes are made!</p>
2458
- </div>
2459
-
2460
- <div id="email_template_help_dialog" title="Help" style="display: none;">
2461
- <h3><b>Help</b></h3>
2462
- <p>This page allows you to add, edit, and delete email templates for your quiz!</p>
2463
- <p>You can have unlimited different emails to send the user after he or she takes the quiz. For example, you can have an email sent if they pass, and then send the default if they fail.</p>
2464
- <p>If you only need the one email, leave just the default and edit it and then click the Save button.</p>
2465
- <p>To add a new email, click Add New Email. A new section will appear with the email.</p>
2466
- <p>For your extra emails, you must designate what score the user must be above and what score the user must be below to receive the email. If the user does not fall into any, the default email will be sent.</p>
2467
- <p>Be sure to save after any changes are made!</p>
2468
- </div>
2469
-
2470
- </div>
2471
- </div>
2472
  <?php
2473
- }
2474
- else
2475
- {
2476
- ?>
2477
- <!-- css -->
2478
- <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
2479
- <!-- jquery scripts -->
2480
- <?php
2481
- wp_enqueue_script( 'jquery' );
2482
- wp_enqueue_script( 'jquery-ui-core' );
2483
- ?>
2484
- <div class="wrap">
2485
- <div class='mlw_quiz_options'>
2486
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
2487
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
2488
- <strong>Hey!</strong> Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.</p
2489
- </div>
2490
- </div>
2491
- <?php
2492
- }
2493
- ?>
2494
- <?php
2495
  }
2496
  ?>
8
 
9
  function mlw_generate_quiz_options()
10
  {
 
11
  global $wpdb;
12
+ global $mlwQmnAlertManager;
13
+ $quiz_id = $_GET["quiz_id"];
14
+ if (isset($_GET["quiz_id"]))
15
+ {
16
+ $table_name = $wpdb->prefix . "mlw_quizzes";
17
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
18
+ }
19
+ ?>
20
+ <!-- css -->
21
+ <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" />
22
+ <!-- jquery scripts -->
23
+ <?php
24
+ wp_enqueue_script( 'jquery' );
25
+ wp_enqueue_script( 'jquery-ui-core' );
26
+ wp_enqueue_script( 'jquery-ui-dialog' );
27
+ wp_enqueue_script( 'jquery-ui-button' );
28
+ wp_enqueue_script( 'jquery-ui-accordion' );
29
+ wp_enqueue_script( 'jquery-ui-tooltip' );
30
+ wp_enqueue_script( 'jquery-ui-tabs' );
31
+ wp_enqueue_script( 'jquery-effects-blind' );
32
+ wp_enqueue_script( 'jquery-effects-explode' );
33
+ ?>
34
+ <script type="text/javascript">
35
+ var $j = jQuery.noConflict();
36
+ // increase the default animation speed to exaggerate the effect
37
+ $j.fx.speeds._default = 1000;
38
+ $j(function() {
39
+ $j("button").button();
40
+ $j( "#tabs" ).tabs();
41
+ });
42
+ </script>
43
+ <style>
44
+ .mlw_tab_content
45
+ {
46
+ padding: 20px 20px 20px 20px;
47
+ margin: 20px 20px 20px 20px;
48
+ }
49
+ </style>
50
+ <div class="wrap">
51
+ <div class='mlw_quiz_options'>
52
+ <h2>Quiz Settings For <?php echo $mlw_quiz_options->quiz_name; ?></h2>
53
+ <?php
54
+ ob_start();
55
  if ($quiz_id != "")
56
  {
57
+ ?>
58
+ <div id="tabs">
59
+ <ul>
60
+ <?php do_action('mlw_qmn_options_tab'); ?>
61
+ </ul>
62
+ <?php do_action('mlw_qmn_options_tab_content'); ?>
63
+
64
+ </div>
65
+ <?php
66
+ }
67
+ else
68
+ {
69
+ ?>
70
+ <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
71
+ <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
72
+ <strong>Hey!</strong> Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.</p
73
+ </div>
74
+ <?php
75
+ }
76
+ $mlw_output = ob_get_contents();
77
+ ob_end_clean();
78
+ $mlwQmnAlertManager->showAlerts();
79
+ echo $mlw_output;
80
+ ?>
81
+
82
+ <?php echo mlw_qmn_show_adverts(); ?>
83
+ </div>
84
+ </div>
85
+ <?php
86
+ }
87
+
88
+ add_action('mlw_qmn_options_tab', 'mlw_options_questions_tab');
89
+ add_action('mlw_qmn_options_tab', 'mlw_options_text_tab');
90
+ add_action('mlw_qmn_options_tab', 'mlw_options_option_tab');
91
+ add_action('mlw_qmn_options_tab', 'mlw_options_leaderboard_tab');
92
+ add_action('mlw_qmn_options_tab', 'mlw_options_certificate_tab');
93
+ add_action('mlw_qmn_options_tab', 'mlw_options_emails_tab');
94
+ add_action('mlw_qmn_options_tab', 'mlw_options_results_tab');
95
+ add_action('mlw_qmn_options_tab', 'mlw_options_styling_tab');
96
+ add_action('mlw_qmn_options_tab', 'mlw_options_tools_tab');
97
+ add_action('mlw_qmn_options_tab', 'mlw_options_preview_tab');
98
+
99
+ function mlw_options_questions_tab()
100
+ {
101
+ echo "<li><a href=\"#tabs-1\">Questions</a></li>";
102
+ }
103
+ function mlw_options_text_tab()
104
+ {
105
+ echo "<li><a href=\"#tabs-2\">Text</a></li>";
106
+ }
107
+ function mlw_options_option_tab()
108
+ {
109
+ echo "<li><a href=\"#tabs-3\">Options</a></li>";
110
+ }
111
+ function mlw_options_leaderboard_tab()
112
+ {
113
+ echo "<li><a href=\"#tabs-4\">Leaderboard</a></li>";
114
+ }
115
+ function mlw_options_certificate_tab()
116
+ {
117
+ echo "<li><a href=\"#tabs-5\">Certificate (Beta)</a></li>";
118
+ }
119
+ function mlw_options_emails_tab()
120
+ {
121
+ echo "<li><a href=\"#tabs-9\">Emails</a></li>";
122
+ }
123
+ function mlw_options_results_tab()
124
+ {
125
+ echo "<li><a href=\"#tabs-6\">Results Page</a></li>";
126
+ }
127
+ function mlw_options_styling_tab()
128
+ {
129
+ echo "<li><a href=\"#tabs-7\">Styling</a></li>";
130
+ }
131
+ function mlw_options_tools_tab()
132
+ {
133
+ echo "<li><a href=\"#tabs-8\">Tools/Add-Ons</a></li>";
134
+ }
135
+ function mlw_options_preview_tab()
136
+ {
137
+ echo "<li><a href=\"#tabs-preview\">Preview (Beta)</a></li>";
138
+ }
139
 
140
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_questions_tab_content');
141
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_text_tab_content');
142
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_option_tab_content');
143
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_leaderboard_tab_content');
144
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_certificate_tab_content');
145
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_emails_tab_content');
146
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_results_tab_content');
147
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_styling_tab_content');
148
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_tools_tab_content');
149
+ add_action('mlw_qmn_options_tab_content', 'mlw_options_preview_tab_content');
150
+
151
+ function mlw_options_questions_tab_content()
152
+ {
153
+ global $wpdb;
154
+ global $mlwQmnAlertManager;
155
+ $quiz_id = $_GET["quiz_id"];
156
+
157
  //Edit question
158
  if ( isset($_POST["edit_question"]) && $_POST["edit_question"] == "confirmation")
159
  {
202
  $results = $wpdb->query( $update );
203
  if ($results != false)
204
  {
205
+ $mlwQmnAlertManager->newAlert('The question has been updated successfully.', 'success');
206
 
207
  //Insert Action Into Audit Trail
208
  global $current_user;
215
  }
216
  else
217
  {
218
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0004.', 'error');
 
219
  }
220
  }
221
 
230
  $results = $wpdb->query( $update );
231
  if ($results != false)
232
  {
233
+ $mlwQmnAlertManager->newAlert('The question has been deleted successfully.', 'success');
234
 
235
  //Insert Action Into Audit Trail
236
  global $current_user;
243
  }
244
  else
245
  {
246
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0005.', 'error');
 
247
  }
248
  }
249
 
312
 
313
  if ($results != false)
314
  {
315
+ $mlwQmnAlertManager->newAlert('The question has been duplicated successfully.', 'success');
316
 
317
  //Insert Action Into Audit Trail
318
  global $current_user;
325
  }
326
  else
327
  {
328
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0019.', 'error');
 
329
  }
330
  }
331
 
368
  $results = $wpdb->query( $insert );
369
  if ($results != false)
370
  {
371
+ $mlwQmnAlertManager->newAlert('The question has been created successfully.', 'success');
372
 
373
  //Insert Action Into Audit Trail
374
  global $current_user;
381
  }
382
  else
383
  {
384
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0006.', 'error');
 
385
  }
386
  }
387
+
388
+ if (isset($_GET["quiz_id"]))
 
389
  {
390
+ $table_name = $wpdb->prefix . "mlw_quizzes";
391
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  }
393
 
394
+ $mlw_qmn_table_limit = 10;
395
+ $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
+ if( isset($_GET{'mlw_question_page'} ) )
 
 
 
 
 
 
398
  {
399
+ $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1;
400
+ $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  }
402
+ else
 
 
 
 
 
 
403
  {
404
+ $mlw_qmn_question_page = 0;
405
+ $mlw_qmn_question_begin = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  }
407
+ $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit);
408
 
409
+ $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'
410
+ ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
 
412
+ //Load and prepare answer arrays
413
+ $mlw_qmn_answer_arrays = array();
414
+ foreach($mlw_question_data as $mlw_question_info) {
415
+ $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array);
416
+ if ( !is_array($mlw_qmn_answer_array_each) )
417
  {
418
+ $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0);
419
+ $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1;
420
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array(
421
+ array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]),
422
+ array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]),
423
+ array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]),
424
+ array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]),
425
+ array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]),
426
+ array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5]));
 
427
  }
428
  else
429
  {
430
+ $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each;
 
431
  }
432
  }
433
+ $is_new_quiz = $wpdb->num_rows;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  ?>
435
+ <div id="tabs-1" class="mlw_tab_content">
436
+ <script>
437
+ $j(function() {
438
+ $j("#prev_page, #next_page, #new_answer_button").button();
439
+ });
440
+
441
+ jQuery(function() {
442
+ jQuery('#new_question_dialog').dialog({
443
+ autoOpen: false,
444
+ show: 'blind',
445
+ width:800,
446
+ hide: 'explode',
447
+ buttons: {
448
+ Cancel: function() {
449
+ jQuery(this).dialog('close');
450
+ }
451
+ }
452
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
 
454
+ jQuery('#new_question_button').click(function() {
455
+ jQuery('#new_question_dialog').dialog('open');
456
+ document.getElementById("question_name").focus();
457
+ return false;
458
+ } );
459
+ jQuery('#new_question_button_two').click(function() {
460
+ jQuery('#new_question_dialog').dialog('open');
461
+ document.getElementById("question_name").focus();
462
+ return false;
463
+ } );
464
+ });
465
+ function deleteQuestion(id){
466
+ jQuery("#delete_dialog").dialog({
467
+ autoOpen: false,
468
+ show: 'blind',
469
+ hide: 'explode',
470
+ buttons: {
471
+ Cancel: function() {
472
+ jQuery(this).dialog('close');
473
+ }
474
+ }
475
+ });
476
+ jQuery("#delete_dialog").dialog('open');
477
+ var idText = document.getElementById("delete_question_id");
478
+ var idHidden = document.getElementById("question_id");
479
+ idText.innerHTML = id;
480
+ idHidden.value = id;
481
+ };
482
+ function duplicateQuestion(id){
483
+ jQuery("#duplicate_dialog").dialog({
484
+ autoOpen: false,
485
+ show: 'blind',
486
+ hide: 'explode',
487
+ buttons: {
488
+ Cancel: function() {
489
+ jQuery(this).dialog('close');
490
+ }
491
+ }
492
+ });
493
+ jQuery("#duplicate_dialog").dialog('open');
494
+ var idHidden = document.getElementById("duplicate_question_id");
495
+ idHidden.value = id;
496
+ };
497
+ function editQuestion(id){
498
+ jQuery("#edit_question_dialog_"+id).dialog({
499
+ autoOpen: false,
500
+ show: 'blind',
501
+ width:800,
502
+ hide: 'explode',
503
+ buttons: {
504
+ Cancel: function() {
505
+ jQuery(this).dialog('close');
506
+ }
507
+ }
508
+ });
509
+ jQuery("#edit_question_dialog_"+id).dialog('open');
510
+ };
511
+ function mlw_add_new_question(id)
512
  {
513
+ var total_answers = parseFloat(document.getElementById("question_"+id+"_answer_total").value);
514
+ total_answers = total_answers + 1;
515
+ document.getElementById("question_"+id+"_answer_total").value = total_answers;
516
+ jQuery("#question_"+id+"_answers").append("<tr valign='top'><td><span style='font-weight:bold;'>Answer "+total_answers+"</span></td><td><input type='text' name='edit_answer_"+total_answers+"' id='edit_answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='edit_answer_"+total_answers+"_points' id='edit_answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='edit_answer_"+total_answers+"_correct' name='edit_answer_"+total_answers+"_correct' value=1 /></td></tr>");
 
 
517
  }
518
+ function mlw_add_answer_to_new_question()
519
  {
520
+ var total_answers = parseFloat(document.getElementById("new_question_answer_total").value);
521
+ total_answers = total_answers + 1;
522
+ document.getElementById("new_question_answer_total").value = total_answers;
523
+ jQuery("#new_question_answers").append("<tr valign='top'><td><span style='font-weight:bold;'>Answer "+total_answers+"</span></td><td><input type='text' name='answer_"+total_answers+"' id='answer_"+total_answers+"' style='border-color:#000000;color:#3300CC;cursor:hand;width: 250px;'/></td><td><input type='text' name='answer_"+total_answers+"_points' id='answer_"+total_answers+"_points' value=0 style='border-color:#000000;color:#3300CC; cursor:hand;'/></td><td><input type='checkbox' id='answer_"+total_answers+"_correct' name='answer_"+total_answers+"_correct' value=1 /></td></tr>");
524
  }
525
+ </script>
526
+ <style>
527
+ .linkOptions
528
  {
529
+ color: #0074a2 !important;
530
+ font-size: 14px !important;
531
  }
532
+ .linkDelete
533
+ {
534
+ color: red !important;
535
+ font-size: 14px !important;
536
+ }
537
+ .linkOptions:hover,
538
+ .linkDelete:hover
539
+ {
540
+ background-color: black;
541
+ }
542
+ </style>
543
+ <button id="new_question_button_two">Add Question</button>
544
+ <br />
545
+ <?php
546
+ $question_list = "";
547
+ $display = "";
548
+ $alternate = "";
549
+ foreach($mlw_question_data as $mlw_question_info) {
550
+ $mlw_question_settings = @unserialize($mlw_question_info->question_settings);
551
+ if (!is_array($mlw_question_settings)) {
552
+ $mlw_question_settings = array();
553
+ $mlw_question_settings['required'] = 1;
554
+ }
555
+ $mlw_question_type_text = "";
556
+ switch ($mlw_question_info->question_type) {
557
+ case 0:
558
+ $mlw_question_type_text = "Multiple Choice";
559
+ break;
560
+ case 1:
561
+ $mlw_question_type_text = "Horizontal Multiple Choice";
562
+ break;
563
+ case 2:
564
+ $mlw_question_type_text = "Drop Down";
565
+ break;
566
+ case 3:
567
+ $mlw_question_type_text = "Small Open Answer";
568
+ break;
569
+ case 4:
570
+ $mlw_question_type_text = "Multiple Response";
571
+ break;
572
+ case 5:
573
+ $mlw_question_type_text = "Large Open Answer";
574
+ break;
575
+ case 6:
576
+ $mlw_question_type_text = "Text Block";
577
+ break;
578
+ case 7:
579
+ $mlw_question_type_text = "Number";
580
+ break;
581
+ case 8:
582
+ $mlw_question_type_text = "Accept";
583
+ break;
584
+ case 9:
585
+ $mlw_question_type_text = "Captcha";
586
+ break;
587
+ case 10:
588
+ $mlw_question_type_text = "Horizontal Multiple Response";
589
+ break;
590
+ default:
591
+ $mlw_question_type_text = "Error Code ";
592
+ }
593
+ if($alternate) $alternate = "";
594
+ else $alternate = " class=\"alternate\"";
595
+ $question_list .= "<tr{$alternate}>";
596
+ $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_info->question_order . "</span></td>";
597
+ $question_list .= "<td><span style='font-size:16px;'>" . $mlw_question_type_text . "</span></td>";
598
+ $question_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_question_info->question_name ."</span><div class='row-actions'><a class='linkOptions' onclick=\"editQuestion('".$mlw_question_info->question_id."')\" href='#'>Edit</a> | <a class='linkOptions' onclick=\"duplicateQuestion('".$mlw_question_info->question_id."')\" href='#'>Duplicate</a>| <a class='linkDelete' onclick=\"deleteQuestion('".$mlw_question_info->question_id."')\" href='#'>Delete</a></div></td>";
599
+ $question_list .= "</tr>";
600
+
601
 
602
+ $mlw_question_answer_array = $mlw_qmn_answer_arrays[$mlw_question_info->question_id];
603
+ ?>
604
+ <div id="edit_question_dialog_<?php echo $mlw_question_info->question_id; ?>" title="Edit Question" style="display:none;">
605
  <?php
606
  echo "<form action='' method='post'>";
607
+ echo "<input type='hidden' name='edit_question' value='confirmation' />";
608
+ echo "<input type='hidden' id='edit_question_id' name='edit_question_id' value='".$mlw_question_info->question_id."' />";
609
  echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
610
+ ?>
611
+ <table class="wide" style="text-align: left; white-space: nowrap;" id="question_<?php echo $mlw_question_info->question_id; ?>_answers" name="question_<?php echo $mlw_question_info->question_id; ?>_answers">
612
  <tr>
613
  <td><span style='font-weight:bold;'>Question</span></td>
614
  <td colspan="3">
615
+ <textarea name="edit_question_name" id="edit_question_name" style="width: 500px; height: 150px;"><?php echo htmlspecialchars_decode($mlw_question_info->question_name, ENT_QUOTES); ?></textarea>
616
  </td>
617
  </tr>
618
  <tr valign="top">
627
  </tr>
628
  <?php
629
  $mlw_answer_total = 0;
630
+ foreach($mlw_question_answer_array as $mlw_question_answer_each)
631
+ {
632
+ $mlw_answer_total = $mlw_answer_total + 1;
633
+ ?>
634
+ <tr valign="top">
635
+ <td><span style='font-weight:bold;'>Answer <?php echo $mlw_answer_total; ?></span></td>
636
+ <td>
637
+ <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>" id="edit_answer_<?php echo $mlw_answer_total; ?>" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_answer_each[0], ENT_QUOTES)); ?>" style="border-color:#000000;
638
+ color:#3300CC;
639
+ cursor:hand;
640
+ width: 250px;"/>
641
+ </td>
642
+ <td>
643
+ <input type="text" name="edit_answer_<?php echo $mlw_answer_total; ?>_points" id="edit_answer_<?php echo $mlw_answer_total; ?>_points" value="<?php echo $mlw_question_answer_each[1]; ?>" style="border-color:#000000;
644
+ color:#3300CC;
645
+ cursor:hand;"/>
646
+ </td>
647
+ <td><input type="checkbox" id="edit_answer_<?php echo $mlw_answer_total; ?>_correct" name="edit_answer_<?php echo $mlw_answer_total; ?>_correct" <?php if ($mlw_question_answer_each[2] == 1) { echo 'checked="checked"'; } ?> value=1 /></td>
648
+ </tr>
649
+ <?php
650
+ }
651
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  </table>
653
+ <a href="#" id="new_answer_button" onclick="mlw_add_new_question(<?php echo $mlw_question_info->question_id; ?>);">Add New Answer!</a>
654
  <br />
655
  <br />
656
  <table class="wide" style="text-align: left; white-space: nowrap;">
657
  <tr>
658
+ <td><span style='font-weight:bold;'>Correct Answer Info:</span></td>
659
+ <td colspan="3"><input type="text" name="edit_correct_answer_info" id="edit_correct_answer_info" style="border-color:#000000;
660
  color:#3300CC;
661
  cursor:hand;
662
+ width:550px;" value="<?php echo esc_attr(htmlspecialchars_decode($mlw_question_info->question_answer_info, ENT_QUOTES)); ?>"/></td>
663
  </tr>
664
  <tr valign="top">
665
  <td><span style='font-weight:bold;'>Hint</span></td>
666
  <td colspan="3">
667
+ <input type="text" name="edit_hint" id="edit_hint" style="border-color:#000000;
668
  color:#3300CC;
669
  cursor:hand;
670
+ width:550px;" value="<?php echo htmlspecialchars_decode($mlw_question_info->hints, ENT_QUOTES); ?>"/>
671
  </td>
672
  </tr>
673
  <tr><td>&nbsp;</td></tr>
675
  <tr valign="top">
676
  <td><span style='font-weight:bold;'>Question Type</span></td>
677
  <td colspan="3">
678
+ <select name="edit_question_type">
679
+ <option value="0" <?php if ($mlw_question_info->question_type == 0) { echo 'selected="selected"'; } ?>>Normal Multiple Choice (Vertical Radio)</option>
680
+ <option value="1" <?php if ($mlw_question_info->question_type == 1) { echo 'selected="selected"'; } ?>>Horizontal Multiple Choice (Horizontal Radio)</option>
681
+ <option value="2" <?php if ($mlw_question_info->question_type == 2) { echo 'selected="selected"'; } ?>>Drop Down (Select)</option>
682
+ <option value="3" <?php if ($mlw_question_info->question_type == 3) { echo 'selected="selected"'; } ?>>Open Answer (Text Input)</option>
683
+ <option value="5" <?php if ($mlw_question_info->question_type == 5) { echo 'selected="selected"'; } ?>>Open Answer (Large Text Input)</option>
684
+ <option value="4" <?php if ($mlw_question_info->question_type == 4) { echo 'selected="selected"'; } ?>>Multiple Response (Checkbox)</option>
685
+ <option value="10" <?php if ($mlw_question_info->question_type == 10) { echo 'selected="selected"'; } ?>>Horizontal Multiple Response (Checkbox)</option>
686
+ <option value="6" <?php if ($mlw_question_info->question_type == 6) { echo 'selected="selected"'; } ?>>Text Block</option>
687
+ <option value="7" <?php if ($mlw_question_info->question_type == 7) { echo 'selected="selected"'; } ?>>Number</option>
688
+ <option value="8" <?php if ($mlw_question_info->question_type == 8) { echo 'selected="selected"'; } ?>>Accept</option>
689
+ <option value="9" <?php if ($mlw_question_info->question_type == 9) { echo 'selected="selected"'; } ?>>Captcha</option>
690
  </select>
691
  </div></td>
692
  </tr>
693
  <tr valign="top">
694
  <td><span style='font-weight:bold;'>Comment Field</span></td>
695
+ <td colspan="3">
696
+ <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1" name="edit_comments" value=0 <?php if ($mlw_question_info->comments == 0) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio1">Small Text Field</label>
697
+ <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3" name="edit_comments" value=2 <?php if ($mlw_question_info->comments == 2) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio3">Large Text Field</label>
698
+ <input type="radio" id="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2" name="edit_comments" value=1 <?php if ($mlw_question_info->comments == 1) { echo 'checked="checked"'; } ?>/><label for="<?php echo $mlw_question_info->question_id; ?>_editCommentRadio2">None</label>
699
+ </td>
700
  </tr>
701
  <tr valign="top">
702
  <td><span style='font-weight:bold;'>Question Order</span></td>
703
  <td>
704
+ <input type="number" step="1" min="1" name="edit_question_order" value="<?php echo $mlw_question_info->question_order; ?>" id="edit_question_order" style="border-color:#000000;
705
  color:#3300CC;
706
  cursor:hand;"/>
707
  </td>
709
  <tr valign="top">
710
  <td><span style='font-weight:bold;'>Required?</span></td>
711
  <td colspan="3">
712
+ <select name="edit_required">
713
+ <option value="0" <?php if ($mlw_question_settings['required'] == 0) { echo 'selected="selected"'; } ?>>Yes</option>
714
+ <option value="1" <?php if ($mlw_question_settings['required'] == 1) { echo 'selected="selected"'; } ?>>No</option>
715
  </select>
716
  </div></td>
717
  </tr>
718
  </table>
719
  <p> *Required currently only works on open answer, number, and captcha question types</p>
720
+ <input type="hidden" name="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" id="question_<?php echo $mlw_question_info->question_id; ?>_answer_total" value="<?php echo $mlw_answer_total; ?>" />
721
+ <p class='submit'><input type='submit' class='button-primary' value='Edit Question' /></p>
722
+ </form>
723
+ </div>
 
 
 
724
 
725
+ <?php
726
+ }
727
+
728
+ if( $mlw_qmn_question_page > 0 )
729
+ {
730
+ $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
731
+ $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
732
+ if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
733
+ {
734
+ $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
735
+ }
736
+ }
737
+ else if( $mlw_qmn_question_page == 0 )
738
+ {
739
+ if( $mlw_qmn_question_left > $mlw_qmn_table_limit )
740
+ {
741
+ $display .= "<a id=\"next_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_question_page&&quiz_id=$quiz_id\">Next 10 Questions</a>";
742
+ }
743
+ }
744
+ else if( $mlw_qmn_question_left < $mlw_qmn_table_limit )
745
+ {
746
+ $mlw_qmn_previous_page = $mlw_qmn_question_page - 2;
747
+ $display .= "<a id=\"prev_page\" href=\"?page=mlw_quiz_options&&mlw_question_page=$mlw_qmn_previous_page&&quiz_id=$quiz_id\">Previous 10 Questions</a>";
748
+ }
749
 
750
+ $display .= "<table class=\"widefat\">";
751
+ $display .= "<thead><tr>
752
+ <th>Question Order</th>
753
+ <th>Question Type</th>
754
+ <th>Question</th>
755
+ </tr></thead>";
756
+ $display .= "<tbody id=\"the-list\">{$question_list}</tbody>";
757
+ $display .= "<tfoot><tr>
758
+ <th>Question Order</th>
759
+ <th>Question Type</th>
760
+ <th>Question</th>
761
+ </tr></tfoot>";
762
+ $display .= "</table>";
763
+ echo $display;
764
+ ?>
765
+ <button id="new_question_button">Add Question</button>
766
+ <div id="new_question_dialog" title="Create New Question" style="display:none;">
767
+
768
+ <?php
769
+ echo "<form action='' method='post'>";
770
+ echo "<input type='hidden' name='create_question' value='confirmation' />";
771
+ echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
772
+ ?>
773
+ <table class="wide" style="text-align: left; white-space: nowrap;" id="new_question_answers" name="new_question_answers">
774
+ <tr>
775
+ <td><span style='font-weight:bold;'>Question</span></td>
776
+ <td colspan="3">
777
+ <textarea name="question_name" id="question_name" style="width: 500px; height: 150px;"></textarea>
778
+ </td>
779
+ </tr>
780
+ <tr valign="top">
781
+ <td>&nbsp;</td>
782
+ <td>&nbsp;</td>
783
+ </tr>
784
+ <tr valign="top">
785
+ <td>&nbsp;</td>
786
+ <td><span style='font-weight:bold;'>Answers</span></td>
787
+ <td><span style='font-weight:bold;'>Points Worth</span></td>
788
+ <td><span style='font-weight:bold;'>Correct Answer</span></td>
789
+ </tr>
790
+ <?php
791
+ $mlw_answer_total = 0;
792
+ $mlw_answer_total = $mlw_answer_total + 1;
793
+ ?>
794
+ <tr valign="top">
795
+ <td><span style='font-weight:bold;'>Answer <?php echo $mlw_answer_total; ?></span></td>
796
+ <td>
797
+ <input type="text" name="answer_<?php echo $mlw_answer_total; ?>" id="answer_<?php echo $mlw_answer_total; ?>" value="" style="border-color:#000000;
798
+ color:#3300CC;
799
+ cursor:hand;
800
+ width: 250px;"/>
801
+ </td>
802
+ <td>
803
+ <input type="text" name="answer_<?php echo $mlw_answer_total; ?>_points" id="answer_<?php echo $mlw_answer_total; ?>_points" value=0 style="border-color:#000000;
804
+ color:#3300CC;
805
+ cursor:hand;"/>
806
+ </td>
807
+ <td><input type="checkbox" id="answer_<?php echo $mlw_answer_total; ?>_correct" name="answer_<?php echo $mlw_answer_total; ?>_correct" checked="checked" value=1 /></td>
808
+ </tr>
809
+ </table>
810
+ <a href="#" id="new_answer_button" onclick="mlw_add_answer_to_new_question();">Add New Answer!</a>
811
+ <br />
812
+ <br />
813
+ <table class="wide" style="text-align: left; white-space: nowrap;">
814
+ <tr>
815
+ <td><span style='font-weight:bold;'>Correct Answer Info</span></td>
816
+ <td colspan="3"><input type="text" name="correct_answer_info" value="" id="correct_answer_info" style="border-color:#000000;
817
+ color:#3300CC;
818
+ cursor:hand;
819
+ width:550px;"/></td>
820
+ </tr>
821
+ <tr valign="top">
822
+ <td><span style='font-weight:bold;'>Hint</span></td>
823
+ <td colspan="3">
824
+ <input type="text" name="hint" value="" id="hint" style="border-color:#000000;
825
+ color:#3300CC;
826
+ cursor:hand;
827
+ width:550px;"/>
828
+ </td>
829
+ </tr>
830
+ <tr><td>&nbsp;</td></tr>
831
+ <tr><td>&nbsp;</td></tr>
832
+ <tr valign="top">
833
+ <td><span style='font-weight:bold;'>Question Type</span></td>
834
+ <td colspan="3">
835
+ <select name="question_type">
836
+ <option value="0" selected="selected">Normal Multiple Choice (Vertical Radio)</option>
837
+ <option value="1">Horizontal Multiple Choice (Horizontal Radio)</option>
838
+ <option value="2">Drop Down (Select)</option>
839
+ <option value="3">Open Answer (Text Input)</option>
840
+ <option value="5">Open Answer (Large Text Input)</option>
841
+ <option value="4">Multiple Response (Checkbox)</option>
842
+ <option value="10">Horizontal Multiple Response (Checkbox)</option>
843
+ <option value="6">Text Block</option>
844
+ <option value="7">Number</option>
845
+ <option value="8">Accept</option>
846
+ <option value="9">Captcha</option>
847
+ </select>
848
+ </div></td>
849
+ </tr>
850
+ <tr valign="top">
851
+ <td><span style='font-weight:bold;'>Comment Field</span></td>
852
+ <td colspan="3"><div id="comments">
853
+ <input type="radio" id="commentsRadio1" name="comments" value=0 /><label for="commentsRadio1">Small Text Field</label>
854
+ <input type="radio" id="commentsRadio3" name="comments" value=2 /><label for="commentsRadio3">Large Text Field</label>
855
+ <input type="radio" id="commentsRadio2" name="comments" checked="checked" value=1 /><label for="commentsRadio2">None</label>
856
+ </div></td>
857
+ </tr>
858
+ <tr valign="top">
859
+ <td><span style='font-weight:bold;'>Question Order</span></td>
860
+ <td>
861
+ <input type="number" step="1" min="1" name="new_question_order" value="1" id="new_question_order" style="border-color:#000000;
862
+ color:#3300CC;
863
+ cursor:hand;"/>
864
+ </td>
865
+ </tr>
866
+ <tr valign="top">
867
+ <td><span style='font-weight:bold;'>Required?</span></td>
868
+ <td colspan="3">
869
+ <select name="required">
870
+ <option value="0" selected="selected">Yes</option>
871
+ <option value="1">No</option>
872
+ </select>
873
+ </div></td>
874
+ </tr>
875
+ </table>
876
+ <p> *Required currently only works on open answer, number, and captcha question types</p>
877
+ <input type="hidden" name="new_question_answer_total" id="new_question_answer_total" value="<?php echo $mlw_answer_total; ?>" />
878
+ <?php
879
+ echo "<p class='submit'><input type='submit' class='button-primary' value='Create Question' /></p>";
880
+ echo "</form>";
881
+ ?>
882
+ </div>
883
+ <!--Dialogs-->
884
+ <div id="delete_dialog" title="Delete Question?" style="display:none;">
885
+ <h3><b>Are you sure you want to delete Question <span id="delete_question_id"></span>?</b></h3>
886
+ <?php
887
+ echo "<form action='' method='post'>";
888
+ echo "<input type='hidden' name='delete_question' value='confirmation' />";
889
+ echo "<input type='hidden' id='question_id' name='question_id' value='' />";
890
+ echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
891
+ echo "<p class='submit'><input type='submit' class='button-primary' value='Delete Question' /></p>";
892
+ echo "</form>";
893
+ ?>
894
+ </div>
895
+
896
+ <div id="duplicate_dialog" title="Duplicate Question?" style="display:none;">
897
+ <h3><b>Are you sure you want to duplicate this Question?</b></h3>
898
+ <?php
899
+ echo "<form action='' method='post'>";
900
+ echo "<input type='hidden' name='duplicate_question' value='confirmation' />";
901
+ echo "<input type='hidden' id='duplicate_question_id' name='duplicate_question_id' value='' />";
902
+ echo "<input type='hidden' name='quiz_id' value='".$quiz_id."' />";
903
+ echo "<p class='submit'><input type='submit' class='button-primary' value='Duplicate Question' /></p>";
904
+ echo "</form>";
905
+ ?>
906
+ </div>
907
+ </div>
908
+ <?php
909
+ }
910
 
911
+ function mlw_options_text_tab_content()
912
+ {
913
+ global $wpdb;
914
+ global $mlwQmnAlertManager;
915
+ $quiz_id = $_GET["quiz_id"];
916
+ //Submit saved templates into database
917
+ if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation")
918
+ {
919
+ //Variables for save templates form
920
+ $mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES);
921
+ $mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES);
922
+ $mlw_qmn_social_medi_text = htmlspecialchars($_POST["mlw_quiz_social_media_text_template"], ENT_QUOTES);
923
+ $mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES);
924
+ $mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES);
925
+ $mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES);
926
+ $mlw_business_field_text = htmlspecialchars($_POST["mlw_businessText"], ENT_QUOTES);
927
+ $mlw_email_field_text = htmlspecialchars($_POST["mlw_emailText"], ENT_QUOTES);
928
+ $mlw_phone_field_text = htmlspecialchars($_POST["mlw_phoneText"], ENT_QUOTES);
929
+ $mlw_before_comments = htmlspecialchars($_POST["mlw_quiz_before_comments"], ENT_QUOTES);
930
+ $mlw_comment_field_text = htmlspecialchars($_POST["mlw_commentText"], ENT_QUOTES);
931
+ $mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] ));
932
+ $mlw_email_from_text = $_POST["emailFromText"];
933
+ $mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES);
934
+ $quiz_id = $_POST["quiz_id"];
935
+
936
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$mlw_qmn_social_medi_text."', pagination_text='".$mlw_qmn_pagination_field."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id;
937
+ $results = $wpdb->query( $update );
938
+ if ($results != false)
939
+ {
940
+ $mlwQmnAlertManager->newAlert('The templates has been updated successfully.', 'success');
941
+
942
+ //Insert Action Into Audit Trail
943
+ global $current_user;
944
+ get_currentuserinfo();
945
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
946
+ $insert = "INSERT INTO " . $table_name .
947
+ "(trail_id, action_user, action, time) " .
948
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
949
+ $results = $wpdb->query( $insert );
950
+ }
951
+ else
952
+ {
953
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0007.', 'error');
954
+ }
955
+ }
956
+
957
+ if (isset($_GET["quiz_id"]))
958
+ {
959
+ $table_name = $wpdb->prefix . "mlw_quizzes";
960
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
961
+ }
962
+
963
+ //Load Pagination Text
964
+ $mlw_qmn_pagination_text = "";
965
+ $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text);
966
+ if (!is_array($mlw_qmn_pagination_text)) {
967
+ $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text);
968
+ }
969
+ ?>
970
+ <div id="tabs-2" class="mlw_tab_content">
971
  <h3 style="text-align: center;">Template Variables</h3>
972
  <table class="form-table">
973
  <tr>
1147
  <button id="save_template_button" onclick="javascript: document.quiz_template_form.submit();">Save Templates</button>
1148
  <?php echo "</form>"; ?>
1149
  </div>
1150
+ <?php
1151
+ }
1152
+
1153
+ function mlw_options_option_tab_content()
1154
+ {
1155
+ global $wpdb;
1156
+ global $mlwQmnAlertManager;
1157
+ $quiz_id = $_GET["quiz_id"];
1158
+ //Submit saved options into database
1159
+ if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation")
1160
+ {
1161
+ //Variables for save options form
1162
+ $mlw_system = $_POST["system"];
1163
+ $mlw_qmn_pagination = intval($_POST["pagination"]);
1164
+ $mlw_qmn_social_media = intval($_POST["social_media"]);
1165
+ $mlw_qmn_question_numbering = intval($_POST["question_numbering"]);
1166
+ $mlw_qmn_timer = intval($_POST["timer_limit"]);
1167
+ $mlw_qmn_questions_from_total = $_POST["question_from_total"];
1168
+ $mlw_randomness_order = $_POST["randomness_order"];
1169
+ $mlw_total_user_tries = intval($_POST["total_user_tries"]);
1170
+ $mlw_send_user_email = $_POST["sendUserEmail"];
1171
+ $mlw_send_admin_email = $_POST["sendAdminEmail"];
1172
+ $mlw_contact_location = $_POST["contact_info_location"];
1173
+ $mlw_user_name = $_POST["userName"];
1174
+ $mlw_user_comp = $_POST["userComp"];
1175
+ $mlw_user_email = $_POST["userEmail"];
1176
+ $mlw_user_phone = $_POST["userPhone"];
1177
+ $mlw_admin_email = $_POST["adminEmail"];
1178
+ $mlw_comment_section = $_POST["commentSection"];
1179
+ $mlw_qmn_loggedin_contact = $_POST["loggedin_user_contact"];
1180
+ $quiz_id = $_POST["quiz_id"];
1181
+
1182
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', loggedin_user_contact='".$mlw_qmn_loggedin_contact."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', admin_email='".$mlw_admin_email."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."', question_from_total=".$mlw_qmn_questions_from_total.", total_user_tries=".$mlw_total_user_tries.", social_media=".$mlw_qmn_social_media.", pagination=".$mlw_qmn_pagination.", timer_limit=".$mlw_qmn_timer.", question_numbering=".$mlw_qmn_question_numbering.", last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id;
1183
+ $results = $wpdb->query( $update );
1184
+ if ($results != false)
1185
+ {
1186
+ $mlwQmnAlertManager->newAlert('The options has been updated successfully.', 'success');
1187
+
1188
+ //Insert Action Into Audit Trail
1189
+ global $current_user;
1190
+ get_currentuserinfo();
1191
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1192
+ $insert = "INSERT INTO " . $table_name .
1193
+ "(trail_id, action_user, action, time) " .
1194
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
1195
+ $results = $wpdb->query( $insert );
1196
+ }
1197
+ else
1198
+ {
1199
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0008.', 'error');
1200
+ }
1201
+ }
1202
+
1203
+ if (isset($_GET["quiz_id"]))
1204
+ {
1205
+ $table_name = $wpdb->prefix . "mlw_quizzes";
1206
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1207
+ }
1208
+ ?>
1209
+ <div id="tabs-3" class="mlw_tab_content">
1210
+ <script>
1211
+ jQuery(function() {
1212
+ jQuery( "#system, #randomness_order, #loggedin_user_contact, #sendUserEmail, #sendAdminEmail, #contact_info_location, #userName, #userComp, #userEmail, #userPhone, #pagination, #commentSection, #social_media, #question_numbering, #comments" ).buttonset();
1213
+ });
1214
+ </script>
1215
  <button id="save_options_button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button>
1216
  <?php
1217
  echo "<form action='' method='post' name='quiz_options_form'>";
1348
  <button id="save_options_button" onclick="javascript: document.quiz_options_form.submit();">Save Options</button>
1349
  <?php echo "</form>"; ?>
1350
  </div>
1351
+ <?php
1352
+ }
1353
+
1354
+ function mlw_options_leaderboard_tab_content()
1355
+ {
1356
+ global $wpdb;
1357
+ global $mlwQmnAlertManager;
1358
+ $quiz_id = $_GET["quiz_id"];
1359
+ ///Submit saved leaderboard template into database
1360
+ if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation")
1361
+ {
1362
+ ///Variables for save leaderboard options form
1363
+ $mlw_leaderboard_template = $_POST["mlw_quiz_leaderboard_template"];
1364
+ $mlw_leaderboard_quiz_id = $_POST["leaderboard_quiz_id"];
1365
+ $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_leaderboard_quiz_id;
1366
+ $results = $wpdb->query( $update );
1367
+ if ($results != false)
1368
+ {
1369
+ $mlwQmnAlertManager->newAlert('The leaderboards has been updated successfully.', 'success');
1370
+
1371
+ //Insert Action Into Audit Trail
1372
+ global $current_user;
1373
+ get_currentuserinfo();
1374
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1375
+ $insert = "INSERT INTO " . $table_name .
1376
+ "(trail_id, action_user, action, time) " .
1377
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
1378
+ $results = $wpdb->query( $insert );
1379
+ }
1380
+ else
1381
+ {
1382
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0009.', 'error');
1383
+ }
1384
+ }
1385
+
1386
+ if (isset($_GET["quiz_id"]))
1387
+ {
1388
+ $table_name = $wpdb->prefix . "mlw_quizzes";
1389
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1390
+ }
1391
+ ?>
1392
+ <div id="tabs-4" class="mlw_tab_content">
1393
  <h3>Template Variables</h3>
1394
  <table class="form-table">
1395
  <tr>
1421
  <td><strong>%QUIZ_NAME%</strong> - The name of the quiz</td>
1422
  </tr>
1423
  </table>
1424
+ <button id="save_template_button" onclick="javascript: document.quiz_leaderboard_options_form.submit();">Save Leaderboard Options</button>
1425
  <?php
1426
  echo "<form action='' method='post' name='quiz_leaderboard_options_form'>";
1427
  echo "<input type='hidden' name='save_leaderboard_options' value='confirmation' />";
1452
  <button id="save_template_button" onclick="javascript: document.quiz_leaderboard_options_form.submit();">Save Leaderboard Options</button>
1453
  </form>
1454
  </div>
1455
+ <?php
1456
+ }
1457
+
1458
+ function mlw_options_certificate_tab_content()
1459
+ {
1460
+ global $wpdb;
1461
+ global $mlwQmnAlertManager;
1462
+ $quiz_id = $_GET["quiz_id"];
1463
+ //Saved Certificate Options
1464
+ if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation")
1465
+ {
1466
+ $mlw_certificate_id = intval($_POST["certificate_quiz_id"]);
1467
+ $mlw_certificate_title = $_POST["certificate_title"];
1468
+ $mlw_certificate_text = $_POST["certificate_template"];
1469
+ $mlw_certificate_logo = $_POST["certificate_logo"];
1470
+ $mlw_certificate_background = $_POST["certificate_background"];
1471
+ $mlw_enable_certificates = intval($_POST["enableCertificates"]);
1472
+ $mlw_certificate = array($mlw_certificate_title, $mlw_certificate_text, $mlw_certificate_logo, $mlw_certificate_background, $mlw_enable_certificates);
1473
+ $mlw_certificate_serialized = serialize($mlw_certificate);
1474
+
1475
+ $mlw_certificate_sql_results = $wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "mlw_quizzes SET certificate_template=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_certificate_serialized, $mlw_certificate_id ) );
1476
+
1477
+
1478
+ if ($mlw_certificate_sql_results != false)
1479
+ {
1480
+ $mlwQmnAlertManager->newAlert('The certificate has been updated successfully.', 'success');
1481
+
1482
+ //Insert Action Into Audit Trail
1483
+ global $current_user;
1484
+ get_currentuserinfo();
1485
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1486
+ $insert = "INSERT INTO " . $table_name .
1487
+ "(trail_id, action_user, action, time) " .
1488
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . date("h:i:s A m/d/Y") . "')";
1489
+ $results = $wpdb->query( $insert );
1490
+ }
1491
+ else
1492
+ {
1493
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0012.', 'error');
1494
+ }
1495
+ }
1496
+ if (isset($_GET["quiz_id"]))
1497
+ {
1498
+ $table_name = $wpdb->prefix . "mlw_quizzes";
1499
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1500
+ }
1501
+
1502
+ //Load Certificate Options Variables
1503
+ $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template);
1504
+ if (!is_array($mlw_certificate_options)) {
1505
+ // something went wrong, initialize to empty array
1506
+ $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1);
1507
+ }
1508
+ ?>
1509
+ <div id="tabs-5" class="mlw_tab_content">
1510
+ <script>
1511
+ jQuery(function() {
1512
+ jQuery( "#enableCertificates" ).buttonset();
1513
+ });
1514
+ </script>
1515
  <h3>Quiz Certificate (Beta)</h3>
1516
  <p>Enter in your text here to fill in the certificate for this quiz. Be sure to enter in the link variable into the templates on the Quiz Text tab so the user can access the certificate.</p>
1517
  <p>These fields cannot contain HTML.</p>
1574
  <button id="save_certificate_button" onclick="javascript: document.quiz_certificate_options_form.submit();">Save Certificate Options</button>
1575
  </form>
1576
  </div>
1577
+ <?php
1578
+ }
1579
+
1580
+ function mlw_options_emails_tab_content()
1581
+ {
1582
+ global $wpdb;
1583
+ global $mlwQmnAlertManager;
1584
+ $quiz_id = $_GET["quiz_id"];
1585
+ //Check to add new user email template
1586
+ if (isset($_POST["mlw_add_email_page"]) && $_POST["mlw_add_email_page"] == "confirmation")
1587
+ {
1588
+ //Function variables
1589
+ $mlw_qmn_add_email_id = intval($_POST["mlw_add_email_quiz_id"]);
1590
+ $mlw_qmn_user_email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) );
1591
+
1592
+ //Load user email and check if it is array already. If not, turn it into one
1593
+ $mlw_qmn_email_array = @unserialize($mlw_qmn_user_email);
1594
+ if (is_array($mlw_qmn_email_array))
1595
+ {
1596
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
1597
+ array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
1598
+ $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
1599
+
1600
+ }
1601
+ else
1602
+ {
1603
+ $mlw_qmn_email_array = array(array(0, 0, $mlw_qmn_user_email, 'Quiz Results For %QUIZ_NAME%'));
1604
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%');
1605
+ array_unshift($mlw_qmn_email_array , $mlw_new_landing_array);
1606
+ $mlw_qmn_email_array = serialize($mlw_qmn_email_array);
1607
+ }
1608
+ //Update message_after with new array then check to see if worked
1609
+ $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) );
1610
+ if ($mlw_new_email_results != false)
1611
+ {
1612
+ $mlwQmnAlertManager->newAlert('The email has been added successfully.', 'success');
1613
+
1614
+ //Insert Action Into Audit Trail
1615
+ global $current_user;
1616
+ get_currentuserinfo();
1617
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1618
+ $insert = "INSERT INTO " . $table_name .
1619
+ "(trail_id, action_user, action, time) " .
1620
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New User Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
1621
+ $results = $wpdb->query( $insert );
1622
+ }
1623
+ else
1624
+ {
1625
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0016.', 'error');
1626
+ }
1627
+ }
1628
+
1629
+ //Check to save email templates
1630
+ if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation")
1631
+ {
1632
+ //Function Variables
1633
+ $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]);
1634
+ $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]);
1635
+ $mlw_qmn_admin_email = htmlspecialchars(stripslashes($_POST["mlw_quiz_admin_email_template"]), ENT_QUOTES);
1636
+
1637
+ //Create new array
1638
+ $i = 1;
1639
+ $mlw_qmn_new_email_array = array();
1640
+ while ($i <= $mlw_qmn_email_template_total)
1641
+ {
1642
+ if ($_POST["user_email_".$i] != "Delete")
1643
+ {
1644
+ $mlw_qmn_email_each = array(intval($_POST["user_email_begin_".$i]), intval($_POST["user_email_end_".$i]), htmlspecialchars(stripslashes($_POST["user_email_".$i]), ENT_QUOTES), htmlspecialchars(stripslashes($_POST["user_email_subject_".$i]), ENT_QUOTES));
1645
+ $mlw_qmn_new_email_array[] = $mlw_qmn_email_each;
1646
+ }
1647
+ $i++;
1648
+ }
1649
+ $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array);
1650
+ $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_admin_email, $mlw_qmn_email_id ) );
1651
+ if ($mlw_new_email_results != false)
1652
+ {
1653
+ $mlwQmnAlertManager->newAlert('The email has been updated successfully.', 'success');
1654
+
1655
+ //Insert Action Into Audit Trail
1656
+ global $current_user;
1657
+ get_currentuserinfo();
1658
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1659
+ $insert = "INSERT INTO " . $table_name .
1660
+ "(trail_id, action_user, action, time) " .
1661
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Email Templates Have Been Saved For Quiz Number ".$mlw_qmn_email_id."' , '" . date("h:i:s A m/d/Y") . "')";
1662
+ $results = $wpdb->query( $insert );
1663
+ }
1664
+ else
1665
+ {
1666
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0017.', 'error');
1667
+ }
1668
+ }
1669
+
1670
+ if (isset($_GET["quiz_id"]))
1671
+ {
1672
+ $table_name = $wpdb->prefix . "mlw_quizzes";
1673
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1674
+ }
1675
+
1676
+ //Load Email Templates
1677
+ $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template);
1678
+ if (!is_array($mlw_qmn_user_email_array)) {
1679
+ // something went wrong, initialize to empty array
1680
+ $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%'));
1681
+ }
1682
+ ?>
1683
+
1684
+ <div id="tabs-9" class="mlw_tab_content">
1685
+ <script>
1686
+ $j(function() {
1687
+ $j("#new_email_button_top, #new_email_button_bottom").button();
1688
+ });
1689
+ jQuery(function() {
1690
+ jQuery("#email_accordion").accordion({
1691
+ heightStyle: "content"
1692
+ });
1693
+ });
1694
+ function delete_email(id)
1695
+ {
1696
+ document.getElementById('user_email_'+id).value = "Delete";
1697
+ document.mlw_quiz_save_email_form.submit();
1698
+ }
1699
+ </script>
1700
  <h3>Template Variables</h3>
1701
  <table class="form-table">
1702
  <tr>
1738
  <input type='hidden' name='mlw_add_email_quiz_id' value='<?php echo $quiz_id; ?>' />
1739
  </form>
1740
  <button id="save_email_button" onclick="javascript: document.mlw_quiz_save_email_form.submit();">Save Email Templates</button>
 
1741
  <form method="post" action="" name="mlw_quiz_save_email_form">
1742
  <div id="email_accordion">
1743
  <h3><a href="#">Email Sent To User</a></h3>
1857
  </form>
1858
  <button id="save_email_button" onclick="javascript: document.mlw_quiz_save_email_form.submit();">Save Email Templates</button>
1859
  </div>
1860
+ <?php
1861
+ }
1862
+
1863
+ function mlw_options_results_tab_content()
1864
+ {
1865
+ global $wpdb;
1866
+ global $mlwQmnAlertManager;
1867
+ $quiz_id = $_GET["quiz_id"];
1868
+ //Check to add new results page
1869
+ if (isset($_POST["mlw_add_landing_page"]) && $_POST["mlw_add_landing_page"] == "confirmation")
1870
+ {
1871
+ //Function variables
1872
+ $mlw_qmn_landing_id = intval($_POST["mlw_add_landing_quiz_id"]);
1873
+ $mlw_qmn_message_after = $wpdb->get_var( $wpdb->prepare( "SELECT message_after FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_landing_id ) );
1874
+ //Load message_after and check if it is array already. If not, turn it into one
1875
+ $mlw_qmn_landing_array = @unserialize($mlw_qmn_message_after);
1876
+ if (is_array($mlw_qmn_landing_array))
1877
+ {
1878
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
1879
+ array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
1880
+ $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
1881
+
1882
+ }
1883
+ else
1884
+ {
1885
+ $mlw_qmn_landing_array = array(array(0, 0, $mlw_qmn_message_after));
1886
+ $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here');
1887
+ array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array);
1888
+ $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array);
1889
+ }
1890
+
1891
+ //Update message_after with new array then check to see if worked
1892
+ $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) );
1893
+ if ($mlw_new_landing_results != false)
1894
+ {
1895
+ $mlwQmnAlertManager->newAlert('The results page has been added successfully.', 'success');
1896
+
1897
+ //Insert Action Into Audit Trail
1898
+ global $current_user;
1899
+ get_currentuserinfo();
1900
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1901
+ $insert = "INSERT INTO " . $table_name .
1902
+ "(trail_id, action_user, action, time) " .
1903
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'New Landing Page Has Been Created For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
1904
+ $results = $wpdb->query( $insert );
1905
+ }
1906
+ else
1907
+ {
1908
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0013.', 'error');
1909
+ }
1910
+ }
1911
+
1912
+ //Check to save landing pages
1913
+ if (isset($_POST["mlw_save_landing_pages"]) && $_POST["mlw_save_landing_pages"] == "confirmation")
1914
+ {
1915
+ //Function Variables
1916
+ $mlw_qmn_landing_id = intval($_POST["mlw_landing_quiz_id"]);
1917
+ $mlw_qmn_landing_total = intval($_POST["mlw_landing_page_total"]);
1918
+
1919
+ //Create new array
1920
+ $i = 1;
1921
+ $mlw_qmn_new_landing_array = array();
1922
+ while ($i <= $mlw_qmn_landing_total)
1923
+ {
1924
+ if ($_POST["message_after_".$i] != "Delete")
1925
+ {
1926
+ $mlw_qmn_landing_each = array(intval($_POST["message_after_begin_".$i]), intval($_POST["message_after_end_".$i]), htmlspecialchars(stripslashes($_POST["message_after_".$i]), ENT_QUOTES));
1927
+ $mlw_qmn_new_landing_array[] = $mlw_qmn_landing_each;
1928
+ }
1929
+ $i++;
1930
+ }
1931
+ $mlw_qmn_new_landing_array = serialize($mlw_qmn_new_landing_array);
1932
+ $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) );
1933
+ if ($mlw_new_landing_results != false)
1934
+ {
1935
+ $mlwQmnAlertManager->newAlert('The results page has been saved successfully.', 'success');
1936
+
1937
+ //Insert Action Into Audit Trail
1938
+ global $current_user;
1939
+ get_currentuserinfo();
1940
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1941
+ $insert = "INSERT INTO " . $table_name .
1942
+ "(trail_id, action_user, action, time) " .
1943
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Landing Pages Have Been Saved For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')";
1944
+ $results = $wpdb->query( $insert );
1945
+ }
1946
+ else
1947
+ {
1948
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0014.', 'error');
1949
+ }
1950
+ }
1951
+
1952
+ if (isset($_GET["quiz_id"]))
1953
+ {
1954
+ $table_name = $wpdb->prefix . "mlw_quizzes";
1955
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
1956
+ }
1957
+
1958
+ //Load Landing Pages
1959
+ $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after);
1960
+ if (!is_array($mlw_message_after_array)) {
1961
+ // something went wrong, initialize to empty array
1962
+ $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after));
1963
+ }
1964
+ ?>
1965
+ <div id="tabs-6" class="mlw_tab_content">
1966
+ <script>
1967
+ function delete_landing(id)
1968
+ {
1969
+ document.getElementById('message_after_'+id).value = "Delete";
1970
+ document.mlw_quiz_save_landing_form.submit();
1971
+ }
1972
+ </script>
1973
  <h3>Template Variables</h3>
1974
  <table class="form-table">
1975
  <tr>
2012
  </table>
2013
  <button id="save_landing_button" onclick="javascript: document.mlw_quiz_save_landing_form.submit();">Save Results Pages</button>
2014
  <button id="new_landing_button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();">Add New Results Page</button>
 
2015
  <form method="post" action="" name="mlw_quiz_save_landing_form" style=" display:inline!important;">
2016
  <table class="widefat">
2017
  <thead>
2089
  <button id="new_landing_button" onclick="javascript: document.mlw_quiz_add_landing_form.submit();">Add New Results Page</button>
2090
  </form>
2091
  </div>
2092
+ <?php
2093
+ }
2094
+
2095
+ function mlw_options_styling_tab_content()
2096
+ {
2097
+ global $wpdb;
2098
+ global $mlwQmnAlertManager;
2099
+ $quiz_id = $_GET["quiz_id"];
2100
+ if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation")
2101
+ {
2102
+ //Function Variables
2103
+ $mlw_qmn_style_id = intval($_POST["style_quiz_id"]);
2104
+ $mlw_qmn_theme = $_POST["save_quiz_theme"];
2105
+ $mlw_qmn_style = htmlspecialchars(stripslashes($_POST["quiz_css"]), ENT_QUOTES);
2106
+
2107
+ //Save the new css
2108
+ $mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) );
2109
+ if ($mlw_save_stle_results != false)
2110
+ {
2111
+ $mlwQmnAlertManager->newAlert('The style has been saved successfully.', 'success');
2112
+
2113
+ //Insert Action Into Audit Trail
2114
+ global $current_user;
2115
+ get_currentuserinfo();
2116
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
2117
+ $insert = "INSERT INTO " . $table_name .
2118
+ "(trail_id, action_user, action, time) " .
2119
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')";
2120
+ $results = $wpdb->query( $insert );
2121
+ }
2122
+ else
2123
+ {
2124
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0015.', 'error');
2125
+ }
2126
+ }
2127
+
2128
+ if (isset($_GET["quiz_id"]))
2129
+ {
2130
+ $table_name = $wpdb->prefix . "mlw_quizzes";
2131
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
2132
+ }
2133
+ ?>
2134
+ <div id="tabs-7" class="mlw_tab_content">
2135
+ <script>
2136
+ function mlw_qmn_theme(theme)
2137
+ {
2138
+ document.getElementById('save_quiz_theme').value = theme;
2139
+ jQuery("div.mlw_qmn_themeBlockActive").toggleClass("mlw_qmn_themeBlockActive");
2140
+ jQuery("#mlw_qmn_theme_block_"+theme).toggleClass("mlw_qmn_themeBlockActive");
2141
+
2142
+ }
2143
+ </script>
2144
  <?php
2145
  echo "<form action='' method='post' name='quiz_style_form'>";
2146
  echo "<input type='hidden' name='save_style_options' value='confirmation' />";
2244
  <button id="save_styles_button" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>
2245
  </form>
2246
  </div>
2247
+ <?php
2248
+ }
2249
+
2250
+ function mlw_options_tools_tab_content()
2251
+ {
2252
+ global $wpdb;
2253
+ global $mlwQmnAlertManager;
2254
+ $quiz_id = $_GET["quiz_id"];
2255
+ //Update Quiz Table
2256
+ if (isset($_POST["mlw_reset_quiz_stats"]) && $_POST["mlw_reset_quiz_stats"] == "confirmation")
2257
+ {
2258
+ //Variables from reset stats form
2259
+ $mlw_reset_stats_quiz_id = $_POST["mlw_reset_quiz_id"];
2260
+ $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_reset_stats_quiz_id;
2261
+ $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql );
2262
+ if ($mlw_reset_sql_results != false)
2263
+ {
2264
+ $mlwQmnAlertManager->newAlert('The stats has been reset successfully.', 'success');
2265
+
2266
+ //Insert Action Into Audit Trail
2267
+ global $current_user;
2268
+ get_currentuserinfo();
2269
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
2270
+ $insert = "INSERT INTO " . $table_name .
2271
+ "(trail_id, action_user, action, time) " .
2272
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')";
2273
+ $results = $wpdb->query( $insert );
2274
+ }
2275
+ else
2276
+ {
2277
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0010.', 'error');
2278
+ }
2279
+ }
2280
+
2281
+ if (isset($_GET["quiz_id"]))
2282
+ {
2283
+ $table_name = $wpdb->prefix . "mlw_quizzes";
2284
+ $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
2285
+ }
2286
+ ?>
2287
+ <div id="tabs-8" class="mlw_tab_content">
2288
+ <script>
2289
+ jQuery(function() {
2290
+ jQuery('#mlw_reset_stats_dialog').dialog({
2291
+ autoOpen: false,
2292
+ show: 'blind',
2293
+ width:700,
2294
+ hide: 'explode',
2295
+ buttons: {
2296
+ Ok: function() {
2297
+ jQuery(this).dialog('close');
2298
+ }
2299
+ }
2300
+ });
2301
+
2302
+ jQuery('#mlw_reset_stats_button').click(function() {
2303
+ jQuery('#mlw_reset_stats_dialog').dialog('open');
2304
+ return false;
2305
+ } );
2306
+ });
2307
+ </script>
2308
  <p>Use this button to reset all the stats collected for this quiz (Quiz Views and Times Quiz Has Been Taken). </p>
2309
  <button id="mlw_reset_stats_button">Reset Quiz Views And Taken Stats</button>
2310
  <?php do_action('mlw_qmn_quiz_tools'); ?>
2319
  ?>
2320
  </div>
2321
  </div>
2322
+ <?php
2323
+ }
 
 
2324
 
2325
+ function mlw_options_preview_tab_content()
2326
+ {
2327
+ ?>
2328
+ <div id="tabs-preview" class="mlw_tab_content">
 
 
 
 
 
 
 
 
 
 
 
2329
  <?php
2330
+ echo do_shortcode( '[mlw_quizmaster quiz='.intval($_GET["quiz_id"]).']' );
 
 
 
 
 
2331
  ?>
2332
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2333
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2334
  }
2335
  ?>
includes/mlw_results.php CHANGED
@@ -9,7 +9,7 @@ Copyright 2013, My Local Webstop (email : fpcorso@mylocalwebstop.com)
9
  function mlw_generate_quiz_results()
10
  {
11
  global $wpdb;
12
- $mlw_hasDeletedResults = false;
13
 
14
  ///Delete Results Function
15
  if (isset($_POST["delete_results"]) && $_POST["delete_results"] == "confirmation")
@@ -20,16 +20,23 @@ function mlw_generate_quiz_results()
20
  $mlw_delete_results_name = $_POST["delete_quiz_name"];
21
  $mlw_delete_results_update_sql = "UPDATE " . $wpdb->prefix . "mlw_results" . " SET deleted=1 WHERE result_id=".$mlw_delete_results_id;
22
  $mlw_delete_results_results = $wpdb->query( $mlw_delete_results_update_sql );
23
- $mlw_hasDeletedResults = true;
 
 
24
 
25
- //Insert Action Into Audit Trail
26
- global $current_user;
27
- get_currentuserinfo();
28
- $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
29
- $insert = "INSERT INTO " . $table_name .
30
- "(trail_id, action_user, action, time) " .
31
- "VALUES (NULL , '" . $current_user->display_name . "' , 'Results Has Been Deleted From: ".$mlw_delete_results_name."' , '" . date("h:i:s A m/d/Y") . "')";
32
- $results = $wpdb->query( $insert );
 
 
 
 
 
33
  }
34
 
35
  global $wpdb;
@@ -131,23 +138,28 @@ function mlw_generate_quiz_results()
131
  <div class="wrap">
132
  <div class='mlw_quiz_options'>
133
  <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
134
- <?php if ($mlw_hasDeletedResults)
135
- {
136
- ?>
137
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
138
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
139
- <strong>Success!</strong> Your results have been deleted.</p>
140
- </div>
141
- <?php
142
- }
143
- ?>
144
  <?php
 
 
145
  $quotes_list = "";
146
  $display = "";
147
  $alternate = "";
148
  foreach($mlw_quiz_data as $mlw_quiz_info) {
149
  if($alternate) $alternate = "";
150
  else $alternate = " class=\"alternate\"";
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  $quotes_list .= "<tr{$alternate}>";
152
  $quotes_list .= "<td><span style='color:green;font-size:16px;'><a href='admin.php?page=mlw_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a>|<a onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></td>";
153
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span></td>";
@@ -163,6 +175,7 @@ function mlw_generate_quiz_results()
163
  {
164
  $quotes_list .= "<td><span style='font-size:16px;'>Not Graded</span></td>";
165
  }
 
166
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
167
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
168
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->email ."</span></td>";
@@ -198,6 +211,7 @@ function mlw_generate_quiz_results()
198
  <th>Actions</th>
199
  <th>Quiz Name</th>
200
  <th>Score</th>
 
201
  <th>Name</th>
202
  <th>Business</th>
203
  <th>Email</th>
9
  function mlw_generate_quiz_results()
10
  {
11
  global $wpdb;
12
+ global $mlwQmnAlertManager;
13
 
14
  ///Delete Results Function
15
  if (isset($_POST["delete_results"]) && $_POST["delete_results"] == "confirmation")
20
  $mlw_delete_results_name = $_POST["delete_quiz_name"];
21
  $mlw_delete_results_update_sql = "UPDATE " . $wpdb->prefix . "mlw_results" . " SET deleted=1 WHERE result_id=".$mlw_delete_results_id;
22
  $mlw_delete_results_results = $wpdb->query( $mlw_delete_results_update_sql );
23
+ if ($mlw_delete_results_results != false)
24
+ {
25
+ $mlwQmnAlertManager->newAlert('Your results has been deleted successfully.', 'success');
26
 
27
+ //Insert Action Into Audit Trail
28
+ global $current_user;
29
+ get_currentuserinfo();
30
+ $table_name = $wpdb->prefix . "mlw_qm_audit_trail";
31
+ $insert = "INSERT INTO " . $table_name .
32
+ "(trail_id, action_user, action, time) " .
33
+ "VALUES (NULL , '" . $current_user->display_name . "' , 'Results Has Been Deleted From: ".$mlw_delete_results_name."' , '" . date("h:i:s A m/d/Y") . "')";
34
+ $results = $wpdb->query( $insert );
35
+ }
36
+ else
37
+ {
38
+ $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0021.', 'error');
39
+ }
40
  }
41
 
42
  global $wpdb;
138
  <div class="wrap">
139
  <div class='mlw_quiz_options'>
140
  <h2>Quiz Results<a id="opener" href="">(?)</a></h2>
 
 
 
 
 
 
 
 
 
 
141
  <?php
142
+ $mlwQmnAlertManager->showAlerts();
143
+
144
  $quotes_list = "";
145
  $display = "";
146
  $alternate = "";
147
  foreach($mlw_quiz_data as $mlw_quiz_info) {
148
  if($alternate) $alternate = "";
149
  else $alternate = " class=\"alternate\"";
150
+ $mlw_complete_time = '';
151
+ $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
152
+ if (is_array($mlw_qmn_results_array))
153
+ {
154
+ $mlw_complete_minutes = floor($mlw_qmn_results_array[0] / 60);
155
+ if ($mlw_complete_minutes > 0)
156
+ {
157
+ $mlw_complete_time .= "$mlw_complete_minutes minutes ";
158
+ }
159
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
160
+ $mlw_complete_time .= "$mlw_complete_seconds seconds";
161
+ }
162
+
163
  $quotes_list .= "<tr{$alternate}>";
164
  $quotes_list .= "<td><span style='color:green;font-size:16px;'><a href='admin.php?page=mlw_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a>|<a onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></td>";
165
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span></td>";
175
  {
176
  $quotes_list .= "<td><span style='font-size:16px;'>Not Graded</span></td>";
177
  }
178
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_complete_time ."</span></td>";
179
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
180
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
181
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->email ."</span></td>";
211
  <th>Actions</th>
212
  <th>Quiz Name</th>
213
  <th>Score</th>
214
+ <th>Time To Complete</th>
215
  <th>Name</th>
216
  <th>Business</th>
217
  <th>Email</th>
includes/mlw_results_details.php CHANGED
@@ -133,6 +133,10 @@ EOC;
133
  <div id="tabs-1">
134
  <h2>Quiz Results From <?php echo $mlw_results_data->quiz_name; ?></h2>
135
  <table>
 
 
 
 
136
  <tr>
137
  <td>Name Provided: </td>
138
  <td><?php echo $mlw_results_data->name; ?></td>
@@ -181,8 +185,16 @@ EOC;
181
  }
182
  else
183
  {
 
 
 
 
 
 
 
 
184
  ?>
185
- This quiz was completed in <?php echo $mlw_qmn_results_array[0]; ?> seconds.<br />
186
  <br />
187
  The comments entered into the comment box (if enabled):<br />
188
  <?php echo $mlw_qmn_results_array[2]; ?><br />
133
  <div id="tabs-1">
134
  <h2>Quiz Results From <?php echo $mlw_results_data->quiz_name; ?></h2>
135
  <table>
136
+ <tr>
137
+ <td>Time Taken: </td>
138
+ <td><?php echo $mlw_results_data->time_taken; ?></td>
139
+ </tr>
140
  <tr>
141
  <td>Name Provided: </td>
142
  <td><?php echo $mlw_results_data->name; ?></td>
185
  }
186
  else
187
  {
188
+ $mlw_complete_time = '';
189
+ $mlw_complete_minutes = floor($mlw_qmn_results_array[0] / 60);
190
+ if ($mlw_complete_minutes > 0)
191
+ {
192
+ $mlw_complete_time .= "$mlw_complete_minutes minutes ";
193
+ }
194
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
195
+ $mlw_complete_time .= "$mlw_complete_seconds seconds";
196
  ?>
197
+ This quiz was completed in <?php echo $mlw_complete_time; ?>.<br />
198
  <br />
199
  The comments entered into the comment box (if enabled):<br />
200
  <?php echo $mlw_qmn_results_array[2]; ?><br />
includes/mlw_update.php CHANGED
@@ -6,7 +6,7 @@ function mlw_quiz_update()
6
  {
7
 
8
  //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
9
- $data = "3.3.2";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
@@ -340,4 +340,4 @@ function mlw_quiz_update()
340
  add_option('mlw_advert_shows' , 'true');
341
  }
342
  }
343
- ?>
6
  {
7
 
8
  //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not.
9
+ $data = "3.4.1";
10
  if ( ! get_option('mlw_quiz_master_version'))
11
  {
12
  add_option('mlw_quiz_master_version' , $data);
340
  add_option('mlw_advert_shows' , 'true');
341
  }
342
  }
343
+ ?>
mlw_quizmaster2.php CHANGED
@@ -1,193 +1,194 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: Quiz Master Next
5
- Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
- Version: 3.3.3
7
- Author: Frank Corso
8
- Author URI: http://www.mylocalwebstop.com/
9
- Plugin URI: http://www.mylocalwebstop.com/
10
- */
11
-
12
- /*
13
- Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
14
-
15
- Disclaimer of Warranties.
16
-
17
- The plugin is provided "as is". My Local Webstop and its suppliers and licensors hereby disclaim all warranties of any kind,
18
- express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose and non-infringement.
19
- Neither My Local Webstop nor its suppliers and licensors, makes any warranty that the plugin will be error free or that access thereto will be continuous or uninterrupted.
20
- You understand that you install, operate, and unistall the plugin at your own discretion and risk.
21
- */
22
-
23
-
24
- ///Files to Include
25
- include("includes/mlw_quiz.php");
26
- include("includes/mlw_dashboard.php");
27
- include("includes/mlw_quiz_admin.php");
28
- include("includes/mlw_quiz_options.php");
29
- include("includes/mlw_quiz_install.php");
30
- include("includes/mlw_results.php");
31
- include("includes/mlw_results_details.php");
32
- include("includes/mlw_tools.php");
33
- include("includes/mlw_leaderboard.php");
34
- include("includes/mlw_update.php");
35
- include("includes/mlw_qmn_widgets.php");
36
- include("includes/mlw_qmn_credits.php");
37
-
38
-
39
- ///Activation Actions
40
- add_action('admin_menu', 'mlw_add_menu');
41
- add_action('admin_init', 'mlw_quiz_update');
42
- add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
43
- add_shortcode('mlw_quizmaster', 'mlw_quiz_shortcode');
44
- add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
45
- register_activation_hook( __FILE__, 'mlw_quiz_activate');
46
- register_deactivation_hook( __FILE__, 'mlw_quiz_deactivate');
47
-
48
- //Setup Translations
49
- function mlw_qmn_translation_setup() {
50
- load_plugin_textdomain( 'mlw_qmn_text_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
51
- }
52
- add_action('plugins_loaded', 'mlw_qmn_translation_setup');
53
-
54
-
55
- ///Create Admin Pages
56
- function mlw_add_menu()
57
- {
58
- if (function_exists('add_menu_page'))
59
- {
60
- add_menu_page('Quiz Master Next', 'Quiz Dashboard', 'moderate_comments', __FILE__, 'mlw_generate_quiz_dashboard', 'dashicons-feedback');
61
- add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 'moderate_comments', 'mlw_quiz_admin', 'mlw_generate_quiz_admin');
62
- add_submenu_page(__FILE__, 'Quiz Settings', 'Quiz Settings', 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
63
- add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
64
- add_submenu_page(__FILE__, 'Quiz Result Details', 'Quiz Result Details', 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
65
- add_submenu_page(__FILE__, 'Tools', 'Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
66
- add_submenu_page(__FILE__, 'QMN About', 'QMN About', 'manage_options', 'mlw_qmn_about', 'mlw_generate_about_page');
67
- }
68
- }
69
-
70
-
71
- //Admin Notice
72
- add_action('admin_notices', 'mlw_qmn_notice');
73
- function mlw_qmn_notice() {
74
- if ( get_option('mlw_qmn_review_notice') == 1 && current_user_can( 'manage_options' ) )
75
- {
76
- echo "
77
- <style>
78
- div.help_decide
79
- {
80
- display: block;
81
- text-align:center;
82
- letter-spacing: 1px;
83
- margin: auto;
84
- text-shadow: 0 1px 1px #000000;
85
- background: #0d97d8;
86
- border: 5px solid #106daa;
87
- -moz-border-radius: 20px;
88
- -webkit-border-radius: 20px;
89
- -khtml-border-radius: 20px;
90
- border-radius: 20px;
91
- color: #FFFFFF;
92
- }
93
- div.help_decide a
94
- {
95
- color: yellow;
96
- }
97
- </style>";
98
- echo '<div class="help_decide"><p>';
99
- printf(__('You have been using the Quiz Master Next plugin for a while now! Thanks for choosing to use this plugin. If it has benefited your website, please consider purchasing an <a href="http://mylocalwebstop.com/shop/">add-on</a>, giving a <a href="http://wordpress.org/support/view/plugin-reviews/quiz-master-next">review</a>, or taking this <a href="http://mylocalwebstop.com/sample-survey/" target="_blank">survey</a>. | <a href="%1$s">Hide Notice</a>'), '?page=quiz-master-next/mlw_quizmaster2.php&&mlw_qmn_ignore_notice=0');
100
- echo "</p></div>";
101
- }
102
- }
103
- //Check to see if notices should be shown or dismissed
104
- add_action('admin_init', 'mlw_qmn_notice_ignore');
105
- function mlw_qmn_notice_ignore() {
106
- global $wpdb;
107
- if ( ! get_option('mlw_qmn_review_notice'))
108
- {
109
- add_option('mlw_qmn_review_notice' , '0');
110
- }
111
- if ($wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results" ) >= 20 && get_option('mlw_qmn_review_notice') == 0)
112
- {
113
- update_option('mlw_qmn_review_notice' , '1');
114
- }
115
- if ( isset($_GET['mlw_qmn_ignore_notice']) && '0' == $_GET['mlw_qmn_ignore_notice'] ) {
116
- update_option('mlw_qmn_review_notice' , '2');
117
- }
118
- }
119
- function mlw_qmn_show_adverts()
120
- {
121
- $mlw_advert = "";
122
- $mlw_advert_text = "";
123
- if ( get_option('mlw_advert_shows') == 'true' )
124
- {
125
- $mlw_random_int = rand(0, 8);
126
- switch ($mlw_random_int) {
127
- case 0:
128
- $mlw_advert_text = "Need support or features? Check out our Premium Support options! Visit our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for details!";
129
- break;
130
- case 1:
131
- $mlw_advert_text = "Is Quiz Master Next beneficial to your website? Please help by giving us a review on WordPress.org by going <a href=\"http://wordpress.org/support/view/plugin-reviews/quiz-master-next\">here</a>!";
132
- break;
133
- case 2:
134
- $mlw_advert_text = "Want help installing and configuring one of our plugins? Check out our Plugin Installation services. Visit our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for details!";
135
- break;
136
- case 3:
137
- $mlw_advert_text = "Would you like to support this plugin but do not need or want premium support? Please consider our inexpensive 'Advertisements Be Gone' add-on which will get rid of these ads. Visit our <a href=\"http://mylocalwebstop.com/shop/\">Plugin Add-On Store</a> for details!";
138
- break;
139
- case 4:
140
- $mlw_advert_text = "Need to be able to export the results of your quizzes? Be sure to check out our new Export Results add-on in our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a>!";
141
- break;
142
- case 5:
143
- $mlw_advert_text = "Need help keeping your plugins, themes, and WordPress up to date? Want around the clock security monitoring and off-site back-ups? How about WordPress training videos, a monthly status report, and support/consultation? Check out our <a href=\"http://mylocalwebstop.com/wordpress-maintenance-services/\">WordPress Maintenance Services</a> for more details!";
144
- break;
145
- case 6:
146
- $mlw_advert_text = "Setting up a new site? Let us take care of the set-up so you back to running your business. Check out our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for more details!";
147
- break;
148
- case 7:
149
- $mlw_advert_text = "Need a page so your users can see their results from all the quizzes they have taken? Try our new User Dashboard add-on. Check out our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for more details!";
150
- break;
151
- case 8:
152
- $mlw_advert_text = "Our new Popular Add-On Pack is now only $45 for 6 add-ons! Now is the time to save almost 50%! Visit our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for details.";
153
- break;
154
- default:
155
- $mlw_advert_text = "Need support or features? Check out our Premium Support options! Visit our <a href=\"http://mylocalwebstop.com/shop/\">Plugin Add-On Store</a> for details!";
156
- }
157
- $mlw_advert .= "
158
- <style>
159
- div.help_decide
160
- {
161
- display: block;
162
- text-align:center;
163
- letter-spacing: 1px;
164
- margin: auto;
165
- text-shadow: 0 1px 1px #000000;
166
- background: #0d97d8;
167
- border: 5px solid #106daa;
168
- -moz-border-radius: 20px;
169
- -webkit-border-radius: 20px;
170
- -khtml-border-radius: 20px;
171
- border-radius: 20px;
172
- color: #FFFFFF;
173
- }
174
- div.help_decide a
175
- {
176
- color: yellow;
177
- }
178
- </style>";
179
- $mlw_advert .= "
180
- <div class=\"help_decide\">
181
- <p>$mlw_advert_text</p>
182
- </div>";
183
- }
184
- return $mlw_advert;
185
- }
186
-
187
-
188
-
189
- /*
190
-
191
-
192
- */
193
- ?>
 
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: Quiz Master Next
5
+ Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
6
+ Version: 3.4.1
7
+ Author: Frank Corso
8
+ Author URI: http://www.mylocalwebstop.com/
9
+ Plugin URI: http://www.mylocalwebstop.com/
10
+ */
11
+
12
+ /*
13
+ Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com)
14
+
15
+ Disclaimer of Warranties.
16
+
17
+ The plugin is provided "as is". My Local Webstop and its suppliers and licensors hereby disclaim all warranties of any kind,
18
+ express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose and non-infringement.
19
+ Neither My Local Webstop nor its suppliers and licensors, makes any warranty that the plugin will be error free or that access thereto will be continuous or uninterrupted.
20
+ You understand that you install, operate, and unistall the plugin at your own discretion and risk.
21
+ */
22
+
23
+
24
+ ///Files to Include
25
+ include("includes/mlw_alerts.php");
26
+ include("includes/mlw_quiz.php");
27
+ include("includes/mlw_dashboard.php");
28
+ include("includes/mlw_quiz_admin.php");
29
+ include("includes/mlw_quiz_options.php");
30
+ include("includes/mlw_quiz_install.php");
31
+ include("includes/mlw_results.php");
32
+ include("includes/mlw_results_details.php");
33
+ include("includes/mlw_tools.php");
34
+ include("includes/mlw_leaderboard.php");
35
+ include("includes/mlw_update.php");
36
+ include("includes/mlw_qmn_widgets.php");
37
+ include("includes/mlw_qmn_credits.php");
38
+
39
+
40
+ ///Activation Actions
41
+ add_action('admin_menu', 'mlw_add_menu');
42
+ add_action('admin_init', 'mlw_quiz_update');
43
+ add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
44
+ add_shortcode('mlw_quizmaster', 'mlw_quiz_shortcode');
45
+ add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
46
+ register_activation_hook( __FILE__, 'mlw_quiz_activate');
47
+ register_deactivation_hook( __FILE__, 'mlw_quiz_deactivate');
48
+
49
+ //Setup Translations
50
+ function mlw_qmn_translation_setup() {
51
+ load_plugin_textdomain( 'mlw_qmn_text_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
52
+ }
53
+ add_action('plugins_loaded', 'mlw_qmn_translation_setup');
54
+
55
+
56
+ ///Create Admin Pages
57
+ function mlw_add_menu()
58
+ {
59
+ if (function_exists('add_menu_page'))
60
+ {
61
+ add_menu_page('Quiz Master Next', 'Quiz Dashboard', 'moderate_comments', __FILE__, 'mlw_generate_quiz_dashboard', 'dashicons-feedback');
62
+ add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 'moderate_comments', 'mlw_quiz_admin', 'mlw_generate_quiz_admin');
63
+ add_submenu_page(__FILE__, 'Quiz Settings', 'Quiz Settings', 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
64
+ add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
65
+ add_submenu_page(__FILE__, 'Quiz Result Details', 'Quiz Result Details', 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
66
+ add_submenu_page(__FILE__, 'Tools', 'Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
67
+ add_submenu_page(__FILE__, 'QMN About', 'QMN About', 'manage_options', 'mlw_qmn_about', 'mlw_generate_about_page');
68
+ }
69
+ }
70
+
71
+
72
+ //Admin Notice
73
+ add_action('admin_notices', 'mlw_qmn_notice');
74
+ function mlw_qmn_notice() {
75
+ if ( get_option('mlw_qmn_review_notice') == 1 && current_user_can( 'manage_options' ) )
76
+ {
77
+ echo "
78
+ <style>
79
+ div.help_decide
80
+ {
81
+ display: block;
82
+ text-align:center;
83
+ letter-spacing: 1px;
84
+ margin: auto;
85
+ text-shadow: 0 1px 1px #000000;
86
+ background: #0d97d8;
87
+ border: 5px solid #106daa;
88
+ -moz-border-radius: 20px;
89
+ -webkit-border-radius: 20px;
90
+ -khtml-border-radius: 20px;
91
+ border-radius: 20px;
92
+ color: #FFFFFF;
93
+ }
94
+ div.help_decide a
95
+ {
96
+ color: yellow;
97
+ }
98
+ </style>";
99
+ echo '<div class="help_decide"><p>';
100
+ printf(__('You have been using the Quiz Master Next plugin for a while now! Thanks for choosing to use this plugin. If it has benefited your website, please consider purchasing an <a href="http://mylocalwebstop.com/shop/">add-on</a>, giving a <a href="http://wordpress.org/support/view/plugin-reviews/quiz-master-next">review</a>, or taking this <a href="http://mylocalwebstop.com/sample-survey/" target="_blank">survey</a>. | <a href="%1$s">Hide Notice</a>'), '?page=quiz-master-next/mlw_quizmaster2.php&&mlw_qmn_ignore_notice=0');
101
+ echo "</p></div>";
102
+ }
103
+ }
104
+ //Check to see if notices should be shown or dismissed
105
+ add_action('admin_init', 'mlw_qmn_notice_ignore');
106
+ function mlw_qmn_notice_ignore() {
107
+ global $wpdb;
108
+ if ( ! get_option('mlw_qmn_review_notice'))
109
+ {
110
+ add_option('mlw_qmn_review_notice' , '0');
111
+ }
112
+ if ($wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_results" ) >= 20 && get_option('mlw_qmn_review_notice') == 0)
113
+ {
114
+ update_option('mlw_qmn_review_notice' , '1');
115
+ }
116
+ if ( isset($_GET['mlw_qmn_ignore_notice']) && '0' == $_GET['mlw_qmn_ignore_notice'] ) {
117
+ update_option('mlw_qmn_review_notice' , '2');
118
+ }
119
+ }
120
+ function mlw_qmn_show_adverts()
121
+ {
122
+ $mlw_advert = "";
123
+ $mlw_advert_text = "";
124
+ if ( get_option('mlw_advert_shows') == 'true' )
125
+ {
126
+ $mlw_random_int = rand(0, 8);
127
+ switch ($mlw_random_int) {
128
+ case 0:
129
+ $mlw_advert_text = "Need support or features? Check out our Premium Support options! Visit our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for details!";
130
+ break;
131
+ case 1:
132
+ $mlw_advert_text = "Is Quiz Master Next beneficial to your website? Please help by giving us a review on WordPress.org by going <a href=\"http://wordpress.org/support/view/plugin-reviews/quiz-master-next\">here</a>!";
133
+ break;
134
+ case 2:
135
+ $mlw_advert_text = "Want help installing and configuring one of our plugins? Check out our Plugin Installation services. Visit our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for details!";
136
+ break;
137
+ case 3:
138
+ $mlw_advert_text = "Would you like to support this plugin but do not need or want premium support? Please consider our inexpensive 'Advertisements Be Gone' add-on which will get rid of these ads. Visit our <a href=\"http://mylocalwebstop.com/shop/\">Plugin Add-On Store</a> for details!";
139
+ break;
140
+ case 4:
141
+ $mlw_advert_text = "Need to be able to export the results of your quizzes? Be sure to check out our new Export Results add-on in our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a>!";
142
+ break;
143
+ case 5:
144
+ $mlw_advert_text = "Need help keeping your plugins, themes, and WordPress up to date? Want around the clock security monitoring and off-site back-ups? How about WordPress training videos, a monthly status report, and support/consultation? Check out our <a href=\"http://mylocalwebstop.com/wordpress-maintenance-services/\">WordPress Maintenance Services</a> for more details!";
145
+ break;
146
+ case 6:
147
+ $mlw_advert_text = "Setting up a new site? Let us take care of the set-up so you back to running your business. Check out our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for more details!";
148
+ break;
149
+ case 7:
150
+ $mlw_advert_text = "Need a page so your users can see their results from all the quizzes they have taken? Try our new User Dashboard add-on. Check out our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for more details!";
151
+ break;
152
+ case 8:
153
+ $mlw_advert_text = "Our new Popular Add-On Pack is now only $45 for 6 add-ons! Now is the time to save almost 50%! Visit our <a href=\"http://mylocalwebstop.com/shop/\">WordPress Store</a> for details.";
154
+ break;
155
+ default:
156
+ $mlw_advert_text = "Need support or features? Check out our Premium Support options! Visit our <a href=\"http://mylocalwebstop.com/shop/\">Plugin Add-On Store</a> for details!";
157
+ }
158
+ $mlw_advert .= "
159
+ <style>
160
+ div.help_decide
161
+ {
162
+ display: block;
163
+ text-align:center;
164
+ letter-spacing: 1px;
165
+ margin: auto;
166
+ text-shadow: 0 1px 1px #000000;
167
+ background: #0d97d8;
168
+ border: 5px solid #106daa;
169
+ -moz-border-radius: 20px;
170
+ -webkit-border-radius: 20px;
171
+ -khtml-border-radius: 20px;
172
+ border-radius: 20px;
173
+ color: #FFFFFF;
174
+ }
175
+ div.help_decide a
176
+ {
177
+ color: yellow;
178
+ }
179
+ </style>";
180
+ $mlw_advert .= "
181
+ <div class=\"help_decide\">
182
+ <p>$mlw_advert_text</p>
183
+ </div>";
184
+ }
185
+ return $mlw_advert;
186
+ }
187
+
188
+
189
+
190
+ /*
191
+
192
+
193
+ */
194
+ ?>
readme.txt CHANGED
@@ -1,717 +1,730 @@
1
- === Quiz Master Next ===
2
- Contributors: fpcorso
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RTGYAETX36ZQJ
4
- Tags: quiz, test, score, exam, survey, contact, form, email, answer, question
5
- Requires at least: 3.8.1
6
- Tested up to: 4.0
7
- Stable tag: 3.3.3
8
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
-
10
- The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website.
11
-
12
- == Description ==
13
-
14
- The easiest and most flexible way to add multiple quizzes, tests, surveys, and contact forms to your website. This plugin allows for unlimited quizzes each with unlimited amount of questions. The plugin allows you to create the quiz, add it to any page using a customized shortcode, allows the user to take the quiz, and then saves the results. You can set up what the user sees after he or she takes the quiz based on the user's score. You can also have the plugin create a certificate for the user as well!
15
-
16
- = Have Unlimted Quizzes, Tests, Surveys, Contact Forms, etc.. =
17
- Each of your quizzes can have **unlimited** questions and each of those questions can have **unlimited** answers! Your questions can contain **HTML** to show images, Youtube videos and more.
18
-
19
- = Customize Your Text =
20
- All the text your users see can be **customized**. Everything from the text blocks throughout the quiz to the submit button.
21
-
22
- = Different Types Of Questions =
23
- You can have **multiple choice** (radio buttons), **true and false**, **open answer** question, **drop down**, **multiple response** (checkboxes), **number**, **captcha**, and **accept**. More types are being supported in future updates!
24
-
25
- = Mulitple Landing Pages For Each Quiz =
26
- Each quiz can have **unlimited** results pages that can be customized with your text. Show different results pages based on the users score!
27
-
28
- = Emails After Completion Of Quiz =
29
- After the user takes a quiz, you can have the plugin email you and the user with results. This too can be customized with your own text.
30
-
31
- = Very Flexible =
32
- Your quiz can be graded with an incorrect/correct system or a points-based system. Or not at all. You ask for contact information at the beginning or the end and you decide which contact fields are required. You can decide to use all the questions or only a select few chosen at random. You can also set the number of questions per page or have all the questions on one page.
33
-
34
- = Useful For Businesses =
35
- The plugin features useful **statistics** that show how many times each quiz has been viewed and taken and plots the data on several different **graphs** so you can see how the quizzes are doing at a glance. Also, the plugin includes an **audit trail** that logs every action done on the admin side so you can keep up with who is doing what!
36
-
37
- = Saves The Results For Later Use =
38
- The plugin will **save** the results, the user's answers, the user's comments, and more!
39
-
40
- = Other Useful Features =
41
-
42
- * Allow the user to share the results on *social networks*
43
- * Show all questions on one page or have only one question per page
44
- * Allows for you to create **certificates** for the user
45
- * Can set amount of tries a user has to take the quiz
46
- * Can enable **comment boxes** for each question and/or comment section at the end of the quiz
47
- * Can enable **hints** for questions
48
- * Can show user why the answer is the correct answer
49
- * Questions can be in predetermined order or random
50
- * **Leaderboards** for every quiz which can be used as shortcode or in included widget
51
- * Keep track how long a user takes on the quiz
52
- * Able to set up time limits on the quiz
53
- * And **Much** More...
54
-
55
- = Quiz Master Next Add-ons =
56
- While Quiz Master Next is fully functional and is packed full of features that will meet the needs of most, we do offer vaious extra features and support available in our [Wordpress Store](http://mylocalwebstop.com/shop/)
57
-
58
-
59
- == Installation ==
60
-
61
- We now offer an installation service to assist you in this process. We will install any or all of our plugins and spend up to 2 hours with you for consultaion and training. Visit our website for details.
62
- [My Local Webstop Plugin Installation](http://mylocalwebstop.com/product/plugin-installation/)
63
-
64
- **Or**
65
-
66
- * Navigate to Add New Plugin page within your WordPress
67
- * Search for Quiz Master Next
68
- * Click Install Now link on the plugin and follow the prompts
69
- * Activate the plugin through the 'Plugins' menu in WordPress
70
-
71
- **Or**
72
-
73
- * Upload plugin dir to the `/wp-content/plugins/` directory
74
- * Activate the plugin through the 'Plugins' menu in WordPress
75
-
76
-
77
- == Frequently Asked Questions ==
78
-
79
- = What does the option do on that page? =
80
- On each page, there is a "?" next to the page title. Clicking on it will bring up a small help window that will assist you on that page.
81
-
82
- = How do you use that feature? =
83
- We have begun creating documentation for the plugin. You can view the documentation here: [Documentation](http://mylocalwebstop.com/plugin-documentation/) If you still have any trouble, feel free to use the widget on the quiz dashboard within the plugin to contact me and I will help you.
84
-
85
- = I need a lot of help setting up my quiz, what can you do to help? =
86
- We now offer a premium support plan that offers priority response, priority feature requests, and 1-on-1 training! For details, visit our services page: [My Local Webstop Services](http://mylocalwebstop.com/product/plugin-premium-support/)
87
-
88
- = Do you offer any 1-on-1 training to assist me in using this plugin? =
89
- We now offer an installation service that includes 1-on-1 training as well as a premium support that offers 1-on-1 training. For details, visit our [Wordpress Store](http://mylocalwebstop.com/shop/)
90
-
91
- = I have an idea, how do I contact you? =
92
- Feel free to use the widget on the quiz dashboard within the plugin or from the contact page at mylocalwebstop.com.
93
-
94
- == Screenshots ==
95
-
96
- 1. Quiz Admin Page (With Advertisement Be Gone Add-On)
97
- 2. Quiz Options Page (With Advertisement Be Gone Add-On)
98
- 3. Quiz Dashboard Page (With Advertisement Be Gone Add-On)
99
- 4. Example Quiz
100
- 5. Example Survey
101
- 6. Quiz Results Page
102
- 7. Example Contact Form
103
- 8. Example Quiz With Styling
104
-
105
- == Changelog ==
106
-
107
- = 3.3.3 (November 14, 2014) =
108
- * Minor Backend Change To Quiz Validation
109
- * Disabled Enter Key On Quiz
110
- * Minor Bug Fixes
111
-
112
- = 3.3.2 (October 26, 2014) =
113
- * Minor Design Change To Quiz Options
114
-
115
- = 3.3.1 (October 15, 2014) =
116
- * Added Horizontal Multiple Response Question Type
117
- * Added Ability To Duplicate Questions When Duplicate Quizzes
118
- * Added Last Modified Column To Table On Quizzes Page
119
- * Fixed Number Question Type Grading Bug
120
- * Fixed Missing theme_selected Column Installation Bug
121
- * Fixed Missing theme_selected Column Duplication Bug
122
- * Fixed Numerous Small Bugs
123
-
124
- = 3.2.2 (October 4, 2014) =
125
- * Minor Bug Fixes
126
-
127
- = 3.2.1 (October 2, 2014) =
128
- * Added New Captcha Question Type
129
- * Fixed Number Question Type Validation Bug
130
- * Fixed Validation Wrong Border Bug
131
-
132
- = 3.1.1 (September 15, 2014) =
133
- * Added Ability To Duplicate Individual Questions
134
- * Added Ability To Require Accept, Number, And Open Answer Question Types
135
- * Added Number Question Type
136
- * Added Accept Non-Question Type
137
-
138
- = 3.0.1 (August 28, 2014) =
139
- * Added New Style Manager
140
- * Added Ability For Non-Question Question Types
141
- * Added New Text Block Question Type
142
- * Added Question Type Column To Question List
143
- * Minor Design Changes To Quiz Questions Tab
144
- * Fixed Results Delete Link Not Working Bug
145
- * Fixed Quiz Name Showing Escaped Values Bug
146
-
147
- = 2.9.1 (August 11, 2014) =
148
- * Added Facebook Sharing
149
- * Added Ability To Edit Email Subject
150
- * Added Large Open Answer Question Type
151
- * Added Ability For Points To Have Decimal Values
152
- * Fixed Not All Questions Showing In Results Bug
153
- * Fixed Not Valid Email On Non-Required Email Bug
154
- * Fixed Special Character Not Grading Properly In Open Answer Bug
155
-
156
- = 2.8.5 (August 9, 2014) =
157
- * Minor Bug Fixes
158
- * Minor Design Tweaks To About Page
159
-
160
- = 2.8.4 (August 3, 2014) =
161
- * Minor Bug Fixes
162
-
163
- = 2.8.3 (June 8, 2014) =
164
- * Next/Previous Buttons Now Scroll Page To Top Of Quiz
165
- * Minor Bug Fixes
166
-
167
- = 2.8.2 (May 28, 2014) =
168
- * Minor Bug Fixes
169
-
170
- = 2.8.1 (May 26, 2014) =
171
- * Took Out Help Related Tool Tips
172
- * Design Changes To Quiz Text Tab For Easier Navigation
173
- * Deleted How-To Page, Please Use Documentation On Our Website
174
- * Renamed Quiz Options Page As Quiz Settings To Avoid Confusion With Quiz Options Tab
175
-
176
- = 2.7.3 (May 19, 2014) =
177
- * Fixed Open Answer Not Showing Correct Answer Bug
178
-
179
- = 2.7.2 (May 18, 2014) =
180
- * Fixed Timer Not Restarting Bug
181
- * Fixed Tooltip Affecting Whole Page Bug
182
-
183
- = 2.7.1 (May 16, 2014) =
184
- * Added Ability To Set Number Of Question Per Page
185
- * Fixed HTML Not Showing On Results Page Bug
186
- * Fixed Timer Not Disabling New Fields Bug
187
- * Fixed Timer Submitting Disabled Fields Bug
188
-
189
- = 2.6.4 (May 12, 2014) =
190
- * Bug Fixes
191
-
192
- = 2.6.3 (May 9, 2014) =
193
- * Bug Fixes
194
-
195
- = 2.6.2 (May 8, 2014) =
196
- * Bug Fixes
197
-
198
- = 2.6.1 (May 7, 2014) =
199
- * Added UTF-8 Support For Special Characters And Non-Latin Languages
200
- * Fixed Question Bank Showing All Answers Bug
201
-
202
- = 2.5.1 (May 3, 2014) =
203
- * Rebuilt Answer System
204
- * Added Ability To Have Unlimited Answers
205
- * Added Ability To Randomize Answers
206
- * Added New Question Type - Multiple Response (Checkboxes)
207
- * Added Ability To Send Admin Email To Multiple Users
208
- * Minor Design Changes To Quiz Options Page
209
-
210
- = 2.4.1 (April 20, 2014) =
211
- * Added New Quiz Emails Tab
212
- * Added Ability To Send Different Emails To Users Based On Score
213
- * Fixed Required Question Bug
214
- * Fixed Landing Page Bug
215
-
216
- = 2.3.1 (April 6, 2014) =
217
- * Added Ability To Have Graded Open Answer Questions
218
- * Minor Design Changes
219
-
220
- = 2.2.2 (March 30, 2014) =
221
- * Reverted To Previous Pagination Javascript
222
-
223
- = 2.2.1 (March 30, 2014) =
224
- * Added Ability To Show Question Numbers
225
- * Added More CSS Classes To Quiz Page For Better Styling Options
226
- * Changed Timer To Disable Fields Instead Of Submit Form When Time Is Up
227
- * Fixed Pagination Javascript Bug
228
- * Minor Design Change To Quiz
229
- * Minor Design Change To Quiz Options Page
230
-
231
- = 2.1.1 (March 26, 2014) =
232
- * Added Ability To Edit Style For Each Quiz
233
- * Fixed Tried Quiz Too Many Times Text Bug
234
- * Fixed Dashboard Quartely Widget Bug
235
- * Minor Design Changes To Quiz Options Page
236
-
237
- = 2.0.1 (March 22, 2014) =
238
- * Added Pagination On Quiz Results Page
239
- * Redesigned Results Detail Page
240
- * Fixed PHP Notice On Quizzes Page
241
- * Allow HTML/CSS in Landing Pages
242
-
243
- = 1.9.6 (March 19, 2014) =
244
- * Fixed Duplicate Quiz Bug
245
- * Fixed Uneditable Question Bug
246
- * Fixed Parse Bug
247
- * Made Email Now Send As HTML
248
-
249
- = 1.9.5 (March 18, 2014) =
250
- * Fixed Bug
251
-
252
- = 1.9.4 (March 18, 2014) =
253
- * Fixed Bug
254
-
255
- = 1.9.3 (March 17, 2014) =
256
- * Fixed Bug: Unexpected T_CONSTANT_ENCAPSED_STRING When Activating
257
-
258
- = 1.9.2 (March 17, 2014) =
259
- * Added Ability To Delete Landing Pages
260
- * Added Ability To Have HTML In Correct Answer Info Field
261
- * Added Previous Question Button To Paginated Quiz
262
- * Minor Design Changes To Quiz
263
- * Add Timer To Title Bar
264
- * Added %CURRENT_DATE% field
265
-
266
- = 1.9.1 (March 13, 2014) =
267
- * Added Ability To Show One Question At A Time Instead Of All At Once
268
- * Added Ability To Allow Users To Share Results On Twitter
269
- * Added Ability To Set Time Limits On Quiz
270
- * Minor Design Changes To Quiz
271
- * Minor Bug Fixes
272
-
273
- = 1.8.2 (March 11, 2014) =
274
- * Minor Bug Fixes
275
-
276
- = 1.8.1 (March 10, 2014) =
277
- * Added Customizable Text Section At End Of Quiz
278
- * Added Ability To Set Up Different Landing Pages Based On Score
279
- * Added Ability To Give Certificate After Quiz
280
- * Enhanced Quiz Total Stats Widget
281
- * Minor Design Changes To Quiz
282
- * Fixed Session_Start Bug
283
- * Fixed Division By Zero Bug
284
- * Fixed Total Stats Deleted Bug
285
- * Fixed Dashboard Rounding Bug
286
- * Fixed Notice Unknown Company Field Bug
287
-
288
-
289
- = 1.7.1 (March 6, 2014) =
290
- * Added Several New Widgets To Quiz Dashboard
291
- * Added A Timer Mechanism To Track How Long User Takes On Quiz
292
- * Added New About Update Page
293
- * Fixed Saving Results Bug
294
- * Fixed Random Number On Quiz Options Page Bug
295
-
296
- = 1.6.3 (March 5, 2014) =
297
- * Fixed Duplicated Shortcode Bug
298
- * Quiz Dashboard Design Changes
299
-
300
- = 1.6.2 (March 4, 2014) =
301
- * Minor Bug Fixes
302
- * Minor Design Changes
303
-
304
- = 1.6.1 (March 2, 2014) =
305
- * Added Ability To Limit Amount User Tries Certain Quizzes
306
- * Fixed Internet Explorer Quiz Adding Bug
307
- * Fixed Results Link On Quizzes Page Bug
308
- * Fixed Points Number Check Bug
309
- * Fixed Limited Question Grading Bug
310
- * Minor Design Changes To Admin Pages
311
-
312
- = 1.5.1 (February 26, 2014) =
313
- * Added Ability To Load Only Set Amount Of Questions From Total Questions
314
- * Fixed PHP Notices On Quizzes Page
315
- * Fixed PHP Notices On Quiz Options Page
316
- * Fixed PHP Notices On Quiz Results Page
317
- * Fixed PHP Notices On Quiz
318
- * Fixed Hidden Pop-Up Bug
319
-
320
- = 1.4.2 (February 22, 2014) =
321
- * Fixed Capability Bug
322
- * Minor Design Changes To Question Form
323
- * Hint Bubble Is Now Wider For Longer Hints
324
- * Minor Design Change To Quiz
325
-
326
- = 1.4.1 (February 20, 2014) =
327
- * Enhanced Plugins Compatibility With Other Plugins
328
- * Hints Are Now Hidden By Default
329
- * Minor Bug Fixes
330
-
331
- = 1.3.1 (February 18, 2014) =
332
- * Added Ability To Choose Whether Logged-in Users Can Enter Contact Info
333
- * Fixed Editing Hint Field Error
334
- * Added Ability To Have Media In Answers
335
- * Added Ability To Have HTML In Questions And Answers
336
-
337
- = 1.2.1 (February 11, 2014) =
338
- * Fixed Quiz Results Details Bug
339
- * Continued Working On New Error Code System
340
- * Added Pagination To Tools Page, Quizzes Page And List Of Questions On Quiz Options Page
341
- * Added Ability To Create A Duplicate Of A Quiz
342
-
343
- = 1.1.1 (February 6, 2014) =
344
- * Added %AVERAGE_POINT% Variable That Calculates Average Points Per Question
345
- * Added Field For Reason Why Answer Is Correct
346
- * Added %CORRECT_ANSWER_INFO% To Display Why Answer Is Correct
347
- * Begun Creating New Error Code System
348
- * Fixed Edit Quiz Name Bug
349
- * Fixed New Quiz Bug
350
-
351
- = 1.0.1 (February 4, 2014) =
352
- * Fixed Saving Results Bug
353
- * Fixed Leaderboard Bug
354
-
355
- = 1.0 (February 1, 2014) =
356
- * Added Ability To Customize From Name For User And Admin Emails
357
- * Changed Question Editor
358
- * Minor Change To Help System
359
-
360
- = 0.9.9 (January 30, 2014) =
361
- * Begun Creating New Advanced Help System
362
- * Added New Question Editor
363
- * Added Ability To Have Media In Questions
364
- * Minor Design Changes To Quiz Options
365
-
366
- = 0.9.8 (January 25, 2014) =
367
- * Added Leaderboard Widget
368
- * Added Ability To Reset Quiz Stats On Each Quiz
369
- * Added Ability To Delete Results
370
- * Minor Design Changes
371
- * Minor Bug Fixes
372
-
373
- = 0.9.7 (January 24, 2014) =
374
- * Started Setting Plugin Up For Translations
375
- * Relocated Widgets From Help Page To Quiz Dashboard Page
376
- * Updated Several Of The Help Sections Through Plugin
377
- * Minor Bug Fixes
378
-
379
- = 0.9.6 (January 21, 2014) =
380
- * Added Ability To Edit Question Order When Adding Questions
381
- * Added Ability To Choose Whether Contact Info Is Asked For At Beginning Or End Of Quiz
382
- * Defaulted Question Comment Field To None On New Questions
383
- * Fixed Double Quote Bug
384
- * Enhanced Monthly Stat Widget
385
- * Minor Design Change To Quiz Total Stats Widget
386
- * Minor Design Changes To Quiz Options Page
387
-
388
- = 0.9.5 (January 19, 2014) =
389
- * Added Ability To Edit %QUESTIONS_ANSWERS% Template
390
- * Changed Name Of Support Page To Help Page
391
- * Minor Design Changes On Quiz Options Page
392
-
393
- = 0.9.4 (January 16, 2014) =
394
- * Added Ability To Randomly Order Questions
395
- * Updated Monthly Stat Widget
396
-
397
- = 0.9.3 (January 14, 2014) =
398
- * Logged-In Users Now See Contact Information
399
- * Minor Bug Fixes
400
-
401
- = 0.9.2 (January 12, 2014) =
402
- * Updated Weekly Stat Widget
403
- * Begun Work On Monthly Stat Widget
404
- * Added Ability To Edit Leaderboard Template
405
- * Bug Fixes
406
-
407
- = 0.9.1 (January 8, 2014) =
408
- * Fixed Leaderboard Design Bug
409
- * Fixed Contact Information Design Bug
410
- * Added Ability To Not Need Contact Info For Logged In Users
411
-
412
- = 0.9 (January 5, 2014) =
413
- * Added Ability To Edit Quiz Name
414
- * Added Ability To Display Question As Drop Down
415
- * Added Quiz Name To Completion Email's Subject
416
- * Minor Design Changes To Quiz Options Page
417
- * Design Changes To Quiz
418
-
419
- = 0.8.6 (January 2, 2014) =
420
- * Bug Fixes
421
-
422
- = 0.8.5 (January 1, 2014) =
423
- * New Screenshots Added
424
- * Minor Design Changes
425
- * Bug Fixes
426
-
427
- = 0.8.4 (December 22, 2013) =
428
- * New Option To Change Size Of Comment Field
429
- * Enhanced Weekly Stat Chart
430
- * Bug Fixes
431
-
432
- = 0.8.3 (December 14, 2013) =
433
- * Fixed Leaderboard Bug
434
- * Started Work On Weekly Stat Widget
435
- * Tweaked Some Design Throughout Admin Side
436
- * Minor Bug Fixes
437
-
438
- = 0.8.2 (December 10, 2013) =
439
- * Fixed Disappearing Question Bug Completely
440
- * Updated Update Process
441
-
442
- = 0.8.1 (December 9, 2013) =
443
- * Fixed Disappearing Question Bug
444
-
445
- = 0.8 (December 1, 2013) =
446
- * Added Spam Prevention Techniques To Backend
447
- * Added Ability To Reorder Questions
448
- * Added New Section On How-To Page
449
- * Bug Fixes
450
-
451
- = 0.7.2 (November 24, 2013) =
452
- * Bug Fixes
453
- * Added New Section On How-To Page
454
-
455
- = 0.7.1 (November 19, 2013) =
456
- * Changed Design For How-To Page
457
- * Added New Section In How-To Page
458
- * Added New Widget On Plugin Dashboard For Daily Stats
459
-
460
- = 0.7 (November 15, 2013) =
461
- * Bug Fixes
462
- * Begun Work On New How-To Page
463
- * Continued Redesigning Plugin Dashboard
464
-
465
- = 0.6.2 (November 10, 2013) =
466
- * Bug Fixes
467
- * Added More Stats
468
- * Started Redesigning Plugin Dashboard
469
-
470
- = 0.6.1 (November 2, 2013) =
471
- * Bug Fixes
472
-
473
- = 0.6 (October 19, 2013) =
474
- * Started Developing Quiz Leaderboards
475
- * Added Ability To Save User Answers And Comments
476
- * Added More Statistics To Quiz Dashboard
477
- * Bug Fixes
478
-
479
- = 0.5.3 (October 11, 2013) =
480
- * Bug Fixes
481
- * Started Redesigning Quiz Look
482
-
483
- = 0.5.2 (September 29, 2013) =
484
- * Bug Fixes
485
-
486
- = 0.5.1 (September 22, 2013) =
487
- * Added More Statistics To Quiz Dashboard
488
- * Bug Fixes
489
-
490
- = 0.5 (September 18, 2013) =
491
- * Created New Tools Page And Moved Audit Trail To It
492
- * Added Ability For Comment Section At End Of Quiz
493
- * Added Ability To Have Hints
494
- * Added Option To Have Comment Boxes On Questions
495
- * Added More Statistics To Main Page
496
-
497
- = 0.4.1 (September 15, 2013) =
498
- * Bug Fixes
499
-
500
- = 0.4 (September 13, 2013) =
501
- * Add The Ability To Require Contact Information
502
- * Add Email Validating To Email Field
503
-
504
- = 0.3.1 (September 13, 2013) =
505
- * Bug Fixes
506
-
507
- = 0.3 (September 12, 2013) =
508
- * Increased Scoring Systems To Three: Correct, Points, Or Not Graded
509
- * Error Fixes
510
-
511
- = 0.2 (September 9, 2013) =
512
- * Added New Quiz Dashboard Page
513
- * Created Audit Trail
514
- * Added Ability to Add Questions/Answers to Templates
515
- * Minor Spelling/Grammer Fixes
516
-
517
- = 0.1 (September 1, 2013) =
518
- * Begun Development
519
- * Added ability to create/edit/delete quizzes
520
- * Added ability to create/edit/delete questions
521
- * Added quiz admin page
522
- * Added questions admin page
523
- * Added results page
524
-
525
- == Upgrade Notice ==
526
-
527
- = 3.3.3 =
528
- Upgrade for minor bug fixes.
529
-
530
- = 3.3.1 =
531
- Upgrade for new Horizontal Multiple Response question type and to be able to duplicate questions when duplicating quizzes. Also, fixes several major and minor bugs.
532
-
533
- = 3.2.1 =
534
- Upgrade for new Captcha question types!
535
-
536
- = 3.1.1 =
537
- Upgrade for new Accept and Number question types. Also, now you have the ability to duplicate individual questions!
538
-
539
- = 3.0.1 =
540
- Upgrade for new style manager, new non-question types, text block question type, and various design/bug fixes!
541
-
542
- = 2.9.1 =
543
- Upgrade for facebook sharing, a new question type, the ability to edit the email's subject, and much more!
544
-
545
- = 2.8.5 =
546
- Upgrade for minor bug fixes.
547
-
548
- = 2.8.3 =
549
- Upgrade for minor bug fixes.
550
-
551
- = 2.8.2 =
552
- Upgrade for minor bug fixes.
553
-
554
- = 2.7.3 =
555
- Upgrade for bug fixes.
556
-
557
- = 2.7.2 =
558
- Upgrade for bug fixes.
559
-
560
- = 2.7.1 =
561
- Upgrade to have the ability to set number of questions per page and more bug fixes.
562
-
563
- = 2.6.4 =
564
- Upgrade for bug fixes.
565
-
566
- = 2.6.3 =
567
- Upgrade for bug fixes.
568
-
569
- = 2.6.2 =
570
- Upgrade for bug fixes.
571
-
572
- = 2.6.1 =
573
- Upgrade to be able to support special characters and non-latin based languages.
574
-
575
- = 2.5.1 =
576
- Upgrade for many new features including unlimited answers, random answers, new question type, and more!
577
-
578
- = 2.4.1 =
579
- Upgrade to be able to send different emails based on user's score. Also, minor bug fixes included.
580
-
581
- = 2.1.1 =
582
- Upgrade to have the ability to edit the css styles for each quiz! Plus minor bugs fixes.
583
-
584
- = 2.0.1 =
585
- Upgrade to fix minor bugs and enable pagination on results page.
586
-
587
- = 1.9.2 =
588
- Upgrade to have the ability to delete landing pages, allow users to go back when paginating questions, and have HTML in the correct answer info field!
589
-
590
- = 1.9.1 =
591
- Upgrade to 1.9.1 to get the ability for pagination on the quiz and to allow your users to share their results on Twitter.
592
-
593
- = 1.8.1 =
594
- Upgrade to 1.8.1 to get the ability to have different landing pages based on the user's score, give users certificates, and an additional customizable text section at the end of quiz. Plus minor design changes to quiz and Quiz Dashboard and lots of bug fixes.
595
-
596
- = 1.7.1 =
597
- This update adds new widgets to Quiz Dashboard, adds a timer mechanism, and fixes several minor bugs.
598
-
599
- = 1.6.3 =
600
- This update fixes minor bugs and adds minor design changes.
601
-
602
- = 1.6.2 =
603
- This update fixes minor bugs and adds minor design changes.
604
-
605
- = 1.6.1 =
606
- This update allows you to set the amount of tries a user has for cetain quizzes. Also fixes several bugs.
607
-
608
- = 1.5.1 =
609
- This update allows you to have the quiz only load a set number of questions from your total question bank. Also fixes several minor bugs.
610
-
611
- = 1.4.2 =
612
- This update brings many minor design changes and minor bug fixes.
613
-
614
- = 1.4.1 =
615
- This update helps plugin work better with other plugins. The hints for the quiz are now hidden by default.
616
-
617
- = 1.2.1 =
618
- This update adds pagination to the quizzes, audit trail, and question tables to make using the admin side easier. It also adds the ability to duplicate a quiz. Fixes various minor bugs.
619
-
620
- = 1.1.1 =
621
- This update adds the ability to show the user the reason why an answer is correct. Also, added new variable for templates that calculates average points per question. Minor bug fixes.
622
-
623
- = 1.0.1 =
624
- This update fixes minor bugs.
625
-
626
- = 1.0 =
627
- This update finally brings this plugin out of beta! This update brings the ability to edit the From Name part of the email sent to users and admin. Minor bug fixes.
628
-
629
- = 0.9.9 =
630
- Upgrade to be able to include media in your questions! Also, fixed minor bugs and made minor design changes.
631
-
632
- = 0.9.8 =
633
- Upgrade to use new leaderboard widet! Also, added ability to reset stats for quizzes from Quiz Options page. Added ability to delete results as well. Minor design changes and bug fixes.
634
-
635
- = 0.9.7 =
636
- Upgrade to see widgets relocated from help page to quiz dashboard page. Also, began setting plugin up for translations. Updated many help sections throughout plugin. Minor bug fixes.
637
-
638
- = 0.9.6 =
639
- Upgrade to be able to choose whether contact information is asked for at beginning or end of the quiz. Also, added ability to edit question order when adding new questions. Several minor design changes on admin side. Fixed double quote bug.
640
-
641
- = 0.9.5 =
642
- Upgrade to be able to edit the %QUESTIONS_ANSWERS% template. Also, minor design changes on Quiz Options page.
643
-
644
- = 0.9.4 =
645
- Upgrade to set up your quizzes to randomize the questions
646
-
647
- = 0.9.3 =
648
- Upgrade for minor bug fixes.
649
-
650
- = 0.9.2 =
651
- Upgrade for several enhanced stat widgets and the ability to edit leaderboard templates!
652
-
653
- = 0.9.1 =
654
- Upgrade for several bug fixes and new ability to have logged in users not have to enter contact information
655
-
656
- = 0.9 =
657
- Upgrade for several new features and bug fixes
658
-
659
- = 0.8.6 =
660
- Upgrade to fix minor bugs
661
-
662
- = 0.8.5 =
663
- Upgrade to fix minor bugs
664
-
665
- = 0.8.4 =
666
- Upgrade to enjoy small tweaks throughout admin side
667
-
668
- = 0.8.3 =
669
- Upgrade to enjoy small tweaks throughout admin side
670
-
671
- = 0.8.2 =
672
- Upgrade to fix bug that made questions vanish.
673
-
674
- = 0.8.1 =
675
- Upgrade to fix bug that made questions vanish.
676
-
677
- = 0.8 =
678
- Upgrade to enjoy several new features and minor bug fixes.
679
-
680
- = 0.7.2 =
681
- Upgrade to fix minor bugs and view new section on how-to page.
682
-
683
- = 0.7.1 =
684
- Upgrade to fix minor bugs, view new section how-to page, and new stats on main page.
685
-
686
- = 0.7 =
687
- Upgrade to fix minor bugs, view new how-to page, and new stats on main page.
688
-
689
- = 0.6.2 =
690
- Upgrade to fix some minor bug fixes.
691
-
692
- = 0.6 =
693
- Upgrade to enjoy several new features including saved results and leaderboards!
694
-
695
- = 0.5.3 =
696
- Upgrade to fix some minor bug fixes.
697
-
698
- = 0.5.2 =
699
- Upgrade to fix some minor bug fixes.
700
-
701
- = 0.5.1 =
702
- Upgrade to fix some minor bug fixes.
703
-
704
- = 0.5 =
705
- Upgrade to enjoy several new features including surveys!
706
-
707
- = 0.4 =
708
- Upgrade to enjoy being able to require contact information.
709
-
710
- = 0.3 =
711
- Upgrade to enjoy the new Not Graded scoring system and some error fixes!
712
-
713
- = 0.2 =
714
- Upgrade to enjoy three new features and some minor fixes!
715
-
716
- = 0.1 =
717
- Initial Version
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Quiz Master Next ===
2
+ Contributors: fpcorso
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RTGYAETX36ZQJ
4
+ Tags: quiz, test, score, exam, survey, contact, form, email, answer, question
5
+ Requires at least: 3.8.1
6
+ Tested up to: 4.0
7
+ Stable tag: 3.4.1
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website.
11
+
12
+ == Description ==
13
+
14
+ The easiest and most flexible way to add multiple quizzes, tests, surveys, and contact forms to your website. This plugin allows for unlimited quizzes each with unlimited amount of questions. The plugin allows you to create the quiz, add it to any page using a customized shortcode, allows the user to take the quiz, and then saves the results. You can set up what the user sees after he or she takes the quiz based on the user's score. You can also have the plugin create a certificate for the user as well!
15
+
16
+ = Have Unlimted Quizzes, Tests, Surveys, Contact Forms, etc.. =
17
+ Each of your quizzes can have **unlimited** questions and each of those questions can have **unlimited** answers! Your questions can contain **HTML** to show images, Youtube videos and more.
18
+
19
+ = Customize Your Text =
20
+ All the text your users see can be **customized**. Everything from the text blocks throughout the quiz to the submit button.
21
+
22
+ = Different Types Of Questions =
23
+ You can have **multiple choice** (radio buttons), **true and false**, **open answer** question, **drop down**, **multiple response** (checkboxes), **number**, **captcha**, and **accept**. More types are being supported in future updates!
24
+
25
+ = Mulitple Landing Pages For Each Quiz =
26
+ Each quiz can have **unlimited** results pages that can be customized with your text. Show different results pages based on the users score!
27
+
28
+ = Emails After Completion Of Quiz =
29
+ After the user takes a quiz, you can have the plugin email you and the user with results. This too can be customized with your own text.
30
+
31
+ = Very Flexible =
32
+ Your quiz can be graded with an incorrect/correct system or a points-based system. Or not at all. You ask for contact information at the beginning or the end and you decide which contact fields are required. You can decide to use all the questions or only a select few chosen at random. You can also set the number of questions per page or have all the questions on one page.
33
+
34
+ = Useful For Businesses =
35
+ The plugin features useful **statistics** that show how many times each quiz has been viewed and taken and plots the data on several different **graphs** so you can see how the quizzes are doing at a glance. Also, the plugin includes an **audit trail** that logs every action done on the admin side so you can keep up with who is doing what!
36
+
37
+ = Saves The Results For Later Use =
38
+ The plugin will **save** the results, the user's answers, the user's comments, and more!
39
+
40
+ = Other Useful Features =
41
+
42
+ * Allow the user to share the results on *social networks*
43
+ * Show all questions on one page or have only one question per page
44
+ * Allows for you to create **certificates** for the user
45
+ * Can set amount of tries a user has to take the quiz
46
+ * Can enable **comment boxes** for each question and/or comment section at the end of the quiz
47
+ * Can enable **hints** for questions
48
+ * Can show user why the answer is the correct answer
49
+ * Questions can be in predetermined order or random
50
+ * **Leaderboards** for every quiz which can be used as shortcode or in included widget
51
+ * Keep track how long a user takes on the quiz
52
+ * Able to set up time limits on the quiz
53
+ * And **Much** More...
54
+
55
+ = Make Suggestions Or Contribute =
56
+ Quiz Master Next is now on [GitHub](https://github.com/fpcorso/quiz_master_next/)!
57
+
58
+ = Quiz Master Next Add-ons =
59
+ While Quiz Master Next is fully functional and is packed full of features that will meet the needs of most, we do offer vaious extra features and support available in our [Wordpress Store](http://mylocalwebstop.com/shop/)
60
+
61
+
62
+ == Installation ==
63
+
64
+ We now offer an installation service to assist you in this process. We will install any or all of our plugins and spend up to 2 hours with you for consultaion and training. Visit our website for details.
65
+ [My Local Webstop Plugin Installation](http://mylocalwebstop.com/product/plugin-installation/)
66
+
67
+ **Or**
68
+
69
+ * Navigate to Add New Plugin page within your WordPress
70
+ * Search for Quiz Master Next
71
+ * Click Install Now link on the plugin and follow the prompts
72
+ * Activate the plugin through the 'Plugins' menu in WordPress
73
+
74
+ **Or**
75
+
76
+ * Upload plugin dir to the `/wp-content/plugins/` directory
77
+ * Activate the plugin through the 'Plugins' menu in WordPress
78
+
79
+
80
+ == Frequently Asked Questions ==
81
+
82
+ = How do you use that feature? =
83
+ We have begun creating documentation for the plugin. You can view the documentation here: [Documentation](http://mylocalwebstop.com/plugin-documentation/) If you still have any trouble, feel free to use the widget on the quiz dashboard within the plugin to contact me and I will help you.
84
+
85
+ = I need a lot of help setting up my quiz, what can you do to help? =
86
+ We now offer a premium support plan that offers priority response, priority feature requests, and 1-on-1 training! For details, visit our services page: [My Local Webstop Services](http://mylocalwebstop.com/product/plugin-premium-support/)
87
+
88
+ = Do you offer any 1-on-1 training to assist me in using this plugin? =
89
+ We now offer an installation service that includes 1-on-1 training as well as a premium support that offers 1-on-1 training. For details, visit our [Wordpress Store](http://mylocalwebstop.com/shop/)
90
+
91
+ = I have an idea, how do I contact you? =
92
+ Feel free to use the widget on the quiz dashboard within the plugin or from the contact page at mylocalwebstop.com.
93
+
94
+ == Screenshots ==
95
+
96
+ 1. Quiz Admin Page (With Advertisement Be Gone Add-On)
97
+ 2. Quiz Options Page (With Advertisement Be Gone Add-On)
98
+ 3. Quiz Dashboard Page (With Advertisement Be Gone Add-On)
99
+ 4. Example Quiz
100
+ 5. Example Survey
101
+ 6. Quiz Results Page
102
+ 7. Example Contact Form
103
+ 8. Example Quiz With Styling
104
+
105
+ == Changelog ==
106
+
107
+ = 3.4.1 (November 20, 2014) =
108
+ * Added Preview Mode (Beta)
109
+ * Several Design Changes To Quizzes Page
110
+ * Minor Design Changes To Quiz Settings Page
111
+ * Added Completion Time To Quiz Results Page
112
+ * Added Time Taken To Quiz Result Details Page
113
+ * Created New Hook On Quiz Settings Page
114
+ * Broke Apart Quiz Settings Backend Into Smaller Functions That Hook Into New Hook
115
+ * Created New Backend Alert Manager Class To Replace Archaic Old Error System
116
+
117
+ = 3.3.3 (November 14, 2014) =
118
+ * Minor Backend Change To Quiz Validation
119
+ * Disabled Enter Key On Quiz
120
+ * Minor Bug Fixes
121
+
122
+ = 3.3.2 (October 26, 2014) =
123
+ * Minor Design Change To Quiz Options
124
+
125
+ = 3.3.1 (October 15, 2014) =
126
+ * Added Horizontal Multiple Response Question Type
127
+ * Added Ability To Duplicate Questions When Duplicate Quizzes
128
+ * Added Last Modified Column To Table On Quizzes Page
129
+ * Fixed Number Question Type Grading Bug
130
+ * Fixed Missing theme_selected Column Installation Bug
131
+ * Fixed Missing theme_selected Column Duplication Bug
132
+ * Fixed Numerous Small Bugs
133
+
134
+ = 3.2.2 (October 4, 2014) =
135
+ * Minor Bug Fixes
136
+
137
+ = 3.2.1 (October 2, 2014) =
138
+ * Added New Captcha Question Type
139
+ * Fixed Number Question Type Validation Bug
140
+ * Fixed Validation Wrong Border Bug
141
+
142
+ = 3.1.1 (September 15, 2014) =
143
+ * Added Ability To Duplicate Individual Questions
144
+ * Added Ability To Require Accept, Number, And Open Answer Question Types
145
+ * Added Number Question Type
146
+ * Added Accept Non-Question Type
147
+
148
+ = 3.0.1 (August 28, 2014) =
149
+ * Added New Style Manager
150
+ * Added Ability For Non-Question Question Types
151
+ * Added New Text Block Question Type
152
+ * Added Question Type Column To Question List
153
+ * Minor Design Changes To Quiz Questions Tab
154
+ * Fixed Results Delete Link Not Working Bug
155
+ * Fixed Quiz Name Showing Escaped Values Bug
156
+
157
+ = 2.9.1 (August 11, 2014) =
158
+ * Added Facebook Sharing
159
+ * Added Ability To Edit Email Subject
160
+ * Added Large Open Answer Question Type
161
+ * Added Ability For Points To Have Decimal Values
162
+ * Fixed Not All Questions Showing In Results Bug
163
+ * Fixed Not Valid Email On Non-Required Email Bug
164
+ * Fixed Special Character Not Grading Properly In Open Answer Bug
165
+
166
+ = 2.8.5 (August 9, 2014) =
167
+ * Minor Bug Fixes
168
+ * Minor Design Tweaks To About Page
169
+
170
+ = 2.8.4 (August 3, 2014) =
171
+ * Minor Bug Fixes
172
+
173
+ = 2.8.3 (June 8, 2014) =
174
+ * Next/Previous Buttons Now Scroll Page To Top Of Quiz
175
+ * Minor Bug Fixes
176
+
177
+ = 2.8.2 (May 28, 2014) =
178
+ * Minor Bug Fixes
179
+
180
+ = 2.8.1 (May 26, 2014) =
181
+ * Took Out Help Related Tool Tips
182
+ * Design Changes To Quiz Text Tab For Easier Navigation
183
+ * Deleted How-To Page, Please Use Documentation On Our Website
184
+ * Renamed Quiz Options Page As Quiz Settings To Avoid Confusion With Quiz Options Tab
185
+
186
+ = 2.7.3 (May 19, 2014) =
187
+ * Fixed Open Answer Not Showing Correct Answer Bug
188
+
189
+ = 2.7.2 (May 18, 2014) =
190
+ * Fixed Timer Not Restarting Bug
191
+ * Fixed Tooltip Affecting Whole Page Bug
192
+
193
+ = 2.7.1 (May 16, 2014) =
194
+ * Added Ability To Set Number Of Question Per Page
195
+ * Fixed HTML Not Showing On Results Page Bug
196
+ * Fixed Timer Not Disabling New Fields Bug
197
+ * Fixed Timer Submitting Disabled Fields Bug
198
+
199
+ = 2.6.4 (May 12, 2014) =
200
+ * Bug Fixes
201
+
202
+ = 2.6.3 (May 9, 2014) =
203
+ * Bug Fixes
204
+
205
+ = 2.6.2 (May 8, 2014) =
206
+ * Bug Fixes
207
+
208
+ = 2.6.1 (May 7, 2014) =
209
+ * Added UTF-8 Support For Special Characters And Non-Latin Languages
210
+ * Fixed Question Bank Showing All Answers Bug
211
+
212
+ = 2.5.1 (May 3, 2014) =
213
+ * Rebuilt Answer System
214
+ * Added Ability To Have Unlimited Answers
215
+ * Added Ability To Randomize Answers
216
+ * Added New Question Type - Multiple Response (Checkboxes)
217
+ * Added Ability To Send Admin Email To Multiple Users
218
+ * Minor Design Changes To Quiz Options Page
219
+
220
+ = 2.4.1 (April 20, 2014) =
221
+ * Added New Quiz Emails Tab
222
+ * Added Ability To Send Different Emails To Users Based On Score
223
+ * Fixed Required Question Bug
224
+ * Fixed Landing Page Bug
225
+
226
+ = 2.3.1 (April 6, 2014) =
227
+ * Added Ability To Have Graded Open Answer Questions
228
+ * Minor Design Changes
229
+
230
+ = 2.2.2 (March 30, 2014) =
231
+ * Reverted To Previous Pagination Javascript
232
+
233
+ = 2.2.1 (March 30, 2014) =
234
+ * Added Ability To Show Question Numbers
235
+ * Added More CSS Classes To Quiz Page For Better Styling Options
236
+ * Changed Timer To Disable Fields Instead Of Submit Form When Time Is Up
237
+ * Fixed Pagination Javascript Bug
238
+ * Minor Design Change To Quiz
239
+ * Minor Design Change To Quiz Options Page
240
+
241
+ = 2.1.1 (March 26, 2014) =
242
+ * Added Ability To Edit Style For Each Quiz
243
+ * Fixed Tried Quiz Too Many Times Text Bug
244
+ * Fixed Dashboard Quartely Widget Bug
245
+ * Minor Design Changes To Quiz Options Page
246
+
247
+ = 2.0.1 (March 22, 2014) =
248
+ * Added Pagination On Quiz Results Page
249
+ * Redesigned Results Detail Page
250
+ * Fixed PHP Notice On Quizzes Page
251
+ * Allow HTML/CSS in Landing Pages
252
+
253
+ = 1.9.6 (March 19, 2014) =
254
+ * Fixed Duplicate Quiz Bug
255
+ * Fixed Uneditable Question Bug
256
+ * Fixed Parse Bug
257
+ * Made Email Now Send As HTML
258
+
259
+ = 1.9.5 (March 18, 2014) =
260
+ * Fixed Bug
261
+
262
+ = 1.9.4 (March 18, 2014) =
263
+ * Fixed Bug
264
+
265
+ = 1.9.3 (March 17, 2014) =
266
+ * Fixed Bug: Unexpected T_CONSTANT_ENCAPSED_STRING When Activating
267
+
268
+ = 1.9.2 (March 17, 2014) =
269
+ * Added Ability To Delete Landing Pages
270
+ * Added Ability To Have HTML In Correct Answer Info Field
271
+ * Added Previous Question Button To Paginated Quiz
272
+ * Minor Design Changes To Quiz
273
+ * Add Timer To Title Bar
274
+ * Added %CURRENT_DATE% field
275
+
276
+ = 1.9.1 (March 13, 2014) =
277
+ * Added Ability To Show One Question At A Time Instead Of All At Once
278
+ * Added Ability To Allow Users To Share Results On Twitter
279
+ * Added Ability To Set Time Limits On Quiz
280
+ * Minor Design Changes To Quiz
281
+ * Minor Bug Fixes
282
+
283
+ = 1.8.2 (March 11, 2014) =
284
+ * Minor Bug Fixes
285
+
286
+ = 1.8.1 (March 10, 2014) =
287
+ * Added Customizable Text Section At End Of Quiz
288
+ * Added Ability To Set Up Different Landing Pages Based On Score
289
+ * Added Ability To Give Certificate After Quiz
290
+ * Enhanced Quiz Total Stats Widget
291
+ * Minor Design Changes To Quiz
292
+ * Fixed Session_Start Bug
293
+ * Fixed Division By Zero Bug
294
+ * Fixed Total Stats Deleted Bug
295
+ * Fixed Dashboard Rounding Bug
296
+ * Fixed Notice Unknown Company Field Bug
297
+
298
+
299
+ = 1.7.1 (March 6, 2014) =
300
+ * Added Several New Widgets To Quiz Dashboard
301
+ * Added A Timer Mechanism To Track How Long User Takes On Quiz
302
+ * Added New About Update Page
303
+ * Fixed Saving Results Bug
304
+ * Fixed Random Number On Quiz Options Page Bug
305
+
306
+ = 1.6.3 (March 5, 2014) =
307
+ * Fixed Duplicated Shortcode Bug
308
+ * Quiz Dashboard Design Changes
309
+
310
+ = 1.6.2 (March 4, 2014) =
311
+ * Minor Bug Fixes
312
+ * Minor Design Changes
313
+
314
+ = 1.6.1 (March 2, 2014) =
315
+ * Added Ability To Limit Amount User Tries Certain Quizzes
316
+ * Fixed Internet Explorer Quiz Adding Bug
317
+ * Fixed Results Link On Quizzes Page Bug
318
+ * Fixed Points Number Check Bug
319
+ * Fixed Limited Question Grading Bug
320
+ * Minor Design Changes To Admin Pages
321
+
322
+ = 1.5.1 (February 26, 2014) =
323
+ * Added Ability To Load Only Set Amount Of Questions From Total Questions
324
+ * Fixed PHP Notices On Quizzes Page
325
+ * Fixed PHP Notices On Quiz Options Page
326
+ * Fixed PHP Notices On Quiz Results Page
327
+ * Fixed PHP Notices On Quiz
328
+ * Fixed Hidden Pop-Up Bug
329
+
330
+ = 1.4.2 (February 22, 2014) =
331
+ * Fixed Capability Bug
332
+ * Minor Design Changes To Question Form
333
+ * Hint Bubble Is Now Wider For Longer Hints
334
+ * Minor Design Change To Quiz
335
+
336
+ = 1.4.1 (February 20, 2014) =
337
+ * Enhanced Plugins Compatibility With Other Plugins
338
+ * Hints Are Now Hidden By Default
339
+ * Minor Bug Fixes
340
+
341
+ = 1.3.1 (February 18, 2014) =
342
+ * Added Ability To Choose Whether Logged-in Users Can Enter Contact Info
343
+ * Fixed Editing Hint Field Error
344
+ * Added Ability To Have Media In Answers
345
+ * Added Ability To Have HTML In Questions And Answers
346
+
347
+ = 1.2.1 (February 11, 2014) =
348
+ * Fixed Quiz Results Details Bug
349
+ * Continued Working On New Error Code System
350
+ * Added Pagination To Tools Page, Quizzes Page And List Of Questions On Quiz Options Page
351
+ * Added Ability To Create A Duplicate Of A Quiz
352
+
353
+ = 1.1.1 (February 6, 2014) =
354
+ * Added %AVERAGE_POINT% Variable That Calculates Average Points Per Question
355
+ * Added Field For Reason Why Answer Is Correct
356
+ * Added %CORRECT_ANSWER_INFO% To Display Why Answer Is Correct
357
+ * Begun Creating New Error Code System
358
+ * Fixed Edit Quiz Name Bug
359
+ * Fixed New Quiz Bug
360
+
361
+ = 1.0.1 (February 4, 2014) =
362
+ * Fixed Saving Results Bug
363
+ * Fixed Leaderboard Bug
364
+
365
+ = 1.0 (February 1, 2014) =
366
+ * Added Ability To Customize From Name For User And Admin Emails
367
+ * Changed Question Editor
368
+ * Minor Change To Help System
369
+
370
+ = 0.9.9 (January 30, 2014) =
371
+ * Begun Creating New Advanced Help System
372
+ * Added New Question Editor
373
+ * Added Ability To Have Media In Questions
374
+ * Minor Design Changes To Quiz Options
375
+
376
+ = 0.9.8 (January 25, 2014) =
377
+ * Added Leaderboard Widget
378
+ * Added Ability To Reset Quiz Stats On Each Quiz
379
+ * Added Ability To Delete Results
380
+ * Minor Design Changes
381
+ * Minor Bug Fixes
382
+
383
+ = 0.9.7 (January 24, 2014) =
384
+ * Started Setting Plugin Up For Translations
385
+ * Relocated Widgets From Help Page To Quiz Dashboard Page
386
+ * Updated Several Of The Help Sections Through Plugin
387
+ * Minor Bug Fixes
388
+
389
+ = 0.9.6 (January 21, 2014) =
390
+ * Added Ability To Edit Question Order When Adding Questions
391
+ * Added Ability To Choose Whether Contact Info Is Asked For At Beginning Or End Of Quiz
392
+ * Defaulted Question Comment Field To None On New Questions
393
+ * Fixed Double Quote Bug
394
+ * Enhanced Monthly Stat Widget
395
+ * Minor Design Change To Quiz Total Stats Widget
396
+ * Minor Design Changes To Quiz Options Page
397
+
398
+ = 0.9.5 (January 19, 2014) =
399
+ * Added Ability To Edit %QUESTIONS_ANSWERS% Template
400
+ * Changed Name Of Support Page To Help Page
401
+ * Minor Design Changes On Quiz Options Page
402
+
403
+ = 0.9.4 (January 16, 2014) =
404
+ * Added Ability To Randomly Order Questions
405
+ * Updated Monthly Stat Widget
406
+
407
+ = 0.9.3 (January 14, 2014) =
408
+ * Logged-In Users Now See Contact Information
409
+ * Minor Bug Fixes
410
+
411
+ = 0.9.2 (January 12, 2014) =
412
+ * Updated Weekly Stat Widget
413
+ * Begun Work On Monthly Stat Widget
414
+ * Added Ability To Edit Leaderboard Template
415
+ * Bug Fixes
416
+
417
+ = 0.9.1 (January 8, 2014) =
418
+ * Fixed Leaderboard Design Bug
419
+ * Fixed Contact Information Design Bug
420
+ * Added Ability To Not Need Contact Info For Logged In Users
421
+
422
+ = 0.9 (January 5, 2014) =
423
+ * Added Ability To Edit Quiz Name
424
+ * Added Ability To Display Question As Drop Down
425
+ * Added Quiz Name To Completion Email's Subject
426
+ * Minor Design Changes To Quiz Options Page
427
+ * Design Changes To Quiz
428
+
429
+ = 0.8.6 (January 2, 2014) =
430
+ * Bug Fixes
431
+
432
+ = 0.8.5 (January 1, 2014) =
433
+ * New Screenshots Added
434
+ * Minor Design Changes
435
+ * Bug Fixes
436
+
437
+ = 0.8.4 (December 22, 2013) =
438
+ * New Option To Change Size Of Comment Field
439
+ * Enhanced Weekly Stat Chart
440
+ * Bug Fixes
441
+
442
+ = 0.8.3 (December 14, 2013) =
443
+ * Fixed Leaderboard Bug
444
+ * Started Work On Weekly Stat Widget
445
+ * Tweaked Some Design Throughout Admin Side
446
+ * Minor Bug Fixes
447
+
448
+ = 0.8.2 (December 10, 2013) =
449
+ * Fixed Disappearing Question Bug Completely
450
+ * Updated Update Process
451
+
452
+ = 0.8.1 (December 9, 2013) =
453
+ * Fixed Disappearing Question Bug
454
+
455
+ = 0.8 (December 1, 2013) =
456
+ * Added Spam Prevention Techniques To Backend
457
+ * Added Ability To Reorder Questions
458
+ * Added New Section On How-To Page
459
+ * Bug Fixes
460
+
461
+ = 0.7.2 (November 24, 2013) =
462
+ * Bug Fixes
463
+ * Added New Section On How-To Page
464
+
465
+ = 0.7.1 (November 19, 2013) =
466
+ * Changed Design For How-To Page
467
+ * Added New Section In How-To Page
468
+ * Added New Widget On Plugin Dashboard For Daily Stats
469
+
470
+ = 0.7 (November 15, 2013) =
471
+ * Bug Fixes
472
+ * Begun Work On New How-To Page
473
+ * Continued Redesigning Plugin Dashboard
474
+
475
+ = 0.6.2 (November 10, 2013) =
476
+ * Bug Fixes
477
+ * Added More Stats
478
+ * Started Redesigning Plugin Dashboard
479
+
480
+ = 0.6.1 (November 2, 2013) =
481
+ * Bug Fixes
482
+
483
+ = 0.6 (October 19, 2013) =
484
+ * Started Developing Quiz Leaderboards
485
+ * Added Ability To Save User Answers And Comments
486
+ * Added More Statistics To Quiz Dashboard
487
+ * Bug Fixes
488
+
489
+ = 0.5.3 (October 11, 2013) =
490
+ * Bug Fixes
491
+ * Started Redesigning Quiz Look
492
+
493
+ = 0.5.2 (September 29, 2013) =
494
+ * Bug Fixes
495
+
496
+ = 0.5.1 (September 22, 2013) =
497
+ * Added More Statistics To Quiz Dashboard
498
+ * Bug Fixes
499
+
500
+ = 0.5 (September 18, 2013) =
501
+ * Created New Tools Page And Moved Audit Trail To It
502
+ * Added Ability For Comment Section At End Of Quiz
503
+ * Added Ability To Have Hints
504
+ * Added Option To Have Comment Boxes On Questions
505
+ * Added More Statistics To Main Page
506
+
507
+ = 0.4.1 (September 15, 2013) =
508
+ * Bug Fixes
509
+
510
+ = 0.4 (September 13, 2013) =
511
+ * Add The Ability To Require Contact Information
512
+ * Add Email Validating To Email Field
513
+
514
+ = 0.3.1 (September 13, 2013) =
515
+ * Bug Fixes
516
+
517
+ = 0.3 (September 12, 2013) =
518
+ * Increased Scoring Systems To Three: Correct, Points, Or Not Graded
519
+ * Error Fixes
520
+
521
+ = 0.2 (September 9, 2013) =
522
+ * Added New Quiz Dashboard Page
523
+ * Created Audit Trail
524
+ * Added Ability to Add Questions/Answers to Templates
525
+ * Minor Spelling/Grammer Fixes
526
+
527
+ = 0.1 (September 1, 2013) =
528
+ * Begun Development
529
+ * Added ability to create/edit/delete quizzes
530
+ * Added ability to create/edit/delete questions
531
+ * Added quiz admin page
532
+ * Added questions admin page
533
+ * Added results page
534
+
535
+ == Upgrade Notice ==
536
+
537
+ = 3.4.1 =
538
+ Upgrade for new preview mode, many design changes, and more!
539
+
540
+ = 3.3.3 =
541
+ Upgrade for minor bug fixes.
542
+
543
+ = 3.3.1 =
544
+ Upgrade for new Horizontal Multiple Response question type and to be able to duplicate questions when duplicating quizzes. Also, fixes several major and minor bugs.
545
+
546
+ = 3.2.1 =
547
+ Upgrade for new Captcha question types!
548
+
549
+ = 3.1.1 =
550
+ Upgrade for new Accept and Number question types. Also, now you have the ability to duplicate individual questions!
551
+
552
+ = 3.0.1 =
553
+ Upgrade for new style manager, new non-question types, text block question type, and various design/bug fixes!
554
+
555
+ = 2.9.1 =
556
+ Upgrade for facebook sharing, a new question type, the ability to edit the email's subject, and much more!
557
+
558
+ = 2.8.5 =
559
+ Upgrade for minor bug fixes.
560
+
561
+ = 2.8.3 =
562
+ Upgrade for minor bug fixes.
563
+
564
+ = 2.8.2 =
565
+ Upgrade for minor bug fixes.
566
+
567
+ = 2.7.3 =
568
+ Upgrade for bug fixes.
569
+
570
+ = 2.7.2 =
571
+ Upgrade for bug fixes.
572
+
573
+ = 2.7.1 =
574
+ Upgrade to have the ability to set number of questions per page and more bug fixes.
575
+
576
+ = 2.6.4 =
577
+ Upgrade for bug fixes.
578
+
579
+ = 2.6.3 =
580
+ Upgrade for bug fixes.
581
+
582
+ = 2.6.2 =
583
+ Upgrade for bug fixes.
584
+
585
+ = 2.6.1 =
586
+ Upgrade to be able to support special characters and non-latin based languages.
587
+
588
+ = 2.5.1 =
589
+ Upgrade for many new features including unlimited answers, random answers, new question type, and more!
590
+
591
+ = 2.4.1 =
592
+ Upgrade to be able to send different emails based on user's score. Also, minor bug fixes included.
593
+
594
+ = 2.1.1 =
595
+ Upgrade to have the ability to edit the css styles for each quiz! Plus minor bugs fixes.
596
+
597
+ = 2.0.1 =
598
+ Upgrade to fix minor bugs and enable pagination on results page.
599
+
600
+ = 1.9.2 =
601
+ Upgrade to have the ability to delete landing pages, allow users to go back when paginating questions, and have HTML in the correct answer info field!
602
+
603
+ = 1.9.1 =
604
+ Upgrade to 1.9.1 to get the ability for pagination on the quiz and to allow your users to share their results on Twitter.
605
+
606
+ = 1.8.1 =
607
+ Upgrade to 1.8.1 to get the ability to have different landing pages based on the user's score, give users certificates, and an additional customizable text section at the end of quiz. Plus minor design changes to quiz and Quiz Dashboard and lots of bug fixes.
608
+
609
+ = 1.7.1 =
610
+ This update adds new widgets to Quiz Dashboard, adds a timer mechanism, and fixes several minor bugs.
611
+
612
+ = 1.6.3 =
613
+ This update fixes minor bugs and adds minor design changes.
614
+
615
+ = 1.6.2 =
616
+ This update fixes minor bugs and adds minor design changes.
617
+
618
+ = 1.6.1 =
619
+ This update allows you to set the amount of tries a user has for cetain quizzes. Also fixes several bugs.
620
+
621
+ = 1.5.1 =
622
+ This update allows you to have the quiz only load a set number of questions from your total question bank. Also fixes several minor bugs.
623
+
624
+ = 1.4.2 =
625
+ This update brings many minor design changes and minor bug fixes.
626
+
627
+ = 1.4.1 =
628
+ This update helps plugin work better with other plugins. The hints for the quiz are now hidden by default.
629
+
630
+ = 1.2.1 =
631
+ This update adds pagination to the quizzes, audit trail, and question tables to make using the admin side easier. It also adds the ability to duplicate a quiz. Fixes various minor bugs.
632
+
633
+ = 1.1.1 =
634
+ This update adds the ability to show the user the reason why an answer is correct. Also, added new variable for templates that calculates average points per question. Minor bug fixes.
635
+
636
+ = 1.0.1 =
637
+ This update fixes minor bugs.
638
+
639
+ = 1.0 =
640
+ This update finally brings this plugin out of beta! This update brings the ability to edit the From Name part of the email sent to users and admin. Minor bug fixes.
641
+
642
+ = 0.9.9 =
643
+ Upgrade to be able to include media in your questions! Also, fixed minor bugs and made minor design changes.
644
+
645
+ = 0.9.8 =
646
+ Upgrade to use new leaderboard widet! Also, added ability to reset stats for quizzes from Quiz Options page. Added ability to delete results as well. Minor design changes and bug fixes.
647
+
648
+ = 0.9.7 =
649
+ Upgrade to see widgets relocated from help page to quiz dashboard page. Also, began setting plugin up for translations. Updated many help sections throughout plugin. Minor bug fixes.
650
+
651
+ = 0.9.6 =
652
+ Upgrade to be able to choose whether contact information is asked for at beginning or end of the quiz. Also, added ability to edit question order when adding new questions. Several minor design changes on admin side. Fixed double quote bug.
653
+
654
+ = 0.9.5 =
655
+ Upgrade to be able to edit the %QUESTIONS_ANSWERS% template. Also, minor design changes on Quiz Options page.
656
+
657
+ = 0.9.4 =
658
+ Upgrade to set up your quizzes to randomize the questions
659
+
660
+ = 0.9.3 =
661
+ Upgrade for minor bug fixes.
662
+
663
+ = 0.9.2 =
664
+ Upgrade for several enhanced stat widgets and the ability to edit leaderboard templates!
665
+
666
+ = 0.9.1 =
667
+ Upgrade for several bug fixes and new ability to have logged in users not have to enter contact information
668
+
669
+ = 0.9 =
670
+ Upgrade for several new features and bug fixes
671
+
672
+ = 0.8.6 =
673
+ Upgrade to fix minor bugs
674
+
675
+ = 0.8.5 =
676
+ Upgrade to fix minor bugs
677
+
678
+ = 0.8.4 =
679
+ Upgrade to enjoy small tweaks throughout admin side
680
+
681
+ = 0.8.3 =
682
+ Upgrade to enjoy small tweaks throughout admin side
683
+
684
+ = 0.8.2 =
685
+ Upgrade to fix bug that made questions vanish.
686
+
687
+ = 0.8.1 =
688
+ Upgrade to fix bug that made questions vanish.
689
+
690
+ = 0.8 =
691
+ Upgrade to enjoy several new features and minor bug fixes.
692
+
693
+ = 0.7.2 =
694
+ Upgrade to fix minor bugs and view new section on how-to page.
695
+
696
+ = 0.7.1 =
697
+ Upgrade to fix minor bugs, view new section how-to page, and new stats on main page.
698
+
699
+ = 0.7 =
700
+ Upgrade to fix minor bugs, view new how-to page, and new stats on main page.
701
+
702
+ = 0.6.2 =
703
+ Upgrade to fix some minor bug fixes.
704
+
705
+ = 0.6 =
706
+ Upgrade to enjoy several new features including saved results and leaderboards!
707
+
708
+ = 0.5.3 =
709
+ Upgrade to fix some minor bug fixes.
710
+
711
+ = 0.5.2 =
712
+ Upgrade to fix some minor bug fixes.
713
+
714
+ = 0.5.1 =
715
+ Upgrade to fix some minor bug fixes.
716
+
717
+ = 0.5 =
718
+ Upgrade to enjoy several new features including surveys!
719
+
720
+ = 0.4 =
721
+ Upgrade to enjoy being able to require contact information.
722
+
723
+ = 0.3 =
724
+ Upgrade to enjoy the new Not Graded scoring system and some error fixes!
725
+
726
+ = 0.2 =
727
+ Upgrade to enjoy three new features and some minor fixes!
728
+
729
+ = 0.1 =
730
+ Initial Version