1: <?php
  2: 
  3: function getPHPFiles($folder, $exclude) {
  4:     global $files;
  5:     $dir = opendir($folder);
  6:     while (($file = readdir($dir)) !== false) {
  7:         $file = str_replace('\\', '/', $file);
  8:         if ($file != '.' && $file != '..') {
  9:             if (is_dir($folder . '/' . $file) && !in_array($file, $exclude)) {
 10:                 getPHPFiles($folder . '/' . $file, $exclude);
 11:             } else {
 12:                 if (getSuffix($file) == 'php') {
 13:                     $entry = $folder . '/' . $file;
 14:                     $files[] = $entry;
 15:                 }
 16:             }
 17:         }
 18:     }
 19:     closedir($dir);
 20:     return $files;
 21: }
 22: 
 23: function formatList($title, $subject, $pattern) {
 24:     global $deprecated;
 25:     preg_match_all($pattern, $subject, $matches);
 26:     $started = false;
 27:     if ($matches && !empty($matches[0])) {
 28:         foreach (array_unique($matches[2]) as $key => $match) {
 29:             $details = $deprecated->unique_functions[strtolower($match)];
 30:             $found = $matches[1][$key];
 31:             switch ($details['class']) {
 32:                 case 'static':
 33:                     if ($found == '->' || $found == '::') {
 34:                         $class = '*';
 35:                         break;
 36:                     } else {
 37:                         continue 2;
 38:                     }
 39:                 case 'final static':
 40:                     if ($found == '->' || $found == '::') {
 41:                         $class = '*+';
 42:                         break;
 43:                     } else {
 44:                         continue 2;
 45:                     }
 46:                 case 'public static':
 47:                     if ($found == '->' || $found == '::') {
 48:                         continue 2;
 49:                     } else {
 50:                         $class = '+';
 51:                         break;
 52:                     }
 53:                 default:
 54:                     if ($found == '->' || $found == '::') {
 55:                         continue 2;
 56:                     } else {
 57:                         $class = '';
 58:                         break;
 59:                     }
 60:             }
 61:             if (!$started) {
 62:                 $started = true;
 63:                 echo '<li class="warningbox nobullet"> ' . $title;
 64:                 echo '<ul>';
 65:             }
 66:             echo '<li>' . $match . $class . '</li>';
 67:         }
 68:     }
 69:     if ($started)
 70:         echo '</ul></li>';
 71: 
 72:     return $started;
 73: }
 74: 
 75: function listUses($files, $base, $pattern) {
 76:     if (is_array($files)) {
 77:         $open = $output = false;
 78:         $oldLocation = '';
 79:         foreach ($files as $file) {
 80:             if (basename($file) != 'deprecated-functions.php') {
 81:                 @set_time_limit(120);
 82:                 $subject = file_get_contents($file);
 83:                 $location = str_replace($base . '/', '', dirname($file));
 84:                 $folders = explode('/', $location);
 85:                 if ($folders[0] != $oldLocation) {
 86:                     $oldLocation = $folders[0];
 87:                     echo '<br /><strong>' . $location . '</strong>';
 88:                 }
 89:                 if ($open) {
 90:                     echo '</ul>';
 91:                 }
 92:                 $script_location = $base . '/' . $location . '/';
 93:                 $script = str_replace($script_location, '', $file);
 94:                 $open = $output = formatList($script, $subject, $pattern);
 95:             } 
 96:         }
 97:         if ($open) {
 98:             echo '</ul>';
 99:         }
100:         if ($output) {
101:             ?>
102:             <p class="messagebox"><?php echo gettext('No calls on deprecated functions were found.'); ?></p>
103:             <?php
104:         }
105:         return $output;
106:     }
107: }
108: 
109: function listDBUses($pattern) {
110:     $lookfor = array('images', 'albums', 'news', 'pages');
111:     $found = array();
112:     foreach ($lookfor as $table) {
113:         echo '<br /><strong>' . sprintf(gettext('%s table'), $table) . '</strong>';
114:         $output = false;
115:         $sql = 'SELECT * FROM ' . prefix($table) . ' WHERE `codeblock` <> "" and `codeblock` IS NOT NULL and `codeblock`!="a:0:{}"';
116:         $result = query($sql);
117:         while ($row = db_fetch_assoc($result)) {
118:             $codeblocks = getSerializedArray($row['codeblock']);
119:             foreach ($codeblocks as $key => $codeblock) {
120:                 switch ($table) {
121:                     case 'news':
122:                     case 'pages':
123:                         $what = $row['titlelink'] . '::' . $key;
124:                         break;
125:                     case 'images':
126:                         $album = getItemByID('albums', $row['albumid']);
127:                         $what = $album->name . ':' . $row['filename'] . '::' . $key;
128:                         break;
129:                     case 'albums':
130:                         $what = $row['folder'] . '::' . $key;
131:                         break;
132:                 }
133:                 if (formatList($what, $codeblock, $pattern))
134:                     $output = true;
135:             }
136:         }
137:         if ($output) {
138:             echo '</ul>';
139:         } else {
140:             ?>
141:             <p class="messagebox"><?php echo gettext('No calls on deprecated functions were found.'); ?></p>
142:             <?php
143:         }
144:     }
145:     return $output;
146: }
147: ?>
148: