Completed
Push — master ( c004c3...65a58d )
by Michael
04:32
created
smartfaq/answer.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,12 @@
 block discarded – undo
20 20
 $op = 'form';
21 21
 
22 22
 // Getting the operation we are doing
23
-if (isset($_GET['op'])) $op = $_GET['op'];
24
-if (isset($_POST['op'])) $op = $_POST['op'];
23
+if (isset($_GET['op'])) {
24
+    $op = $_GET['op'];
25
+}
26
+if (isset($_POST['op'])) {
27
+    $op = $_POST['op'];
28
+}
25 29
 
26 30
 // Getting the faqid
27 31
 $faqid = isset($_GET['faqid'])? intval($_GET['faqid']) : 0;
Please login to merge, or discard this patch.
smartfaq/include/functions.render.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@
 block discarded – undo
123 123
     global $xoTheme, $xoopsConfig;
124 124
     static $icon_handler;
125 125
 
126
-    if (isset($icon_handler)) return $icon_handler;
126
+    if (isset($icon_handler)) {
127
+        return $icon_handler;
128
+    }
127 129
 
128 130
     if (!class_exists("NewbbIconHandler")) {
129 131
         require_once dirname(__DIR__)."/class/icon.php";
Please login to merge, or discard this patch.
smartfaq/include/blocksadmin.inc.php 2 patches
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -203,18 +203,18 @@
 block discarded – undo
203 203
         }
204 204
         if ($myblock->getVar('block_type') == 'C') {
205 205
             switch ($bctype) {
206
-            case 'H':
207
-                $name = _AM_CUSTOMHTML;
208
-                break;
209
-            case 'P':
210
-                $name = _AM_CUSTOMPHP;
211
-                break;
212
-            case 'S':
213
-                $name = _AM_CUSTOMSMILE;
214
-                break;
215
-            default:
216
-                $name = _AM_CUSTOMNOSMILE;
217
-                break;
206
+                case 'H':
207
+                    $name = _AM_CUSTOMHTML;
208
+                    break;
209
+                case 'P':
210
+                    $name = _AM_CUSTOMPHP;
211
+                    break;
212
+                case 'S':
213
+                    $name = _AM_CUSTOMSMILE;
214
+                    break;
215
+                default:
216
+                    $name = _AM_CUSTOMNOSMILE;
217
+                    break;
218 218
             }
219 219
             $myblock->setVar('name', $name);
220 220
             $myblock->setVar('c_type', $bctype);
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -191,7 +191,10 @@
 block discarded – undo
191 191
         }
192 192
         $myblock = new XoopsBlock($bid);
193 193
         // $myblock->setVar('side', $bside); GIJ -
194
-        if ( $bside >= 0 ) $myblock->setVar('side', $bside); // GIJ +
194
+        if ( $bside >= 0 ) {
195
+            $myblock->setVar('side', $bside);
196
+        }
197
+        // GIJ +
195 198
         $myblock->setVar('weight', $bweight);
196 199
         $myblock->setVar('visible', $bvisible);
197 200
         $myblock->setVar('title', $btitle);
Please login to merge, or discard this patch.
smartfaq/include/functions.image.php 1 patch
Braces   +24 added lines, -9 removed lines patch added patch discarded remove patch
@@ -80,7 +80,9 @@  discard block
 block discarded – undo
80 80
         $attachmentImage .= '</a>';
81 81
     } elseif (file_exists($image)) {
82 82
         $attachmentImage = '<img src="'.$image_url.'" alt="'.$source.' '.$img_info.'" />';
83
-    } else $attachmentImage = '';
83
+    } else {
84
+        $attachmentImage = '';
85
+    }
84 86
 
85 87
     return $attachmentImage;
86 88
 }
@@ -152,17 +154,27 @@  discard block
 block discarded – undo
152 154
     $type = $imginfo[2];
153 155
     $supported_types = array();
154 156
 
