function make_list($dir, $item, $subdir) { // convert shell-wildcards to PCRE Regex Syntax $pat = "^" . str_replace("?", ".", str_replace("*", ".*", str_replace(".", "\\.", $item))) . "\$"; // search find_item($dir, $pat, $list, $subdir); if (is_array($list)) { sort($list); } return $list; }
function find_item_ftp($dir, $item, &$list, $recur, $content) { // find items $homedir = realpath($GLOBALS['home_dir']); $opendir = $dir; // convert shell-wildcards to PCRE Regex Syntax $pat = str_replace("?", ".", str_replace("*", ".*", str_replace(".", "\\.", $item))); if (!is_dir($dir)) { $opendir = get_abs_dir($dir); } $handle = @$GLOBALS['ext_File']->opendir($opendir); if ($handle === false && $dir == "") { $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']); } if ($handle === false) { ext_Result::sendResult('search', false, $opendir . ": " . $GLOBALS["error_msg"]["opendir"]); } while (($new_item = $GLOBALS['ext_File']->readdir($handle)) !== false) { if (is_array($new_item)) { $abs_new_item = $new_item; } else { $abs_new_item = get_abs_item($dir, $new_item); } //if(!$GLOBALS['ext_File']->file_exists($abs_new_item)) continue; if (!get_show_item($dir, $new_item)) { continue; } $isDir = get_is_dir($abs_new_item); // match? $include = false; if (@preg_match('@' . $pat . '@is', $new_item) > 0) { $include = true; } if (!$isDir && $include && $content && $GLOBALS['ext_File']->filesize($abs_new_item) < 524288) { $data = $GLOBALS['ext_File']->file_get_contents($abs_new_item); $pattern = preg_quote($content, '/'); // finalise the regular expression, matching the whole line $pattern = "/^.*{$pattern}.*\$/m"; if (preg_match('@' . $pattern . '@is', $data) > 0) { $include = true; } } if ($include) { $list[] = array($dir, $new_item); } // search sub-directories if ($isDir && $recur) { find_item($abs_new_item, $pat, $list, $recur, $content); } } $GLOBALS['ext_File']->closedir($handle); }
function make_list($dir, $item, $subdir, $content) { // make list of found items // convert shell-wildcards to PCRE Regex Syntax $pat = str_replace("?", ".", str_replace("*", ".*", str_replace(".", "\\.", $item))); // search find_item($dir, $pat, $list, $subdir, $content); if (is_array($list)) { sort($list); } return $list; }
$result = false; } } if ($result) { send_list_updates($artist_created, $album_created, $ttid, false); $returninfo['metadata'] = get_all_data($ttid); } } print json_encode($returninfo); } else { debuglog("TTID Not Found", "USERRATING", 2); header('HTTP/1.1 417 Expectation Failed'); } break; case 'delete': $ttids = find_item($uri, null, null, null, null, true); if (count($ttids) == 0) { header('HTTP/1.1 400 Bad Request'); } else { delete_track(array_shift($ttids)); } break; case 'deletewl': $ttid = find_wishlist_item(html_entity_decode($artist), html_entity_decode($album), html_entity_decode($title)); if ($ttid == null) { header('HTTP/1.1 400 Bad Request'); } else { delete_track($ttid); } break; case 'cleanup':