Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($handle = opendir('/var/www/html/PIIF/PIIF/PiiF'))
- {
- #$director = 'D:\wamp\www\2xpiif_redirect\PiiF\\';
- $director = '/var/www/html/PIIF/PIIF/PiiF/';
- $d = dir($director);
- echo "Handle: ".$d->handle."<br>\n";
- echo "Path: ".$d->path."<br>\n";
- $cat_a = 0;
- $cat_b = 0;
- $cat_c = 0;
- while($entry=$d->read())
- {
- if ($entry != "." && $entry != "..")
- {
- if(strtoupper(substr($entry,0,1))=="A"){
- if($cat_a==0){
- #$categ_a_id = 1;
- #echo "se creeaza categoria FUNDAMENTELE INGINERIEI FLUIDELOR<br />";
- $cat_a = 1;
- $categoria_a = $web3->objectFactory->newObject('Cepapers',array('title_ro'=>'FUNDAMENTELE INGINERIEI FLUIDELOR','isPermanent'=>true),'45793669');
- $categ_a_id = $categoria_a->id;
- echo "Categoria: ".$categ_a_id."<br />";
- }
- }
- else if(strtoupper(substr($entry,0,1))=="B"){
- if($cat_b==0){
- #$categ_b_id = 2;
- #echo "se creeaza categoria APLICAŢII DE BAZĂ ÎN INGINERIA FLUIDELOR<br />";
- $cat_b = 1;
- $categoria_b = $web3->objectFactory->newObject('Cepapers',array('title_ro'=>'APLICAŢII DE BAZĂ ÎN INGINERIA FLUIDELOR','isPermanent'=>true),'45793669');
- $categ_b_id = $categoria_b->id;
- echo "Categoria: ".$categ_b_id."<br />";
- }
- }
- else if(strtoupper(substr($entry,0,1))=="C"){
- if($cat_c==0){
- #$categ_c_id = 3;
- #echo "se creeaza categoria APLICAŢII COMPLEXE ÎN INGINERIA FLUIDELOR<br />";
- $cat_c = 1;
- $categoria_c = $web3->objectFactory->newObject('Cepapers',array('title_ro'=>'APLICAŢII COMPLEXE ÎN INGINERIA FLUIDELOR','isPermanent'=>true),'45793669');
- $categ_c_id = $categoria_c->id;
- echo "Categoria: ".$categ_c_id."<br />";
- }
- }
- #echo $entry."<br />";
- /*$opts = array(
- 'http' => array(
- 'method'=>"GET",
- 'header'=>"Content-Type: text/html; charset=utf-8"
- )
- );
- $context = stream_context_create($opts); ,false,$context*/
- $handleFile = @fopen($director.$entry, "ru");
- if ($handleFile) {
- $line_no = 0;
- while (($buffer = fgets($handleFile, 4096)) !== false) {
- $buffer = mb_convert_encoding($buffer, 'HTML-ENTITIES','UTF-8');
- if($line_no == 0){
- $title = $buffer;
- if(strtoupper(substr($entry,0,1))=="A"){
- $id = $categ_a_id;
- }
- else if(strtoupper(substr($entry,0,1))=="B"){
- $id = $categ_b_id;
- }
- else if(strtoupper(substr($entry,0,1))=="C"){
- $id = $categ_c_id;
- }
- $subcat = $web3->objectFactory->newObject('Cepapers',array('title_ro'=>$title,'isPermanent'=>true),$id);
- echo " Subcategoria ".$subcat->id."<br />";
- #$subcat_id = rand(0,100);
- #echo " se creaaza subcateogria: ".$title." cu id ".$subcat_id." de la id: ".$id."<br />";
- }
- else{
- $buffer = trim($buffer);
- if(!empty($buffer)){
- #echo " Se creaza conceptul: ".$buffer." de la id: ".$subcat_id."<br />";
- $concept = $web3->objectFactory->newObject('Cepaper',array('title_ro'=>$buffer,'isPermanent'=>true),$subcat->id);
- echo " Concept ".$concept->id."<br />";
- }
- }
- $line_no++;
- }
- if (!feof($handleFile)) {
- echo "Error: unexpected fgets() fail\n";
- }
- fclose($handleFile);
- }
- }
- }
- $d->close();
- }
Add Comment
Please, Sign In to add comment