Completed
Push — master ( 4911d3...2a36d1 )
by Michael
02:09
created
admin/link.php 3 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -21,81 +21,81 @@
 block discarded – undo
21 21
 $op = '';
22 22
 
23 23
 if (isset($_GET['op'])) {
24
-    $op = $_GET['op'];
24
+	$op = $_GET['op'];
25 25
 }
26 26
 if (isset($_POST['op'])) {
27
-    $op = $_POST['op'];
27
+	$op = $_POST['op'];
28 28
 }
29 29
 
30 30
 switch ($op) {
31 31
 
32
-    case 'del':
33
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
34
-        $controller = new SmartObjectController($smartobjectLinkHandler);
35
-        $controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM);
32
+	case 'del':
33
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
34
+		$controller = new SmartObjectController($smartobjectLinkHandler);
35
+		$controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM);
36 36
 
37
-        break;
37
+		break;
38 38
 
39
-    case 'view':
40
-        $linkid  = isset($_GET['linkid']) ? $_GET['linkid'] : 0;
41
-        $linkObj = $smartobjectLinkHandler->get($linkid);
39
+	case 'view':
40
+		$linkid  = isset($_GET['linkid']) ? $_GET['linkid'] : 0;
41
+		$linkObj = $smartobjectLinkHandler->get($linkid);
42 42
 
43
-        if ($linkObj->isNew()) {
44
-            redirect_header(SMARTOBJECT_URL . 'admin/link.php', 3, _AM_SOBJECT_LINK_NOT_FOUND);
45
-        }
43
+		if ($linkObj->isNew()) {
44
+			redirect_header(SMARTOBJECT_URL . 'admin/link.php', 3, _AM_SOBJECT_LINK_NOT_FOUND);
45
+		}
46 46
 
47
-        smart_xoops_cp_header();
47
+		smart_xoops_cp_header();
48 48
 
49
-        //smart_adminMenu(1, _AM_SOBJECT_SENT_LINK_DISPLAY);
49
+		//smart_adminMenu(1, _AM_SOBJECT_SENT_LINK_DISPLAY);
50 50
 
51
-        smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINK_DISPLAY, _AM_SOBJECT_SENT_LINK_DISPLAY_INFO);
51
+		smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINK_DISPLAY, _AM_SOBJECT_SENT_LINK_DISPLAY_INFO);
52 52
 
53
-        require_once XOOPS_ROOT_PATH . '/class/template.php';
53
+		require_once XOOPS_ROOT_PATH . '/class/template.php';
54 54
 
55
-        // ---
56
-        // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
57
-        //      $xoopsTpl = new XoopsTpl();
58
-        $xoopsTpl = new XoopsTpl();
59
-        //---
55
+		// ---
56
+		// 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
57
+		//      $xoopsTpl = new XoopsTpl();
58
+		$xoopsTpl = new XoopsTpl();
59
+		//---
60 60
 
61
-        $xoopsTpl->assign('link', $linkObj->toArray());
62
-        $xoopsTpl->display('db:smartobject_sentlink_display.tpl');
61
+		$xoopsTpl->assign('link', $linkObj->toArray());
62
+		$xoopsTpl->display('db:smartobject_sentlink_display.tpl');
63 63
 
64
-        echo '<br>';
65
-        smart_close_collapsable('sentlinks');
66
-        echo '<br>';
64
+		echo '<br>';
65
+		smart_close_collapsable('sentlinks');
66
+		echo '<br>';
67 67
 
68
-        break;
68
+		break;
69 69
 
70
-    default:
70
+	default:
71 71
 
72
-        smart_xoops_cp_header();
72
+		smart_xoops_cp_header();
73 73
 
74
-        $adminObject->displayNavigation(basename(__FILE__));
74
+		$adminObject->displayNavigation(basename(__FILE__));
75 75
 
76
-        //smart_adminMenu(1, _AM_SOBJECT_SENT_LINKS);
76
+		//smart_adminMenu(1, _AM_SOBJECT_SENT_LINKS);
77 77
 
78
-        smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINKS, _AM_SOBJECT_SENT_LINKS_INFO);
78
+		smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINKS, _AM_SOBJECT_SENT_LINKS_INFO);
79 79
 
80
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
81
-        $objectTable = new SmartObjectTable($smartobjectLinkHandler, null, ['delete']);
82
-        $objectTable->addColumn(new SmartObjectColumn('date'));
83
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align = 'left', $width = false, 'getFromInfo'));
84
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_TO, $align = 'left', $width = false, 'getToInfo'));
85
-        $objectTable->addColumn(new SmartObjectColumn('link'));
80
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
81
+		$objectTable = new SmartObjectTable($smartobjectLinkHandler, null, ['delete']);
82
+		$objectTable->addColumn(new SmartObjectColumn('date'));
83
+		$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align = 'left', $width = false, 'getFromInfo'));
84
+		$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_TO, $align = 'left', $width = false, 'getToInfo'));
85
+		$objectTable->addColumn(new SmartObjectColumn('link'));
86 86
 
87
-        $objectTable->addCustomAction('getViewItemLink');
87
+		$objectTable->addCustomAction('getViewItemLink');
88 88
 
89
-        $objectTable->setDefaultSort('date');
90
-        $objectTable->setDefaultOrder('DESC');
89
+		$objectTable->setDefaultSort('date');
90
+		$objectTable->setDefaultOrder('DESC');
91 91
 
92
-        $objectTable->render();
92
+		$objectTable->render();
93 93
 
94
-        echo '<br>';
95
-        smart_close_collapsable('sentlinks');
96
-        echo '<br>';
94
+		echo '<br>';
95
+		smart_close_collapsable('sentlinks');
96
+		echo '<br>';
97 97
 
98
-        break;
98
+		break;
99 99
 }
100 100
 
101 101
 //smart_modFooter();
Please login to merge, or discard this patch.
Switch Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -29,73 +29,73 @@
 block discarded – undo
29 29
 
30 30
 switch ($op) {
31 31
 
32
-    case 'del':
33
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
34
-        $controller = new SmartObjectController($smartobjectLinkHandler);
35
-        $controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM);
32
+    	case 'del':
33
+        	require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
34
+        	$controller = new SmartObjectController($smartobjectLinkHandler);
35
+        	$controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM);
36 36
 
37
-        break;
37
+        	break;
38 38
 
39
-    case 'view':
40
-        $linkid  = isset($_GET['linkid']) ? $_GET['linkid'] : 0;
41
-        $linkObj = $smartobjectLinkHandler->get($linkid);
39
+    	case 'view':
40
+        	$linkid  = isset($_GET['linkid']) ? $_GET['linkid'] : 0;
41
+        	$linkObj = $smartobjectLinkHandler->get($linkid);
42 42
 
43
-        if ($linkObj->isNew()) {
44
-            redirect_header(SMARTOBJECT_URL . 'admin/link.php', 3, _AM_SOBJECT_LINK_NOT_FOUND);
45
-        }
43
+        	if ($linkObj->isNew()) {
44
+            	redirect_header(SMARTOBJECT_URL . 'admin/link.php', 3, _AM_SOBJECT_LINK_NOT_FOUND);
45
+        	}
46 46
 
47
-        smart_xoops_cp_header();
47
+        	smart_xoops_cp_header();
48 48
 
49
-        //smart_adminMenu(1, _AM_SOBJECT_SENT_LINK_DISPLAY);
49
+        	//smart_adminMenu(1, _AM_SOBJECT_SENT_LINK_DISPLAY);
50 50
 
51
-        smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINK_DISPLAY, _AM_SOBJECT_SENT_LINK_DISPLAY_INFO);
51
+        	smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINK_DISPLAY, _AM_SOBJECT_SENT_LINK_DISPLAY_INFO);
52 52
 
53
-        require_once XOOPS_ROOT_PATH . '/class/template.php';
53
+        	require_once XOOPS_ROOT_PATH . '/class/template.php';
54 54
 
55
-        // ---
56
-        // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
57
-        //      $xoopsTpl = new XoopsTpl();
58
-        $xoopsTpl = new XoopsTpl();
59
-        //---
55
+        	// ---
56
+        	// 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
57
+        	//      $xoopsTpl = new XoopsTpl();
58
+        	$xoopsTpl = new XoopsTpl();
59
+        	//---
60 60
 
61
-        $xoopsTpl->assign('link', $linkObj->toArray());
62
-        $xoopsTpl->display('db:smartobject_sentlink_display.tpl');
61
+        	$xoopsTpl->assign('link', $linkObj->toArray());
62
+        	$xoopsTpl->display('db:smartobject_sentlink_display.tpl');
63 63
 
64
-        echo '<br>';
65
-        smart_close_collapsable('sentlinks');
66
-        echo '<br>';
64
+        	echo '<br>';
65
+        	smart_close_collapsable('sentlinks');
66
+        	echo '<br>';
67 67
 
68
-        break;
68
+        	break;
69 69
 
70
-    default:
70
+    	default:
71 71
 
72
-        smart_xoops_cp_header();
72
+        	smart_xoops_cp_header();
73 73
 
74
-        $adminObject->displayNavigation(basename(__FILE__));
74
+        	$adminObject->displayNavigation(basename(__FILE__));
75 75
 
76
-        //smart_adminMenu(1, _AM_SOBJECT_SENT_LINKS);
76
+        	//smart_adminMenu(1, _AM_SOBJECT_SENT_LINKS);
77 77
 
78
-        smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINKS, _AM_SOBJECT_SENT_LINKS_INFO);
78
+        	smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINKS, _AM_SOBJECT_SENT_LINKS_INFO);
79 79
 
80
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
81
-        $objectTable = new SmartObjectTable($smartobjectLinkHandler, null, ['delete']);
82
-        $objectTable->addColumn(new SmartObjectColumn('date'));
83
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align = 'left', $width = false, 'getFromInfo'));
84
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_TO, $align = 'left', $width = false, 'getToInfo'));
85
-        $objectTable->addColumn(new SmartObjectColumn('link'));
80
+        	require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
81
+        	$objectTable = new SmartObjectTable($smartobjectLinkHandler, null, ['delete']);
82
+        	$objectTable->addColumn(new SmartObjectColumn('date'));
83
+        	$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align = 'left', $width = false, 'getFromInfo'));
84
+        	$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_TO, $align = 'left', $width = false, 'getToInfo'));
85
+        	$objectTable->addColumn(new SmartObjectColumn('link'));
86 86
 
87
-        $objectTable->addCustomAction('getViewItemLink');
87
+        	$objectTable->addCustomAction('getViewItemLink');
88 88
 
89
-        $objectTable->setDefaultSort('date');
90
-        $objectTable->setDefaultOrder('DESC');
89
+        	$objectTable->setDefaultSort('date');
90
+        	$objectTable->setDefaultOrder('DESC');
91 91
 
92
-        $objectTable->render();
92
+        	$objectTable->render();
93 93
 
94
-        echo '<br>';
95
-        smart_close_collapsable('sentlinks');
96
-        echo '<br>';
94
+        	echo '<br>';
95
+        	smart_close_collapsable('sentlinks');
96
+        	echo '<br>';
97 97
 
98
-        break;
98
+        	break;
99 99
 }
100 100
 
101 101
 //smart_modFooter();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
  * Licence: GNU
12 12
  */
13 13
 
14
-require_once __DIR__ . '/admin_header.php';
15
-require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
16
-require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectlink.php';
14
+require_once __DIR__.'/admin_header.php';
15
+require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php';
16
+require_once SMARTOBJECT_ROOT_PATH.'class/smartobjectlink.php';
17 17
 $adminObject = \Xmf\Module\Admin::getInstance();
18 18
 
19 19
 $smartobjectLinkHandler = xoops_getModuleHandler('link');
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 switch ($op) {
31 31
 
32 32
     case 'del':
33
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
33
+        require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjectcontroller.php';
34 34
         $controller = new SmartObjectController($smartobjectLinkHandler);
35 35
         $controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM);
36 36
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $linkObj = $smartobjectLinkHandler->get($linkid);
42 42
 
43 43
         if ($linkObj->isNew()) {
44
-            redirect_header(SMARTOBJECT_URL . 'admin/link.php', 3, _AM_SOBJECT_LINK_NOT_FOUND);
44
+            redirect_header(SMARTOBJECT_URL.'admin/link.php', 3, _AM_SOBJECT_LINK_NOT_FOUND);
45 45
         }
46 46
 
47 47
         smart_xoops_cp_header();
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
         smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINK_DISPLAY, _AM_SOBJECT_SENT_LINK_DISPLAY_INFO);
52 52
 
53
-        require_once XOOPS_ROOT_PATH . '/class/template.php';
53
+        require_once XOOPS_ROOT_PATH.'/class/template.php';
54 54
 
55 55
         // ---
56 56
         // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINKS, _AM_SOBJECT_SENT_LINKS_INFO);
79 79
 
80
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
80
+        require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php';
81 81
         $objectTable = new SmartObjectTable($smartobjectLinkHandler, null, ['delete']);
82 82
         $objectTable->addColumn(new SmartObjectColumn('date'));
83 83
         $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align = 'left', $width = false, 'getFromInfo'));
@@ -100,4 +100,4 @@  discard block
 block discarded – undo
100 100
 
101 101
 //smart_modFooter();
102 102
 //xoops_cp_footer();
103
-require_once __DIR__ . '/admin_footer.php';
103
+require_once __DIR__.'/admin_footer.php';
Please login to merge, or discard this patch.
admin/rating.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
 
12 12
 function editclass($showmenu = false, $ratingid = 0)
13 13
 {
14
-    global $smartobjectRatingHandler;
15
-
16
-    $ratingObj = $smartobjectRatingHandler->get($ratingid);
17
-
18
-    if (!$ratingObj->isNew()) {
19
-        if ($showmenu) {
20
-            //smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _AM_SOBJECT_EDITING);
21
-        }
22
-        smart_collapsableBar('ratingedit', _AM_SOBJECT_RATINGS_EDIT, _AM_SOBJECT_RATINGS_EDIT_INFO);
23
-
24
-        $sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_EDIT, 'addrating');
25
-        $sform->display();
26
-        smart_close_collapsable('ratingedit');
27
-    } else {
28
-        $ratingObj->hideFieldFromForm(['item', 'itemid', 'uid', 'date', 'rate']);
29
-
30
-        if (isset($_POST['op'])) {
31
-            $controller = new SmartObjectController($smartobjectRatingHandler);
32
-            $controller->postDataToObject($ratingObj);
33
-
34
-            if ($_POST['op'] === 'changedField') {
35
-                switch ($_POST['changedField']) {
36
-                    case 'dirname':
37
-                        $ratingObj->showFieldOnForm(['item', 'itemid', 'uid', 'date', 'rate']);
38
-                        break;
39
-                }
40
-            }
41
-        }
42
-
43
-        if ($showmenu) {
44
-            //smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _CO_SOBJECT_CREATINGNEW);
45
-        }
46
-
47
-        smart_collapsableBar('ratingcreate', _AM_SOBJECT_RATINGS_CREATE, _AM_SOBJECT_RATINGS_CREATE_INFO);
48
-        $sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_CREATE, 'addrating');
49
-        $sform->display();
50
-        smart_close_collapsable('ratingcreate');
51
-    }
14
+	global $smartobjectRatingHandler;
15
+
16
+	$ratingObj = $smartobjectRatingHandler->get($ratingid);
17
+
18
+	if (!$ratingObj->isNew()) {
19
+		if ($showmenu) {
20
+			//smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _AM_SOBJECT_EDITING);
21
+		}
22
+		smart_collapsableBar('ratingedit', _AM_SOBJECT_RATINGS_EDIT, _AM_SOBJECT_RATINGS_EDIT_INFO);
23
+
24
+		$sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_EDIT, 'addrating');
25
+		$sform->display();
26
+		smart_close_collapsable('ratingedit');
27
+	} else {
28
+		$ratingObj->hideFieldFromForm(['item', 'itemid', 'uid', 'date', 'rate']);
29
+
30
+		if (isset($_POST['op'])) {
31
+			$controller = new SmartObjectController($smartobjectRatingHandler);
32
+			$controller->postDataToObject($ratingObj);
33
+
34
+			if ($_POST['op'] === 'changedField') {
35
+				switch ($_POST['changedField']) {
36
+					case 'dirname':
37
+						$ratingObj->showFieldOnForm(['item', 'itemid', 'uid', 'date', 'rate']);
38
+						break;
39
+				}
40
+			}
41
+		}
42
+
43
+		if ($showmenu) {
44
+			//smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _CO_SOBJECT_CREATINGNEW);
45
+		}
46
+
47
+		smart_collapsableBar('ratingcreate', _AM_SOBJECT_RATINGS_CREATE, _AM_SOBJECT_RATINGS_CREATE_INFO);
48
+		$sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_CREATE, 'addrating');
49
+		$sform->display();
50
+		smart_close_collapsable('ratingcreate');
51
+	}
52 52
 }
