@@ -99,11 +99,10 @@ |
||
| 99 | 99 | * Constructor |
| 100 | 100 | * |
| 101 | 101 | * @param string $uploadDir |
| 102 | - * @param array $allowedMimeTypes |
|
| 102 | + * @param integer $allowedMimeTypes |
|
| 103 | 103 | * @param int $maxFileSize |
| 104 | 104 | * @param int $maxWidth |
| 105 | 105 | * @param int $maxHeight |
| 106 | - * @param int $cmodvalue |
|
| 107 | 106 | */ |
| 108 | 107 | function SmartUploader($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
| 109 | 108 | { |
@@ -29,27 +29,27 @@ discard block |
||
| 29 | 29 | // Project: The XOOPS Project // |
| 30 | 30 | // ------------------------------------------------------------------------- // |
| 31 | 31 | /** |
| 32 | - * ! |
|
| 33 | - * Example |
|
| 34 | - * |
|
| 35 | - * include_once 'uploader.php'; |
|
| 36 | - * $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); |
|
| 37 | - * $maxfilesize = 50000; |
|
| 38 | - * $maxfilewidth = 120; |
|
| 39 | - * $maxfileheight = 120; |
|
| 40 | - * $uploader = new SmartUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); |
|
| 41 | - * if ($uploader->fetchMedia($HTTP_POST_VARS['uploade_file_name'])) { |
|
| 42 | - * if (!$uploader->upload()) { |
|
| 43 | - * echo $uploader->getErrors(); |
|
| 44 | - * } else { |
|
| 45 | - * echo '<h4>File uploaded successfully!</h4>' |
|
| 46 | - * echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />'; |
|
| 47 | - * echo 'Full path: ' . $uploader->getSavedDestination(); |
|
| 48 | - * } |
|
| 49 | - * } else { |
|
| 50 | - * echo $uploader->getErrors(); |
|
| 51 | - * } |
|
| 52 | - */ |
|
| 32 | + * ! |
|
| 33 | + * Example |
|
| 34 | + * |
|
| 35 | + * include_once 'uploader.php'; |
|
| 36 | + * $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); |
|
| 37 | + * $maxfilesize = 50000; |
|
| 38 | + * $maxfilewidth = 120; |
|
| 39 | + * $maxfileheight = 120; |
|
| 40 | + * $uploader = new SmartUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); |
|
| 41 | + * if ($uploader->fetchMedia($HTTP_POST_VARS['uploade_file_name'])) { |
|
| 42 | + * if (!$uploader->upload()) { |
|
| 43 | + * echo $uploader->getErrors(); |
|
| 44 | + * } else { |
|
| 45 | + * echo '<h4>File uploaded successfully!</h4>' |
|
| 46 | + * echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />'; |
|
| 47 | + * echo 'Full path: ' . $uploader->getSavedDestination(); |
|
| 48 | + * } |
|
| 49 | + * } else { |
|
| 50 | + * echo $uploader->getErrors(); |
|
| 51 | + * } |
|
| 52 | + */ |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Upload Media files |
@@ -88,49 +88,49 @@ discard block |
||
| 88 | 88 | class SmartUploader extends XoopsMediaUploader |
| 89 | 89 | { |
| 90 | 90 | |
| 91 | - var $ext; |
|
| 92 | - var $dimension; |
|
| 91 | + var $ext; |
|
| 92 | + var $dimension; |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * No admin check for uploads |
|
| 96 | - */ |
|
| 97 | - var $noadmin_sizecheck; |
|
| 98 | - /** |
|
| 99 | - * Constructor |
|
| 100 | - * |
|
| 101 | - * @param string $uploadDir |
|
| 102 | - * @param array $allowedMimeTypes |
|
| 103 | - * @param int $maxFileSize |
|
| 104 | - * @param int $maxWidth |
|
| 105 | - * @param int $maxHeight |
|
| 106 | - * @param int $cmodvalue |
|
| 107 | - */ |
|
| 108 | - function SmartUploader($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
|
| 109 | - { |
|
| 110 | - $this->XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
| 111 | - } |
|
| 94 | + /** |
|
| 95 | + * No admin check for uploads |
|
| 96 | + */ |
|
| 97 | + var $noadmin_sizecheck; |
|
| 98 | + /** |
|
| 99 | + * Constructor |
|
| 100 | + * |
|
| 101 | + * @param string $uploadDir |
|
| 102 | + * @param array $allowedMimeTypes |
|
| 103 | + * @param int $maxFileSize |
|
| 104 | + * @param int $maxWidth |
|
| 105 | + * @param int $maxHeight |
|
| 106 | + * @param int $cmodvalue |
|
| 107 | + */ |
|
| 108 | + function SmartUploader($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
|
| 109 | + { |
|
| 110 | + $this->XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - function noAdminSizeCheck($value) |
|
| 114 | - { |
|
| 115 | - $this->noadmin_sizecheck = $value; |
|
| 116 | - } |
|
| 113 | + function noAdminSizeCheck($value) |
|
| 114 | + { |
|
| 115 | + $this->noadmin_sizecheck = $value; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Is the file the right size? |
|
| 120 | - * |
|
| 121 | - * @return bool |
|
| 122 | - */ |
|
| 123 | - function checkMaxFileSize() |
|
| 124 | - { |
|
| 125 | - if ($this->noadmin_sizecheck) |
|
| 126 | - { |
|
| 127 | - return true; |
|
| 128 | - } |
|
| 129 | - if ($this->mediaSize > $this->maxFileSize) |
|
| 130 | - { |
|
| 131 | - return false; |
|
| 132 | - } |
|
| 133 | - return true; |
|
| 134 | - } |
|
| 118 | + /** |
|
| 119 | + * Is the file the right size? |
|
| 120 | + * |
|
| 121 | + * @return bool |
|
| 122 | + */ |
|
| 123 | + function checkMaxFileSize() |
|
| 124 | + { |
|
| 125 | + if ($this->noadmin_sizecheck) |
|
| 126 | + { |
|
| 127 | + return true; |
|
| 128 | + } |
|
| 129 | + if ($this->mediaSize > $this->maxFileSize) |
|
| 130 | + { |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 133 | + return true; |
|
| 134 | + } |
|
| 135 | 135 | } |
| 136 | 136 | ?> |
| 137 | 137 | \ No newline at end of file |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | */ |
| 84 | 84 | mt_srand((double) microtime() * 1000000); |
| 85 | 85 | |
| 86 | -include_once XOOPS_ROOT_PATH."/class/uploader.php"; |
|
| 86 | +include_once XOOPS_ROOT_PATH . "/class/uploader.php"; |
|
| 87 | 87 | |
| 88 | 88 | class SmartUploader extends XoopsMediaUploader |
| 89 | 89 | { |
@@ -81,6 +81,12 @@ |
||
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Initializing the CAPTCHA class |
| 84 | + * @param boolean $skipmember |
|
| 85 | + * @param integer $num_chars |
|
| 86 | + * @param integer $fontsize_min |
|
| 87 | + * @param integer $fontsize_max |
|
| 88 | + * @param integer $background_type |
|
| 89 | + * @param integer $background_num |
|
| 84 | 90 | */ |
| 85 | 91 | function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null) |
| 86 | 92 | { |
@@ -12,205 +12,205 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | class XoopsCaptcha { |
| 15 | - var $active = true; |
|
| 16 | - var $mode = "text"; // potential values: image, text |
|
| 17 | - var $config = array(); |
|
| 18 | - |
|
| 19 | - var $message = array(); // Logging error messages |
|
| 20 | - |
|
| 21 | - function XoopsCaptcha() |
|
| 22 | - { |
|
| 23 | - // Loading default preferences |
|
| 24 | - $this->config = @include dirname(__FILE__)."/config.php"; |
|
| 25 | - |
|
| 26 | - $this->setMode($this->config["mode"]); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - function &instance() |
|
| 30 | - { |
|
| 31 | - static $instance; |
|
| 32 | - if(!isset($instance)) { |
|
| 33 | - $instance = new XoopsCaptcha(); |
|
| 34 | - } |
|
| 35 | - return $instance; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - function setConfig($name, $val) |
|
| 39 | - { |
|
| 40 | - if($name == "mode") { |
|
| 41 | - $this->setMode($val); |
|
| 42 | - }elseif(isset($this->$name)) { |
|
| 43 | - $this->$name = $val; |
|
| 44 | - }else { |
|
| 45 | - $this->config[$name] = $val; |
|
| 46 | - } |
|
| 47 | - return true; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Set CAPTCHA mode |
|
| 52 | - * |
|
| 53 | - * For future possible modes, right now force to use text or image |
|
| 54 | - * |
|
| 55 | - * @param string $mode if no mode is set, just verify current mode |
|
| 56 | - */ |
|
| 57 | - function setMode($mode = null) |
|
| 58 | - { |
|
| 59 | - if( !empty($mode) && in_array($mode, array("text", "image")) ) { |
|
| 60 | - $this->mode = $mode; |
|
| 61 | - |
|
| 62 | - if($this->mode != "image") { |
|
| 63 | - return; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // Disable image mode |
|
| 68 | - if(!extension_loaded('gd')) { |
|
| 69 | - $this->mode = "text"; |
|
| 70 | - }else{ |
|
| 71 | - $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
|
| 72 | - foreach($required_functions as $func) { |
|
| 73 | - if(!function_exists($func)) { |
|
| 74 | - $this->mode = "text"; |
|
| 75 | - break; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Initializing the CAPTCHA class |
|
| 84 | - */ |
|
| 85 | - function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null) |
|
| 86 | - { |
|
| 87 | - // Loading RUN-TIME settings |
|
| 88 | - foreach(array_keys($this->config) as $key) { |
|
| 89 | - if(isset(${$key}) && ${$key} !== null) { |
|
| 90 | - $this->config[$key] = ${$key}; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - $this->config["name"] = $name; |
|
| 94 | - |
|
| 95 | - // Skip CAPTCHA for member if set |
|
| 96 | - if($this->config["skipmember"] && is_object($GLOBALS["xoopsUser"])) { |
|
| 97 | - $this->active = false; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Verify user submission |
|
| 103 | - */ |
|
| 104 | - function verify($skipMember = null) |
|
| 105 | - { |
|
| 106 | - $sessionName = @$_SESSION['XoopsCaptcha_name']; |
|
| 107 | - $skipMember = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember; |
|
| 108 | - $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] ); |
|
| 109 | - |
|
| 110 | - $is_valid = false; |
|
| 111 | - |
|
| 112 | - // Skip CAPTCHA for member if set |
|
| 113 | - if( is_object($GLOBALS["xoopsUser"]) && !empty($skipMember) ) { |
|
| 114 | - $is_valid = true; |
|
| 115 | - // Kill too many attempts |
|
| 116 | - }elseif(!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) { |
|
| 117 | - $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 118 | - |
|
| 119 | - // Verify the code |
|
| 120 | - }elseif(!empty($_SESSION['XoopsCaptcha_sessioncode'])){ |
|
| 121 | - $func = ($this->config["casesensitive"]) ? "strcmp" : "strcasecmp"; |
|
| 122 | - $is_valid = ! $func( trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - if(!empty($maxAttempts)) { |
|
| 126 | - if(!$is_valid) { |
|
| 127 | - // Increase the attempt records on failure |
|
| 128 | - $_SESSION['XoopsCaptcha_attempt_'.$sessionName]++; |
|
| 129 | - // Log the error message |
|
| 130 | - $this->message[] = XOOPS_CAPTCHA_INVALID_CODE; |
|
| 131 | - |
|
| 132 | - }else{ |
|
| 133 | - |
|
| 134 | - // reset attempt records on success |
|
| 135 | - $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - $this->destroyGarbage(true); |
|
| 139 | - |
|
| 140 | - return $is_valid; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - function getCaption() |
|
| 144 | - { |
|
| 145 | - return defined("XOOPS_CAPTCHA_CAPTION") ? constant("XOOPS_CAPTCHA_CAPTION") : ""; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - function getMessage() |
|
| 149 | - { |
|
| 150 | - return implode("<br />", $this->message); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Destory historical stuff |
|
| 155 | - */ |
|
| 156 | - function destroyGarbage($clearSession = false) |
|
| 157 | - { |
|
| 158 | - require_once dirname(__FILE__)."/".$this->mode.".php"; |
|
| 159 | - $class = "XoopsCaptcha".ucfirst($this->mode); |
|
| 160 | - $captcha_handler = new $class(); |
|
| 161 | - if(method_exists($captcha_handler, "destroyGarbage")) { |
|
| 162 | - $captcha_handler->loadConfig($this->config); |
|
| 163 | - $captcha_handler->destroyGarbage(); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if($clearSession) { |
|
| 167 | - $_SESSION['XoopsCaptcha_name'] = null; |
|
| 168 | - $_SESSION['XoopsCaptcha_skipmember'] = null; |
|
| 169 | - $_SESSION['XoopsCaptcha_sessioncode'] = null; |
|
| 170 | - $_SESSION['XoopsCaptcha_maxattempts'] = null; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return true; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - function render() |
|
| 177 | - { |
|
| 178 | - $form = ""; |
|
| 179 | - |
|
| 180 | - if( !$this->active || empty($this->config["name"]) ) { |
|
| 181 | - return $form; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $_SESSION['XoopsCaptcha_name'] = $this->config["name"]; |
|
| 185 | - $_SESSION['XoopsCaptcha_skipmember'] = $this->config["skipmember"]; |
|
| 186 | - $maxAttempts = $this->config["maxattempt"]; |
|
| 187 | - $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts; |
|
| 188 | - /* |
|
| 15 | + var $active = true; |
|
| 16 | + var $mode = "text"; // potential values: image, text |
|
| 17 | + var $config = array(); |
|
| 18 | + |
|
| 19 | + var $message = array(); // Logging error messages |
|
| 20 | + |
|
| 21 | + function XoopsCaptcha() |
|
| 22 | + { |
|
| 23 | + // Loading default preferences |
|
| 24 | + $this->config = @include dirname(__FILE__)."/config.php"; |
|
| 25 | + |
|
| 26 | + $this->setMode($this->config["mode"]); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + function &instance() |
|
| 30 | + { |
|
| 31 | + static $instance; |
|
| 32 | + if(!isset($instance)) { |
|
| 33 | + $instance = new XoopsCaptcha(); |
|
| 34 | + } |
|
| 35 | + return $instance; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + function setConfig($name, $val) |
|
| 39 | + { |
|
| 40 | + if($name == "mode") { |
|
| 41 | + $this->setMode($val); |
|
| 42 | + }elseif(isset($this->$name)) { |
|
| 43 | + $this->$name = $val; |
|
| 44 | + }else { |
|
| 45 | + $this->config[$name] = $val; |
|
| 46 | + } |
|
| 47 | + return true; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Set CAPTCHA mode |
|
| 52 | + * |
|
| 53 | + * For future possible modes, right now force to use text or image |
|
| 54 | + * |
|
| 55 | + * @param string $mode if no mode is set, just verify current mode |
|
| 56 | + */ |
|
| 57 | + function setMode($mode = null) |
|
| 58 | + { |
|
| 59 | + if( !empty($mode) && in_array($mode, array("text", "image")) ) { |
|
| 60 | + $this->mode = $mode; |
|
| 61 | + |
|
| 62 | + if($this->mode != "image") { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // Disable image mode |
|
| 68 | + if(!extension_loaded('gd')) { |
|
| 69 | + $this->mode = "text"; |
|
| 70 | + }else{ |
|
| 71 | + $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
|
| 72 | + foreach($required_functions as $func) { |
|
| 73 | + if(!function_exists($func)) { |
|
| 74 | + $this->mode = "text"; |
|
| 75 | + break; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Initializing the CAPTCHA class |
|
| 84 | + */ |
|
| 85 | + function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null) |
|
| 86 | + { |
|
| 87 | + // Loading RUN-TIME settings |
|
| 88 | + foreach(array_keys($this->config) as $key) { |
|
| 89 | + if(isset(${$key}) && ${$key} !== null) { |
|
| 90 | + $this->config[$key] = ${$key}; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + $this->config["name"] = $name; |
|
| 94 | + |
|
| 95 | + // Skip CAPTCHA for member if set |
|
| 96 | + if($this->config["skipmember"] && is_object($GLOBALS["xoopsUser"])) { |
|
| 97 | + $this->active = false; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Verify user submission |
|
| 103 | + */ |
|
| 104 | + function verify($skipMember = null) |
|
| 105 | + { |
|
| 106 | + $sessionName = @$_SESSION['XoopsCaptcha_name']; |
|
| 107 | + $skipMember = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember; |
|
| 108 | + $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] ); |
|
| 109 | + |
|
| 110 | + $is_valid = false; |
|
| 111 | + |
|
| 112 | + // Skip CAPTCHA for member if set |
|
| 113 | + if( is_object($GLOBALS["xoopsUser"]) && !empty($skipMember) ) { |
|
| 114 | + $is_valid = true; |
|
| 115 | + // Kill too many attempts |
|
| 116 | + }elseif(!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) { |
|
| 117 | + $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 118 | + |
|
| 119 | + // Verify the code |
|
| 120 | + }elseif(!empty($_SESSION['XoopsCaptcha_sessioncode'])){ |
|
| 121 | + $func = ($this->config["casesensitive"]) ? "strcmp" : "strcasecmp"; |
|
| 122 | + $is_valid = ! $func( trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if(!empty($maxAttempts)) { |
|
| 126 | + if(!$is_valid) { |
|
| 127 | + // Increase the attempt records on failure |
|
| 128 | + $_SESSION['XoopsCaptcha_attempt_'.$sessionName]++; |
|
| 129 | + // Log the error message |
|
| 130 | + $this->message[] = XOOPS_CAPTCHA_INVALID_CODE; |
|
| 131 | + |
|
| 132 | + }else{ |
|
| 133 | + |
|
| 134 | + // reset attempt records on success |
|
| 135 | + $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + $this->destroyGarbage(true); |
|
| 139 | + |
|
| 140 | + return $is_valid; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + function getCaption() |
|
| 144 | + { |
|
| 145 | + return defined("XOOPS_CAPTCHA_CAPTION") ? constant("XOOPS_CAPTCHA_CAPTION") : ""; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + function getMessage() |
|
| 149 | + { |
|
| 150 | + return implode("<br />", $this->message); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Destory historical stuff |
|
| 155 | + */ |
|
| 156 | + function destroyGarbage($clearSession = false) |
|
| 157 | + { |
|
| 158 | + require_once dirname(__FILE__)."/".$this->mode.".php"; |
|
| 159 | + $class = "XoopsCaptcha".ucfirst($this->mode); |
|
| 160 | + $captcha_handler = new $class(); |
|
| 161 | + if(method_exists($captcha_handler, "destroyGarbage")) { |
|
| 162 | + $captcha_handler->loadConfig($this->config); |
|
| 163 | + $captcha_handler->destroyGarbage(); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if($clearSession) { |
|
| 167 | + $_SESSION['XoopsCaptcha_name'] = null; |
|
| 168 | + $_SESSION['XoopsCaptcha_skipmember'] = null; |
|
| 169 | + $_SESSION['XoopsCaptcha_sessioncode'] = null; |
|
| 170 | + $_SESSION['XoopsCaptcha_maxattempts'] = null; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return true; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + function render() |
|
| 177 | + { |
|
| 178 | + $form = ""; |
|
| 179 | + |
|
| 180 | + if( !$this->active || empty($this->config["name"]) ) { |
|
| 181 | + return $form; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $_SESSION['XoopsCaptcha_name'] = $this->config["name"]; |
|
| 185 | + $_SESSION['XoopsCaptcha_skipmember'] = $this->config["skipmember"]; |
|
| 186 | + $maxAttempts = $this->config["maxattempt"]; |
|
| 187 | + $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts; |
|
| 188 | + /* |
|
| 189 | 189 | if(!empty($maxAttempts)) { |
| 190 | 190 | $_SESSION['XoopsCaptcha_maxattempts_'.$_SESSION['XoopsCaptcha_name']] = $maxAttempts; |
| 191 | 191 | } |
| 192 | 192 | */ |
| 193 | 193 | |
| 194 | - // Fail on too many attempts |
|
| 195 | - if(!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config["name"]] > $maxAttempts) { |
|
| 196 | - $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 197 | - // Load the form element |
|
| 198 | - }else{ |
|
| 199 | - $form = $this->loadForm(); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return $form; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - function loadForm() |
|
| 206 | - { |
|
| 207 | - require_once dirname(__FILE__)."/".$this->mode.".php"; |
|
| 208 | - $class = "XoopsCaptcha".ucfirst($this->mode); |
|
| 209 | - $captcha_handler = new $class(); |
|
| 210 | - $captcha_handler->loadConfig($this->config); |
|
| 211 | - |
|
| 212 | - $form = $captcha_handler->render(); |
|
| 213 | - return $form; |
|
| 214 | - } |
|
| 194 | + // Fail on too many attempts |
|
| 195 | + if(!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config["name"]] > $maxAttempts) { |
|
| 196 | + $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 197 | + // Load the form element |
|
| 198 | + }else{ |
|
| 199 | + $form = $this->loadForm(); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return $form; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + function loadForm() |
|
| 206 | + { |
|
| 207 | + require_once dirname(__FILE__)."/".$this->mode.".php"; |
|
| 208 | + $class = "XoopsCaptcha".ucfirst($this->mode); |
|
| 209 | + $captcha_handler = new $class(); |
|
| 210 | + $captcha_handler->loadConfig($this->config); |
|
| 211 | + |
|
| 212 | + $form = $captcha_handler->render(); |
|
| 213 | + return $form; |
|
| 214 | + } |
|
| 215 | 215 | } |
| 216 | 216 | ?> |
| 217 | 217 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class XoopsCaptcha { |
| 15 | 15 | var $active = true; |
| 16 | - var $mode = "text"; // potential values: image, text |
|
| 16 | + var $mode = "text"; // potential values: image, text |
|
| 17 | 17 | var $config = array(); |
| 18 | 18 | |
| 19 | 19 | var $message = array(); // Logging error messages |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | function XoopsCaptcha() |
| 22 | 22 | { |
| 23 | 23 | // Loading default preferences |
| 24 | - $this->config = @include dirname(__FILE__)."/config.php"; |
|
| 24 | + $this->config = @include dirname(__FILE__) . "/config.php"; |
|
| 25 | 25 | |
| 26 | 26 | $this->setMode($this->config["mode"]); |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | function &instance() |
| 30 | 30 | { |
| 31 | 31 | static $instance; |
| 32 | - if(!isset($instance)) { |
|
| 32 | + if (!isset($instance)) { |
|
| 33 | 33 | $instance = new XoopsCaptcha(); |
| 34 | 34 | } |
| 35 | 35 | return $instance; |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | function setConfig($name, $val) |
| 39 | 39 | { |
| 40 | - if($name == "mode") { |
|
| 40 | + if ($name == "mode") { |
|
| 41 | 41 | $this->setMode($val); |
| 42 | - }elseif(isset($this->$name)) { |
|
| 42 | + }elseif (isset($this->$name)) { |
|
| 43 | 43 | $this->$name = $val; |
| 44 | - }else { |
|
| 44 | + } else { |
|
| 45 | 45 | $this->config[$name] = $val; |
| 46 | 46 | } |
| 47 | 47 | return true; |
@@ -56,21 +56,21 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function setMode($mode = null) |
| 58 | 58 | { |
| 59 | - if( !empty($mode) && in_array($mode, array("text", "image")) ) { |
|
| 59 | + if (!empty($mode) && in_array($mode, array("text", "image"))) { |
|
| 60 | 60 | $this->mode = $mode; |
| 61 | 61 | |
| 62 | - if($this->mode != "image") { |
|
| 62 | + if ($this->mode != "image") { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Disable image mode |
| 68 | - if(!extension_loaded('gd')) { |
|
| 68 | + if (!extension_loaded('gd')) { |
|
| 69 | 69 | $this->mode = "text"; |
| 70 | - }else{ |
|
| 70 | + } else { |
|
| 71 | 71 | $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
| 72 | - foreach($required_functions as $func) { |
|
| 73 | - if(!function_exists($func)) { |
|
| 72 | + foreach ($required_functions as $func) { |
|
| 73 | + if (!function_exists($func)) { |
|
| 74 | 74 | $this->mode = "text"; |
| 75 | 75 | break; |
| 76 | 76 | } |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null) |
| 86 | 86 | { |
| 87 | 87 | // Loading RUN-TIME settings |
| 88 | - foreach(array_keys($this->config) as $key) { |
|
| 89 | - if(isset(${$key}) && ${$key} !== null) { |
|
| 88 | + foreach (array_keys($this->config) as $key) { |
|
| 89 | + if (isset(${$key}) && ${$key} !== null) { |
|
| 90 | 90 | $this->config[$key] = ${$key}; |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | $this->config["name"] = $name; |
| 94 | 94 | |
| 95 | 95 | // Skip CAPTCHA for member if set |
| 96 | - if($this->config["skipmember"] && is_object($GLOBALS["xoopsUser"])) { |
|
| 96 | + if ($this->config["skipmember"] && is_object($GLOBALS["xoopsUser"])) { |
|
| 97 | 97 | $this->active = false; |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -105,34 +105,34 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $sessionName = @$_SESSION['XoopsCaptcha_name']; |
| 107 | 107 | $skipMember = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember; |
| 108 | - $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] ); |
|
| 108 | + $maxAttempts = intval(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 109 | 109 | |
| 110 | 110 | $is_valid = false; |
| 111 | 111 | |
| 112 | 112 | // Skip CAPTCHA for member if set |
| 113 | - if( is_object($GLOBALS["xoopsUser"]) && !empty($skipMember) ) { |
|
| 113 | + if (is_object($GLOBALS["xoopsUser"]) && !empty($skipMember)) { |
|
| 114 | 114 | $is_valid = true; |
| 115 | 115 | // Kill too many attempts |
| 116 | - }elseif(!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) { |
|
| 116 | + }elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) { |
|
| 117 | 117 | $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
| 118 | 118 | |
| 119 | 119 | // Verify the code |
| 120 | - }elseif(!empty($_SESSION['XoopsCaptcha_sessioncode'])){ |
|
| 120 | + }elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) { |
|
| 121 | 121 | $func = ($this->config["casesensitive"]) ? "strcmp" : "strcasecmp"; |
| 122 | - $is_valid = ! $func( trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
|
| 122 | + $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if(!empty($maxAttempts)) { |
|
| 126 | - if(!$is_valid) { |
|
| 125 | + if (!empty($maxAttempts)) { |
|
| 126 | + if (!$is_valid) { |
|
| 127 | 127 | // Increase the attempt records on failure |
| 128 | - $_SESSION['XoopsCaptcha_attempt_'.$sessionName]++; |
|
| 128 | + $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++; |
|
| 129 | 129 | // Log the error message |
| 130 | 130 | $this->message[] = XOOPS_CAPTCHA_INVALID_CODE; |
| 131 | 131 | |
| 132 | - }else{ |
|
| 132 | + } else { |
|
| 133 | 133 | |
| 134 | 134 | // reset attempt records on success |
| 135 | - $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null; |
|
| 135 | + $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | $this->destroyGarbage(true); |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | function destroyGarbage($clearSession = false) |
| 157 | 157 | { |
| 158 | - require_once dirname(__FILE__)."/".$this->mode.".php"; |
|
| 159 | - $class = "XoopsCaptcha".ucfirst($this->mode); |
|
| 158 | + require_once dirname(__FILE__) . "/" . $this->mode . ".php"; |
|
| 159 | + $class = "XoopsCaptcha" . ucfirst($this->mode); |
|
| 160 | 160 | $captcha_handler = new $class(); |
| 161 | - if(method_exists($captcha_handler, "destroyGarbage")) { |
|
| 161 | + if (method_exists($captcha_handler, "destroyGarbage")) { |
|
| 162 | 162 | $captcha_handler->loadConfig($this->config); |
| 163 | 163 | $captcha_handler->destroyGarbage(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if($clearSession) { |
|
| 166 | + if ($clearSession) { |
|
| 167 | 167 | $_SESSION['XoopsCaptcha_name'] = null; |
| 168 | 168 | $_SESSION['XoopsCaptcha_skipmember'] = null; |
| 169 | 169 | $_SESSION['XoopsCaptcha_sessioncode'] = null; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | { |
| 178 | 178 | $form = ""; |
| 179 | 179 | |
| 180 | - if( !$this->active || empty($this->config["name"]) ) { |
|
| 180 | + if (!$this->active || empty($this->config["name"])) { |
|
| 181 | 181 | return $form; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | |
| 194 | 194 | // Fail on too many attempts |
| 195 | - if(!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config["name"]] > $maxAttempts) { |
|
| 195 | + if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config["name"]] > $maxAttempts) { |
|
| 196 | 196 | $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
| 197 | 197 | // Load the form element |
| 198 | - }else{ |
|
| 198 | + } else { |
|
| 199 | 199 | $form = $this->loadForm(); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | function loadForm() |
| 206 | 206 | { |
| 207 | - require_once dirname(__FILE__)."/".$this->mode.".php"; |
|
| 208 | - $class = "XoopsCaptcha".ucfirst($this->mode); |
|
| 207 | + require_once dirname(__FILE__) . "/" . $this->mode . ".php"; |
|
| 208 | + $class = "XoopsCaptcha" . ucfirst($this->mode); |
|
| 209 | 209 | $captcha_handler = new $class(); |
| 210 | 210 | $captcha_handler->loadConfig($this->config); |
| 211 | 211 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | if($name == "mode") { |
| 41 | 41 | $this->setMode($val); |
| 42 | - }elseif(isset($this->$name)) { |
|
| 42 | + } elseif(isset($this->$name)) { |
|
| 43 | 43 | $this->$name = $val; |
| 44 | - }else { |
|
| 44 | + } else { |
|
| 45 | 45 | $this->config[$name] = $val; |
| 46 | 46 | } |
| 47 | 47 | return true; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | // Disable image mode |
| 68 | 68 | if(!extension_loaded('gd')) { |
| 69 | 69 | $this->mode = "text"; |
| 70 | - }else{ |
|
| 70 | + } else{ |
|
| 71 | 71 | $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
| 72 | 72 | foreach($required_functions as $func) { |
| 73 | 73 | if(!function_exists($func)) { |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | if( is_object($GLOBALS["xoopsUser"]) && !empty($skipMember) ) { |
| 114 | 114 | $is_valid = true; |
| 115 | 115 | // Kill too many attempts |
| 116 | - }elseif(!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) { |
|
| 116 | + } elseif(!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) { |
|
| 117 | 117 | $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
| 118 | 118 | |
| 119 | 119 | // Verify the code |
| 120 | - }elseif(!empty($_SESSION['XoopsCaptcha_sessioncode'])){ |
|
| 120 | + } elseif(!empty($_SESSION['XoopsCaptcha_sessioncode'])){ |
|
| 121 | 121 | $func = ($this->config["casesensitive"]) ? "strcmp" : "strcasecmp"; |
| 122 | 122 | $is_valid = ! $func( trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
| 123 | 123 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | // Log the error message |
| 130 | 130 | $this->message[] = XOOPS_CAPTCHA_INVALID_CODE; |
| 131 | 131 | |
| 132 | - }else{ |
|
| 132 | + } else{ |
|
| 133 | 133 | |
| 134 | 134 | // reset attempt records on success |
| 135 | 135 | $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | if(!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config["name"]] > $maxAttempts) { |
| 196 | 196 | $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
| 197 | 197 | // Load the form element |
| 198 | - }else{ |
|
| 198 | + } else{ |
|
| 199 | 199 | $form = $this->loadForm(); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -174,6 +174,9 @@ discard block |
||
| 174 | 174 | imagedestroy($this->oImage); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | + /** |
|
| 178 | + * @param string $name |
|
| 179 | + */ |
|
| 177 | 180 | function _getList($name, $extension = "") |
| 178 | 181 | { |
| 179 | 182 | $items = array(); |
@@ -235,7 +238,7 @@ discard block |
||
| 235 | 238 | /** |
| 236 | 239 | * Return random background |
| 237 | 240 | * |
| 238 | - * @return array |
|
| 241 | + * @return string|null |
|
| 239 | 242 | */ |
| 240 | 243 | function loadBackground() |
| 241 | 244 | { |
@@ -10,174 +10,174 @@ discard block |
||
| 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 | class XoopsCaptchaImageHandler { |
| 17 | - var $config = array(); |
|
| 18 | - //var $mode = "gd"; // GD or bmp |
|
| 19 | - var $code; |
|
| 20 | - var $invalid = false; |
|
| 21 | - |
|
| 22 | - var $font; |
|
| 23 | - var $spacing; |
|
| 24 | - var $width; |
|
| 25 | - var $height; |
|
| 26 | - |
|
| 27 | - function XoopsCaptchaImageHandler() |
|
| 28 | - { |
|
| 29 | - if(empty($_SESSION['XoopsCaptcha_name'])) { |
|
| 30 | - $this->invalid = true; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - if(!extension_loaded('gd')) { |
|
| 34 | - $this->mode = "bmp"; |
|
| 35 | - }else{ |
|
| 36 | - $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
|
| 37 | - foreach($required_functions as $func) { |
|
| 38 | - if(!function_exists($func)) { |
|
| 39 | - $this->mode = "bmp"; |
|
| 40 | - break; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Loading configs from CAPTCHA class |
|
| 48 | - */ |
|
| 49 | - function setConfig($config = array()) |
|
| 50 | - { |
|
| 51 | - // Loading default preferences |
|
| 52 | - $this->config =& $config; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - function loadImage() |
|
| 56 | - { |
|
| 57 | - $this->createCode(); |
|
| 58 | - $this->setCode(); |
|
| 59 | - $this->createImage(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Create Code |
|
| 64 | - */ |
|
| 65 | - function createCode() |
|
| 66 | - { |
|
| 67 | - if($this->invalid) { |
|
| 68 | - return; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if($this->mode == "bmp") { |
|
| 72 | - $this->config["num_chars"] = 4; |
|
| 73 | - $this->code = rand( pow(10, $this->config["num_chars"] - 1), intval( str_pad("9", $this->config["num_chars"], "9") ) ); |
|
| 74 | - }else{ |
|
| 75 | - $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"] ); |
|
| 76 | - if (!$this->config["casesensitive"]) { |
|
| 77 | - $this->code = strtoupper( $this->code ); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - function setCode() |
|
| 83 | - { |
|
| 84 | - if($this->invalid) { |
|
| 85 | - return; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $_SESSION['XoopsCaptcha_sessioncode'] = strval( $this->code ); |
|
| 89 | - $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] ); |
|
| 90 | - |
|
| 91 | - // Increase the attempt records on refresh |
|
| 92 | - if(!empty($maxAttempts)) { |
|
| 93 | - $_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']]++; |
|
| 94 | - if($_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 95 | - $this->invalid = true; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - function createImage($file = "") |
|
| 101 | - { |
|
| 102 | - if($this->invalid) { |
|
| 103 | - header("Content-type: image/gif"); |
|
| 104 | - readfile(XOOPS_ROOT_PATH."/images/subject/icon2.gif"); |
|
| 105 | - return; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if($this->mode == "bmp") { |
|
| 109 | - return $this->createImageBmp(); |
|
| 110 | - }else{ |
|
| 111 | - return $this->createImageGd(); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Create CAPTCHA iamge with GD |
|
| 117 | - * Originated from DuGris' SecurityImage |
|
| 118 | - */ |
|
| 119 | - // --------------------------------------------------------------------------- // |
|
| 120 | - // Class : SecurityImage 1.5 // |
|
| 121 | - // Author: DuGris aka L. Jen <http://www.dugris.info> // |
|
| 122 | - // Email : [email protected] // |
|
| 123 | - // Licence: GNU // |
|
| 124 | - // Project: The XOOPS Project // |
|
| 125 | - // --------------------------------------------------------------------------- // |
|
| 126 | - function createImageGd($file = "") |
|
| 127 | - { |
|
| 128 | - $this->loadFont(); |
|
| 129 | - $this->setImageSize(); |
|
| 130 | - |
|
| 131 | - $this->oImage = imagecreatetruecolor($this->width, $this->height); |
|
| 132 | - $background = imagecolorallocate($this->oImage, 255, 255, 255); |
|
| 133 | - imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background); |
|
| 134 | - |
|
| 135 | - switch ($this->config["background_type"]) { |
|
| 136 | - default: |
|
| 137 | - case 0: |
|
| 138 | - $this->drawBars(); |
|
| 139 | - break; |
|
| 140 | - |
|
| 141 | - case 1: |
|
| 142 | - $this->drawCircles(); |
|
| 143 | - break; |
|
| 144 | - |
|
| 145 | - case 2: |
|
| 146 | - $this->drawLines(); |
|
| 147 | - break; |
|
| 148 | - |
|
| 149 | - case 3: |
|
| 150 | - $this->drawRectangles(); |
|
| 151 | - break; |
|
| 152 | - |
|
| 153 | - case 4: |
|
| 154 | - $this->drawEllipses(); |
|
| 155 | - break; |
|
| 156 | - |
|
| 157 | - case 5: |
|
| 158 | - $this->drawPolygons(); |
|
| 159 | - break; |
|
| 160 | - |
|
| 161 | - case 100: |
|
| 162 | - $this->createFromFile(); |
|
| 163 | - break; |
|
| 164 | - } |
|
| 165 | - $this->drawBorder(); |
|
| 166 | - $this->drawCode(); |
|
| 167 | - |
|
| 168 | - if(empty($file)) { |
|
| 169 | - header("Content-type: image/jpeg"); |
|
| 170 | - imagejpeg ($this->oImage); |
|
| 171 | - }else{ |
|
| 172 | - imagejpeg ($this->oImage, XOOPS_ROOT_PATH. "/". $this->config["imagepath"]. "/". $file . ".jpg"); |
|
| 173 | - } |
|
| 174 | - imagedestroy($this->oImage); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - function _getList($name, $extension = "") |
|
| 178 | - { |
|
| 179 | - $items = array(); |
|
| 180 | - /* |
|
| 17 | + var $config = array(); |
|
| 18 | + //var $mode = "gd"; // GD or bmp |
|
| 19 | + var $code; |
|
| 20 | + var $invalid = false; |
|
| 21 | + |
|
| 22 | + var $font; |
|
| 23 | + var $spacing; |
|
| 24 | + var $width; |
|
| 25 | + var $height; |
|
| 26 | + |
|
| 27 | + function XoopsCaptchaImageHandler() |
|
| 28 | + { |
|
| 29 | + if(empty($_SESSION['XoopsCaptcha_name'])) { |
|
| 30 | + $this->invalid = true; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + if(!extension_loaded('gd')) { |
|
| 34 | + $this->mode = "bmp"; |
|
| 35 | + }else{ |
|
| 36 | + $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
|
| 37 | + foreach($required_functions as $func) { |
|
| 38 | + if(!function_exists($func)) { |
|
| 39 | + $this->mode = "bmp"; |
|
| 40 | + break; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Loading configs from CAPTCHA class |
|
| 48 | + */ |
|
| 49 | + function setConfig($config = array()) |
|
| 50 | + { |
|
| 51 | + // Loading default preferences |
|
| 52 | + $this->config =& $config; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + function loadImage() |
|
| 56 | + { |
|
| 57 | + $this->createCode(); |
|
| 58 | + $this->setCode(); |
|
| 59 | + $this->createImage(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Create Code |
|
| 64 | + */ |
|
| 65 | + function createCode() |
|
| 66 | + { |
|
| 67 | + if($this->invalid) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if($this->mode == "bmp") { |
|
| 72 | + $this->config["num_chars"] = 4; |
|
| 73 | + $this->code = rand( pow(10, $this->config["num_chars"] - 1), intval( str_pad("9", $this->config["num_chars"], "9") ) ); |
|
| 74 | + }else{ |
|
| 75 | + $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"] ); |
|
| 76 | + if (!$this->config["casesensitive"]) { |
|
| 77 | + $this->code = strtoupper( $this->code ); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + function setCode() |
|
| 83 | + { |
|
| 84 | + if($this->invalid) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $_SESSION['XoopsCaptcha_sessioncode'] = strval( $this->code ); |
|
| 89 | + $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] ); |
|
| 90 | + |
|
| 91 | + // Increase the attempt records on refresh |
|
| 92 | + if(!empty($maxAttempts)) { |
|
| 93 | + $_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']]++; |
|
| 94 | + if($_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 95 | + $this->invalid = true; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + function createImage($file = "") |
|
| 101 | + { |
|
| 102 | + if($this->invalid) { |
|
| 103 | + header("Content-type: image/gif"); |
|
| 104 | + readfile(XOOPS_ROOT_PATH."/images/subject/icon2.gif"); |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if($this->mode == "bmp") { |
|
| 109 | + return $this->createImageBmp(); |
|
| 110 | + }else{ |
|
| 111 | + return $this->createImageGd(); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Create CAPTCHA iamge with GD |
|
| 117 | + * Originated from DuGris' SecurityImage |
|
| 118 | + */ |
|
| 119 | + // --------------------------------------------------------------------------- // |
|
| 120 | + // Class : SecurityImage 1.5 // |
|
| 121 | + // Author: DuGris aka L. Jen <http://www.dugris.info> // |
|
| 122 | + // Email : [email protected] // |
|
| 123 | + // Licence: GNU // |
|
| 124 | + // Project: The XOOPS Project // |
|
| 125 | + // --------------------------------------------------------------------------- // |
|
| 126 | + function createImageGd($file = "") |
|
| 127 | + { |
|
| 128 | + $this->loadFont(); |
|
| 129 | + $this->setImageSize(); |
|
| 130 | + |
|
| 131 | + $this->oImage = imagecreatetruecolor($this->width, $this->height); |
|
| 132 | + $background = imagecolorallocate($this->oImage, 255, 255, 255); |
|
| 133 | + imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background); |
|
| 134 | + |
|
| 135 | + switch ($this->config["background_type"]) { |
|
| 136 | + default: |
|
| 137 | + case 0: |
|
| 138 | + $this->drawBars(); |
|
| 139 | + break; |
|
| 140 | + |
|
| 141 | + case 1: |
|
| 142 | + $this->drawCircles(); |
|
| 143 | + break; |
|
| 144 | + |
|
| 145 | + case 2: |
|
| 146 | + $this->drawLines(); |
|
| 147 | + break; |
|
| 148 | + |
|
| 149 | + case 3: |
|
| 150 | + $this->drawRectangles(); |
|
| 151 | + break; |
|
| 152 | + |
|
| 153 | + case 4: |
|
| 154 | + $this->drawEllipses(); |
|
| 155 | + break; |
|
| 156 | + |
|
| 157 | + case 5: |
|
| 158 | + $this->drawPolygons(); |
|
| 159 | + break; |
|
| 160 | + |
|
| 161 | + case 100: |
|
| 162 | + $this->createFromFile(); |
|
| 163 | + break; |
|
| 164 | + } |
|
| 165 | + $this->drawBorder(); |
|
| 166 | + $this->drawCode(); |
|
| 167 | + |
|
| 168 | + if(empty($file)) { |
|
| 169 | + header("Content-type: image/jpeg"); |
|
| 170 | + imagejpeg ($this->oImage); |
|
| 171 | + }else{ |
|
| 172 | + imagejpeg ($this->oImage, XOOPS_ROOT_PATH. "/". $this->config["imagepath"]. "/". $file . ".jpg"); |
|
| 173 | + } |
|
| 174 | + imagedestroy($this->oImage); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + function _getList($name, $extension = "") |
|
| 178 | + { |
|
| 179 | + $items = array(); |
|
| 180 | + /* |
|
| 181 | 181 | if(@ include_once XOOPS_ROOT_PATH."/Frameworks/art/functions.ini.php") { |
| 182 | 182 | load_functions("cache"); |
| 183 | 183 | if($items = mod_loadCacheFile("captcha_{$name}", "captcha")) { |
@@ -185,227 +185,227 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | */ |
| 188 | - require_once XOOPS_ROOT_PATH."/class/xoopslists.php"; |
|
| 189 | - $file_path = $this->config["rootpath"]."/{$name}"; |
|
| 190 | - $files = XoopsLists::getFileListAsArray($file_path); |
|
| 191 | - foreach( $files as $item) { |
|
| 192 | - if ( empty($extension) || preg_match("/(\.{$extension})$/i",$item) ) { |
|
| 193 | - $items[] = $item; |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - if(function_exists("mod_createCacheFile")) { |
|
| 197 | - mod_createCacheFile($items, "captcha_{$name}", "captcha"); |
|
| 198 | - } |
|
| 199 | - return $items; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - function loadFont() |
|
| 203 | - { |
|
| 204 | - $fonts = $this->_getList("fonts", "ttf"); |
|
| 205 | - $this->font = $this->config["rootpath"]."/fonts/".$fonts[array_rand($fonts)]; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - function setImageSize() |
|
| 209 | - { |
|
| 210 | - $MaxCharWidth = 0; |
|
| 211 | - $MaxCharHeight = 0; |
|
| 212 | - $oImage = imagecreatetruecolor(100, 100); |
|
| 213 | - $text_color = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 214 | - $FontSize = $this->config["fontsize_max"]; |
|
| 215 | - for ($Angle = -30; $Angle <= 30; $Angle++) { |
|
| 216 | - for ($i = 65; $i <= 90; $i++) { |
|
| 217 | - $CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array()); |
|
| 218 | - $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]); |
|
| 219 | - if ($_MaxCharWidth > $MaxCharWidth ) { |
|
| 220 | - $MaxCharWidth = $_MaxCharWidth; |
|
| 221 | - } |
|
| 222 | - $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 223 | - if ($_MaxCharHeight > $MaxCharHeight ) { |
|
| 224 | - $MaxCharHeight = $_MaxCharHeight; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - imagedestroy($oImage); |
|
| 229 | - |
|
| 230 | - $this->height = $MaxCharHeight + 2; |
|
| 231 | - $this->spacing = (int)( ($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"]); |
|
| 232 | - $this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing/2); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Return random background |
|
| 237 | - * |
|
| 238 | - * @return array |
|
| 239 | - */ |
|
| 240 | - function loadBackground() |
|
| 241 | - { |
|
| 242 | - $RandBackground = null; |
|
| 243 | - if( $backgrounds = $this->_getList("backgrounds", "(gif|jpg|png)") ) { |
|
| 244 | - $RandBackground = $this->config["rootpath"]."/backgrounds/".$backgrounds[array_rand($backgrounds)]; |
|
| 245 | - } |
|
| 246 | - return $RandBackground; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Draw Image background |
|
| 251 | - */ |
|
| 252 | - function createFromFile() |
|
| 253 | - { |
|
| 254 | - if ( $RandImage = $this->loadBackground() ) { |
|
| 255 | - $ImageType = @getimagesize($RandImage); |
|
| 256 | - switch ( @$ImageType[2] ) { |
|
| 257 | - case 1: |
|
| 258 | - $BackgroundImage = imagecreatefromgif($RandImage); |
|
| 259 | - break; |
|
| 260 | - |
|
| 261 | - case 2: |
|
| 262 | - $BackgroundImage = imagecreatefromjpeg($RandImage); |
|
| 263 | - break; |
|
| 264 | - |
|
| 265 | - case 3: |
|
| 266 | - $BackgroundImage = imagecreatefrompng($RandImage); |
|
| 267 | - break; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - if(!empty($BackgroundImage)){ |
|
| 271 | - imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage)); |
|
| 272 | - imagedestroy($BackgroundImage); |
|
| 273 | - } else { |
|
| 274 | - $this->drawBars(); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Draw Code |
|
| 280 | - */ |
|
| 281 | - function drawCode() |
|
| 282 | - { |
|
| 283 | - for ($i = 0; $i < $this->config["num_chars"] ; $i++) { |
|
| 284 | - // select random greyscale colour |
|
| 285 | - $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 286 | - |
|
| 287 | - // write text to image |
|
| 288 | - $Angle = mt_rand(10, 30); |
|
| 289 | - if (($i % 2)) { |
|
| 290 | - $Angle = mt_rand(-10, -30); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - // select random font size |
|
| 294 | - $FontSize = mt_rand($this->config["fontsize_min"], $this->config["fontsize_max"]); |
|
| 295 | - |
|
| 296 | - $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array()); |
|
| 297 | - $CharHeight = abs( $CharDetails[1] + $CharDetails[5] ); |
|
| 298 | - |
|
| 299 | - // calculate character starting coordinates |
|
| 300 | - $posX = ($this->spacing/2) + ($i * $this->spacing); |
|
| 301 | - $posY = 2 + ($this->height / 2) + ($CharHeight / 4); |
|
| 302 | - |
|
| 303 | - imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array()); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * Draw Border |
|
| 309 | - */ |
|
| 310 | - function drawBorder() |
|
| 311 | - { |
|
| 312 | - $rgb = rand(50, 150); |
|
| 313 | - $border_color = imagecolorallocate ($this->oImage, $rgb, $rgb, $rgb); |
|
| 314 | - imagerectangle($this->oImage, 0, 0, $this->width-1, $this->height-1, $border_color); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * Draw Circles background |
|
| 319 | - */ |
|
| 320 | - function drawCircles() |
|
| 321 | - { |
|
| 322 | - for($i = 1; $i <= $this->config["background_num"]; $i++){ |
|
| 323 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 324 | - imagefilledellipse($this->oImage, mt_rand(0,$this->width-10), mt_rand(0,$this->height-3), mt_rand(10,20), mt_rand(20,30),$randomcolor); |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Draw Lines background |
|
| 330 | - */ |
|
| 331 | - function drawLines() |
|
| 332 | - { |
|
| 333 | - for ($i = 0; $i < $this->config["background_num"]; $i++) { |
|
| 334 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 335 | - imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Draw Rectangles background |
|
| 341 | - */ |
|
| 342 | - function drawRectangles() |
|
| 343 | - { |
|
| 344 | - for ($i = 1; $i <= $this->config["background_num"]; $i++) { |
|
| 345 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 346 | - imagefilledrectangle($this->oImage, mt_rand(0,$this->width), mt_rand(0,$this->height), mt_rand(0, $this->width), mt_rand(0,$this->height), $randomcolor); |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Draw Bars background |
|
| 352 | - */ |
|
| 353 | - function drawBars() |
|
| 354 | - { |
|
| 355 | - for ($i= 0 ; $i <= $this->height;) { |
|
| 356 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 357 | - imageline( $this->oImage, 0, $i, $this->width, $i, $randomcolor ); |
|
| 358 | - $i = $i + 2.5; |
|
| 359 | - } |
|
| 360 | - for ($i = 0;$i <= $this->width;) { |
|
| 361 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 362 | - imageline( $this->oImage, $i, 0, $i, $this->height, $randomcolor ); |
|
| 363 | - $i = $i + 2.5; |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Draw Ellipses background |
|
| 369 | - */ |
|
| 370 | - function drawEllipses() |
|
| 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 | - imageellipse($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 polygons background |
|
| 380 | - */ |
|
| 381 | - function drawPolygons() |
|
| 382 | - { |
|
| 383 | - for($i = 1; $i <= $this->config["background_num"]; $i++){ |
|
| 384 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 385 | - $coords = array(); |
|
| 386 | - for ($j=1; $j <= $this->config["polygon_point"]; $j++) { |
|
| 387 | - $coords[] = mt_rand(0,$this->width); |
|
| 388 | - $coords[] = mt_rand(0,$this->height); |
|
| 389 | - } |
|
| 390 | - imagefilledpolygon($this->oImage, $coords, $this->config["polygon_point"], $randomcolor); |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Create CAPTCHA iamge with BMP |
|
| 396 | - * TODO |
|
| 397 | - */ |
|
| 398 | - function createImageBmp($file = "") |
|
| 399 | - { |
|
| 400 | - $image = ""; |
|
| 401 | - |
|
| 402 | - if(empty($file)) { |
|
| 403 | - header("Content-type: image/bmp"); |
|
| 404 | - echo $image; |
|
| 405 | - }else{ |
|
| 406 | - return $image; |
|
| 407 | - } |
|
| 408 | - } |
|
| 188 | + require_once XOOPS_ROOT_PATH."/class/xoopslists.php"; |
|
| 189 | + $file_path = $this->config["rootpath"]."/{$name}"; |
|
| 190 | + $files = XoopsLists::getFileListAsArray($file_path); |
|
| 191 | + foreach( $files as $item) { |
|
| 192 | + if ( empty($extension) || preg_match("/(\.{$extension})$/i",$item) ) { |
|
| 193 | + $items[] = $item; |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + if(function_exists("mod_createCacheFile")) { |
|
| 197 | + mod_createCacheFile($items, "captcha_{$name}", "captcha"); |
|
| 198 | + } |
|
| 199 | + return $items; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + function loadFont() |
|
| 203 | + { |
|
| 204 | + $fonts = $this->_getList("fonts", "ttf"); |
|
| 205 | + $this->font = $this->config["rootpath"]."/fonts/".$fonts[array_rand($fonts)]; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + function setImageSize() |
|
| 209 | + { |
|
| 210 | + $MaxCharWidth = 0; |
|
| 211 | + $MaxCharHeight = 0; |
|
| 212 | + $oImage = imagecreatetruecolor(100, 100); |
|
| 213 | + $text_color = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 214 | + $FontSize = $this->config["fontsize_max"]; |
|
| 215 | + for ($Angle = -30; $Angle <= 30; $Angle++) { |
|
| 216 | + for ($i = 65; $i <= 90; $i++) { |
|
| 217 | + $CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array()); |
|
| 218 | + $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]); |
|
| 219 | + if ($_MaxCharWidth > $MaxCharWidth ) { |
|
| 220 | + $MaxCharWidth = $_MaxCharWidth; |
|
| 221 | + } |
|
| 222 | + $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 223 | + if ($_MaxCharHeight > $MaxCharHeight ) { |
|
| 224 | + $MaxCharHeight = $_MaxCharHeight; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + imagedestroy($oImage); |
|
| 229 | + |
|
| 230 | + $this->height = $MaxCharHeight + 2; |
|
| 231 | + $this->spacing = (int)( ($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"]); |
|
| 232 | + $this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing/2); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Return random background |
|
| 237 | + * |
|
| 238 | + * @return array |
|
| 239 | + */ |
|
| 240 | + function loadBackground() |
|
| 241 | + { |
|
| 242 | + $RandBackground = null; |
|
| 243 | + if( $backgrounds = $this->_getList("backgrounds", "(gif|jpg|png)") ) { |
|
| 244 | + $RandBackground = $this->config["rootpath"]."/backgrounds/".$backgrounds[array_rand($backgrounds)]; |
|
| 245 | + } |
|
| 246 | + return $RandBackground; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Draw Image background |
|
| 251 | + */ |
|
| 252 | + function createFromFile() |
|
| 253 | + { |
|
| 254 | + if ( $RandImage = $this->loadBackground() ) { |
|
| 255 | + $ImageType = @getimagesize($RandImage); |
|
| 256 | + switch ( @$ImageType[2] ) { |
|
| 257 | + case 1: |
|
| 258 | + $BackgroundImage = imagecreatefromgif($RandImage); |
|
| 259 | + break; |
|
| 260 | + |
|
| 261 | + case 2: |
|
| 262 | + $BackgroundImage = imagecreatefromjpeg($RandImage); |
|
| 263 | + break; |
|
| 264 | + |
|
| 265 | + case 3: |
|
| 266 | + $BackgroundImage = imagecreatefrompng($RandImage); |
|
| 267 | + break; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + if(!empty($BackgroundImage)){ |
|
| 271 | + imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage)); |
|
| 272 | + imagedestroy($BackgroundImage); |
|
| 273 | + } else { |
|
| 274 | + $this->drawBars(); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Draw Code |
|
| 280 | + */ |
|
| 281 | + function drawCode() |
|
| 282 | + { |
|
| 283 | + for ($i = 0; $i < $this->config["num_chars"] ; $i++) { |
|
| 284 | + // select random greyscale colour |
|
| 285 | + $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 286 | + |
|
| 287 | + // write text to image |
|
| 288 | + $Angle = mt_rand(10, 30); |
|
| 289 | + if (($i % 2)) { |
|
| 290 | + $Angle = mt_rand(-10, -30); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + // select random font size |
|
| 294 | + $FontSize = mt_rand($this->config["fontsize_min"], $this->config["fontsize_max"]); |
|
| 295 | + |
|
| 296 | + $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array()); |
|
| 297 | + $CharHeight = abs( $CharDetails[1] + $CharDetails[5] ); |
|
| 298 | + |
|
| 299 | + // calculate character starting coordinates |
|
| 300 | + $posX = ($this->spacing/2) + ($i * $this->spacing); |
|
| 301 | + $posY = 2 + ($this->height / 2) + ($CharHeight / 4); |
|
| 302 | + |
|
| 303 | + imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array()); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * Draw Border |
|
| 309 | + */ |
|
| 310 | + function drawBorder() |
|
| 311 | + { |
|
| 312 | + $rgb = rand(50, 150); |
|
| 313 | + $border_color = imagecolorallocate ($this->oImage, $rgb, $rgb, $rgb); |
|
| 314 | + imagerectangle($this->oImage, 0, 0, $this->width-1, $this->height-1, $border_color); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * Draw Circles background |
|
| 319 | + */ |
|
| 320 | + function drawCircles() |
|
| 321 | + { |
|
| 322 | + for($i = 1; $i <= $this->config["background_num"]; $i++){ |
|
| 323 | + $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 324 | + imagefilledellipse($this->oImage, mt_rand(0,$this->width-10), mt_rand(0,$this->height-3), mt_rand(10,20), mt_rand(20,30),$randomcolor); |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Draw Lines background |
|
| 330 | + */ |
|
| 331 | + function drawLines() |
|
| 332 | + { |
|
| 333 | + for ($i = 0; $i < $this->config["background_num"]; $i++) { |
|
| 334 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 335 | + imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * Draw Rectangles background |
|
| 341 | + */ |
|
| 342 | + function drawRectangles() |
|
| 343 | + { |
|
| 344 | + for ($i = 1; $i <= $this->config["background_num"]; $i++) { |
|
| 345 | + $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 346 | + imagefilledrectangle($this->oImage, mt_rand(0,$this->width), mt_rand(0,$this->height), mt_rand(0, $this->width), mt_rand(0,$this->height), $randomcolor); |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Draw Bars background |
|
| 352 | + */ |
|
| 353 | + function drawBars() |
|
| 354 | + { |
|
| 355 | + for ($i= 0 ; $i <= $this->height;) { |
|
| 356 | + $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 357 | + imageline( $this->oImage, 0, $i, $this->width, $i, $randomcolor ); |
|
| 358 | + $i = $i + 2.5; |
|
| 359 | + } |
|
| 360 | + for ($i = 0;$i <= $this->width;) { |
|
| 361 | + $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 362 | + imageline( $this->oImage, $i, 0, $i, $this->height, $randomcolor ); |
|
| 363 | + $i = $i + 2.5; |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Draw Ellipses background |
|
| 369 | + */ |
|
| 370 | + function drawEllipses() |
|
| 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 | + imageellipse($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 polygons background |
|
| 380 | + */ |
|
| 381 | + function drawPolygons() |
|
| 382 | + { |
|
| 383 | + for($i = 1; $i <= $this->config["background_num"]; $i++){ |
|
| 384 | + $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 385 | + $coords = array(); |
|
| 386 | + for ($j=1; $j <= $this->config["polygon_point"]; $j++) { |
|
| 387 | + $coords[] = mt_rand(0,$this->width); |
|
| 388 | + $coords[] = mt_rand(0,$this->height); |
|
| 389 | + } |
|
| 390 | + imagefilledpolygon($this->oImage, $coords, $this->config["polygon_point"], $randomcolor); |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Create CAPTCHA iamge with BMP |
|
| 396 | + * TODO |
|
| 397 | + */ |
|
| 398 | + function createImageBmp($file = "") |
|
| 399 | + { |
|
| 400 | + $image = ""; |
|
| 401 | + |
|
| 402 | + if(empty($file)) { |
|
| 403 | + header("Content-type: image/bmp"); |
|
| 404 | + echo $image; |
|
| 405 | + }else{ |
|
| 406 | + return $image; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $config = @include "../config.php"; |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | error_reporting(0); |
| 10 | 10 | $xoopsLogger->activated = false; |
| 11 | 11 | |
| 12 | -if(empty($_SERVER['HTTP_REFERER']) || !preg_match("/^".preg_quote(XOOPS_URL, '/')."/", $_SERVER['HTTP_REFERER'])) { |
|
| 12 | +if (empty($_SERVER['HTTP_REFERER']) || !preg_match("/^" . preg_quote(XOOPS_URL, '/') . "/", $_SERVER['HTTP_REFERER'])) { |
|
| 13 | 13 | exit(); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | class XoopsCaptchaImageHandler { |
| 17 | - var $config = array(); |
|
| 17 | + var $config = array(); |
|
| 18 | 18 | //var $mode = "gd"; // GD or bmp |
| 19 | 19 | var $code; |
| 20 | 20 | var $invalid = false; |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | function XoopsCaptchaImageHandler() |
| 28 | 28 | { |
| 29 | - if(empty($_SESSION['XoopsCaptcha_name'])) { |
|
| 29 | + if (empty($_SESSION['XoopsCaptcha_name'])) { |
|
| 30 | 30 | $this->invalid = true; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if(!extension_loaded('gd')) { |
|
| 33 | + if (!extension_loaded('gd')) { |
|
| 34 | 34 | $this->mode = "bmp"; |
| 35 | - }else{ |
|
| 35 | + } else { |
|
| 36 | 36 | $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
| 37 | - foreach($required_functions as $func) { |
|
| 38 | - if(!function_exists($func)) { |
|
| 37 | + foreach ($required_functions as $func) { |
|
| 38 | + if (!function_exists($func)) { |
|
| 39 | 39 | $this->mode = "bmp"; |
| 40 | 40 | break; |
| 41 | 41 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | function setConfig($config = array()) |
| 50 | 50 | { |
| 51 | 51 | // Loading default preferences |
| 52 | - $this->config =& $config; |
|
| 52 | + $this->config = & $config; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | function loadImage() |
@@ -64,34 +64,34 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function createCode() |
| 66 | 66 | { |
| 67 | - if($this->invalid) { |
|
| 67 | + if ($this->invalid) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if($this->mode == "bmp") { |
|
| 71 | + if ($this->mode == "bmp") { |
|
| 72 | 72 | $this->config["num_chars"] = 4; |
| 73 | - $this->code = rand( pow(10, $this->config["num_chars"] - 1), intval( str_pad("9", $this->config["num_chars"], "9") ) ); |
|
| 74 | - }else{ |
|
| 75 | - $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"] ); |
|
| 73 | + $this->code = rand(pow(10, $this->config["num_chars"] - 1), intval(str_pad("9", $this->config["num_chars"], "9"))); |
|
| 74 | + } else { |
|
| 75 | + $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"]); |
|
| 76 | 76 | if (!$this->config["casesensitive"]) { |
| 77 | - $this->code = strtoupper( $this->code ); |
|
| 77 | + $this->code = strtoupper($this->code); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | function setCode() |
| 83 | 83 | { |
| 84 | - if($this->invalid) { |
|
| 84 | + if ($this->invalid) { |
|
| 85 | 85 | return; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $_SESSION['XoopsCaptcha_sessioncode'] = strval( $this->code ); |
|
| 89 | - $maxAttempts = intval( @$_SESSION['XoopsCaptcha_maxattempts'] ); |
|
| 88 | + $_SESSION['XoopsCaptcha_sessioncode'] = strval($this->code); |
|
| 89 | + $maxAttempts = intval(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 90 | 90 | |
| 91 | 91 | // Increase the attempt records on refresh |
| 92 | - if(!empty($maxAttempts)) { |
|
| 93 | - $_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']]++; |
|
| 94 | - if($_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 92 | + if (!empty($maxAttempts)) { |
|
| 93 | + $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++; |
|
| 94 | + if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 95 | 95 | $this->invalid = true; |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | function createImage($file = "") |
| 101 | 101 | { |
| 102 | - if($this->invalid) { |
|
| 102 | + if ($this->invalid) { |
|
| 103 | 103 | header("Content-type: image/gif"); |
| 104 | - readfile(XOOPS_ROOT_PATH."/images/subject/icon2.gif"); |
|
| 104 | + readfile(XOOPS_ROOT_PATH . "/images/subject/icon2.gif"); |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if($this->mode == "bmp") { |
|
| 108 | + if ($this->mode == "bmp") { |
|
| 109 | 109 | return $this->createImageBmp(); |
| 110 | - }else{ |
|
| 110 | + } else { |
|
| 111 | 111 | return $this->createImageGd(); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | $this->drawBorder(); |
| 166 | 166 | $this->drawCode(); |
| 167 | 167 | |
| 168 | - if(empty($file)) { |
|
| 168 | + if (empty($file)) { |
|
| 169 | 169 | header("Content-type: image/jpeg"); |
| 170 | - imagejpeg ($this->oImage); |
|
| 171 | - }else{ |
|
| 172 | - imagejpeg ($this->oImage, XOOPS_ROOT_PATH. "/". $this->config["imagepath"]. "/". $file . ".jpg"); |
|
| 170 | + imagejpeg($this->oImage); |
|
| 171 | + } else { |
|
| 172 | + imagejpeg($this->oImage, XOOPS_ROOT_PATH . "/" . $this->config["imagepath"] . "/" . $file . ".jpg"); |
|
| 173 | 173 | } |
| 174 | 174 | imagedestroy($this->oImage); |
| 175 | 175 | } |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | */ |
| 188 | - require_once XOOPS_ROOT_PATH."/class/xoopslists.php"; |
|
| 189 | - $file_path = $this->config["rootpath"]."/{$name}"; |
|
| 188 | + require_once XOOPS_ROOT_PATH . "/class/xoopslists.php"; |
|
| 189 | + $file_path = $this->config["rootpath"] . "/{$name}"; |
|
| 190 | 190 | $files = XoopsLists::getFileListAsArray($file_path); |
| 191 | - foreach( $files as $item) { |
|
| 192 | - if ( empty($extension) || preg_match("/(\.{$extension})$/i",$item) ) { |
|
| 191 | + foreach ($files as $item) { |
|
| 192 | + if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) { |
|
| 193 | 193 | $items[] = $item; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | - if(function_exists("mod_createCacheFile")) { |
|
| 196 | + if (function_exists("mod_createCacheFile")) { |
|
| 197 | 197 | mod_createCacheFile($items, "captcha_{$name}", "captcha"); |
| 198 | 198 | } |
| 199 | 199 | return $items; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | function loadFont() |
| 203 | 203 | { |
| 204 | 204 | $fonts = $this->_getList("fonts", "ttf"); |
| 205 | - $this->font = $this->config["rootpath"]."/fonts/".$fonts[array_rand($fonts)]; |
|
| 205 | + $this->font = $this->config["rootpath"] . "/fonts/" . $fonts[array_rand($fonts)]; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | function setImageSize() |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | for ($Angle = -30; $Angle <= 30; $Angle++) { |
| 216 | 216 | for ($i = 65; $i <= 90; $i++) { |
| 217 | 217 | $CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array()); |
| 218 | - $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]); |
|
| 219 | - if ($_MaxCharWidth > $MaxCharWidth ) { |
|
| 218 | + $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]); |
|
| 219 | + if ($_MaxCharWidth > $MaxCharWidth) { |
|
| 220 | 220 | $MaxCharWidth = $_MaxCharWidth; |
| 221 | 221 | } |
| 222 | - $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 223 | - if ($_MaxCharHeight > $MaxCharHeight ) { |
|
| 222 | + $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 223 | + if ($_MaxCharHeight > $MaxCharHeight) { |
|
| 224 | 224 | $MaxCharHeight = $_MaxCharHeight; |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | imagedestroy($oImage); |
| 229 | 229 | |
| 230 | 230 | $this->height = $MaxCharHeight + 2; |
| 231 | - $this->spacing = (int)( ($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"]); |
|
| 232 | - $this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing/2); |
|
| 231 | + $this->spacing = (int) (($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"]); |
|
| 232 | + $this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing / 2); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | function loadBackground() |
| 241 | 241 | { |
| 242 | 242 | $RandBackground = null; |
| 243 | - if( $backgrounds = $this->_getList("backgrounds", "(gif|jpg|png)") ) { |
|
| 244 | - $RandBackground = $this->config["rootpath"]."/backgrounds/".$backgrounds[array_rand($backgrounds)]; |
|
| 243 | + if ($backgrounds = $this->_getList("backgrounds", "(gif|jpg|png)")) { |
|
| 244 | + $RandBackground = $this->config["rootpath"] . "/backgrounds/" . $backgrounds[array_rand($backgrounds)]; |
|
| 245 | 245 | } |
| 246 | 246 | return $RandBackground; |
| 247 | 247 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | function createFromFile() |
| 253 | 253 | { |
| 254 | - if ( $RandImage = $this->loadBackground() ) { |
|
| 254 | + if ($RandImage = $this->loadBackground()) { |
|
| 255 | 255 | $ImageType = @getimagesize($RandImage); |
| 256 | - switch ( @$ImageType[2] ) { |
|
| 256 | + switch (@$ImageType[2]) { |
|
| 257 | 257 | case 1: |
| 258 | 258 | $BackgroundImage = imagecreatefromgif($RandImage); |
| 259 | 259 | break; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | break; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - if(!empty($BackgroundImage)){ |
|
| 270 | + if (!empty($BackgroundImage)) { |
|
| 271 | 271 | imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage)); |
| 272 | 272 | imagedestroy($BackgroundImage); |
| 273 | 273 | } else { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | function drawCode() |
| 282 | 282 | { |
| 283 | - for ($i = 0; $i < $this->config["num_chars"] ; $i++) { |
|
| 283 | + for ($i = 0; $i < $this->config["num_chars"]; $i++) { |
|
| 284 | 284 | // select random greyscale colour |
| 285 | 285 | $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
| 286 | 286 | |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | $FontSize = mt_rand($this->config["fontsize_min"], $this->config["fontsize_max"]); |
| 295 | 295 | |
| 296 | 296 | $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array()); |
| 297 | - $CharHeight = abs( $CharDetails[1] + $CharDetails[5] ); |
|
| 297 | + $CharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 298 | 298 | |
| 299 | 299 | // calculate character starting coordinates |
| 300 | - $posX = ($this->spacing/2) + ($i * $this->spacing); |
|
| 300 | + $posX = ($this->spacing / 2) + ($i * $this->spacing); |
|
| 301 | 301 | $posY = 2 + ($this->height / 2) + ($CharHeight / 4); |
| 302 | 302 | |
| 303 | 303 | imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array()); |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | function drawBorder() |
| 311 | 311 | { |
| 312 | 312 | $rgb = rand(50, 150); |
| 313 | - $border_color = imagecolorallocate ($this->oImage, $rgb, $rgb, $rgb); |
|
| 314 | - imagerectangle($this->oImage, 0, 0, $this->width-1, $this->height-1, $border_color); |
|
| 313 | + $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb); |
|
| 314 | + imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -319,9 +319,9 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | function drawCircles() |
| 321 | 321 | { |
| 322 | - for($i = 1; $i <= $this->config["background_num"]; $i++){ |
|
| 323 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 324 | - imagefilledellipse($this->oImage, mt_rand(0,$this->width-10), mt_rand(0,$this->height-3), mt_rand(10,20), mt_rand(20,30),$randomcolor); |
|
| 322 | + for ($i = 1; $i <= $this->config["background_num"]; $i++) { |
|
| 323 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 324 | + imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor); |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | function drawLines() |
| 332 | 332 | { |
| 333 | 333 | for ($i = 0; $i < $this->config["background_num"]; $i++) { |
| 334 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 334 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 335 | 335 | imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
| 336 | 336 | } |
| 337 | 337 | } |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | function drawRectangles() |
| 343 | 343 | { |
| 344 | 344 | for ($i = 1; $i <= $this->config["background_num"]; $i++) { |
| 345 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 346 | - imagefilledrectangle($this->oImage, mt_rand(0,$this->width), mt_rand(0,$this->height), mt_rand(0, $this->width), mt_rand(0,$this->height), $randomcolor); |
|
| 345 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 346 | + imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
@@ -352,14 +352,14 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | function drawBars() |
| 354 | 354 | { |
| 355 | - for ($i= 0 ; $i <= $this->height;) { |
|
| 356 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 357 | - imageline( $this->oImage, 0, $i, $this->width, $i, $randomcolor ); |
|
| 355 | + for ($i = 0; $i <= $this->height;) { |
|
| 356 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 357 | + imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor); |
|
| 358 | 358 | $i = $i + 2.5; |
| 359 | 359 | } |
| 360 | - for ($i = 0;$i <= $this->width;) { |
|
| 361 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 362 | - imageline( $this->oImage, $i, 0, $i, $this->height, $randomcolor ); |
|
| 360 | + for ($i = 0; $i <= $this->width;) { |
|
| 361 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 362 | + imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor); |
|
| 363 | 363 | $i = $i + 2.5; |
| 364 | 364 | } |
| 365 | 365 | } |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | function drawEllipses() |
| 371 | 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 | - imageellipse($this->oImage, mt_rand(0,$this->width), mt_rand(0,$this->height), mt_rand(0,$this->width), mt_rand(0,$this->height), $randomcolor); |
|
| 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 | + imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | function drawPolygons() |
| 382 | 382 | { |
| 383 | - for($i = 1; $i <= $this->config["background_num"]; $i++){ |
|
| 384 | - $randomcolor = imagecolorallocate ($this->oImage , mt_rand(190,255), mt_rand(190,255), mt_rand(190,255)); |
|
| 383 | + for ($i = 1; $i <= $this->config["background_num"]; $i++) { |
|
| 384 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 385 | 385 | $coords = array(); |
| 386 | - for ($j=1; $j <= $this->config["polygon_point"]; $j++) { |
|
| 387 | - $coords[] = mt_rand(0,$this->width); |
|
| 388 | - $coords[] = mt_rand(0,$this->height); |
|
| 386 | + for ($j = 1; $j <= $this->config["polygon_point"]; $j++) { |
|
| 387 | + $coords[] = mt_rand(0, $this->width); |
|
| 388 | + $coords[] = mt_rand(0, $this->height); |
|
| 389 | 389 | } |
| 390 | 390 | imagefilledpolygon($this->oImage, $coords, $this->config["polygon_point"], $randomcolor); |
| 391 | 391 | } |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | { |
| 400 | 400 | $image = ""; |
| 401 | 401 | |
| 402 | - if(empty($file)) { |
|
| 402 | + if (empty($file)) { |
|
| 403 | 403 | header("Content-type: image/bmp"); |
| 404 | 404 | echo $image; |
| 405 | - }else{ |
|
| 405 | + } else { |
|
| 406 | 406 | return $image; |
| 407 | 407 | } |
| 408 | 408 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | if(!extension_loaded('gd')) { |
| 34 | 34 | $this->mode = "bmp"; |
| 35 | - }else{ |
|
| 35 | + } else{ |
|
| 36 | 36 | $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); |
| 37 | 37 | foreach($required_functions as $func) { |
| 38 | 38 | if(!function_exists($func)) { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if($this->mode == "bmp") { |
| 72 | 72 | $this->config["num_chars"] = 4; |
| 73 | 73 | $this->code = rand( pow(10, $this->config["num_chars"] - 1), intval( str_pad("9", $this->config["num_chars"], "9") ) ); |
| 74 | - }else{ |
|
| 74 | + } else{ |
|
| 75 | 75 | $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config["num_chars"] ); |
| 76 | 76 | if (!$this->config["casesensitive"]) { |
| 77 | 77 | $this->code = strtoupper( $this->code ); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | if($this->mode == "bmp") { |
| 109 | 109 | return $this->createImageBmp(); |
| 110 | - }else{ |
|
| 110 | + } else{ |
|
| 111 | 111 | return $this->createImageGd(); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | if(empty($file)) { |
| 169 | 169 | header("Content-type: image/jpeg"); |
| 170 | 170 | imagejpeg ($this->oImage); |
| 171 | - }else{ |
|
| 171 | + } else{ |
|
| 172 | 172 | imagejpeg ($this->oImage, XOOPS_ROOT_PATH. "/". $this->config["imagepath"]. "/". $file . ".jpg"); |
| 173 | 173 | } |
| 174 | 174 | imagedestroy($this->oImage); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | if(empty($file)) { |
| 403 | 403 | header("Content-type: image/bmp"); |
| 404 | 404 | echo $image; |
| 405 | - }else{ |
|
| 405 | + } else{ |
|
| 406 | 406 | return $image; |
| 407 | 407 | } |
| 408 | 408 | } |
@@ -53,6 +53,9 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | return $xoops22; |
| 55 | 55 | } |
| 56 | +/** |
|
| 57 | + * @return string |
|
| 58 | + */ |
|
| 56 | 59 | function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false) { |
| 57 | 60 | if (!$moduleName) { |
| 58 | 61 | global $xoopsModule; |
@@ -189,6 +192,9 @@ discard block |
||
| 189 | 192 | } |
| 190 | 193 | return $value; |
| 191 | 194 | } |
| 195 | +/** |
|
| 196 | + * @return boolean|string |
|
| 197 | + */ |
|
| 192 | 198 | function smart_getCurrentModuleName() { |
| 193 | 199 | global $xoopsModule; |
| 194 | 200 | if (is_object($xoopsModule)) { |
@@ -240,6 +246,9 @@ discard block |
||
| 240 | 246 | $truncated_string = xoops_substr($str, $start, $length - $position_of_space +strlen($trimmarker), $trimmarker); |
| 241 | 247 | return $truncated_string; |
| 242 | 248 | } |
| 249 | +/** |
|
| 250 | + * @param string $key |
|
| 251 | + */ |
|
| 243 | 252 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') { |
| 244 | 253 | if (!$moduleName) { |
| 245 | 254 | $moduleName = smart_getCurrentModuleName(); |
@@ -293,6 +302,7 @@ discard block |
||
| 293 | 302 | } |
| 294 | 303 | /** |
| 295 | 304 | * Thanks to the NewBB2 Development Team |
| 305 | + * @param string $target |
|
| 296 | 306 | */ |
| 297 | 307 | function smart_admin_mkdir($target) { |
| 298 | 308 | // http://www.php.net/manual/en/function.mkdir.php |
@@ -556,11 +566,17 @@ discard block |
||
| 556 | 566 | } |
| 557 | 567 | */ |
| 558 | 568 | } |
| 569 | +/** |
|
| 570 | + * @param string $name |
|
| 571 | + */ |
|
| 559 | 572 | function smart_close_collapsable($name) { |
| 560 | 573 | echo "</div>"; |
| 561 | 574 | smart_openclose_collapsable($name); |
| 562 | 575 | echo "<br />"; |
| 563 | 576 | } |
| 577 | +/** |
|
| 578 | + * @param string $name |
|
| 579 | + */ |
|
| 564 | 580 | function smart_setCookieVar($name, $value, $time = 0) { |
| 565 | 581 | if ($time == 0) { |
| 566 | 582 | $time = time() + 3600 * 24 * 365; |
@@ -568,6 +584,9 @@ discard block |
||
| 568 | 584 | } |
| 569 | 585 | setcookie($name, $value, $time, '/'); |
| 570 | 586 | } |
| 587 | +/** |
|
| 588 | + * @param string $name |
|
| 589 | + */ |
|
| 571 | 590 | function smart_getCookieVar($name, $default = '') { |
| 572 | 591 | $name = str_replace('.', '_', $name); |
| 573 | 592 | if ((isset ($_COOKIE[$name])) && ($_COOKIE[$name] > '')) { |
@@ -673,6 +692,9 @@ discard block |
||
| 673 | 692 | $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
| 674 | 693 | return $text; |
| 675 | 694 | } |
| 695 | +/** |
|
| 696 | + * @param string $src |
|
| 697 | + */ |
|
| 676 | 698 | function smart_addScript($src) { |
| 677 | 699 | echo '<script src="' . $src . '" type="text/javascript"></script>'; |
| 678 | 700 | } |
@@ -791,6 +813,10 @@ discard block |
||
| 791 | 813 | return $text; |
| 792 | 814 | } |
| 793 | 815 | |
| 816 | +/** |
|
| 817 | + * @param string $module |
|
| 818 | + * @param string $file |
|
| 819 | + */ |
|
| 794 | 820 | function smart_loadLanguageFile($module, $file) { |
| 795 | 821 | global $xoopsConfig; |
| 796 | 822 | |
@@ -6,120 +6,120 @@ discard block |
||
| 6 | 6 | * Licence: GNU |
| 7 | 7 | */ |
| 8 | 8 | if (!defined("XOOPS_ROOT_PATH")) { |
| 9 | - die("XOOPS root path not defined"); |
|
| 9 | + die("XOOPS root path not defined"); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | function smart_get_css_link($cssfile) { |
| 13 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />'; |
|
| 14 | - return $ret; |
|
| 13 | + $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />'; |
|
| 14 | + return $ret; |
|
| 15 | 15 | } |
| 16 | 16 | function smart_get_page_before_form() { |
| 17 | - global $smart_previous_page; |
|
| 18 | - return isset ($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 17 | + global $smart_previous_page; |
|
| 18 | + return isset ($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 19 | 19 | } |
| 20 | 20 | /** |
| 21 | - * Checks if a user is admin of $module |
|
| 22 | - * |
|
| 23 | - * @return boolean : true if user is admin |
|
| 24 | - */ |
|
| 21 | + * Checks if a user is admin of $module |
|
| 22 | + * |
|
| 23 | + * @return boolean : true if user is admin |
|
| 24 | + */ |
|
| 25 | 25 | function smart_userIsAdmin($module = false) { |
| 26 | - global $xoopsUser; |
|
| 27 | - static $smart_isAdmin; |
|
| 28 | - if (!$module) { |
|
| 29 | - global $xoopsModule; |
|
| 30 | - $module = $xoopsModule->getVar('dirname'); |
|
| 31 | - } |
|
| 32 | - if (isset ($smart_isAdmin[$module])) { |
|
| 33 | - return $smart_isAdmin[$module]; |
|
| 34 | - } |
|
| 35 | - if (!$xoopsUser) { |
|
| 36 | - $smart_isAdmin[$module] = false; |
|
| 37 | - return $smart_isAdmin[$module]; |
|
| 38 | - } |
|
| 39 | - $smart_isAdmin[$module] = false; |
|
| 40 | - $smartModule = smart_getModuleInfo($module); |
|
| 41 | - if (!is_object($smartModule)) { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - $module_id = $smartModule->getVar('mid'); |
|
| 45 | - $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 46 | - return $smart_isAdmin[$module]; |
|
| 26 | + global $xoopsUser; |
|
| 27 | + static $smart_isAdmin; |
|
| 28 | + if (!$module) { |
|
| 29 | + global $xoopsModule; |
|
| 30 | + $module = $xoopsModule->getVar('dirname'); |
|
| 31 | + } |
|
| 32 | + if (isset ($smart_isAdmin[$module])) { |
|
| 33 | + return $smart_isAdmin[$module]; |
|
| 34 | + } |
|
| 35 | + if (!$xoopsUser) { |
|
| 36 | + $smart_isAdmin[$module] = false; |
|
| 37 | + return $smart_isAdmin[$module]; |
|
| 38 | + } |
|
| 39 | + $smart_isAdmin[$module] = false; |
|
| 40 | + $smartModule = smart_getModuleInfo($module); |
|
| 41 | + if (!is_object($smartModule)) { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + $module_id = $smartModule->getVar('mid'); |
|
| 45 | + $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 46 | + return $smart_isAdmin[$module]; |
|
| 47 | 47 | } |
| 48 | 48 | function smart_isXoops22() { |
| 49 | - $xoops22 = false; |
|
| 50 | - $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 51 | - if (substr($xv, 2, 1) == '2') { |
|
| 52 | - $xoops22 = true; |
|
| 53 | - } |
|
| 54 | - return $xoops22; |
|
| 49 | + $xoops22 = false; |
|
| 50 | + $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 51 | + if (substr($xv, 2, 1) == '2') { |
|
| 52 | + $xoops22 = true; |
|
| 53 | + } |
|
| 54 | + return $xoops22; |
|
| 55 | 55 | } |
| 56 | 56 | function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false) { |
| 57 | - if (!$moduleName) { |
|
| 58 | - global $xoopsModule; |
|
| 59 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 60 | - } |
|
| 61 | - $smartModule = & smart_getModuleInfo($moduleName); |
|
| 62 | - $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 63 | - if (!isset ($smartModule)) { |
|
| 64 | - return ''; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - if ($forBreadCrumb && (isset ($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 68 | - return ''; |
|
| 69 | - } |
|
| 70 | - if (!$withLink) { |
|
| 71 | - return $smartModule->getVar('name'); |
|
| 72 | - } else { |
|
| 73 | - $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 74 | - if ($seoMode == 'rewrite') { |
|
| 75 | - $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 76 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 77 | - } elseif ($seoMode == 'pathinfo') { |
|
| 78 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 79 | - } else { |
|
| 80 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 84 | - } |
|
| 57 | + if (!$moduleName) { |
|
| 58 | + global $xoopsModule; |
|
| 59 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 60 | + } |
|
| 61 | + $smartModule = & smart_getModuleInfo($moduleName); |
|
| 62 | + $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 63 | + if (!isset ($smartModule)) { |
|
| 64 | + return ''; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + if ($forBreadCrumb && (isset ($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 68 | + return ''; |
|
| 69 | + } |
|
| 70 | + if (!$withLink) { |
|
| 71 | + return $smartModule->getVar('name'); |
|
| 72 | + } else { |
|
| 73 | + $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 74 | + if ($seoMode == 'rewrite') { |
|
| 75 | + $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 76 | + $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 77 | + } elseif ($seoMode == 'pathinfo') { |
|
| 78 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 79 | + } else { |
|
| 80 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 84 | + } |
|
| 85 | 85 | } |
| 86 | 86 | function smart_getModuleNameForSEO($moduleName = false) { |
| 87 | - $smartModule = & smart_getModuleInfo($moduleName); |
|
| 88 | - $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 89 | - if (isset ($smartModuleConfig['seo_module_name'])) { |
|
| 90 | - return $smartModuleConfig['seo_module_name']; |
|
| 91 | - } |
|
| 92 | - $ret = smart_getModuleName(false, false, $moduleName); |
|
| 93 | - return (strtolower($ret)); |
|
| 87 | + $smartModule = & smart_getModuleInfo($moduleName); |
|
| 88 | + $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 89 | + if (isset ($smartModuleConfig['seo_module_name'])) { |
|
| 90 | + return $smartModuleConfig['seo_module_name']; |
|
| 91 | + } |
|
| 92 | + $ret = smart_getModuleName(false, false, $moduleName); |
|
| 93 | + return (strtolower($ret)); |
|
| 94 | 94 | } |
| 95 | 95 | function smart_getModuleModeSEO($moduleName = false) { |
| 96 | - $smartModule = & smart_getModuleInfo($moduleName); |
|
| 97 | - $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 98 | - return isset ($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 96 | + $smartModule = & smart_getModuleInfo($moduleName); |
|
| 97 | + $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 98 | + return isset ($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 99 | 99 | } |
| 100 | 100 | function smart_getModuleIncludeIdSEO($moduleName = false) { |
| 101 | - $smartModule = & smart_getModuleInfo($moduleName); |
|
| 102 | - $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 103 | - return !empty ($smartModuleConfig['seo_inc_id']); |
|
| 101 | + $smartModule = & smart_getModuleInfo($moduleName); |
|
| 102 | + $smartModuleConfig = & smart_getModuleConfig($moduleName); |
|
| 103 | + return !empty ($smartModuleConfig['seo_inc_id']); |
|
| 104 | 104 | } |
| 105 | 105 | function smart_getenv($key) { |
| 106 | - $ret = ''; |
|
| 107 | - $ret = isset ($_SERVER[$key]) ? $_SERVER[$key] : (isset ($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 108 | - return $ret; |
|
| 106 | + $ret = ''; |
|
| 107 | + $ret = isset ($_SERVER[$key]) ? $_SERVER[$key] : (isset ($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 108 | + return $ret; |
|
| 109 | 109 | } |
| 110 | 110 | function smart_xoops_cp_header() { |
| 111 | - xoops_cp_header(); |
|
| 112 | - global $xoopsModule, $xoopsConfig; |
|
| 113 | - /** |
|
| 114 | - * include SmartObject admin language file |
|
| 115 | - */ |
|
| 116 | - $fileName = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 117 | - if (file_exists($fileName)) { |
|
| 118 | - include_once $fileName; |
|
| 119 | - } else { |
|
| 120 | - include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 121 | - } |
|
| 122 | - ?> |
|
| 111 | + xoops_cp_header(); |
|
| 112 | + global $xoopsModule, $xoopsConfig; |
|
| 113 | + /** |
|
| 114 | + * include SmartObject admin language file |
|
| 115 | + */ |
|
| 116 | + $fileName = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 117 | + if (file_exists($fileName)) { |
|
| 118 | + include_once $fileName; |
|
| 119 | + } else { |
|
| 120 | + include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 121 | + } |
|
| 122 | + ?> |
|
| 123 | 123 | <script type='text/javascript'> |
| 124 | 124 | <!-- |
| 125 | 125 | var smart_url='<?php echo SMARTOBJECT_URL ?>'; |
@@ -132,388 +132,388 @@ discard block |
||
| 132 | 132 | src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script> |
| 133 | 133 | <?php |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Include the admin language constants for the SmartObject Framework |
|
| 137 | - */ |
|
| 138 | - $admin_file = SMARTOBJECT_ROOT_PATH . "language/" . $xoopsConfig['language'] . "/admin.php"; |
|
| 139 | - if (!file_exists($admin_file)) { |
|
| 140 | - $admin_file = SMARTOBJECT_ROOT_PATH . "language/english/admin.php"; |
|
| 141 | - } |
|
| 142 | - include_once ($admin_file); |
|
| 135 | + /** |
|
| 136 | + * Include the admin language constants for the SmartObject Framework |
|
| 137 | + */ |
|
| 138 | + $admin_file = SMARTOBJECT_ROOT_PATH . "language/" . $xoopsConfig['language'] . "/admin.php"; |
|
| 139 | + if (!file_exists($admin_file)) { |
|
| 140 | + $admin_file = SMARTOBJECT_ROOT_PATH . "language/english/admin.php"; |
|
| 141 | + } |
|
| 142 | + include_once ($admin_file); |
|
| 143 | 143 | } |
| 144 | 144 | /** |
| 145 | - * Detemines if a table exists in the current db |
|
| 146 | - * |
|
| 147 | - * @param string $table the table name (without XOOPS prefix) |
|
| 148 | - * @return bool True if table exists, false if not |
|
| 149 | - * |
|
| 150 | - * @access public |
|
| 151 | - * @author xhelp development team |
|
| 152 | - */ |
|
| 145 | + * Detemines if a table exists in the current db |
|
| 146 | + * |
|
| 147 | + * @param string $table the table name (without XOOPS prefix) |
|
| 148 | + * @return bool True if table exists, false if not |
|
| 149 | + * |
|
| 150 | + * @access public |
|
| 151 | + * @author xhelp development team |
|
| 152 | + */ |
|
| 153 | 153 | function smart_TableExists($table) { |
| 154 | - $bRetVal = false; |
|
| 155 | - //Verifies that a MySQL table exists |
|
| 156 | - $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 157 | - $realname = $xoopsDB->prefix($table); |
|
| 158 | - $sql = "SHOW TABLES FROM ".XOOPS_DB_NAME; |
|
| 159 | - $ret = $xoopsDB->queryF($sql); |
|
| 160 | - while (list ($m_table) = $xoopsDB->fetchRow($ret)) { |
|
| 161 | - if ($m_table == $realname) { |
|
| 162 | - $bRetVal = true; |
|
| 163 | - break; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - $xoopsDB->freeRecordSet($ret); |
|
| 167 | - return ($bRetVal); |
|
| 154 | + $bRetVal = false; |
|
| 155 | + //Verifies that a MySQL table exists |
|
| 156 | + $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 157 | + $realname = $xoopsDB->prefix($table); |
|
| 158 | + $sql = "SHOW TABLES FROM ".XOOPS_DB_NAME; |
|
| 159 | + $ret = $xoopsDB->queryF($sql); |
|
| 160 | + while (list ($m_table) = $xoopsDB->fetchRow($ret)) { |
|
| 161 | + if ($m_table == $realname) { |
|
| 162 | + $bRetVal = true; |
|
| 163 | + break; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + $xoopsDB->freeRecordSet($ret); |
|
| 167 | + return ($bRetVal); |
|
| 168 | 168 | } |
| 169 | 169 | /** |
| 170 | - * Gets a value from a key in the xhelp_meta table |
|
| 171 | - * |
|
| 172 | - * @param string $key |
|
| 173 | - * @return string $value |
|
| 174 | - * |
|
| 175 | - * @access public |
|
| 176 | - * @author xhelp development team |
|
| 177 | - */ |
|
| 170 | + * Gets a value from a key in the xhelp_meta table |
|
| 171 | + * |
|
| 172 | + * @param string $key |
|
| 173 | + * @return string $value |
|
| 174 | + * |
|
| 175 | + * @access public |
|
| 176 | + * @author xhelp development team |
|
| 177 | + */ |
|
| 178 | 178 | function smart_GetMeta($key, $moduleName = false) { |
| 179 | - if (!$moduleName) { |
|
| 180 | - $moduleName = smart_getCurrentModuleName(); |
|
| 181 | - } |
|
| 182 | - $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 183 | - $sql = sprintf("SELECT metavalue FROM %s WHERE metakey=%s", $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 184 | - $ret = $xoopsDB->query($sql); |
|
| 185 | - if (!$ret) { |
|
| 186 | - $value = false; |
|
| 187 | - } else { |
|
| 188 | - list ($value) = $xoopsDB->fetchRow($ret); |
|
| 189 | - } |
|
| 190 | - return $value; |
|
| 179 | + if (!$moduleName) { |
|
| 180 | + $moduleName = smart_getCurrentModuleName(); |
|
| 181 | + } |
|
| 182 | + $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 183 | + $sql = sprintf("SELECT metavalue FROM %s WHERE metakey=%s", $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 184 | + $ret = $xoopsDB->query($sql); |
|
| 185 | + if (!$ret) { |
|
| 186 | + $value = false; |
|
| 187 | + } else { |
|
| 188 | + list ($value) = $xoopsDB->fetchRow($ret); |
|
| 189 | + } |
|
| 190 | + return $value; |
|
| 191 | 191 | } |
| 192 | 192 | function smart_getCurrentModuleName() { |
| 193 | - global $xoopsModule; |
|
| 194 | - if (is_object($xoopsModule)) { |
|
| 195 | - return $xoopsModule->getVar('dirname'); |
|
| 196 | - } else { |
|
| 197 | - return false; |
|
| 198 | - } |
|
| 193 | + global $xoopsModule; |
|
| 194 | + if (is_object($xoopsModule)) { |
|
| 195 | + return $xoopsModule->getVar('dirname'); |
|
| 196 | + } else { |
|
| 197 | + return false; |
|
| 198 | + } |
|
| 199 | 199 | } |
| 200 | 200 | /** |
| 201 | - * Sets a value for a key in the xhelp_meta table |
|
| 202 | - * |
|
| 203 | - * @param string $key |
|
| 204 | - * @param string $value |
|
| 205 | - * @return bool TRUE if success, FALSE if failure |
|
| 206 | - * |
|
| 207 | - * @access public |
|
| 208 | - * @author xhelp development team |
|
| 209 | - */ |
|
| 201 | + * Sets a value for a key in the xhelp_meta table |
|
| 202 | + * |
|
| 203 | + * @param string $key |
|
| 204 | + * @param string $value |
|
| 205 | + * @return bool TRUE if success, FALSE if failure |
|
| 206 | + * |
|
| 207 | + * @access public |
|
| 208 | + * @author xhelp development team |
|
| 209 | + */ |
|
| 210 | 210 | function smart_SetMeta($key, $value, $moduleName = false) { |
| 211 | - if (!$moduleName) { |
|
| 212 | - $moduleName = smart_getCurrentModuleName(); |
|
| 213 | - } |
|
| 214 | - $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 215 | - $ret = smart_GetMeta($key, $moduleName); |
|
| 216 | - if ($ret === '0' || $ret > 0) { |
|
| 217 | - $sql = sprintf("UPDATE %s SET metavalue = %s WHERE metakey = %s", $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 218 | - } else { |
|
| 219 | - $sql = sprintf("INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)", $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 220 | - } |
|
| 221 | - $ret = $xoopsDB->queryF($sql); |
|
| 222 | - if (!$ret) { |
|
| 223 | - return false; |
|
| 224 | - } |
|
| 225 | - return true; |
|
| 211 | + if (!$moduleName) { |
|
| 212 | + $moduleName = smart_getCurrentModuleName(); |
|
| 213 | + } |
|
| 214 | + $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 215 | + $ret = smart_GetMeta($key, $moduleName); |
|
| 216 | + if ($ret === '0' || $ret > 0) { |
|
| 217 | + $sql = sprintf("UPDATE %s SET metavalue = %s WHERE metakey = %s", $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 218 | + } else { |
|
| 219 | + $sql = sprintf("INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)", $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 220 | + } |
|
| 221 | + $ret = $xoopsDB->queryF($sql); |
|
| 222 | + if (!$ret) { |
|
| 223 | + return false; |
|
| 224 | + } |
|
| 225 | + return true; |
|
| 226 | 226 | } |
| 227 | 227 | // Thanks to Mithrandir :-) |
| 228 | 228 | function smart_substr($str, $start, $length, $trimmarker = '...') { |
| 229 | - // if the string is empty, let's get out ;-) |
|
| 230 | - if ($str == '') { |
|
| 231 | - return $str; |
|
| 232 | - } |
|
| 233 | - // reverse a string that is shortened with '' as trimmarker |
|
| 234 | - $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 235 | - // find first space in reversed string |
|
| 236 | - $position_of_space = strpos($reversed_string, " ", 0); |
|
| 237 | - // truncate the original string to a length of $length |
|
| 238 | - // minus the position of the last space |
|
| 239 | - // plus the length of the $trimmarker |
|
| 240 | - $truncated_string = xoops_substr($str, $start, $length - $position_of_space +strlen($trimmarker), $trimmarker); |
|
| 241 | - return $truncated_string; |
|
| 229 | + // if the string is empty, let's get out ;-) |
|
| 230 | + if ($str == '') { |
|
| 231 | + return $str; |
|
| 232 | + } |
|
| 233 | + // reverse a string that is shortened with '' as trimmarker |
|
| 234 | + $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 235 | + // find first space in reversed string |
|
| 236 | + $position_of_space = strpos($reversed_string, " ", 0); |
|
| 237 | + // truncate the original string to a length of $length |
|
| 238 | + // minus the position of the last space |
|
| 239 | + // plus the length of the $trimmarker |
|
| 240 | + $truncated_string = xoops_substr($str, $start, $length - $position_of_space +strlen($trimmarker), $trimmarker); |
|
| 241 | + return $truncated_string; |
|
| 242 | 242 | } |
| 243 | 243 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') { |
| 244 | - if (!$moduleName) { |
|
| 245 | - $moduleName = smart_getCurrentModuleName(); |
|
| 246 | - } |
|
| 247 | - $configs = smart_getModuleConfig($moduleName); |
|
| 248 | - if (isset ($configs[$key])) { |
|
| 249 | - return $configs[$key]; |
|
| 250 | - } else { |
|
| 251 | - if ($default === 'default_is_undefined') { |
|
| 252 | - return null; |
|
| 253 | - } else { |
|
| 254 | - return $default; |
|
| 255 | - } |
|
| 256 | - } |
|
| 244 | + if (!$moduleName) { |
|
| 245 | + $moduleName = smart_getCurrentModuleName(); |
|
| 246 | + } |
|
| 247 | + $configs = smart_getModuleConfig($moduleName); |
|
| 248 | + if (isset ($configs[$key])) { |
|
| 249 | + return $configs[$key]; |
|
| 250 | + } else { |
|
| 251 | + if ($default === 'default_is_undefined') { |
|
| 252 | + return null; |
|
| 253 | + } else { |
|
| 254 | + return $default; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | 257 | } |
| 258 | 258 | /** |
| 259 | - * Copy a file, or a folder and its contents |
|
| 260 | - * |
|
| 261 | - * @author Aidan Lister <[email protected]> |
|
| 262 | - * @version 1.0.0 |
|
| 263 | - * @param string $source The source |
|
| 264 | - * @param string $dest The destination |
|
| 265 | - * @return bool Returns true on success, false on failure |
|
| 266 | - */ |
|
| 259 | + * Copy a file, or a folder and its contents |
|
| 260 | + * |
|
| 261 | + * @author Aidan Lister <[email protected]> |
|
| 262 | + * @version 1.0.0 |
|
| 263 | + * @param string $source The source |
|
| 264 | + * @param string $dest The destination |
|
| 265 | + * @return bool Returns true on success, false on failure |
|
| 266 | + */ |
|
| 267 | 267 | function smart_copyr($source, $dest) { |
| 268 | - // Simple copy for a file |
|
| 269 | - if (is_file($source)) { |
|
| 270 | - return copy($source, $dest); |
|
| 271 | - } |
|
| 272 | - // Make destination directory |
|
| 273 | - if (!is_dir($dest)) { |
|
| 274 | - mkdir($dest); |
|
| 275 | - } |
|
| 276 | - // Loop through the folder |
|
| 277 | - $dir = dir($source); |
|
| 278 | - while (false !== $entry = $dir->read()) { |
|
| 279 | - // Skip pointers |
|
| 280 | - if ($entry == '.' || $entry == '..') { |
|
| 281 | - continue; |
|
| 282 | - } |
|
| 283 | - // Deep copy directories |
|
| 284 | - if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
| 285 | - copyr("$source/$entry", "$dest/$entry"); |
|
| 286 | - } else { |
|
| 287 | - copy("$source/$entry", "$dest/$entry"); |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - // Clean up |
|
| 291 | - $dir->close(); |
|
| 292 | - return true; |
|
| 268 | + // Simple copy for a file |
|
| 269 | + if (is_file($source)) { |
|
| 270 | + return copy($source, $dest); |
|
| 271 | + } |
|
| 272 | + // Make destination directory |
|
| 273 | + if (!is_dir($dest)) { |
|
| 274 | + mkdir($dest); |
|
| 275 | + } |
|
| 276 | + // Loop through the folder |
|
| 277 | + $dir = dir($source); |
|
| 278 | + while (false !== $entry = $dir->read()) { |
|
| 279 | + // Skip pointers |
|
| 280 | + if ($entry == '.' || $entry == '..') { |
|
| 281 | + continue; |
|
| 282 | + } |
|
| 283 | + // Deep copy directories |
|
| 284 | + if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
| 285 | + copyr("$source/$entry", "$dest/$entry"); |
|
| 286 | + } else { |
|
| 287 | + copy("$source/$entry", "$dest/$entry"); |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + // Clean up |
|
| 291 | + $dir->close(); |
|
| 292 | + return true; |
|
| 293 | 293 | } |
| 294 | 294 | /** |
| 295 | - * Thanks to the NewBB2 Development Team |
|
| 296 | - */ |
|
| 295 | + * Thanks to the NewBB2 Development Team |
|
| 296 | + */ |
|
| 297 | 297 | function smart_admin_mkdir($target) { |
| 298 | - // http://www.php.net/manual/en/function.mkdir.php |
|
| 299 | - // saint at corenova.com |
|
| 300 | - // bart at cdasites dot com |
|
| 301 | - if (is_dir($target) || empty ($target)) { |
|
| 302 | - return true; // best case check first |
|
| 303 | - } |
|
| 304 | - if (file_exists($target) && !is_dir($target)) { |
|
| 305 | - return false; |
|
| 306 | - } |
|
| 307 | - if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 308 | - if (!file_exists($target)) { |
|
| 309 | - $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 310 | - smart_admin_chmod($target); |
|
| 311 | - return $res; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - $res = is_dir($target); |
|
| 315 | - return $res; |
|
| 298 | + // http://www.php.net/manual/en/function.mkdir.php |
|
| 299 | + // saint at corenova.com |
|
| 300 | + // bart at cdasites dot com |
|
| 301 | + if (is_dir($target) || empty ($target)) { |
|
| 302 | + return true; // best case check first |
|
| 303 | + } |
|
| 304 | + if (file_exists($target) && !is_dir($target)) { |
|
| 305 | + return false; |
|
| 306 | + } |
|
| 307 | + if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 308 | + if (!file_exists($target)) { |
|
| 309 | + $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 310 | + smart_admin_chmod($target); |
|
| 311 | + return $res; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + $res = is_dir($target); |
|
| 315 | + return $res; |
|
| 316 | 316 | } |
| 317 | 317 | /** |
| 318 | - * Thanks to the NewBB2 Development Team |
|
| 319 | - */ |
|
| 318 | + * Thanks to the NewBB2 Development Team |
|
| 319 | + */ |
|
| 320 | 320 | function smart_admin_chmod($target, $mode = 0777) { |
| 321 | - return @ chmod($target, $mode); |
|
| 321 | + return @ chmod($target, $mode); |
|
| 322 | 322 | } |
| 323 | 323 | function smart_imageResize($src, $maxWidth, $maxHeight) { |
| 324 | - $width = ''; |
|
| 325 | - $height = ''; |
|
| 326 | - $type = ''; |
|
| 327 | - $attr = ''; |
|
| 328 | - if (file_exists($src)) { |
|
| 329 | - list ($width, $height, $type, $attr) = getimagesize($src); |
|
| 330 | - if ($width > $maxWidth) { |
|
| 331 | - $originalWidth = $width; |
|
| 332 | - $width = $maxWidth; |
|
| 333 | - $height = $width * $height / $originalWidth; |
|
| 334 | - } |
|
| 335 | - if ($height > $maxHeight) { |
|
| 336 | - $originalHeight = $height; |
|
| 337 | - $height = $maxHeight; |
|
| 338 | - $width = $height * $width / $originalHeight; |
|
| 339 | - } |
|
| 340 | - $attr = " width='$width' height='$height'"; |
|
| 341 | - } |
|
| 342 | - return array ( |
|
| 343 | - $width, |
|
| 344 | - $height, |
|
| 345 | - $type, |
|
| 346 | - $attr |
|
| 347 | - ); |
|
| 324 | + $width = ''; |
|
| 325 | + $height = ''; |
|
| 326 | + $type = ''; |
|
| 327 | + $attr = ''; |
|
| 328 | + if (file_exists($src)) { |
|
| 329 | + list ($width, $height, $type, $attr) = getimagesize($src); |
|
| 330 | + if ($width > $maxWidth) { |
|
| 331 | + $originalWidth = $width; |
|
| 332 | + $width = $maxWidth; |
|
| 333 | + $height = $width * $height / $originalWidth; |
|
| 334 | + } |
|
| 335 | + if ($height > $maxHeight) { |
|
| 336 | + $originalHeight = $height; |
|
| 337 | + $height = $maxHeight; |
|
| 338 | + $width = $height * $width / $originalHeight; |
|
| 339 | + } |
|
| 340 | + $attr = " width='$width' height='$height'"; |
|
| 341 | + } |
|
| 342 | + return array ( |
|
| 343 | + $width, |
|
| 344 | + $height, |
|
| 345 | + $type, |
|
| 346 | + $attr |
|
| 347 | + ); |
|
| 348 | 348 | } |
| 349 | 349 | function &smart_getModuleInfo($moduleName = false) { |
| 350 | - static $smartModules; |
|
| 351 | - if (isset ($smartModules[$moduleName])) { |
|
| 352 | - $ret =& $smartModules[$moduleName]; |
|
| 353 | - return $ret; |
|
| 354 | - } |
|
| 355 | - global $xoopsModule; |
|
| 356 | - if (!$moduleName) { |
|
| 357 | - if (isset ($xoopsModule) && is_object($xoopsModule)) { |
|
| 358 | - $smartModules[$xoopsModule->getVar('dirname')] = & $xoopsModule; |
|
| 359 | - return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - if (!isset ($smartModules[$moduleName])) { |
|
| 363 | - if (isset ($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 364 | - $smartModules[$moduleName] = & $xoopsModule; |
|
| 365 | - } else { |
|
| 366 | - $hModule = & xoops_gethandler('module'); |
|
| 367 | - if ($moduleName != 'xoops') { |
|
| 368 | - $smartModules[$moduleName] = & $hModule->getByDirname($moduleName); |
|
| 369 | - |
|
| 370 | - } else { |
|
| 371 | - $smartModules[$moduleName] = & $hModule->getByDirname('system'); |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - } |
|
| 375 | - return $smartModules[$moduleName]; |
|
| 350 | + static $smartModules; |
|
| 351 | + if (isset ($smartModules[$moduleName])) { |
|
| 352 | + $ret =& $smartModules[$moduleName]; |
|
| 353 | + return $ret; |
|
| 354 | + } |
|
| 355 | + global $xoopsModule; |
|
| 356 | + if (!$moduleName) { |
|
| 357 | + if (isset ($xoopsModule) && is_object($xoopsModule)) { |
|
| 358 | + $smartModules[$xoopsModule->getVar('dirname')] = & $xoopsModule; |
|
| 359 | + return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + if (!isset ($smartModules[$moduleName])) { |
|
| 363 | + if (isset ($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 364 | + $smartModules[$moduleName] = & $xoopsModule; |
|
| 365 | + } else { |
|
| 366 | + $hModule = & xoops_gethandler('module'); |
|
| 367 | + if ($moduleName != 'xoops') { |
|
| 368 | + $smartModules[$moduleName] = & $hModule->getByDirname($moduleName); |
|
| 369 | + |
|
| 370 | + } else { |
|
| 371 | + $smartModules[$moduleName] = & $hModule->getByDirname('system'); |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | + return $smartModules[$moduleName]; |
|
| 376 | 376 | } |
| 377 | 377 | function &smart_getModuleConfig($moduleName = false) { |
| 378 | - static $smartConfigs; |
|
| 379 | - if (isset ($smartConfigs[$moduleName])) { |
|
| 380 | - $ret = & $smartConfigs[$moduleName]; |
|
| 381 | - return $ret; |
|
| 382 | - } |
|
| 383 | - global $xoopsModule, $xoopsModuleConfig; |
|
| 384 | - if (!$moduleName) { |
|
| 385 | - if (isset ($xoopsModule) && is_object($xoopsModule)) { |
|
| 386 | - $smartConfigs[$xoopsModule->getVar('dirname')] = & $xoopsModuleConfig; |
|
| 387 | - return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 388 | - } |
|
| 389 | - } |
|
| 390 | - // if we still did not found the xoopsModule, this is because there is none |
|
| 391 | - if (!$moduleName) { |
|
| 392 | - $ret = false; |
|
| 393 | - return $ret; |
|
| 394 | - } |
|
| 395 | - if (isset ($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 396 | - $smartConfigs[$moduleName] = & $xoopsModuleConfig; |
|
| 397 | - } else { |
|
| 398 | - $module = & smart_getModuleInfo($moduleName); |
|
| 399 | - if (!is_object($module)) { |
|
| 400 | - $ret = false; |
|
| 401 | - return $ret; |
|
| 402 | - } |
|
| 403 | - $hModConfig = & xoops_gethandler('config'); |
|
| 404 | - $smartConfigs[$moduleName] = & $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 405 | - } |
|
| 406 | - return $smartConfigs[$moduleName]; |
|
| 378 | + static $smartConfigs; |
|
| 379 | + if (isset ($smartConfigs[$moduleName])) { |
|
| 380 | + $ret = & $smartConfigs[$moduleName]; |
|
| 381 | + return $ret; |
|
| 382 | + } |
|
| 383 | + global $xoopsModule, $xoopsModuleConfig; |
|
| 384 | + if (!$moduleName) { |
|
| 385 | + if (isset ($xoopsModule) && is_object($xoopsModule)) { |
|
| 386 | + $smartConfigs[$xoopsModule->getVar('dirname')] = & $xoopsModuleConfig; |
|
| 387 | + return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | + // if we still did not found the xoopsModule, this is because there is none |
|
| 391 | + if (!$moduleName) { |
|
| 392 | + $ret = false; |
|
| 393 | + return $ret; |
|
| 394 | + } |
|
| 395 | + if (isset ($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 396 | + $smartConfigs[$moduleName] = & $xoopsModuleConfig; |
|
| 397 | + } else { |
|
| 398 | + $module = & smart_getModuleInfo($moduleName); |
|
| 399 | + if (!is_object($module)) { |
|
| 400 | + $ret = false; |
|
| 401 | + return $ret; |
|
| 402 | + } |
|
| 403 | + $hModConfig = & xoops_gethandler('config'); |
|
| 404 | + $smartConfigs[$moduleName] = & $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 405 | + } |
|
| 406 | + return $smartConfigs[$moduleName]; |
|
| 407 | 407 | } |
| 408 | 408 | function smart_deleteFile($dirname) { |
| 409 | - // Simple delete for a file |
|
| 410 | - if (is_file($dirname)) { |
|
| 411 | - return unlink($dirname); |
|
| 412 | - } |
|
| 409 | + // Simple delete for a file |
|
| 410 | + if (is_file($dirname)) { |
|
| 411 | + return unlink($dirname); |
|
| 412 | + } |
|
| 413 | 413 | } |
| 414 | 414 | function smart_formatErrors($errors = array ()) { |
| 415 | - $ret = ''; |
|
| 416 | - foreach ($errors as $key => $value) { |
|
| 417 | - $ret .= "<br /> - " . $value; |
|
| 418 | - } |
|
| 419 | - return $ret; |
|
| 415 | + $ret = ''; |
|
| 416 | + foreach ($errors as $key => $value) { |
|
| 417 | + $ret .= "<br /> - " . $value; |
|
| 418 | + } |
|
| 419 | + return $ret; |
|
| 420 | 420 | } |
| 421 | 421 | /** |
| 422 | - * smart_getLinkedUnameFromId() |
|
| 423 | - * |
|
| 424 | - * @param integer $userid Userid of poster etc |
|
| 425 | - * @param integer $name : 0 Use Usenamer 1 Use realname |
|
| 426 | - * @return |
|
| 427 | - */ |
|
| 422 | + * smart_getLinkedUnameFromId() |
|
| 423 | + * |
|
| 424 | + * @param integer $userid Userid of poster etc |
|
| 425 | + * @param integer $name : 0 Use Usenamer 1 Use realname |
|
| 426 | + * @return |
|
| 427 | + */ |
|
| 428 | 428 | function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array (), $withContact = false) { |
| 429 | - if (!is_numeric($userid)) { |
|
| 430 | - return $userid; |
|
| 431 | - } |
|
| 432 | - $userid = intval($userid); |
|
| 433 | - if ($userid > 0) { |
|
| 434 | - if ($users == array ()) { |
|
| 435 | - //fetching users |
|
| 436 | - $member_handler = & xoops_gethandler('member'); |
|
| 437 | - $user = & $member_handler->getUser($userid); |
|
| 438 | - } else { |
|
| 439 | - if (!isset ($users[$userid])) { |
|
| 440 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 441 | - } |
|
| 442 | - $user = & $users[$userid]; |
|
| 443 | - } |
|
| 444 | - if (is_object($user)) { |
|
| 445 | - $ts = & MyTextSanitizer :: getInstance(); |
|
| 446 | - $username = $user->getVar('uname'); |
|
| 447 | - $fullname = ''; |
|
| 448 | - $fullname2 = $user->getVar('name'); |
|
| 449 | - if (($name) && !empty ($fullname2)) { |
|
| 450 | - $fullname = $user->getVar('name'); |
|
| 451 | - } |
|
| 452 | - if (!empty ($fullname)) { |
|
| 453 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $userid . "'>" . $ts->htmlSpecialChars($username) . "</a>]"; |
|
| 454 | - } else { |
|
| 455 | - $linkeduser = "<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . "</a>"; |
|
| 456 | - } |
|
| 457 | - // add contact info : email + PM |
|
| 458 | - if ($withContact) { |
|
| 459 | - $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"/></a>'; |
|
| 460 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 461 | - $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"/></a>'; |
|
| 462 | - } |
|
| 463 | - return $linkeduser; |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 429 | + if (!is_numeric($userid)) { |
|
| 430 | + return $userid; |
|
| 431 | + } |
|
| 432 | + $userid = intval($userid); |
|
| 433 | + if ($userid > 0) { |
|
| 434 | + if ($users == array ()) { |
|
| 435 | + //fetching users |
|
| 436 | + $member_handler = & xoops_gethandler('member'); |
|
| 437 | + $user = & $member_handler->getUser($userid); |
|
| 438 | + } else { |
|
| 439 | + if (!isset ($users[$userid])) { |
|
| 440 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 441 | + } |
|
| 442 | + $user = & $users[$userid]; |
|
| 443 | + } |
|
| 444 | + if (is_object($user)) { |
|
| 445 | + $ts = & MyTextSanitizer :: getInstance(); |
|
| 446 | + $username = $user->getVar('uname'); |
|
| 447 | + $fullname = ''; |
|
| 448 | + $fullname2 = $user->getVar('name'); |
|
| 449 | + if (($name) && !empty ($fullname2)) { |
|
| 450 | + $fullname = $user->getVar('name'); |
|
| 451 | + } |
|
| 452 | + if (!empty ($fullname)) { |
|
| 453 | + $linkeduser = "$fullname [<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $userid . "'>" . $ts->htmlSpecialChars($username) . "</a>]"; |
|
| 454 | + } else { |
|
| 455 | + $linkeduser = "<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . "</a>"; |
|
| 456 | + } |
|
| 457 | + // add contact info : email + PM |
|
| 458 | + if ($withContact) { |
|
| 459 | + $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"/></a>'; |
|
| 460 | + $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 461 | + $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"/></a>'; |
|
| 462 | + } |
|
| 463 | + return $linkeduser; |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 467 | 467 | } |
| 468 | 468 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) { |
| 469 | - global $xoopsModule, $xoopsConfig; |
|
| 470 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 471 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 472 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 473 | - } else { |
|
| 474 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 475 | - } |
|
| 476 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 477 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 478 | - } else { |
|
| 479 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 480 | - } |
|
| 481 | - $headermenu = array(); |
|
| 482 | - $adminmenu = array(); |
|
| 483 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 484 | - $tpl = new XoopsTpl(); |
|
| 485 | - $tpl->assign(array ( |
|
| 486 | - 'headermenu' => $headermenu, |
|
| 487 | - 'adminmenu' => $adminmenu, |
|
| 488 | - 'current' => $currentoption, |
|
| 489 | - 'breadcrumb' => $breadcrumb, |
|
| 490 | - 'headermenucount' => count($headermenu |
|
| 491 | - ), 'submenus' => $submenus, 'currentsub' => $currentsub, 'submenuscount' => count($submenus))); |
|
| 492 | - $tpl->display('db:smartobject_admin_menu.html'); |
|
| 469 | + global $xoopsModule, $xoopsConfig; |
|
| 470 | + include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 471 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 472 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 473 | + } else { |
|
| 474 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 475 | + } |
|
| 476 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 477 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 478 | + } else { |
|
| 479 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 480 | + } |
|
| 481 | + $headermenu = array(); |
|
| 482 | + $adminmenu = array(); |
|
| 483 | + include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 484 | + $tpl = new XoopsTpl(); |
|
| 485 | + $tpl->assign(array ( |
|
| 486 | + 'headermenu' => $headermenu, |
|
| 487 | + 'adminmenu' => $adminmenu, |
|
| 488 | + 'current' => $currentoption, |
|
| 489 | + 'breadcrumb' => $breadcrumb, |
|
| 490 | + 'headermenucount' => count($headermenu |
|
| 491 | + ), 'submenus' => $submenus, 'currentsub' => $currentsub, 'submenuscount' => count($submenus))); |
|
| 492 | + $tpl->display('db:smartobject_admin_menu.html'); |
|
| 493 | 493 | } |
| 494 | 494 | function smart_collapsableBar($id = '', $title = '', $dsc = '') { |
| 495 | - global $xoopsModule; |
|
| 496 | - echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 497 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "images/close12.gif alt='' /></a> " . $title . "</h3>"; |
|
| 498 | - echo "<div id='" . $id . "'>"; |
|
| 499 | - if ($dsc != '') { |
|
| 500 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . "</span>"; |
|
| 501 | - } |
|
| 495 | + global $xoopsModule; |
|
| 496 | + echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 497 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "images/close12.gif alt='' /></a> " . $title . "</h3>"; |
|
| 498 | + echo "<div id='" . $id . "'>"; |
|
| 499 | + if ($dsc != '') { |
|
| 500 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . "</span>"; |
|
| 501 | + } |
|
| 502 | 502 | } |
| 503 | 503 | function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '') { |
| 504 | - global $xoopsModule; |
|
| 505 | - $onClick = "ajaxtogglecollapse('$id')"; |
|
| 506 | - //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 507 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 508 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "images/close12.gif alt='' /></a> " . $title . "</h3>"; |
|
| 509 | - echo "<div id='" . $id . "'>"; |
|
| 510 | - if ($dsc != '') { |
|
| 511 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . "</span>"; |
|
| 512 | - } |
|
| 504 | + global $xoopsModule; |
|
| 505 | + $onClick = "ajaxtogglecollapse('$id')"; |
|
| 506 | + //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 507 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 508 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "images/close12.gif alt='' /></a> " . $title . "</h3>"; |
|
| 509 | + echo "<div id='" . $id . "'>"; |
|
| 510 | + if ($dsc != '') { |
|
| 511 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . "</span>"; |
|
| 512 | + } |
|
| 513 | 513 | } |
| 514 | 514 | /** |
| 515 | - * Ajax testing...... |
|
| 516 | - */ |
|
| 515 | + * Ajax testing...... |
|
| 516 | + */ |
|
| 517 | 517 | /* |
| 518 | 518 | function smart_collapsableBar($id = '', $title = '', $dsc='') |
| 519 | 519 | { |
@@ -533,20 +533,20 @@ discard block |
||
| 533 | 533 | } |
| 534 | 534 | */ |
| 535 | 535 | function smart_openclose_collapsable($name) { |
| 536 | - $urls = smart_getCurrentUrls(); |
|
| 537 | - $path = $urls['phpself']; |
|
| 538 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 539 | - $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 540 | - $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 541 | - if ($cookie == 'none') { |
|
| 542 | - echo ' |
|
| 536 | + $urls = smart_getCurrentUrls(); |
|
| 537 | + $path = $urls['phpself']; |
|
| 538 | + $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 539 | + $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 540 | + $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 541 | + if ($cookie == 'none') { |
|
| 542 | + echo ' |
|
| 543 | 543 | <script type="text/javascript"><!-- |
| 544 | 544 | togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
| 545 | 545 | //--> |
| 546 | 546 | </script> |
| 547 | 547 | '; |
| 548 | - } |
|
| 549 | - /* if ($cookie == 'none') { |
|
| 548 | + } |
|
| 549 | + /* if ($cookie == 'none') { |
|
| 550 | 550 | echo ' |
| 551 | 551 | <script type="text/javascript"><!-- |
| 552 | 552 | hideElement("' . $name . '"); |
@@ -557,63 +557,63 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | } |
| 559 | 559 | function smart_close_collapsable($name) { |
| 560 | - echo "</div>"; |
|
| 561 | - smart_openclose_collapsable($name); |
|
| 562 | - echo "<br />"; |
|
| 560 | + echo "</div>"; |
|
| 561 | + smart_openclose_collapsable($name); |
|
| 562 | + echo "<br />"; |
|
| 563 | 563 | } |
| 564 | 564 | function smart_setCookieVar($name, $value, $time = 0) { |
| 565 | - if ($time == 0) { |
|
| 566 | - $time = time() + 3600 * 24 * 365; |
|
| 567 | - //$time = ''; |
|
| 568 | - } |
|
| 569 | - setcookie($name, $value, $time, '/'); |
|
| 565 | + if ($time == 0) { |
|
| 566 | + $time = time() + 3600 * 24 * 365; |
|
| 567 | + //$time = ''; |
|
| 568 | + } |
|
| 569 | + setcookie($name, $value, $time, '/'); |
|
| 570 | 570 | } |
| 571 | 571 | function smart_getCookieVar($name, $default = '') { |
| 572 | - $name = str_replace('.', '_', $name); |
|
| 573 | - if ((isset ($_COOKIE[$name])) && ($_COOKIE[$name] > '')) { |
|
| 574 | - return $_COOKIE[$name]; |
|
| 575 | - } else { |
|
| 576 | - return $default; |
|
| 577 | - } |
|
| 572 | + $name = str_replace('.', '_', $name); |
|
| 573 | + if ((isset ($_COOKIE[$name])) && ($_COOKIE[$name] > '')) { |
|
| 574 | + return $_COOKIE[$name]; |
|
| 575 | + } else { |
|
| 576 | + return $default; |
|
| 577 | + } |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | function smart_getCurrentUrls() { |
| 581 | - $urls = array(); |
|
| 582 | - $http = ((strpos(XOOPS_URL, "https://")) === false) ? ("http://") : ("https://"); |
|
| 583 | - $phpself = $_SERVER['PHP_SELF']; |
|
| 584 | - $httphost = $_SERVER['HTTP_HOST']; |
|
| 585 | - $querystring = $_SERVER['QUERY_STRING']; |
|
| 586 | - if ($querystring != '') { |
|
| 587 | - $querystring = '?' . $querystring; |
|
| 588 | - } |
|
| 589 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 590 | - $urls = array (); |
|
| 591 | - $urls['http'] = $http; |
|
| 592 | - $urls['httphost'] = $httphost; |
|
| 593 | - $urls['phpself'] = $phpself; |
|
| 594 | - $urls['querystring'] = $querystring; |
|
| 595 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 596 | - $urls['full'] = $currenturl; |
|
| 597 | - $urls['isHomePage'] = (XOOPS_URL . "/index.php") == ($http . $httphost . $phpself); |
|
| 598 | - return $urls; |
|
| 581 | + $urls = array(); |
|
| 582 | + $http = ((strpos(XOOPS_URL, "https://")) === false) ? ("http://") : ("https://"); |
|
| 583 | + $phpself = $_SERVER['PHP_SELF']; |
|
| 584 | + $httphost = $_SERVER['HTTP_HOST']; |
|
| 585 | + $querystring = $_SERVER['QUERY_STRING']; |
|
| 586 | + if ($querystring != '') { |
|
| 587 | + $querystring = '?' . $querystring; |
|
| 588 | + } |
|
| 589 | + $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 590 | + $urls = array (); |
|
| 591 | + $urls['http'] = $http; |
|
| 592 | + $urls['httphost'] = $httphost; |
|
| 593 | + $urls['phpself'] = $phpself; |
|
| 594 | + $urls['querystring'] = $querystring; |
|
| 595 | + $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 596 | + $urls['full'] = $currenturl; |
|
| 597 | + $urls['isHomePage'] = (XOOPS_URL . "/index.php") == ($http . $httphost . $phpself); |
|
| 598 | + return $urls; |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | function smart_getCurrentPage() { |
| 602 | - $urls = smart_getCurrentUrls(); |
|
| 603 | - return $urls['full']; |
|
| 602 | + $urls = smart_getCurrentUrls(); |
|
| 603 | + return $urls['full']; |
|
| 604 | 604 | } |
| 605 | 605 | /** |
| 606 | - * Create a title for the short_url field of an article |
|
| 607 | - * |
|
| 608 | - * @credit psylove |
|
| 609 | - * |
|
| 610 | - * @var string $title title of the article |
|
| 611 | - * @var string $withExt do we add an html extension or not |
|
| 612 | - * @return string sort_url for the article |
|
| 613 | - */ |
|
| 606 | + * Create a title for the short_url field of an article |
|
| 607 | + * |
|
| 608 | + * @credit psylove |
|
| 609 | + * |
|
| 610 | + * @var string $title title of the article |
|
| 611 | + * @var string $withExt do we add an html extension or not |
|
| 612 | + * @return string sort_url for the article |
|
| 613 | + */ |
|
| 614 | 614 | /** |
| 615 | - * Moved in SmartMetaGenClass |
|
| 616 | - */ |
|
| 615 | + * Moved in SmartMetaGenClass |
|
| 616 | + */ |
|
| 617 | 617 | /* |
| 618 | 618 | function smart_seo_title($title='', $withExt=true) |
| 619 | 619 | { |
@@ -645,210 +645,210 @@ discard block |
||
| 645 | 645 | } |
| 646 | 646 | */ |
| 647 | 647 | function smart_modFooter() { |
| 648 | - global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 648 | + global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 649 | 649 | |
| 650 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 651 | - $tpl = new XoopsTpl(); |
|
| 650 | + include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 651 | + $tpl = new XoopsTpl(); |
|
| 652 | 652 | |
| 653 | - $hModule = & xoops_gethandler('module'); |
|
| 654 | - $versioninfo = & $hModule->get($xoopsModule->getVar('mid')); |
|
| 655 | - $modfootertxt = "Module " . $versioninfo->getInfo('name') . " - Version " . $versioninfo->getInfo('version') . ""; |
|
| 656 | - $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->getVar('dirname') . "/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'/></a>"; |
|
| 657 | - $tpl->assign('modfooter', $modfooter); |
|
| 653 | + $hModule = & xoops_gethandler('module'); |
|
| 654 | + $versioninfo = & $hModule->get($xoopsModule->getVar('mid')); |
|
| 655 | + $modfootertxt = "Module " . $versioninfo->getInfo('name') . " - Version " . $versioninfo->getInfo('version') . ""; |
|
| 656 | + $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->getVar('dirname') . "/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'/></a>"; |
|
| 657 | + $tpl->assign('modfooter', $modfooter); |
|
| 658 | 658 | |
| 659 | - if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 660 | - define("_AM_SOBJECT_XOOPS_PRO", "Do you need help with this module ?<br />Do you need new features not yet available ?"); |
|
| 661 | - } |
|
| 662 | - $smartobject_config = smart_getModuleConfig('smartobject'); |
|
| 663 | - $tpl->assign('smartobject_enable_admin_footer', $smartobject_config['enable_admin_footer']); |
|
| 664 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html'); |
|
| 659 | + if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 660 | + define("_AM_SOBJECT_XOOPS_PRO", "Do you need help with this module ?<br />Do you need new features not yet available ?"); |
|
| 661 | + } |
|
| 662 | + $smartobject_config = smart_getModuleConfig('smartobject'); |
|
| 663 | + $tpl->assign('smartobject_enable_admin_footer', $smartobject_config['enable_admin_footer']); |
|
| 664 | + $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html'); |
|
| 665 | 665 | } |
| 666 | 666 | function smart_xoops_cp_footer() { |
| 667 | - smart_modFooter(); |
|
| 668 | - xoops_cp_footer(); |
|
| 667 | + smart_modFooter(); |
|
| 668 | + xoops_cp_footer(); |
|
| 669 | 669 | } |
| 670 | 670 | function smart_sanitizeForCommonTags($text) { |
| 671 | - global $xoopsConfig; |
|
| 672 | - $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 673 | - $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 674 | - return $text; |
|
| 671 | + global $xoopsConfig; |
|
| 672 | + $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 673 | + $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 674 | + return $text; |
|
| 675 | 675 | } |
| 676 | 676 | function smart_addScript($src) { |
| 677 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 677 | + echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 678 | 678 | } |
| 679 | 679 | function smart_addStyle($src) { |
| 680 | - if ($src == 'smartobject') { |
|
| 681 | - $src = SMARTOBJECT_URL . 'module.css'; |
|
| 682 | - } |
|
| 683 | - echo smart_get_css_link($src); |
|
| 680 | + if ($src == 'smartobject') { |
|
| 681 | + $src = SMARTOBJECT_URL . 'module.css'; |
|
| 682 | + } |
|
| 683 | + echo smart_get_css_link($src); |
|
| 684 | 684 | } |
| 685 | 685 | function smart_addAdminAjaxSupport() { |
| 686 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 687 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 688 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 686 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 687 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 688 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 689 | 689 | } |
| 690 | 690 | function smart_sanitizeForSmartpopupLink($text) { |
| 691 | - $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 692 | - $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 693 | - $ret = preg_replace($patterns, $replacements, $text); |
|
| 694 | - return $ret; |
|
| 691 | + $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 692 | + $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 693 | + $ret = preg_replace($patterns, $replacements, $text); |
|
| 694 | + return $ret; |
|
| 695 | 695 | } |
| 696 | 696 | /** |
| 697 | - * Finds the width and height of an image (can also be a flash file) |
|
| 698 | - * |
|
| 699 | - * @credit phppp |
|
| 700 | - * |
|
| 701 | - * @var string $url path of the image file |
|
| 702 | - * @var string $width reference to the width |
|
| 703 | - * @var string $height reference to the height |
|
| 704 | - * @return bool false if impossible to find dimension |
|
| 705 | - */ |
|
| 697 | + * Finds the width and height of an image (can also be a flash file) |
|
| 698 | + * |
|
| 699 | + * @credit phppp |
|
| 700 | + * |
|
| 701 | + * @var string $url path of the image file |
|
| 702 | + * @var string $width reference to the width |
|
| 703 | + * @var string $height reference to the height |
|
| 704 | + * @return bool false if impossible to find dimension |
|
| 705 | + */ |
|
| 706 | 706 | function smart_getImageSize($url, & $width, & $height) { |
| 707 | - if (empty ($width) || empty ($height)) { |
|
| 708 | - if (!$dimension = @ getimagesize($url)) { |
|
| 709 | - return false; |
|
| 710 | - } |
|
| 711 | - if (!empty ($width)) { |
|
| 712 | - $height = $dimension[1] * $width / $dimension[0]; |
|
| 713 | - } |
|
| 714 | - elseif (!empty ($height)) { |
|
| 715 | - $width = $dimension[0] * $height / $dimension[1]; |
|
| 716 | - } else { |
|
| 717 | - list ($width, $height) = array ( |
|
| 718 | - $dimension[0], |
|
| 719 | - $dimension[1] |
|
| 720 | - ); |
|
| 721 | - } |
|
| 722 | - return true; |
|
| 723 | - } else { |
|
| 724 | - return true; |
|
| 725 | - } |
|
| 707 | + if (empty ($width) || empty ($height)) { |
|
| 708 | + if (!$dimension = @ getimagesize($url)) { |
|
| 709 | + return false; |
|
| 710 | + } |
|
| 711 | + if (!empty ($width)) { |
|
| 712 | + $height = $dimension[1] * $width / $dimension[0]; |
|
| 713 | + } |
|
| 714 | + elseif (!empty ($height)) { |
|
| 715 | + $width = $dimension[0] * $height / $dimension[1]; |
|
| 716 | + } else { |
|
| 717 | + list ($width, $height) = array ( |
|
| 718 | + $dimension[0], |
|
| 719 | + $dimension[1] |
|
| 720 | + ); |
|
| 721 | + } |
|
| 722 | + return true; |
|
| 723 | + } else { |
|
| 724 | + return true; |
|
| 725 | + } |
|
| 726 | 726 | } |
| 727 | 727 | /** |
| 728 | - * Convert characters to decimal values |
|
| 729 | - * |
|
| 730 | - * @author eric.wallet at yahoo.fr |
|
| 731 | - * @link http://ca.php.net/manual/en/function.htmlentities.php#69913 |
|
| 732 | - */ |
|
| 728 | + * Convert characters to decimal values |
|
| 729 | + * |
|
| 730 | + * @author eric.wallet at yahoo.fr |
|
| 731 | + * @link http://ca.php.net/manual/en/function.htmlentities.php#69913 |
|
| 732 | + */ |
|
| 733 | 733 | function smart_htmlnumericentities($str) { |
| 734 | - return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 734 | + return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 735 | 735 | } |
| 736 | 736 | function & smart_getcorehandler($name, $optional = false) { |
| 737 | - static $handlers; |
|
| 738 | - $name = strtolower(trim($name)); |
|
| 739 | - if (!isset ($handlers[$name])) { |
|
| 740 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 741 | - require_once $hnd_file; |
|
| 742 | - } |
|
| 743 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 744 | - if (class_exists($class)) { |
|
| 745 | - $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops'); |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - if (!isset ($handlers[$name]) && !$optional) { |
|
| 749 | - trigger_error('Class <b>' . $class . '</b> does not exist<br />Handler Name: ' . $name, E_USER_ERROR); |
|
| 750 | - } |
|
| 751 | - if (isset ($handlers[$name])) { |
|
| 752 | - return $handlers[$name]; |
|
| 753 | - } |
|
| 754 | - $inst = false; |
|
| 737 | + static $handlers; |
|
| 738 | + $name = strtolower(trim($name)); |
|
| 739 | + if (!isset ($handlers[$name])) { |
|
| 740 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 741 | + require_once $hnd_file; |
|
| 742 | + } |
|
| 743 | + $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 744 | + if (class_exists($class)) { |
|
| 745 | + $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops'); |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + if (!isset ($handlers[$name]) && !$optional) { |
|
| 749 | + trigger_error('Class <b>' . $class . '</b> does not exist<br />Handler Name: ' . $name, E_USER_ERROR); |
|
| 750 | + } |
|
| 751 | + if (isset ($handlers[$name])) { |
|
| 752 | + return $handlers[$name]; |
|
| 753 | + } |
|
| 754 | + $inst = false; |
|
| 755 | 755 | } |
| 756 | 756 | function smart_sanitizeAdsenses_callback($matches) { |
| 757 | - global $smartobject_adsense_handler; |
|
| 758 | - if (isset($smartobject_adsense_handler->objects[$matches[1]])){ |
|
| 759 | - $adsenseObj = $smartobject_adsense_handler->objects[$matches[1]]; |
|
| 760 | - $ret = $adsenseObj->render(); |
|
| 761 | - return $ret; |
|
| 762 | - } else { |
|
| 763 | - return ''; |
|
| 764 | - } |
|
| 757 | + global $smartobject_adsense_handler; |
|
| 758 | + if (isset($smartobject_adsense_handler->objects[$matches[1]])){ |
|
| 759 | + $adsenseObj = $smartobject_adsense_handler->objects[$matches[1]]; |
|
| 760 | + $ret = $adsenseObj->render(); |
|
| 761 | + return $ret; |
|
| 762 | + } else { |
|
| 763 | + return ''; |
|
| 764 | + } |
|
| 765 | 765 | } |
| 766 | 766 | function smart_sanitizeAdsenses($text) { |
| 767 | 767 | |
| 768 | - $patterns = array (); |
|
| 769 | - $replacements = array (); |
|
| 768 | + $patterns = array (); |
|
| 769 | + $replacements = array (); |
|
| 770 | 770 | |
| 771 | - $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 772 | - $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 773 | - return $text; |
|
| 771 | + $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 772 | + $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 773 | + return $text; |
|
| 774 | 774 | } |
| 775 | 775 | function smart_sanitizeCustomtags_callback($matches) { |
| 776 | - global $smartobject_customtag_handler; |
|
| 777 | - if (isset($smartobject_customtag_handler->objects[$matches[1]])){ |
|
| 778 | - $customObj = $smartobject_customtag_handler->objects[$matches[1]]; |
|
| 779 | - $ret = $customObj->renderWithPhp(); |
|
| 780 | - return $ret; |
|
| 781 | - } else { |
|
| 782 | - return ''; |
|
| 783 | - } |
|
| 776 | + global $smartobject_customtag_handler; |
|
| 777 | + if (isset($smartobject_customtag_handler->objects[$matches[1]])){ |
|
| 778 | + $customObj = $smartobject_customtag_handler->objects[$matches[1]]; |
|
| 779 | + $ret = $customObj->renderWithPhp(); |
|
| 780 | + return $ret; |
|
| 781 | + } else { |
|
| 782 | + return ''; |
|
| 783 | + } |
|
| 784 | 784 | } |
| 785 | 785 | function smart_sanitizeCustomtags($text) { |
| 786 | - $patterns = array (); |
|
| 787 | - $replacements = array (); |
|
| 786 | + $patterns = array (); |
|
| 787 | + $replacements = array (); |
|
| 788 | 788 | |
| 789 | - $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 790 | - $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 791 | - return $text; |
|
| 789 | + $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 790 | + $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 791 | + return $text; |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | function smart_loadLanguageFile($module, $file) { |
| 795 | - global $xoopsConfig; |
|
| 795 | + global $xoopsConfig; |
|
| 796 | 796 | |
| 797 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 798 | - if (!file_exists($filename)) { |
|
| 799 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 800 | - } |
|
| 801 | - if (file_exists($filename)) { |
|
| 802 | - include_once($filename); |
|
| 803 | - } |
|
| 797 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 798 | + if (!file_exists($filename)) { |
|
| 799 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 800 | + } |
|
| 801 | + if (file_exists($filename)) { |
|
| 802 | + include_once($filename); |
|
| 803 | + } |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | function smart_loadCommonLanguageFile() { |
| 807 | - smart_loadLanguageFile('smartobject', 'common'); |
|
| 807 | + smart_loadLanguageFile('smartobject', 'common'); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | function smart_purifyText($text, $keyword = false) |
| 811 | 811 | { |
| 812 | - global $myts; |
|
| 813 | - $text = str_replace(' ', ' ', $text); |
|
| 814 | - $text = str_replace('<br />', ' ', $text); |
|
| 815 | - $text = str_replace('<br/>', ' ', $text); |
|
| 816 | - $text = str_replace('<br', ' ', $text); |
|
| 817 | - $text = strip_tags($text); |
|
| 818 | - $text = html_entity_decode($text); |
|
| 819 | - $text = $myts->undoHtmlSpecialChars($text); |
|
| 820 | - $text = str_replace(')', ' ', $text); |
|
| 821 | - $text = str_replace('(', ' ', $text); |
|
| 822 | - $text = str_replace(':', ' ', $text); |
|
| 823 | - $text = str_replace('&euro', ' euro ', $text); |
|
| 824 | - $text = str_replace('&hellip', '...', $text); |
|
| 825 | - $text = str_replace('&rsquo', ' ', $text); |
|
| 826 | - $text = str_replace('!', ' ', $text); |
|
| 827 | - $text = str_replace('?', ' ', $text); |
|
| 828 | - $text = str_replace('"', ' ', $text); |
|
| 829 | - $text = str_replace('-', ' ', $text); |
|
| 830 | - $text = str_replace('\n', ' ', $text); |
|
| 831 | - $text = str_replace('―', ' ', $text); |
|
| 832 | - |
|
| 833 | - if ($keyword){ |
|
| 834 | - $text = str_replace('.', ' ', $text); |
|
| 835 | - $text = str_replace(',', ' ', $text); |
|
| 836 | - $text = str_replace('\'', ' ', $text); |
|
| 837 | - } |
|
| 838 | - $text = str_replace(';', ' ', $text); |
|
| 839 | - |
|
| 840 | - return $text; |
|
| 812 | + global $myts; |
|
| 813 | + $text = str_replace(' ', ' ', $text); |
|
| 814 | + $text = str_replace('<br />', ' ', $text); |
|
| 815 | + $text = str_replace('<br/>', ' ', $text); |
|
| 816 | + $text = str_replace('<br', ' ', $text); |
|
| 817 | + $text = strip_tags($text); |
|
| 818 | + $text = html_entity_decode($text); |
|
| 819 | + $text = $myts->undoHtmlSpecialChars($text); |
|
| 820 | + $text = str_replace(')', ' ', $text); |
|
| 821 | + $text = str_replace('(', ' ', $text); |
|
| 822 | + $text = str_replace(':', ' ', $text); |
|
| 823 | + $text = str_replace('&euro', ' euro ', $text); |
|
| 824 | + $text = str_replace('&hellip', '...', $text); |
|
| 825 | + $text = str_replace('&rsquo', ' ', $text); |
|
| 826 | + $text = str_replace('!', ' ', $text); |
|
| 827 | + $text = str_replace('?', ' ', $text); |
|
| 828 | + $text = str_replace('"', ' ', $text); |
|
| 829 | + $text = str_replace('-', ' ', $text); |
|
| 830 | + $text = str_replace('\n', ' ', $text); |
|
| 831 | + $text = str_replace('―', ' ', $text); |
|
| 832 | + |
|
| 833 | + if ($keyword){ |
|
| 834 | + $text = str_replace('.', ' ', $text); |
|
| 835 | + $text = str_replace(',', ' ', $text); |
|
| 836 | + $text = str_replace('\'', ' ', $text); |
|
| 837 | + } |
|
| 838 | + $text = str_replace(';', ' ', $text); |
|
| 839 | + |
|
| 840 | + return $text; |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | function smart_html2text($document) |
| 844 | 844 | { |
| 845 | - // PHP Manual:: function preg_replace |
|
| 846 | - // $document should contain an HTML document. |
|
| 847 | - // This will remove HTML tags, javascript sections |
|
| 848 | - // and white space. It will also convert some |
|
| 849 | - // common HTML entities to their text equivalent. |
|
| 850 | - // Credits : newbb2 |
|
| 851 | - $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 845 | + // PHP Manual:: function preg_replace |
|
| 846 | + // $document should contain an HTML document. |
|
| 847 | + // This will remove HTML tags, javascript sections |
|
| 848 | + // and white space. It will also convert some |
|
| 849 | + // common HTML entities to their text equivalent. |
|
| 850 | + // Credits : newbb2 |
|
| 851 | + $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 852 | 852 | "'<img.*?/>'si", // Strip out img tags |
| 853 | 853 | "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
| 854 | 854 | "'([\r\n])[\s]+'", // Strip out white space |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | "'&(copy|#169);'i", |
| 864 | 864 | "'&#(\d+);'e"); // evaluate as php |
| 865 | 865 | |
| 866 | - $replace = array ("", |
|
| 866 | + $replace = array ("", |
|
| 867 | 867 | "", |
| 868 | 868 | "", |
| 869 | 869 | "\\1", |
@@ -872,14 +872,14 @@ discard block |
||
| 872 | 872 | "<", |
| 873 | 873 | ">", |
| 874 | 874 | " ", |
| 875 | - chr(161), |
|
| 876 | - chr(162), |
|
| 877 | - chr(163), |
|
| 878 | - chr(169), |
|
| 875 | + chr(161), |
|
| 876 | + chr(162), |
|
| 877 | + chr(163), |
|
| 878 | + chr(169), |
|
| 879 | 879 | "chr(\\1)"); |
| 880 | 880 | |
| 881 | - $text = preg_replace($search, $replace, $document); |
|
| 882 | - return $text; |
|
| 881 | + $text = preg_replace($search, $replace, $document); |
|
| 882 | + return $text; |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | /** |
@@ -889,91 +889,91 @@ discard block |
||
| 889 | 889 | * This function should be able to cover almost all floats that appear in an european environment. |
| 890 | 890 | */ |
| 891 | 891 | function smart_getfloat($str, $set=FALSE){ |
| 892 | - if(preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 893 | - // Found number in $str, so set $str that number |
|
| 894 | - $str = $match[0]; |
|
| 895 | - if(strstr($str, ',')){ |
|
| 896 | - // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 897 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 898 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 899 | - return floatval($str); |
|
| 900 | - }else{ |
|
| 901 | - // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 902 | - if(preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE){ |
|
| 903 | - // Treat single dot as decimal separator |
|
| 904 | - |
|
| 905 | - return floatval($str); |
|
| 906 | - } else {//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br/><br/> "; |
|
| 907 | - // Else, treat all dots as thousand seps |
|
| 908 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 909 | - return floatval($str); |
|
| 910 | - } |
|
| 911 | - } |
|
| 912 | - }else{ |
|
| 913 | - // No number found, return zero |
|
| 914 | - return 0; |
|
| 915 | - } |
|
| 892 | + if(preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 893 | + // Found number in $str, so set $str that number |
|
| 894 | + $str = $match[0]; |
|
| 895 | + if(strstr($str, ',')){ |
|
| 896 | + // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 897 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 898 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 899 | + return floatval($str); |
|
| 900 | + }else{ |
|
| 901 | + // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 902 | + if(preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE){ |
|
| 903 | + // Treat single dot as decimal separator |
|
| 904 | + |
|
| 905 | + return floatval($str); |
|
| 906 | + } else {//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br/><br/> "; |
|
| 907 | + // Else, treat all dots as thousand seps |
|
| 908 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 909 | + return floatval($str); |
|
| 910 | + } |
|
| 911 | + } |
|
| 912 | + }else{ |
|
| 913 | + // No number found, return zero |
|
| 914 | + return 0; |
|
| 915 | + } |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | function smart_currency($var, $currencyObj=false) { |
| 919 | - $ret = smart_getfloat($var, array('single_dot_as_decimal'=> TRUE)); |
|
| 920 | - $ret = round($ret, 2); |
|
| 921 | - // make sur we have at least .00 in the $var |
|
| 922 | - $decimal_section_original = strstr($ret, '.'); |
|
| 923 | - $decimal_section = $decimal_section_original; |
|
| 924 | - if ($decimal_section) { |
|
| 925 | - if (strlen($decimal_section) == 1) { |
|
| 926 | - $decimal_section = '.00'; |
|
| 927 | - } elseif(strlen($decimal_section) == 2) { |
|
| 928 | - $decimal_section = $decimal_section . '0'; |
|
| 929 | - } |
|
| 930 | - $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 931 | - } else { |
|
| 932 | - $ret = $ret . '.00'; |
|
| 933 | - } |
|
| 934 | - if ($currencyObj) { |
|
| 935 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 936 | - } |
|
| 919 | + $ret = smart_getfloat($var, array('single_dot_as_decimal'=> TRUE)); |
|
| 920 | + $ret = round($ret, 2); |
|
| 921 | + // make sur we have at least .00 in the $var |
|
| 922 | + $decimal_section_original = strstr($ret, '.'); |
|
| 923 | + $decimal_section = $decimal_section_original; |
|
| 924 | + if ($decimal_section) { |
|
| 925 | + if (strlen($decimal_section) == 1) { |
|
| 926 | + $decimal_section = '.00'; |
|
| 927 | + } elseif(strlen($decimal_section) == 2) { |
|
| 928 | + $decimal_section = $decimal_section . '0'; |
|
| 929 | + } |
|
| 930 | + $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 931 | + } else { |
|
| 932 | + $ret = $ret . '.00'; |
|
| 933 | + } |
|
| 934 | + if ($currencyObj) { |
|
| 935 | + $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 936 | + } |
|
| 937 | 937 | return $ret; |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | function smart_float($var) { |
| 941 | - return smart_currency($var); |
|
| 941 | + return smart_currency($var); |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | function smart_getModuleAdminLink($moduleName=false) { |
| 945 | - global $xoopsModule; |
|
| 946 | - if (!$moduleName && (isset ($xoopsModule) && is_object($xoopsModule))) { |
|
| 947 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 948 | - } |
|
| 949 | - $ret = ''; |
|
| 950 | - if ($moduleName) { |
|
| 951 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" ._CO_SOBJECT_ADMIN_PAGE . "</a>"; |
|
| 952 | - } |
|
| 953 | - return $ret; |
|
| 945 | + global $xoopsModule; |
|
| 946 | + if (!$moduleName && (isset ($xoopsModule) && is_object($xoopsModule))) { |
|
| 947 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 948 | + } |
|
| 949 | + $ret = ''; |
|
| 950 | + if ($moduleName) { |
|
| 951 | + $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" ._CO_SOBJECT_ADMIN_PAGE . "</a>"; |
|
| 952 | + } |
|
| 953 | + return $ret; |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | function smart_getEditors() { |
| 957 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 958 | - if (!file_exists($filename)) { |
|
| 959 | - return false; |
|
| 960 | - } |
|
| 961 | - include_once $filename; |
|
| 962 | - $xoopseditor_handler = XoopsEditorHandler::getInstance(); |
|
| 963 | - $aList = $xoopseditor_handler->getList(); |
|
| 964 | - $ret = array(); |
|
| 965 | - foreach($aList as $k=>$v) { |
|
| 966 | - $ret[$v] = $k; |
|
| 967 | - } |
|
| 968 | - return $ret; |
|
| 957 | + $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 958 | + if (!file_exists($filename)) { |
|
| 959 | + return false; |
|
| 960 | + } |
|
| 961 | + include_once $filename; |
|
| 962 | + $xoopseditor_handler = XoopsEditorHandler::getInstance(); |
|
| 963 | + $aList = $xoopseditor_handler->getList(); |
|
| 964 | + $ret = array(); |
|
| 965 | + foreach($aList as $k=>$v) { |
|
| 966 | + $ret[$v] = $k; |
|
| 967 | + } |
|
| 968 | + return $ret; |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | function smart_getTablesArray($moduleName, $items) { |
| 972 | - $ret = array(); |
|
| 973 | - foreach ($items as $item) { |
|
| 974 | - $ret[] = $moduleName . '_' . $item; |
|
| 975 | - } |
|
| 976 | - $ret[] = $moduleName . '_meta'; |
|
| 977 | - return $ret; |
|
| 972 | + $ret = array(); |
|
| 973 | + foreach ($items as $item) { |
|
| 974 | + $ret[] = $moduleName . '_' . $item; |
|
| 975 | + } |
|
| 976 | + $ret[] = $moduleName . '_meta'; |
|
| 977 | + return $ret; |
|
| 978 | 978 | } |
| 979 | 979 | ?> |
| 980 | 980 | \ No newline at end of file |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | //Verifies that a MySQL table exists |
| 156 | 156 | $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection(); |
| 157 | 157 | $realname = $xoopsDB->prefix($table); |
| 158 | - $sql = "SHOW TABLES FROM ".XOOPS_DB_NAME; |
|
| 158 | + $sql = "SHOW TABLES FROM " . XOOPS_DB_NAME; |
|
| 159 | 159 | $ret = $xoopsDB->queryF($sql); |
| 160 | 160 | while (list ($m_table) = $xoopsDB->fetchRow($ret)) { |
| 161 | 161 | if ($m_table == $realname) { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | // truncate the original string to a length of $length |
| 238 | 238 | // minus the position of the last space |
| 239 | 239 | // plus the length of the $trimmarker |
| 240 | - $truncated_string = xoops_substr($str, $start, $length - $position_of_space +strlen($trimmarker), $trimmarker); |
|
| 240 | + $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 241 | 241 | return $truncated_string; |
| 242 | 242 | } |
| 243 | 243 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') { |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | $attr = " width='$width' height='$height'"; |
| 341 | 341 | } |
| 342 | - return array ( |
|
| 342 | + return array( |
|
| 343 | 343 | $width, |
| 344 | 344 | $height, |
| 345 | 345 | $type, |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | function &smart_getModuleInfo($moduleName = false) { |
| 350 | 350 | static $smartModules; |
| 351 | 351 | if (isset ($smartModules[$moduleName])) { |
| 352 | - $ret =& $smartModules[$moduleName]; |
|
| 352 | + $ret = & $smartModules[$moduleName]; |
|
| 353 | 353 | return $ret; |
| 354 | 354 | } |
| 355 | 355 | global $xoopsModule; |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | return unlink($dirname); |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | -function smart_formatErrors($errors = array ()) { |
|
| 414 | +function smart_formatErrors($errors = array()) { |
|
| 415 | 415 | $ret = ''; |
| 416 | 416 | foreach ($errors as $key => $value) { |
| 417 | 417 | $ret .= "<br /> - " . $value; |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | * @param integer $name : 0 Use Usenamer 1 Use realname |
| 426 | 426 | * @return |
| 427 | 427 | */ |
| 428 | -function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array (), $withContact = false) { |
|
| 428 | +function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false) { |
|
| 429 | 429 | if (!is_numeric($userid)) { |
| 430 | 430 | return $userid; |
| 431 | 431 | } |
| 432 | 432 | $userid = intval($userid); |
| 433 | 433 | if ($userid > 0) { |
| 434 | - if ($users == array ()) { |
|
| 434 | + if ($users == array()) { |
|
| 435 | 435 | //fetching users |
| 436 | 436 | $member_handler = & xoops_gethandler('member'); |
| 437 | 437 | $user = & $member_handler->getUser($userid); |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | $adminmenu = array(); |
| 483 | 483 | include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
| 484 | 484 | $tpl = new XoopsTpl(); |
| 485 | - $tpl->assign(array ( |
|
| 485 | + $tpl->assign(array( |
|
| 486 | 486 | 'headermenu' => $headermenu, |
| 487 | 487 | 'adminmenu' => $adminmenu, |
| 488 | 488 | 'current' => $currentoption, |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | $querystring = '?' . $querystring; |
| 588 | 588 | } |
| 589 | 589 | $currenturl = $http . $httphost . $phpself . $querystring; |
| 590 | - $urls = array (); |
|
| 590 | + $urls = array(); |
|
| 591 | 591 | $urls['http'] = $http; |
| 592 | 592 | $urls['httphost'] = $httphost; |
| 593 | 593 | $urls['phpself'] = $phpself; |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | elseif (!empty ($height)) { |
| 715 | 715 | $width = $dimension[0] * $height / $dimension[1]; |
| 716 | 716 | } else { |
| 717 | - list ($width, $height) = array ( |
|
| 717 | + list ($width, $height) = array( |
|
| 718 | 718 | $dimension[0], |
| 719 | 719 | $dimension[1] |
| 720 | 720 | ); |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | } |
| 743 | 743 | $class = 'Xoops' . ucfirst($name) . 'Handler'; |
| 744 | 744 | if (class_exists($class)) { |
| 745 | - $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops'); |
|
| 745 | + $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 746 | 746 | } |
| 747 | 747 | } |
| 748 | 748 | if (!isset ($handlers[$name]) && !$optional) { |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | } |
| 756 | 756 | function smart_sanitizeAdsenses_callback($matches) { |
| 757 | 757 | global $smartobject_adsense_handler; |
| 758 | - if (isset($smartobject_adsense_handler->objects[$matches[1]])){ |
|
| 758 | + if (isset($smartobject_adsense_handler->objects[$matches[1]])) { |
|
| 759 | 759 | $adsenseObj = $smartobject_adsense_handler->objects[$matches[1]]; |
| 760 | 760 | $ret = $adsenseObj->render(); |
| 761 | 761 | return $ret; |
@@ -765,8 +765,8 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | function smart_sanitizeAdsenses($text) { |
| 767 | 767 | |
| 768 | - $patterns = array (); |
|
| 769 | - $replacements = array (); |
|
| 768 | + $patterns = array(); |
|
| 769 | + $replacements = array(); |
|
| 770 | 770 | |
| 771 | 771 | $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
| 772 | 772 | $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | function smart_sanitizeCustomtags_callback($matches) { |
| 776 | 776 | global $smartobject_customtag_handler; |
| 777 | - if (isset($smartobject_customtag_handler->objects[$matches[1]])){ |
|
| 777 | + if (isset($smartobject_customtag_handler->objects[$matches[1]])) { |
|
| 778 | 778 | $customObj = $smartobject_customtag_handler->objects[$matches[1]]; |
| 779 | 779 | $ret = $customObj->renderWithPhp(); |
| 780 | 780 | return $ret; |
@@ -783,8 +783,8 @@ discard block |
||
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | 785 | function smart_sanitizeCustomtags($text) { |
| 786 | - $patterns = array (); |
|
| 787 | - $replacements = array (); |
|
| 786 | + $patterns = array(); |
|
| 787 | + $replacements = array(); |
|
| 788 | 788 | |
| 789 | 789 | $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
| 790 | 790 | $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | $text = str_replace('\n', ' ', $text); |
| 831 | 831 | $text = str_replace('―', ' ', $text); |
| 832 | 832 | |
| 833 | - if ($keyword){ |
|
| 833 | + if ($keyword) { |
|
| 834 | 834 | $text = str_replace('.', ' ', $text); |
| 835 | 835 | $text = str_replace(',', ' ', $text); |
| 836 | 836 | $text = str_replace('\'', ' ', $text); |
@@ -848,11 +848,11 @@ discard block |
||
| 848 | 848 | // and white space. It will also convert some |
| 849 | 849 | // common HTML entities to their text equivalent. |
| 850 | 850 | // Credits : newbb2 |
| 851 | - $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 852 | - "'<img.*?/>'si", // Strip out img tags |
|
| 853 | - "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 854 | - "'([\r\n])[\s]+'", // Strip out white space |
|
| 855 | - "'&(quot|#34);'i", // Replace HTML entities |
|
| 851 | + $search = array("'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 852 | + "'<img.*?/>'si", // Strip out img tags |
|
| 853 | + "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 854 | + "'([\r\n])[\s]+'", // Strip out white space |
|
| 855 | + "'&(quot|#34);'i", // Replace HTML entities |
|
| 856 | 856 | "'&(amp|#38);'i", |
| 857 | 857 | "'&(lt|#60);'i", |
| 858 | 858 | "'&(gt|#62);'i", |
@@ -861,9 +861,9 @@ discard block |
||
| 861 | 861 | "'&(cent|#162);'i", |
| 862 | 862 | "'&(pound|#163);'i", |
| 863 | 863 | "'&(copy|#169);'i", |
| 864 | - "'&#(\d+);'e"); // evaluate as php |
|
| 864 | + "'&#(\d+);'e"); // evaluate as php |
|
| 865 | 865 | |
| 866 | - $replace = array ("", |
|
| 866 | + $replace = array("", |
|
| 867 | 867 | "", |
| 868 | 868 | "", |
| 869 | 869 | "\\1", |
@@ -888,35 +888,35 @@ discard block |
||
| 888 | 888 | * Use this snippet to extract any float out of a string. You can choose how a single dot is treated with the (bool) 'single_dot_as_decimal' directive. |
| 889 | 889 | * This function should be able to cover almost all floats that appear in an european environment. |
| 890 | 890 | */ |
| 891 | -function smart_getfloat($str, $set=FALSE){ |
|
| 892 | - if(preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 891 | +function smart_getfloat($str, $set = FALSE) { |
|
| 892 | + if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 893 | 893 | // Found number in $str, so set $str that number |
| 894 | 894 | $str = $match[0]; |
| 895 | - if(strstr($str, ',')){ |
|
| 895 | + if (strstr($str, ',')) { |
|
| 896 | 896 | // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
| 897 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 898 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 897 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 898 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 899 | 899 | return floatval($str); |
| 900 | - }else{ |
|
| 900 | + } else { |
|
| 901 | 901 | // No comma exists, so we have to decide, how a single dot shall be treated |
| 902 | - if(preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE){ |
|
| 902 | + if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE) { |
|
| 903 | 903 | // Treat single dot as decimal separator |
| 904 | 904 | |
| 905 | 905 | return floatval($str); |
| 906 | 906 | } else {//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br/><br/> "; |
| 907 | 907 | // Else, treat all dots as thousand seps |
| 908 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 908 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 909 | 909 | return floatval($str); |
| 910 | 910 | } |
| 911 | 911 | } |
| 912 | - }else{ |
|
| 912 | + } else { |
|
| 913 | 913 | // No number found, return zero |
| 914 | 914 | return 0; |
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | -function smart_currency($var, $currencyObj=false) { |
|
| 919 | - $ret = smart_getfloat($var, array('single_dot_as_decimal'=> TRUE)); |
|
| 918 | +function smart_currency($var, $currencyObj = false) { |
|
| 919 | + $ret = smart_getfloat($var, array('single_dot_as_decimal'=> TRUE)); |
|
| 920 | 920 | $ret = round($ret, 2); |
| 921 | 921 | // make sur we have at least .00 in the $var |
| 922 | 922 | $decimal_section_original = strstr($ret, '.'); |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | if ($decimal_section) { |
| 925 | 925 | if (strlen($decimal_section) == 1) { |
| 926 | 926 | $decimal_section = '.00'; |
| 927 | - } elseif(strlen($decimal_section) == 2) { |
|
| 927 | + } elseif (strlen($decimal_section) == 2) { |
|
| 928 | 928 | $decimal_section = $decimal_section . '0'; |
| 929 | 929 | } |
| 930 | 930 | $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
@@ -941,14 +941,14 @@ discard block |
||
| 941 | 941 | return smart_currency($var); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | -function smart_getModuleAdminLink($moduleName=false) { |
|
| 944 | +function smart_getModuleAdminLink($moduleName = false) { |
|
| 945 | 945 | global $xoopsModule; |
| 946 | 946 | if (!$moduleName && (isset ($xoopsModule) && is_object($xoopsModule))) { |
| 947 | 947 | $moduleName = $xoopsModule->getVar('dirname'); |
| 948 | 948 | } |
| 949 | 949 | $ret = ''; |
| 950 | 950 | if ($moduleName) { |
| 951 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" ._CO_SOBJECT_ADMIN_PAGE . "</a>"; |
|
| 951 | + $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . "</a>"; |
|
| 952 | 952 | } |
| 953 | 953 | return $ret; |
| 954 | 954 | } |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | $xoopseditor_handler = XoopsEditorHandler::getInstance(); |
| 963 | 963 | $aList = $xoopseditor_handler->getList(); |
| 964 | 964 | $ret = array(); |
| 965 | - foreach($aList as $k=>$v) { |
|
| 965 | + foreach ($aList as $k=>$v) { |
|
| 966 | 966 | $ret[$v] = $k; |
| 967 | 967 | } |
| 968 | 968 | return $ret; |
@@ -710,8 +710,7 @@ discard block |
||
| 710 | 710 | } |
| 711 | 711 | if (!empty ($width)) { |
| 712 | 712 | $height = $dimension[1] * $width / $dimension[0]; |
| 713 | - } |
|
| 714 | - elseif (!empty ($height)) { |
|
| 713 | + } elseif (!empty ($height)) { |
|
| 715 | 714 | $width = $dimension[0] * $height / $dimension[1]; |
| 716 | 715 | } else { |
| 717 | 716 | list ($width, $height) = array ( |
@@ -897,7 +896,7 @@ discard block |
||
| 897 | 896 | $str = str_replace('.', '', $str); // Erase thousand seps |
| 898 | 897 | $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
| 899 | 898 | return floatval($str); |
| 900 | - }else{ |
|
| 899 | + } else{ |
|
| 901 | 900 | // No comma exists, so we have to decide, how a single dot shall be treated |
| 902 | 901 | if(preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == TRUE && $set['single_dot_as_decimal'] == TRUE){ |
| 903 | 902 | // Treat single dot as decimal separator |
@@ -909,7 +908,7 @@ discard block |
||
| 909 | 908 | return floatval($str); |
| 910 | 909 | } |
| 911 | 910 | } |
| 912 | - }else{ |
|
| 911 | + } else{ |
|
| 913 | 912 | // No number found, return zero |
| 914 | 913 | return 0; |
| 915 | 914 | } |
@@ -23,18 +23,18 @@ discard block |
||
| 23 | 23 | $dbupdater = new WfdownloadsDbupdater(); |
| 24 | 24 | |
| 25 | 25 | if (!wfdownloads_TableExists('wfdownloads_meta')) { |
| 26 | - // Create table wfdownloads_meta |
|
| 27 | - $table = new WfdownloadsTable('wfdownloads_meta'); |
|
| 28 | - $table->setStructure( "CREATE TABLE %s ( |
|
| 26 | + // Create table wfdownloads_meta |
|
| 27 | + $table = new WfdownloadsTable('wfdownloads_meta'); |
|
| 28 | + $table->setStructure( "CREATE TABLE %s ( |
|
| 29 | 29 | metakey varchar(50) NOT NULL default '', |
| 30 | 30 | metavalue varchar(255) NOT NULL default '', |
| 31 | 31 | PRIMARY KEY (metakey)) |
| 32 | 32 | ENGINE=MyISAM;"); |
| 33 | 33 | |
| 34 | - $table->setData(sprintf("'version', %s", round($GLOBALS['xoopsModule']->getVar('version') / 100, 2))); |
|
| 35 | - if ($dbupdater->updateTable($table)) { |
|
| 36 | - echo "wfdownloads_meta table created<br />"; |
|
| 37 | - } |
|
| 34 | + $table->setData(sprintf("'version', %s", round($GLOBALS['xoopsModule']->getVar('version') / 100, 2))); |
|
| 35 | + if ($dbupdater->updateTable($table)) { |
|
| 36 | + echo "wfdownloads_meta table created<br />"; |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $download_fields = array( |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | $download_table = new WfdownloadsTable("wfdownloads_downloads"); |
| 86 | 86 | $fields = get_table_info($download_handler->table, $download_fields); |
| 87 | 87 | // Check for renamed fields |
| 88 | - rename_fields($download_table, $renamed_fields, $fields, $download_fields); |
|
| 88 | + rename_fields($download_table, $renamed_fields, $fields, $download_fields); |
|
| 89 | 89 | update_table($download_fields, $fields, $download_table); |
| 90 | - if ($dbupdater->updateTable($download_table)) { |
|
| 91 | - echo "Downloads table updated<br />"; |
|
| 92 | - } |
|
| 90 | + if ($dbupdater->updateTable($download_table)) { |
|
| 91 | + echo "Downloads table updated<br />"; |
|
| 92 | + } |
|
| 93 | 93 | unset($fields); |
| 94 | 94 | |
| 95 | 95 | $mod_fields = array( |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | rename_fields($mod_table, $renamed_fields, $fields, $mod_fields); |
| 144 | 144 | update_table($mod_fields, $fields, $mod_table); |
| 145 | 145 | if ($dbupdater->updateTable($mod_table)) { |
| 146 | - echo "Modified Downloads table updated <br />"; |
|
| 146 | + echo "Modified Downloads table updated <br />"; |
|
| 147 | 147 | } |
| 148 | 148 | unset($fields); |
| 149 | 149 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $fields = get_table_info($cat_handler->table, $cat_fields); |
| 172 | 172 | update_table($cat_fields, $fields, $cat_table); |
| 173 | 173 | if ($dbupdater->updateTable($cat_table)) { |
| 174 | - echo "Category table updated<br />"; |
|
| 174 | + echo "Category table updated<br />"; |
|
| 175 | 175 | } |
| 176 | 176 | unset($fields); |
| 177 | 177 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $fields = get_table_info($broken_handler->table, $broken_fields); |
| 191 | 191 | update_table($broken_fields, $fields, $broken_table); |
| 192 | 192 | if ($dbupdater->updateTable($broken_table)) { |
| 193 | - echo "Broken Reports table updated<br />"; |
|
| 193 | + echo "Broken Reports table updated<br />"; |
|
| 194 | 194 | } |
| 195 | 195 | unset($fields); |
| 196 | 196 | } |
@@ -202,31 +202,31 @@ discard block |
||
| 202 | 202 | // ========================================================================================= |
| 203 | 203 | function invert_nohtm_dohtml_values() |
| 204 | 204 | { |
| 205 | - $ret = array(); |
|
| 205 | + $ret = array(); |
|
| 206 | 206 | global $xoopsDB; |
| 207 | 207 | $cat_handler = xoops_getmodulehandler('category', 'wfdownloads'); |
| 208 | 208 | $result = $xoopsDB->query("SHOW COLUMNS FROM ".$cat_handler->table); |
| 209 | 209 | while ($existing_field = $xoopsDB->fetchArray($result)) { |
| 210 | - $fields[$existing_field['field']] = $existing_field['type']; |
|
| 210 | + $fields[$existing_field['field']] = $existing_field['type']; |
|
| 211 | 211 | } |
| 212 | 212 | if (in_array("nohtml", array_keys($fields))) { |
| 213 | - $dbupdater = new WfdownloadsDbupdater(); |
|
| 213 | + $dbupdater = new WfdownloadsDbupdater(); |
|
| 214 | 214 | //Invert column values |
| 215 | - // alter options in wfdownloads_cat |
|
| 216 | - $table = new WfdownloadsTable('wfdownloads_cat'); |
|
| 217 | - $table->addAlteredField('nohtml', "dohtml tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 218 | - $table->addAlteredField('nosmiley', "dosmiley tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 219 | - $table->addAlteredField('noxcodes', "doxcode tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 220 | - $table->addAlteredField('noimages', "doimage tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 221 | - $table->addAlteredField('nobreak', "dobr tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 215 | + // alter options in wfdownloads_cat |
|
| 216 | + $table = new WfdownloadsTable('wfdownloads_cat'); |
|
| 217 | + $table->addAlteredField('nohtml', "dohtml tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 218 | + $table->addAlteredField('nosmiley', "dosmiley tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 219 | + $table->addAlteredField('noxcodes', "doxcode tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 220 | + $table->addAlteredField('noimages', "doimage tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 221 | + $table->addAlteredField('nobreak', "dobr tinyint(1) NOT NULL DEFAULT '1'"); |
|
| 222 | 222 | |
| 223 | - //inverting values no=1 <=> do=0 |
|
| 224 | - // have to store teporarly as value = 2 to |
|
| 225 | - // avoid putting everithing to same value |
|
| 226 | - // if you change 1 to 0, then 0 to one, |
|
| 227 | - // every value will be 1, follow me? |
|
| 228 | - $table->addUpdatedWhere('dohtml', 2,'=1'); |
|
| 229 | - $table->addUpdatedWhere('dohtml', 1,'=0'); |
|
| 223 | + //inverting values no=1 <=> do=0 |
|
| 224 | + // have to store teporarly as value = 2 to |
|
| 225 | + // avoid putting everithing to same value |
|
| 226 | + // if you change 1 to 0, then 0 to one, |
|
| 227 | + // every value will be 1, follow me? |
|
| 228 | + $table->addUpdatedWhere('dohtml', 2,'=1'); |
|
| 229 | + $table->addUpdatedWhere('dohtml', 1,'=0'); |
|
| 230 | 230 | $table->addUpdatedWhere('dohtml', 0,'=2'); |
| 231 | 231 | |
| 232 | 232 | $table->addUpdatedWhere('dosmiley', 2,'=1'); |
@@ -254,22 +254,22 @@ discard block |
||
| 254 | 254 | * @return void |
| 255 | 255 | */ |
| 256 | 256 | function update_table($new_fields, $existing_fields, &$table) { |
| 257 | - foreach ($new_fields as $field => $fieldinfo) { |
|
| 258 | - $type = $fieldinfo["Type"]; |
|
| 259 | - if (!in_array($field, array_keys($existing_fields) ) ) { |
|
| 260 | - //Add field as it is missing |
|
| 261 | - $table->addNewField($field, $type); |
|
| 262 | - //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type); |
|
| 263 | - //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br />"; |
|
| 257 | + foreach ($new_fields as $field => $fieldinfo) { |
|
| 258 | + $type = $fieldinfo["Type"]; |
|
| 259 | + if (!in_array($field, array_keys($existing_fields) ) ) { |
|
| 260 | + //Add field as it is missing |
|
| 261 | + $table->addNewField($field, $type); |
|
| 262 | + //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type); |
|
| 263 | + //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br />"; |
|
| 264 | 264 | } |
| 265 | 265 | elseif ($existing_fields[$field] != $type) { |
| 266 | - $table->addAlteredField($field, $field." ".$type); |
|
| 267 | - // check $fields[$field]['type'] for things like "int(10) unsigned" |
|
| 268 | - //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type); |
|
| 269 | - //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br />"; |
|
| 266 | + $table->addAlteredField($field, $field." ".$type); |
|
| 267 | + // check $fields[$field]['type'] for things like "int(10) unsigned" |
|
| 268 | + //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type); |
|
| 269 | + //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br />"; |
|
| 270 | 270 | } |
| 271 | 271 | else { |
| 272 | - //echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br />"; |
|
| 272 | + //echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br />"; |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | } |
@@ -283,19 +283,19 @@ discard block |
||
| 283 | 283 | * @return array |
| 284 | 284 | */ |
| 285 | 285 | function get_table_info($table, $default_fields) { |
| 286 | - global $xoopsDB; |
|
| 286 | + global $xoopsDB; |
|
| 287 | 287 | $result = $xoopsDB->query("SHOW COLUMNS FROM ".$table); |
| 288 | 288 | while ($existing_field = $xoopsDB->fetchArray($result)) { |
| 289 | - $fields[$existing_field['Field']] = $existing_field['Type']; |
|
| 290 | - if ($existing_field['Null'] != "YES") { |
|
| 291 | - $fields[$existing_field['Field']] .= " NOT NULL"; |
|
| 292 | - } |
|
| 293 | - if ($existing_field['Extra']) { |
|
| 294 | - $fields[$existing_field['Field']] .= " ".$existing_field['Extra']; |
|
| 295 | - } |
|
| 296 | - if ($default_fields[$existing_field['Field']]['Default']) { |
|
| 297 | - $fields[$existing_field['Field']] .= " default '".$existing_field['Default']."'"; |
|
| 298 | - } |
|
| 289 | + $fields[$existing_field['Field']] = $existing_field['Type']; |
|
| 290 | + if ($existing_field['Null'] != "YES") { |
|
| 291 | + $fields[$existing_field['Field']] .= " NOT NULL"; |
|
| 292 | + } |
|
| 293 | + if ($existing_field['Extra']) { |
|
| 294 | + $fields[$existing_field['Field']] .= " ".$existing_field['Extra']; |
|
| 295 | + } |
|
| 296 | + if ($default_fields[$existing_field['Field']]['Default']) { |
|
| 297 | + $fields[$existing_field['Field']] .= " default '".$existing_field['Default']."'"; |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | return $fields; |
| 301 | 301 | } |
@@ -310,59 +310,59 @@ discard block |
||
| 310 | 310 | * @return array |
| 311 | 311 | */ |
| 312 | 312 | function rename_fields(&$table, $renamed_fields, &$fields, $new_fields) { |
| 313 | - foreach (array_keys($fields) as $field) { |
|
| 314 | - if (in_array($field, array_keys($renamed_fields))) { |
|
| 315 | - $new_field_name = $renamed_fields[$field]; |
|
| 316 | - $new_field_type = $new_fields[$new_field_name]["Type"]; |
|
| 317 | - $table->addAltered($field, $new_field_name." ".$new_field_type); |
|
| 318 | - //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type); |
|
| 319 | - //echo $field." Renamed to ".$new_field_name."<br />"; |
|
| 320 | - $fields[$new_field_name] = $new_field_type; |
|
| 321 | - } |
|
| 313 | + foreach (array_keys($fields) as $field) { |
|
| 314 | + if (in_array($field, array_keys($renamed_fields))) { |
|
| 315 | + $new_field_name = $renamed_fields[$field]; |
|
| 316 | + $new_field_type = $new_fields[$new_field_name]["Type"]; |
|
| 317 | + $table->addAltered($field, $new_field_name." ".$new_field_type); |
|
| 318 | + //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type); |
|
| 319 | + //echo $field." Renamed to ".$new_field_name."<br />"; |
|
| 320 | + $fields[$new_field_name] = $new_field_type; |
|
| 321 | + } |
|
| 322 | 322 | } |
| 323 | 323 | //return $fields; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | $op = isset($_REQUEST['op']) ? intval($_REQUEST['op']) : 0; |
| 327 | 327 | switch ($op) { |
| 328 | - case 1: |
|
| 329 | - // Make sure that nohtml is properly changed to dohtml |
|
| 330 | - invert_nohtm_dohtml_values(); |
|
| 331 | - // Ensure that the proper tables are present |
|
| 332 | - update_tables_to_300(); |
|
| 333 | - // Import data from MyDownloads |
|
| 334 | - import_mydownloads_to_wfdownloads(); |
|
| 335 | - break; |
|
| 328 | + case 1: |
|
| 329 | + // Make sure that nohtml is properly changed to dohtml |
|
| 330 | + invert_nohtm_dohtml_values(); |
|
| 331 | + // Ensure that the proper tables are present |
|
| 332 | + update_tables_to_300(); |
|
| 333 | + // Import data from MyDownloads |
|
| 334 | + import_mydownloads_to_wfdownloads(); |
|
| 335 | + break; |
|
| 336 | 336 | |
| 337 | - case 2: |
|
| 338 | - // Update WF-Downloads |
|
| 339 | - $log = invert_nohtm_dohtml_values(); |
|
| 340 | - update_tables_to_300(); |
|
| 341 | - break; |
|
| 337 | + case 2: |
|
| 338 | + // Update WF-Downloads |
|
| 339 | + $log = invert_nohtm_dohtml_values(); |
|
| 340 | + update_tables_to_300(); |
|
| 341 | + break; |
|
| 342 | 342 | |
| 343 | - default: |
|
| 344 | - //ask what to do |
|
| 345 | - include XOOPS_ROOT_PATH."/class/xoopsformloader.php"; |
|
| 346 | - $form = new XoopsThemeForm('Upgrade WF-Downloads',"form", $_SERVER['REQUEST_URI']); |
|
| 343 | + default: |
|
| 344 | + //ask what to do |
|
| 345 | + include XOOPS_ROOT_PATH."/class/xoopsformloader.php"; |
|
| 346 | + $form = new XoopsThemeForm('Upgrade WF-Downloads',"form", $_SERVER['REQUEST_URI']); |
|
| 347 | 347 | |
| 348 | - //Is MyDownloads installed? |
|
| 349 | - $module_handler = xoops_gethandler('module'); |
|
| 350 | - $mydownloadsModule = $module_handler->getByDirname("mydownloads"); |
|
| 351 | - if (is_object($mydownloadsModule)) { |
|
| 352 | - $mydownloadsButton = new XoopsFormButton("Import data from MyDownloads", "myd_button", "Import", "submit"); |
|
| 353 | - $mydownloadsButton->setExtra("onclick='document.forms.form.op.value=\"1\"'"); |
|
| 354 | - $form->addElement($mydownloadsButton); |
|
| 355 | - } |
|
| 348 | + //Is MyDownloads installed? |
|
| 349 | + $module_handler = xoops_gethandler('module'); |
|
| 350 | + $mydownloadsModule = $module_handler->getByDirname("mydownloads"); |
|
| 351 | + if (is_object($mydownloadsModule)) { |
|
| 352 | + $mydownloadsButton = new XoopsFormButton("Import data from MyDownloads", "myd_button", "Import", "submit"); |
|
| 353 | + $mydownloadsButton->setExtra("onclick='document.forms.form.op.value=\"1\"'"); |
|
| 354 | + $form->addElement($mydownloadsButton); |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - if (!wfdownloads_TableExists('wfdownloads_meta')) { |
|
| 358 | - $updateButton = new XoopsFormButton("Update WF-Downloads", "upd_button", "Update", "submit"); |
|
| 359 | - $updateButton->setExtra("onclick='document.forms.form.op.value=\"2\"'"); |
|
| 360 | - $form->addElement($updateButton); |
|
| 361 | - } |
|
| 357 | + if (!wfdownloads_TableExists('wfdownloads_meta')) { |
|
| 358 | + $updateButton = new XoopsFormButton("Update WF-Downloads", "upd_button", "Update", "submit"); |
|
| 359 | + $updateButton->setExtra("onclick='document.forms.form.op.value=\"2\"'"); |
|
| 360 | + $form->addElement($updateButton); |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - $form->addElement(new XoopsFormHidden('op', 0)); |
|
| 364 | - $form->display(); |
|
| 365 | - break; |
|
| 363 | + $form->addElement(new XoopsFormHidden('op', 0)); |
|
| 364 | + $form->display(); |
|
| 365 | + break; |
|
| 366 | 366 | } |
| 367 | 367 | //wfdownloads_modFooter(); |
| 368 | 368 | //xoops_cp_footer(); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | if (!wfdownloads_TableExists('wfdownloads_meta')) { |
| 26 | 26 | // Create table wfdownloads_meta |
| 27 | 27 | $table = new WfdownloadsTable('wfdownloads_meta'); |
| 28 | - $table->setStructure( "CREATE TABLE %s ( |
|
| 28 | + $table->setStructure("CREATE TABLE %s ( |
|
| 29 | 29 | metakey varchar(50) NOT NULL default '', |
| 30 | 30 | metavalue varchar(255) NOT NULL default '', |
| 31 | 31 | PRIMARY KEY (metakey)) |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $ret = array(); |
| 206 | 206 | global $xoopsDB; |
| 207 | 207 | $cat_handler = xoops_getmodulehandler('category', 'wfdownloads'); |
| 208 | - $result = $xoopsDB->query("SHOW COLUMNS FROM ".$cat_handler->table); |
|
| 208 | + $result = $xoopsDB->query("SHOW COLUMNS FROM " . $cat_handler->table); |
|
| 209 | 209 | while ($existing_field = $xoopsDB->fetchArray($result)) { |
| 210 | 210 | $fields[$existing_field['field']] = $existing_field['type']; |
| 211 | 211 | } |
@@ -225,21 +225,21 @@ discard block |
||
| 225 | 225 | // avoid putting everithing to same value |
| 226 | 226 | // if you change 1 to 0, then 0 to one, |
| 227 | 227 | // every value will be 1, follow me? |
| 228 | - $table->addUpdatedWhere('dohtml', 2,'=1'); |
|
| 229 | - $table->addUpdatedWhere('dohtml', 1,'=0'); |
|
| 230 | - $table->addUpdatedWhere('dohtml', 0,'=2'); |
|
| 228 | + $table->addUpdatedWhere('dohtml', 2, '=1'); |
|
| 229 | + $table->addUpdatedWhere('dohtml', 1, '=0'); |
|
| 230 | + $table->addUpdatedWhere('dohtml', 0, '=2'); |
|
| 231 | 231 | |
| 232 | - $table->addUpdatedWhere('dosmiley', 2,'=1'); |
|
| 233 | - $table->addUpdatedWhere('dosmiley', 1,'=0'); |
|
| 234 | - $table->addUpdatedWhere('dosmiley', 0,'=2'); |
|
| 232 | + $table->addUpdatedWhere('dosmiley', 2, '=1'); |
|
| 233 | + $table->addUpdatedWhere('dosmiley', 1, '=0'); |
|
| 234 | + $table->addUpdatedWhere('dosmiley', 0, '=2'); |
|
| 235 | 235 | |
| 236 | - $table->addUpdatedWhere('doxcode', 2,'=1'); |
|
| 237 | - $table->addUpdatedWhere('doxcode', 1,'=0'); |
|
| 238 | - $table->addUpdatedWhere('doxcode', 0,'=2'); |
|
| 236 | + $table->addUpdatedWhere('doxcode', 2, '=1'); |
|
| 237 | + $table->addUpdatedWhere('doxcode', 1, '=0'); |
|
| 238 | + $table->addUpdatedWhere('doxcode', 0, '=2'); |
|
| 239 | 239 | |
| 240 | - $table->addUpdatedWhere('doimage', 2,'=1'); |
|
| 241 | - $table->addUpdatedWhere('doimage', 1,'=0'); |
|
| 242 | - $table->addUpdatedWhere('doimage', 0,'=2'); |
|
| 240 | + $table->addUpdatedWhere('doimage', 2, '=1'); |
|
| 241 | + $table->addUpdatedWhere('doimage', 1, '=0'); |
|
| 242 | + $table->addUpdatedWhere('doimage', 0, '=2'); |
|
| 243 | 243 | $ret = $dbupdater->updateTable($table); |
| 244 | 244 | } |
| 245 | 245 | return $ret; |
@@ -256,14 +256,14 @@ discard block |
||
| 256 | 256 | function update_table($new_fields, $existing_fields, &$table) { |
| 257 | 257 | foreach ($new_fields as $field => $fieldinfo) { |
| 258 | 258 | $type = $fieldinfo["Type"]; |
| 259 | - if (!in_array($field, array_keys($existing_fields) ) ) { |
|
| 259 | + if (!in_array($field, array_keys($existing_fields))) { |
|
| 260 | 260 | //Add field as it is missing |
| 261 | 261 | $table->addNewField($field, $type); |
| 262 | 262 | //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type); |
| 263 | 263 | //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br />"; |
| 264 | 264 | } |
| 265 | 265 | elseif ($existing_fields[$field] != $type) { |
| 266 | - $table->addAlteredField($field, $field." ".$type); |
|
| 266 | + $table->addAlteredField($field, $field . " " . $type); |
|
| 267 | 267 | // check $fields[$field]['type'] for things like "int(10) unsigned" |
| 268 | 268 | //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type); |
| 269 | 269 | //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br />"; |
@@ -284,17 +284,17 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function get_table_info($table, $default_fields) { |
| 286 | 286 | global $xoopsDB; |
| 287 | - $result = $xoopsDB->query("SHOW COLUMNS FROM ".$table); |
|
| 287 | + $result = $xoopsDB->query("SHOW COLUMNS FROM " . $table); |
|
| 288 | 288 | while ($existing_field = $xoopsDB->fetchArray($result)) { |
| 289 | 289 | $fields[$existing_field['Field']] = $existing_field['Type']; |
| 290 | 290 | if ($existing_field['Null'] != "YES") { |
| 291 | 291 | $fields[$existing_field['Field']] .= " NOT NULL"; |
| 292 | 292 | } |
| 293 | 293 | if ($existing_field['Extra']) { |
| 294 | - $fields[$existing_field['Field']] .= " ".$existing_field['Extra']; |
|
| 294 | + $fields[$existing_field['Field']] .= " " . $existing_field['Extra']; |
|
| 295 | 295 | } |
| 296 | 296 | if ($default_fields[$existing_field['Field']]['Default']) { |
| 297 | - $fields[$existing_field['Field']] .= " default '".$existing_field['Default']."'"; |
|
| 297 | + $fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'"; |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | return $fields; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | if (in_array($field, array_keys($renamed_fields))) { |
| 315 | 315 | $new_field_name = $renamed_fields[$field]; |
| 316 | 316 | $new_field_type = $new_fields[$new_field_name]["Type"]; |
| 317 | - $table->addAltered($field, $new_field_name." ".$new_field_type); |
|
| 317 | + $table->addAltered($field, $new_field_name . " " . $new_field_type); |
|
| 318 | 318 | //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type); |
| 319 | 319 | //echo $field." Renamed to ".$new_field_name."<br />"; |
| 320 | 320 | $fields[$new_field_name] = $new_field_type; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | default: |
| 344 | 344 | //ask what to do |
| 345 | - include XOOPS_ROOT_PATH."/class/xoopsformloader.php"; |
|
| 346 | - $form = new XoopsThemeForm('Upgrade WF-Downloads',"form", $_SERVER['REQUEST_URI']); |
|
| 345 | + include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; |
|
| 346 | + $form = new XoopsThemeForm('Upgrade WF-Downloads', "form", $_SERVER['REQUEST_URI']); |
|
| 347 | 347 | |
| 348 | 348 | //Is MyDownloads installed? |
| 349 | 349 | $module_handler = xoops_gethandler('module'); |
@@ -261,14 +261,12 @@ |
||
| 261 | 261 | $table->addNewField($field, $type); |
| 262 | 262 | //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type); |
| 263 | 263 | //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br />"; |
| 264 | - } |
|
| 265 | - elseif ($existing_fields[$field] != $type) { |
|
| 264 | + } elseif ($existing_fields[$field] != $type) { |
|
| 266 | 265 | $table->addAlteredField($field, $field." ".$type); |
| 267 | 266 | // check $fields[$field]['type'] for things like "int(10) unsigned" |
| 268 | 267 | //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type); |
| 269 | 268 | //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br />"; |
| 270 | - } |
|
| 271 | - else { |
|
| 269 | + } else { |
|
| 272 | 270 | //echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br />"; |
| 273 | 271 | } |
| 274 | 272 | } |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | $ratingid = isset($_GET['ratingid']) ? intval($_GET['ratingid']) : 0 ; |
| 71 | 71 | |
| 72 | 72 | smart_xoops_cp_header(); |
| 73 | - echo $indexAdmin->addNavigation('rating.php'); |
|
| 73 | + echo $indexAdmin->addNavigation('rating.php'); |
|
| 74 | 74 | |
| 75 | 75 | editclass(true, $ratingid); |
| 76 | 76 | break; |
| 77 | 77 | |
| 78 | 78 | case "addrating": |
| 79 | - include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 80 | - $controller = new SmartObjectController($smartobject_rating_handler); |
|
| 79 | + include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 80 | + $controller = new SmartObjectController($smartobject_rating_handler); |
|
| 81 | 81 | $controller->storeFromDefaultForm(_AM_SOBJECT_RATINGS_CREATED, _AM_SOBJECT_RATINGS_MODIFIED, SMARTOBJECT_URL . 'admin/rating.php'); |
| 82 | 82 | |
| 83 | 83 | break; |
| 84 | 84 | |
| 85 | 85 | case "del": |
| 86 | - include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 87 | - $controller = new SmartObjectController($smartobject_rating_handler); |
|
| 86 | + include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 87 | + $controller = new SmartObjectController($smartobject_rating_handler); |
|
| 88 | 88 | $controller->handleObjectDeletion(); |
| 89 | 89 | |
| 90 | 90 | break; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | default: |
| 93 | 93 | |
| 94 | 94 | smart_xoops_cp_header(); |
| 95 | - echo $indexAdmin->addNavigation('rating.php'); |
|
| 95 | + echo $indexAdmin->addNavigation('rating.php'); |
|
| 96 | 96 | |
| 97 | 97 | //smart_adminMenu(4, _AM_SOBJECT_RATINGS); |
| 98 | 98 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | $ratingObj = $smartobject_rating_handler->get($ratingid); |
| 15 | 15 | |
| 16 | - if (!$ratingObj->isNew()){ |
|
| 16 | + if (!$ratingObj->isNew()) { |
|
| 17 | 17 | |
| 18 | 18 | if ($showmenu) { |
| 19 | 19 | //smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _AM_SOBJECT_EDITING); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $controller->postDataToObject($ratingObj); |
| 32 | 32 | |
| 33 | 33 | if ($_POST['op'] == 'changedField') { |
| 34 | - switch($_POST['changedField']) { |
|
| 34 | + switch ($_POST['changedField']) { |
|
| 35 | 35 | case 'dirname' : |
| 36 | 36 | $ratingObj->showFieldOnForm(array('item', 'itemid', 'uid', 'date', 'rate')); |
| 37 | 37 | break; |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | include_once("admin_header.php"); |
| 56 | -include_once SMARTOBJECT_ROOT_PATH."class/smartobjecttable.php"; |
|
| 57 | -include_once SMARTOBJECT_ROOT_PATH."class/rating.php"; |
|
| 56 | +include_once SMARTOBJECT_ROOT_PATH . "class/smartobjecttable.php"; |
|
| 57 | +include_once SMARTOBJECT_ROOT_PATH . "class/rating.php"; |
|
| 58 | 58 | $smartobject_rating_handler = xoops_getmodulehandler('rating'); |
| 59 | 59 | $indexAdmin = new ModuleAdmin(); |
| 60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | case "mod": |
| 68 | 68 | case "changedField"; |
| 69 | 69 | |
| 70 | - $ratingid = isset($_GET['ratingid']) ? intval($_GET['ratingid']) : 0 ; |
|
| 70 | + $ratingid = isset($_GET['ratingid']) ? intval($_GET['ratingid']) : 0; |
|
| 71 | 71 | |
| 72 | 72 | smart_xoops_cp_header(); |
| 73 | 73 | echo $indexAdmin->addNavigation('rating.php'); |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | break; |
| 77 | 77 | |
| 78 | 78 | case "addrating": |
| 79 | - include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 79 | + include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 80 | 80 | $controller = new SmartObjectController($smartobject_rating_handler); |
| 81 | 81 | $controller->storeFromDefaultForm(_AM_SOBJECT_RATINGS_CREATED, _AM_SOBJECT_RATINGS_MODIFIED, SMARTOBJECT_URL . 'admin/rating.php'); |
| 82 | 82 | |
| 83 | 83 | break; |
| 84 | 84 | |
| 85 | 85 | case "del": |
| 86 | - include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 86 | + include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 87 | 87 | $controller = new SmartObjectController($smartobject_rating_handler); |
| 88 | 88 | $controller->handleObjectDeletion(); |
| 89 | 89 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | smart_collapsableBar('createdratings', _AM_SOBJECT_RATINGS, _AM_SOBJECT_RATINGS_DSC); |
| 100 | 100 | |
| 101 | - include_once SMARTOBJECT_ROOT_PATH."class/smartobjecttable.php"; |
|
| 101 | + include_once SMARTOBJECT_ROOT_PATH . "class/smartobjecttable.php"; |
|
| 102 | 102 | $objectTable = new SmartObjectTable($smartobject_rating_handler); |
| 103 | 103 | $objectTable->addColumn(new SmartObjectColumn('name', 'left')); |
| 104 | 104 | $objectTable->addColumn(new SmartObjectColumn('dirname', 'left')); |
@@ -60,8 +60,12 @@ |
||
| 60 | 60 | |
| 61 | 61 | $op = ''; |
| 62 | 62 | |
| 63 | -if (isset($_GET['op'])) $op = $_GET['op']; |
|
| 64 | -if (isset($_POST['op'])) $op = $_POST['op']; |
|
| 63 | +if (isset($_GET['op'])) { |
|
| 64 | + $op = $_GET['op']; |
|
| 65 | +} |
|
| 66 | +if (isset($_POST['op'])) { |
|
| 67 | + $op = $_POST['op']; |
|
| 68 | +} |
|
| 65 | 69 | |
| 66 | 70 | switch ($op) { |
| 67 | 71 | case "mod": |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | if (!file_exists($fileinc = $pathLanguage . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/' . 'main.php')) { |
| 23 | - $fileinc = $pathLanguage . '/language/english/main.php'; |
|
| 23 | + $fileinc = $pathLanguage . '/language/english/main.php'; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | include_once $fileinc; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $i++; |
| 72 | 72 | $adminmenu[$i]['title'] = _MI_SOBJECT_CURRENCIES; |
| 73 | 73 | $adminmenu[$i]['link'] = "admin/currency.php"; |
| 74 | - $adminmenu[$i]["icon"] = $pathIcon32 . '/cash_stack.png'; |
|
| 74 | + $adminmenu[$i]["icon"] = $pathIcon32 . '/cash_stack.png'; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | include_once $fileinc; |
| 27 | 27 | |
| 28 | 28 | $adminmenu = array(); |
| 29 | -$i=0; |
|
| 29 | +$i = 0; |
|
| 30 | 30 | $adminmenu[$i]["title"] = _AM_MODULEADMIN_HOME; |
| 31 | 31 | $adminmenu[$i]['link'] = "admin/index.php"; |
| 32 | 32 | $adminmenu[$i]["icon"] = $pathIcon32 . '/home.png'; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $i++; |
| 72 | 72 | $adminmenu[$i]['title'] = _MI_SOBJECT_CURRENCIES; |
| 73 | 73 | $adminmenu[$i]['link'] = "admin/currency.php"; |
| 74 | - $adminmenu[$i]["icon"] = $pathIcon32 . '/cash_stack.png'; |
|
| 74 | + $adminmenu[$i]["icon"] = $pathIcon32 . '/cash_stack.png'; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -81,24 +81,24 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | // --- for XCL --- |
| 83 | 83 | // $headermenu[$i]['link'] = '../../system/admin.php?fct=preferences&op=showmod&mod=' . $xoopsModule->getVar('mid'); |
| 84 | - $mid = $xoopsModule->getVar('mid') ; |
|
| 85 | - if ( defined( 'XOOPS_CUBE_LEGACY' ) ) { |
|
| 86 | - $link_pref = XOOPS_URL.'/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id='.$mid; |
|
| 84 | + $mid = $xoopsModule->getVar('mid'); |
|
| 85 | + if (defined('XOOPS_CUBE_LEGACY')) { |
|
| 86 | + $link_pref = XOOPS_URL . '/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id=' . $mid; |
|
| 87 | 87 | } else { |
| 88 | - $link_pref = XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid ; |
|
| 88 | + $link_pref = XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $mid; |
|
| 89 | 89 | } |
| 90 | - $headermenu[$i]['link'] = $link_pref ; |
|
| 90 | + $headermenu[$i]['link'] = $link_pref; |
|
| 91 | 91 | // ----- |
| 92 | 92 | |
| 93 | 93 | // --- for XCL --- |
| 94 | 94 | // $headermenu[$i]['link'] = XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=update&module=" . $xoopsModule->getVar('dirname'); |
| 95 | - $dirname = $xoopsModule->getVar('dirname') ; |
|
| 96 | - if ( defined( 'XOOPS_CUBE_LEGACY' ) ) { |
|
| 97 | - $link_module = XOOPS_URL.'/modules/legacy/admin/index.php?action=ModuleUpdate&dirname='.$dirname; |
|
| 95 | + $dirname = $xoopsModule->getVar('dirname'); |
|
| 96 | + if (defined('XOOPS_CUBE_LEGACY')) { |
|
| 97 | + $link_module = XOOPS_URL . '/modules/legacy/admin/index.php?action=ModuleUpdate&dirname=' . $dirname; |
|
| 98 | 98 | } else { |
| 99 | - $link_module = XOOPS_URL.'/modules/system/admin.php?fct=modulesadmin&op=update&module='.$dirname; |
|
| 99 | + $link_module = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=' . $dirname; |
|
| 100 | 100 | } |
| 101 | - $headermenu[$i]['link'] = $link_module ; |
|
| 101 | + $headermenu[$i]['link'] = $link_module; |
|
| 102 | 102 | // ----- |
| 103 | 103 | |
| 104 | 104 | $i++; |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | switch ($op) { |
| 27 | 27 | |
| 28 | 28 | case "del": |
| 29 | - include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 30 | - $controller = new SmartObjectController($smartobject_link_handler); |
|
| 29 | + include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 30 | + $controller = new SmartObjectController($smartobject_link_handler); |
|
| 31 | 31 | $controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM); |
| 32 | 32 | |
| 33 | 33 | break; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | smart_xoops_cp_header(); |
| 70 | 70 | |
| 71 | - echo $indexAdmin->addNavigation('link.php'); |
|
| 71 | + echo $indexAdmin->addNavigation('link.php'); |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | //smart_adminMenu(1, _AM_SOBJECT_SENT_LINKS); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | include_once("admin_header.php"); |
| 15 | -include_once SMARTOBJECT_ROOT_PATH."class/smartobjecttable.php"; |
|
| 16 | -include_once SMARTOBJECT_ROOT_PATH."class/smartobjectlink.php"; |
|
| 15 | +include_once SMARTOBJECT_ROOT_PATH . "class/smartobjecttable.php"; |
|
| 16 | +include_once SMARTOBJECT_ROOT_PATH . "class/smartobjectlink.php"; |
|
| 17 | 17 | $indexAdmin = new ModuleAdmin(); |
| 18 | 18 | |
| 19 | 19 | $smartobject_link_handler = xoops_getmodulehandler('link'); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | switch ($op) { |
| 27 | 27 | |
| 28 | 28 | case "del": |
| 29 | - include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 29 | + include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobjectcontroller.php"; |
|
| 30 | 30 | $controller = new SmartObjectController($smartobject_link_handler); |
| 31 | 31 | $controller->handleObjectDeletion(_AM_SOBJECT_SENT_LINK_DELETE_CONFIRM); |
| 32 | 32 | |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | // --- |
| 52 | 52 | // 2012-01-01 PHP 5.3 : Assigning the return value of new by reference is now deprecated. |
| 53 | 53 | // $xoopsTpl =& new XoopsTpl(); |
| 54 | - $xoopsTpl = new XoopsTpl(); |
|
| 54 | + $xoopsTpl = new XoopsTpl(); |
|
| 55 | 55 | //--- |
| 56 | 56 | |
| 57 | 57 | $xoopsTpl->assign('link', $linkObj->toArray()); |
| 58 | - $xoopsTpl->display( 'db:smartobject_sentlink_display.html' ); |
|
| 58 | + $xoopsTpl->display('db:smartobject_sentlink_display.html'); |
|
| 59 | 59 | |
| 60 | 60 | echo "<br />"; |
| 61 | 61 | smart_close_collapsable('sentlinks'); |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | smart_collapsableBar('sentlinks', _AM_SOBJECT_SENT_LINKS, _AM_SOBJECT_SENT_LINKS_INFO); |
| 77 | 77 | |
| 78 | - include_once SMARTOBJECT_ROOT_PATH."class/smartobjecttable.php"; |
|
| 78 | + include_once SMARTOBJECT_ROOT_PATH . "class/smartobjecttable.php"; |
|
| 79 | 79 | $objectTable = new SmartObjectTable($smartobject_link_handler, null, array('delete')); |
| 80 | 80 | $objectTable->addColumn(new SmartObjectColumn('date')); |
| 81 | - $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align='left', $width=false, 'getFromInfo')); |
|
| 82 | - $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_TO, $align='left', $width=false, 'getToInfo')); |
|
| 81 | + $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_FROM, $align = 'left', $width = false, 'getFromInfo')); |
|
| 82 | + $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_LINKS_TO, $align = 'left', $width = false, 'getToInfo')); |
|
| 83 | 83 | $objectTable->addColumn(new SmartObjectColumn('link')); |
| 84 | 84 | |
| 85 | 85 | $objectTable->addCustomAction("getViewItemLink"); |
@@ -20,8 +20,12 @@ |
||
| 20 | 20 | |
| 21 | 21 | $op = ''; |
| 22 | 22 | |
| 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 | switch ($op) { |
| 27 | 31 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | $pathModuleAdmin = $xoopsModule->getInfo('dirmoduleadmin'); |
| 42 | 42 | |
| 43 | 43 | if ( file_exists($GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'))){ |
| 44 | - include_once $GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'); |
|
| 45 | - }else{ |
|
| 46 | - redirect_header("../../../admin.php", 5, _AM_BIRTHDAY_MODULEADMIN_MISSING, false); |
|
| 47 | - } |
|
| 48 | 44 | \ No newline at end of file |
| 45 | + include_once $GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'); |
|
| 46 | + }else{ |
|
| 47 | + redirect_header("../../../admin.php", 5, _AM_BIRTHDAY_MODULEADMIN_MISSING, false); |
|
| 48 | + } |
|
| 49 | 49 | \ No newline at end of file |
@@ -36,12 +36,12 @@ |
||
| 36 | 36 | xoops_loadLanguage('modinfo', $thisModuleDir); |
| 37 | 37 | xoops_loadLanguage('main', $thisModuleDir); |
| 38 | 38 | |
| 39 | -$pathIcon16 = '../'.$xoopsModule->getInfo('icons16'); |
|
| 40 | -$pathIcon32 = '../'.$xoopsModule->getInfo('icons32'); |
|
| 39 | +$pathIcon16 = '../' . $xoopsModule->getInfo('icons16'); |
|
| 40 | +$pathIcon32 = '../' . $xoopsModule->getInfo('icons32'); |
|
| 41 | 41 | $pathModuleAdmin = $xoopsModule->getInfo('dirmoduleadmin'); |
| 42 | 42 | |
| 43 | -if ( file_exists($GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'))){ |
|
| 44 | - include_once $GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'); |
|
| 45 | - }else{ |
|
| 43 | +if (file_exists($GLOBALS['xoops']->path($pathModuleAdmin . '/moduleadmin.php'))) { |
|
| 44 | + include_once $GLOBALS['xoops']->path($pathModuleAdmin . '/moduleadmin.php'); |
|
| 45 | + } else { |
|
| 46 | 46 | redirect_header("../../../admin.php", 5, _AM_BIRTHDAY_MODULEADMIN_MISSING, false); |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -42,6 +42,6 @@ |
||
| 42 | 42 | |
| 43 | 43 | if ( file_exists($GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'))){ |
| 44 | 44 | include_once $GLOBALS['xoops']->path($pathModuleAdmin.'/moduleadmin.php'); |
| 45 | - }else{ |
|
| 45 | + } else{ |
|
| 46 | 46 | redirect_header("../../../admin.php", 5, _AM_BIRTHDAY_MODULEADMIN_MISSING, false); |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |