Completed
Push — master ( ed35ab...871ad1 )
by Michael
05:54
created

images.php ➔ drawDirs_Files()   F

Complexity

Conditions 32
Paths 5491

Size

Total Lines 174
Code Lines 125

Duplication

Lines 56
Ratio 32.18 %

Importance

Changes 0
Metric Value
cc 32
eloc 125
nc 5491
nop 2
dl 56
loc 174
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 68 and the first side effect is on line 13.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * ExtendedFileManager images.php file. Shows folders and files.
4
 * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz, Raimund Meyer
5
 * Version: Updated on 08-01-2005 by Afru
6
 * Version: Updated on 04-07-2006 by Krzysztof Kotowicz
7
 * Version: Updated on 29-10-2006 by Raimund Meyer
8
 * Version: Updated on 20-01-2008 by Raimund Meyer
9
 * Package: ExtendedFileManager (EFM 1.4)
10
 * http://www.afrusoft.com/htmlarea
11
 */
12
13
	if(isset($_REQUEST['mode'])) $insertMode=$_REQUEST['mode'];
14
	if(!isset($insertMode)) $insertMode="image";
15
16
require_once('config.inc.php');
17
require_once('Classes/ExtendedFileManager.php');
18
$backend_url_enc = htmlspecialchars( $IMConfig['backend_url'] );
19
//default path is /
20
$relative = '/';
21
$manager = new ExtendedFileManager($IMConfig, $insertMode);
22
23
//process any file uploads
24
$uploadStatus=$manager->processUploads();
25
26
//process any file renames
27
$renameStatus=$manager->processRenames();
28
29
//process paste
30
$pasteStatus = (isset($_GET['paste'])) ? 	$manager->processPaste() : false;
31
32
$refreshFile = ($IMConfig['allow_delete'] && $manager->deleteFiles()) ? true : false;
33
34
$refreshDir = false;
35
//process any directory functions
36
if(($IMConfig['allow_delete'] && $manager->deleteDirs()) || $manager->processNewDir() || $pasteStatus || $renameStatus )
37
	$refreshDir = true;