53 53
 
54 54
 require_once __DIR__ . '/admin_header.php';
@@ -60,60 +60,60 @@  discard block
 block discarded – undo
60 60
 $op = '';
61 61
 
62 62
 if (isset($_GET['op'])) {
63
-    $op = $_GET['op'];
63
+	$op = $_GET['op'];
64 64
 }
65 65
 if (isset($_POST['op'])) {
66
-    $op = $_POST['op'];
66
+	$op = $_POST['op'];
67 67
 }
68 68
 
69 69
 switch ($op) {
70
-    case 'mod':
71
-    case 'changedField':
70
+	case 'mod':
71
+	case 'changedField':
72 72
 
73
-        $ratingid = isset($_GET['ratingid']) ? (int)$_GET['ratingid'] : 0;
73
+		$ratingid = isset($_GET['ratingid']) ? (int)$_GET['ratingid'] : 0;
74 74
 
75
-        smart_xoops_cp_header();
76
-        $adminObject->displayNavigation(basename(__FILE__));
75
+		smart_xoops_cp_header();
76
+		$adminObject->displayNavigation(basename(__FILE__));
77 77
 
78
-        editclass(true, $ratingid);
79
-        break;
78
+		editclass(true, $ratingid);
79
+		break;
80 80
 
81
-    case 'addrating':
82
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
83
-        $controller = new SmartObjectController($smartobjectRatingHandler);
84
-        $controller->storeFromDefaultForm(_AM_SOBJECT_RATINGS_CREATED, _AM_SOBJECT_RATINGS_MODIFIED, SMARTOBJECT_URL . 'admin/rating.php');
81
+	case 'addrating':
82
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
83
+		$controller = new SmartObjectController($smartobjectRatingHandler);
84
+		$controller->storeFromDefaultForm(_AM_SOBJECT_RATINGS_CREATED, _AM_SOBJECT_RATINGS_MODIFIED, SMARTOBJECT_URL . 'admin/rating.php');
85 85
 
86
-        break;
86
+		break;
87 87
 
88
-    case 'del':
89
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
90
-        $controller = new SmartObjectController($smartobjectRatingHandler);
91
-        $controller->handleObjectDeletion();
88
+	case 'del':
89
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
90
+		$controller = new SmartObjectController($smartobjectRatingHandler);
91
+		$controller->handleObjectDeletion();
92 92
 
93
-        break;
93
+		break;
94 94
 
95
-    default:
95
+	default:
96 96
 
97
-        smart_xoops_cp_header();
98
-        $adminObject->displayNavigation(basename(__FILE__));
97
+		smart_xoops_cp_header();
98
+		$adminObject->displayNavigation(basename(__FILE__));
99 99
 
100
-        //smart_adminMenu(4, _AM_SOBJECT_RATINGS);
100
+		//smart_adminMenu(4, _AM_SOBJECT_RATINGS);
101 101
 
102
-        smart_collapsableBar('createdratings', _AM_SOBJECT_RATINGS, _AM_SOBJECT_RATINGS_DSC);
102
+		smart_collapsableBar('createdratings', _AM_SOBJECT_RATINGS, _AM_SOBJECT_RATINGS_DSC);
103 103
 
104
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
105
-        $objectTable = new SmartObjectTable($smartobjectRatingHandler);
106
-        $objectTable->addColumn(new SmartObjectColumn('name', 'left'));
107
-        $objectTable->addColumn(new SmartObjectColumn('dirname', 'left'));
108
-        $objectTable->addColumn(new SmartObjectColumn('item', 'left', false, 'getItemValue'));
109
-        $objectTable->addColumn(new SmartObjectColumn('date', 'center', 150));
110
-        $objectTable->addColumn(new SmartObjectColumn('rate', 'center', 40, 'getRateValue'));
104
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
105
+		$objectTable = new SmartObjectTable($smartobjectRatingHandler);
106
+		$objectTable->addColumn(new SmartObjectColumn('name', 'left'));
107
+		$objectTable->addColumn(new SmartObjectColumn('dirname', 'left'));
108
+		$objectTable->addColumn(new SmartObjectColumn('item', 'left', false, 'getItemValue'));
109
+		$objectTable->addColumn(new SmartObjectColumn('date', 'center', 150));
110
+		$objectTable->addColumn(new SmartObjectColumn('rate', 'center', 40, 'getRateValue'));
111 111
 
112
-        //      $objectTable->addCustomAction('getCreateItemLink');
113
-        //      $objectTable->addCustomAction('getCreateAttributLink');
112
+		//      $objectTable->addCustomAction('getCreateItemLink');
113
+		//      $objectTable->addCustomAction('getCreateAttributLink');
114 114
 
115
-        $objectTable->addIntroButton('addrating', 'rating.php?op=mod', _AM_SOBJECT_RATINGS_CREATE);
116
-        /*
115
+		$objectTable->addIntroButton('addrating', 'rating.php?op=mod', _AM_SOBJECT_RATINGS_CREATE);
116
+		/*
117 117
                 $criteria_upcoming = new CriteriaCompo();
118 118
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
119 119
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
                 ));
139 139
         */
140 140
 
141
-        $objectTable->render();
141
+		$objectTable->render();
142 142
 
143
-        echo '<br>';
144
-        smart_close_collapsable('createdratings');
145
-        echo '<br>';
143
+		echo '<br>';
144
+		smart_close_collapsable('createdratings');
145
+		echo '<br>';
146 146
 
147
-        break;
147
+		break;
148 148
 }
149 149
 
150 150
 //smart_modFooter();
Please login to merge, or discard this patch.
admin/customtag.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -12,32 +12,32 @@  discard block
 block discarded – undo
12 12
 
13 13
 function editcustomtag($showmenu = false, $customtagid = 0, $clone = false)
14 14
 {
15
-    global $smartobjectCustomtagHandler;
16
-
17
-    $customtagObj = $smartobjectCustomtagHandler->get($customtagid);
18
-
19
-    if (!$clone && !$customtagObj->isNew()) {
20
-        if ($showmenu) {
21
-            //smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS . " > " . _AM_SOBJECT_EDITING);
22
-        }
23
-        smart_collapsableBar('customtagedit', _AM_SOBJECT_CUSTOMTAGS_EDIT, _AM_SOBJECT_CUSTOMTAGS_EDIT_INFO);
24
-
25
-        $sform = $customtagObj->getForm(_AM_SOBJECT_CUSTOMTAGS_EDIT, 'addcustomtag');
26
-        $sform->display();
27
-        smart_close_collapsable('customtagedit');
28
-    } else {
29
-        $customtagObj->setVar('customtagid', 0);
30
-        $customtagObj->setVar('tag', '');
31
-
32
-        if ($showmenu) {
33
-            //smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS . " > " . _CO_SOBJECT_CREATINGNEW);
34
-        }
35
-
36
-        smart_collapsableBar('customtagcreate', _AM_SOBJECT_CUSTOMTAGS_CREATE, _AM_SOBJECT_CUSTOMTAGS_CREATE_INFO);
37
-        $sform = $customtagObj->getForm(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'addcustomtag');
38
-        $sform->display();
39
-        smart_close_collapsable('customtagcreate');
40
-    }
15
+	global $smartobjectCustomtagHandler;
16
+
17
+	$customtagObj = $smartobjectCustomtagHandler->get($customtagid);
18
+
19
+	if (!$clone && !$customtagObj->isNew()) {
20
+		if ($showmenu) {
21
+			//smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS . " > " . _AM_SOBJECT_EDITING);
22
+		}
23
+		smart_collapsableBar('customtagedit', _AM_SOBJECT_CUSTOMTAGS_EDIT, _AM_SOBJECT_CUSTOMTAGS_EDIT_INFO);
24
+
25
+		$sform = $customtagObj->getForm(_AM_SOBJECT_CUSTOMTAGS_EDIT, 'addcustomtag');
26
+		$sform->display();
27
+		smart_close_collapsable('customtagedit');
28
+	} else {
29
+		$customtagObj->setVar('customtagid', 0);
30
+		$customtagObj->setVar('tag', '');
31
+
32
+		if ($showmenu) {
33
+			//smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS . " > " . _CO_SOBJECT_CREATINGNEW);
34
+		}
35
+
36
+		smart_collapsableBar('customtagcreate', _AM_SOBJECT_CUSTOMTAGS_CREATE, _AM_SOBJECT_CUSTOMTAGS_CREATE_INFO);
37
+		$sform = $customtagObj->getForm(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'addcustomtag');
38
+		$sform->display();
39
+		smart_close_collapsable('customtagcreate');
40
+	}
41 41
 }
42 42
 
43 43
 require_once __DIR__ . '/admin_header.php';
@@ -52,70 +52,70 @@  discard block
 block discarded – undo
52 52
 $op = '';
53 53
 
54 54
 if (isset($_GET['op'])) {
55
-    $op = $_GET['op'];
55
+	$op = $_GET['op'];
56 56
 }
57 57
 if (isset($_POST['op'])) {
58
-    $op = $_POST['op'];
58
+	$op = $_POST['op'];
59 59
 }
60 60
 
61 61
 switch ($op) {
62
-    case 'mod':
62
+	case 'mod':
63 63
 
64
-        $customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
64
+		$customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
65 65
 
66
-        smart_xoops_cp_header();
67
-        $adminObject->displayNavigation(basename(__FILE__));
66
+		smart_xoops_cp_header();
67
+		$adminObject->displayNavigation(basename(__FILE__));
68 68
 
69
-        editcustomtag(true, $customtagid);
70
-        break;
69
+		editcustomtag(true, $customtagid);
70
+		break;
71 71
 
72
-    case 'clone':
72
+	case 'clone':
73 73
 
74
-        $customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
74
+		$customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
75 75
 
76
-        smart_xoops_cp_header();
77
-        $adminObject->displayNavigation(basename(__FILE__));
76
+		smart_xoops_cp_header();
77
+		$adminObject->displayNavigation(basename(__FILE__));
78 78
 
79
-        editcustomtag(true, $customtagid, true);
80
-        break;
79
+		editcustomtag(true, $customtagid, true);
80
+		break;
81 81
 
82
-    case 'addcustomtag':
83
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
84
-        $controller = new SmartObjectController($smartobjectCustomtagHandler);
85
-        $controller->storeFromDefaultForm(_AM_SOBJECT_CUSTOMTAGS_CREATED, _AM_SOBJECT_CUSTOMTAGS_MODIFIED);
86
-        break;
82
+	case 'addcustomtag':
83
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
84
+		$controller = new SmartObjectController($smartobjectCustomtagHandler);
85
+		$controller->storeFromDefaultForm(_AM_SOBJECT_CUSTOMTAGS_CREATED, _AM_SOBJECT_CUSTOMTAGS_MODIFIED);
86
+		break;
87 87
 
88
-    case 'del':
88
+	case 'del':
89 89
 
90
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
91
-        $controller = new SmartObjectController($smartobjectCustomtagHandler);
92
-        $controller->handleObjectDeletion();
90
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
91
+		$controller = new SmartObjectController($smartobjectCustomtagHandler);
92
+		$controller->handleObjectDeletion();
93 93
 
94
-        break;
94
+		break;
95 95
 
96
-    default:
96
+	default:
97 97
 
98
-        smart_xoops_cp_header();
99
-        $adminObject->displayNavigation(basename(__FILE__));
100
-        $adminObject->addItemButton(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'customtag.php?op=mod', 'add', '');
101
-        $adminObject->displayButton('left', '');
98
+		smart_xoops_cp_header();
99
+		$adminObject->displayNavigation(basename(__FILE__));
100
+		$adminObject->addItemButton(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'customtag.php?op=mod', 'add', '');
101
+		$adminObject->displayButton('left', '');
102 102
 
103
-        //smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS);
103
+		//smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS);
104 104
 
105
-        smart_collapsableBar('createdcustomtags', _AM_SOBJECT_CUSTOMTAGS, _AM_SOBJECT_CUSTOMTAGS_DSC);
105
+		smart_collapsableBar('createdcustomtags', _AM_SOBJECT_CUSTOMTAGS, _AM_SOBJECT_CUSTOMTAGS_DSC);
106 106
 
107
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
108
-        $objectTable = new SmartObjectTable($smartobjectCustomtagHandler);
109
-        $objectTable->addColumn(new SmartObjectColumn('name', 'left', 150, 'getCustomtagName'));
110
-        $objectTable->addColumn(new SmartObjectColumn('description', 'left'));
111
-        $objectTable->addColumn(new SmartObjectColumn('language', 'center', 150));
107
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
108
+		$objectTable = new SmartObjectTable($smartobjectCustomtagHandler);
109
+		$objectTable->addColumn(new SmartObjectColumn('name', 'left', 150, 'getCustomtagName'));
110
+		$objectTable->addColumn(new SmartObjectColumn('description', 'left'));
111
+		$objectTable->addColumn(new SmartObjectColumn('language', 'center', 150));
112 112
 
113
-        //      $objectTable->addCustomAction('getCreateItemLink');
114
-        //      $objectTable->addCustomAction('getCreateAttributLink');
113
+		//      $objectTable->addCustomAction('getCreateItemLink');
114
+		//      $objectTable->addCustomAction('getCreateAttributLink');
115 115
 
116
-        //      $objectTable->addIntroButton('addcustomtag', 'customtag.php?op=mod', _AM_SOBJECT_CUSTOMTAGS_CREATE); //mb button
116
+		//      $objectTable->addIntroButton('addcustomtag', 'customtag.php?op=mod', _AM_SOBJECT_CUSTOMTAGS_CREATE); //mb button
117 117
 
118
-        /*
118
+		/*
119 119
                 $criteria_upcoming = new CriteriaCompo();
120 120
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
121 121
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                                             'criteria' => $criteria_last30days
140 140
                 ));
141 141
         */
142
-        $objectTable->addQuickSearch(['title', 'summary', 'description']);
143
-        $objectTable->addCustomAction('getCloneLink');
142
+		$objectTable->addQuickSearch(['title', 'summary', 'description']);
143
+		$objectTable->addCustomAction('getCloneLink');
144 144
 
145
-        $objectTable->render();
145
+		$objectTable->render();
146 146
 
147
-        echo '<br>';
148
-        smart_close_collapsable('createdcustomtags');
149
-        echo '<br>';
147
+		echo '<br>';
148
+		smart_close_collapsable('createdcustomtags');
149
+		echo '<br>';
150 150
 
151
-        break;
151
+		break;
152 152
 }
153 153
 
154 154
 //smart_modFooter();
Please login to merge, or discard this patch.
Switch Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -59,63 +59,63 @@  discard block
 block discarded – undo
59 59
 }
60 60
 
