function getProjectFiles($root, $curl) { for ($i = 0; $i < count($root); $i++) { if ($root[$i]->type == 'd') { curl_setopt($curl, CURLOPT_URL, 'https://intra.epitech.eu' . $root[$i]->fullpath . '?format=json'); $output = curl_exec($curl); $output = json_decode(clean_json($output)); $root[$i]->subfiles = getProjectFiles($output, $curl); } else { $root[$i]->subfiles = array(); } } return $root; }
private function getProject() { if (!isset($_REQUEST['scolaryear']) || !isset($_REQUEST['codemodule']) || !isset($_REQUEST['codeinstance']) || !isset($_REQUEST['codeacti'])) { echo json_encode(array('error' => 'those parameters are required : scolaryear, codemodule, codeinstance, codeacti')); } else { $output = json_decode(clean_json($this->getPage('https://intra.epitech.eu/intra/module/' . $_REQUEST['scolaryear'] . '/' . $_REQUEST['codemodule'] . '/' . $_REQUEST['codeinstance'] . '/' . $_REQUEST['codeacti'] . '/project/?format=json', false))); if (count($output) > 0) { $project = bind_api(template_project(), $output[0]); $files = json_decode(clean_json($this->getPage('https://intra.epitech.eu/intra/module/' . $_REQUEST['scolaryear'] . '/' . $_REQUEST['codemodule'] . '/' . $_REQUEST['codeinstance'] . '/' . $_REQUEST['codeacti'] . '/project/file/?format=json', false))); $project['files'] = getProjectFiles($files, curl_copy_handle($this->curl)); foreach ($output[0]->registered as $key => $val) { if (isMyProjectGroup($val, $this->login)) { $project['master'] = getProjectMaster($val->master); $project['members'] = getProjectMembers($val->members); } } echo json_encode($project); } else { echo json_encode(array('error' => 'project not found')); } } }
<?php function getProjectFiles($projectPath) { $projectPath = utf8_decode($projectPath); $files = glob($projectPath . "/*"); //$filesx = scandir($projectPath); $filesLength = sizeof($files); for ($i = 0; $i < $filesLength; $i++) { $files[$i] = iconv("ISO-8859-2", "UTF-8", $files[$i]); } echo json_encode($files); } $projectPath = $_POST["projectPath"]; getProjectFiles($projectPath); /* $files = scandir("E://Cvan/Offline/Licznik Logął"); print_r ($files);*/ /* $tmpFile = fopen("E://Cvan/Offline/Licznik Log/xxs.txt", 'r'); $fileForWritingContent = fread($tmpFile, 80); echo $fileForWritingContent; $dir_name = "C://Cvan"; mkdir($dir_name );*/