38
39
40
$diskInfo=$manager->getDiskInfo();
41
42
//check for any sub-directory request
43
//check that the requested sub-directory exists
44
//and valid
45 View Code Duplication
if(isset($_REQUEST['dir']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
{
47
	$path = rawurldecode($_REQUEST['dir']);
48
	if($manager->validRelativePath($path))
49
		$relative = $path;
50
}
51
52
$afruViewType = (isset($_REQUEST['viewtype'])) ? $afruViewType=$_REQUEST['viewtype'] : '';
53
54
if($afruViewType!="thumbview" && $afruViewType!="listview")
55
{
56
  $afruViewType=$IMConfig['view_type'];
57
}
58
//get the list of files and directories
59
$list = $manager->getFiles($relative);
60
61
62
/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
63
64
65
/**
66
 * Draw folders and files. Changed by Afru
67
 */
68
function drawDirs_Files($list, &$manager) 
69
{
70
	global $relative, $afruViewType, $IMConfig, $insertMode,$backend_url_enc;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
71
72
    switch ($afruViewType) {
73
        case 'listview':
74
    		$maxNameLength = 30;
75
    		?>
76
            <table class="listview" id="listview">
77
            <thead>
78
            <tr><th>Name</th><th>Size</th><th>Image Size</th><th>Date Modified</th><th>&nbsp;</th></tr></thead>
79
            <tbody>
80
            <?php
81
    		// start of foreach for draw listview folders .
82
    		foreach($list[0] as $path => $dir)
83
    		{ ?>
84
    			<tr>
85
    			<td><span style="width:20px;"><img src="<?php print $IMConfig['base_url'];?>icons/folder_small.gif" alt="" /></span>
86
				<a href="<?php print $backend_url_enc; ?>__function=images&amp;mode=<?php echo $insertMode;?>&amp;dir=<?php echo rawurlencode($path); ?>&amp;viewtype=<?php echo $afruViewType; ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>">
87
    			<?php
88 View Code Duplication
    			if(strlen($dir['entry'])>$maxNameLength) echo substr($dir['entry'],0,$maxNameLength)."..."; else echo $dir['entry'];
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
    			?>
90
    			</a></td>
91
    			<td colspan="2" >Folder</td>
92
93
    			<td ><?php echo date($IMConfig['date_format'],$dir['stat']['mtime']); ?></td>
94
95
    			<td class="actions" >
96
            <?php
97 View Code Duplication
              if($IMConfig['allow_delete'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
              {
99
                ?>
100
    				<a href="<?php print $backend_url_enc; ?>__function=images&amp;mode=<?php echo $insertMode;?>&amp;dir=<?php echo $relative; ?>&amp;deld=<?php echo rawurlencode($path); ?>&amp;viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);" style="border:0px;"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0" /></a>
101
                <?php
102
              }
103
            ?>
104
			    	<?php if ($IMConfig['allow_rename']) { ?>
105
			                    <a href="#" title="Rename" onclick="renameDir('<?php echo rawurlencode($dir['entry']);?>'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0" /></a>
106
			        <?php }  ?>
107 View Code Duplication
    				<?php if ($IMConfig['allow_cut_copy_paste']) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
108
                    <a href="#" title="Cut" onclick="copyDir('<?php echo rawurlencode($dir['entry']);?>','move'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_cut.gif" height="15" width="15" alt="Cut" /></a>
109
                     <a href="#" title="Copy" onclick="copyDir('<?php echo rawurlencode($dir['entry']);?>','copy'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_copy.gif" height="15" width="15" alt="Copy" /></a>
110
     		   		<?php }  ?>
111
    			</td>
112
    			</tr>
113
    		  <?php
114
    		} // end of foreach for draw listview folders .
115
116
    		clearstatcache();
117
118
    		// start of foreach for draw listview files .
119
    		foreach($list[1] as $entry => $file)
120
    		{
121
    			?>
122
                <tr>
123
        		  <td>
124
					<a href="#" class="thumb" style="cursor: pointer;vertical-align:middle;" ondblclick="this.onclick();window.top.onOK();" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo preg_replace('#\..{3,4}$#', '', $entry); ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" <?php if ($insertMode == 'image') { ?> onmouseover="showPreview('<?php echo $file['relative'];?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" <?php } ?> >
125
          <span style="width:20px;vertical-align:middle;"><img src="<?php print $IMConfig['base_url']; if(is_file('icons/'.$file['ext'].'_small.gif')) echo "icons/".$file['ext']."_small.gif"; else echo $IMConfig['default_listicon']; ?>" alt="" style="border:none;" /></span><span style="vertical-align:middle;">
126
        			<?php
127
        			if(strlen($entry)>$maxNameLength) echo substr($entry,0,$maxNameLength)."..."; else echo $entry;
128
        			?></span>
129
                  </a></td>
130
                  <td><?php echo Files::formatSize($file['stat']['size']); ?></td>
131 View Code Duplication
                  <td><?php if($file['image'][0] > 0){ echo $file['image'][0].'x'.$file['image'][1]; } ?></td>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
132
    			  <td ><?php echo date($IMConfig['date_format'],$file['stat']['mtime']); ?></td>
133
                  <td class="actions">
134 View Code Duplication
                    <?php if($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
135
                    <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" border="0" /></a>
136
                    <?php }  ?>  
137
             <?php
138 View Code Duplication
              if($IMConfig['allow_delete'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
              {
140
                ?>
141
                    <a href="<?php print $backend_url_enc; ?>__function=images&amp;dir=<?php echo $relative; ?>&amp;delf=<?php echo rawurlencode($file['relative']);?>&amp;mode=<?php echo $insertMode;?>&amp;viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0" /></a>
142
                 <?php
143
               }
144
             ?>
145 View Code Duplication
        			<?php if ($IMConfig['allow_rename']) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
146
                    <a href="#" title="Rename" onclick="renameFile('<?php echo rawurlencode($file['relative']);?>'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0" /></a>
147
                    <?php }  ?>
148 View Code Duplication
        			<?php if ($IMConfig['allow_cut_copy_paste']) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
149
                    <a href="#" title="Cut" onclick="copyFile('<?php echo rawurlencode($entry);?>','move'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_cut.gif" height="15" width="15" alt="Cut" /></a>
150
                     <a href="#" title="Copy" onclick="copyFile('<?php echo rawurlencode($entry);?>','copy'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_copy.gif" height="15" width="15" alt="Copy" /></a>
151
                    <?php }  ?>
152
                  </td>
153
                </tr>
154
    		  <?php
155
    		}//end of foreach of draw listview files
156
            ?>
157
            </tbody>
158
            </table>
159
            <?php
160
        break;
161
        case 'thumbview': // thumbview is default
162
        default:
163
    		$maxFileNameLength=16;
164
    		$maxFolderNameLength=16;
165
    		// start of foreach for draw thumbview folders.
166
    		foreach($list[0] as $path => $dir)
167
    		{ ?>
168
    <div class="dir_holder">
169
      <a class="dir" href="<?php print $backend_url_enc;?>__function=images&amp;mode=<?php echo $insertMode;?>&amp;dir=<?php echo rawurlencode($path); ?>&amp;viewtype=<?php echo $afruViewType; ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="<?php print $IMConfig['base_url'];?>img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a>
170
171
      <div class="fileName">
172 View Code Duplication
      <?php if(strlen($dir['entry']) > $maxFolderNameLength)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
173
                echo substr($dir['entry'], 0, $maxFolderNameLength) . "...";
174
              else
175
                echo $dir['entry']; ?>
176
      </div>
177
      <div class="edit">
178
      <?php
179 View Code Duplication
        if($IMConfig['allow_delete'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
180
        {
181
          ?>
182
        <a href="<?php print $backend_url_enc;?>__function=images&amp;mode=<?php echo $insertMode;?>&amp;dir=<?php echo $relative; ?>&amp;deld=<?php echo rawurlencode($path); ?>&amp;viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" /></a>
183
          <?php
184
        }
185
      ?>
186
    	<?php if ($IMConfig['allow_rename']) { ?>
187
                    <a href="#" title="Rename" onclick="renameDir('<?php echo rawurlencode($dir['entry']);?>'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0" /></a>
188
        <?php }  ?>
189 View Code Duplication
        <?php if ($IMConfig['allow_cut_copy_paste']) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
190
                    <a href="#" title="Cut" onclick="copyDir('<?php echo rawurlencode($dir['entry']);?>','move'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_cut.gif" height="15" width="15" alt="Cut" /></a>
191
                     <a href="#" title="Copy" onclick="copyDir('<?php echo rawurlencode($dir['entry']);?>','copy'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_copy.gif" height="15" width="15" alt="Copy" /></a>
192
        <?php }  ?>
193
      </div>
194
    </div>
195
    		  <?php
196
    		} // end of foreach for draw thumbview folders.
197
198
199
    		// start of foreach for draw thumbview files.
200
    		foreach($list[1] as $entry => $file)
201
    		{
202
    			$afruimgdimensions=$manager->checkImageSize($file['relative']);
0 ignored issues
show
Unused Code introduced by
$afruimgdimensions is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
203
    			$thisFileNameLength = $maxFileNameLength;
204
    			?>
205
                <div class="thumb_holder" id="holder_<?php echo asc2hex($entry) ?>">
206
                  <a href="#" class="thumb" style="cursor: pointer;" ondblclick="this.onclick();window.top.onOK();" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo preg_replace('#\..{3,4}$#', '', $entry); ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>">
207
                    <img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" />
208
                  </a>
209
                   <div class="fileName">
210
                   <?php
211
            			if(strlen($entry) > $thisFileNameLength + 3) echo strtolower(substr($entry,0,$thisFileNameLength))."..."; else echo $entry;
212
            		?>
213
                   </div>
214
                  <div class="edit">
215 View Code Duplication
                    <?php if($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0 )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
                    { ?>
217
                    <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" /></a>
218
            		<?php $thisFileNameLength -= 3; } ?>
219
                <?php
220 View Code Duplication
                  if($IMConfig['allow_delete'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
221
                  {
222
                    ?>
223
                    <a href="<?php print $backend_url_enc; ?>__function=images&amp;mode=<?php echo $insertMode;?>&amp;dir=<?php echo $relative; ?>&amp;delf=<?php echo rawurlencode($file['relative']);?>&amp;viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" /></a>
224
                    <?php
225
                  }
226
                ?>
227
        			<?php if ($IMConfig['allow_rename']) { ?>
228
                    <a href="#" title="Rename" onclick="renameFile('<?php echo rawurlencode($file['relative']);?>'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_rename.gif" height="15" width="15" alt="Rename" /></a>
229
                    <?php $thisFileNameLength -= 3; }  ?>
230 View Code Duplication
                	<?php if ($IMConfig['allow_cut_copy_paste']) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
                    <a href="#" title="Cut" onclick="copyFile('<?php echo rawurlencode($entry);?>','move'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_cut.gif" height="15" width="15" alt="Cut" /></a>
232
                     <a href="#" title="Copy" onclick="copyFile('<?php echo rawurlencode($entry);?>','copy'); return false;"><img src="<?php print $IMConfig['base_url'];?>img/edit_copy.gif" height="15" width="15" alt="Copy" /></a>
233
                    <?php $thisFileNameLength -= 6; }  ?>
234
            		
235
                  </div>
236
                </div>
237
    		  <?php
238
    		}//end of foreach of draw thumbview files
239
240
    }
241
}//end of function drawDirs_Files
242
243
244
/**
245
 * No directories and no files.
246
 */
247
function drawNoResults() 
0 ignored issues
show
Best Practice introduced by
The function drawNoResults() has been defined more than once; this definition is ignored, only the first definition in htdocs/class/xoopseditor...ImageManager/images.php (L97-106) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
248
{
249
?>
250
<div class="noResult">No Files Found</div>
251
<?php
252
}
253
254
/**
255
 * No directories and no files.
256
 */
257
function drawErrorBase(&$manager) 
0 ignored issues
show
Best Practice introduced by
The function drawErrorBase() has been defined more than once; this definition is ignored, only the first definition in htdocs/class/xoopseditor...ImageManager/images.php (L111-120) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
258
{
259
?>
260
<div class="error"><span>Invalid base directory:</span> <?php echo $manager->getImagesDir(); ?></div>
261
<?php
262
}
263
264
/**
265
 * Utility to convert ascii string to hex
266
 */
267 View Code Duplication
function asc2hex ($temp)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
268
{
269
  $data = '';
270
  $len = strlen($temp);
271
  for ($i=0; $i<$len; $i++) $data.=sprintf("%02x",ord(substr($temp,$i,1)));
272
  return $data;
273
}
274
275
?>
276
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
277
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
278
<html xmlns="http://www.w3.org/1999/xhtml">
279
<head>
280
	<title>File List</title>
281
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
282
	<link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
283
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
284
<script type="text/javascript">
285
/*<![CDATA[*/
286
287
    var _backend_url = "<?php print $IMConfig['backend_url']; ?>";
288
289
	if(window.top)
290
		Xinha = window.top.Xinha;
291
292
	function hideMessage()
293
	{
294
		var topDoc = window.top.document;
295
		var messages = topDoc.getElementById('messages');
296
		if (messages)
297
		{
298
			messages.style.display = "none";
299
		}
300
		//window.parent.resize();
301
	}
302
303
	init = function()
304
	{
305
        __dlg_translate('ExtendedFileManager');
306
        
307
		hideMessage();
308
		<?php if ($afruViewType == 'listview')
309
			print "var d = new dragTableCols('listview');";
310
		
311
		if(isset($uploadStatus) && !is_numeric($uploadStatus) && !is_bool($uploadStatus))
312
		echo "alert(i18n('$uploadStatus'));";
313
		else if(isset($uploadStatus) && $uploadStatus==false)
314
		echo 'alert(i18n("Unable to upload File. \nEither Maximum file size [$max_size='.($insertMode == 'image' ? $IMConfig['max_filesize_kb_image'] : $IMConfig['max_filesize_kb_link'] ).'$ KB] exceeded or\nFolder doesn\'t have write permission."));';
315
		?>
316
317
		<?php
318
		if(isset($renameStatus) && !is_numeric($renameStatus) && !is_bool($renameStatus))
319
		echo 'alert(i18n("'.$renameStatus.'"));';
320
		else if(isset($renameStatus) && $renameStatus===false)
321
		echo 'alert(i18n("Unable to rename file. File of the same name already exists or\nfolder doesn\'t have write permission."));';
322
		?>
323
		
324
		<?php
325
		if (isset($pasteStatus) && is_numeric($pasteStatus))
326
		{
327
			switch ($pasteStatus)
328
			{
329
				case 100 :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
330
					$pasteStatus = 'Source file/folder not found.';
331
				break;
332
				case 101 :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
333
					$pasteStatus = 'Copy failed.\nMaybe folder doesn\'t have write permission.';
334
				break;
335
				case 102 :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
336
					$pasteStatus = 'Could not create destination folder.';
337
				break;
338
				case 103 :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
339
					$pasteStatus = 'File pasted OK.';
340
				break;
341
				case 104 :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
342
					$pasteStatus = 'Destination file/folder already exists.';
343
				break;
344
			}
345
		}
346
		if(isset($pasteStatus) && !is_bool($pasteStatus))
347
		{
348
			echo 'alert(i18n("'.$pasteStatus.'"));';
349
		}
350
		?>
351
352
		var topDoc = window.top.document;
353
354
<?php
355
	//we need to refesh the drop directory list
356
	//save the current dir, delete all select options
357
	//add the new list, re-select the saved dir.
358 View Code Duplication
	if($refreshDir) 
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
359
	{ 
360
		$dirs = $manager->getDirs();
361
?>
362
		var selection = topDoc.getElementById('dirPath');
363
		var currentDir = selection.options[selection.selectedIndex].text;
364
365
		while(selection.length > 0)
366
		{	selection.remove(0); }
367
		
368
		selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");
369
		<?php foreach($dirs as $relative=>$fullpath) { ?>
370
		selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");
371
		<?php } ?>
372
		
373
		for(var i = 0; i < selection.length; i++)
374
		{
375
			var thisDir = selection.options[i].text;
376
			if(thisDir == currentDir)
377
			{
378
				selection.selectedIndex = i;
379
				break;
380
			}
381
		}		
382
<?php } ?>
383
	}
384
    
385
	function editImage(image) 
386
	{
387
		var url = "<?php print $IMConfig['backend_url']; ?>__function=editor&img="+image+"&mode=<?php print $insertMode ?>";
388
        Dialog(url, function(param)
389
		{
390
			if (!param) { // user must have pressed Cancel
391
				return false;
392
			} else
393
			{
394
				return true;
395
			}
396
		}, null);
397
	}
398
399
/*]]>*/
400
</script>
401
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
402
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/popup.js"></script>
403
<script type="text/javascript">
404
<!--
405
// Koto: why emptying? commented out
406
//if(window.top.document.getElementById('manager_mode').value=="image")
407
//emptyProperties();
408
<?php if(isset($diskInfo)) echo 'updateDiskMesg(i18n(\''.$diskInfo.'\'));'; ?>
409
//-->
410
</script>
411
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dragTableCols.js"></script>
412
</head>
413
414
<body>
415
<?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
416
	elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>
417
	<?php drawDirs_Files($list, $manager); ?>
418
<?php } else { drawNoResults(); } ?>
0 ignored issues
show
Unused Code introduced by
The call to the function drawNoResults() seems unnecessary as the function has no side-effects.
Loading history...
419
</body>
420
</html>
421