61 61
 switch ($op) {
62
-    case 'mod':
62
+    	case 'mod':
63 63
 
64
-        $customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
64
+        	$customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
65 65
 
66
-        smart_xoops_cp_header();
67
-        $adminObject->displayNavigation(basename(__FILE__));
66
+        	smart_xoops_cp_header();
67
+        	$adminObject->displayNavigation(basename(__FILE__));
68 68
 
69
-        editcustomtag(true, $customtagid);
70
-        break;
69
+        	editcustomtag(true, $customtagid);
70
+        	break;
71 71
 
72
-    case 'clone':
72
+    	case 'clone':
73 73
 
74
-        $customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
74
+        	$customtagid = isset($_GET['customtagid']) ? (int)$_GET['customtagid'] : 0;
75 75
 
76
-        smart_xoops_cp_header();
77
-        $adminObject->displayNavigation(basename(__FILE__));
76
+        	smart_xoops_cp_header();
77
+        	$adminObject->displayNavigation(basename(__FILE__));
78 78
 
79
-        editcustomtag(true, $customtagid, true);
80
-        break;
79
+        	editcustomtag(true, $customtagid, true);
80
+        	break;
81 81
 
82
-    case 'addcustomtag':
83
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
84
-        $controller = new SmartObjectController($smartobjectCustomtagHandler);
85
-        $controller->storeFromDefaultForm(_AM_SOBJECT_CUSTOMTAGS_CREATED, _AM_SOBJECT_CUSTOMTAGS_MODIFIED);
86
-        break;
82
+    	case 'addcustomtag':
83
+        	require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
84
+        	$controller = new SmartObjectController($smartobjectCustomtagHandler);
85
+        	$controller->storeFromDefaultForm(_AM_SOBJECT_CUSTOMTAGS_CREATED, _AM_SOBJECT_CUSTOMTAGS_MODIFIED);
86
+        	break;
87 87
 
88
-    case 'del':
88
+    	case 'del':
89 89
 
90
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
91
-        $controller = new SmartObjectController($smartobjectCustomtagHandler);
92
-        $controller->handleObjectDeletion();
90
+        	require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
91
+        	$controller = new SmartObjectController($smartobjectCustomtagHandler);
92
+        	$controller->handleObjectDeletion();
93 93
 
94
-        break;
94
+        	break;
95 95
 
96
-    default:
96
+    	default:
97 97
 
98
-        smart_xoops_cp_header();
99
-        $adminObject->displayNavigation(basename(__FILE__));
100
-        $adminObject->addItemButton(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'customtag.php?op=mod', 'add', '');
101
-        $adminObject->displayButton('left', '');
98
+        	smart_xoops_cp_header();
99
+        	$adminObject->displayNavigation(basename(__FILE__));
100
+        	$adminObject->addItemButton(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'customtag.php?op=mod', 'add', '');
101
+        	$adminObject->displayButton('left', '');
102 102
 
103
-        //smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS);
103
+        	//smart_adminMenu(2, _AM_SOBJECT_CUSTOMTAGS);
104 104
 
105
-        smart_collapsableBar('createdcustomtags', _AM_SOBJECT_CUSTOMTAGS, _AM_SOBJECT_CUSTOMTAGS_DSC);
105
+        	smart_collapsableBar('createdcustomtags', _AM_SOBJECT_CUSTOMTAGS, _AM_SOBJECT_CUSTOMTAGS_DSC);
106 106
 
107
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
108
-        $objectTable = new SmartObjectTable($smartobjectCustomtagHandler);
109
-        $objectTable->addColumn(new SmartObjectColumn('name', 'left', 150, 'getCustomtagName'));
110
-        $objectTable->addColumn(new SmartObjectColumn('description', 'left'));
111
-        $objectTable->addColumn(new SmartObjectColumn('language', 'center', 150));
107
+        	require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
108
+        	$objectTable = new SmartObjectTable($smartobjectCustomtagHandler);
109
+        	$objectTable->addColumn(new SmartObjectColumn('name', 'left', 150, 'getCustomtagName'));
110
+        	$objectTable->addColumn(new SmartObjectColumn('description', 'left'));
111
+        	$objectTable->addColumn(new SmartObjectColumn('language', 'center', 150));
112 112
 
113
-        //      $objectTable->addCustomAction('getCreateItemLink');
114
-        //      $objectTable->addCustomAction('getCreateAttributLink');
113
+        	//      $objectTable->addCustomAction('getCreateItemLink');
114
+        	//      $objectTable->addCustomAction('getCreateAttributLink');
115 115
 
116
-        //      $objectTable->addIntroButton('addcustomtag', 'customtag.php?op=mod', _AM_SOBJECT_CUSTOMTAGS_CREATE); //mb button
116
+        	//      $objectTable->addIntroButton('addcustomtag', 'customtag.php?op=mod', _AM_SOBJECT_CUSTOMTAGS_CREATE); //mb button
117 117
 
118
-        /*
118
+        	/*
119 119
                 $criteria_upcoming = new CriteriaCompo();
120 120
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
121 121
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                                             'criteria' => $criteria_last30days
140 140
                 ));
141 141
         */
142
-        $objectTable->addQuickSearch(['title', 'summary', 'description']);
143
-        $objectTable->addCustomAction('getCloneLink');
142
+        	$objectTable->addQuickSearch(['title', 'summary', 'description']);
143
+        	$objectTable->addCustomAction('getCloneLink');
144 144
 
145
-        $objectTable->render();
145
+        	$objectTable->render();
146 146
 
147
-        echo '<br>';
148
-        smart_close_collapsable('createdcustomtags');
149
-        echo '<br>';
147
+        	echo '<br>';
148
+        	smart_close_collapsable('createdcustomtags');
149
+        	echo '<br>';
150 150
 
151
-        break;
151
+        	break;
152 152
 }
153 153
 
154 154
 //smart_modFooter();
Please login to merge, or discard this patch.
admin/update.php 2 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -18,180 +18,180 @@  discard block
 block discarded – undo
18 18
 // =========================================================================================
19 19
 function update_tables_to_300()
20 20
 {
21
-    $dbupdater = new WfdownloadsDbupdater();
21
+	$dbupdater = new WfdownloadsDbupdater();
22 22
 
23
-    if (!wfdownloads_TableExists('wfdownloads_meta')) {
24
-        // Create table wfdownloads_meta
25
-        $table = new WfdownloadsTable('wfdownloads_meta');
26
-        $table->setStructure("CREATE TABLE %s (
23
+	if (!wfdownloads_TableExists('wfdownloads_meta')) {
24
+		// Create table wfdownloads_meta
25
+		$table = new WfdownloadsTable('wfdownloads_meta');
26
+		$table->setStructure("CREATE TABLE %s (
27 27
                                 metakey varchar(50) NOT NULL default '',
28 28
                                 metavalue varchar(255) NOT NULL default '',
29 29
                                 PRIMARY KEY (metakey))
30 30
                                 ENGINE=MyISAM;");
31 31
 
32
-        $table->setData(sprintf("'version', %s", round($GLOBALS['xoopsModule']->getVar('version') / 100, 2)));
33
-        if ($dbupdater->updateTable($table)) {
34
-            echo 'wfdownloads_meta table created<br>';
35
-        }
36
-    }
32
+		$table->setData(sprintf("'version', %s", round($GLOBALS['xoopsModule']->getVar('version') / 100, 2)));
33
+		if ($dbupdater->updateTable($table)) {
34
+			echo 'wfdownloads_meta table created<br>';
35
+		}
36
+	}
37 37
 
38
-    $download_fields = [
39
-        'lid'           => ['Type' => 'int(11) unsigned NOT NULL auto_increment', 'Default' => false],
40
-        'cid'           => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
41
-        'title'         => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
42
-        'url'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
43
-        'filename'      => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
44
-        'filetype'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
45
-        'homepage'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
46
-        'version'       => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
47
-        'size'          => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
48
-        'platform'      => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
49
-        'screenshot'    => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
50
-        'submitter'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
51
-        'publisher'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
52
-        'status'        => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
53
-        'date'          => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
54
-        'hits'          => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
55
-        'rating'        => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
56
-        'votes'         => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
57
-        'comments'      => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
58
-        'license'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
59
-        'mirror'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
60
-        'price'         => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
61
-        'paypalemail'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
62
-        'features'      => ['Type' => 'text NOT NULL', 'Default' => false],
63
-        'requirements'  => ['Type' => 'text NOT NULL', 'Default' => false],
64
-        'homepagetitle' => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
65
-        'forumid'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
66
-        'limitations'   => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
67
-        'dhistory'      => ['Type' => 'text NOT NULL', 'Default' => false],
68
-        'published'     => ['Type' => "int(11) NOT NULL default '1089662528'", 'Default' => true],
69
-        'expired'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
70
-        'updated'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
71
-        'offline'       => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
72
-        'description'   => ['Type' => 'text NOT NULL', 'Default' => false],
73
-        'ipaddress'     => ['Type' => "varchar(120) NOT NULL default '0'", 'Default' => true],
74
-        'notifypub'     => ['Type' => "int(1) NOT NULL default '0'", 'Default' => true],
75
-        'summary'       => ['Type' => 'text NOT NULL', 'Default' => false]
76
-    ];
38
+	$download_fields = [
39
+		'lid'           => ['Type' => 'int(11) unsigned NOT NULL auto_increment', 'Default' => false],
40
+		'cid'           => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
41
+		'title'         => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
42
+		'url'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
43
+		'filename'      => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
44
+		'filetype'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
45
+		'homepage'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
46
+		'version'       => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
47
+		'size'          => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
48
+		'platform'      => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
49
+		'screenshot'    => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
50
+		'submitter'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
51
+		'publisher'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
52
+		'status'        => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
53
+		'date'          => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
54
+		'hits'          => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
55
+		'rating'        => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
56
+		'votes'         => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
57
+		'comments'      => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
58
+		'license'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
59
+		'mirror'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
60
+		'price'         => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
61
+		'paypalemail'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
62
+		'features'      => ['Type' => 'text NOT NULL', 'Default' => false],
63
+		'requirements'  => ['Type' => 'text NOT NULL', 'Default' => false],
64
+		'homepagetitle' => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
65
+		'forumid'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
66
+		'limitations'   => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
67
+		'dhistory'      => ['Type' => 'text NOT NULL', 'Default' => false],
68
+		'published'     => ['Type' => "int(11) NOT NULL default '1089662528'", 'Default' => true],
69
+		'expired'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
70
+		'updated'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
71
+		'offline'       => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
72
+		'description'   => ['Type' => 'text NOT NULL', 'Default' => false],
73
+		'ipaddress'     => ['Type' => "varchar(120) NOT NULL default '0'", 'Default' => true],
74
+		'notifypub'     => ['Type' => "int(1) NOT NULL default '0'", 'Default' => true],
75
+		'summary'       => ['Type' => 'text NOT NULL', 'Default' => false]
76
+	];
77 77
 
78
-    $renamed_fields = [
79
-        'logourl' => 'screenshot'
80
-    ];
78
+	$renamed_fields = [
79
+		'logourl' => 'screenshot'
80
+	];
81 81
 
82
-    echo '<br><b>Checking Download table</b><br>';
83
-    $downloadHandler = xoops_getModuleHandler('download', 'wfdownloads');
84
-    $download_table  = new WfdownloadsTable('wfdownloads_downloads');
85
-    $fields          = get_table_info($downloadHandler->table, $download_fields);
86
-    // Check for renamed fields
87
-    rename_fields($download_table, $renamed_fields, $fields, $download_fields);
88
-    update_table($download_fields, $fields, $download_table);
89
-    if ($dbupdater->updateTable($download_table)) {
90
-        echo 'Downloads table updated<br>';
91
-    }
92
-    unset($fields);
82
+	echo '<br><b>Checking Download table</b><br>';
83
+	$downloadHandler = xoops_getModuleHandler('download', 'wfdownloads');
84
+	$download_table  = new WfdownloadsTable('wfdownloads_downloads');
85
+	$fields          = get_table_info($downloadHandler->table, $download_fields);
86
+	// Check for renamed fields
87
+	rename_fields($download_table, $renamed_fields, $fields, $download_fields);
88
+	update_table($download_fields, $fields, $download_table);
89
+	if ($dbupdater->updateTable($download_table)) {
90
+		echo 'Downloads table updated<br>';
91
+	}
92
+	unset($fields);
93 93
 
94
-    $mod_fields = [
95
-        'requestid'       => ['Type' => 'int(11) NOT NULL auto_increment', 'Default' => false],
96
-        'lid'             => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
97
-        'cid'             => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
98
-        'title'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
99
-        'url'             => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
100
-        'filename'        => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
101
-        'filetype'        => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
102
-        'homepage'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
103
-        'version'         => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
104
-        'size'            => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
105
-        'platform'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
106
-        'screenshot'      => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
107
-        'submitter'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
108
-        'publisher'       => ['Type' => 'text NOT NULL', 'Default' => false],
109
-        'status'          => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
110
-        'date'            => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
111
-        'hits'            => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
112
-        'rating'          => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
113
-        'votes'           => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
114
-        'comments'        => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
115
-        'license'         => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
116
-        'mirror'          => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
117
-        'price'           => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
118
-        'paypalemail'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
119
-        'features'        => ['Type' => 'text NOT NULL', 'Default' => false],
120
-        'requirements'    => ['Type' => 'text NOT NULL', 'Default' => false],
121
-        'homepagetitle'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
122
-        'forumid'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
123
-        'limitations'     => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
124
-        'dhistory'        => ['Type' => 'text NOT NULL', 'Default' => false],
125
-        'published'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
126
-        'expired'         => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
127
-        'updated'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
128
-        'offline'         => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
129
-        'summary'         => ['Type' => 'text NOT NULL', 'Default' => false],
130
-        'description'     => ['Type' => 'text NOT NULL', 'Default' => false],
131
-        'modifysubmitter' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
132
-        'requestdate'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
133
-    ];
94
+	$mod_fields = [
95
+		'requestid'       => ['Type' => 'int(11) NOT NULL auto_increment', 'Default' => false],
96
+		'lid'             => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
97
+		'cid'             => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
98
+		'title'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
99
+		'url'             => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
100
+		'filename'        => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
101
+		'filetype'        => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
102
+		'homepage'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
103
+		'version'         => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
104
+		'size'            => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
105
+		'platform'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
106
+		'screenshot'      => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
107
+		'submitter'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
108
+		'publisher'       => ['Type' => 'text NOT NULL', 'Default' => false],
109
+		'status'          => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
110
+		'date'            => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
111
+		'hits'            => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
112
+		'rating'          => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
113
+		'votes'           => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
114
+		'comments'        => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
115
+		'license'         => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
116
+		'mirror'          => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
117
+		'price'           => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
118
+		'paypalemail'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
119
+		'features'        => ['Type' => 'text NOT NULL', 'Default' => false],
120
+		'requirements'    => ['Type' => 'text NOT NULL', 'Default' => false],
121
+		'homepagetitle'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
122
+		'forumid'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
123
+		'limitations'     => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
124
+		'dhistory'        => ['Type' => 'text NOT NULL', 'Default' => false],
125
+		'published'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
126
+		'expired'         => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
127
+		'updated'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
128
+		'offline'         => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
129
+		'summary'         => ['Type' => 'text NOT NULL', 'Default' => false],
130
+		'description'     => ['Type' => 'text NOT NULL', 'Default' => false],
131
+		'modifysubmitter' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
132
+		'requestdate'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
133
+	];
134 134
 
135
-    $renamed_fields = [
136
-        'logourl' => 'screenshot'
137
-    ];
135
+	$renamed_fields = [
136
+		'logourl' => 'screenshot'
137
+	];
138 138
 
139
-    echo '<br><b>Checking Modified Downloads table</b><br>';
140
-    $moduleHandler = xoops_getModuleHandler('modification', 'wfdownloads');
141
-    $mod_table     = new WfdownloadsTable('wfdownloads_mod');
142
-    $fields        = get_table_info($moduleHandler->table, $mod_fields);
143
-    rename_fields($mod_table, $renamed_fields, $fields, $mod_fields);
144
-    update_table($mod_fields, $fields, $mod_table);
145
-    if ($dbupdater->updateTable($mod_table)) {
146
-        echo 'Modified Downloads table updated <br>';
147
-    }
148
-    unset($fields);
139
+	echo '<br><b>Checking Modified Downloads table</b><br>';
140
+	$moduleHandler = xoops_getModuleHandler('modification', 'wfdownloads');
141
+	$mod_table     = new WfdownloadsTable('wfdownloads_mod');
142
+	$fields        = get_table_info($moduleHandler->table, $mod_fields);
143
+	rename_fields($mod_table, $renamed_fields, $fields, $mod_fields);
144
+	update_table($mod_fields, $fields, $mod_table);
145
+	if ($dbupdater->updateTable($mod_table)) {
146
+		echo 'Modified Downloads table updated <br>';
147
+	}
148
+	unset($fields);
149 149
 
150
-    $cat_fields = [
151
-        'cid'          => ['Type' => 'int(5) unsigned NOT NULL auto_increment', 'Default' => false],
152
-        'pid'          => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
153
-        'title'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
154
-        'imgurl'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
155
-        'description'  => ['Type' => "text NULL", 'Default' => true],
156
-        'total'        => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
157
-        'summary'      => ['Type' => 'text NOT NULL', 'Default' => false],
158
-        'spotlighttop' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
159
-        'spotlighthis' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
160
-        'dohtml'       => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
161
-        'dosmiley'     => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
162
-        'doxcode'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
163
-        'doimage'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
164
-        'dobr'         => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
165
-        'weight'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
166
-    ];
167
-    echo '<br><b>Checking Category table</b><br>';
168
-    $catHandler = xoops_getModuleHandler('category', 'wfdownloads');
169
-    $cat_table  = new WfdownloadsTable('wfdownloads_cat');
170
-    $fields     = get_table_info($catHandler->table, $cat_fields);
171
-    update_table($cat_fields, $fields, $cat_table);
172
-    if ($dbupdater->updateTable($cat_table)) {
173
-        echo 'Category table updated<br>';
174
-    }
175
-    unset($fields);
150
+	$cat_fields = [
151
+		'cid'          => ['Type' => 'int(5) unsigned NOT NULL auto_increment', 'Default' => false],
152
+		'pid'          => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
153
+		'title'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
154
+		'imgurl'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
155
+		'description'  => ['Type' => "text NULL", 'Default' => true],
156
+		'total'        => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
157
+		'summary'      => ['Type' => 'text NOT NULL', 'Default' => false],
158
+		'spotlighttop' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
159
+		'spotlighthis' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
160
+		'dohtml'       => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
161
+		'dosmiley'     => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
162
+		'doxcode'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
163
+		'doimage'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
164
+		'dobr'         => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
165
+		'weight'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
166
+	];
167
+	echo '<br><b>Checking Category table</b><br>';
168
+	$catHandler = xoops_getModuleHandler('category', 'wfdownloads');
169
+	$cat_table  = new WfdownloadsTable('wfdownloads_cat');
170
+	$fields     = get_table_info($catHandler->table, $cat_fields);
171
+	update_table($cat_fields, $fields, $cat_table);
172
+	if ($dbupdater->updateTable($cat_table)) {
173
+		echo 'Category table updated<br>';
174
+	}
175
+	unset($fields);
176 176
 
177
-    $broken_fields = [
178
-        'reportid'     => ['Type' => 'int(5) NOT NULL auto_increment', 'Default' => false],
179
-        'lid'          => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
180
-        'sender'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
181
-        'ip'           => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
182
-        'date'         => ['Type' => "varchar(11) NOT NULL default '0'", 'Default' => true],
183
-        'confirmed'    => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true],
184
-        'acknowledged' => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true]
185
-    ];
186
-    echo '<br><b>Checking Broken Report table</b><br>';
187
-    $brokenHandler = xoops_getModuleHandler('report', 'wfdownloads');
188
-    $broken_table  = new WfdownloadsTable('wfdownloads_broken');
189
-    $fields        = get_table_info($brokenHandler->table, $broken_fields);
190
-    update_table($broken_fields, $fields, $broken_table);
191
-    if ($dbupdater->updateTable($broken_table)) {
192
-        echo 'Broken Reports table updated<br>';
193
-    }
194
-    unset($fields);
177
+	$broken_fields = [
178
+		'reportid'     => ['Type' => 'int(5) NOT NULL auto_increment', 'Default' => false],
179
+		'lid'          => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
180
+		'sender'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
181
+		'ip'           => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
182
+		'date'         => ['Type' => "varchar(11) NOT NULL default '0'", 'Default' => true],
183
+		'confirmed'    => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true],
184
+		'acknowledged' => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true]
185
+	];
186
+	echo '<br><b>Checking Broken Report table</b><br>';
187
+	$brokenHandler = xoops_getModuleHandler('report', 'wfdownloads');
188
+	$broken_table  = new WfdownloadsTable('wfdownloads_broken');
189
+	$fields        = get_table_info($brokenHandler->table, $broken_fields);
190
+	update_table($broken_fields, $fields, $broken_table);
191
+	if ($dbupdater->updateTable($broken_table)) {
192
+		echo 'Broken Reports table updated<br>';
193
+	}
194
+	unset($fields);
195 195
 }
