thaiall logomy background
coding : gallery. gallery.pl.
my town
Source : Perl | PHP | ASP | JSP | HTML | HTML5 | JavaScript | Java | COBOL | C++ | MS Access | VBNet | VB | Python | โค้ดดี
File : gallery.pl. ID : 0601
Skin : Default | Sons-of-obsidian | Sunburst | Highlighter | Full
#!/usr/bin/perl
$droot = "/home/";
$i=0;
$title[$i]="pokemon"; $galt[$i]="pokemon"; $gale[$i]="pokemon"; $i++;
$title[$i]="cartoon"; $galt[$i]="cartoont"; $gale[$i]="cartoone"; $i++;
$title[$i]="streetfighter"; $galt[$i]="sft"; $gale[$i]="sfe"; $i++;
$title[$i]="test"; $galt[$i]="g01t"; $gale[$i]="g01e"; $i++;
$imax=$i-1;
&parse_form;
for $j(0..$imax) { if ($v{'cat'} eq $title[$j]) { $gal=$j; } }
$gdire=join '',"/",$gale[$gal],"/"; &getf;
print"Content-type:text/html\n\n";   
print'<html><head><base target=_blank></head><body>';
$trowcol = $v{'row'} * $v{'col'};
$tot_page = ($tot_pro - ($tot_pro % $trowcol)) / $trowcol + 1;
if ($v{'res'} eq '800') {
  if ($v{'col'} eq '6') {$wd = 100;}
  if ($v{'col'} eq '7') {$wd = 85;}
  if ($v{'col'} eq '8') {$wd = 75;}
}
if ($v{'res'} eq '1024') {
  if ($v{'col'} eq '6') {$wd = 130;}
  if ($v{'col'} eq '7') {$wd = 110;}
  if ($v{'col'} eq '8') {$wd = 100;}  
}
print"<form action=gallery.pl action=post target=_top>";
if (!$v{'file'}) {
print'<table width=100% border=1><tr><td>';
print'<select NAME=row SIZE=1>';
for $i (4..6) {
  print"<option value=$i ";
  if ($v{'row'} eq $i) { print'selected';} print">$i row";
}
print'</select></td><td align=center>';
print'<select NAME=col SIZE=1>';
for $i (6..8) {
  print"<option value=$i ";
  if ($v{'col'} eq $i) { print'selected';} print">$i col";
}
print'</select></td><td align=center>';
print'<select NAME=res SIZE=1>';
print'<option value=800 ';
if ($v{'res'} eq '800') { print'selected';} print'>800*600';
print'<option value=1024 ';
if ($v{'res'} eq '1024') { print'selected';} print'>1024*768';
print'</select></td><td align=center>';
print'<select NAME=seq SIZE=1>';
print'<option value=asc ';
if ($v{'seq'} eq 'asc') { print'selected';} print'>Ascending';
print'<option value=des ';
if ($v{'seq'} eq 'des') { print'selected';} print'>Descending';
print"</select></td><td>$v{'page'} of $tot_page</td><td>", $v{'row'}*$v{'col'};
print" Pic/Page</td><td>$tot_pro Total Pic</td></tr></table>";
}
print'<table width=100% border=1><tr><td valign=top width=100>';
print"<input type=submit value='Go gallery'>";
print'<select NAME=cat SIZE=8>';
for $i(0..$imax) {
  print"<option value=$title[$i]";
  if ($title[$gal] eq $title[$i]) { print" selected";} 
  print">$title[$i]";
}
print"</select>$hr เลือกหน้า<br>";
for $i(1..$tot_page) { print'<input type=submit name=page value=',$i,'> '; }
print'</form></td><td bgcolor=#fffffd align=center valign=top>';
print'<table width=100%><td>';
if ($v{'file'}) {
  print"<center><img src=$gdire$v{'file'}></center>";
} else {  
  for $i(1..$trowcol) {
    $p = $v{'page'}*$trowcol-$trowcol+$i-1; 
    if ($p<10) { $p=join'','00',$p; } else { if ($p<100) { $p=join'','0',$p; }} 
    if ($p < $tot_pro) {
      @filetr = split ("\/",$okr[$p]);
	  $filet = $filetr[@filetr - 1];
      print'<a href=gallery.pl?cat=',$v{'cat'},'&file=',$filet;
	  print'><img border=0 src=',$okr[$p],' width=',$wd,'></a> ',"\n";
    }
  }    
}
print'</td></table></td></tr></table></body></html>';

sub parse_form {
  if ($ENV{'REQUEST_METHOD'} eq 'GET') {
    @pairs = split(/&/, $ENV{'QUERY_STRING'});
  } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
  }  
  foreach $pair (@pairs) {
    local($name, $value) = split(/=/, $pair);
    $v{$name} = $value;
  }
if (!$v{'cat'}) { $v{'cat'}=$title[0]; }
if (!$v{'seq'}) { $v{'seq'}='asc'; }
if (!$v{'res'}) { $v{'res'}=800; }
if (!$v{'col'}) { $v{'col'}=6; }
if (!$v{'row'}) { $v{'row'}=4; }
if (!$v{'page'}) { $v{'page'}=1; }
}