155
-    if (!extension_loaded('gd')) return false;
156
-    if (function_exists('imagegif')) $supported_types[] = 1;
157
-    if (function_exists('imagejpeg'))$supported_types[] = 2;
158
-    if (function_exists('imagepng')) $supported_types[] = 3;
157
+    if (!extension_loaded('gd')) {
158
+        return false;
159
+    }
160
+    if (function_exists('imagegif')) {
161
+        $supported_types[] = 1;
162
+    }
163
+    if (function_exists('imagejpeg')) {
164
+        $supported_types[] = 2;
165
+    }
166
+    if (function_exists('imagepng')) {
167
+        $supported_types[] = 3;
168
+    }
159 169
 
160 170
     $imageCreateFunction = (function_exists('imagecreatetruecolor'))? "imagecreatetruecolor" : "imagecreate";
161 171
 
162 172
     if (in_array($type, $supported_types) ) {
163 173
         switch ($type) {
164 174
             case 1 :
165
-                if (!function_exists('imagecreatefromgif')) return false;
175
+                if (!function_exists('imagecreatefromgif')) {
176
+                    return false;
177
+                }
166 178
                 $im = imagecreatefromgif ($src_file);
167 179
                 $new_im = imagecreate($newWidth, $newHeight);
168 180
                 imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
@@ -189,8 +201,11 @@  discard block
 block discarded – undo
189 201
         }
190 202
     }
191 203
 
192
-    if (file_exists($new_file))    return true;
193
-    else return false;
194
-}
204
+    if (file_exists($new_file)) {
205
+        return true;
206
+    } else {
207
+        return false;
208
+    }
209
+    }
195 210
 
196 211
 endif;
Please login to merge, or discard this patch.
smartfaq/class/answer.php 1 patch
Braces   +31 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,17 +62,24 @@  discard block
 block discarded – undo
62 62
     // attachment functions    TODO: there should be a file/attachment management class
63 63
     function getAttachment()
64 64
     {
65
-        if (count($this->attachment_array)) return $this->attachment_array;
65
+        if (count($this->attachment_array)) {
66
+            return $this->attachment_array;
67
+        }
66 68
         $attachment = $this->getVar('attachment');
67
-        if (empty($attachment)) $this->attachment_array = null;
68
-        else $this->attachment_array = @unserialize(base64_decode($attachment));
69
+        if (empty($attachment)) {
70
+            $this->attachment_array = null;
71
+        } else {
72
+            $this->attachment_array = @unserialize(base64_decode($attachment));
73
+        }
69 74
 
70 75
         return $this->attachment_array;
71 76
     }
72 77
 
73 78
     function incrementDownload($attach_key)