196 196
 
197 197
 // =========================================================================================
@@ -204,48 +204,48 @@  discard block
 block discarded – undo
204 204
  */
205 205
 function invert_nohtm_dohtml_values()
206 206
 {
207
-    $ret = [];
208
-    global $xoopsDB;
209
-    $catHandler = xoops_getModuleHandler('category', 'wfdownloads');
210
-    $result     = $xoopsDB->query('SHOW COLUMNS FROM ' . $catHandler->table);
211
-    while ($existing_field = $xoopsDB->fetchArray($result)) {
212
-        $fields[$existing_field['field']] = $existing_field['type'];
213
-    }
214
-    if (in_array('nohtml', array_keys($fields))) {
215
-        $dbupdater = new WfdownloadsDbupdater();
216
-        //Invert column values
217
-        // alter options in wfdownloads_cat
218
-        $table = new WfdownloadsTable('wfdownloads_cat');
219
-        $table->addAlteredField('nohtml', "dohtml tinyint(1) NOT NULL DEFAULT '1'");
220
-        $table->addAlteredField('nosmiley', "dosmiley tinyint(1) NOT NULL DEFAULT '1'");
221
-        $table->addAlteredField('noxcodes', "doxcode tinyint(1) NOT NULL DEFAULT '1'");
222
-        $table->addAlteredField('noimages', "doimage tinyint(1) NOT NULL DEFAULT '1'");
223
-        $table->addAlteredField('nobreak', "dobr tinyint(1) NOT NULL DEFAULT '1'");
207
+	$ret = [];
208
+	global $xoopsDB;
209
+	$catHandler = xoops_getModuleHandler('category', 'wfdownloads');
210
+	$result     = $xoopsDB->query('SHOW COLUMNS FROM ' . $catHandler->table);
211
+	while ($existing_field = $xoopsDB->fetchArray($result)) {
212
+		$fields[$existing_field['field']] = $existing_field['type'];
213
+	}
214
+	if (in_array('nohtml', array_keys($fields))) {
215
+		$dbupdater = new WfdownloadsDbupdater();
216
+		//Invert column values
217
+		// alter options in wfdownloads_cat
218
+		$table = new WfdownloadsTable('wfdownloads_cat');
219
+		$table->addAlteredField('nohtml', "dohtml tinyint(1) NOT NULL DEFAULT '1'");
220
+		$table->addAlteredField('nosmiley', "dosmiley tinyint(1) NOT NULL DEFAULT '1'");
221
+		$table->addAlteredField('noxcodes', "doxcode tinyint(1) NOT NULL DEFAULT '1'");
222
+		$table->addAlteredField('noimages', "doimage tinyint(1) NOT NULL DEFAULT '1'");
223
+		$table->addAlteredField('nobreak', "dobr tinyint(1) NOT NULL DEFAULT '1'");
224 224
 
225
-        //inverting values no=1 <=> do=0
226
-        // have to store teporarly as value = 2 to
227
-        // avoid putting everithing to same value
228
-        // if you change 1 to 0, then 0 to one,
229
-        // every value will be 1, follow me?
230
-        $table->addUpdatedWhere('dohtml', 2, '=1');
231
-        $table->addUpdatedWhere('dohtml', 1, '=0');
232
-        $table->addUpdatedWhere('dohtml', 0, '=2');
225
+		//inverting values no=1 <=> do=0
226
+		// have to store teporarly as value = 2 to
227
+		// avoid putting everithing to same value
228
+		// if you change 1 to 0, then 0 to one,
229
+		// every value will be 1, follow me?
230
+		$table->addUpdatedWhere('dohtml', 2, '=1');
231
+		$table->addUpdatedWhere('dohtml', 1, '=0');
232
+		$table->addUpdatedWhere('dohtml', 0, '=2');
233 233
 
234
-        $table->addUpdatedWhere('dosmiley', 2, '=1');
235
-        $table->addUpdatedWhere('dosmiley', 1, '=0');
236
-        $table->addUpdatedWhere('dosmiley', 0, '=2');
234
+		$table->addUpdatedWhere('dosmiley', 2, '=1');
235
+		$table->addUpdatedWhere('dosmiley', 1, '=0');
236
+		$table->addUpdatedWhere('dosmiley', 0, '=2');
237 237
 
238
-        $table->addUpdatedWhere('doxcode', 2, '=1');
239
-        $table->addUpdatedWhere('doxcode', 1, '=0');
240
-        $table->addUpdatedWhere('doxcode', 0, '=2');
238
+		$table->addUpdatedWhere('doxcode', 2, '=1');
239
+		$table->addUpdatedWhere('doxcode', 1, '=0');
240
+		$table->addUpdatedWhere('doxcode', 0, '=2');
241 241
 
242
-        $table->addUpdatedWhere('doimage', 2, '=1');
243
-        $table->addUpdatedWhere('doimage', 1, '=0');
244
-        $table->addUpdatedWhere('doimage', 0, '=2');
245
-        $ret = $dbupdater->updateTable($table);
246
-    }
242
+		$table->addUpdatedWhere('doimage', 2, '=1');
243
+		$table->addUpdatedWhere('doimage', 1, '=0');
244
+		$table->addUpdatedWhere('doimage', 0, '=2');
245
+		$ret = $dbupdater->updateTable($table);
246
+	}
247 247
 
248
-    return $ret;
248
+	return $ret;
249 249
 }
250 250
 
251 251
 /**
@@ -258,22 +258,22 @@  discard block
 block discarded – undo
258 258
  */
259 259
 function update_table($new_fields, $existing_fields, &$table)
260 260
 {
261
-    foreach ($new_fields as $field => $fieldinfo) {
262
-        $type = $fieldinfo['Type'];
263
-        if (!in_array($field, array_keys($existing_fields))) {
264
-            //Add field as it is missing
265
-            $table->addNewField($field, $type);
266
-            //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type);
267
-            //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br>";
268
-        } elseif ($existing_fields[$field] != $type) {
269
-            $table->addAlteredField($field, $field . ' ' . $type);
270
-            // check $fields[$field]['type'] for things like "int(10) unsigned"
271
-            //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type);
272
-            //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br>";
273
-        } else {
274
-            //echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br>";
275
-        }
276
-    }
261
+	foreach ($new_fields as $field => $fieldinfo) {
262
+		$type = $fieldinfo['Type'];
263
+		if (!in_array($field, array_keys($existing_fields))) {
264
+			//Add field as it is missing
265
+			$table->addNewField($field, $type);
266
+			//$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type);
267
+			//echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br>";
268
+		} elseif ($existing_fields[$field] != $type) {
269
+			$table->addAlteredField($field, $field . ' ' . $type);
270
+			// check $fields[$field]['type'] for things like "int(10) unsigned"
271
+			//$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type);
272
+			//echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br>";
273
+		} else {
274
+			//echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br>";
275
+		}
276
+	}
277 277
 }
278 278
 
279 279
 /**
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
  */
287 287
 function get_table_info($table, $default_fields)
288 288
 {
289
-    global $xoopsDB;
290
-    $result = $xoopsDB->query('SHOW COLUMNS FROM ' . $table);
291
-    while ($existing_field = $xoopsDB->fetchArray($result)) {
292
-        $fields[$existing_field['Field']] = $existing_field['Type'];
293
-        if ($existing_field['Null'] !== 'YES') {
294
-            $fields[$existing_field['Field']] .= ' NOT NULL';
295
-        }
296
-        if ($existing_field['Extra']) {
297
-            $fields[$existing_field['Field']] .= ' ' . $existing_field['Extra'];
298
-        }
299
-        if ($default_fields[$existing_field['Field']]['Default']) {
300
-            $fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'";
301
-        }
302
-    }
289
+	global $xoopsDB;
290
+	$result = $xoopsDB->query('SHOW COLUMNS FROM ' . $table);
291
+	while ($existing_field = $xoopsDB->fetchArray($result)) {
292
+		$fields[$existing_field['Field']] = $existing_field['Type'];
293
+		if ($existing_field['Null'] !== 'YES') {
294
+			$fields[$existing_field['Field']] .= ' NOT NULL';
295
+		}
296
+		if ($existing_field['Extra']) {
297
+			$fields[$existing_field['Field']] .= ' ' . $existing_field['Extra'];
298
+		}
299
+		if ($default_fields[$existing_field['Field']]['Default']) {
300
+			$fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'";
301
+		}
302
+	}
303 303
 
304
-    return $fields;
304
+	return $fields;
305 305
 }
306 306
 
307 307
 /**
@@ -315,60 +315,60 @@  discard block
 block discarded – undo
315 315
  */
316 316
 function rename_fields(&$table, $renamed_fields, &$fields, $new_fields)
317 317
 {
318
-    foreach (array_keys($fields) as $field) {
319
-        if (in_array($field, array_keys($renamed_fields))) {
320
-            $new_field_name = $renamed_fields[$field];
321
-            $new_field_type = $new_fields[$new_field_name]['Type'];
322
-            $table->addAltered($field, $new_field_name . ' ' . $new_field_type);
323
-            //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type);
324
-            //echo $field." Renamed to ".$new_field_name."<br>";
325
-            $fields[$new_field_name] = $new_field_type;
326
-        }
327
-    }
328
-    //return $fields;
318
+	foreach (array_keys($fields) as $field) {
319
+		if (in_array($field, array_keys($renamed_fields))) {
320
+			$new_field_name = $renamed_fields[$field];
321
+			$new_field_type = $new_fields[$new_field_name]['Type'];
322
+			$table->addAltered($field, $new_field_name . ' ' . $new_field_type);
323
+			//$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type);
324
+			//echo $field." Renamed to ".$new_field_name."<br>";
325
+			$fields[$new_field_name] = $new_field_type;
326
+		}
327
+	}
328
+	//return $fields;
329 329
 }
330 330
 
331 331
 $op = isset($_REQUEST['op']) ? (int)$_REQUEST['op'] : 0;
