Changeset 67 for branches/testa-single-bookmark/php/content3.php
- Timestamp:
- Sep 5, 2019 9:42:27 AM (6 years ago)
- File:
-
- 1 edited
-
branches/testa-single-bookmark/php/content3.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa-single-bookmark/php/content3.php
r63 r67 15 15 require_once( dirname(__FILE__) . "/spyc-0.5/spyc.php"); // ★の部分にはspyc.phpを置いたパスを入れます 16 16 17 $exec_path = dirname(__FILE__) . "/.."; 17 $Top_path = dirname(__FILE__) . "/.."; 18 $Url_data = null; 19 $Url_data_array = null; 18 20 19 21 function get_url_data_array() … … 25 27 } 26 28 27 function get_url_data_array0()28 {29 $array = array(30 array('url' => 'https://toppers.jp', 'path' => '/var/www/vhosts/devconf.northern-cross.info/httpdocs/a/tmp/devconf-guest-4/tmp/md2site-x/_xtest/wtjx/t12/src') );31 32 return $array;33 }34 35 29 function get_url_data( $num ){ 36 $array = get_url_data_array();37 return $ array[$num];30 global $Url_data_array; 31 return $Url_data_array[$num]; 38 32 } 39 33 … … 43 37 44 38 function get_path_from_url_data( $num , $part){ 39 global $Url_data_array; 40 45 41 switch($part){ 46 42 case 'data': 47 $ret = get_url_data( $num )['path'];43 $ret = $Url_data_array[$num]['path']; 48 44 break; 49 45 case 'conf': 50 $ret = get_url_data( $num )['conf_path'];46 $ret = $Url_data_array[$num]['conf_path']; 51 47 break; 52 48 case 'output': 53 $ret = get_url_data( $num )['output_path'];49 $ret = $Url_data_array[$num]['output_path']; 54 50 break; 55 51 default: … … 123 119 } 124 120 125 126 121 function get_path_info( $num , $part){ 127 122 $path_info = get_path_list_by_url( $num , $part); … … 138 133 function ensure_storage_dir( $storage_dir , $num, $filename ) { 139 134 $dir = implode( "/" , array( $storage_dir , $num) ); 140 mkdir($dir); 135 if( !file_exists( $dir ) ){ 136 mkdir($dir); 137 } 141 138 $path = implode( "/" , array( $dir , $filename) ); 142 139 ensure_dir( $dir ); … … 152 149 } 153 150 154 function build_one_html( $ exec_path, $num , $md_path , $part) {151 function build_one_html( $top_path, $num , $md_path , $part) { 155 152 $pathinfo = pathinfo( $md_path ); 156 153 $md_fname = $pathinfo['basename']; … … 169 166 $output_url = $url_data["output_url"]; 170 167 171 $cmd_line_items = array( $ exec_path . "/bin/build.sh" , $bundle_path , $t, $s, $conf_path);168 $cmd_line_items = array( $top_path . "/bin/build.sh" , $bundle_path , $t, $s, $conf_path); 172 169 173 170 $cmd_line = implode(" " , $cmd_line_items); … … 191 188 192 189 function cmdx(){ 193 global $exec_path; 190 global $Top_path; 191 global $Url_data; 192 global $Url_data_array; 193 194 $Url_data_array = get_url_data_array(); 194 195 195 196 $filelist_filename = array("data"=> "filelist.json", "conf"=> "conf-filelist.json", "output" => "output-filelist.json"); 197 $output_url_filename = "output_url.json"; 196 198 # $storage_dir = dirname(__FILE__) . '/../storage'; 197 199 $storage_dir = dirname(__FILE__) . '/../storage-devconf'; … … 202 204 if (isset($_GET['num'])) { 203 205 $num = $_GET['num']; 206 207 $Url_data = get_url_data($num); 208 204 209 if (isset($_GET['part'])) { 205 210 $part = $_GET['part']; … … 237 242 $content = json_encode($info); 238 243 break; 244 case 'update_output_url_listx': 245 $content = update_output_url_list( $num ); 246 case 'get_output_url_listx': 247 $path = ensure_storage_dir( $storage_dir , $num , $output_url_filename ); 248 if( file_exists($path) ){ 249 $content = input_file( $path ); 250 } 251 else { 252 $content = update_output_url_list( $num ); 253 } 254 break; 239 255 default: 256 $content = "bad cmd=" . $cmd; 240 257 break; 241 258 } … … 248 265 if (isset($_POST['num'])) { 249 266 $num = $_POST['num']; 267 268 $Url_data = get_url_data($num); 269 250 270 if (isset($_POST['part'])) { 251 271 $part = $_POST['part']; … … 259 279 $top_path = get_path_from_url_data( $num , $part); 260 280 $filename_abs_path = $top_path . DIRECTORY_SEPARATOR . $path; 261 $ret = build_one_html( $ exec_path , $num, $path, $part );281 $ret = build_one_html( $Top_path , $num, $path, $part ); 262 282 } 263 283 else{ … … 304 324 } 305 325 else{ 306 echo( $content);326 echo("no content"); 307 327 } 308 328 } … … 331 351 332 352 function get_full_path($num, $key, $fname){ 333 $array = get_url_data_array(); 334 return $array[$num][$key] . "/" . $fname; 335 } 336 337 function get_restrict_from_settings_yml() { 338 $settings = get_url_data_array(); 339 $array = $settings[0]['restrict']; 353 global $Url_data_array; 354 return $Url_data_array[$num][$key] . "/" . $fname; 355 } 356 357 function get_restrict_from_settings_yml( $num ) { 358 global $Url_data_array; 359 360 /* $settings = get_url_data_array();*/ 361 $settings = $Url_data_array; 362 if( !isset($settings[$num]) ){ 363 return array(); 364 } 365 $array = $settings[$num]['restrict']; 366 if( !isset( $array ) ){ 367 return array(); 368 } 340 369 341 370 $r_keys = array_keys( $array ); … … 361 390 $list = get_site_tsv($num ); 362 391 363 $restrict_array = get_restrict_from_settings_yml( );392 $restrict_array = get_restrict_from_settings_yml( $num ); 364 393 365 394 foreach( $list as $k => $v ){ … … 399 428 } 400 429 430 function update_output_url_list( $num ){ 431 $json_data = get_output_url_list( $num ); 432 $content = json_encode($json_data); 433 output_file( $path , $content ); 434 435 return $content; 436 } 437 438 function get_output_url_list( $num ){ 439 $output_url = get_output_url($num); 440 $data = array( "output_url" => get_output_url($num), 441 "htmlfname" => array() 442 ); 443 444 $list = get_site_tsv( $num ); 445 $restrict_htmlnames = get_restrict_basenames( $num ); 446 447 $output_path = get_path_from_url_data( $num, 'output' ); 448 foreach( $list as $k => $v ){ 449 $htmlfname = $v["output_html"]; 450 if( $htmlfname !== null ){ 451 $array = array( "full" => "", "partial" => "" ); 452 if( !isset( $restrict_htmlnames[$htmlfname] ) ){ 453 $fpath = $output_path . '/' . $htmlfname; 454 if( file_exist($fpath) ){ 455 $array["full"] = $htmlfname; 456 } 457 $fpath_tmp = $fpath . '.tmp'; 458 if( file_exist($fpath_tmp) ){ 459 $array["partial"] = $htmlfname_tmp; 460 } 461 array_push( $data["htmlfname"] , $array); 462 } 463 } 464 } 465 466 return $data; 467 } 468 401 469 function get_output_url($num){ 402 $settings = get_url_data_array(); 403 return $settings[$num]['output_url']; 470 return $Url_data['output_url']; 404 471 } 405 472 406 473 function get_restrict($num){ 407 $settings = get_url_data_array(); 408 return $settings[$num]['restrict']; 409 } 410 411 function get_item($num, $name){ 412 $settings = get_url_data_array(); 413 return $settings[$num][$name]; 414 } 415 416 function get_settings_file( $name ){ 417 $dir = get_item( 0 , "conf_path" ); 418 $path = implode( "/" , [$dir, $name] ); 419 420 return $path; 421 } 422 423 function do_exec(){ 424 $cmd = "ls -l /z"; 425 426 exec($cmd, $opt, $ret); 427 428 # print_r($opt); 429 # echo "ret=" . $ret . "\n"; 474 /* $settings = get_url_data_array();*/ 475 global $Url_data_array; 476 return $Url_data_array[$num]['restrict']; 430 477 } 431 478 432 479 cmdx(); 433 /* 434 do_exec(); 435 */ 436 /* 437 $num = 0; 438 $path = "/attempt/devconf2018/data/devconf2018.md"; 439 $part = "data"; 440 $lines = build_one_html( $exec_path, $num , $path , $part ); 441 442 var_dump( $lines ); 443 444 foreach( $lines as $k => $v ){ 445 if( is_array( $v )){ 446 echo implode( "\n" , $v ); 447 } 448 else{ 449 echo $v . "\n"; 450 } 451 } 452 */ 480 481 #echo json_encode( get_output_url_list(0) ); 482 # var_dump( get_output_url_list(0) ); 483 #var_dump( get_output_url_list(0) ); 484 #echo json_encode( get_output_url_list(0) ); 453 485 ?>
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)