sub getf{
$gdirt=join '',$droot,$galt[$gal],"/.";
opendir(click,"$gdirt");
@allf = readdir click;	
closedir(click);   
for $i (0 .. @allf) {		
  $r4 = lc substr($allf[$i],length($allf[$i])-4,4);
  if (length($allf[$i]) > 4 and  ($r4 eq ".jpg" or $r4 eq ".gif")) { 
    $pp = join '',"/",$galt[$gal],"/",$allf[$i];
    push @okr,$pp; 
  }
}
if ($v{'seq'} eq "des") { @okr = reverse sort @okr; }
$tot_pro = @okr;
}
จำนวน : 116 บรรทัด
าษาเฮชทีเอ็มแอล (HTML = HyperText Markup Language) คือ ภาษาคอมพิวเตอร์ที่ออกแบบมาเพื่อใช้ในการสร้างเว็บเพจที่เรียกดูผ่านทางเว็บเบราว์เซอร์ (Web Browser) เริ่มพัฒนาโดย ทิม เบอร์เนอรส์ ลี (Tim Berners Lee) ในปัจจุบัน HTML ล่าสุดคือ รุ่น 5 เป็นมาตรฐานหนึ่งของ ISO ซึ่งจัดการโดย World Wide Web Consortium (W3C) ในปัจจุบัน ทาง W3C ผลักดัน รูปแบบของ HTML แบบใหม่ ที่เรียกว่า XHTML รุ่นแรกคือ 1.0 (ม.ค.2543) ซึ่งมีโครงสร้างเป็นแบบ XML (eXtensible Markup Language)
าษาพีเอชพี (PHP Language) คือ ภาษาคอมพิวเตอร์ประเภทโอเพนท์ซอร์ท (Open Source Computer Language) สำหรับพัฒนาเว็บเพจแบบไดนามิก เมื่อเครื่องบริการได้รับคำร้องจากผู้ใช้ก็จะส่งให้กับ ตัวแปลภาษา ทำหน้าที่ประมวลผลและส่งข้อมูลกลับไปยังเครื่องของผู้ใช้ที่ร้องขอ ในรูปเอชทีเอ็มแอล ภาพ หรือแฟ้มดิจิทอลอื่นใด ลักษณะของภาษามีรากฐานคำสั่งมาจากภาษาซี เป็นภาษาที่สามารถพัฒนาให้ใช้งานแบบโต้ตอบกับผู้ใช้ได้
าษาไพทอน (Python Language) คือ ภาษาคอมพิวเตอร์ประเภทโอเพนท์ซอร์ท (Open Source Computer Language) สำหรับพัฒนาแอพพลิเคชั่นโดยไม่ยึดติดกับแพลตฟอร์ม (Platform) และใช้ในงานได้หลายประเภท ทั้งใช้ในการประมวลผลผ่านคอมมานด์ไลน์ หรือเป็นเว็บเพจแบบไดนามิก เมื่อเครื่องบริการได้รับคำร้องจากผู้ใช้ก็จะส่งให้โค้ดให้กับตัวแปลภาษา เพื่อทำหน้าที่ประมวลผลและส่งข้อมูลกลับไปยังเครื่องของผู้ใช้ที่ร้องขอ ในรูปข้อความ เอชทีเอ็มแอล ภาพ หรือแฟ้มดิจิทอลอื่นใด ลักษณะของภาษามีรากฐานคำสั่งมาจากภาษาซี เป็นภาษาที่สามารถพัฒนาให้ใช้งานแบบโต้ตอบกับผู้ใช้ได้ จุดที่แตกต่างกับภาษาอื่น คือ การรวบรวมจุดเด่นของแต่ละภาษามารวมเข้าด้วยกัน
อสคิวแอล (SQL = Structured Query Language) คือ ภาษาสอบถามข้อมูล หรือภาษาจัดการข้อมูลอย่างมีโครงสร้าง มีการพัฒนาภาษาคอมพิวเตอร์ และโปรแกรมฐานข้อมูลที่รองรับมากมาย เพราะจัดการข้อมูลได้ง่าย เช่น MySQL, MariaDB, MsSQL, PostgreSQL หรือ MS Access เป็นต้น สำหรับโปรแกรมฐานข้อมูลที่ได้รับความนิยมคือ MySQL หรือ MariaDB เป็น Open Source ที่ใช้งานได้ทั้งใน Linux และ Windows
วัสดีชาวโลก (Hello World) คือ ผลลัพธ์ครั้งแรกที่นักพัฒนาโปรแกรมนิยมเลือกใช้แสดงผลในโปรแกรมแรกที่เขียนขึ้นเพื่อทดสอบการทำงาน ข้อความนี้ทำให้นึกถึงมนุษย์ต่างดาวที่มาเยือนโลกและกล่าวกับมนุษย์เมื่อพบกันครั้งแรกในภาพยนตร์
ตัวอย่าง Hello World
ปรับปรุงโปรแกรม source.pl : 2565-07-24
rspsocial
Thaiall.com