332 332
 switch ($op) {
333
-    case 1:
334
-        // Make sure that nohtml is properly changed to dohtml
335
-        invert_nohtm_dohtml_values();
336
-        // Ensure that the proper tables are present
337
-        update_tables_to_300();
338
-        // Import data from MyDownloads
339
-        import_mydownloads_to_wfdownloads();
340
-        break;
333
+	case 1:
334
+		// Make sure that nohtml is properly changed to dohtml
335
+		invert_nohtm_dohtml_values();
336
+		// Ensure that the proper tables are present
337
+		update_tables_to_300();
338
+		// Import data from MyDownloads
339
+		import_mydownloads_to_wfdownloads();
340
+		break;
341 341
 
342
-    case 2:
343
-        // Update WF-Downloads
344
-        $log = invert_nohtm_dohtml_values();
345
-        update_tables_to_300();
346
-        break;
342
+	case 2:
343
+		// Update WF-Downloads
344
+		$log = invert_nohtm_dohtml_values();
345
+		update_tables_to_300();
346
+		break;
347 347
 
348
-    default:
349
-        //ask what to do
350
-        include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
351
-        $form = new XoopsThemeForm('Upgrade WF-Downloads', 'form', $_SERVER['REQUEST_URI']);
348
+	default:
349
+		//ask what to do
350
+		include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
351
+		$form = new XoopsThemeForm('Upgrade WF-Downloads', 'form', $_SERVER['REQUEST_URI']);
352 352
 
353
-        //Is MyDownloads installed?
354
-        /** @var XoopsModuleHandler $moduleHandler */
355
-        $moduleHandler     = xoops_getHandler('module');
356
-        $mydownloadsModule = $moduleHandler->getByDirname('mydownloads');
357
-        if (is_object($mydownloadsModule)) {
358
-            $mydownloadsButton = new XoopsFormButton('Import data from MyDownloads', 'myd_button', 'Import', 'submit');
359
-            $mydownloadsButton->setExtra("onclick='document.forms.form.op.value=\"1\"'");
360
-            $form->addElement($mydownloadsButton);
361
-        }
353
+		//Is MyDownloads installed?
354
+		/** @var XoopsModuleHandler $moduleHandler */
355
+		$moduleHandler     = xoops_getHandler('module');
356
+		$mydownloadsModule = $moduleHandler->getByDirname('mydownloads');
357
+		if (is_object($mydownloadsModule)) {
358
+			$mydownloadsButton = new XoopsFormButton('Import data from MyDownloads', 'myd_button', 'Import', 'submit');
359
+			$mydownloadsButton->setExtra("onclick='document.forms.form.op.value=\"1\"'");
360
+			$form->addElement($mydownloadsButton);
361
+		}
362 362
 
363
-        if (!wfdownloads_TableExists('wfdownloads_meta')) {
364
-            $updateButton = new XoopsFormButton('Update WF-Downloads', 'upd_button', 'Update', 'submit');
365
-            $updateButton->setExtra("onclick='document.forms.form.op.value=\"2\"'");
366
-            $form->addElement($updateButton);
367
-        }
363
+		if (!wfdownloads_TableExists('wfdownloads_meta')) {
364
+			$updateButton = new XoopsFormButton('Update WF-Downloads', 'upd_button', 'Update', 'submit');
365
+			$updateButton->setExtra("onclick='document.forms.form.op.value=\"2\"'");
366
+			$form->addElement($updateButton);
367
+		}
368 368
 
369
-        $form->addElement(new XoopsFormHidden('op', 0));
370
-        $form->display();
371
-        break;
369
+		$form->addElement(new XoopsFormHidden('op', 0));
370
+		$form->display();
371
+		break;
372 372
 }
373 373
 //wfdownloads_modFooter();
374 374
 //xoops_cp_footer();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * Licence: GNU
8 8
  */
9 9
 
10
-require_once __DIR__ . '/admin_header.php';
11
-require_once SMARTCONTENT_ROOT_PATH . 'class/dbupdater.php';
10
+require_once __DIR__.'/admin_header.php';
11
+require_once SMARTCONTENT_ROOT_PATH.'class/dbupdater.php';
12 12
 
13 13
 smartcontent_xoops_cp_header();
14 14
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     $ret = [];
208 208
     global $xoopsDB;
209 209
     $catHandler = xoops_getModuleHandler('category', 'wfdownloads');
210
-    $result     = $xoopsDB->query('SHOW COLUMNS FROM ' . $catHandler->table);
210
+    $result     = $xoopsDB->query('SHOW COLUMNS FROM '.$catHandler->table);
211 211
     while ($existing_field = $xoopsDB->fetchArray($result)) {
212 212
         $fields[$existing_field['field']] = $existing_field['type'];
213 213
     }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type);
267 267
             //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br>";
268 268
         } elseif ($existing_fields[$field] != $type) {
269
-            $table->addAlteredField($field, $field . ' ' . $type);
269
+            $table->addAlteredField($field, $field.' '.$type);
270 270
             // check $fields[$field]['type'] for things like "int(10) unsigned"
271 271
             //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type);
272 272
             //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br>";
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 function get_table_info($table, $default_fields)
288 288
 {
289 289
     global $xoopsDB;
290
-    $result = $xoopsDB->query('SHOW COLUMNS FROM ' . $table);
290
+    $result = $xoopsDB->query('SHOW COLUMNS FROM '.$table);
291 291
     while ($existing_field = $xoopsDB->fetchArray($result)) {
292 292
         $fields[$existing_field['Field']] = $existing_field['Type'];
293 293
         if ($existing_field['Null'] !== 'YES') {
294 294
             $fields[$existing_field['Field']] .= ' NOT NULL';
295 295
         }
296 296
         if ($existing_field['Extra']) {
297
-            $fields[$existing_field['Field']] .= ' ' . $existing_field['Extra'];
297
+            $fields[$existing_field['Field']] .= ' '.$existing_field['Extra'];
298 298
         }
299 299
         if ($default_fields[$existing_field['Field']]['Default']) {
300
-            $fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'";
300
+            $fields[$existing_field['Field']] .= " default '".$existing_field['Default']."'";
301 301
         }
302 302
     }
303 303
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
         if (in_array($field, array_keys($renamed_fields))) {
320 320
             $new_field_name = $renamed_fields[$field];
321 321
             $new_field_type = $new_fields[$new_field_name]['Type'];
322
-            $table->addAltered($field, $new_field_name . ' ' . $new_field_type);
322
+            $table->addAltered($field, $new_field_name.' '.$new_field_type);
323 323
             //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type);
324 324
             //echo $field." Renamed to ".$new_field_name."<br>";
325 325
             $fields[$new_field_name] = $new_field_type;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
     //return $fields;
329 329
 }
330 330
 
331
-$op = isset($_REQUEST['op']) ? (int)$_REQUEST['op'] : 0;
331
+$op = isset($_REQUEST['op']) ? (int) $_REQUEST['op'] : 0;
332 332
 switch ($op) {
333 333
     case 1:
334 334
         // Make sure that nohtml is properly changed to dohtml
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
     default:
349 349
         //ask what to do
350
-        include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
350
+        include XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
351 351
         $form = new XoopsThemeForm('Upgrade WF-Downloads', 'form', $_SERVER['REQUEST_URI']);
352 352
 
353 353
         //Is MyDownloads installed?
@@ -372,4 +372,4 @@  discard block
 block discarded – undo
372 372
 }
373 373
 //wfdownloads_modFooter();
374 374
 //xoops_cp_footer();
375
-require_once __DIR__ . '/admin_footer.php';
375
+require_once __DIR__.'/admin_footer.php';
Please login to merge, or discard this patch.
admin/adsense.php 3 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -12,32 +12,32 @@  discard block
 block discarded – undo
12 12
 
13 13
 function editclass($showmenu = false, $adsenseid = 0, $clone = false)
14 14
 {
15
-    global $smartobjectAdsenseHandler;
16
-
17
-    $adsenseObj = $smartobjectAdsenseHandler->get($adsenseid);
18
-
19
-    if (!$clone && !$adsenseObj->isNew()) {
20
-        if ($showmenu) {
21
-            //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING);
22
-        }
23
-        smart_collapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO);
24
-
25
-        $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense');
26
-        $sform->display();
27
-        smart_close_collapsable('adsenseedit');
28
-    } else {
29
-        $adsenseObj->setVar('adsenseid', 0);
30
-        $adsenseObj->setVar('tag', '');
31
-
32
-        if ($showmenu) {
33
-            //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW);
34
-        }
35
-
36
-        smart_collapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO);
37
-        $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true);
38
-        $sform->display();
39
-        smart_close_collapsable('adsensecreate');
40
-    }
15
+	global $smartobjectAdsenseHandler;
16
+
17
+	$adsenseObj = $smartobjectAdsenseHandler->get($adsenseid);
18
+
19
+	if (!$clone && !$adsenseObj->isNew()) {
20
+		if ($showmenu) {
21
+			//smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING);
22
+		}
23
+		smart_collapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO);
24
+
25
+		$sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense');
26
+		$sform->display();
27
+		smart_close_collapsable('adsenseedit');
28
+	} else {
29
+		$adsenseObj->setVar('adsenseid', 0);
30
+		$adsenseObj->setVar('tag', '');
31
+
32
+		if ($showmenu) {
33
+			//smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW);
34
+		}
35
+
36
+		smart_collapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO);
37
+		$sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true);
38
+		$sform->display();
39
+		smart_close_collapsable('adsensecreate');
40
+	}
41 41
 }
42 42
 
43 43
 require_once __DIR__ . '/admin_header.php';
@@ -50,72 +50,72 @@  discard block
 block discarded – undo
50 50
 $op = '';
51 51
 
52 52
 if (isset($_GET['op'])) {
53
-    $op = $_GET['op'];
53
+	$op = $_GET['op'];
54 54
 }
55 55
 if (isset($_POST['op'])) {
56
-    $op = $_POST['op'];
56
+	$op = $_POST['op'];
57 57
 }
58 58
 
59 59
 switch ($op) {
60
-    case 'mod':
60
+	case 'mod':
61 61
 
62
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
62
+		$adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
63 63
 
64
-        smart_xoops_cp_header();
65
-        $adminObject->displayNavigation(basename(__FILE__));
64
+		smart_xoops_cp_header();
65
+		$adminObject->displayNavigation(basename(__FILE__));
66 66
 
67
-        editclass(true, $adsenseid);
68
-        break;
67
+		editclass(true, $adsenseid);
68
+		break;
69 69
 
70
-    case 'clone':
70
+	case 'clone':
71 71
 
72
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
72
+		$adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
73 73
 
74
-        smart_xoops_cp_header();
75
-        $adminObject->displayNavigation(basename(__FILE__));
74
+		smart_xoops_cp_header();
75
+		$adminObject->displayNavigation(basename(__FILE__));
76 76
 
77
-        editclass(true, $adsenseid, true);
78
-        break;
77
+		editclass(true, $adsenseid, true);
78
+		break;
79 79
 
80
-    case 'addadsense':
81
-        if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
82
-            $xoopsCaptcha = XoopsCaptcha::getInstance();
83
-            if (!$xoopsCaptcha->verify()) {
84
-                redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85
-            }
86
-        }
87
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
88
-        $controller = new SmartObjectController($smartobjectAdsenseHandler);
89
-        $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
90
-        break;
80
+	case 'addadsense':
81
+		if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
82
+			$xoopsCaptcha = XoopsCaptcha::getInstance();
83
+			if (!$xoopsCaptcha->verify()) {
84
+				redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85
+			}
86
+		}
87
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
88
+		$controller = new SmartObjectController($smartobjectAdsenseHandler);
89
+		$controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
90
+		break;
91 91
 
92
-    case 'del':
92
+	case 'del':
93 93
 
94
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
95
-        $controller = new SmartObjectController($smartobjectAdsenseHandler);
96
-        $controller->handleObjectDeletion();
94
+		require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
95
+		$controller = new SmartObjectController($smartobjectAdsenseHandler);
96
+		$controller->handleObjectDeletion();
97 97
 
98
-        break;
98
+		break;
99 99
 
100
-    default:
100
+	default:
101 101
 
102
-        smart_xoops_cp_header();
103
-        $adminObject->displayNavigation(basename(__FILE__));
102
+		smart_xoops_cp_header();
103
+		$adminObject->displayNavigation(basename(__FILE__));
104 104
 
105
-        //smart_adminMenu(3, _AM_SOBJECT_ADSENSES);
105
+		//smart_adminMenu(3, _AM_SOBJECT_ADSENSES);
106 106
 
107
-        smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
107
+		smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
108 108
 
109
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
110
-        $objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
111
-        $objectTable->addColumn(new SmartObjectColumn('description', 'left'));
112
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
109
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
110
+		$objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
111
+		$objectTable->addColumn(new SmartObjectColumn('description', 'left'));
112
+		$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
113 113
 
114
-        //      $objectTable->addCustomAction('getCreateItemLink');
115
-        //      $objectTable->addCustomAction('getCreateAttributLink');
114
+		//      $objectTable->addCustomAction('getCreateItemLink');
115
+		//      $objectTable->addCustomAction('getCreateAttributLink');
116 116
 
117
-        $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
118
-        /*
117
+		$objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
118
+		/*
119 119
                 $criteria_upcoming = new CriteriaCompo();
120 120
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
121 121
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                                             'criteria' => $criteria_last30days
140 140
                 ));
141 141
         */
142
-        $objectTable->addQuickSearch(['title', 'summary', 'description']);
143
-        $objectTable->addCustomAction('getCloneLink');
142
+		$objectTable->addQuickSearch(['title', 'summary', 'description']);
143
+		$objectTable->addCustomAction('getCloneLink');
144 144
 
145
-        $objectTable->render();
145
+		$objectTable->render();
146 146
 
147
-        echo '<br>';
148
-        smart_close_collapsable('createdadsenses');
149
-        echo '<br>';
147
+		echo '<br>';
148
+		smart_close_collapsable('createdadsenses');
149
+		echo '<br>';
150 150
 
151
-        break;
151
+		break;
152 152
 }
153 153
 
154 154
 //smart_modFooter();
Please login to merge, or discard this patch.
Switch Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -57,65 +57,65 @@  discard block
 block discarded – undo
57 57
 }
58 58
 
59 59
 switch ($op) {
60
-    case 'mod':
60
+    	case 'mod':
61 61
 
62
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
62
+        	$adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
63 63
 
64
-        smart_xoops_cp_header();
65
-        $adminObject->displayNavigation(basename(__FILE__));
64
+        	smart_xoops_cp_header();
65
+        	$adminObject->displayNavigation(basename(__FILE__));
66 66
 
67
-        editclass(true, $adsenseid);
68
-        break;
67
+        	editclass(true, $adsenseid);
68
+        	break;
69 69
 
70
-    case 'clone':
70
+    	case 'clone':
71 71
 
72
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
72
+        	$adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
73 73
 
74
-        smart_xoops_cp_header();
75
-        $adminObject->displayNavigation(basename(__FILE__));
74
+        	smart_xoops_cp_header();
75
+        	$adminObject->displayNavigation(basename(__FILE__));
76 76
 
77
-        editclass(true, $adsenseid, true);
78
-        break;
77
+        	editclass(true, $adsenseid, true);
78
+        	break;
79 79
 
80
-    case 'addadsense':
81
-        if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
82
-            $xoopsCaptcha = XoopsCaptcha::getInstance();
83
-            if (!$xoopsCaptcha->verify()) {
84
-                redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85
-            }
86
-        }
87
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
88
-        $controller = new SmartObjectController($smartobjectAdsenseHandler);
89
-        $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
90
-        break;
80
+    	case 'addadsense':
81
+        	if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
82
+            	$xoopsCaptcha = XoopsCaptcha::getInstance();
83
+            	if (!$xoopsCaptcha->verify()) {
84
+                	redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85
+            	}
86
+        	}
87
+        	require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
88
+        	$controller = new SmartObjectController($smartobjectAdsenseHandler);
89
+        	$controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
90
+        	break;
91 91
 
92
-    case 'del':
92
+    	case 'del':
93 93
 
94
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
95
-        $controller = new SmartObjectController($smartobjectAdsenseHandler);
96
-        $controller->handleObjectDeletion();
94
+        	require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
95
+        	$controller = new SmartObjectController($smartobjectAdsenseHandler);
96
+        	$controller->handleObjectDeletion();
97 97
 
98
-        break;
98
+        	break;
99 99
 
100
-    default:
100
+    	default:
101 101
 
102
-        smart_xoops_cp_header();
103
-        $adminObject->displayNavigation(basename(__FILE__));
102
+        	smart_xoops_cp_header();
103
+        	$adminObject->displayNavigation(basename(__FILE__));
104 104
 
105
-        //smart_adminMenu(3, _AM_SOBJECT_ADSENSES);
105
+        	//smart_adminMenu(3, _AM_SOBJECT_ADSENSES);
106 106
 
107
-        smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
107
+        	smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
108 108
 
