Customized File Download in PHP

<?
if($_GET['action']==”download”){
$file = “./images/”.$_GET['filename'].”.”;
header(“Content-type: application/force-download”); //optional
header(“Content-Transfer-Encoding: Binary”);
header(“Content-length: “.filesize($file));
header(“Content-Disposition: attachment; filename=”.basename($file).”");
readfile(“$file”);
}else{
$folder = “./images/”;
if (is_dir($folder)){
$contents = scandir($folder);
$bad = array(“.”, “..”, “.DS_Store”, “_notes”, “Thumbs.db”);
$files = array_diff($contents, $bad);
}
echo<<<FILES
?>
<table>
<?
FILES;
while(list($key,$value) = each($files)){
$rCtr++;
echo<<<FILES
?>
<tr><td align=”right”>$value</td>
<td><img src=”images/download.png”
onmousedown=”window.open(‘$PHP_SELF?action=download&filename=$value’,'_self’)”
style=”cursor:pointer” /></td></tr>
<?
FILES;
}
?>
</table>
<?
}
?>

<?

if($_GET['action']==”download”){

$file = “./images/”.$_GET['filename'].”.”;

header(“Content-type: application/force-download”); //optional

header(“Content-Transfer-Encoding: Binary”);

header(“Content-length: “.filesize($file));

header(“Content-Disposition: attachment; filename=”.basename($file).”");

readfile(“$file”);

}else{

$folder = “./images/”;

if (is_dir($folder)){

$contents = scandir($folder);

$bad = array(“.”, “..”, “.DS_Store”, “_notes”, “Thumbs.db”);

$files = array_diff($contents, $bad);

}

echo<<<FILES

?>

<table>

<?

FILES;

while(list($key,$value) = each($files)){

$rCtr++;

echo<<<FILES

?>

<tr><td align=”right”>$value</td>

<td><img src=”images/download.png”

onmousedown=”window.open(‘$PHP_SELF?action=download&filename=$value’,'_self’)”

style=”cursor:pointer” /></td></tr>

<?

FILES;

}

?>

</table>

<?

}

?>

PHP File Download

<?php

// place this code inside a php file and call it f.e. "download.php"
$path = $_SERVER['DOCUMENT_ROOT']."/path2file/"; // change the path to fit your websites document structure
$fullPath = $path.$_GET['download_file'];

if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;
// example: place this kind of link into the document where the file download is offered:
// <a href="download.php?download_file=some_file.pdf">Download here</a>
?>

List of Passers PSU – Lingayen College Admission Test

List of Passers PSU – Lingayen College Admission Test
Date of Exam: November 5 & 6, 2009

1      ARESPI, Mary Grace C.
2      BRAVO, Mark Jayson Z.
3      CACATIAN, Jan paul F.
4      CARIG, Ali-Rose
5      CASTILLO, Clarissa A.
6      CASTILLO, Kaye One J.
7      CORRE, Michelle Joy
8      DE GUZMAN Jr, Alfredo M.
9      DOMAGAS, Kevien Allan E.
10    ENOR, Jenny Lyn P.
11    FERRER, Janet S.
12    FRONDA, Ma. Kristina B.
13    GAPASIN, Marilyn J.
14    IGNACIO, Erish Yvonne M.
15    LOPEZ, Remzceil C.
16    MANAOIS, Charito B.
17    MANAOIS, Charles B.
18    MEGU, VANESSA L.
19    MENDEGORIN, Christine M.
20    MOLINO, Mona Marie V.      no pic submitted
21    ORAZA, Joel M.
22    PASAGOY, Josua A.
23    PERALTA, Stephen Jan D.
24    PEREZ, JAYLA JOY C.
25    RAMOS, Gembert R.    no pic submitted
26    RIVERA, Ryan M.
27    SOTELO, Rochelle P.
28    TOMAS, Robert V.
29    ULANDAY, Maria Christine R.
30    VALLEJOS Jr., Luther Carl P.
31    VERGARA, Rachelle C.
32    VIRGO, Catherine I.

*** Please get your passer slip at the Guidance Office before proceeding for evaluation and enrollment

Please scroll down for the requirements and evaluation procedure

List of examinees who passed the PSU – College Admission Test

Ade, Saint Raymond T.
Ayala, Michael Angelo P.
Balois, Mary Jane C.
Barnachea, John Carl S.
Biag, Anabelle G.
Braza, Jhon Kirby F.
Camba, Leilani O.
Cayabyab, Sarah Rhea C.
Clemente, Josephine S.
Corla, Cherry Lhen M.
De Castro, Levi Dan L.
Dorognan, Jenelyn G.
Isleta, Clarizze Anne C.
Licuanan, Crystal Jade V.
Ocon, Cherry Mae T.
Ramos Jr., Loreto G.
Ramos, Mary Ann A.
Repato, Art Wilson G.
Sino Cruz, Virgie Lizza B.
Talinio, Emmanuel Gerald C.
Vallata, Jevy Lynn B.

BRING THE FOLLOWING REQUIREMENTS:

  • Honorable Dismissal / Certificate of Transfer
  • Certification of Grades / Transcript of Records
  • Photocopy of NSO Birth Certificate
  • Medical Certificate
  • 2 pcs 2 x 2 picture
  • 1 pc. 1×1 picture
  • Long Brown Envelope w/ PSU Logo (available at PSU Coop Store)

*** Foreign students are required to report at the Registrar’s Office for additional requirements and evaluation.

Please refer to the following personnel for evaluation and enrolment:

AB Public Administration – Mrs. Rhodora Malicdem – Soc Sci Dept.
AB Economics – Mrs. Erna Salazar – Soc Sci Dept.
BS Business Management – Mrs. Magni Fernandez – Soc Sci Dept.
BS Social Work – Mrs. Cheryl Escaño – Soc Sci Dept.
Secondary Education ( Social Studies) – Dr. Julie Lomibao – Soc Sci Dept.
BS Computer Science – Mr. Marvin Santillan – Math Dept.
BS Information & Comm. Tech – Mr. Russel Dela Cruz – Math Dept.
BS Mathematics – Ms. Maila Puzon – Math Dept.
BS Hospitality Management ( HRM) – Mrs. Mila Malicdem – Food Lab 2
BS Nutrition and Dietetics – Dr. Ofelia Puzon – ND Faculty Room
Secondary Education ( Physical Science) – Dr. Zeny Abalos – Sci Faculty Rm.
Secondary Education ( English ) – Dr. Perla Urbano – Convention Hall
Secondary Education ( Home Mgt.) – Prof. Chari Valencerina – Food Lab 1
AB English – Mr. Rhomir Yanquiling – Convention Hall
Industrial Technology – Prof. Francis Lazo – West Campus

Final Requirements for IV – BSICT

Final checking of project proposal documents and prototype will be on November 6, 2009. Revisions should be at least 15% finish before your final grades will be given.

Release of Classcards

The release of classcards for subjects handled by Mr. VAA will be on November 3, 2009.

PSU Lingayen Campus Tribute to Retirees 2009


Download the video.

Proposal Presentation Schedule for IV – BSICT

Schedule for Proposal Presentation and group sequence can be viewed using the following link:

October 21, 2009 (Wednesday)
October 22, 2009 (Thursday)

The proposal presentation will start at 8:30am of the said date.  Each group will be given a 45 minutes to 1 hour of discussion of proposal and prototype.  Your power point or flash presentation  should be set up earlier prior to the start of the presentation.  Provide four copies of your proposal documents that should given to your adviser and panelists before the scheduled presentation to your class adviser.

No show or a 30-minutes late during the scheduled presentation means an outright failure.

Final Exemption Opportunity for III – BSICT

Students who are interested to try this problem can earn and extra points or exemption for finals.  Solve the problem using PHP scripting language.

Show your codes on October 19, 2008 (9:00) to your instructor for checking and evaluation.

The problem was excerpt from HP CodeWars 2009.

Redundant Acronym Syndrome Syndrome

Task Description

From Wikipedia, the free encyclopedia:

The term RAS syndrome refers to the use of one of the words that make up an acronym as well as the abbreviation itself, thus in effect repeating that word. It stands for “Redundant Acronym Syndrome syndrome,” and is itself a humorous example of a redundant acronym.

Write a program that generates RAS syndrome acronyms.

Program Input

Each line of the input contains one or more words. The line of text will be no longer than 80 letters, spaces, and/or punctuation. The last line of the input is the word END.

automated teller machine
random access memory
alternating current
scholastic aptitude test
international standard book number
END

Program Output

The program must print the acronyms in RAS syndrome format. For this program you can assume that the repeated word is always the last word of the input line. Acronyms must be upper-case, regardless of the case of the input.

ATM machine
RAM memory
AC current
SAT test
ISBN number

New Schedule and Announcement of Opportunity Activity for III – BSICT

Here are the schedule for the month of October:

Date Activities
15 Final Submission of Project
19 Final Examination
21 Tentative Day of Releasing of Classcards

Opportunity Activity will be posted on the next article for interested students who would like to earn an extra point or a possible exemption.

Always check the website for updated and fresh announcements.