-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanPrompts.php
More file actions
64 lines (52 loc) · 2.24 KB
/
scanPrompts.php
File metadata and controls
64 lines (52 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
$path = '/var/www/html/ziptie/llama.cpp/prompts';
$path2 = '/var/www/html/ziptie/prompts';
shell_exec("rm /var/www/html/ziptie/avaliablePrompts.txt");
shell_exec("touch /var/www/html/ziptie/llama.cpp/prompts/no-pre-prompt.txt");
// function getDirContents($path) {
// $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
// $files = array();
// foreach ($rii as $file)
// if (!$file->isDir())
// $files[] = $file->getPathname();
// return $files;
// }
// $modelArray = getDirContents($path);
// foreach($modelArray as $modelFileName) {
// if(!str_contains($modelFileName, ':Zone.Identifier')){
// $promptFullPath = $modelFileName;
// $promptName = str_replace("/var/www/html/ziptie/llama.cpp/prompts/", "", "$modelFileName");
// $promptName = explode(".", $promptName);
// $promptName = $promptName[0];
// echo "<script>console.log('$promptName --- $promptFullPath')</script>";
// echo '<br>';
// $myfile = fopen("/var/www/html/ziptie/avaliablePrompts.txt", "a") or die("Unable to open file!");
// $txt = "$promptName~$promptFullPath\n";
// fwrite($myfile, $txt);
// fclose($myfile);
// }
// }
function getDirContents2($path2) {
$rii2 = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path2));
$files2 = array();
foreach ($rii2 as $file2)
if (!$file2->isDir())
$files2[] = $file2->getPathname();
return $files2;
}
$modelArray2 = getDirContents2($path2);
foreach($modelArray2 as $modelFileName2) {
if(!str_contains($modelFileName2, ':Zone.Identifier')){
$promptFullPath2 = $modelFileName2;
$promptName2 = str_replace("/var/www/html/ziptie/prompts/", "", "$modelFileName2");
$promptName2 = explode(".", $promptName2);
$promptName2 = $promptName2[0];
echo "<script>console.log('$promptName2 --- $promptFullPath2')</script>";
echo '<br>';
$myfile2 = fopen("/var/www/html/ziptie/avaliablePrompts.txt", "a") or die("Unable to open file!");
$txt2 = "$promptName2~$promptFullPath2\n";
fwrite($myfile2, $txt2);
fclose($myfile2);
}
}
?>