109
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
110
-        $objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
111
-        $objectTable->addColumn(new SmartObjectColumn('description', 'left'));
112
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
109
+        	require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
110
+        	$objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
111
+        	$objectTable->addColumn(new SmartObjectColumn('description', 'left'));
112
+        	$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
113 113
 
114
-        //      $objectTable->addCustomAction('getCreateItemLink');
115
-        //      $objectTable->addCustomAction('getCreateAttributLink');
114
+        	//      $objectTable->addCustomAction('getCreateItemLink');
115
+        	//      $objectTable->addCustomAction('getCreateAttributLink');
116 116
 
117
-        $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
118
-        /*
117
+        	$objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
118
+        	/*
119 119
                 $criteria_upcoming = new CriteriaCompo();
120 120
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
121 121
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                                             'criteria' => $criteria_last30days
140 140
                 ));
141 141
         */
142
-        $objectTable->addQuickSearch(['title', 'summary', 'description']);
143
-        $objectTable->addCustomAction('getCloneLink');
142
+        	$objectTable->addQuickSearch(['title', 'summary', 'description']);
143
+        	$objectTable->addCustomAction('getCloneLink');
144 144
 
145
-        $objectTable->render();
145
+        	$objectTable->render();
146 146
 
147
-        echo '<br>';
148
-        smart_close_collapsable('createdadsenses');
149
-        echo '<br>';
147
+        	echo '<br>';
148
+        	smart_close_collapsable('createdadsenses');
149
+        	echo '<br>';
150 150
 
151
-        break;
151
+        	break;
152 152
 }
153 153
 
154 154
 //smart_modFooter();
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
     }
41 41
 }
42 42
 
43
-require_once __DIR__ . '/admin_header.php';
44
-require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
45
-require_once SMARTOBJECT_ROOT_PATH . 'class/adsense.php';
43
+require_once __DIR__.'/admin_header.php';
44
+require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php';
45
+require_once SMARTOBJECT_ROOT_PATH.'class/adsense.php';
46 46
 $smartobjectAdsenseHandler = xoops_getModuleHandler('adsense');
47 47
 smart_loadLanguageFile('smartobject', 'adsense');