74 79
     {
75
-        if (!$attach_key) return false;
80
+        if (!$attach_key) {
81
+            return false;
82
+        }
76 83
         $this->attachment_array[strval($attach_key)]['num_download'] ++;
77 84
 
78 85
         return $this->attachment_array[strval($attach_key)]['num_download'];
@@ -80,9 +87,11 @@  discard block
 block discarded – undo
80 87
 
81 88
     function saveAttachment()
82 89
     {
83
-        if (is_array($this->attachment_array) && count($this->attachment_array) > 0)
84
-            $attachment_save = base64_encode(serialize($this->attachment_array));
85
-        else $attachment_save = '';
90
+        if (is_array($this->attachment_array) && count($this->attachment_array) > 0) {
91
+                    $attachment_save = base64_encode(serialize($this->attachment_array));
92
+        } else {
93
+            $attachment_save = '';
94
+        }
86 95
         $this->setVar('attachment', $attachment_save);
87 96
         $sql = "UPDATE " . $GLOBALS["xoopsDB"]->prefix("smartfaq_answers") . " SET attachment=" . $GLOBALS["xoopsDB"]->quoteString($attachment_save) . " WHERE post_id = " . $this->getVar('answerid');
88 97
         if (!$result = $GLOBALS["xoopsDB"]->queryF($sql)) {
@@ -98,11 +107,18 @@  discard block
 block discarded – undo
98 107
         global $xoopsModuleConfig;
99 108
 
100 109
         $attach_old = $this->getAttachment();
101
-        if (!is_array($attach_old) || count($attach_old) < 1) return true;
110
+        if (!is_array($attach_old) || count($attach_old) < 1) {
111
+            return true;
112
+        }
102 113
         $this->attachment_array = array();
103 114
 
104
-        if ($attach_array === null) $attach_array = array_keys($attach_old); // to delete all!
105
-        if (!is_array($attach_array)) $attach_array = array($attach_array);
115
+        if ($attach_array === null) {
116
+            $attach_array = array_keys($attach_old);
117
+        }
118
+        // to delete all!
119
+        if (!is_array($attach_array)) {
120
+            $attach_array = array($attach_array);
121
+        }
106 122
 
107 123
         foreach ($attach_old as $key => $attach) {
108 124
             if (in_array($key, $attach_array)) {
@@ -112,9 +128,11 @@  discard block
 block discarded – undo
112 128
             }
113 129
             $this->attachment_array[$key] = $attach;
114 130
         }
115
-        if (is_array($this->attachment_array) && count($this->attachment_array) > 0)
116
-            $attachment_save = base64_encode(serialize($this->attachment_array));
117
-        else $attachment_save = '';
131
+        if (is_array($this->attachment_array) && count($this->attachment_array) > 0) {
132
+                    $attachment_save = base64_encode(serialize($this->attachment_array));
133
+        } else {
134
+            $attachment_save = '';
135
+        }
118 136
         $this->setVar('attachment', $attachment_save);
119 137
 
120 138
         return true;
Please login to merge, or discard this patch.
smartfaq/submit.php 1 patch
Switch Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -47,161 +47,161 @@  discard block
 block discarded – undo
47 47
 }
48 48
 
49 49
 switch ($op) {
50
-    case 'preview':
50
+        case 'preview':
51 51
 
52
-    Global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB;
52
+        Global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB;
53 53
 
54
-    $faqObj = $faq_handler->create();
55
-    $answerObj = $answer_handler->create();
56
-    $categoryObj = $category_handler->get($_POST['categoryid']);
54
+        $faqObj = $faq_handler->create();
55
+        $answerObj = $answer_handler->create();
56
+        $categoryObj = $category_handler->get($_POST['categoryid']);
57 57
 
58
-    if (!$xoopsUser) {
59
-        if ($xoopsModuleConfig['anonpost'] == 1) {
60
-            $uid = 0;
58
+        if (!$xoopsUser) {
59
+            if ($xoopsModuleConfig['anonpost'] == 1) {
60
+                $uid = 0;
61
+            } else {
62
+                redirect_header("index.php", 3, _NOPERM);
63
+                exit();
64
+            }
61 65
         } else {
62
-            redirect_header("index.php", 3, _NOPERM);
63
-            exit();
66
+            $uid = $xoopsUser->uid();
64 67
         }
65
-    } else {
66
-        $uid = $xoopsUser->uid();
67
-    }
68 68
 
69
-    $notifypub = isset($_POST['notifypub'])? $_POST['notifypub'] : 0;
69
+        $notifypub = isset($_POST['notifypub'])? $_POST['notifypub'] : 0;
70 70
 
71
-    // Putting the values about the FAQ in the FAQ object
72
-    $faqObj->setVar('categoryid', $_POST['categoryid']);
73
-    $faqObj->setVar('uid', $uid);
74
-    $faqObj->setVar('question', $_POST['question']);
75
-    $faqObj->setVar('howdoi', $_POST['howdoi']);
76
-    $faqObj->setVar('diduno', $_POST['diduno']);
77
-    $faqObj->setVar('datesub', time());
71
+        // Putting the values about the FAQ in the FAQ object
72
+        $faqObj->setVar('categoryid', $_POST['categoryid']);
73
+        $faqObj->setVar('uid', $uid);
74
+        $faqObj->setVar('question', $_POST['question']);
75
+        $faqObj->setVar('howdoi', $_POST['howdoi']);
76
+        $faqObj->setVar('diduno', $_POST['diduno']);
77
+        $faqObj->setVar('datesub', time());
78 78
 
79
-    // Putting the values in the answer object
80
-    $answerObj->setVar('status', _SF_AN_STATUS_APPROVED);
81
-    $answerObj->setVar('faqid', $faqObj->faqid());
82
-    $answerObj->setVar('answer', $_POST['answer']);
83
-    $answerObj->setVar('uid', $uid);
79
+        // Putting the values in the answer object
80
+        $answerObj->setVar('status', _SF_AN_STATUS_APPROVED);
81
+        $answerObj->setVar('faqid', $faqObj->faqid());
82
+        $answerObj->setVar('answer', $_POST['answer']);
83
+        $answerObj->setVar('uid', $uid);
84 84
 
85
-    global $xoopsUser, $myts;
85
+        global $xoopsUser, $myts;
86 86
 
87
-    $xoopsOption['template_main'] = 'smartfaq_submit.tpl';
88
-    include_once(XOOPS_ROOT_PATH . "/header.php");
89
-    include_once __DIR__ . '/footer.php';
87
+        $xoopsOption['template_main'] = 'smartfaq_submit.tpl';
88
+        include_once(XOOPS_ROOT_PATH . "/header.php");
89
+        include_once __DIR__ . '/footer.php';
90 90
 
91
-    $name = ($xoopsUser)? (ucwords($xoopsUser->getVar("uname"))) : 'Anonymous';
91
+        $name = ($xoopsUser)? (ucwords($xoopsUser->getVar("uname"))) : 'Anonymous';
92 92
 
93
-    $moduleName = $myts->displayTarea($xoopsModule->getVar('name'));
94
-    $faq = $faqObj->toArray(null, $categoryObj, false);
95
-    $faq['categoryPath'] = $categoryObj->getCategoryPath(true);
96
-    $faq['answer'] = $answerObj->answer();
97
-    $faq['who_when'] = $faqObj->getWhoAndWhen();
93
+        $moduleName = $myts->displayTarea($xoopsModule->getVar('name'));
94
+        $faq = $faqObj->toArray(null, $categoryObj, false);
95
+        $faq['categoryPath'] = $categoryObj->getCategoryPath(true);
96
+        $faq['answer'] = $answerObj->answer();
97
+        $faq['who_when'] = $faqObj->getWhoAndWhen();
98 98
 
99
-    $faq['comments'] = -1;
100
-    $xoopsTpl->assign('faq', $faq);
101
-    $xoopsTpl->assign('op', 'preview');
102
-    $xoopsTpl->assign('whereInSection', $moduleName);
103
-    $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
99
+        $faq['comments'] = -1;
100
+        $xoopsTpl->assign('faq', $faq);
101
+        $xoopsTpl->assign('op', 'preview');
102
+        $xoopsTpl->assign('whereInSection', $moduleName);
103
+        $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
104 104
 
105
-    $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
106
-    $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
105
+        $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
106
+        $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
107 107
 
108
-    include_once 'include/submit.inc.php';
108
+        include_once 'include/submit.inc.php';
109 109
 
110
-    include_once XOOPS_ROOT_PATH . '/footer.php';
110
+        include_once XOOPS_ROOT_PATH . '/footer.php';
111 111
 
112
-    exit();
113
-    break;
112
+        exit();
113
+        break;
114 114
 
115
-    case 'post':
115
+        case 'post':
116 116
 
117
-    Global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB;
117
+        Global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB;
118 118
 
119
-    $newFaqObj = $faq_handler->create();
120
-    $newAnswerObj = $answer_handler->create();
119
+        $newFaqObj = $faq_handler->create();
120
+        $newAnswerObj = $answer_handler->create();
121 121
 
122
-    if (!$xoopsUser) {
123
-        if ($xoopsModuleConfig['anonpost'] == 1) {
124
-            $uid = 0;
122
+        if (!$xoopsUser) {
123
+            if ($xoopsModuleConfig['anonpost'] == 1) {
124
+                $uid = 0;
125
+            } else {
126
+                redirect_header("index.php", 3, _NOPERM);
127
+                exit();
128
+            }
125 129
         } else {
126
-            redirect_header("index.php", 3, _NOPERM);
127
-            exit();
130
+            $uid = $xoopsUser->uid();
128 131
         }
129
-    } else {
130
-        $uid = $xoopsUser->uid();
131
-    }
132 132
 
133
-    $notifypub = isset($_POST['notifypub'])? $_POST['notifypub'] : 0;
134
-
135
-    // Putting the values about the FAQ in the FAQ object
136
-    $newFaqObj->setVar('categoryid', $_POST['categoryid']);
137
-    $newFaqObj->setVar('uid', $uid);
138
-    $newFaqObj->setVar('question', $_POST['question']);
139
-    $newFaqObj->setVar('howdoi', $_POST['howdoi']);
140
-    $newFaqObj->setVar('diduno', $_POST['diduno']);
141
-    $newFaqObj->setVar('notifypub', $notifypub);
142
-    //$newFaqObj->setVar('modulelink', $_POST['modulelink']);
143
-    //$newFaqObj->setVar('contextpage', $_POST['contextpage']);
144
-
145
-    // Setting the status of the FAQ
146
-
147
-    // if user is admin, FAQ are automatically published
148
-    $isAdmin = sf_userIsAdmin();
149
-    if ($isAdmin) {
150
-        $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED);
151
-    } elseif ($xoopsModuleConfig['autoapprove_submitted_faq'] ==  1) {
152
-        $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED);
153
-    } else {
154
-        $newFaqObj->setVar('status', _SF_STATUS_SUBMITTED);
155
-    }
133
+        $notifypub = isset($_POST['notifypub'])? $_POST['notifypub'] : 0;
134
+
135
+        // Putting the values about the FAQ in the FAQ object
136
+        $newFaqObj->setVar('categoryid', $_POST['categoryid']);
137
+        $newFaqObj->setVar('uid', $uid);
138
+        $newFaqObj->setVar('question', $_POST['question']);
139
+        $newFaqObj->setVar('howdoi', $_POST['howdoi']);
140
+        $newFaqObj->setVar('diduno', $_POST['diduno']);
141
+        $newFaqObj->setVar('notifypub', $notifypub);
142
+        //$newFaqObj->setVar('modulelink', $_POST['modulelink']);
143
+        //$newFaqObj->setVar('contextpage', $_POST['contextpage']);
144
+
145
+        // Setting the status of the FAQ
146
+
147
+        // if user is admin, FAQ are automatically published
148
+        $isAdmin = sf_userIsAdmin();
149
+        if ($isAdmin) {
150
+            $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED);
151
+        } elseif ($xoopsModuleConfig['autoapprove_submitted_faq'] ==  1) {
152
+            $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED);
153
+        } else {
154
+            $newFaqObj->setVar('status', _SF_STATUS_SUBMITTED);
155
+        }
156 156
 
157
-    // Storing the FAQ object in the database
158
-    if ( !$newFaqObj->store() ) {
159
-        redirect_header("javascript:history.go(-1)", 2, _MD_SF_SUBMIT_ERROR);
160
-        exit();
161
-    }
157
+        // Storing the FAQ object in the database
158
+        if ( !$newFaqObj->store() ) {
159
+            redirect_header("javascript:history.go(-1)", 2, _MD_SF_SUBMIT_ERROR);
160
+            exit();
161
+        }
162 162
 
163
-    // Putting the values in the answer object
164
-    $newAnswerObj->setVar('status', _SF_AN_STATUS_APPROVED);
165
-    $newAnswerObj->setVar('faqid', $newFaqObj->faqid());
166
-    $newAnswerObj->setVar('answer', $_POST['answer']);
167
-    $newAnswerObj->setVar('uid', $uid);
168
-
169
-//====================================================================================
170
-        //TODO post Attachment
171
-        $attachments_tmp = array();
172
-        if (!empty($_POST["attachments_tmp"])) {
173
-            $attachments_tmp = unserialize(base64_decode($_POST["attachments_tmp"]));
174
-            if (isset($_POST["delete_tmp"]) && count($_POST["delete_tmp"])) {
175
-                foreach ($_POST["delete_tmp"] as $key) {
176
-                    unlink(XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['dir_attachments'] . "/" . $attachments_tmp[$key][0]);
177
-                    unset($attachments_tmp[$key]);
163
+        // Putting the values in the answer object
164
+        $newAnswerObj->setVar('status', _SF_AN_STATUS_APPROVED);
165
+        $newAnswerObj->setVar('faqid', $newFaqObj->faqid());
166
+        $newAnswerObj->setVar('answer', $_POST['answer']);
167
+        $newAnswerObj->setVar('uid', $uid);
168
+
169
+    //====================================================================================
170
+            //TODO post Attachment
171
+            $attachments_tmp = array();
172
+            if (!empty($_POST["attachments_tmp"])) {
173
+                $attachments_tmp = unserialize(base64_decode($_POST["attachments_tmp"]));
174
+                if (isset($_POST["delete_tmp"]) && count($_POST["delete_tmp"])) {
175
+                    foreach ($_POST["delete_tmp"] as $key) {
176
+                        unlink(XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['dir_attachments'] . "/" . $attachments_tmp[$key][0]);
177
+                        unset($attachments_tmp[$key]);
178
+                    }
178 179
                 }
179 180
             }
180
-        }
181
-        if (count($attachments_tmp)) {
182
-            foreach ($attachments_tmp as $key => $attach) {
183
-                if (rename(XOOPS_CACHE_PATH . "/" . $attachments_tmp[$key][0], XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['dir_attachments'] . "/" . $attachments_tmp[$key][0])) {
184
-                    $post_obj->setAttachment($attach[0], $attach[1], $attach[2]);
181
+            if (count($attachments_tmp)) {
182
+                foreach ($attachments_tmp as $key => $attach) {
183
+                    if (rename(XOOPS_CACHE_PATH . "/" . $attachments_tmp[$key][0], XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['dir_attachments'] . "/" . $attachments_tmp[$key][0])) {
184
+                        $post_obj->setAttachment($attach[0], $attach[1], $attach[2]);
185
+                    }
185 186
                 }
186 187
             }
187
-        }
188
-        $error_upload = '';
189
-
190
-        if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != '' && $topic_handler->getPermission($forum_obj, $topic_status, 'attach') ) {
191
-            require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/class/uploader.php';
192
-            $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024;
193
-            $uploaddir = XOOPS_CACHE_PATH;
194
-
195
-            $uploader = new sf_uploader(
196
-                $uploaddir,
197
-                $newAnswerObj->getVar('attach_ext'),
198
-                intval($maxfilesize),
199
-                intval($xoopsModuleConfig['max_img_width']),
200
-                intval($xoopsModuleConfig['max_img_height'])
201
-            );
202
-
203
-            if ($_FILES['userfile']['error'] > 0) {
204
-                switch ($_FILES['userfile']['error']) {
188
+            $error_upload = '';
189
+
190
+            if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != '' && $topic_handler->getPermission($forum_obj, $topic_status, 'attach') ) {
191
+                require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/class/uploader.php';
192
+                $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024;
193
+                $uploaddir = XOOPS_CACHE_PATH;
194
+
195
+                $uploader = new sf_uploader(
196
+                    $uploaddir,
197
+                    $newAnswerObj->getVar('attach_ext'),
198
+                    intval($maxfilesize),
199
+                    intval($xoopsModuleConfig['max_img_width']),
200
+                    intval($xoopsModuleConfig['max_img_height'])
201
+                );
202
+
203
+                if ($_FILES['userfile']['error'] > 0) {
204
+                    switch ($_FILES['userfile']['error']) {
205 205
                     case 1:
206 206
                         $error_message[] = _MD_NEWBB_MAXUPLOADFILEINI;
207 207
                         break;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                     default:
212 212
                         $error_message[] = _MD_NEWBB_UPLOAD_ERRNODEF;
213 213
                         break;
214
-                }
214
+                    }
215 215
             } else {
216 216
                 $uploader->setCheckMediaTypeByExt();
217 217
 
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
     exit();
278 278
     break;
279 279
 
280
-    case 'form':
281
-    default:
280
+        case 'form':
281
+        default:
282 282
 
283
-    global $xoopsUser, $myts;
283
+        global $xoopsUser, $myts;
284 284
 
285
-    $faqObj = $faq_handler->create();
286
-    $answerObj = $answer_handler->create();
287
-    $categoryObj = $category_handler->create();
285
+        $faqObj = $faq_handler->create();
286
+        $answerObj = $answer_handler->create();
287
+        $categoryObj = $category_handler->create();
288 288
 
289
-    $xoopsOption['template_main'] = 'smartfaq_submit.html';
290
-    include_once(XOOPS_ROOT_PATH . "/header.php");
291
-    include_once __DIR__ . '/footer.php';
289
+        $xoopsOption['template_main'] = 'smartfaq_submit.html';
290
+        include_once(XOOPS_ROOT_PATH . "/header.php");
291
+        include_once __DIR__ . '/footer.php';
292 292
 
293
-    $name = ($xoopsUser)? (ucwords($xoopsUser->getVar("uname"))) : 'Anonymous';
294
-    $notifypub = 1;
295
-    $moduleName = $myts->displayTarea($xoopsModule->getVar('name'));
296
-    $xoopsTpl->assign('whereInSection', $moduleName);
297
-    $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
293
+        $name = ($xoopsUser)? (ucwords($xoopsUser->getVar("uname"))) : 'Anonymous';
294
+        $notifypub = 1;
295
+        $moduleName = $myts->displayTarea($xoopsModule->getVar('name'));
296
+        $xoopsTpl->assign('whereInSection', $moduleName);
297
+        $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
298 298
 
299
-    $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
300
-    $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
299
+        $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
300
+        $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
301 301
 
302
-    include_once 'include/submit.inc.php';
302
+        include_once 'include/submit.inc.php';
303 303
 
304
-    include_once XOOPS_ROOT_PATH . '/footer.php';
305
-    break;
304
+        include_once XOOPS_ROOT_PATH . '/footer.php';
305
+        break;
306 306
 }
Please login to merge, or discard this patch.
smartfaq/admin/answer.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,12 @@
 block discarded – undo
12 12
 $op = '';
13 13
 
14 14
 // Getting the operation we are doing
15
-if (isset($_GET['op'])) $op = $_GET['op'];
16
-if (isset($_POST['op'])) $op = $_POST['op'];
15
+if (isset($_GET['op'])) {
16
+    $op = $_GET['op'];
17
+}
18
+if (isset($_POST['op'])) {
19
+    $op = $_POST['op'];
20
+}
17 21
 
18 22
 // Creating the answer handler object
19 23
 $answer_handler =& sf_gethandler('answer');
Please login to merge, or discard this patch.
smartfaq/admin/faq.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,12 @@
 block discarded – undo
19 19
 $answer_handler =& sf_gethandler('answer');
20 20
 
21 21
 $op = '';
22
-if (isset($_GET['op'])) $op = $_GET['op'];
23
-if (isset($_POST['op'])) $op = $_POST['op'];
22
+if (isset($_GET['op'])) {
23
+    $op = $_GET['op'];
24
+}
25
+if (isset($_POST['op'])) {
26
+    $op = $_POST['op'];
27
+}
24 28
 
25 29
 // Where shall we start?
26 30
 $startfaq = isset($_GET['startfaq'])? intval($_GET['startfaq']) : 0;
Please login to merge, or discard this patch.
smartfaq/admin/main.php 1 patch
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -182,13 +182,13 @@
 block discarded – undo
182 182
 }
183 183
 
184 184
 switch ($ordersel) {
185
-    case 'ASC':
186
-    $ordertxtasc = "selected='selected'";
187
-    break;
185
+        case 'ASC':
186
+        $ordertxtasc = "selected='selected'";
187
+        break;
188 188
 
189
-    default :
190
-    $ordertxtdesc = "selected='selected'";
191
-    break;
189
+        default :
190
+        $ordertxtdesc = "selected='selected'";
191
+        break;
192 192
 }
193 193
 
194 194
 switch ($statussel) {
Please login to merge, or discard this patch.