48 48
 $adminObject = \Xmf\Module\Admin::getInstance();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 switch ($op) {
60 60
     case 'mod':
61 61
 
62
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
62
+        $adsenseid = isset($_GET['adsenseid']) ? (int) $_GET['adsenseid'] : 0;
63 63
 
64 64
         smart_xoops_cp_header();
65 65
         $adminObject->displayNavigation(basename(__FILE__));
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     case 'clone':
71 71
 
72
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
72
+        $adsenseid = isset($_GET['adsenseid']) ? (int) $_GET['adsenseid'] : 0;
73 73
 
74 74
         smart_xoops_cp_header();
75 75
         $adminObject->displayNavigation(basename(__FILE__));
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         break;
79 79
 
80 80
     case 'addadsense':
81
-        if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
81
+        if (@require_once SMARTOBJECT_ROOT_PATH.'include/captcha/captcha.php') {
82 82
             $xoopsCaptcha = XoopsCaptcha::getInstance();
83 83
             if (!$xoopsCaptcha->verify()) {
84 84
                 redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85 85
             }
86 86
         }
87
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
87
+        require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjectcontroller.php';
88 88
         $controller = new SmartObjectController($smartobjectAdsenseHandler);
89 89
         $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
90 90
         break;
91 91
 
92 92
     case 'del':
93 93
 
94
-        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
94
+        require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjectcontroller.php';
95 95
         $controller = new SmartObjectController($smartobjectAdsenseHandler);
96 96
         $controller->handleObjectDeletion();
97 97
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
         smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
108 108
 
109
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
109
+        require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php';
110 110
         $objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
111 111
         $objectTable->addColumn(new SmartObjectColumn('description', 'left'));
112 112
         $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
@@ -153,4 +153,4 @@  discard block
 block discarded – undo
153 153
 
154 154
 //smart_modFooter();
155 155
 //xoops_cp_footer();
156
-require_once __DIR__ . '/admin_footer.php';
156
+require_once __DIR__.'/admin_footer.php';
Please login to merge, or discard this patch.
include/captcha/config.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -12,40 +12,40 @@
 block discarded – undo
12 12
  */
13 13
 
14 14
 $config = [
15
-    'mode'       => 'image',
16
-    'name'       => 'xoopscaptcha',
17
-    'skipmember' => true,
18
-    // Skip CAPTCHA check for members
19
-    'maxattempt' => 100,
20
-    // Maximum attempts for each session
15
+	'mode'       => 'image',
16
+	'name'       => 'xoopscaptcha',
17
+	'skipmember' => true,
18
+	// Skip CAPTCHA check for members
19
+	'maxattempt' => 100,
20
+	// Maximum attempts for each session
21 21
 
22
-    'num_chars'       => 4,
23
-    // Maximum characters
22
+	'num_chars'       => 4,
23
+	// Maximum characters
24 24
 
25
-    // For image mode, based on DuGris' SecurityImage
26
-    'rootpath'        => __DIR__,
27
-    // __Absolute__ Path to the root of fonts and backgrounds
28
-    'imagepath'       => 'uploads/captcha',
29
-    // Path to temporary image files, __relative__ to XOOPS_ROOT_PATH
30
-    'imageurl'        => 'modules/smartobject/include/captcha/scripts/img.php',
31
-    // Path to the script for creating image, __relative__ to XOOPS_ROOT_PATH
32
-    'casesensitive'   => false,
33
-    // Characters in image mode is case-sensitive
34
-    'fontsize_min'    => 12,
35
-    // Minimum font-size
36
-    'fontsize_max'    => 12,
37
-    // Maximum font-size
38
-    'background_type' => 0,
39
-    // Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files
40
-    'background_num'  => 50,
41
-    // Number of background images to generate
42
-    'polygon_point'   => 3
25
+	// For image mode, based on DuGris' SecurityImage
26
+	'rootpath'        => __DIR__,
27
+	// __Absolute__ Path to the root of fonts and backgrounds
28
+	'imagepath'       => 'uploads/captcha',
29
+	// Path to temporary image files, __relative__ to XOOPS_ROOT_PATH
30
+	'imageurl'        => 'modules/smartobject/include/captcha/scripts/img.php',
31
+	// Path to the script for creating image, __relative__ to XOOPS_ROOT_PATH
32
+	'casesensitive'   => false,
33
+	// Characters in image mode is case-sensitive
34
+	'fontsize_min'    => 12,
35
+	// Minimum font-size
36
+	'fontsize_max'    => 12,
37
+	// Maximum font-size
38
+	'background_type' => 0,
39
+	// Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files
40
+	'background_num'  => 50,
41
+	// Number of background images to generate
42
+	'polygon_point'   => 3
43 43
 ];
44 44
 
45 45
 $language = preg_replace("/[^a-z0-9_\-]/i", '', $GLOBALS['xoopsConfig']['language']);
46 46
 
47 47
 if (!@require_once __DIR__ . "/language/{$language}.php") {
48
-    require_once __DIR__ . '/language/english.php';
48
+	require_once __DIR__ . '/language/english.php';
49 49
 }
50 50
 
51 51
 return $config;
Please login to merge, or discard this patch.
include/captcha/formcaptcha.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
15 15
 
16
-require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelement.php';
16
+require_once XOOPS_ROOT_PATH.'/class/xoopsform/formelement.php';
17 17
 
18 18
 /*
19 19
  * Usage
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $backgroundnum = null
63 63
     ) {
64 64
         if (!class_exists('XoopsCaptcaha')) {
65
-            require_once SMARTOBJECT_ROOT_PATH . '/include/captcha/captcha.php';
65
+            require_once SMARTOBJECT_ROOT_PATH.'/include/captcha/captcha.php';
66 66
         }
67 67
 
68 68
         $this->_captchaHandler = XoopsCaptcha::getInstance();
Please login to merge, or discard this patch.
include/captcha/captcha.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -13,253 +13,253 @@
 block discarded – undo
13 13
  */
14 14
 class XoopsCaptcha
15 15
 {
16
-    public $active = true;
17
-    public $mode   = 'text';    // potential values: image, text
18
-    public $config = [];
19
-
20
-    public $message = []; // Logging error messages
21
-
22
-    /**
23
-     * XoopsCaptcha constructor.
24
-     */
25
-    public function __construct()
26
-    {
27
-        // Loading default preferences
28
-        $this->config = @include __DIR__ . '/config.php';
29
-
30
-        $this->setMode($this->config['mode']);
31
-    }
32
-
33
-    /**
34
-     * @return XoopsCaptcha
35
-     */
36
-    public static function getInstance()
37
-    {
38
-        static $instance;
39
-        if (null === $instance) {
40
-            $instance = new static();
41
-        }
42
-
43
-        return $instance;
44
-    }
45
-
46
-    /**
47
-     * @param $name
48
-     * @param $val
49
-     * @return bool
50
-     */
51
-    public function setConfig($name, $val)
52
-    {
53
-        if ($name === 'mode') {
54
-            $this->setMode($val);
55
-        } elseif (isset($this->$name)) {
56
-            $this->$name = $val;
57
-        } else {
58
-            $this->config[$name] = $val;
59
-        }
60
-
61
-        return true;
62
-    }
63
-
64
-    /**
65
-     * Set CAPTCHA mode
66
-     *
67
-     * For future possible modes, right now force to use text or image
68
-     *
69
-     * @param string $mode if no mode is set, just verify current mode
70
-     */
71
-    public function setMode($mode = null)
72
-    {
73
-        if (!empty($mode) && in_array($mode, ['text', 'image'])) {
74
-            $this->mode = $mode;
75
-
76
-            if ($this->mode !== 'image') {
77
-                return;
78
-            }
79
-        }
80
-
81
-        // Disable image mode
82
-        if (!extension_loaded('gd')) {
83
-            $this->mode = 'text';
84
-        } else {
85
-            $required_functions = [
86
-                'imagecreatetruecolor',
87
-                'imagecolorallocate',
88
-                'imagefilledrectangle',
89
-                'imagejpeg',
90
-                'imagedestroy',
91
-                'imageftbbox'
92
-            ];
93
-            foreach ($required_functions as $func) {
94
-                if (!function_exists($func)) {
95
-                    $this->mode = 'text';
96
-                    break;
97
-                }
98
-            }
99
-        }
100
-    }
101
-
102
-    /**
103
-     * Initializing the CAPTCHA class
104
-     * @param string $name
105
-     * @param null   $skipmember
106
-     * @param null   $num_chars
107
-     * @param null   $fontsize_min
108
-     * @param null   $fontsize_max
109
-     * @param null   $background_type
110
-     * @param null   $background_num
111
-     */
112
-    public function init(
113
-        $name = 'xoopscaptcha',
114
-        $skipmember = null,
115
-        $num_chars = null,
116
-        $fontsize_min = null,
117
-        $fontsize_max = null,
118
-        $background_type = null,
119
-        $background_num = null
120
-    ) {
121
-        // Loading RUN-TIME settings
122
-        foreach (array_keys($this->config) as $key) {
123
-            if (isset(${$key}) && ${$key} !== null) {
124
-                $this->config[$key] = ${$key};
125
-            }
126
-        }
127
-        $this->config['name'] = $name;
128
-
129
-        // Skip CAPTCHA for member if set
130
-        if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) {
131
-            $this->active = false;
132
-        }
133
-    }
134
-
135
-    /**
136
-     * Verify user submission
137
-     * @param  null $skipMember
138
-     * @return bool
139
-     */
140
-    public function verify($skipMember = null)
141
-    {
142
-        $sessionName = @$_SESSION['XoopsCaptcha_name'];
143
-        $skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
144
-        $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
145
-
146
-        $is_valid = false;
147
-
148
-        // Skip CAPTCHA for member if set
149
-        if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
150
-            $is_valid = true;
151
-            // Kill too many attempts
152
-        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
153
-            $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
154
-
155
-            // Verify the code
156
-        } elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
157
-            $func     = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp';
158
-            $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
159
-        }
160
-
161
-        if (!empty($maxAttempts)) {
162
-            if (!$is_valid) {
163
-                // Increase the attempt records on failure
164
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
165
-                // Log the error message
166
-                $this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
167
-            } else {
168
-
169
-                // reset attempt records on success
170
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
171
-            }
172
-        }
173
-        $this->destroyGarbage(true);
174
-
175
-        return $is_valid;
176
-    }
177
-
178
-    /**
179
-     * @return mixed|string
180
-     */
181
-    public function getCaption()
182
-    {
183
-        return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : '';
184
-    }
185
-
186
-    /**
187
-     * @return string
188
-     */
189
-    public function getMessage()
190
-    {
191
-        return implode('<br>', $this->message);
192
-    }
193
-
194
-    /**
195
-     * Destory historical stuff
196
-     * @param  bool $clearSession
197
-     * @return bool
198
-     */
199
-    public function destroyGarbage($clearSession = false)
200
-    {
201
-        require_once __DIR__ . '/' . $this->mode . '.php';
202
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
203
-        $captchaHandler = new $class();
204
-        if (method_exists($captchaHandler, 'destroyGarbage')) {
205
-            $captchaHandler->loadConfig($this->config);
206
-            $captchaHandler->destroyGarbage();
207
-        }
208
-
209
-        if ($clearSession) {
210
-            $_SESSION['XoopsCaptcha_name']        = null;
211
-            $_SESSION['XoopsCaptcha_skipmember']  = null;
212
-            $_SESSION['XoopsCaptcha_sessioncode'] = null;
213
-            $_SESSION['XoopsCaptcha_maxattempts'] = null;
214
-        }
215
-
216
-        return true;
217
-    }
218
-
219
-    /**
220
-     * @return mixed|string
221
-     */
222
-    public function render()
223
-    {
224
-        $form = '';
225
-
226
-        if (!$this->active || empty($this->config['name'])) {
227
-            return $form;
228
-        }
229
-
230
-        $_SESSION['XoopsCaptcha_name']        = $this->config['name'];
231
-        $_SESSION['XoopsCaptcha_skipmember']  = $this->config['skipmember'];
232
-        $maxAttempts                          = $this->config['maxattempt'];
233
-        $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts;
234
-        /*
16
+	public $active = true;
17
+	public $mode   = 'text';    // potential values: image, text
18
+	public $config = [];
19
+
20
+	public $message = []; // Logging error messages
21
+
22
+	/**
23
+	 * XoopsCaptcha constructor.
24
+	 */
25
+	public function __construct()
26
+	{
27
+		// Loading default preferences
28
+		$this->config = @include __DIR__ . '/config.php';
29
+
30
+		$this->setMode($this->config['mode']);
31
+	}
32
+
33
+	/**
34
+	 * @return XoopsCaptcha
35
+	 */
36
+	public static function getInstance()
37
+	{
38
+		static $instance;
39
+		if (null === $instance) {
40
+			$instance = new static();
41
+		}
42
+
43
+		return $instance;
44
+	}
45
+
46
+	/**
47
+	 * @param $name
48
+	 * @param $val
49
+	 * @return bool
50
+	 */
51
+	public function setConfig($name, $val)
52
+	{
53
+		if ($name === 'mode') {
54
+			$this->setMode($val);
55
+		} elseif (isset($this->$name)) {
56
+			$this->$name = $val;
57
+		} else {
58
+			$this->config[$name] = $val;
59
+		}
60
+
61
+		return true;
62
+	}
63
+
64
+	/**
65
+	 * Set CAPTCHA mode
66
+	 *
67
+	 * For future possible modes, right now force to use text or image
68
+	 *
69
+	 * @param string $mode if no mode is set, just verify current mode
70
+	 */
71
+	public function setMode($mode = null)
72
+	{
73
+		if (!empty($mode) && in_array($mode, ['text', 'image'])) {
74
+			$this->mode = $mode;
75
+
76
+			if ($this->mode !== 'image') {
77
+				return;
78
+			}
79
+		}
80
+
81
+		// Disable image mode
82
+		if (!extension_loaded('gd')) {
83
+			$this->mode = 'text';
84
+		} else {
85
+			$required_functions = [
86
+				'imagecreatetruecolor',
87
+				'imagecolorallocate',
88
+				'imagefilledrectangle',
89
+				'imagejpeg',
90
+				'imagedestroy',
91
+				'imageftbbox'
92
+			];
93
+			foreach ($required_functions as $func) {
94
+				if (!function_exists($func)) {
95
+					$this->mode = 'text';
96
+					break;
97
+				}
98
+			}
99
+		}
100
+	}
101
+
102
+	/**
103
+	 * Initializing the CAPTCHA class
104
+	 * @param string $name
105
+	 * @param null   $skipmember
106
+	 * @param null   $num_chars
107
+	 * @param null   $fontsize_min
108
+	 * @param null   $fontsize_max
109
+	 * @param null   $background_type
110
+	 * @param null   $background_num
111
+	 */
112
+	public function init(
113
+		$name = 'xoopscaptcha',
114
+		$skipmember = null,
115
+		$num_chars = null,
116
+		$fontsize_min = null,
117
+		$fontsize_max = null,
118
+		$background_type = null,
119
+		$background_num = null
120
+	) {
121
+		// Loading RUN-TIME settings
122
+		foreach (array_keys($this->config) as $key) {
123
+			if (isset(${$key}) && ${$key} !== null) {
124
+				$this->config[$key] = ${$key};
125
+			}
126
+		}
127
+		$this->config['name'] = $name;
128
+
129
+		// Skip CAPTCHA for member if set
130
+		if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) {
131
+			$this->active = false;
132
+		}
133
+	}
134
+
135
+	/**
136
+	 * Verify user submission
137
+	 * @param  null $skipMember
138
+	 * @return bool
139
+	 */
140
+	public function verify($skipMember = null)
141
+	{
142
+		$sessionName = @$_SESSION['XoopsCaptcha_name'];
143
+		$skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
144
+		$maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
145
+
146
+		$is_valid = false;
147
+
148
+		// Skip CAPTCHA for member if set
149
+		if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
150
+			$is_valid = true;
151
+			// Kill too many attempts
152
+		} elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
153
+			$this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
154
+
155
+			// Verify the code
156
+		} elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
157
+			$func     = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp';
158
+			$is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
159
+		}
160
+
161
+		if (!empty($maxAttempts)) {
162
+			if (!$is_valid) {
163
+				// Increase the attempt records on failure
164
+				$_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
165
+				// Log the error message
166
+				$this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
167
+			} else {
168
+
169
+				// reset attempt records on success
170
+				$_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
171
+			}
172
+		}
173
+		$this->destroyGarbage(true);
174
+
175
+		return $is_valid;
176
+	}
177
+
178
+	/**
179
+	 * @return mixed|string
180
+	 */
181
+	public function getCaption()
182
+	{
183
+		return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : '';
184
+	}
185
+
186
+	/**
187
+	 * @return string
188
+	 */
189
+	public function getMessage()
190
+	{
191
+		return implode('<br>', $this->message);
192
+	}
193
+
194
+	/**
195
+	 * Destory historical stuff
196
+	 * @param  bool $clearSession
197
+	 * @return bool
198
+	 */
199
+	public function destroyGarbage($clearSession = false)
200
+	{
201
+		require_once __DIR__ . '/' . $this->mode . '.php';
202
+		$class          = 'XoopsCaptcha' . ucfirst($this->mode);
203
+		$captchaHandler = new $class();
204
+		if (method_exists($captchaHandler, 'destroyGarbage')) {
205
+			$captchaHandler->loadConfig($this->config);
206
+			$captchaHandler->destroyGarbage();
207
+		}
208
+
209
+		if ($clearSession) {
210
+			$_SESSION['XoopsCaptcha_name']        = null;
211
+			$_SESSION['XoopsCaptcha_skipmember']  = null;
212
+			$_SESSION['XoopsCaptcha_sessioncode'] = null;
213
+			$_SESSION['XoopsCaptcha_maxattempts'] = null;
214
+		}
215
+
216
+		return true;
217
+	}
218
+
219
+	/**
220
+	 * @return mixed|string
221
+	 */
222
+	public function render()
223
+	{
224
+		$form = '';
225
+
226
+		if (!$this->active || empty($this->config['name'])) {
227
+			return $form;
228
+		}
229
+
230
+		$_SESSION['XoopsCaptcha_name']        = $this->config['name'];
231
+		$_SESSION['XoopsCaptcha_skipmember']  = $this->config['skipmember'];
232
+		$maxAttempts                          = $this->config['maxattempt'];
233
+		$_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts;
234
+		/*
235 235
          if (!empty($maxAttempts)) {
236 236
          $_SESSION['XoopsCaptcha_maxattempts_'.$_SESSION['XoopsCaptcha_name']] = $maxAttempts;
237 237
          }
238 238
          */
239 239
 
240
-        // Fail on too many attempts
241
-        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
242
-            $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
243
-            // Load the form element
244
-        } else {
245
-            $form = $this->loadForm();
246
-        }
247
-
248
-        return $form;
249
-    }
250
-
251
-    /**
252
-     * @return mixed
253
-     */
254
-    public function loadForm()
255
-    {
256
-        require_once __DIR__ . '/' . $this->mode . '.php';
257
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
258
-        $captchaHandler = new $class();
259
-        $captchaHandler->loadConfig($this->config);
260
-
261
-        $form = $captchaHandler->render();
262
-
263
-        return $form;
264
-    }
240
+		// Fail on too many attempts
241
+		if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
242
+			$form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
243
+			// Load the form element
244
+		} else {
245
+			$form = $this->loadForm();
246
+		}
247
+
248
+		return $form;
249
+	}
250
+
251
+	/**
252
+	 * @return mixed
253
+	 */
254
+	public function loadForm()
255
+	{
256
+		require_once __DIR__ . '/' . $this->mode . '.php';
257
+		$class          = 'XoopsCaptcha' . ucfirst($this->mode);
258
+		$captchaHandler = new $class();
259
+		$captchaHandler->loadConfig($this->config);
260
+
261
+		$form = $captchaHandler->render();
262
+
263
+		return $form;
264
+	}
265 265
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 class XoopsCaptcha
15 15
 {
16 16
     public $active = true;
17
-    public $mode   = 'text';    // potential values: image, text
17
+    public $mode   = 'text'; // potential values: image, text
18 18
     public $config = [];
19 19
 
20 20
     public $message = []; // Logging error messages
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public function __construct()
26 26
     {
27 27
         // Loading default preferences
28
-        $this->config = @include __DIR__ . '/config.php';
28
+        $this->config = @include __DIR__.'/config.php';
29 29
 
30 30
         $this->setMode($this->config['mode']);
31 31
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     {
142 142
         $sessionName = @$_SESSION['XoopsCaptcha_name'];
143 143
         $skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
144
-        $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
144
+        $maxAttempts = (int) (@$_SESSION['XoopsCaptcha_maxattempts']);
145 145
 
146 146
         $is_valid = false;
147 147
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
150 150
             $is_valid = true;
151 151
             // Kill too many attempts
152
-        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
152
+        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) {
153 153
             $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
154 154
 
155 155
             // Verify the code
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
         if (!empty($maxAttempts)) {
162 162
             if (!$is_valid) {
163 163
                 // Increase the attempt records on failure
164
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
164
+                $_SESSION['XoopsCaptcha_attempt_'.$sessionName]++;
165 165
                 // Log the error message
166 166
                 $this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
167 167
             } else {
168 168
 
169 169
                 // reset attempt records on success
170
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
170
+                $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null;
171 171
             }
172 172
         }
173 173
         $this->destroyGarbage(true);
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function destroyGarbage($clearSession = false)
200 200
     {
201
-        require_once __DIR__ . '/' . $this->mode . '.php';
202
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
201
+        require_once __DIR__.'/'.$this->mode.'.php';
202
+        $class          = 'XoopsCaptcha'.ucfirst($this->mode);
203 203
         $captchaHandler = new $class();
204 204
         if (method_exists($captchaHandler, 'destroyGarbage')) {
205 205
             $captchaHandler->loadConfig($this->config);
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
          */
239 239
 
240 240
         // Fail on too many attempts
241
-        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
241
+        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config['name']] > $maxAttempts) {
242 242
             $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
243 243
             // Load the form element
244 244
         } else {
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
      */
254 254
     public function loadForm()
255 255
     {
256
-        require_once __DIR__ . '/' . $this->mode . '.php';
257
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
256
+        require_once __DIR__.'/'.$this->mode.'.php';
257
+        $class          = 'XoopsCaptcha'.ucfirst($this->mode);
258 258
         $captchaHandler = new $class();
259 259
         $captchaHandler->loadConfig($this->config);
260 260
 
Please login to merge, or discard this patch.
include/captcha/scripts/img.php 1 patch
Indentation   +412 added lines, -412 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $xoopsLogger->activated = false;
11 11
 
12 12
 if (empty($_SERVER['HTTP_REFERER']) || !preg_match('/^' . preg_quote(XOOPS_URL, '/') . '/', $_SERVER['HTTP_REFERER'])) {
13
-    exit();
13
+	exit();
14 14
 }
15 15
 
16 16
 /**
@@ -18,192 +18,192 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class XoopsCaptchaImageHandler
20 20
 {
21
-    public $config = [];
22
-    //var $mode = "gd"; // GD or bmp
23
-    public $code;
24
-    public $invalid = false;
25
-
26
-    public $font;
27
-    public $spacing;
28
-    public $width;
29
-    public $height;
30
-
31
-    /**
32
-     * XoopsCaptchaImageHandler constructor.
33
-     */
34
-    public function __construct()
35
-    {
36
-        if (empty($_SESSION['XoopsCaptcha_name'])) {
37
-            $this->invalid = true;
38
-        }
39
-
40
-        if (!extension_loaded('gd')) {
41
-            $this->mode = 'bmp';
42
-        } else {
43
-            $required_functions = [
44
-                'imagecreatetruecolor',
45
-                'imagecolorallocate',
46
-                'imagefilledrectangle',
47
-                'imagejpeg',
48
-                'imagedestroy',
49
-                'imageftbbox'
50
-            ];
51
-            foreach ($required_functions as $func) {
52
-                if (!function_exists($func)) {
53
-                    $this->mode = 'bmp';
54
-                    break;
55
-                }
56
-            }
57
-        }
58
-    }
59
-
60
-    /**
61
-     * Loading configs from CAPTCHA class
62
-     * @param array $config
63
-     */
64
-    public function setConfig($config = [])
65
-    {
66
-        // Loading default preferences
67
-        $this->config = $config;
68
-    }
69
-
70
-    public function loadImage()
71
-    {
72
-        $this->createCode();
73
-        $this->setCode();
74
-        $this->createImage();
75
-    }
76
-
77
-    /**
78
-     * Create Code
79
-     */
80
-    public function createCode()
81
-    {
82
-        if ($this->invalid) {
83
-            return;
84
-        }
85
-
86
-        if ($this->mode === 'bmp') {
87
-            $this->config['num_chars'] = 4;
88
-            $this->code                = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9'));
89
-        } else {
90
-            $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']);
91
-            if (!$this->config['casesensitive']) {
92
-                $this->code = strtoupper($this->code);
93
-            }
94
-        }
95
-    }
96
-
97
-    public function setCode()
98
-    {
99
-        if ($this->invalid) {
100
-            return;
101
-        }
102
-
103
-        $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
104
-        $maxAttempts                          = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
105
-
106
-        // Increase the attempt records on refresh
107
-        if (!empty($maxAttempts)) {
108
-            $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
109
-            if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
110
-                $this->invalid = true;
111
-            }
112
-        }
113
-    }
114
-
115
-    /**
116
-     * @param  string $file
117
-     * @return string|void
118
-     */
119
-    public function createImage($file = '')
120
-    {
121
-        if ($this->invalid) {
122
-            header('Content-type: image/gif');
123
-            readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif');
124
-
125
-            return;
126
-        }
127
-
128
-        if ($this->mode === 'bmp') {
129
-            return $this->createImageBmp();
130
-        } else {
131
-            return $this->createImageGd();
132
-        }
133
-    }
134
-
135
-    /**
136
-     *  Create CAPTCHA iamge with GD
137
-     *  Originated from DuGris' SecurityImage
138
-     * @param string $file
139
-     */
140
-    //  --------------------------------------------------------------------------- //
141
-    // Class: SecurityImage 1.5                                                    //
142
-    // Author: DuGris aka L. Jen <http://www.dugris.info>                           //
143
-    // Email: [email protected]                                                    //
144
-    // Licence: GNU                                                                 //
145
-    // Project: XOOPS Project                                                   //
146
-    //  --------------------------------------------------------------------------- //
147
-    public function createImageGd($file = '')
148
-    {
149
-        $this->loadFont();
150
-        $this->setImageSize();
151
-
152
-        $this->oImage = imagecreatetruecolor($this->width, $this->height);
153
-        $background   = imagecolorallocate($this->oImage, 255, 255, 255);
154
-        imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background);
155
-
156
-        switch ($this->config['background_type']) {
157
-            default:
158
-            case 0:
159
-                $this->drawBars();
160
-                break;
161
-
162
-            case 1:
163
-                $this->drawCircles();
164
-                break;
165
-
166
-            case 2:
167
-                $this->drawLines();
168
-                break;
169
-
170
-            case 3:
171
-                $this->drawRectangles();
172
-                break;
173
-
174
-            case 4:
175
-                $this->drawEllipses();
176
-                break;
177
-
178
-            case 5:
179
-                $this->drawPolygons();
180
-                break;
181
-
182
-            case 100:
183
-                $this->createFromFile();
184
-                break;
185
-        }
186
-        $this->drawBorder();
187
-        $this->drawCode();
188
-
189
-        if (empty($file)) {
190
-            header('Content-type: image/jpeg');
191
-            imagejpeg($this->oImage);
192
-        } else {
193
-            imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg');
194
-        }
195
-        imagedestroy($this->oImage);
196
-    }
197
-
198
-    /**
199
-     * @param         $name
200
-     * @param  string $extension
201
-     * @return array
202
-     */
203
-    public function _getList($name, $extension = '')
204
-    {
205
-        $items = [];
206
-        /*
21
+	public $config = [];
22
+	//var $mode = "gd"; // GD or bmp
23
+	public $code;
24
+	public $invalid = false;
25
+
26
+	public $font;
27
+	public $spacing;
28
+	public $width;
29
+	public $height;
30
+
31
+	/**
32
+	 * XoopsCaptchaImageHandler constructor.
33
+	 */
34
+	public function __construct()
35
+	{
36
+		if (empty($_SESSION['XoopsCaptcha_name'])) {
37
+			$this->invalid = true;
38
+		}
39
+
40
+		if (!extension_loaded('gd')) {
41
+			$this->mode = 'bmp';
42
+		} else {
43
+			$required_functions = [
44
+				'imagecreatetruecolor',
45
+				'imagecolorallocate',
46
+				'imagefilledrectangle',
47
+				'imagejpeg',
48
+				'imagedestroy',
49
+				'imageftbbox'
50
+			];
51
+			foreach ($required_functions as $func) {
52
+				if (!function_exists($func)) {
53
+					$this->mode = 'bmp';
54
+					break;
55
+				}
56
+			}
57
+		}
58
+	}
59
+
60
+	/**
61
+	 * Loading configs from CAPTCHA class
62
+	 * @param array $config
63
+	 */
64
+	public function setConfig($config = [])
65
+	{
66
+		// Loading default preferences
67
+		$this->config = $config;
68
+	}
69
+
70
+	public function loadImage()
71
+	{
72
+		$this->createCode();
73
+		$this->setCode();
74
+		$this->createImage();
75
+	}
76
+
77
+	/**
78
+	 * Create Code
79
+	 */
80
+	public function createCode()
81
+	{
82
+		if ($this->invalid) {
83
+			return;
84
+		}
85
+
86
+		if ($this->mode === 'bmp') {
87
+			$this->config['num_chars'] = 4;
88
+			$this->code                = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9'));
89
+		} else {
90
+			$this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']);
91
+			if (!$this->config['casesensitive']) {
92
+				$this->code = strtoupper($this->code);
93
+			}
94
+		}
95
+	}
96
+
97
+	public function setCode()
98
+	{
99
+		if ($this->invalid) {
100
+			return;
101
+		}
102
+
103
+		$_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
104
+		$maxAttempts                          = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
105
+
106
+		// Increase the attempt records on refresh
107
+		if (!empty($maxAttempts)) {
108
+			$_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
109
+			if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
110
+				$this->invalid = true;
111
+			}
112
+		}
113
+	}
114
+
115
+	/**
116
+	 * @param  string $file
117
+	 * @return string|void
118
+	 */
119
+	public function createImage($file = '')
120
+	{
121
+		if ($this->invalid) {
122
+			header('Content-type: image/gif');
123
+			readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif');
124
+
125
+			return;
126
+		}
127
+
128
+		if ($this->mode === 'bmp') {
129
+			return $this->createImageBmp();
130
+		} else {
131
+			return $this->createImageGd();
132
+		}
133
+	}
134
+
135
+	/**
136
+	 *  Create CAPTCHA iamge with GD
137
+	 *  Originated from DuGris' SecurityImage
138
+	 * @param string $file
139
+	 */
140
+	//  --------------------------------------------------------------------------- //
141
+	// Class: SecurityImage 1.5                                                    //
142
+	// Author: DuGris aka L. Jen <http://www.dugris.info>                           //
143
+	// Email: [email protected]                                                    //
144
+	// Licence: GNU                                                                 //
145
+	// Project: XOOPS Project                                                   //
146
+	//  --------------------------------------------------------------------------- //
147
+	public function createImageGd($file = '')
148
+	{
149
+		$this->loadFont();
150
+		$this->setImageSize();
151
+
152
+		$this->oImage = imagecreatetruecolor($this->width, $this->height);
153
+		$background   = imagecolorallocate($this->oImage, 255, 255, 255);
154
+		imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background);
155
+
156
+		switch ($this->config['background_type']) {
157
+			default:
158
+			case 0:
159
+				$this->drawBars();
160
+				break;
161
+
162
+			case 1:
163
+				$this->drawCircles();
164
+				break;
165
+
166
+			case 2:
167
+				$this->drawLines();
168
+				break;
169
+
170
+			case 3:
171
+				$this->drawRectangles();
172
+				break;
173
+
174
+			case 4:
175
+				$this->drawEllipses();
176
+				break;
177
+
178
+			case 5:
179
+				$this->drawPolygons();
180
+				break;
181
+
182
+			case 100:
183
+				$this->createFromFile();
184
+				break;
185
+		}
186
+		$this->drawBorder();
187
+		$this->drawCode();
188
+
189
+		if (empty($file)) {
190
+			header('Content-type: image/jpeg');
191
+			imagejpeg($this->oImage);
192
+		} else {
193
+			imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg');
194
+		}
195
+		imagedestroy($this->oImage);
196
+	}
197
+
198
+	/**
199
+	 * @param         $name
200
+	 * @param  string $extension
201
+	 * @return array
202
+	 */
203
+	public function _getList($name, $extension = '')
204
+	{
205
+		$items = [];
206
+		/*
207 207
          if (@ require_once XOOPS_ROOT_PATH."/Frameworks/art/functions.ini.php") {
208 208
          load_functions("cache");
209 209
          if ($items = mod_loadCacheFile("captcha_{$name}", "captcha")) {
@@ -211,231 +211,231 @@  discard block
 block discarded – undo
211 211
          }
212 212
          }
213 213
          */
214
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
215
-        $file_path = $this->config['rootpath'] . "/{$name}";
216
-        $files     = XoopsLists::getFileListAsArray($file_path);
217
-        foreach ($files as $item) {
218
-            if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
219
-                $items[] = $item;
220
-            }
221
-        }
222
-        if (function_exists('mod_createCacheFile')) {
223
-            mod_createCacheFile($items, "captcha_{$name}", 'captcha');
224
-        }
225
-
226
-        return $items;
227
-    }
228
-
229
-    public function loadFont()
230
-    {
231
-        $fonts      = $this->_getList('fonts', 'ttf');
232
-        $this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)];
233
-    }
234
-
235
-    public function setImageSize()
236
-    {
237
-        $MaxCharWidth  = 0;
238
-        $MaxCharHeight = 0;
239
-        $oImage        = imagecreatetruecolor(100, 100);
240
-        $text_color    = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
241
-        $FontSize      = $this->config['fontsize_max'];
242
-        for ($Angle = -30; $Angle <= 30; ++$Angle) {
243
-            for ($i = 65; $i <= 90; ++$i) {
244
-                $CharDetails   = imageftbbox($FontSize, $Angle, $this->font, chr($i), []);
245
-                $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
246
-                if ($_MaxCharWidth > $MaxCharWidth) {
247
-                    $MaxCharWidth = $_MaxCharWidth;
248
-                }
249
-                $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
250
-                if ($_MaxCharHeight > $MaxCharHeight) {
251
-                    $MaxCharHeight = $_MaxCharHeight;
252
-                }
253
-            }
254
-        }
255
-        imagedestroy($oImage);
256
-
257
-        $this->height  = $MaxCharHeight + 2;
258
-        $this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']);
259
-        $this->width   = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2);
260
-    }
261
-
262
-    /**
263
-     * Return random background
264
-     *
265
-     * @return array
266
-     */
267
-    public function loadBackground()
268
-    {
269
-        $RandBackground = null;
270
-        if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) {
271
-            $RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)];
272
-        }
273
-
274
-        return $RandBackground;
275
-    }
276
-
277
-    /**
278
-     * Draw Image background
279
-     */
280
-    public function createFromFile()
281
-    {
282
-        if ($RandImage = $this->loadBackground()) {
283
-            $ImageType = @getimagesize($RandImage);
284
-            switch (@$ImageType[2]) {
285
-                case 1:
286
-                    $BackgroundImage = imagecreatefromgif($RandImage);
287
-                    break;
288
-
289
-                case 2:
290
-                    $BackgroundImage = imagecreatefromjpeg($RandImage);
291
-                    break;
292
-
293
-                case 3:
294
-                    $BackgroundImage = imagecreatefrompng($RandImage);
295
-                    break;
296
-            }
297
-        }
298
-        if (!empty($BackgroundImage)) {
299
-            imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
300
-            imagedestroy($BackgroundImage);
301
-        } else {
302
-            $this->drawBars();
303
-        }
304
-    }
305
-
306
-    /**
307
-     * Draw Code
308
-     */
309
-    public function drawCode()
310
-    {
311
-        for ($i = 0; $i < $this->config['num_chars']; ++$i) {
312
-            // select random greyscale colour
313
-            $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
314
-
315
-            // write text to image
316
-            $Angle = mt_rand(10, 30);
317
-            if ($i % 2) {
318
-                $Angle = mt_rand(-10, -30);
319
-            }
320
-
321
-            // select random font size
322
-            $FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']);
323
-
324
-            $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], []);
325
-            $CharHeight  = abs($CharDetails[1] + $CharDetails[5]);
326
-
327
-            // calculate character starting coordinates
328
-            $posX = ($this->spacing / 2) + ($i * $this->spacing);
329
-            $posY = 2 + ($this->height / 2) + ($CharHeight / 4);
330
-
331
-            imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], []);
332
-        }
333
-    }
334
-
335
-    /**
336
-     * Draw Border
337
-     */
338
-    public function drawBorder()
339
-    {
340
-        $rgb          = mt_rand(50, 150);
341
-        $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
342
-        imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
343
-    }
344
-
345
-    /**
346
-     * Draw Circles background
347
-     */
348
-    public function drawCircles()
349
-    {
350
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
351
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
352
-            imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
353
-        }
354
-    }
355
-
356
-    /**
357
-     * Draw Lines background
358
-     */
359
-    public function drawLines()
360
-    {
361
-        for ($i = 0; $i < $this->config['background_num']; ++$i) {
362
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
363
-            imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
364
-        }
365
-    }
366
-
367
-    /**
368
-     * Draw Rectangles background
369
-     */
370
-    public function drawRectangles()
371
-    {
372
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
373
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
374
-            imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
375
-        }
376
-    }
377
-
378
-    /**
379
-     * Draw Bars background
380
-     */
381
-    public function drawBars()
382
-    {
383
-        for ($i = 0; $i <= $this->height;) {
384
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
385
-            imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
386
-            $i += 2.5;
387
-        }
388
-        for ($i = 0; $i <= $this->width;) {
389
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
390
-            imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
391
-            $i += 2.5;
392
-        }
393
-    }
394
-
395
-    /**
396
-     * Draw Ellipses background
397
-     */
398
-    public function drawEllipses()
399
-    {
400
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
401
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
402
-            imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
403
-        }
404
-    }
405
-
406
-    /**
407
-     * Draw polygons background
408
-     */
409
-    public function drawPolygons()
410
-    {
411
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
412
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
413
-            $coords      = [];
414
-            for ($j = 1; $j <= $this->config['polygon_point']; ++$j) {
415
-                $coords[] = mt_rand(0, $this->width);
416
-                $coords[] = mt_rand(0, $this->height);
417
-            }
418
-            imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor);
419
-        }
420
-    }
421
-
422
-    /**
423
-     *  Create CAPTCHA iamge with BMP
424
-     *  TODO
425
-     * @param  string $file
426
-     * @return string
427
-     */
428
-    public function createImageBmp($file = '')
429
-    {
430
-        $image = '';
431
-
432
-        if (empty($file)) {
433
-            header('Content-type: image/bmp');
434
-            echo $image;
435
-        } else {
436
-            return $image;
437
-        }
438
-    }
214
+		require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
215
+		$file_path = $this->config['rootpath'] . "/{$name}";
216
+		$files     = XoopsLists::getFileListAsArray($file_path);
217
+		foreach ($files as $item) {
218
+			if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
219
+				$items[] = $item;
220
+			}
221
+		}
222
+		if (function_exists('mod_createCacheFile')) {
223
+			mod_createCacheFile($items, "captcha_{$name}", 'captcha');
224
+		}
225
+
226
+		return $items;
227
+	}
228
+
229
+	public function loadFont()
230
+	{
231
+		$fonts      = $this->_getList('fonts', 'ttf');
232
+		$this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)];
233
+	}
234
+
235
+	public function setImageSize()
236
+	{
237
+		$MaxCharWidth  = 0;
238
+		$MaxCharHeight = 0;
239
+		$oImage        = imagecreatetruecolor(100, 100);
240
+		$text_color    = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
241
+		$FontSize      = $this->config['fontsize_max'];
242
+		for ($Angle = -30; $Angle <= 30; ++$Angle) {
243
+			for ($i = 65; $i <= 90; ++$i) {
244
+				$CharDetails   = imageftbbox($FontSize, $Angle, $this->font, chr($i), []);
245
+				$_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
246
+				if ($_MaxCharWidth > $MaxCharWidth) {
247
+					$MaxCharWidth = $_MaxCharWidth;
248
+				}
249
+				$_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
250
+				if ($_MaxCharHeight > $MaxCharHeight) {
251
+					$MaxCharHeight = $_MaxCharHeight;
252
+				}
253
+			}
254
+		}
255
+		imagedestroy($oImage);
256
+
257
+		$this->height  = $MaxCharHeight + 2;
258
+		$this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']);
259
+		$this->width   = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2);
260
+	}
261
+
262
+	/**
263
+	 * Return random background
264
+	 *
265
+	 * @return array
266
+	 */
267
+	public function loadBackground()
268
+	{
269
+		$RandBackground = null;
270
+		if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) {
271
+			$RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)];
272
+		}
273
+
274
+		return $RandBackground;
275
+	}
276
+
277
+	/**
278
+	 * Draw Image background
279
+	 */
280
+	public function createFromFile()
281
+	{
282
+		if ($RandImage = $this->loadBackground()) {
283
+			$ImageType = @getimagesize($RandImage);
284
+			switch (@$ImageType[2]) {
285
+				case 1:
286
+					$BackgroundImage = imagecreatefromgif($RandImage);
287
+					break;
288
+
289
+				case 2:
290
+					$BackgroundImage = imagecreatefromjpeg($RandImage);
291
+					break;
292
+
293
+				case 3:
294
+					$BackgroundImage = imagecreatefrompng($RandImage);
295
+					break;
296
+			}
297
+		}
298
+		if (!empty($BackgroundImage)) {
299
+			imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
300
+			imagedestroy($BackgroundImage);
301
+		} else {
302
+			$this->drawBars();
303
+		}
304
+	}
305
+
306
+	/**
307
+	 * Draw Code
308
+	 */
309
+	public function drawCode()
310
+	{
311
+		for ($i = 0; $i < $this->config['num_chars']; ++$i) {
312
+			// select random greyscale colour
313
+			$text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
314
+
315
+			// write text to image
316
+			$Angle = mt_rand(10, 30);
317
+			if ($i % 2) {
318
+				$Angle = mt_rand(-10, -30);
319
+			}
320
+
321
+			// select random font size
322
+			$FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']);
323
+
324
+			$CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], []);
325
+			$CharHeight  = abs($CharDetails[1] + $CharDetails[5]);
326
+
327
+			// calculate character starting coordinates
328
+			$posX = ($this->spacing / 2) + ($i * $this->spacing);
329
+			$posY = 2 + ($this->height / 2) + ($CharHeight / 4);
330
+
331
+			imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], []);
332
+		}
333
+	}
334
+
335
+	/**
336
+	 * Draw Border
337
+	 */
338
+	public function drawBorder()
339
+	{
340
+		$rgb          = mt_rand(50, 150);
341
+		$border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
342
+		imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
343
+	}
344
+
345
+	/**
346
+	 * Draw Circles background
347
+	 */
348
+	public function drawCircles()
349
+	{
350
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
351
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
352
+			imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
353
+		}
354
+	}
355
+
356
+	/**
357
+	 * Draw Lines background
358
+	 */
359
+	public function drawLines()
360
+	{
361
+		for ($i = 0; $i < $this->config['background_num']; ++$i) {
362
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
363
+			imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
364
+		}
365
+	}
366
+
367
+	/**
368
+	 * Draw Rectangles background
369
+	 */
370
+	public function drawRectangles()
371
+	{
372
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
373
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
374
+			imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
375
+		}
376
+	}
377
+
378
+	/**
379
+	 * Draw Bars background
380
+	 */
381
+	public function drawBars()
382
+	{
383
+		for ($i = 0; $i <= $this->height;) {
384
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
385
+			imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
386
+			$i += 2.5;
387
+		}
388
+		for ($i = 0; $i <= $this->width;) {
389
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
390
+			imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
391
+			$i += 2.5;
392
+		}
393
+	}
394
+
395
+	/**
396
+	 * Draw Ellipses background
397
+	 */
398
+	public function drawEllipses()
399
+	{
400
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
401
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
402
+			imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
403
+		}
404
+	}
405
+
406
+	/**
407
+	 * Draw polygons background
408
+	 */
409
+	public function drawPolygons()
410
+	{
411
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
412
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
413
+			$coords      = [];
414
+			for ($j = 1; $j <= $this->config['polygon_point']; ++$j) {
415
+				$coords[] = mt_rand(0, $this->width);
416
+				$coords[] = mt_rand(0, $this->height);
417
+			}
418
+			imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor);
419
+		}
420
+	}
421
+
422
+	/**
423
+	 *  Create CAPTCHA iamge with BMP
424
+	 *  TODO
425
+	 * @param  string $file
426
+	 * @return string
427
+	 */
428
+	public function createImageBmp($file = '')
429
+	{
430
+		$image = '';
431
+
432
+		if (empty($file)) {
433
+			header('Content-type: image/bmp');
434
+			echo $image;
435
+		} else {
436
+			return $image;
437
+		}
438
+	}
439 439
 }
440 440
 
441 441
 $config       = @include __DIR__ . '/../config.php';
Please login to merge, or discard this patch.