2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merging the Limesurvey 1.91+ branch of queXS in to the trunk

This commit is contained in:
azammitdcarf
2011-09-08 01:58:41 +00:00
parent dfa55a3b9e
commit eaa9578ab8
2312 changed files with 811461 additions and 597534 deletions

View File

@@ -1,3 +1,10 @@
queXS 1.5.0 - Changes since 1.4.0:
New features:
*Updated to Limesurvey 1.91+
*Data export via Limesurvey allowing for limitations by queXS questionnaire / sample
*Select the first respondent for an appointment by default
queXS 1.4.0 - Changes since 1.3.0: queXS 1.4.0 - Changes since 1.3.0:
New features: New features:

View File

@@ -193,15 +193,23 @@ display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id) if ($questionnaire_id)
{ {
print "<p><a href='?data&amp;questionnaire_id=$questionnaire_id'>". T_("Download all data for this questionnaire") . "</a></p>"; $sql = "SELECT lime_sid
FROM questionnaire
WHERE questionnaire_id = $questionnaire_id";
$ls = $db->GetRow($sql);
$lsid = $ls['lime_sid'];
print "<p><a href='" . LIME_URL . "admin/admin.php?action=exportresults&amp;sid=$lsid'>". T_("Download data for this questionnaire via Limesurvey") . "</a></p>";
print "<h3>" . T_("Please select a sample") . "</h3>";
$sample_import_id = false; $sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
display_sample_chooser($questionnaire_id,$sample_import_id); display_sample_chooser($questionnaire_id,$sample_import_id);
if ($sample_import_id) if ($sample_import_id)
{ {
print "<p><a href='?data&amp;questionnaire_id=$questionnaire_id&amp;sample_import_id=$sample_import_id'>" . T_("Download data for this sample") . "</a></p>"; print "<p><a href='" .LIME_URL . "admin/admin.php?action=exportresults&amp;sid=$lsid&amp;quexsfilterinc=$questionnaire_id:$sample_import_id'>" . T_("Download data for this sample via Limesurvey") . "</a></p>";
//get sample vars //get sample vars
$sql = "SELECT sv.var as value, sv.var as description $sql = "SELECT sv.var as value, sv.var as description
FROM `sample_var` as sv FROM `sample_var` as sv

View File

@@ -49,9 +49,10 @@ xhtml_head(T_("Administrative Tools"),true,array("../css/table.css","../css/admi
print "<div id='menu'><ul class='navmenu'>"; print "<div id='menu'><ul class='navmenu'>";
print "<li><h3>" . T_("Questionnaire creation and management") . "</h3>"; print "<li><h3>" . T_("Questionnaire creation and management") . "</h3>";
print "<ul><li><a href=\"?page=new.php\">" . T_("Create a new questionnaire") . "</a></li>"; print "<ul><li><a href='?page=" . LIME_URL ."admin/admin.php?action=newsurvey'>" . T_("Create an instrument in Limesurvey") . "</a></li>";
print "<li><a href=\"?page=new.php\">" . T_("Create a new questionnaire") . "</a></li>";
print "<li><a href=\"?page=questionnairelist.php\">" . T_("Questionnaire management") . "</a></li>"; print "<li><a href=\"?page=questionnairelist.php\">" . T_("Questionnaire management") . "</a></li>";
print "<li><a href=\"?page=" . LIME_URL . "admin/admin.php\">" . T_("Administer questionnaires with Limesurvey") . "</a></li></ul></li>"; print "<li><a href=\"?page=" . LIME_URL . "admin/admin.php\">" . T_("Administer instruments with Limesurvey") . "</a></li></ul></li>";
print "<li><h3>" . T_("Sample/List management") . "</h3><ul>"; print "<li><h3>" . T_("Sample/List management") . "</h3><ul>";
print "<li><a href=\"?page=import.php\">" . T_("Import a sample file (in CSV form)") . "</a></li>"; print "<li><a href=\"?page=import.php\">" . T_("Import a sample file (in CSV form)") . "</a></li>";

View File

@@ -82,25 +82,11 @@ if (isset($_POST['import_file']))
$rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],get_magic_quotes_gpc())); $rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],get_magic_quotes_gpc()));
$info = $db->qstr(html_entity_decode($_POST['info'],get_magic_quotes_gpc())); $info = $db->qstr(html_entity_decode($_POST['info'],get_magic_quotes_gpc()));
if ($_POST['select'] == "new") //use existing lime instrument
{ $lime_sid = bigintval($_POST['select']);
//create one from scratch
include_once("../functions/functions.limesurvey.php");
$lime_sid = create_limesurvey_questionnaire($name);
}
else
{
//use existing lime instrument
$lime_sid = bigintval($_POST['select']);
}
if ($_POST['selectrs'] == "new")
{ if (is_numeric($_POST['selectrs']))
//create one from scratch
include_once("../functions/functions.limesurvey.php");
$lime_rs_sid = create_limesurvey_questionnaire($db->qstr(T_("Respondent Selection for ") . $_POST['description']),false);
}
else if (is_numeric($_POST['selectrs']))
{ {
$lime_rs_sid = bigintval($_POST['selectrs']); $lime_rs_sid = bigintval($_POST['selectrs']);
} }
@@ -114,7 +100,6 @@ if (isset($_POST['import_file']))
{ {
$qid = $db->Insert_ID(); $qid = $db->Insert_ID();
print "<p>" . T_("Successfully inserted") . " $name " . T_("as questionnaire") . " $qid, " . T_("linked to") . " $lime_sid</p>"; print "<p>" . T_("Successfully inserted") . " $name " . T_("as questionnaire") . " $qid, " . T_("linked to") . " $lime_sid</p>";
print "<p>" . T_("You must now edit and activate the questionnaire") . "</p>";
}else }else
{ {
print "<p>" . T_("Error: Failed to insert questionnaire") . "</p>"; print "<p>" . T_("Error: Failed to insert questionnaire") . "</p>";
@@ -129,7 +114,7 @@ if (isset($_POST['import_file']))
<form enctype="multipart/form-data" action="" method="post"> <form enctype="multipart/form-data" action="" method="post">
<p><input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></p> <p><input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></p>
<p><? echo T_("Name for questionnaire:"); ?> <input type="text" name="description"/></p> <p><? echo T_("Name for questionnaire:"); ?> <input type="text" name="description"/></p>
<p><? echo T_("Select creation type:"); ?> <select name="select"><option value="new"><? echo T_("Create new questionnaire in Limesurvey"); ?></option><? <p><? echo T_("Select limesurvey instrument:");
$sql = "SELECT s.sid as sid, sl.surveyls_title AS title $sql = "SELECT s.sid as sid, sl.surveyls_title AS title
FROM " . LIME_PREFIX . "surveys AS s FROM " . LIME_PREFIX . "surveys AS s
LEFT JOIN " . LIME_PREFIX . "surveys_languagesettings AS sl ON ( s.sid = sl.surveyls_survey_id LEFT JOIN " . LIME_PREFIX . "surveys_languagesettings AS sl ON ( s.sid = sl.surveyls_survey_id
@@ -140,14 +125,20 @@ $surveys = $db->GetAll($sql);
if (!empty($surveys)) if (!empty($surveys))
{ {
print "<select name='select'>";
foreach($surveys as $s) foreach($surveys as $s)
{ {
print "<option value=\"{$s['sid']}\">" . T_("Existing questionnaire:") . " {$s['title']}</option>"; print "<option value=\"{$s['sid']}\">" . T_("Existing instrument:") . " {$s['title']}</option>";
} }
print "</select>";
} }
?></select></p> else
{
print "<a href='" . LIME_URL ."admin/admin.php?action=newsurvey'>" . T_("Create an instrument in Limesurvey") ."</a>";
}
?></p>
<p><? echo T_("Respondent selection type:"); ?> <p><? echo T_("Respondent selection type:"); ?>
<select name="selectrs" onchange="if(this.value=='old') show(this,'rstext'); else hide(this,'rstext');"><option value="none"><? echo T_("No respondent selection (go straight to questionnaire)"); ?></option><option value="old"><? echo T_("Use basic respondent selection text (below)"); ?></option><option value="new"><? echo T_("Create new respondent selection questionnaire in Limesurvey"); ?></option> <select name="selectrs" onchange="if(this.value=='old') show(this,'rstext'); else hide(this,'rstext');"><option value="none"><? echo T_("No respondent selection (go straight to questionnaire)"); ?></option><option value="old"><? echo T_("Use basic respondent selection text (below)"); ?></option>
<? <?
$sql = "SELECT s.sid as sid, sl.surveyls_title AS title $sql = "SELECT s.sid as sid, sl.surveyls_title AS title
FROM " . LIME_PREFIX . "surveys AS s FROM " . LIME_PREFIX . "surveys AS s
@@ -161,7 +152,7 @@ if (!empty($surveys))
{ {
foreach($surveys as $s) foreach($surveys as $s)
{ {
print "<option value=\"{$s['sid']}\">" . T_("Existing questionnaire:") . " {$s['title']}</option>"; print "<option value=\"{$s['sid']}\">" . T_("Existing instrument:") . " {$s['title']}</option>";
} }
} }

View File

@@ -71,6 +71,7 @@ xhtml_head(T_("Operator Performance"),true,array("../css/table.css"),array("../j
//xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); //xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness")));
$questionnaire_id = false; $questionnaire_id = false;
print "<h3>" . T_("Please select a questionnaire") . "</h3>";
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id); display_questionnaire_chooser($questionnaire_id);
@@ -92,6 +93,8 @@ if ($questionnaire_id)
ORDER BY s.start ASC"; ORDER BY s.start ASC";
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
print "<h3>" . T_("Please select a shift") . "</h3>";
display_chooser($rs,"shift_id","shift_id",true,"questionnaire_id=$questionnaire_id"); display_chooser($rs,"shift_id","shift_id",true,"questionnaire_id=$questionnaire_id");

View File

@@ -158,7 +158,7 @@ if (isset($_GET['modify']))
echo "<h1>" . $rs['description'] . "</h1>"; echo "<h1>" . $rs['description'] . "</h1>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'>" . T_("Edit questionnaire in Limesurvey") . "</a></p>"; echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'>" . T_("Edit instrument in Limesurvey") . "</a></p>";
?> ?>
<form action="?modify=<? echo $questionnaire_id; ?>" method="post"> <form action="?modify=<? echo $questionnaire_id; ?>" method="post">
<p><? echo T_("Name for questionnaire:"); ?> <input type="text" name="description" value="<? echo $rs['description']; ?>"/></p> <p><? echo T_("Name for questionnaire:"); ?> <input type="text" name="description" value="<? echo $rs['description']; ?>"/></p>

View File

@@ -66,6 +66,7 @@ $sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample")); xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
print "<h2>" . T_("Please select a questionnaire") . "</h2>";
$questionnaire_id = false; $questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id); display_questionnaire_chooser($questionnaire_id);
@@ -79,52 +80,66 @@ if ($questionnaire_id)
GROUP BY call_attempt.case_id) AS t1 GROUP BY call_attempt.case_id) AS t1
GROUP BY ca1"; GROUP BY ca1";
print "<h2>" . T_("This project") . "</h2>"; $cal = $db->GetAll($sql);
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
$sample_import_id = false; if (!empty($cal))
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
display_sample_chooser($questionnaire_id,$sample_import_id);
if ($sample_import_id)
{ {
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1
FROM call_attempt
JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id')
JOIN sample ON (sample.sample_id = `case`.sample_id AND sample.import_id = '$sample_import_id')
GROUP BY call_attempt.case_id) AS t1
GROUP BY ca1";
print "<h2>" . T_("This sample") . "</h2>"; xhtml_table($cal,array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
print "<h2>" . T_("Please select a sample") . "</h2>";
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
display_sample_chooser($questionnaire_id,$sample_import_id);
$questionnaire_sample_quota_row_id = false; if ($sample_import_id)
if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id);
if ($questionnaire_sample_quota_row_id)
{ {
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample $sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1 FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1
FROM call_attempt FROM call_attempt
JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id') JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id')
JOIN sample ON (sample.sample_id = `case`.sample_id AND sample.import_id = '$sample_import_id') JOIN sample ON (sample.sample_id = `case`.sample_id AND sample.import_id = '$sample_import_id')
JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$questionnaire_sample_quota_row_id')
JOIN sample_var ON (sample_var.sample_id = `case`.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)
GROUP BY call_attempt.case_id) AS t1 GROUP BY call_attempt.case_id) AS t1
GROUP BY ca1"; GROUP BY ca1";
print "<h2>" . T_("This quota") . "</h2>"; $cal = $db->GetAll($sql);
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
if (!empty($cal))
{
xhtml_table($cal,array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
$questionnaire_sample_quota_row_id = false;
if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
print "<h2>" . T_("Please select a quota") . "</h2>";
display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id);
if ($questionnaire_sample_quota_row_id)
{
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1
FROM call_attempt
JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id')
JOIN sample ON (sample.sample_id = `case`.sample_id AND sample.import_id = '$sample_import_id')
JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$questionnaire_sample_quota_row_id')
JOIN sample_var ON (sample_var.sample_id = `case`.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)
GROUP BY call_attempt.case_id) AS t1
GROUP BY ca1";
$cal = $db->GetAll($sql);
if (empty($cal))
print "<p>" . T_("No calls for this quota") . "</p>";
else
xhtml_table($cal,array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
}
}
else
print "<p>" . T_("No calls for this sample") . "</p>";
} }
} }
else
print "<p>" . T_("No calls for this questionnaire") . "</p>";
} }
xhtml_foot(); xhtml_foot();
?> ?>

View File

@@ -121,7 +121,9 @@ xhtml_head(T_("Appointment"),true,array("css/respondent.css"),$js);
//select a respondent from a list or create a new one //select a respondent from a list or create a new one
print("<p>" . T_("Select a respondent") . "</p>"); print("<p>" . T_("Select a respondent") . "</p>");
display_respondent_list($case_id,isset($_GET['respondent_id'])?bigintval($_GET['respondent_id']):false); $sr = display_respondent_list($case_id,isset($_GET['respondent_id'])?bigintval($_GET['respondent_id']):false,true);
if ($sr != false) $_GET['respondent_id'] = $sr;
if(isset($_GET['respondent_id']) && $_GET['respondent_id'] == 0) if(isset($_GET['respondent_id']) && $_GET['respondent_id'] == 0)
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -178,8 +178,9 @@ function return_contact_phone_list($case_id)
* *
* @param int $case_id The case ID * @param int $case_id The case ID
* @param bool|int $respondent_id The respondent already selected or false if none selected * @param bool|int $respondent_id The respondent already selected or false if none selected
* @param bool $first Select the first respondent available if none specifically selected?
*/ */
function display_respondent_list($case_id,$respondent_id = false) function display_respondent_list($case_id,$respondent_id = false,$first = false)
{ {
global $db; global $db;
@@ -195,13 +196,21 @@ function display_respondent_list($case_id,$respondent_id = false)
foreach($rs as $r) foreach($rs as $r)
{ {
$rid = $r['respondent_id']; $rid = $r['respondent_id'];
$selected = ""; if ($respondent_id == false && $first == true)
{
$first = false;
$selected = "selected='selected'";
$respondent_id = $rid;
}
else
$selected = "";
if ($rid == $respondent_id) $selected="selected='selected'"; if ($rid == $respondent_id) $selected="selected='selected'";
print "<option value='?respondent_id=$rid' $selected>{$r['firstName']} {$r['lastName']}</option>"; print "<option value='?respondent_id=$rid' $selected>{$r['firstName']} {$r['lastName']}</option>";
} }
} }
print "<option value='?respondent_id=0' class='addresp'>" . T_("Add respondent") . "</option></select></div>"; print "<option value='?respondent_id=0' class='addresp'>" . T_("Add respondent") . "</option></select></div>";
return $respondent_id;
} }

View File

@@ -173,7 +173,8 @@ function get_stats_by_shift($questionnaire_id,$shift_id)
*/ */
function sec_to_time($seconds) function sec_to_time($seconds)
{ {
$h = 0;
$m = 0;
if($seconds >= 3600){ if($seconds >= 3600){
$h = floor($seconds/3600); $h = floor($seconds/3600);
$seconds = ($seconds%3600); $seconds = ($seconds%3600);

View File

@@ -117,9 +117,15 @@ function xhtml_table($content,$fields,$head = false,$class = "tclass",$highlight
foreach ($fields as $e) foreach ($fields as $e)
{ {
print "<td>{$row[$e]}</td>"; print "<td>";
if (isset($row[$e])) print $row[$e];
print "</td>";
if ($total && in_array($e,$total)) if ($total && in_array($e,$total))
{
if (!isset($tot[$e]))
$tot[$e] = 0;
$tot[$e] += $row[$e]; $tot[$e] += $row[$e];
}
} }
print "</tr>"; print "</tr>";
} }

View File

@@ -1,101 +1,65 @@
<?php <?php
/** /**
* LimeSurvey * LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz * Copyright (C) 2010 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved. * All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php * License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant * LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or * to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or * is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses. * other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details. * See COPYRIGHT.php for copyright notices and details.
* *
* $Id: COPYRIGHT.php 5431 2008-08-16 21:05:52Z c_schmitz $ * $Id: COPYRIGHT.php 8540 2010-03-31 11:37:19Z texens $
*/ */
// no direct access // no direct access
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");} if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
?> ?>
LimeSurvey derives from copyrighted works licensed under the GNU General LimeSurvey derives from copyrighted works licensed under the GNU General
Public License. This version has been modified pursuant to the Public License. This version has been modified pursuant to the GNU
GNU General Public License as of August 5, 2007, and as distributed, General Public License as of August 5, 2007, and as distributed, it
it includes or is derivative of works licensed under the GNU General includes or is derivative of works licensed under the GNU General Public
Public License or other free or open source software licenses, including License or other free or open source software licenses, including works
works copyrighted by any or all of the following, from 2003 through 2007: copyrighted by any or all of the following, from 2003 through 2010:
Jason Cleeland, Carsten Schmitz, Thibault Le Meur, Josef Prandstetter, Jason Cleeland, Carsten Schmitz, Thibault Le Meur, Josef Prandstetter,
David Olivier, Gustavo San Roman, Sébastien Gaugry, Esteban Adrián Pérez, Tony Partner, David Olivier, Gustavo San Roman, S<EFBFBD>bastien Gaugry,
Gasper Koren, Yeung Kai Sun, Shawn Wales, Ronald Leenes, Mario Marani, Esteban Adri<72>n P<>rez, Gasper Koren, Yeung Kai Sun, Shawn Wales, Ronald
Darrel O'Pry, Marco Ermini, Patrick McKnight, Chris Wessells, Johannes Kutsam, Leenes, Mario Marani, Darrel O'Pry, Marco Ermini, Patrick McKnight,
Karyl Stein, Arjen Gideonse, Nikolay Tsanov, Thomas Lee, Liang Zhao, Chris Wessells, Johannes Kutsam, Livio Finos, Karyl Stein, Arjen
Katarina Pavic, Mikkel Skovgaard Sørensen, Rolf Njor Jensen, Johan Geertsma, Gideonse, Nikolay Tsanov, Thomas Lee, Liang Zhao, Katarina Pavic, Mikkel
Ronald Leenes, Peter De Berdt, Patrick Drews, Peter Sereinigg, Skovgaard S<>rensen, Rolf Njor Jensen, Johan Geertsma, Ronald Leenes,
Artemis Mendrinos, David Selmeczi, Gabriele Carioli, Masaru Ryumae, Peter De Berdt, Patrick Drews, Peter Sereinigg, Artemis Mendrinos, David
Odd-Jarle Kristoffersen, Eirik Sunde, Rosaura Gazzola, Job Vieira Lúcio, Selmeczi, Gabriele Carioli, Masaru Ryumae, Odd-Jarle Kristoffersen,
Bogdan Anastasiei, Alexei G. Tchernov, Alexander Shilov, Gasper Koren, Eirik Sunde, Rosaura Gazzola, Job Vieira L<>cio, Bogdan Anastasiei,
Luis M. Martinez, Juan Rafael Fernández, Jose Luis Ramirez, Björn Mildh, Alexei G. Tchernov, Alexander Shilov, Gasper Koren, Luis M. Martinez,
Niklas Andersson, Vinh Ngo and Mitchell Butler. Juan Rafael Fern<72>ndez, Jose Luis Ramirez, Bj<42>rn Mildh, Niklas Andersson,
Vinh Ngo and Mitchell Butler. LimeSurvey also includes or is derivative
of works distributed under the following copyright notices: PHPSurveyor
---- Copyright: Jason Cleeland, 2003 License: GNU General Public License
(GPL V2 or later) ADOdb ---- Copyright: John Lim, 2004 License: GNU
Lesser General Public License (LGPL) PHP-gettext ---- Copyright: Danilo
Segan, 2003, 2006 License: GNU General Public License (GPL V2 or later)
LimeSurvey also includes or is derivative of works distributed under the following copyright notices: DHTML Calendar Widget ---- Copyright: Mihai Bazon, 2002-2005 License:
GNU Lesser General Public License (LGPL) Slider ---- Copyright: Erik
Arvidsson, 1999 - 2002 License: GNU General Public License SHA256 static
class ---- Copyright: Developer's Network (2005) Author: feyd _at_
devnetwork .dot. net License: GNU Lesser General Public License (LGPL)
PHPSurveyor tabPANE ---- Copyright: Emil A Eklund (2004) http://webfx.eae.net
---- License: Apache Software License 2.0 PEAR ---- Copyright: 1997-2004 The
Copyright: Jason Cleeland, 2003 PHP Group License: PHP license phpMailer ---- Copyright: 2001 - 2003
License: GNU General Public License (GPL V2 or later) Brent R. Matzelle License: GNU Lesser General Public License (LGPL)
ADOdb Sanitize Library ---- Copyright: 2002,2003 Free Software Foundation
---- License: GNU General Public License (GPL) TCPDF Class ---- Copyright:
Copyright: John Lim, 2004 2006 Nicola Asuni License: GNU Lesser General Public License (LGPL)
License: GNU Lesser General Public License (LGPL)
PHP-gettext mint_idea Template ---- Copyright: David Kohout
---- http://www.davidkohout.cz License: GNU General Public License (GPL)
Copyright: Danilo Segan, 2003, 2006
License: GNU General Public License (GPL V2 or later)
DHTML Calendar Widget arPHP Class ---- Copyright: 2009 Khaled Al-Shamaa http://www.ar-php.org
---- License: GNU Lesser General Public License (LGPL)
Copyright: Mihai Bazon, 2002-2005
License: GNU Lesser General Public License (LGPL)
Slider
----
Copyright: Erik Arvidsson, 1999 - 2002
License: GNU General Public License
SHA256 static class
----
Copyright: Developer's Network (2005)
Author: feyd _at_ devnetwork .dot. net
License: GNU Lesser General Public License (LGPL)
tabPANE
----
Copyright: Emil A Eklund (2004) http://webfx.eae.net
License: Apache Software License 2.0
PEAR
----
Copyright: 1997-2004 The PHP Group
License: PHP license
phpMailer
----
Copyright: 2001 - 2003 Brent R. Matzelle
License: GNU Lesser General Public License (LGPL)
Sanitize Library
----
Copyright: 2002,2003 Free Software Foundation
License: GNU General Public License (GPL)
TCPDF Class
----
Copyright: 2006 Nicola Asuni
License: GNU Lesser General Public License (LGPL)
mint_idea Template
----
Copyright: David Kohout http://www.davidkohout.cz
License: GNU General Public License (GPL)

View File

@@ -1,340 +1,266 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991
Version 2, June 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA Everyone is permitted to copy and distribute verbatim
copies of this license document, but changing it is not allowed.
Copyright (C) 1989, 1991 Free Software Foundation, Inc. Preamble The licenses for most software are designed to take away your
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA freedom to share and change it. By contrast, the GNU General Public
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software General Public License applies to most of the Free Software Foundation's
Foundation's software and to any other program whose authors commit to software and to any other program whose authors commit to using it.
using it. (Some other Free Software Foundation software is covered by (Some other Free Software Foundation software is covered by the GNU
the GNU Library General Public License instead.) You can apply it to Library General Public License instead.) You can apply it to your
your programs, too. programs, too. When we speak of free software, we are referring to
freedom, not price. Our General Public Licenses are designed to make
When we speak of free software, we are referring to freedom, not sure that you have the freedom to distribute copies of free software
price. Our General Public Licenses are designed to make sure that you (and charge for this service if you wish), that you receive source code
have the freedom to distribute copies of free software (and charge for or can get it if you want it, that you can change the software or use
this service if you wish), that you receive source code or can get it pieces of it in new free programs; and that you know you can do these
if you want it, that you can change the software or use pieces of it things. To protect your rights, we need to make restrictions that forbid
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights. anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it. distribute copies of the software, or if you modify it. For example, if
you distribute copies of such a program, whether gratis or for a fee,
you must give the recipients all the rights that you have. You must make
sure that they, too, receive or can get the source code. And you must
show them these terms so they know their rights. We protect your rights
with two steps: (1) copyright the software, and (2) offer you this
license which gives you legal permission to copy, distribute and/or
modify the software. Also, for each author's protection and ours, we
want to make certain that everyone understands that there is no warranty
for this free software. If the software is modified by someone else and
passed on, we want its recipients to know that what they have is not the
original, so that any problems introduced by others will not reflect on
the original authors' reputations. Finally, any free program is
threatened constantly by software patents. We wish to avoid the danger
that redistributors of a free program will individually obtain patent
licenses, in effect making the program proprietary. To prevent this, we
have made it clear that any patent must be licensed for everyone's free
use or not licensed at all. The precise terms and conditions for
copying, distribution and modification follow. GNU GENERAL PUBLIC
LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
For example, if you distribute copies of such a program, whether 0. This License applies to any program or other work which contains a
gratis or for a fee, you must give the recipients all the rights that notice placed by the copyright holder saying it may be distributed under
you have. You must make sure that they, too, receive or can get the the terms of this General Public License. The "Program", below, refers
source code. And you must show them these terms so they know their to any such program or work, and a "work based on the Program" means
rights. either the Program or any derivative work under copyright law: that is
to say, a work containing the Program or a portion of it, either
We protect your rights with two steps: (1) copyright the software, and verbatim or with modifications and/or translated into another language.
(2) offer you this license which gives you legal permission to copy, (Hereinafter, translation is included without limitation in the term
distribute and/or modify the software. "modification".) Each licensee is addressed as "you". Activities other
than copying, distribution and modification are not covered by this
Also, for each author's protection and ours, we want to make certain License; they are outside its scope. The act of running the Program is
that everyone understands that there is no warranty for this free not restricted, and the output from the Program is covered only if its
software. If the software is modified by someone else and passed on, we contents constitute a work based on the Program (independent of having
want its recipients to know that what they have is not the original, so been made by running the Program). Whether that is true depends on what
that any problems introduced by others will not reflect on the original the Program does. 1. You may copy and distribute verbatim copies of the
authors' reputations. Program's source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an appropriate
Finally, any free program is threatened constantly by software copyright notice and disclaimer of warranty; keep intact all the notices
patents. We wish to avoid the danger that redistributors of a free that refer to this License and to the absence of any warranty; and give
program will individually obtain patent licenses, in effect making the any other recipients of the Program a copy of this License along with
program proprietary. To prevent this, we have made it clear that any the Program. You may charge a fee for the physical act of transferring a
patent must be licensed for everyone's free use or not licensed at all. copy, and you may at your option offer warranty protection in exchange
for a fee. 2. You may modify your copy or copies of the Program or any
The precise terms and conditions for copying, distribution and portion of it, thus forming a work based on the Program, and copy and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions: above, provided that you also meet all of these conditions: a) You must
cause the modified files to carry prominent notices stating that you
a) You must cause the modified files to carry prominent notices changed the files and the date of any change. b) You must cause any work
stating that you changed the files and the date of any change. that you distribute or publish, that in whole or in part contains or is
derived from the Program or any part thereof, to be licensed as a whole
b) You must cause any work that you distribute or publish, that in at no charge to all third parties under the terms of this License. c) If
whole or in part contains or is derived from the Program or any the modified program normally reads commands interactively when run, you
part thereof, to be licensed as a whole at no charge to all third must cause it, when started running for such interactive use in the most
parties under the terms of this License. ordinary way, to print or display an announcement including an
appropriate copyright notice and a notice that there is no warranty (or
c) If the modified program normally reads commands interactively else, saying that you provide a warranty) and that users may
when run, you must cause it, when started running for such redistribute the program under these conditions, and telling the user
interactive use in the most ordinary way, to print or display an how to view a copy of this License. (Exception: if the Program itself is
announcement including an appropriate copyright notice and a interactive but does not normally print such an announcement, your work
notice that there is no warranty (or else, saying that you provide based on the Program is not required to print an announcement.) These
a warranty) and that users may redistribute the program under requirements apply to the modified work as a whole. If identifiable
these conditions, and telling the user how to view a copy of this sections of that work are not derived from the Program, and can be
License. (Exception: if the Program itself is interactive but reasonably considered independent and separate works in themselves, then
does not normally print such an announcement, your work based on this License, and its terms, do not apply to those sections when you
the Program is not required to print an announcement.) distribute them as separate works. But when you distribute the same
sections as part of a whole which is a work based on the Program, the
These requirements apply to the modified work as a whole. If distribution of the whole must be on the terms of this License, whose
identifiable sections of that work are not derived from the Program, permissions for other licensees extend to the entire whole, and thus to
and can be reasonably considered independent and separate works in each and every part regardless of who wrote it. Thus, it is not the
themselves, then this License, and its terms, do not apply to those intent of this section to claim rights or contest your rights to work
sections when you distribute them as separate works. But when you written entirely by you; rather, the intent is to exercise the right to
distribute the same sections as part of a whole which is a work based control the distribution of derivative or collective works based on the
on the Program, the distribution of the whole must be on the terms of Program. In addition, mere aggregation of another work not based on the
this License, whose permissions for other licensees extend to the Program with the Program (or with a work based on the Program) on a
entire whole, and thus to each and every part regardless of who wrote it. volume of a storage or distribution medium does not bring the other work
under the scope of this License. 3. You may copy and distribute the
Thus, it is not the intent of this section to claim rights or contest Program (or a work based on it, under Section 2) in object code or
your rights to work written entirely by you; rather, the intent is to executable form under the terms of Sections 1 and 2 above provided that
exercise the right to control the distribution of derivative or you also do one of the following: a) Accompany it with the complete
collective works based on the Program. corresponding machine-readable source code, which must be distributed
under the terms of Sections 1 and 2 above on a medium customarily used
In addition, mere aggregation of another work not based on the Program for software interchange; or, b) Accompany it with a written offer,
with the Program (or with a work based on the Program) on a volume of valid for at least three years, to give any third party, for a charge no
a storage or distribution medium does not bring the other work under more than your cost of physically performing source distribution, a
the scope of this License. complete machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
3. You may copy and distribute the Program (or a work based on it, customarily used for software interchange; or, c) Accompany it with the
under Section 2) in object code or executable form under the terms of information you received as to the offer to distribute corresponding
Sections 1 and 2 above provided that you also do one of the following: source code. (This alternative is allowed only for noncommercial
distribution and only if you received the program in object code or
a) Accompany it with the complete corresponding machine-readable executable form with such an offer, in accord with Subsection b above.)
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source making modifications to it. For an executable work, complete source code
code means all the source code for all modules it contains, plus any means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to associated interface definition files, plus the scripts used to control
control compilation and installation of the executable. However, as a compilation and installation of the executable. However, as a special
special exception, the source code distributed need not include exception, the source code distributed need not include anything that is
anything that is normally distributed (in either source or binary normally distributed (in either source or binary form) with the major
form) with the major components (compiler, kernel, and so on) of the components (compiler, kernel, and so on) of the operating system on
operating system on which the executable runs, unless that component which the executable runs, unless that component itself accompanies the
itself accompanies the executable. executable. If distribution of executable or object code is made by
offering access to copy from a designated place, then offering
If distribution of executable or object code is made by offering equivalent access to copy the source code from the same place counts as
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not distribution of the source code, even though third parties are not
compelled to copy the source along with the object code. compelled to copy the source along with the object code. 4. You may not
copy, modify, sublicense, or distribute the Program except as expressly
4. You may not copy, modify, sublicense, or distribute the Program provided under this License. Any attempt otherwise to copy, modify,
except as expressly provided under this License. Any attempt sublicense or distribute the Program is void, and will automatically
otherwise to copy, modify, sublicense or distribute the Program is terminate your rights under this License. However, parties who have
void, and will automatically terminate your rights under this License. received copies, or rights, from you under this License will not have
However, parties who have received copies, or rights, from you under their licenses terminated so long as such parties remain in full
this License will not have their licenses terminated so long as such compliance. 5. You are not required to accept this License, since you
parties remain in full compliance. have not signed it. However, nothing else grants you permission to
modify or distribute the Program or its derivative works. These actions
5. You are not required to accept this License, since you have not are prohibited by law if you do not accept this License. Therefore, by
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and Program), you indicate your acceptance of this License to do so, and all
all its terms and conditions for copying, distributing or modifying its terms and conditions for copying, distributing or modifying the
the Program or works based on it. Program or works based on it. 6. Each time you redistribute the Program
(or any work based on the Program), the recipient automatically receives
a license from the original licensor to copy, distribute or modify the
Program subject to these terms and conditions. You may not impose any
further restrictions on the recipients' exercise of the rights granted
herein. You are not responsible for enforcing compliance by third
parties to this License. 7. If, as a consequence of a court judgment or
allegation of patent infringement or for any other reason (not limited
to patent issues), conditions are imposed on you (whether by court
order, agreement or otherwise) that contradict the conditions of this
License, they do not excuse you from the conditions of this License. If
you cannot distribute so as to satisfy simultaneously your obligations
under this License and any other pertinent obligations, then as a
consequence you may not distribute the Program at all. For example, if a
patent license would not permit royalty-free redistribution of the
Program by all those who receive copies directly or indirectly through
you, then the only way you could satisfy both it and this License would
be to refrain entirely from distribution of the Program. If any portion
of this section is held invalid or unenforceable under any particular
circumstance, the balance of the section is intended to apply and the
section as a whole is intended to apply in other circumstances. It is
not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the
free software distribution system, which is implemented by public
license practices. Many people have made generous contributions to the
wide range of software distributed through that system in reliance on
consistent application of that system; it is up to the author/donor to
decide if he or she is willing to distribute software through any other
system and a licensee cannot impose that choice. This section is
intended to make thoroughly clear what is believed to be a consequence
of the rest of this License. 8. If the distribution and/or use of the
Program is restricted in certain countries either by patents or by
copyrighted interfaces, the original copyright holder who places the
Program under this License may add an explicit geographical distribution
limitation excluding those countries, so that distribution is permitted
only in or among countries not thus excluded. In such case, this License
incorporates the limitation as if written in the body of this License.
6. Each time you redistribute the Program (or any work based on the 9. The Free Software Foundation may publish revised and/or new versions
Program), the recipient automatically receives a license from the of the General Public License from time to time. Such new versions will
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns. Each version is given a distinguishing
version number. If the Program specifies a version number of this
License which applies to it and "any later version", you have the option
of following the terms and conditions either of that version or of any
later version published by the Free Software Foundation. If the Program
does not specify a version number of this License, you may choose any
version ever published by the Free Software Foundation. 10. If you wish
to incorporate parts of the Program into other free programs whose
distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make
exceptions for this. Our decision will be guided by the two goals of
preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. NO WARRANTY
Each version is given a distinguishing version number. If the Program 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
specifies a version number of this License which applies to it and "any FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
REPAIR OR CORRECTION. NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS
REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply
These Terms to Your New Programs If you develop a new program, and you
want it to be of the greatest possible use to the public, the best way
to achieve this is to make it free software which everyone can
redistribute and change under these terms. To do so, attach the
following notices to the program. It is safest to attach them to the
start of each source file to most effectively convey the exclusion of
warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
END OF TERMS AND CONDITIONS <one
line to give the program's name and a brief idea of what it does.>
Copyright (C)
<year>
<name of author>
How to Apply These Terms to Your New Programs This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. You should have received a
copy of the GNU General Public License along with this program; if not,
write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA Also add information on how to contact you by
electronic and paper mail. If the program is interactive, make it output
a short notice like this when it starts in an interactive mode:
If you develop a new program, and you want it to be of the greatest Gnomovision version 69, Copyright (C) year name of author Gnomovision
possible use to the public, the best way to achieve this is to make it comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is
free software which everyone can redistribute and change under these terms. free software, and you are welcome to redistribute it under certain
conditions; type `show c' for details. The hypothetical commands `show
w' and `show c' should show the appropriate parts of the General Public
License. Of course, the commands you use may be called something other
than `show w' and `show c'; they could even be mouse-clicks or menu
items--whatever suits your program. You should also get your employer
(if you work as a programmer) or your school, if any, to sign a
"copyright disclaimer" for the program, if necessary. Here is a sample;
alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest
in the program `Gnomovision' (which makes passes at compilers) written
by James Hacker.
To do so, attach the following notices to the program. It is safest <signature of Ty Coon>
to attach them to the start of each source file to most effectively , 1 April 1989 Ty Coon, President of Vice This General Public License
convey the exclusion of warranty; and each file should have at least does not permit incorporating your program into proprietary programs. If
the "copyright" line and a pointer to where the full notice is found. your program is a subroutine library, you may consider it more useful to
permit linking proprietary applications with the library. If this is
<one line to give the program's name and a brief idea of what it does.> what you want to do, use the GNU Library General Public License instead
Copyright (C) <year> <name of author> of this License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -1,5 +0,0 @@
AuthType Basic
AuthName "queXS CATI: Authentication Required"
AuthUserFile /var/opt/quexs/htpasswd
AuthGroupFile /var/opt/quexs/htgroup
require group admin

View File

@@ -1,141 +1,148 @@
<?php <?php
/* /*
* LimeSurvey * LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz * Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved. * All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php * License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant * LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or * to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or * is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses. * other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details. * See COPYRIGHT.php for copyright notices and details.
* *
* $Id: access_denied.php 7140 2009-06-18 06:56:20Z mennodekker $ * $Id: access_denied.php 10925 2011-09-02 14:12:02Z c_schmitz $
*/ */
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly (access_denied)");} if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly (access_denied)");}
if (isset($_SESSION['loginID'])) if (isset($_SESSION['loginID']))
{ {
$accesssummary = "<br /><strong>".$clang->gT("Access denied!")."</strong><br />\n"; $accesssummary = "<p><strong>".$clang->gT("Access denied!")."</strong><br />\n";
$action=returnglobal('action'); $action=returnglobal('action');
if ( $action == "dumpdb" ) if ( $action == "dumpdb" )
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed dump the database!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed dump the database!")."<br />";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "dumplabel") elseif($action == "dumplabel")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed export a label set!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed export a label set!")."<br />";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "edituser") elseif($action == "edituser")
{ {
$accesssummary .= $clang->gT("You are not allowed to change user data!"); $accesssummary .= "<p>".$clang->gT("You are not allowed to change user data!");
$accesssummary .= "<br /><br /><a href='$scriptname?action=editusers'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<br /><br /><a href='$scriptname?action=editusers'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "newsurvey") elseif($action == "newsurvey")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to create new surveys!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to create new surveys!")."<br />";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "deletesurvey") elseif($action == "deletesurvey")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to delete this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to delete this survey!")."<br />";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "addquestion") elseif($action == "addquestion")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to add new questions for this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to add new questions for this survey!")."<br />";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "activate") elseif($action == "activate")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to activate this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to activate this survey!")."<br />";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "deactivate") elseif($action == "deactivate")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to deactivate this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to deactivate this survey!")."<br />";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "addgroup") elseif($action == "addgroup")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to add a group to this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to add a group to this survey!")."<br />";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "ordergroups") elseif($action == "ordergroups")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to order groups in this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to order groups in this survey!")."<br />";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "editsurvey") elseif($action == "editsurvey")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to edit this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to edit this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "editgroup") elseif($action == "editgroup")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to edit groups in this survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to edit groups in this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "browse_response" || $action == "listcolumn" || $action == "vvexport" || $action == "vvimport") elseif($action == "browse_response" || $action == "listcolumn" || $action == "vvexport" || $action == "vvimport")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to browse responses!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to browse responses!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "assessment") elseif($action == "assessment")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to set assessment rules!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to set assessment rules!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "delusergroup") elseif($action == "delusergroup")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to delete this group!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to delete this group!")."</p>";
$accesssummary .= "<a href='$scriptname?action=editusergroups'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?action=editusergroups'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "importsurvey") elseif($action == "importsurvey")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to import a survey!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to import a survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "importgroup") elseif($action == "importgroup")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to import a group!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to import a group!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "importquestion") elseif($action == "importquestion")
{ {
$accesssummary .= "<p>".$clang->gT("You are not allowed to to import a question!")."</p>"; $accesssummary .= "<p>".$clang->gT("You are not allowed to to import a question!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
elseif($action == "CSRFwarn") elseif($action == "CSRFwarn")
{ {
$accesssummary .= "<p><font color='red'>".$clang->gT("Security Alert")."</font>: ".$clang->gT("Someone may be trying to use your LimeSurvey session (CSRF attack suspected). If you just clicked on a malicious link, please report this to your system administrator.")."</p>"; $sURLID='';
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; if (isset($sid)) {
} $sURLID="?sid={$sid}";
elseif($action == "FakeGET") }
{ $accesssummary .= "<p><span color='errortitle'>".$clang->gT("Security alert")."</span>: ".$clang->gT("Someone may be trying to use your LimeSurvey session (CSRF attack suspected). If you just clicked on a malicious link, please report this to your system administrator.").'<br>'.$clang->gT('Also this problem can occur when you are working/editing in LimeSurvey in several browser windows/tabs at the same time.')."</p>";
$accesssummary .= "<p><font color='red'>".$clang->gT("Security Alert")."</font>: ".$clang->gT("Someone may be trying to use your LimeSurvey session by using dangerous GET requests (CSRF attack suspected). If you just clicked on a malicious link, please report this to your system administrator.")."</p>"; $accesssummary .= "<a href='{$scriptname}{$sURLID}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; }
} elseif($action == "FakeGET")
else {
{ $accesssummary .= "<p><span class='errortitle'>".$clang->gT("Security alert")."</span>: ".$clang->gT("Someone may be trying to use your LimeSurvey session (CSRF attack suspected). If you just clicked on a malicious link, please report this to your system administrator.").'<br>'.$clang->gT('Also this problem can occur when you are working/editing in LimeSurvey in several browser windows/tabs at the same time.')."</p>";
$accesssummary .= "<br />".$clang->gT("You are not allowed to perform this operation!")."<br />\n"; $accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
if(!empty($sid)) }
$accesssummary .= "<br /><br /><a href='$scriptname?sid=$sid>".$clang->gT("Continue")."</a><br />&nbsp;\n"; else
elseif(!empty($ugid)) {
//elseif(isset($_GET['ugid'])) $accesssummary .= "<br />".$clang->gT("You are not allowed to perform this operation!")."<br />\n";
{ if(!empty($sid))
$accesssummary .= "<br /><br /><a href='$scriptname?action=editusergroups&ugid={$ugid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; {
} $accesssummary .= "<br /><br /><a href='$scriptname?sid=$sid>".$clang->gT("Continue")."</a><br />&nbsp;\n";
else }
$accesssummary .= "<br /><br /><a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n"; elseif(!empty($ugid))
} {
$accesssummary .= "<br /><br /><a href='$scriptname?action=editusergroups&ugid={$ugid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
} }
else
{
$accesssummary .= "<br /><br /><a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
}
}
?> ?>

View File

@@ -1,588 +1,84 @@
<?php <?php
/* /*
* LimeSurvey * LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz * Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved. * All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php * License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant * LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or * to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or * is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses. * other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details. * See COPYRIGHT.php for copyright notices and details.
* *
* $Id: activate.php 7453 2009-08-12 14:41:09Z c_schmitz $ * $Id: activate.php 10925 2011-09-02 14:12:02Z c_schmitz $
*/ */
//Ensure script is not run directly, avoid path disclosure //Ensure script is not run directly, avoid path disclosure
include_once("login_check.php"); //Login Check dies also if the script is started directly include_once("login_check.php"); //Login Check dies also if the script is started directly
include_once("activate_functions.php");
$postsid=returnglobal('sid'); $postsid=returnglobal('sid');
$activateoutput=''; $activateoutput='';
$qtypes=getqtypelist('','array');
if (!isset($_POST['ok']) || !$_POST['ok']) if (!isset($_POST['ok']) || !$_POST['ok'])
{ {
if (isset($_GET['fixnumbering']) && $_GET['fixnumbering']) if (isset($_GET['fixnumbering']) && $_GET['fixnumbering'])
{ {
//Fix a question id - requires renumbering a question fixNumbering($_GET['fixnumbering']);
$oldqid = $_GET['fixnumbering']; }
$query = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC";
$result = db_select_limit_assoc($query, 1) or safe_die($query."<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow()) {$lastqid=$row['qid'];}
$newqid=$lastqid+1;
$query = "UPDATE {$dbprefix}questions SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
//Update conditions.. firstly conditions FOR this question
$query = "UPDATE {$dbprefix}conditions SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
//Now conditions based upon this question
$query = "SELECT cqid, cfieldname FROM {$dbprefix}conditions WHERE cqid=$oldqid";
$result = db_execute_assoc($query) or safe_die($query."<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
$switcher[]=array("cqid"=>$row['cqid'], "cfieldname"=>$row['cfieldname']);
}
if (isset($switcher))
{
foreach ($switcher as $switch)
{
$query = "UPDATE {$dbprefix}conditions
SET cqid=$newqid,
cfieldname='".str_replace("X".$oldqid, "X".$newqid, $switch['cfieldname'])."'
WHERE cqid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
}
}
//Now question_attributes
$query = "UPDATE {$dbprefix}question_attributes SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
//Now answers
$query = "UPDATE {$dbprefix}answers SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
}
$baselang = GetBaseLanguageFromSurveyID($postsid); // Check consistency for groups and questions
$groupquery = "SELECT g.gid,g.group_name,count(q.qid) as count from {$dbprefix}questions as q RIGHT JOIN {$dbprefix}groups as g ON q.gid=g.gid WHERE g.sid=$postsid AND g.language='$baselang' AND q.language='$baselang' group by g.gid,g.group_name;"; $failedgroupcheck = checkGroup($postsid);
$groupresult=db_execute_assoc($groupquery) or safe_die($groupquery."<br />".$connect->ErrorMsg()); $failedcheck = checkQuestions($postsid, $surveyid, $qtypes);
while ($row=$groupresult->FetchRow())
{ //TIBO
if ($row['count'] == 0)
{
$failedgroupcheck[]=array($row['gid'], $row['group_name'], ": ".$clang->gT("This group does not contain any question(s)."));
}
}
//CHECK TO MAKE SURE ALL QUESTION TYPES THAT REQUIRE ANSWERS HAVE ACTUALLY GOT ANSWERS //IF ANY OF THE CHECKS FAILED, PRESENT THIS SCREEN
//THESE QUESTION TYPES ARE: if ((isset($failedcheck) && $failedcheck) || (isset($failedgroupcheck) && $failedgroupcheck))
// # "L" -> LIST {
// # "O" -> LIST WITH COMMENT $activateoutput .= "<br />\n<div class='messagebox ui-corner-all'>\n";
// # "M" -> MULTIPLE OPTIONS $activateoutput .= "<div class='header ui-widget-header'>".$clang->gT("Activate Survey")." ($surveyid)</div>\n";
// # "P" -> MULTIPLE OPTIONS WITH COMMENTS $activateoutput .= "<div class='warningheader'>\n".$clang->gT("Error")."<br />\n";
// # "A", "B", "C", "E", "F", "H", "^" -> Various Array Types $activateoutput .= $clang->gT("Survey does not pass consistency check")."</div>\n";
// # "R" -> RANKING $activateoutput .= "<p>\n";
// # "U" -> FILE CSV MORE $activateoutput .= "<strong>".$clang->gT("The following problems have been found:")."</strong><br />\n";
// # "I" -> FILE CSV ONE $activateoutput .= "<ul>\n";
// # ":" -> Array Multi Flexi Numbers if (isset($failedcheck) && $failedcheck)
// # ";" -> Array Multi Flexi Text {
// # "1" -> MULTI SCALE foreach ($failedcheck as $fc)
{
$activateoutput .= "<li> Question qid-{$fc[0]} (\"<a href='$scriptname?sid=$surveyid&amp;gid=$fc[3]&amp;qid=$fc[0]'>{$fc[1]}</a>\"){$fc[2]}</li>\n";
}
}
if (isset($failedgroupcheck) && $failedgroupcheck)
{
foreach ($failedgroupcheck as $fg)
{
$activateoutput .= "\t\t\t\t<li> Group gid-{$fg[0]} (\"<a href='$scriptname?sid=$surveyid&amp;gid=$fg[0]'>{$fg[1]}</a>\"){$fg[2]}</li>\n";
}
}
$activateoutput .= "</ul>\n";
$activateoutput .= $clang->gT("The survey cannot be activated until these problems have been resolved.")."\n";
$activateoutput .= "</div><br />&nbsp;\n";
return;
}
$chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type IN ('L', 'O', 'M', 'P', 'A', 'B', 'C', 'E', 'F', 'R', 'J', '!', '^', ':', '1')"; $activateoutput .= "<br />\n<div class='messagebox ui-corner-all'>\n";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't get list of questions<br />$chkquery<br />".$connect->ErrorMsg()); $activateoutput .= "<div class='header ui-widget-header'>".$clang->gT("Activate Survey")." ($surveyid)</div>\n";
while ($chkrow = $chkresult->FetchRow()) $activateoutput .= "<div class='warningheader'>\n";
{ $activateoutput .= $clang->gT("Warning")."<br />\n";
$chaquery = "SELECT * FROM {$dbprefix}answers WHERE qid = {$chkrow['qid']} ORDER BY sortorder, answer"; $activateoutput .= $clang->gT("READ THIS CAREFULLY BEFORE PROCEEDING")."\n";
$charesult=$connect->Execute($chaquery); $activateoutput .= "\t</div>\n";
$chacount=$charesult->RecordCount(); $activateoutput .= $clang->gT("You should only activate a survey when you are absolutely certain that your survey setup is finished and will not need changing.")."<br /><br />\n";
if (!$chacount > 0) $activateoutput .= $clang->gT("Once a survey is activated you can no longer:")."<ul><li>".$clang->gT("Add or delete groups")."</li><li>".$clang->gT("Add or delete questions")."</li><li>".$clang->gT("Add or delete subquestions or change their codes")."</li></ul>\n";
{ $activateoutput .= $clang->gT("However you can still:")."<ul><li>".$clang->gT("Edit your questions code/title/text and advanced options")."</li><li>".$clang->gT("Edit your group names or descriptions")."</li><li>".$clang->gT("Add, remove or edit answer options")."</li><li>".$clang->gT("Change survey name or description")."</li></ul>\n";
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question is a multiple answer type question but has no answers."), $chkrow['gid']); $activateoutput .= $clang->gT("Once data has been entered into this survey, if you want to add or remove groups or questions, you will need to deactivate this survey, which will move all data that has already been entered into a separate archived table.")."<br /><br />\n";
} $activateoutput .= "\t<input type='submit' value=\"".$clang->gT("Activate Survey")."\" onclick=\"".get2post("$scriptname?action=activate&amp;ok=Y&amp;sid={$_GET['sid']}")."\" />\n";
} $activateoutput .= "</div><br />&nbsp;\n";
//NOW CHECK THAT ALL QUESTIONS HAVE A 'QUESTION TYPE' FIELD
$chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type = ''";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing types<br />$chkquery<br />".$connect->ErrorMsg());
while ($chkrow = $chkresult->FetchRow())
{
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question does not have a question 'type' set."), $chkrow['gid']);
}
//CHECK THAT FLEXIBLE LABEL TYPE QUESTIONS HAVE AN "LID" SET
$chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type IN ('F', 'H', 'W', 'Z', ':', '1') AND (lid = 0 OR lid is null)";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing LIDs<br />$chkquery<br />".$connect->ErrorMsg());
while($chkrow = $chkresult->FetchRow()){
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question requires a Labelset, but none is set."), $chkrow['gid']);
} // while
//CHECK THAT FLEXIBLE LABEL TYPE QUESTIONS HAVE AN "LID1" SET FOR MULTI SCALE
$chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND (type ='1') AND (lid1 = 0 OR lid1 is null)";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing LIDs<br />$chkquery<br />".$connect->ErrorMsg());
while($chkrow = $chkresult->FetchRow()){
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question requires a second Labelset, but none is set."), $chkrow['gid']);
} // while
//NOW check that all used labelsets have all necessary languages
$chkquery = "SELECT qid, question, gid, lid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type IN ('F', 'H', 'W', 'Z', ':', '1') AND (lid > 0) AND (lid is not null)";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing LID languages<br />$chkquery<br />".$connect->ErrorMsg());
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($slangs,$baselang);
while ($chkrow = $chkresult->FetchRow())
{
foreach ($slangs as $surveylanguage)
{
$chkquery2 = "SELECT lid FROM {$dbprefix}labels WHERE language='$surveylanguage' AND (lid = {$chkrow['lid']}) ";
$chkresult2 = db_execute_assoc($chkquery2);
if ($chkresult2->RecordCount()==0)
{
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("The labelset used in this question does not exists or is missing a translation."), $chkrow['gid']);
}
} //foreach
} //while
//CHECK THAT ALL CONDITIONS SET ARE FOR QUESTIONS THAT PRECEED THE QUESTION CONDITION
//A: Make an array of all the qids in order of appearance
// $qorderquery="SELECT * FROM {$dbprefix}questions, {$dbprefix}groups WHERE {$dbprefix}questions.gid={$dbprefix}groups.gid AND {$dbprefix}questions.sid={$_GET['sid']} ORDER BY {$dbprefix}groups.sortorder, {$dbprefix}questions.title";
// $qorderresult=$connect->Execute($qorderquery) or safe_die("Couldn't generate a list of questions in order<br />$qorderquery<br />".$connect->ErrorMsg());
// $qordercount=$qorderresult->RecordCount();
// $c=0;
// while ($qorderrow=$qorderresult->FetchRow())
// {
// $qidorder[]=array($c, $qorderrow['qid']);
// $c++;
// }
//TO AVOID NATURAL SORT ORDER ISSUES, FIRST GET ALL QUESTIONS IN NATURAL SORT ORDER, AND FIND OUT WHICH NUMBER IN THAT ORDER THIS QUESTION IS
$qorderquery = "SELECT * FROM {$dbprefix}questions WHERE sid=$surveyid AND type not in ('S', 'D', 'T', 'Q')";
$qorderresult = db_execute_assoc($qorderquery) or safe_die ("$qorderquery<br />".$connect->ErrorMsg());
$qrows = array(); //Create an empty array in case FetchRow does not return any rows
while ($qrow = $qorderresult->FetchRow()) {$qrows[] = $qrow;} // Get table output into array
usort($qrows, 'CompareGroupThenTitle'); // Perform a case insensitive natural sort on group name then question title of a multidimensional array
$c=0;
foreach ($qrows as $qr)
{
$qidorder[]=array($c, $qrow['qid']);
$c++;
}
$qordercount="";
//1: Get each condition's question id
$conquery= "SELECT {$dbprefix}conditions.qid, cqid, {$dbprefix}questions.question, "
. "{$dbprefix}questions.gid "
. "FROM {$dbprefix}conditions, {$dbprefix}questions, {$dbprefix}groups "
. "WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid "
. "AND {$dbprefix}questions.gid={$dbprefix}groups.gid ORDER BY {$dbprefix}conditions.qid";
$conresult=db_execute_assoc($conquery) or safe_die("Couldn't check conditions for relative consistency<br />$conquery<br />".$connect->ErrorMsg());
//2: Check each conditions cqid that it occurs later than the cqid
while ($conrow=$conresult->FetchRow())
{
$cqidfound=0;
$qidfound=0;
$b=0;
while ($b<$qordercount)
{
if ($conrow['cqid'] == $qidorder[$b][1])
{
$cqidfound = 1;
$b=$qordercount;
}
if ($conrow['qid'] == $qidorder[$b][1])
{
$qidfound = 1;
$b=$qordercount;
}
if ($qidfound == 1)
{
$failedcheck[]=array($conrow['qid'], $conrow['question'], ": ".$clang->gT("This question has a condition set, however the condition is based on a question that appears after it."), $conrow['gid']);
}
$b++;
}
}
//CHECK THAT ALL THE CREATED FIELDS WILL BE UNIQUE
$fieldmap=createFieldMap($surveyid, "full");
if (isset($fieldmap))
{
foreach($fieldmap as $fielddata)
{
$fieldlist[]=$fielddata['fieldname'];
}
$fieldlist=array_reverse($fieldlist); //let's always change the later duplicate, not the earlier one
}
$checkKeysUniqueComparison = create_function('$value','if ($value > 1) return true;');
@$duplicates = array_keys (array_filter (array_count_values($fieldlist), $checkKeysUniqueComparison));
if (isset($duplicates))
{
foreach ($duplicates as $dup)
{
$badquestion=arraySearchByKey($dup, $fieldmap, "fieldname", 1);
$fix = "[<a href='$scriptname?action=activate&amp;sid=$surveyid&amp;fixnumbering=".$badquestion['qid']."'>Click Here to Fix</a>]";
$failedcheck[]=array($badquestion['qid'], $badquestion['question'], ": Bad duplicate fieldname $fix", $badquestion['gid']);
}
}
//IF ANY OF THE CHECKS FAILED, PRESENT THIS SCREEN
if ((isset($failedcheck) && $failedcheck) || (isset($failedgroupcheck) && $failedgroupcheck))
{
$activateoutput .= "<br />\n<table bgcolor='#FFFFFF' width='500' align='center' style='border: 1px solid #555555' cellpadding='6' cellspacing='0'>\n";
$activateoutput .= "\t\t\t\t<tr bgcolor='#555555'><td height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Activate Survey")." ($surveyid)</strong></font></td></tr>\n";
$activateoutput .= "\t<tr>\n";
$activateoutput .= "\t\t<td align='center' bgcolor='#ffeeee'>\n";
$activateoutput .= "\t\t\t<font color='red'><strong>".$clang->gT("Error")."</strong><br />\n";
$activateoutput .= "\t\t\t".$clang->gT("Survey does not pass consistency check")."</font>\n";
$activateoutput .= "\t\t</td>\n";
$activateoutput .= "\t</tr>\n";
$activateoutput .= "\t<tr>\n";
$activateoutput .= "\t\t<td>\n";
$activateoutput .= "\t\t\t<strong>".$clang->gT("The following problems have been found:")."</strong><br />\n";
$activateoutput .= "\t\t\t<ul>\n";
foreach ($failedcheck as $fc)
{
$activateoutput .= "\t\t\t\t<li> Question qid-{$fc[0]} (\"<a href='$scriptname?sid=$surveyid&amp;gid=$fc[3]&amp;qid=$fc[0]'>{$fc[1]}</a>\"){$fc[2]}</li>\n";
}
foreach ($failedgroupcheck as $fg)
{
$activateoutput .= "\t\t\t\t<li> Group gid-{$fg[0]} (\"<a href='$scriptname?sid=$surveyid&amp;gid=$fg[0]'>{$fg[1]}</a>\"){$fg[2]}</li>\n";
}
$activateoutput .= "\t\t\t</ul>\n";
$activateoutput .= "\t\t\t".$clang->gT("The survey cannot be activated until these problems have been resolved.")."\n";
$activateoutput .= "\t\t</td>\n";
$activateoutput .= "\t</tr>\n";
$activateoutput .= "</table><br />&nbsp;\n";
return;
}
$activateoutput .= "<br />\n<div class='messagebox'>\n";
$activateoutput .= "\t\t\t\t<div class='header'>".$clang->gT("Activate Survey")." ($surveyid)</div>\n";
$activateoutput .= "\t\t<div class='warningheader'>\n";
$activateoutput .= $clang->gT("Warning")."<br />\n";
$activateoutput .= $clang->gT("READ THIS CAREFULLY BEFORE PROCEEDING")."\n";
$activateoutput .= "\t\t\t</div>\n";
$activateoutput .= $clang->gT("You should only activate a survey when you are absolutely certain that your survey setup is finished and will not need changing.")."<br /><br />\n";
$activateoutput .= $clang->gT("Once a survey is activated you can no longer:")."<ul><li>".$clang->gT("Add or delete groups")."</li><li>".$clang->gT("Add or remove answers to Multiple Answer questions")."</li><li>".$clang->gT("Add or delete questions")."</li></ul>\n";
$activateoutput .= $clang->gT("However you can still:")."<ul><li>".$clang->gT("Edit (change) your questions code, text or type")."</li><li>".$clang->gT("Edit (change) your group names")."</li><li>".$clang->gT("Add, Remove or Edit pre-defined question answers (except for Multi-answer questions)")."</li><li>".$clang->gT("Change survey name or description")."</li></ul>\n";
$activateoutput .= $clang->gT("Once data has been entered into this survey, if you want to add or remove groups or questions, you will need to de-activate this survey, which will move all data that has already been entered into a separate archived table.")."<br /><br />\n";
$activateoutput .= "\t\t\t<input type='submit' value=\"".$clang->gT("Activate Survey")."\" onclick=\"".get2post("$scriptname?action=activate&amp;ok=Y&amp;sid={$_GET['sid']}")."\" />\n";
$activateoutput .= "</div><br />&nbsp;\n";
} }
else else
{ {
//Create the survey responses table $activateoutput = activateSurvey($postsid,$surveyid);
$createsurvey = "id I NOTNULL AUTO PRIMARY,\n";
$createsurvey .= " submitdate T,\n";
$createsurvey .= " startlanguage C(20) NOTNULL ,\n";
//Check for any additional fields for this survey and create necessary fields (token and datestamp)
$pquery = "SELECT private, allowregister, datestamp, ipaddr, refurl FROM {$dbprefix}surveys WHERE sid={$postsid}";
$presult=db_execute_assoc($pquery);
while($prow=$presult->FetchRow())
{
if ($prow['private'] == "N")
{
$createsurvey .= " token C(36),\n";
$surveynotprivate="TRUE";
}
if ($prow['allowregister'] == "Y")
{
$surveyallowsregistration="TRUE";
}
if ($prow['datestamp'] == "Y")
{
$createsurvey .= " datestamp T NOTNULL,\n";
$createsurvey .= " startdate T NOTNULL,\n";
}
if ($prow['ipaddr'] == "Y")
{
$createsurvey .= " ipaddr X,\n";
}
//Check to see if 'refurl' field is required.
if ($prow['refurl'] == "Y")
{
$createsurvey .= " refurl X,\n";
}
}
//Get list of questions for the base language
$aquery = " SELECT * FROM ".db_table_name('questions').", ".db_table_name('groups')
." WHERE ".db_table_name('questions').".gid=".db_table_name('groups').".gid "
." AND ".db_table_name('questions').".sid={$postsid} "
." AND ".db_table_name('groups').".language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND ".db_table_name('questions').".language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY group_order, question_order";
$aresult = db_execute_assoc($aquery);
while ($arow=$aresult->FetchRow()) //With each question, create the appropriate field(s)
{
if ( substr($createsurvey, strlen($createsurvey)-2, 2) != ",\n") {$createsurvey .= ",\n";}
if ($arow['type'] != "M" && $arow['type'] != "A" && $arow['type'] != "B" &&
$arow['type'] != "C" && $arow['type'] != "E" && $arow['type'] != "F" &&
$arow['type'] != "H" && $arow['type'] != "P" && $arow['type'] != "R" &&
$arow['type'] != "Q" && $arow['type'] != "^" && $arow['type'] != "J" &&
$arow['type'] != "K" && $arow['type'] != ":" && $arow['type'] != ";" &&
$arow['type'] != "1")
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}`";
switch($arow['type'])
{
case "N": //NUMERICAL
$createsurvey .= " F";
break;
case "S": //SHORT TEXT
if ($databasetype=='mysql' || $databasetype=='mysqli') {$createsurvey .= " X";}
else {$createsurvey .= " C(255)";}
break;
case "L": //LIST (RADIO)
case "!": //LIST (DROPDOWN)
case "W":
case "Z":
$createsurvey .= " C(5)";
if ($arow['other'] == "Y")
{
$createsurvey .= ",\n`{$arow['sid']}X{$arow['gid']}X{$arow['qid']}other` X";
}
break;
case "I": // CSV ONE
$createsurvey .= " C(5)";
break;
case "O": //DROPDOWN LIST WITH COMMENT
$createsurvey .= " C(5),\n `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}comment` X";
break;
case "T": //LONG TEXT
$createsurvey .= " X";
break;
case "U": //HUGE TEXT
$createsurvey .= " X";
break;
case "D": //DATE
$createsurvey .= " D";
break;
case "5": //5 Point Choice
case "G": //Gender
case "Y": //YesNo
case "X": //Boilerplate
$createsurvey .= " C(1)";
break;
}
}
elseif ($arow['type'] == "M" || $arow['type'] == "A" || $arow['type'] == "B" ||
$arow['type'] == "C" || $arow['type'] == "E" || $arow['type'] == "F" ||
$arow['type'] == "H" || $arow['type'] == "P" || $arow['type'] == "^")
{
//MULTI ENTRY
$abquery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q"
." WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND a.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY a.sortorder, a.answer";
$abresult=db_execute_assoc($abquery) or safe_die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
while ($abrow=$abresult->FetchRow())
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}` C(5),\n";
if ($abrow['other']=="Y") {$alsoother="Y";}
if ($arow['type'] == "P")
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}comment` X,\n";
}
}
if ((isset($alsoother) && $alsoother=="Y") && ($arow['type']=="M" || $arow['type']=="P" || $arow['type']=="1")) //Sc: check!
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}other` X,\n";
if ($arow['type']=="P")
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}othercomment` X,\n";
}
}
}
elseif ($arow['type'] == ":" || $arow['type'] == ";")
{
//MULTI ENTRY
$abquery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q"
." WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND a.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY a.sortorder, a.answer";
$abresult=db_execute_assoc($abquery) or die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
$ab2query = "SELECT ".db_table_name('labels').".*
FROM ".db_table_name('questions').", ".db_table_name('labels')."
WHERE sid=$surveyid
AND ".db_table_name('labels').".lid=".db_table_name('questions').".lid
AND ".db_table_name('labels').".language='".GetbaseLanguageFromSurveyid($postsid)."'
AND ".db_table_name('questions').".qid=".$arow['qid']."
ORDER BY ".db_table_name('labels').".sortorder, ".db_table_name('labels').".title";
$ab2result=db_execute_assoc($ab2query) or die("Couldn't get list of labels in createFieldMap function (case :)<br />$ab2query<br />".htmlspecialchars($connection->ErrorMsg()));
while($ab2row=$ab2result->FetchRow())
{
$lset[]=$ab2row;
}
while ($abrow=$abresult->FetchRow())
{
foreach($lset as $ls)
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}_{$ls['code']}` X,\n";
}
}
unset($lset);
}
elseif ($arow['type'] == "Q")
{
$abquery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND a.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY a.sortorder, a.answer";
$abresult=db_execute_assoc($abquery) or safe_die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
while ($abrow = $abresult->FetchRow())
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}`";
if ($databasetype=='mysql' || $databasetype=='mysqli')
{
$createsurvey .= " X";
}
else
{
$createsurvey .= " C(255)";
}
$createsurvey .= ",\n";
}
}
elseif ($arow['type'] == "K") //Multiple Numeric - replica of multiple short text, except numbers only
{
$abquery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND a.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY a.sortorder, a.answer";
$abresult=db_execute_assoc($abquery) or safe_die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
while ($abrow = $abresult->FetchRow())
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}` F,\n";
}
} //End if ($arow['type'] == "K")
/* elseif ($arow['type'] == "J")
{
$abquery = "SELECT {$dbprefix}answers.*, {$dbprefix}questions.other FROM {$dbprefix}answers, {$dbprefix}questions WHERE {$dbprefix}answers.qid={$dbprefix}questions.qid AND sid={$_GET['sid']} AND {$dbprefix}questions.qid={$arow['qid']} ORDER BY {$dbprefix}answers.sortorder, {$dbprefix}answers.answer";
$abresult=db_execute_assoc($abquery) or safe_die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
while ($abrow = $abresultt->FetchRow())
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}` C(5),\n";
}
}*/
elseif ($arow['type'] == "R")
{
//MULTI ENTRY
$abquery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q"
." WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND a.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY a.sortorder, a.answer";
$abresult=$connect->Execute($abquery) or safe_die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
$abcount=$abresult->RecordCount();
for ($i=1; $i<=$abcount; $i++)
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}$i` C(5),\n";
}
}
elseif ($arow['type'] == "1")
{
$abquery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q"
." WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND a.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." ORDER BY a.sortorder, a.answer";
$abresult=db_execute_assoc($abquery) or safe_die ("Couldn't get perform answers query<br />$abquery<br />".$connect->ErrorMsg());
$abcount=$abresult->RecordCount();
while ($abrow = $abresult->FetchRow())
{
$abmultiscalequery = "SELECT a.*, q.other FROM {$dbprefix}answers as a, {$dbprefix}questions as q, {$dbprefix}labels as l"
." WHERE a.qid=q.qid AND sid={$postsid} AND q.qid={$arow['qid']} "
." AND l.lid=q.lid AND sid={$postsid} AND q.qid={$arow['qid']} AND l.title = '' "
." AND l.language='".GetbaseLanguageFromSurveyid($postsid). "' "
." AND q.language='".GetbaseLanguageFromSurveyid($postsid). "' ";
$abmultiscaleresult=$connect->Execute($abmultiscalequery) or safe_die ("Couldn't get perform answers query<br />$abmultiscalequery<br />".$connect->ErrorMsg());
$abmultiscaleresultcount =$abmultiscaleresult->RecordCount();
$abmultiscaleresultcount = 1;
for ($j=0; $j<=$abmultiscaleresultcount; $j++)
{
$createsurvey .= " `{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['code']}#$j` C(5),\n";
}
}
}
}
// If last question is of type MCABCEFHP^QKJR let's get rid of the ending coma in createsurvey
$createsurvey = rtrim($createsurvey, ",\n")."\n"; // Does nothing if not ending with a comma
$tabname = "{$dbprefix}survey_{$postsid}"; # not using db_table_name as it quotes the table name (as does CreateTableSQL)
$taboptarray = array('mysql' => 'ENGINE='.$databasetabletype.' CHARACTER SET utf8 COLLATE utf8_unicode_ci',
'mysqli'=> 'ENGINE='.$databasetabletype.' CHARACTER SET utf8 COLLATE utf8_unicode_ci');
$dict = NewDataDictionary($connect);
$sqlarray = $dict->CreateTableSQL($tabname, $createsurvey, $taboptarray);
$execresult=$dict->ExecuteSQLArray($sqlarray,1);
if ($execresult==0 || $execresult==1)
{
$activateoutput .= "<br />\n<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n" .
"<tr bgcolor='#555555'><td height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Activate Survey")." ($surveyid)</strong></font></td></tr>\n" .
"<tr><td>\n" .
"<font color='red'>".$clang->gT("Survey could not be actived.")."</font><br />\n" .
"<center><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a></center>\n" .
"DB ".$clang->gT("Error").":<br />\n<font color='red'>" . $connect->ErrorMsg() . "</font>\n" .
"<pre>$createsurvey</pre>\n" .
"</td></tr></table></br>&nbsp;\n" .
"</body>\n</html>";
}
if ($execresult != 0 && $execresult !=1)
{
$anquery = "SELECT autonumber_start FROM {$dbprefix}surveys WHERE sid={$postsid}";
if ($anresult=db_execute_assoc($anquery))
{
//if there is an autonumber_start field, start auto numbering here
while($row=$anresult->FetchRow())
{
if ($row['autonumber_start'] > 0)
{
$autonumberquery = "ALTER TABLE {$dbprefix}survey_{$postsid} AUTO_INCREMENT = ".$row['autonumber_start'];
if ($result = $connect->Execute($autonumberquery))
{
//We're happy it worked!
}
else
{
//Continue regardless - it's not the end of the world
}
}
}
}
$activateoutput .= "<br />\n<table class='alertbox'>\n";
$activateoutput .= "\t\t\t\t<tr><td height='4'><strong>".$clang->gT("Activate Survey")." ($surveyid)</td></tr>\n";
$activateoutput .= "\t\t\t\t<tr><td align='center'><font class='successtitle'>".$clang->gT("Survey has been activated. Results table has been successfully created.")."</font><br /><br />\n";
$acquery = "UPDATE {$dbprefix}surveys SET active='Y' WHERE sid=".returnglobal('sid');
$acresult = $connect->Execute($acquery);
// Private means data privacy, not closed access survey
// if (isset($surveynotprivate) && $surveynotprivate) //This survey is tracked, and therefore a tokens table MUST exist
// {
// $activateoutput .= $clang->gT("This is not an anonymous survey. A token table must also be created.")."<br /><br />\n";
// $activateoutput .= "<input type='submit' value='".$clang->gT("Initialise Tokens")."' onclick=\"window.open('$scriptname?action=tokens&amp;sid={$_GET['sid']}&amp;createtable=Y', '_self')\" />\n";
// }
// elseif (isset($surveyallowsregistration) && $surveyallowsregistration == "TRUE")
if (isset($surveyallowsregistration) && $surveyallowsregistration == "TRUE")
{
$activateoutput .= $clang->gT("This survey allows public registration. A token table must also be created.")."<br /><br />\n";
$activateoutput .= "<input type='submit' value='".$clang->gT("Initialise Tokens")."' onclick=\"".get2post("$scriptname?action=tokens&amp;sid={$postsid}&amp;createtable=Y")."\" />\n";
}
else
{
$activateoutput .= $clang->gT("This survey is now active, and responses can be recorded.")."<br /><br />\n";
$activateoutput .= "<strong>".$clang->gT("Open-access mode").":</strong> ".$clang->gT("No invitation code is needed to complete the survey.")."<br />".$clang->gT("You can switch to the closed-access mode by initialising a token table with the button below.")."<br /><br />\n";
$activateoutput .= "<input type='submit' value='".$clang->gT("Switch to closed-access mode")."' onclick=\"".get2post("$scriptname?action=tokens&amp;sid={$postsid}&amp;createtable=Y")."\" />\n";
$activateoutput .= "<input type='submit' value='".$clang->gT("No, thanks.")."' onclick=\"".get2post("$scriptname?sid={$postsid}")."\" />\n";
}
$activateoutput .= "\t\t\t\t</font></font></td></tr></table><br />&nbsp;\n";
}
} }
?>

View File

@@ -0,0 +1,529 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: activate_functions.php 9671 2010-12-21 20:02:24Z c_schmitz $
* Files Purpose: holds functions to activate a survey and precheck the consistency of the survey
*/
/**
* fixes the numbering of questions
* @global $dbprefix $dbprefix
* @global $connect $connect
* @global $clang $clang
* @param <type> $fixnumbering
*/
function fixNumbering($fixnumbering)
{
global $dbprefix, $connect, $clang;
//Fix a question id - requires renumbering a question
$oldqid = $fixnumbering;
$query = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC";
$result = db_select_limit_assoc($query, 1) or safe_die($query."<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow()) {$lastqid=$row['qid'];}
$newqid=$lastqid+1;
$query = "UPDATE {$dbprefix}questions SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
// Update subquestions
$query = "UPDATE {$dbprefix}questions SET parent_qid=$newqid WHERE parent_qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
//Update conditions.. firstly conditions FOR this question
$query = "UPDATE {$dbprefix}conditions SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
//Now conditions based upon this question
$query = "SELECT cqid, cfieldname FROM {$dbprefix}conditions WHERE cqid=$oldqid";
$result = db_execute_assoc($query) or safe_die($query."<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
$switcher[]=array("cqid"=>$row['cqid'], "cfieldname"=>$row['cfieldname']);
}
if (isset($switcher))
{
foreach ($switcher as $switch)
{
$query = "UPDATE {$dbprefix}conditions
SET cqid=$newqid,
cfieldname='".str_replace("X".$oldqid, "X".$newqid, $switch['cfieldname'])."'
WHERE cqid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
}
}
//Now question_attributes
$query = "UPDATE {$dbprefix}question_attributes SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
//Now answers
$query = "UPDATE {$dbprefix}answers SET qid=$newqid WHERE qid=$oldqid";
$result = $connect->Execute($query) or safe_die($query."<br />".$connect->ErrorMsg());
}
/**
* checks consistency of groups
* @global $dbprefix
* @global $connect
* @global $clang
* @return <type>
*/
function checkGroup($postsid)
{
global $dbprefix, $connect, $clang;
$baselang = GetBaseLanguageFromSurveyID($postsid);
$groupquery = "SELECT g.gid,g.group_name,count(q.qid) as count from {$dbprefix}questions as q RIGHT JOIN {$dbprefix}groups as g ON q.gid=g.gid AND g.language=q.language WHERE g.sid=$postsid AND g.language='$baselang' group by g.gid,g.group_name;";
$groupresult=db_execute_assoc($groupquery) or safe_die($groupquery."<br />".$connect->ErrorMsg());
while ($row=$groupresult->FetchRow())
{ //TIBO
if ($row['count'] == 0)
{
$failedgroupcheck[]=array($row['gid'], $row['group_name'], ": ".$clang->gT("This group does not contain any question(s)."));
}
}
if(isset($failedgroupcheck))
return $failedgroupcheck;
else
return false;
}
/**
* checks questions in a survey for consistency
* @global <type> $dbprefix
* @global <type> $connect
* @global <type> $clang
* @param <type> $postsid
* @param <type> $surveyid
* @return array $faildcheck
*/
function checkQuestions($postsid, $surveyid, $qtypes)
{
global $dbprefix, $connect, $clang;
//CHECK TO MAKE SURE ALL QUESTION TYPES THAT REQUIRE ANSWERS HAVE ACTUALLY GOT ANSWERS
//THESE QUESTION TYPES ARE:
// # "L" -> LIST
// # "O" -> LIST WITH COMMENT
// # "M" -> Multiple choice
// # "P" -> Multiple choice with comments
// # "A", "B", "C", "E", "F", "H", "^" -> Various Array Types
// # "R" -> RANKING
// # "U" -> FILE CSV MORE
// # "I" -> LANGUAGE SWITCH
// # ":" -> Array Multi Flexi Numbers
// # ";" -> Array Multi Flexi Text
// # "1" -> MULTI SCALE
$chkquery = "SELECT qid, question, gid, type FROM {$dbprefix}questions WHERE sid={$surveyid} and parent_qid=0";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't get list of questions<br />$chkquery<br />".$connect->ErrorMsg());
while ($chkrow = $chkresult->FetchRow())
{
if ($qtypes[$chkrow['type']]['subquestions']>0)
{
$chaquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid = {$chkrow['qid']} ORDER BY question_order";
$charesult=$connect->Execute($chaquery);
$chacount=$charesult->RecordCount();
if ($chacount == 0)
{
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question is a subquestion type question but has no configured subquestions."), $chkrow['gid']);
}
}
if ($qtypes[$chkrow['type']]['answerscales']>0)
{
$chaquery = "SELECT * FROM {$dbprefix}answers WHERE qid = {$chkrow['qid']} ORDER BY sortorder, answer";
$charesult=$connect->Execute($chaquery);
$chacount=$charesult->RecordCount();
if ($chacount == 0)
{
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question is a multiple answer type question but has no answers."), $chkrow['gid']);
}
}
}
//NOW CHECK THAT ALL QUESTIONS HAVE A 'QUESTION TYPE' FIELD SET
$chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type = ''";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing types<br />$chkquery<br />".$connect->ErrorMsg());
while ($chkrow = $chkresult->FetchRow())
{
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question does not have a question 'type' set."), $chkrow['gid']);
}
//ChECK THAT certain array question types have answers set
$chkquery = "SELECT q.qid, question, gid FROM {$dbprefix}questions as q WHERE (select count(*) from {$dbprefix}answers as a where a.qid=q.qid and scale_id=0)=0 and sid={$_GET['sid']} AND type IN ('F', 'H', 'W', 'Z', '1') and q.parent_qid=0";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing answers<br />$chkquery<br />".$connect->ErrorMsg());
while($chkrow = $chkresult->FetchRow()){
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question requires answers, but none are set."), $chkrow['gid']);
} // while
//CHECK THAT DUAL Array has answers set
$chkquery = "SELECT q.qid, question, gid FROM {$dbprefix}questions as q WHERE (select count(*) from {$dbprefix}answers as a where a.qid=q.qid and scale_id=1)=0 and sid={$_GET['sid']} AND type='1' and q.parent_qid=0";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing 2nd answer set<br />$chkquery<br />".$connect->ErrorMsg());
while($chkrow = $chkresult->FetchRow()){
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question requires a second answer set but none is set."), $chkrow['gid']);
} // while
//CHECK THAT ALL CONDITIONS SET ARE FOR QUESTIONS THAT PRECEED THE QUESTION CONDITION
//A: Make an array of all the qids in order of appearance
// $qorderquery="SELECT * FROM {$dbprefix}questions, {$dbprefix}groups WHERE {$dbprefix}questions.gid={$dbprefix}groups.gid AND {$dbprefix}questions.sid={$_GET['sid']} ORDER BY {$dbprefix}groups.sortorder, {$dbprefix}questions.title";
// $qorderresult=$connect->Execute($qorderquery) or safe_die("Couldn't generate a list of questions in order<br />$qorderquery<br />".$connect->ErrorMsg());
// $qordercount=$qorderresult->RecordCount();
// $c=0;
// while ($qorderrow=$qorderresult->FetchRow())
// {
// $qidorder[]=array($c, $qorderrow['qid']);
// $c++;
// }
//TO AVOID NATURAL SORT ORDER ISSUES, FIRST GET ALL QUESTIONS IN NATURAL SORT ORDER, AND FIND OUT WHICH NUMBER IN THAT ORDER THIS QUESTION IS
$qorderquery = "SELECT * FROM {$dbprefix}questions WHERE sid=$surveyid AND type not in ('S', 'D', 'T', 'Q')";
$qorderresult = db_execute_assoc($qorderquery) or safe_die ("$qorderquery<br />".$connect->ErrorMsg());
$qrows = array(); //Create an empty array in case FetchRow does not return any rows
while ($qrow = $qorderresult->FetchRow()) {$qrows[] = $qrow;} // Get table output into array
usort($qrows, 'GroupOrderThenQuestionOrder'); // Perform a case insensitive natural sort on group name then question title of a multidimensional array
$c=0;
foreach ($qrows as $qr)
{
$qidorder[]=array($c, $qrow['qid']);
$c++;
}
$qordercount="";
//1: Get each condition's question id
$conquery= "SELECT {$dbprefix}conditions.qid, cqid, {$dbprefix}questions.question, "
. "{$dbprefix}questions.gid "
. "FROM {$dbprefix}conditions, {$dbprefix}questions, {$dbprefix}groups "
. "WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid "
. "AND {$dbprefix}questions.gid={$dbprefix}groups.gid ORDER BY {$dbprefix}conditions.qid";
$conresult=db_execute_assoc($conquery) or safe_die("Couldn't check conditions for relative consistency<br />$conquery<br />".$connect->ErrorMsg());
//2: Check each conditions cqid that it occurs later than the cqid
while ($conrow=$conresult->FetchRow())
{
$cqidfound=0;
$qidfound=0;
$b=0;
while ($b<$qordercount)
{
if ($conrow['cqid'] == $qidorder[$b][1])
{
$cqidfound = 1;
$b=$qordercount;
}
if ($conrow['qid'] == $qidorder[$b][1])
{
$qidfound = 1;
$b=$qordercount;
}
if ($qidfound == 1)
{
$failedcheck[]=array($conrow['qid'], $conrow['question'], ": ".$clang->gT("This question has a condition set, however the condition is based on a question that appears after it."), $conrow['gid']);
}
$b++;
}
}
//CHECK THAT ALL THE CREATED FIELDS WILL BE UNIQUE
$fieldmap=createFieldMap($surveyid, "full");
if (isset($fieldmap))
{
foreach($fieldmap as $fielddata)
{
$fieldlist[]=$fielddata['fieldname'];
}
$fieldlist=array_reverse($fieldlist); //let's always change the later duplicate, not the earlier one
}
$checkKeysUniqueComparison = create_function('$value','if ($value > 1) return true;');
@$duplicates = array_keys (array_filter (array_count_values($fieldlist), $checkKeysUniqueComparison));
if (isset($duplicates))
{
foreach ($duplicates as $dup)
{
$badquestion=arraySearchByKey($dup, $fieldmap, "fieldname", 1);
$fix = "[<a href='$scriptname?action=activate&amp;sid=$surveyid&amp;fixnumbering=".$badquestion['qid']."'>Click Here to Fix</a>]";
$failedcheck[]=array($badquestion['qid'], $badquestion['question'], ": Bad duplicate fieldname $fix", $badquestion['gid']);
}
}
if(isset($failedcheck))
return $failedcheck;
else
return false;
}
/**
* Function to activate a survey
* @global $dbprefix $dbprefix
* @global $connect $connect
* @global $clang $clang
* @param int $postsid
* @param int $surveyid
* @return string
*/
function activateSurvey($postsid,$surveyid, $scriptname='admin.php')
{
global $dbprefix, $connect, $clang, $databasetype,$databasetabletype, $uploaddir;
$createsurvey='';
$activateoutput='';
$createsurveytimings='';
$createsurveydirectory=false;
//Check for any additional fields for this survey and create necessary fields (token and datestamp)
$pquery = "SELECT anonymized, allowregister, datestamp, ipaddr, refurl, savetimings FROM {$dbprefix}surveys WHERE sid={$postsid}";
$presult=db_execute_assoc($pquery);
$prow=$presult->FetchRow();
if ($prow['allowregister'] == "Y")
{
$surveyallowsregistration="TRUE";
}
if ($prow['savetimings'] == "Y")
{
$savetimings="TRUE";
}
//strip trailing comma and new line feed (if any)
$createsurvey = rtrim($createsurvey, ",\n");
//strip trailing comma and new line feed (if any)
$createsurvey = rtrim($createsurvey, ",\n");
//Get list of questions for the base language
$fieldmap=createFieldMap($surveyid);
foreach ($fieldmap as $arow) //With each question, create the appropriate field(s)
{
if ($createsurvey!='') {$createsurvey .= ",\n";}
$createsurvey .= ' `'.$arow['fieldname'].'`';
switch($arow['type'])
{
case 'startlanguage':
$createsurvey .= " C(20) NOTNULL";
break;
case 'id':
$createsurvey .= " I NOTNULL AUTO PRIMARY";
$createsurveytimings .= " `{$arow['fieldname']}` I NOTNULL PRIMARY,\n";
break;
case "startdate":
case "datestamp":
$createsurvey .= " T NOTNULL";
break;
case "submitdate":
$createsurvey .= " T";
break;
case "lastpage":
$createsurvey .= " I";
break;
case "N": //NUMERICAL
$createsurvey .= " F";
break;
case "S": //SHORT TEXT
if ($databasetype=='mysql' || $databasetype=='mysqli') {$createsurvey .= " X";}
else {$createsurvey .= " C(255)";}
break;
case "L": //LIST (RADIO)
case "!": //LIST (DROPDOWN)
case "M": //Multiple choice
case "P": //Multiple choice with comment
case "O": //DROPDOWN LIST WITH COMMENT
if ($arow['aid'] != 'other' && strpos($arow['aid'],'comment')===false && strpos($arow['aid'],'othercomment')===false)
{
$createsurvey .= " C(5)";
}
else
{
$createsurvey .= " X";
}
break;
case "K": // Multiple Numerical
$createsurvey .= " F";
break;
case "U": //Huge text
case "Q": //Multiple short text
case "T": //LONG TEXT
case ";": //Multi Flexi
case ":": //Multi Flexi
$createsurvey .= " X";
break;
case "D": //DATE
$createsurvey .= " D";
break;
case "5": //5 Point Choice
case "G": //Gender
case "Y": //YesNo
case "X": //Boilerplate
$createsurvey .= " C(1)";
break;
case "I": //Language switch
$createsurvey .= " C(20)";
break;
case "|":
$createsurveydirectory = true;
if (strpos($arow['fieldname'], "_"))
$createsurvey .= " I1";
else
$createsurvey .= " X";
break;
case "ipaddress":
if ($prow['ipaddr'] == "Y")
$createsurvey .= " X";
break;
case "url":
if ($prow['refurl'] == "Y")
$createsurvey .= " X";
break;
case "token":
if ($prow['anonymized'] == "N")
{
$createsurvey .= " C(36)";
}
break;
default:
$createsurvey .= " C(5)";
}
}
$timingsfieldmap = createTimingsFieldMap($surveyid);
$createsurveytimings .= '`'.implode("` F DEFAULT '0',\n`",array_keys($timingsfieldmap)) . "` F DEFAULT '0'";
// If last question is of type MCABCEFHP^QKJR let's get rid of the ending coma in createsurvey
$createsurvey = rtrim($createsurvey, ",\n")."\n"; // Does nothing if not ending with a comma
$tabname = "{$dbprefix}survey_{$postsid}"; # not using db_table_name as it quotes the table name (as does CreateTableSQL)
$taboptarray = array('mysql' => 'ENGINE='.$databasetabletype.' CHARACTER SET utf8 COLLATE utf8_unicode_ci',
'mysqli'=> 'ENGINE='.$databasetabletype.' CHARACTER SET utf8 COLLATE utf8_unicode_ci');
$dict = NewDataDictionary($connect);
$sqlarray = $dict->CreateTableSQL($tabname, $createsurvey, $taboptarray);
if (isset($savetimings) && $savetimings=="TRUE")
{
$tabnametimings = $tabname .'_timings';
$sqlarraytimings = $dict->CreateTableSQL($tabnametimings, $createsurveytimings, $taboptarray);
}
$execresult=$dict->ExecuteSQLArray($sqlarray,1);
if ($execresult==0 || $execresult==1)
{
$activateoutput .= "<br />\n<div class='messagebox ui-corner-all'>\n" .
"<div class='header ui-widget-header'>".$clang->gT("Activate Survey")." ($surveyid)</div>\n" .
"<div class='warningheader'>".$clang->gT("Survey could not be actived.")."</div>\n" .
"<p>" .
$clang->gT("Database error:")."\n <font color='red'>" . $connect->ErrorMsg() . "</font>\n" .
"<pre>$createsurvey</pre>\n
<a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>\n</div>" ;
}
if ($execresult != 0 && $execresult !=1)
{
$anquery = "SELECT autonumber_start FROM {$dbprefix}surveys WHERE sid={$postsid}";
if ($anresult=db_execute_assoc($anquery))
{
//if there is an autonumber_start field, start auto numbering here
while($row=$anresult->FetchRow())
{
if ($row['autonumber_start'] > 0)
{
if ($databasetype=='odbc_mssql' || $databasetype=='odbtp' || $databasetype=='mssql_n' || $databasetype=='mssqlnative') {
mssql_drop_primary_index('survey_'.$postsid);
mssql_drop_constraint('id','survey_'.$postsid);
$autonumberquery = "alter table {$dbprefix}survey_{$postsid} drop column id ";
$connect->Execute($autonumberquery);
$autonumberquery = "alter table {$dbprefix}survey_{$postsid} add [id] int identity({$row['autonumber_start']},1)";
$connect->Execute($autonumberquery);
}
else
{
$autonumberquery = "ALTER TABLE {$dbprefix}survey_{$postsid} AUTO_INCREMENT = ".$row['autonumber_start'];
$result = @$connect->Execute($autonumberquery);
}
}
}
if (isset($savetimings) && $savetimings=="TRUE")
{
$dict->ExecuteSQLArray($sqlarraytimings,1); // create a timings table for this survey
}
}
$activateoutput .= "<br />\n<div class='messagebox ui-corner-all'>\n";
$activateoutput .= "<div class='header ui-widget-header'>".$clang->gT("Activate Survey")." ($surveyid)</div>\n";
$activateoutput .= "<div class='successheader'>".$clang->gT("Survey has been activated. Results table has been successfully created.")."</div><br /><br />\n";
// create the survey directory where the uploaded files can be saved
if ($createsurveydirectory)
if (!file_exists($uploaddir."/surveys/" . $postsid . "/files"))
{
if (!(mkdir($uploaddir."/surveys/" . $postsid . "/files", 0777, true)))
{
$activateoutput .= "<div class='warningheader'>".
$clang->gT("The required directory for saving the uploaded files couldn't be created. Please check file premissions on the limesurvey/upload/surveys directory.") . "</div>";
}
else
{
file_put_contents($uploaddir."/surveys/" . $postsid . "/files/index.html",'<html><head></head><body></body></html>');
}
}
$acquery = "UPDATE {$dbprefix}surveys SET active='Y' WHERE sid=".$surveyid;
$acresult = $connect->Execute($acquery);
if (isset($surveyallowsregistration) && $surveyallowsregistration == "TRUE")
{
$activateoutput .= $clang->gT("This survey allows public registration. A token table must also be created.")."<br /><br />\n";
$activateoutput .= "<input type='submit' value='".$clang->gT("Initialise tokens")."' onclick=\"".get2post("$scriptname?action=tokens&amp;sid={$postsid}&amp;createtable=Y")."\" />\n";
}
else
{
$activateoutput .= $clang->gT("This survey is now active, and responses can be recorded.")."<br /><br />\n";
$activateoutput .= "<strong>".$clang->gT("Open-access mode").":</strong> ".$clang->gT("No invitation code is needed to complete the survey.")."<br />".$clang->gT("You can switch to the closed-access mode by initialising a token table with the button below.")."<br /><br />\n";
$activateoutput .= "<input type='submit' value='".$clang->gT("Switch to closed-access mode")."' onclick=\"".get2post("$scriptname?action=tokens&amp;sid={$postsid}&amp;createtable=Y")."\" />\n";
$activateoutput .= "<input type='submit' value='".$clang->gT("No, thanks.")."' onclick=\"".get2post("$scriptname?sid={$postsid}")."\" />\n";
}
$activateoutput .= "</div><br />&nbsp;\n";
$lsrcOutput = true;
}
if($scriptname=='lsrc')
{
if($lsrcOutput==true)
return true;
else
return $activateoutput;
}
else
{
return $activateoutput;
}
}
function mssql_drop_constraint($fieldname, $tablename)
{
global $dbprefix, $connect, $modifyoutput;
// find out the name of the default constraint
// Did I already mention that this is the most suckiest thing I have ever seen in MSSQL database?
$dfquery ="SELECT c_obj.name AS constraint_name
FROM sys.sysobjects AS c_obj INNER JOIN
sys.sysobjects AS t_obj ON c_obj.parent_obj = t_obj.id INNER JOIN
sys.sysconstraints AS con ON c_obj.id = con.constid INNER JOIN
sys.syscolumns AS col ON t_obj.id = col.id AND con.colid = col.colid
WHERE (c_obj.xtype = 'D') AND (col.name = '$fieldname') AND (t_obj.name='{$dbprefix}{$tablename}')";
$defaultname=$connect->GetRow($dfquery);
if ($defaultname!=false)
{
modify_database("","ALTER TABLE [prefix_$tablename] DROP CONSTRAINT {$defaultname[0]}"); echo $modifyoutput; flush();
}
}
function mssql_drop_primary_index($tablename)
{
global $dbprefix, $connect, $modifyoutput;
// find out the constraint name of the old primary key
$pkquery = "SELECT CONSTRAINT_NAME "
."FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS "
."WHERE (TABLE_NAME = '{$dbprefix}{$tablename}') AND (CONSTRAINT_TYPE = 'PRIMARY KEY')";
$primarykey=$connect->GetOne($pkquery);
if ($primarykey!=false)
{
modify_database("","ALTER TABLE [prefix_{$tablename}] DROP CONSTRAINT {$primarykey}"); echo $modifyoutput; flush();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,406 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: admin_functions.php 9586 2010-12-06 03:08:07Z c_schmitz $
* Files Purpose:
*/
function get2post($url)
{
$url = preg_replace('/&amp;/i','&',$url);
list($calledscript,$query) = explode('?',$url);
$aqueryitems = explode('&',$query);
$arrayParam = Array();
$arrayVal = Array();
foreach ($aqueryitems as $queryitem)
{
list($paramname, $value) = explode ('=', $queryitem);
$arrayParam[] = "'".$paramname."'";
$arrayVal[] = substr($value, 0, 9) != "document." ? "'".$value."'" : $value;
}
// $Paramlist = "[" . implode(",",$arrayParam) . "]";
// $Valuelist = "[" . implode(",",$arrayVal) . "]";
$Paramlist = "new Array(" . implode(",",$arrayParam) . ")";
$Valuelist = "new Array(" . implode(",",$arrayVal) . ")";
$callscript = "sendPost('$calledscript','".$_SESSION['checksessionpost']."',$Paramlist,$Valuelist);";
return $callscript;
}
/**
* This function switches identity insert on/off for the MSSQL database
*
* @param string $table table name (without prefix)
* @param mixed $state Set to true to activate ID insert, or false to deactivate
*/
function db_switchIDInsert($table,$state)
{
global $databasetype, $connect;
if ($databasetype=='odbc_mssql' || $databasetype=='odbtp' || $databasetype=='mssql_n' || $databasetype=='mssqlnative')
{
if ($state==true)
{
$connect->Execute('SET IDENTITY_INSERT '.db_table_name($table).' ON');
}
else
{
$connect->Execute('SET IDENTITY_INSERT '.db_table_name($table).' OFF');
}
}
}
/**
* Returns true if a user has permissions in the particular survey
*
* @param $iSID The survey ID
* @param $sPermission
* @param $sCRUD
* @param $iUID User ID - if not given the one of the current user is used
* @return bool
*/
function bHasSurveyPermission($iSID, $sPermission, $sCRUD, $iUID=null)
{
global $dbprefix, $connect;
if (!in_array($sCRUD,array('create','read','update','delete','import','export'))) return false;
$sCRUD=$sCRUD.'_p';
$iSID = (int)$iSID;
global $aSurveyPermissionCache;
if (is_null($iUID))
{
if (isset($_SESSION['loginID'])) $iUID = $_SESSION['loginID'];
else return false;
if ($_SESSION['USER_RIGHT_SUPERADMIN']==1) return true; //Superadmin has access to all
}
if (!isset($aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD]))
{
$sSQL = "SELECT {$sCRUD} FROM " . db_table_name('survey_permissions') . "
WHERE sid={$iSID} AND uid = {$iUID}
and permission=".db_quoteall($sPermission); //Getting rights for this survey
$bPermission = $connect->GetOne($sSQL);
if ($bPermission==0 || is_null($bPermission)) $bPermission=false;
if ($bPermission==1) $bPermission=true;
$aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD]=$bPermission;
}
return $aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD];
}
/**
* Returns true if the given survey has a File Upload Question Type
* @param $surveyid The survey ID
* @return bool
*/
function bHasFileUploadQuestion($surveyid) {
$fieldmap = createFieldMap($surveyid);
foreach ($fieldmap as $field) {
if (isset($field['type']) && $field['type'] === '|') return true;
}
}
/**
* Returns true if a user has global permission for a certain action. Available permissions are
*
* USER_RIGHT_CREATE_SURVEY
* USER_RIGHT_CONFIGURATOR
* USER_RIGHT_CREATE_USER
* USER_RIGHT_DELETE_USER
* USER_RIGHT_SUPERADMIN
* USER_RIGHT_MANAGE_TEMPLATE
* USER_RIGHT_MANAGE_LABEL
*
* @param $sPermission
* @return bool
*/
function bHasGlobalPermission($sPermission)
{
global $dbprefix, $connect;
global $aSurveyGlobalPermissionCache;
if (isset($_SESSION['loginID'])) $iUID = $_SESSION['loginID'];
else return false;
if ($_SESSION['USER_RIGHT_SUPERADMIN']==1) return true; //Superadmin has access to all
if ($_SESSION[$sPermission]==1)
{
return true;
}
else
{
return false;
}
}
/**
* Set the survey permissions for a user. Beware that all survey permissions for the particual survey are removed before the new ones are written.
*
* @param int $iUserID The User ID
* @param int $iSurveyID The Survey ID
* @param array $aPermissions Array with permissions in format <permissionname>=>array('create'=>0/1,'read'=>0/1,'update'=>0/1,'delete'=>0/1)
*/
function SetSurveyPermissions($iUserID, $iSurveyID, $aPermissions)
{
global $connect, $surveyid;
$iUserID=sanitize_int($iUserID);
$sQuery = "delete from ".db_table_name('survey_permissions')." WHERE sid = {$iSurveyID} AND uid = {$iUserID}";
$connect->Execute($sQuery);
$bResult=true;
foreach($aPermissions as $sPermissionname=>$aPermissions)
{
if (!isset($aPermissions['create'])) {$aPermissions['create']=0;}
if (!isset($aPermissions['read'])) {$aPermissions['read']=0;}
if (!isset($aPermissions['update'])) {$aPermissions['update']=0;}
if (!isset($aPermissions['delete'])) {$aPermissions['delete']=0;}
if (!isset($aPermissions['import'])) {$aPermissions['import']=0;}
if (!isset($aPermissions['export'])) {$aPermissions['export']=0;}
if ($aPermissions['create']==1 || $aPermissions['read']==1 ||$aPermissions['update']==1 || $aPermissions['delete']==1 || $aPermissions['import']==1 || $aPermissions['export']==1)
{
$sQuery = "INSERT INTO ".db_table_name('survey_permissions')." (sid, uid, permission, create_p, read_p, update_p, delete_p, import_p, export_p)
VALUES ({$iSurveyID},{$iUserID},'{$sPermissionname}',{$aPermissions['create']},{$aPermissions['read']},{$aPermissions['update']},{$aPermissions['delete']},{$aPermissions['import']},{$aPermissions['export']})";
$bResult=$connect->Execute($sQuery);
}
}
return $bResult;
}
/**
* Gives all available survey permissions for a certain survey to a user
*
* @param mixed $iUserID The User ID
* @param mixed $iSurveyID The Survey ID
*/
function GiveAllSurveyPermissions($iUserID, $iSurveyID)
{
$aPermissions=aGetBaseSurveyPermissions();
$aPermissionsToSet=array();
foreach ($aPermissions as $sPermissionName=>$aPermissionDetails)
{
foreach ($aPermissionDetails as $sPermissionDetailKey=>$sPermissionDetailValue)
{
if (in_array($sPermissionDetailKey,array('create','read','update','delete','import','export')) && $sPermissionDetailValue==true)
{
$aPermissionsToSet[$sPermissionName][$sPermissionDetailKey]=1;
}
}
}
SetSurveyPermissions($iUserID, $iSurveyID, $aPermissionsToSet);
}
function gettemplatelist()
{
global $usertemplaterootdir, $standardtemplates,$standardtemplaterootdir;
if (!$usertemplaterootdir) {die("gettemplatelist() no template directory");}
if ($handle = opendir($standardtemplaterootdir))
{
while (false !== ($file = readdir($handle)))
{
if (!is_file("$standardtemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn" && isStandardTemplate($file))
{
$list_of_files[$file] = $standardtemplaterootdir.DIRECTORY_SEPARATOR.$file;
}
}
closedir($handle);
}
if ($handle = opendir($usertemplaterootdir))
{
while (false !== ($file = readdir($handle)))
{
if (!is_file("$usertemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn")
{
$list_of_files[$file] = $usertemplaterootdir.DIRECTORY_SEPARATOR.$file;
}
}
closedir($handle);
}
ksort($list_of_files);
return $list_of_files;
}
/**
* This function set a question attribute to a certain value
*
* @param mixed $qid
* @param mixed $sAttributeName
* @param mixed $sAttributeValue
*/
function setQuestionAttribute($qid,$sAttributeName,$sAttributeValue)
{
global $dbprefix,$connect;
$tablename=$dbprefix.'question_attributes';
$aInsertArray=array('qid'=>$qid,
'attribute'=>$sAttributeName,
'value'=>$sAttributeValue);
$sQuery=$connect->GetInsertSQL($tablename,$aInsertArray);
$connect->Execute('delete from '.db_table_name('question_attributes')." where qid={$qid} and attribute=".db_quoteall($sAttributeName));
$connect->Execute($sQuery);
}
/**
* Returns the default email template texts as array
*
* @param mixed $oLanguage Required language translationb object
* @param string $mode Escape mode for the translation function
* @return array
*/
function aTemplateDefaultTexts($oLanguage, $mode='html'){
return array(
'admin_detailed_notification_subject'=>$oLanguage->gT("Response submission for survey {SURVEYNAME} with results",$mode),
'admin_detailed_notification'=>$oLanguage->gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to reload the survey:\n{RELOADURL}\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}\n\n\nThe following answers were given by the participant:\n{ANSWERTABLE}",$mode),
'admin_detailed_notification_css'=>'<style type="text/css">
.printouttable {
margin:1em auto;
}
.printouttable th {
text-align: center;
}
.printouttable td {
border-color: #ddf #ddf #ddf #ddf;
border-style: solid;
border-width: 1px;
padding:0.1em 1em 0.1em 0.5em;
}
.printouttable td:first-child {
font-weight: 700;
text-align: right;
padding-right: 5px;
padding-left: 5px;
}
.printouttable .printanswersquestion td{
background-color:#F7F8FF;
}
.printouttable .printanswersquestionhead td{
text-align: left;
background-color:#ddf;
}
.printouttable .printanswersgroup td{
text-align: center;
font-weight:bold;
padding-top:1em;
}
</style>',
'admin_notification_subject'=>$oLanguage->gT("Response submission for survey {SURVEYNAME}",$mode),
'admin_notification'=>$oLanguage->gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to reload the survey:\n{RELOADURL}\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}",$mode),
'confirmation_subject'=>$oLanguage->gT("Confirmation of your participation in our survey"),
'confirmation'=>$oLanguage->gT("Dear {FIRSTNAME},\n\nthis email is to confirm that you have completed the survey titled {SURVEYNAME} and your response has been saved. Thank you for participating.\n\nIf you have any further questions about this email, please contact {ADMINNAME} on {ADMINEMAIL}.\n\nSincerely,\n\n{ADMINNAME}",$mode),
'invitation_subject'=>$oLanguage->gT("Invitation to participate in a survey",$mode),
'invitation'=>$oLanguage->gT("Dear {FIRSTNAME},\n\nyou have been invited to participate in a survey.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}",$mode)."\n\n".$oLanguage->gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}",$mode),
'reminder_subject'=>$oLanguage->gT("Reminder to participate in a survey",$mode),
'reminder'=>$oLanguage->gT("Dear {FIRSTNAME},\n\nRecently we invited you to participate in a survey.\n\nWe note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}",$mode)."\n\n".$oLanguage->gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}",$mode),
'registration_subject'=>$oLanguage->gT("Survey registration confirmation",$mode),
'registration'=>$oLanguage->gT("Dear {FIRSTNAME},\n\nYou, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.\n\nTo complete this survey, click on the following URL:\n\n{SURVEYURL}\n\nIf you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.",$mode)
);
}
// Closing PHP tag intentionally left out - yes, it is okay
function doAdminHeader()
{
echo getAdminHeader();
}
function getAdminHeader($meta=false)
{
global $sitename, $admintheme, $rooturl, $defaultlang, $css_admin_includes, $homeurl;
if (!isset($_SESSION['adminlang']) || $_SESSION['adminlang']=='') {$_SESSION['adminlang']=$defaultlang;}
$strAdminHeader="<?xml version=\"1.0\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
."<html ";
if (getLanguageRTL($_SESSION['adminlang']))
{
$strAdminHeader.=" dir=\"rtl\" ";
}
$strAdminHeader.=">\n<head>\n";
if ($meta)
{
$strAdminHeader.=$meta;
}
$strAdminHeader.="<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery-ui.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery.qtip.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery.notify.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$homeurl}/scripts/admin_core.js\"></script>\n";
if ($_SESSION['adminlang']!='en')
{
$strAdminHeader.= "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/locale/jquery.ui.datepicker-{$_SESSION['adminlang']}.js\"></script>\n";
}
$strAdminHeader.= "<title>$sitename</title>\n";
$strAdminHeader.= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$homeurl}//styles/$admintheme/tab.webfx.css \" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$rooturl}/scripts/jquery/css/start/jquery-ui.css\" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$homeurl}/styles/$admintheme/printablestyle.css\" media=\"print\" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$homeurl}/styles/$admintheme/adminstyle.css\" />\n"
. "<link rel=\"shortcut icon\" href=\"{$homeurl}/favicon.ico\" type=\"image/x-icon\" />\n"
. "<link rel=\"icon\" href=\"{$homeurl}/favicon.ico\" type=\"image/x-icon\" />\n";
if (getLanguageRTL($_SESSION['adminlang']))
{
$strAdminHeader.="<link rel=\"stylesheet\" type=\"text/css\" href=\"styles/$admintheme/adminstyle-rtl.css\" />\n";
}
$css_admin_includes = array_unique($css_admin_includes);
foreach ($css_admin_includes as $cssinclude)
{
$strAdminHeader .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"$cssinclude\" />\n";
}
$strAdminHeader.= use_firebug()
. "</head>\n<body>\n";
if (isset($_SESSION['dateformat']))
{
$formatdata=getDateFormatData($_SESSION['dateformat']);
$strAdminHeader .= "<script type='text/javascript'>
var userdateformat='".$formatdata['jsdate']."';
var userlanguage='".$_SESSION['adminlang']."';
</script>";
}
// Prepare flashmessage
if (isset($_SESSION['flashmessage']) && $_SESSION['flashmessage']!='')
{
$strAdminHeader .='<div id="flashmessage" style="display:none;">
<div id="themeroller" class="ui-state-highlight ui-corner-all">
<!-- close link -->
<a class="ui-notify-close" href="#">
<span class="ui-icon ui-icon-close" style="float:right"></span>
</a>
<!-- alert icon -->
<span style="float:left; margin:2px 5px 0 0;" class="ui-icon ui-icon-info"></span>
<h1></h1>
<p>'.$_SESSION['flashmessage'].'</p>
</div>
<!-- other templates here, maybe.. -->
</div>';
unset($_SESSION['flashmessage']);
}
// Standard header
$strAdminHeader .="<div class='maintitle'>{$sitename}</div>\n";
return $strAdminHeader;
}

View File

@@ -1,17 +1,17 @@
<?php <?php
/* /*
* LimeSurvey * LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz * Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved. * All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php * License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant * LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or * to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or * is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses. * other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details. * See COPYRIGHT.php for copyright notices and details.
* *
* $Id: assessments.php 7428 2009-08-10 10:26:46Z c_schmitz $ * $Id: assessments.php 10925 2011-09-02 14:12:02Z c_schmitz $
*/ */
include_once("login_check.php"); include_once("login_check.php");
@@ -20,311 +20,302 @@ if (!isset($action)) {$action=returnglobal('action');}
$surveyinfo=getSurveyInfo($surveyid); $surveyinfo=getSurveyInfo($surveyid);
$js_adminheader_includes[]= $homeurl.'/scripts/assessments.js'; $js_admin_includes[]= $homeurl.'/scripts/assessments.js';
$js_adminheader_includes[]= $rooturl.'/scripts/jquery/jquery-ui.js'; $js_admin_includes[]='../scripts/jquery/jquery.tablesorter.min.js';
// . "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/default/jquery-ui.css\" />\n"; // . "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/default/jquery-ui.css\" />\n";
$actsurquery = "SELECT edit_survey_property FROM {$dbprefix}surveys_rights WHERE sid=$surveyid AND uid = ".$_SESSION['loginID']; //Getting rights for this survey
$actsurresult = $connect->Execute($actsurquery) or safe_die($connect->ErrorMsg());
$actsurrows = $actsurresult->FetchRow();
$assessmentlangs = GetAdditionalLanguagesFromSurveyID($surveyid); $assessmentlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid); $baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($assessmentlangs,$baselang); // makes an array with ALL the languages supported by the survey -> $assessmentlangs array_unshift($assessmentlangs,$baselang); // makes an array with ALL the languages supported by the survey -> $assessmentlangs
if (!bHasSurveyPermission($surveyid, 'assessments','read'))
{
$action = "assessment";
include("access_denied.php");
include("admin.php");
exit;
}
if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $actsurrows['edit_survey_property']){ if ($action == "assessmentadd" && bHasSurveyPermission($surveyid, 'assessments','create')) {
$inserttable=$dbprefix."assessments";
if ($action == "assessmentadd") { $first=true;
$inserttable=$dbprefix."assessments"; foreach ($assessmentlangs as $assessmentlang)
$first=true;
foreach ($assessmentlangs as $assessmentlang)
{
if (!isset($_POST['gid'])) $_POST['gid']=0;
$datarray=array(
'sid' => $surveyid,
'scope' => $_POST['scope'],
'gid' => $_POST['gid'],
'minimum' => $_POST['minimum'],
'maximum' => $_POST['maximum'],
'name' => $_POST['name_'.$assessmentlang],
'language' => $assessmentlang,
'message' => $_POST['assessmentmessage_'.$assessmentlang]);
if ($first==false)
{
$datarray['id']=$aid;
}
$query = $connect->GetInsertSQL($inserttable, $datarray, get_magic_quotes_gpc());
$result=$connect->Execute($query) or safe_die("Error inserting<br />$query<br />".$connect->ErrorMsg());
if ($first==true)
{
$first=false;
$aid=$connect->Insert_ID(db_table_name_nq('assessments'),"id");
}
}
} elseif ($action == "assessmentupdate") {
if ($filterxsshtml)
{
require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
}
foreach ($assessmentlangs as $assessmentlang)
{
if (!isset($_POST['gid'])) $_POST['gid']=0;
if ($filterxsshtml)
{
$_POST['name_'.$assessmentlang]=$myFilter->process($_POST['name_'.$assessmentlang]);
$_POST['assessmentmessage_'.$assessmentlang]=$myFilter->process($_POST['assessmentmessage_'.$assessmentlang]);
}
$query = "UPDATE {$dbprefix}assessments
SET scope='".db_quote($_POST['scope'])."',
gid=".sanitize_int($_POST['gid']).",
minimum='".sanitize_signedint($_POST['minimum'])."',
maximum='".sanitize_signedint($_POST['maximum'])."',
name='".db_quote($_POST['name_'.$assessmentlang],true)."',
message='".db_quote($_POST['assessmentmessage_'.$assessmentlang],true)."'
WHERE language='$assessmentlang' and id=".sanitize_int($_POST['id']);
$result = $connect->Execute($query) or safe_die("Error updating<br />$query<br />".$connect->ErrorMsg());
}
} elseif ($action == "assessmentdelete") {
$query = "DELETE FROM {$dbprefix}assessments
WHERE id=".sanitize_int($_POST['id']);
$result=$connect->Execute($query);
}
$assessmentsoutput=PrepareEditorScript();
$assessmentsoutput.="<script type=\"text/javascript\">
<!--
var strnogroup='".$clang->gT("There are no groups available.", "js")."';
--></script>";
$assessmentsoutput.="<table width='100%' border='0' >\n"
. "\t<tr>\n"
. "\t\t<td>\n"
. "<div class='menubar'>\n"
. "\t<div class='menubar-title'>\n"
. "\t\t<strong>".$clang->gT("Assessments")."</strong>\n";
$assessmentsoutput.= "\t</div>\n"
. "\t<div class='menubar-main'>\n"
. "\t\t<div class='menubar-left'>\n"
. "\t\t\t<a href=\"#\" onclick=\"window.open('$scriptname?sid=$surveyid', '_self')\" onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("Return to Survey Administration", "js")."');return false\">" .
"<img name='Administration' src='$imagefiles/home.png' title='' alt='' /></a>\n"
. "\t\t\t<img src='$imagefiles/blank.gif' alt='' width='11' />\n"
. "\t\t\t<img src='$imagefiles/seperator.gif' alt='' />\n";
if ($surveyinfo['assessments']!='Y')
{ {
$assessmentsoutput.='<span style="font-size:11px;">'.sprintf($clang->gT("Notice: Assessment mode for this survey is not activated. You can activate it in the %s survey settings %s (tab 'Notification & data management')."),'<a href="admin.php?action=editsurvey&sid='.$surveyid.'">','</a>').'</span>'; if (!isset($_POST['gid'])) $_POST['gid']=0;
$datarray=array(
'sid' => $surveyid,
'scope' => $_POST['scope'],
'gid' => $_POST['gid'],
'minimum' => $_POST['minimum'],
'maximum' => $_POST['maximum'],
'name' => $_POST['name_'.$assessmentlang],
'language' => $assessmentlang,
'message' => $_POST['assessmentmessage_'.$assessmentlang]);
if ($first==false)
{
$datarray['id']=$aid;
}
$query = $connect->GetInsertSQL($inserttable, $datarray, get_magic_quotes_gpc());
$result=$connect->Execute($query) or safe_die("Error inserting<br />$query<br />".$connect->ErrorMsg());
if ($first==true)
{
$first=false;
$aid=$connect->Insert_ID(db_table_name_nq('assessments'),"id");
}
} }
$assessmentsoutput.= "\t\t</div>\n" } elseif ($action == "assessmentupdate" && bHasSurveyPermission($surveyid, 'assessments','update')) {
if ($filterxsshtml)
{
require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
}
foreach ($assessmentlangs as $assessmentlang)
{
if (!isset($_POST['gid'])) $_POST['gid']=0;
if ($filterxsshtml)
{
$_POST['name_'.$assessmentlang]=$myFilter->process($_POST['name_'.$assessmentlang]);
$_POST['assessmentmessage_'.$assessmentlang]=$myFilter->process($_POST['assessmentmessage_'.$assessmentlang]);
}
$query = "UPDATE {$dbprefix}assessments
SET scope='".db_quote($_POST['scope'],true)."',
gid=".sanitize_int($_POST['gid']).",
minimum='".sanitize_signedint($_POST['minimum'])."',
maximum='".sanitize_signedint($_POST['maximum'])."',
name='".db_quote($_POST['name_'.$assessmentlang],true)."',
message='".db_quote($_POST['assessmentmessage_'.$assessmentlang],true)."'
WHERE language='$assessmentlang' and id=".sanitize_int($_POST['id']);
$result = $connect->Execute($query) or safe_die("Error updating<br />$query<br />".$connect->ErrorMsg());
}
} elseif ($action == "assessmentdelete" && bHasSurveyPermission($surveyid, 'assessments','delete')) {
$query = "DELETE FROM {$dbprefix}assessments
WHERE id=".sanitize_int($_POST['id']);
$result=$connect->Execute($query);
}
if (bHasSurveyPermission($surveyid, 'assessments','read'))
{
$assessmentsoutput=PrepareEditorScript();
$assessmentsoutput.="<script type=\"text/javascript\">
<!--
var strnogroup='".$clang->gT("There are no groups available.", "js")."';
--></script>\n";
$assessmentsoutput.="<div class='menubar'>\n"
. "\t<div class='menubar-title ui-widget-header'>\n"
. "<strong>".$clang->gT("Assessments")."</strong>\n";
$assessmentsoutput.= "\t</div>\n"
. "\t<div class='menubar-main'>\n"
. "<div class='menubar-left'>\n"
. "\t<a href=\"#\" onclick=\"window.open('$scriptname?sid=$surveyid', '_self')\" title='".$clang->gTview("Return to survey administration")."'>"
. "<img name='Administration' src='$imageurl/home.png' alt='".$clang->gT("Return to survey administration")."' /></a>\n"
. "\t<img src='$imageurl/blank.gif' alt='' width='11' />\n"
. "\t<img src='$imageurl/seperator.gif' alt='' />\n";
if ($surveyinfo['assessments']!='Y')
{
$assessmentsoutput.='<span style="font-size:11px;">'.sprintf($clang->gT("Notice: Assessment mode for this survey is not activated. You can activate it in the %s survey settings %s (tab 'Notification & data management')."),'<a href="admin.php?action=editsurvey&amp;sid='.$surveyid.'">','</a>').'</span>';
}
$assessmentsoutput.= "</div>\n"
. "\t</div>\n" . "\t</div>\n"
. "</div>\n"; . "</div>\n";
$assessmentsoutput .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'>&nbsp;</p>"; //CSS Firefox 2 transition fix $assessmentsoutput .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'>&nbsp;</p>"; //CSS Firefox 2 transition fix
if ($surveyid == "") { if ($surveyid == "") {
$assessmentsoutput.= $clang->gT("No SID Provided"); $assessmentsoutput.= $clang->gT("No SID Provided");
exit; exit;
} }
$assessments=getAssessments($surveyid); $assessments=getAssessments($surveyid);
//$assessmentsoutput.= "<pre>";print_r($assessments);echo "</pre>"; //$assessmentsoutput.= "<pre>";print_r($assessments);echo "</pre>";
$groups=getGroups($surveyid); $groups=getGroups($surveyid);
$groupselect="<select name='gid' id='newgroupselect'>\n"; $groupselect="<select name='gid' id='gid'>\n";
foreach($groups as $group) { foreach($groups as $group) {
$groupselect.="<option value='".$group['gid']."'>".$group['group_name']."</option>\n"; $groupselect.="<option value='".$group['gid']."'>".$group['group_name']."</option>\n";
} }
$groupselect .="</select>\n"; $groupselect .="</select>\n";
$headings=array($clang->gT("Scope"), $clang->gT("Question group"), $clang->gT("Minimum"), $clang->gT("Maximum")); $headings=array($clang->gT("Scope"), $clang->gT("Question group"), $clang->gT("Minimum"), $clang->gT("Maximum"));
$inputs=array("<input type='radio' id='radiototal' name='scope' value='T' checked='checked'>".$clang->gT("Total")."</input><input type='radio' id='radiogroup' name='scope' value='G'>".$clang->gT("Group")."</input>",
$groupselect,
"<input type='text' name='minimum' class='numbersonly' />",
"<input type='text' name='maximum' class='numbersonly' />");
$actiontitle=$clang->gT("Add"); $actiontitle=$clang->gT("Add");
$actionvalue="assessmentadd"; $actionvalue="assessmentadd";
$thisid=""; $thisid="";
if ($action == "assessmentedit") { if ($action == "assessmentedit" && bHasSurveyPermission($surveyid, 'assessments','update')) {
$query = "SELECT * FROM {$dbprefix}assessments WHERE id=".sanitize_int($_POST['id'])." and language='$baselang'"; $query = "SELECT * FROM {$dbprefix}assessments WHERE id=".sanitize_int($_POST['id'])." and language='$baselang'";
$results = db_execute_assoc($query); $results = db_execute_assoc($query);
while($row=$results->FetchRow()) { while($row=$results->FetchRow()) {
$editdata=$row; $editdata=$row;
} }
$scopeselect = "<input type='radio' id='radiototal' name='scope' ";
if ($editdata['scope'] == "T") {$scopeselect .= "checked='checked' ";}
$scopeselect .= "value='T'>".$clang->gT("Total")."</input>";
$scopeselect .= "<input type='radio' name='scope' id='radiogroup' value='G'";
if ($editdata['scope'] == "G") {$scopeselect .= " checked='checked'";}
$scopeselect .= ">".$clang->gT("Question group")."</input>";
$groupselect=str_replace("'".$editdata['gid']."'", "'".$editdata['gid']."' selected", $groupselect); $groupselect=str_replace("'".$editdata['gid']."'", "'".$editdata['gid']."' selected", $groupselect);
$inputs=array($scopeselect, $actiontitle=$clang->gT("Edit");
$groupselect,
"<input type='text' name='minimum' value='".$editdata['minimum']."' class='numbersonly' />",
"<input type='text' name='maximum' value='".$editdata['maximum']."' class='numbersonly' />",
"<input type='text' name='name' size='80' value='".htmlentities(stripslashes($editdata['name']), ENT_QUOTES,'UTF-8')."'/>",
"<textarea name='message' id='assessmentmessage' rows='10' cols='80'>".htmlentities(stripslashes($editdata['message']), ENT_QUOTES,'UTF-8')."</textarea>");
$actiontitle=$clang->gT("Edit");
$actionvalue="assessmentupdate"; $actionvalue="assessmentupdate";
$thisid=$editdata['id']; $thisid=$editdata['id'];
} }
//$assessmentsoutput.= "<pre>"; print_r($edits); $assessmentsoutput.= "</pre>"; //$assessmentsoutput.= "<pre>"; print_r($edits); $assessmentsoutput.= "</pre>";
//PRESENT THE PAGE //PRESENT THE PAGE
$assessmentsoutput.= "<br /><table align='center' width='90%'> $assessmentsoutput.= "<div class='header ui-widget-header'>".$clang->gT("Assessment rules")."</div>"
<tr><th colspan='12'>".$clang->gT("Assessment rules")."</th></tr>"
."<tr><th>".$clang->gT("ID")."</th><th>".$clang->gT("SID")."</th>\n";
."<table class='assessmentlist'><thead>"
."<tr><th>".$clang->gT("ID")."</th><th>".$clang->gT("Actions")."</th><th>".$clang->gT("SID")."</th>\n";
foreach ($headings as $head) { foreach ($headings as $head) {
$assessmentsoutput.= "<th>$head</th>\n"; $assessmentsoutput.= "<th>$head</th>\n";
} }
$assessmentsoutput.= "<th>".$clang->gT("Title")."</th><th>".$clang->gT("Message")."</th><th>".$clang->gT("Actions")."</th>"; $assessmentsoutput.= "<th>".$clang->gT("Title")."</th><th>".$clang->gT("Message")."</th>";
$assessmentsoutput.= "</tr>\n"; $assessmentsoutput.= "</tr></thead>\n<tbody>\n";
$flipflop=true; $flipflop=true;
foreach($assessments as $assess) { foreach($assessments as $assess) {
$flipflop=!$flipflop; $flipflop=!$flipflop;
if ($flipflop==true){$assessmentsoutput.= "<tr class='oddrow'>\n";} if ($flipflop==true){$assessmentsoutput.= "<tr class='oddrow'>\n";}
else {$assessmentsoutput.= "<tr class='evenrow'>\n";} else {$assessmentsoutput.= "<tr class='evenrow'>\n";}
$assessmentsoutput.= "<td>".$assess['id']."</td>\n"; $assessmentsoutput.= "<td>".$assess['id']."</td>\n";
$assessmentsoutput.= "<td>".$assess['sid']."</td>\n"; $assessmentsoutput.= "<td>";
if (bHasSurveyPermission($surveyid, 'assessments','update'))
if ($assess['scope'] == "T")
{
$assessmentsoutput.= "<td>".$clang->gT("Total")."</td>\n";
$assessmentsoutput.= "<td>-</td>\n";
}
else
{ {
$assessmentsoutput.= "<td>".$clang->gT("Question group")."</td>\n"; $assessmentsoutput.="<form method='post' action='$scriptname?sid=$surveyid'>
$assessmentsoutput.= "<td>".$groups[$assess['gid']]['group_name']." (".$assess['gid'].")</td>\n"; <input type='image' src='$imageurl/token_edit.png' alt='".$clang->gT("Edit")."' />
<input type='hidden' name='action' value='assessmentedit' />
<input type='hidden' name='id' value='".$assess['id']."' />
</form>";
} }
if (bHasSurveyPermission($surveyid, 'assessments','delete'))
{
$assessmentsoutput.="<form method='post' action='$scriptname?sid=$surveyid'>
<input type='image' src='$imageurl/token_delete.png' alt='".$clang->gT("Delete")."' onclick='return confirm(\"".$clang->gT("Are you sure you want to delete this entry?","js")."\")' />
<input type='hidden' name='action' value='assessmentdelete' />
<input type='hidden' name='id' value='".$assess['id']."' />
</form>";
}
$assessmentsoutput.= "</td><td>".$assess['sid']."</td>\n";
if ($assess['scope'] == "T")
{
$assessmentsoutput.= "<td>".$clang->gT("Total")."</td>\n";
$assessmentsoutput.= "<td>-</td>\n";
}
else
{
$assessmentsoutput.= "<td>".$clang->gT("Question group")."</td>\n";
$assessmentsoutput.= "<td>".$groups[$assess['gid']]['group_name']." (".$assess['gid'].")</td>\n";
}
$assessmentsoutput.= "<td>".$assess['minimum']."</td>\n"; $assessmentsoutput.= "<td>".$assess['minimum']."</td>\n";
$assessmentsoutput.= "<td>".$assess['maximum']."</td>\n"; $assessmentsoutput.= "<td>".$assess['maximum']."</td>\n";
$assessmentsoutput.= "<td>".stripslashes($assess['name'])."</td>\n"; $assessmentsoutput.= "<td>".stripslashes($assess['name'])."</td>\n";
$assessmentsoutput.= "<td>".strip_tags(strip_javascript($assess['message']))."</td>\n"; $assessmentsoutput.= "<td>".strip_tags(strip_javascript($assess['message']))."</td>\n";
$assessmentsoutput.= "<td> $assessmentsoutput.= "</tr></tbody>\n";
<table width='100%'>
<tr><td align='center'><form method='post' action='$scriptname?sid=$surveyid'>
<input type='submit' value='".$clang->gT("Edit")."' />
<input type='hidden' name='action' value='assessmentedit' />
<input type='hidden' name='id' value='".$assess['id']."' />
</form></td>
<td align='center'><form method='post' action='$scriptname?sid=$surveyid'>
<input type='submit' value='".$clang->gT("Delete")."' onclick='return confirm(\"".$clang->gT("Are you sure you want to delete this entry?","js")."\")' />
<input type='hidden' name='action' value='assessmentdelete' />
<input type='hidden' name='id' value='".$assess['id']."' />
</form>
</td>
</tr>
</table>
</td>\n";
$assessmentsoutput.= "</tr>\n";
} }
$assessmentsoutput.= "</table>"; $assessmentsoutput.= "</table>";
if ((bHasSurveyPermission($surveyid, 'assessments','update') && $actionvalue=="assessmentupdate") || (bHasSurveyPermission($surveyid, 'assessments','create')&& $actionvalue=="assessmentadd"))
//now present edit/insert form
$assessmentsoutput.= "<br /><form method='post' name='assessmentsform' action='$scriptname?sid=$surveyid'><table align='center' cellspacing='0' border='0' class='form2columns'>\n";
$assessmentsoutput.= "<tr><th colspan='2'>$actiontitle</th></tr>\n";
$i=0;
foreach ($headings as $head) {
$assessmentsoutput.= "<tr><td>$head</td><td>".$inputs[$i]."<br /></td></tr>\n";
$i++;
}
// start tabs
$assessmentsoutput.= "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
$assessmentsoutput.='</table><div id="languagetabs">'
.'<ul>';
foreach ($assessmentlangs as $assessmentlang)
{ {
$position=0;
$assessmentsoutput .= '<li><a href="#tablang'.$assessmentlang.'"><span>'.getLanguageNameFromCode($assessmentlang, false); //now present edit/insert form
if ($assessmentlang==$baselang) {$assessmentsoutput .= ' ('.$clang->gT("Base Language").')';} $assessmentsoutput.= "<br /><form method='post' class='form30' id='assessmentsform' name='assessmentsform' action='$scriptname?sid=$surveyid'><div class='header ui-widget-header'>\n";
$assessmentsoutput .='</span></a></li>'; $assessmentsoutput.= "$actiontitle</div>\n";
$assessmentsoutput.="<ul><li><label>".$clang->gT("Scope")."</label><input type='radio' id='radiototal' name='scope' value='T' ";
if (!isset($editdata) || $editdata['scope'] == "T") {$assessmentsoutput .= " checked='checked' ";}
$assessmentsoutput.=" /><label for='radiototal'>".$clang->gT("Total")."</label>
<input type='radio' id='radiogroup' name='scope' value='G'";
if (isset($editdata) && $editdata['scope'] == "G") {$assessmentsoutput .= " checked='checked' ";}
$assessmentsoutput.="/><label for='radiogroup'>".$clang->gT("Group")."</label></li>";
$assessmentsoutput.="<li><label for='gid'>".$clang->gT("Question group")."</label>$groupselect</li>"
."<li><label for='minimum'>".$clang->gT("Minimum")."</label><input type='text' id='minimum' name='minimum' class='numbersonly'";
if (isset($editdata)) {$assessmentsoutput .= " value='{$editdata['minimum']}' ";}
$assessmentsoutput.="/></li>"
."<li><label for='maximum'>".$clang->gT("Maximum")."</label><input type='text' id='maximum' name='maximum' class='numbersonly'";
if (isset($editdata)) {$assessmentsoutput .= " value='{$editdata['maximum']}' ";}
$assessmentsoutput.="/></li>";
// start tabs
$assessmentsoutput.= "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
$assessmentsoutput.='</table><div id="languagetabs">'
.'<ul>';
foreach ($assessmentlangs as $assessmentlang)
{
$position=0;
$assessmentsoutput .= '<li><a href="#tablang'.$assessmentlang.'"><span>'.getLanguageNameFromCode($assessmentlang, false);
if ($assessmentlang==$baselang) {$assessmentsoutput .= ' ('.$clang->gT("Base language").')';}
$assessmentsoutput .='</span></a></li>';
}
$assessmentsoutput.= '</ul>';
foreach ($assessmentlangs as $assessmentlang)
{
$heading=''; $message='';
if ($action == "assessmentedit")
{
$query = "SELECT * FROM {$dbprefix}assessments WHERE id=".sanitize_int($_POST['id'])." and language='$assessmentlang'";
$results = db_execute_assoc($query);
while($row=$results->FetchRow()) {
$editdata=$row;
}
$heading=htmlspecialchars($editdata['name'],ENT_QUOTES);
$message=htmlspecialchars($editdata['message']);
}
$assessmentsoutput .= '<div id="tablang'.$assessmentlang.'">';
$assessmentsoutput .= $clang->gT("Heading")."<br/>"
."<input type='text' name='name_$assessmentlang' size='80' value='$heading'/><br /><br />"
.$clang->gT("Message")
."<textarea name='assessmentmessage_$assessmentlang' id='assessmentmessage_$assessmentlang' rows='10' cols='80'>$message</textarea >";
$assessmentsoutput .='</div>';
}
$assessmentsoutput .='</div>';
$assessmentsoutput.= "<p><input type='submit' value='".$clang->gT("Save")."' />\n";
if ($action == "assessmentedit") $assessmentsoutput.= "&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' value='".$clang->gT("Cancel")."' onclick=\"document.assessmentsform.action.value='assessments'\" />\n";
$assessmentsoutput.= "<input type='hidden' name='sid' value='$surveyid' />\n"
."<input type='hidden' name='action' value='$actionvalue' />\n"
."<input type='hidden' name='id' value='$thisid' />\n"
."</div>\n"
."</form>\n";
foreach ($assessmentlangs as $assessmentlang)
{
$assessmentsoutput.=getEditor("assessment-text","assessmentmessage_$assessmentlang", "[".$clang->gT("Message:", "js")."]",$surveyid,$gid,$qid,$action);
}
} }
$assessmentsoutput.= '</ul>'; }
foreach ($assessmentlangs as $assessmentlang)
{
$heading=''; $message='';
if ($action == "assessmentedit")
{
$query = "SELECT * FROM {$dbprefix}assessments WHERE id=".sanitize_int($_POST['id'])." and language='$assessmentlang'";
$results = db_execute_assoc($query);
while($row=$results->FetchRow()) {
$editdata=$row;
}
$heading=$editdata['name'];
$message=$editdata['message'];
}
$assessmentsoutput .= '<div id="tablang'.$assessmentlang.'">';
$assessmentsoutput .= $clang->gT("Heading")."<br/>"
."<input type='text' name='name_$assessmentlang' size='80' value='$heading'/><br /><br />"
.$clang->gT("Message")
."<textarea name='assessmentmessage_$assessmentlang' id='assessmentmessage_$assessmentlang' rows='10' cols='80'>$message</textarea >";
$assessmentsoutput .='</div>';
}
$assessmentsoutput .='</div>';
$assessmentsoutput.= "<div style='width:200px;margin:5px auto;'><input type='submit' value='".$clang->gT("Save")."' />\n";
if ($action == "assessmentedit") $assessmentsoutput.= "&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' value='".$clang->gT("Cancel")."' onclick=\"document.assessmentsform.action.value='assessments'\" />\n";
$assessmentsoutput.= "<input type='hidden' name='sid' value='$surveyid' />\n"
."<input type='hidden' name='action' value='$actionvalue' />\n"
."<input type='hidden' name='id' value='$thisid' />\n"
."<div>\n"
."</form>\n";
foreach ($assessmentlangs as $assessmentlang)
{
$assessmentsoutput.=getEditor("assessment-text","assessmentmessage_$assessmentlang", "[".$clang->gT("Message:", "js")."]",$surveyid,$gid,$qid,$action);
}
}
else
{
$action = "assessment";
include("access_denied.php");
include("admin.php");
}
function getAssessments($surveyid) { function getAssessments($surveyid) {
global $dbprefix, $connect, $baselang; global $dbprefix, $connect, $baselang;
$query = "SELECT id, sid, scope, gid, minimum, maximum, name, message $query = "SELECT id, sid, scope, gid, minimum, maximum, name, message
FROM ".db_table_name('assessments')." FROM ".db_table_name('assessments')."
WHERE sid='$surveyid' and language='$baselang' WHERE sid='$surveyid' and language='$baselang'
ORDER BY scope, gid"; ORDER BY scope, gid";
$result=db_execute_assoc($query) or safe_die("Error getting assessments<br />$query<br />".$connect->ErrorMsg()); $result=db_execute_assoc($query) or safe_die("Error getting assessments<br />$query<br />".$connect->ErrorMsg());
$output=array(); $output=array();
while($row=$result->FetchRow()) { while($row=$result->FetchRow()) {
$output[]=$row; $output[]=$row;
} }
return $output; return $output;
} }
function getGroups($surveyid) { function getGroups($surveyid) {
global $dbprefix, $connect; global $dbprefix, $connect;
$baselang = GetBaseLanguageFromSurveyID($surveyid); $baselang = GetBaseLanguageFromSurveyID($surveyid);
$query = "SELECT gid, group_name $query = "SELECT gid, group_name
FROM ".db_table_name('groups')." FROM ".db_table_name('groups')."
WHERE sid='$surveyid' and language='$baselang' WHERE sid='$surveyid' and language='$baselang'
ORDER BY group_order"; ORDER BY group_order";
$result = db_execute_assoc($query) or safe_die("Error getting groups<br />$query<br />".$connect->ErrorMsg()); $result = db_execute_assoc($query) or safe_die("Error getting groups<br />$query<br />".$connect->ErrorMsg());
$output=array(); $output=array();
while($row=$result->FetchRow()) { while($row=$result->FetchRow()) {
$output[$row['gid']]=$row; $output[$row['gid']]=$row;
} }
return $output; return $output;
} }
?> ?>

View File

@@ -0,0 +1,163 @@
<?php
include_once('globalsettings.php');
include_once('database.php');
if($subaction=='bounceprocessing')
{
if(empty($cron))
{
$surveyidoriginal = $_GET['sid'];
}
$settings=getSurveyInfo($surveyidoriginal);
if ($settings['bounceprocessing']=='N')
{
}
else
{
$bouncetotal=0;
$checktotal=0;
if($settings['bounceprocessing']=='G')
{
$accounttype=getGlobalSetting('bounceaccounttype');
$hostname=getGlobalSetting('bounceaccounthost');
$username=getGlobalSetting('bounceaccountuser');
$pass=getGlobalSetting('bounceaccountpass');
$hostencryption=getGlobalSetting('bounceencryption');
}
else
{
$accounttype=$settings['bounceaccounttype'];
$hostname=$settings['bounceaccounthost'];
$username=$settings['bounceaccountuser'];
$pass=$settings['bounceaccountpass'];
$hostencryption=$settings['bounceaccountencryption'];
}
if($accounttype=='IMAP')
{
if($hostencryption=='SSL')
{
$finalhostname='{'.$hostname.'/imap/ssl}INBOX';
}
elseif($hostencryption=='TLS')
{
$finalhostname='{'.$hostname.'/imap/tls}INBOX';
}
else
{
$finalhostname='{'.$hostname.'/imap}INBOX';
}
if(@$mbox=imap_open($finalhostname,$username,$pass))
{
@$count=imap_num_msg($mbox);
$lasthinfo=imap_headerinfo($mbox,$count);
$datelc=$lasthinfo->date;
$datelcu = strtotime($datelc);
$gettimestamp = "select bouncetime from ".db_table_name("surveys")." where sid='$surveyidoriginal';";
$datelcufiles = $connect->Execute($gettimestamp);
$datelcufile = substr($datelcufiles,11);
while($datelcu > $datelcufile)
{
$lasthinfo=imap_headerinfo($mbox,$count);
$datelc=$lasthinfo->date;
$datelcu = strtotime($datelc);
$header = explode("\r\n", imap_body($mbox,$count));
foreach ($header as $item)
{
if (preg_match('/^X-surveyid/',$item))
{
$surveyid=explode(": ",$item);
}
if (preg_match('/^X-tokenid/',$item))
{
$token=explode(": ",$item);
if($surveyidoriginal == $surveyid[1])
{
$bouncequery = "UPDATE ".db_table_name("tokens_$surveyidoriginal")." set emailstatus='bounced', usesleft=0 where token='".db_quote($token[1])."';";
$anish=$connect->Execute($bouncequery);
$bouncetotal++;
}
}
}
$count--;
$lasthinfo=imap_headerinfo($mbox,$count);
$datelc=$lasthinfo->date;
$datelcu = strtotime($datelc);
$checktotal++;
}
@$count=imap_num_msg($mbox);
@$lastcheckedinfo=imap_headerinfo($mbox,$count);
$datelcfinal=$lastcheckedinfo->date;
$datelcfinalu = strtotime($datelcfinal);
$entertimestamp = "update ".db_table_name("surveys")." set bouncetime='$datelcfinalu' where sid='$surveyidoriginal';";
$executetimestamp = $connect->Execute($entertimestamp);
}
else
{
echo "Please check your settings";
}
}
elseif($accounttype='POP')
{
if($hostencryption=='SSL')
{
$finalhostname='{'.$hostname.'/pop3/ssl/novalidate-cert}INBOX';
}
elseif($hostencryption=='TLS')
{
$finalhostname='{'.$hostname.'/pop3/tls/novalidate-cert}INBOX';
}
else
{
$finalhostname='{'.$hostname.'/pop3/novalidate-cert}INBOX';
}
if(@$mbox=imap_open($finalhostname,$username,$pass))
{
@$count=imap_num_msg($mbox);
while($count>0)
{ @$header = explode("\r\n", imap_body($mbox,$count));
foreach ($header as $item)
{
if (preg_match('/^X-surveyid/',$item))
{
$surveyid=explode(": ",$item);
}
if (preg_match('/^X-tokenid/',$item))
{
$token=explode(": ",$item);
if($surveyidoriginal == $surveyid[1])
{
$bouncequery = "UPDATE ".db_table_name("tokens_$surveyidoriginal")." set emailstatus='bounced', usesleft=0 where token='".db_quote($token[1])."';";
$anish=$connect->Execute($bouncequery) or safe_die ("Couldn't update sent field<br />$query<br />".$connect->ErrorMsg());
$bouncetotal++;
}
}
}
$count--;
$checktotal++;
}
imap_errors();
imap_close($mbox);
}
else
{
echo "Please check your settings";
}
}
if($bouncetotal>0)
{
echo "<div id='dialog-modal'>$checktotal messages were scanned out of which $bouncetotal were marked as bounce by the system. <br><br><br>Please reload the browse table to view results</div>";
}
else
{
echo "<div id ='dialog-modal'>$checktotal messages were scanned out of which $bouncetotal were marked as bounce by the system.</div>";
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,142 +1,142 @@
<?php <?php
/* /*
* Class ProgressBar * Class ProgressBar
* *
* Author: Gerd Weitenberg (hahnebuechen@web.de) * Author: Gerd Weitenberg (hahnebuechen@web.de)
* Date: 2005.03.09 * Date: 2005.03.09
* *
*/ */
class ProgressBar class ProgressBar
{ {
// private vars // private vars
var $code; // unique code var $code; // unique code
var $status = 'new'; // current status (new,show,hide) var $status = 'new'; // current status (new,show,hide)
var $step = 0; // current step var $step = 0; // current step
var $position = array(); // current bar position var $position = array(); // current bar position
// public vars // public vars
var $min = 0; // minimal steps var $min = 0; // minimal steps
var $max = 100; // maximal steps var $max = 100; // maximal steps
var $left = 10; // bar position from left var $left = 10; // bar position from left
var $top = 25; // bar position from top var $top = 25; // bar position from top
var $width = 300; // bar width var $width = 300; // bar width
var $height = 25; // bar height var $height = 25; // bar height
var $pedding = 0; // bar pedding var $pedding = 0; // bar pedding
var $color = '#0033ff'; // bar color var $color = '#0033ff'; // bar color
var $bgr_color = '#c0c0c0'; // bar background color var $bgr_color = '#c0c0c0'; // bar background color
var $border = 1; // bar border width var $border = 1; // bar border width
var $brd_color = '#000000'; // bar border color var $brd_color = '#000000'; // bar border color
var $direction = 'right'; // direction of motion (right,left,up,down) var $direction = 'right'; // direction of motion (right,left,up,down)
var $frame = array('show' => false); // ProgressBar Frame var $frame = array('show' => false); // ProgressBar Frame
/* 'show' => false, # frame show (true/false) /* 'show' => false, # frame show (true/false)
'left' => 200, # frame position from left 'left' => 200, # frame position from left
'top' => 100, # frame position from top 'top' => 100, # frame position from top
'width' => 300, # frame width 'width' => 300, # frame width
'height' => 75, # frame height 'height' => 75, # frame height
'color' => '#c0c0c0', # frame color 'color' => '#c0c0c0', # frame color
'border' => 2, # frame border 'border' => 2, # frame border
'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color 'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color
*/ */
var $label = array(); // ProgressBar Labels var $label = array(); // ProgressBar Labels
/* 'name' => array( # label name /* 'name' => array( # label name
'type' => 'text', # label type (text,button,step,percent,crossbar) 'type' => 'text', # label type (text,button,step,percent,crossbar)
'value' => 'Please wait ...', # label value 'value' => 'Please wait ...', # label value
'left' => 10, # label position from left 'left' => 10, # label position from left
'top' => 20, # label position from top 'top' => 20, # label position from top
'width' => 0, # label width 'width' => 0, # label width
'height' => 0, # label height 'height' => 0, # label height
'align' => 'left', # label align 'align' => 'left', # label align
'font-size' => 11, # label font size 'font-size' => 11, # label font size
'font-family' => 'Verdana, Tahoma, Arial', # label font family 'font-family' => 'Verdana, Tahoma, Arial', # label font family
'font-weight' => '', # label font weight 'font-weight' => '', # label font weight
'color' => '#000000', # label font color 'color' => '#000000', # label font color
'bgr_color' => '' # label background color 'bgr_color' => '' # label background color
) )
*/ */
// constructor // constructor
function ProgressBar($width=0,$height=0) function ProgressBar($width=0,$height=0)
{ {
$this->code = substr(md5(microtime()), 0, 6); $this->code = substr(md5(microtime()), 0, 6);
if ($width>0) {$this->width = $width;} if ($width>0) {$this->width = $width;}
if ($height>0) {$this->height = $height;} if ($height>0) {$this->height = $height;}
} }
// private functions // private functions
function _calculatePercent($step) function _calculatePercent($step)
{ {
$percent = round(($step - $this->min) / ($this->max - $this->min) * 100); $percent = round(($step - $this->min) / ($this->max - $this->min) * 100);
if ($percent > 100) {$percent = 100;} if ($percent > 100) {$percent = 100;}
return $percent; return $percent;
} }
function _calculatePosition($step) function _calculatePosition($step)
{ {
switch ($this->direction) { switch ($this->direction) {
case 'right': case 'right':
case 'left': case 'left':
$bar = $this->width; $bar = $this->width;
break; break;
case 'down': case 'down':
case 'up': case 'up':
$bar = $this->height; $bar = $this->height;
break; break;
} }
$pixel = round(($step - $this->min) * ($bar - ($this->pedding * 2)) / ($this->max - $this->min)); $pixel = round(($step - $this->min) * ($bar - ($this->pedding * 2)) / ($this->max - $this->min));
if ($step <= $this->min) {$pixel = 0;} if ($step <= $this->min) {$pixel = 0;}
if ($step >= $this->max) {$pixel = $bar - ($this->pedding * 2);} if ($step >= $this->max) {$pixel = $bar - ($this->pedding * 2);}
switch ($this->direction) { switch ($this->direction) {
case 'right': case 'right':
$position['left'] = $this->pedding; $position['left'] = $this->pedding;
$position['top'] = $this->pedding; $position['top'] = $this->pedding;
$position['width'] = $pixel; $position['width'] = $pixel;
$position['height'] = $this->height - ($this->pedding * 2); $position['height'] = $this->height - ($this->pedding * 2);
break; break;
case 'left': case 'left':
$position['left'] = $this->width - $this->pedding - $pixel; $position['left'] = $this->width - $this->pedding - $pixel;
$position['top'] = $this->pedding; $position['top'] = $this->pedding;
$position['width'] = $pixel; $position['width'] = $pixel;
$position['height'] = $this->height - ($this->pedding * 2); $position['height'] = $this->height - ($this->pedding * 2);
break; break;
case 'down': case 'down':
$position['left'] = $this->pedding; $position['left'] = $this->pedding;
$position['top'] = $this->pedding; $position['top'] = $this->pedding;
$position['width'] = $this->width - ($this->pedding * 2); $position['width'] = $this->width - ($this->pedding * 2);
$position['height'] = $pixel; $position['height'] = $pixel;
break; break;
case 'up': case 'up':
$position['left'] = $this->pedding; $position['left'] = $this->pedding;
$position['top'] = $this->height - $this->pedding - $pixel; $position['top'] = $this->height - $this->pedding - $pixel;
$position['width'] = $this->width - ($this->pedding * 2); $position['width'] = $this->width - ($this->pedding * 2);
$position['height'] = $pixel; $position['height'] = $pixel;
break; break;
} }
return $position; return $position;
} }
function _setStep($step) function _setStep($step)
{ {
if ($step > $this->max) {$step = $this->max;} if ($step > $this->max) {$step = $this->max;}
if ($step < $this->min) {$step = $this->min;} if ($step < $this->min) {$step = $this->min;}
$this->step = $step; $this->step = $step;
} }
// public functions // public functions
function setFrame($width=0,$height=0) function setFrame($width=0,$height=0)
{ {
$this->frame = array( $this->frame = array(
'show' => true, 'show' => true,
'left' => 20, 'left' => 20,
'top' => 35, 'top' => 35,
@@ -145,17 +145,17 @@ class ProgressBar
'color' => '#c0c0c0', 'color' => '#c0c0c0',
'border' => 2, 'border' => 2,
'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' 'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf'
); );
if ($width>0) {$this->frame['width'] = $width;} if ($width>0) {$this->frame['width'] = $width;}
if ($height>0) {$this->frame['height'] = $height;} if ($height>0) {$this->frame['height'] = $height;}
} }
function addLabel($type,$name,$value='&nbsp;') function addLabel($type,$name,$value='&nbsp;')
{ {
switch($type) { switch($type) {
case 'text': case 'text':
$this->label[$name] = array( $this->label[$name] = array(
'type' => 'text', 'type' => 'text',
'value' => $value, 'value' => $value,
'left' => $this->left, 'left' => $this->left,
@@ -168,10 +168,10 @@ class ProgressBar
'font-weight' => 'normal', 'font-weight' => 'normal',
'color' => '#000000', 'color' => '#000000',
'bgr_color' => '' 'bgr_color' => ''
); );
break; break;
case 'button': case 'button':
$this->label[$name] = array( $this->label[$name] = array(
'type' => 'button', 'type' => 'button',
'value' => $value, 'value' => $value,
'action' => '', 'action' => '',
@@ -186,10 +186,10 @@ class ProgressBar
'font-weight' => 'normal', 'font-weight' => 'normal',
'color' => '#000000', 'color' => '#000000',
'bgr_color' => '' 'bgr_color' => ''
); );
break; break;
case 'step': case 'step':
$this->label[$name] = array( $this->label[$name] = array(
'type' => 'step', 'type' => 'step',
'value' => $value, 'value' => $value,
'left' => $this->left + 5, 'left' => $this->left + 5,
@@ -202,10 +202,10 @@ class ProgressBar
'font-weight' => 'normal', 'font-weight' => 'normal',
'color' => '#000000', 'color' => '#000000',
'bgr_color' => '' 'bgr_color' => ''
); );
break; break;
case 'percent': case 'percent':
$this->label[$name] = array( $this->label[$name] = array(
'type' => 'percent', 'type' => 'percent',
'value' => $value, 'value' => $value,
'left' => $this->left + $this->width - 50, 'left' => $this->left + $this->width - 50,
@@ -218,10 +218,10 @@ class ProgressBar
'font-weight' => 'normal', 'font-weight' => 'normal',
'color' => '#000000', 'color' => '#000000',
'bgr_color' => '' 'bgr_color' => ''
); );
break; break;
case 'crossbar': case 'crossbar':
$this->label[$name] = array( $this->label[$name] = array(
'type' => 'crossbar', 'type' => 'crossbar',
'value' => $value, 'value' => $value,
'left' => $this->left + ($this->width / 2), 'left' => $this->left + ($this->width / 2),
@@ -234,296 +234,338 @@ class ProgressBar
'font-weight' => 'normal', 'font-weight' => 'normal',
'color' => '#000000', 'color' => '#000000',
'bgr_color' => '' 'bgr_color' => ''
); );
break; break;
} }
} }
function addButton($name,$value,$action,$target='self') function addButton($name,$value,$action,$target='self')
{ {
$this->addLabel('button',$name,$value); $this->addLabel('button',$name,$value);
$this->label[$name]['action'] = $action; $this->label[$name]['action'] = $action;
$this->label[$name]['target'] = $target; $this->label[$name]['target'] = $target;
} }
function setLabelPosition($name,$left,$top,$width,$height,$align='') function setLabelPosition($name,$left,$top,$width,$height,$align='')
{ {
$this->label[$name]['top'] = intval($top); $this->label[$name]['top'] = intval($top);
$this->label[$name]['left'] = intval($left); $this->label[$name]['left'] = intval($left);
$this->label[$name]['width'] = intval($width); $this->label[$name]['width'] = intval($width);
$this->label[$name]['height'] = intval($height); $this->label[$name]['height'] = intval($height);
if ($align!='') {$this->label[$name]['align'] = $align;} if ($align!='') {$this->label[$name]['align'] = $align;}
if ($this->status!='new') { if ($this->status!='new') {
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.top="'.$this->label[$name]['top'].'px";document.getElementById("plbl'.$name.$this->code.'").style.left="'.$this->label[$name]['left'].'px";document.getElementById("plbl'.$name.$this->code.'").style.width="'.$this->label[$name]['width'].'px";document.getElementById("plbl'.$name.$this->code.'").style.height="'.$this->label[$name]['height'].'px";document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";</script>'."\n"; echo '<script type="text/JavaScript">
flush(); /* <![CDATA[ */
} document.getElementById("plbl'.$name.$this->code.'").style.top="'.$this->label[$name]['top'].'px";
} document.getElementById("plbl'.$name.$this->code.'").style.left="'.$this->label[$name]['left'].'px";
document.getElementById("plbl'.$name.$this->code.'").style.width="'.$this->label[$name]['width'].'px";
function setLabelColor($name,$color) document.getElementById("plbl'.$name.$this->code.'").style.height="'.$this->label[$name]['height'].'px";
{ document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";
$this->label[$name]['color'] = $color; /* ]]> */
if ($this->status!='new') { </script>'."\n";
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.color="'.$color.'";</script>'."\n"; flush();
flush(); }
} }
}
function setLabelColor($name,$color)
function setLabelBackground($name,$color) {
{ $this->label[$name]['color'] = $color;
$this->label[$name]['bgr_color'] = $color; if ($this->status!='new') {
if ($this->status!='new') { echo '<script type="text/JavaScript">
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.background="'.$color.'";</script>'."\n"; /* <![CDATA[ */
flush(); document.getElementById("plbl'.$name.$this->code.'").style.color="'.$color.'";
} /* ]]> */
} </script>'."\n";
flush();
function setLabelFont($name,$size,$family='',$weight='') }
{ }
$this->label[$name]['font-size'] = intval($size);
if ($family!='') {$this->label[$name]['font-family'] = $family;} function setLabelBackground($name,$color)
if ($weight!='') {$this->label[$name]['font-weight'] = $weight;} {
$this->label[$name]['bgr_color'] = $color;
if ($this->status!='new') { if ($this->status!='new') {
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.font-size="'.$this->label[$name]['font-size'].'px";document.getElementById("plbl'.$name.$this->code.'").style.font-family="'.$this->label[$name]['font-family'].'";document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";</script>'."\n"; echo '<script type="text/JavaScript">
flush(); /* <![CDATA[ */
} document.getElementById("plbl'.$name.$this->code.'").style.background="'.$color.'";
} /* ]]> */
</script>'."\n";
function setLabelValue($name,$value) flush();
{ }
$this->label[$name]['value'] = $value; }
if ($this->status!='new') {
echo '<script type="text/JavaScript">PBlabelText'.$this->code.'("'.$name.'","'.$this->label[$name]['value'].'");</script>'."\n"; function setLabelFont($name,$size,$family='',$weight='')
flush(); {
} $this->label[$name]['font-size'] = intval($size);
} if ($family!='') {$this->label[$name]['font-family'] = $family;}
if ($weight!='') {$this->label[$name]['font-weight'] = $weight;}
function setBarColor($color)
{ if ($this->status!='new') {
$this->color = $color; echo '<script type="text/JavaScript">
if ($this->status!='new') { /* <![CDATA[ */
echo '<script type="text/JavaScript">document.getElementById("pbar'.$this->code.'").style.background="'.$color.'";</script>'."\n"; document.getElementById("plbl'.$name.$this->code.'").style.font-size="'.$this->label[$name]['font-size'].'px";
flush(); document.getElementById("plbl'.$name.$this->code.'").style.font-family="'.$this->label[$name]['font-family'].'";
} document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";
} /* ]]> */
</script>'."\n";
function setBarBackground($color) flush();
{ }
$this->bgr_color = $color; }
if ($this->status!='new') {
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.background="'.$color.'";</script>'."\n"; function setLabelValue($name,$value)
flush(); {
} $this->label[$name]['value'] = $value;
} if ($this->status!='new') {
echo '<script type="text/JavaScript">
function setBarDirection($direction) /* <![CDATA[ */
{ PBlabelText'.$this->code.'("'.$name.'","'.$this->label[$name]['value'].'");
$this->direction = $direction; /* ]]> */
</script>'."\n";
if ($this->status!='new') { flush();
$this->position = $this->_calculatePosition($this->step); }
}
echo '<script type="text/JavaScript">';
echo 'PBposition'.$this->code.'("left",'.$this->position['left'].');'; function setBarColor($color)
echo 'PBposition'.$this->code.'("top",'.$this->position['top'].');'; {
echo 'PBposition'.$this->code.'("width",'.$this->position['width'].');'; $this->color = $color;
echo 'PBposition'.$this->code.'("height",'.$this->position['height'].');'; if ($this->status!='new') {
echo '</script>'."\n"; echo '<script type="text/JavaScript">
flush(); /* <![CDATA[ */
} document.getElementById("pbar'.$this->code.'").style.background="'.$color.'";
} /* ]]> */
</script>'."\n";
function getHtml() flush();
{ }
$html = ''; }
$js = '';
function setBarBackground($color)
$this->_setStep($this->step); {
$this->position = $this->_calculatePosition($this->step); $this->bgr_color = $color;
if ($this->status!='new') {
$style_brd = 'position:absolute;top:'.$this->top.'px;left:'.$this->left.'px;width:'.$this->width.'px;height:'.$this->height.'px;background:'.$this->bgr_color.';'; echo '<script type="text/JavaScript">
if ($this->border>0) {$style_brd .= 'border:'.$this->border.'px solid;border-color:'.$this->brd_color.';';} /* <![CDATA[ */
document.getElementById("pbrd'.$this->code.'").style.background="'.$color.'";
$style_bar = 'position:absolute;top:'.$this->position['top'].'px;left:'.$this->position['left'].'px;'.'width:'.$this->position['width'].'px;height:'.$this->position['height'].'px;background:'.$this->color.';'; /* ]]> */
</script>'."\n";
if ($this->frame['show']==true) { flush();
if ($this->frame['border']>0) {$border = 'border:'.$this->frame['border'].'px solid;border-color:'.$this->frame['brd_color'].';';} }
$html = '<div id="pfrm'.$this->code.'" style="position:absolute;top:'.$this->frame['top'].'px;left:'.$this->frame['left'].'px;width:'.$this->frame['width'].'px;height:'.$this->frame['height'].'px;'.$border.'background:'.$this->frame['color'].';">'."\n"; }
}
function setBarDirection($direction)
$html .= '<div id="pbrd'.$this->code.'" style="'.$style_brd.'">'."\n"; {
$html .= '<div id="pbar'.$this->code.'" style="'.$style_bar.'"></div></div>'."\n"; $this->direction = $direction;
$js .= 'function PBposition'.$this->code.'(item,pixel) {'."\n"; if ($this->status!='new') {
$js .= ' pixel = parseInt(pixel);'."\n"; $this->position = $this->_calculatePosition($this->step);
$js .= ' switch(item) {'."\n";
$js .= ' case "left": document.getElementById("pbar'.$this->code.'").style.left=(pixel) + \'px\'; break;'."\n"; echo '<script type="text/JavaScript">';
$js .= ' case "top": document.getElementById("pbar'.$this->code.'").style.top=(pixel) + \'px\'; break;'."\n"; echo '/* <![CDATA[ */';
$js .= ' case "width": document.getElementById("pbar'.$this->code.'").style.width=(pixel) + \'px\'; break;'."\n"; echo 'PBposition'.$this->code.'("left",'.$this->position['left'].');';
$js .= ' case "height": document.getElementById("pbar'.$this->code.'").style.height=(pixel) + \'px\'; break;'."\n"; echo 'PBposition'.$this->code.'("top",'.$this->position['top'].');';
$js .= ' }'."\n"; echo 'PBposition'.$this->code.'("width",'.$this->position['width'].');';
$js .= '}'."\n"; echo 'PBposition'.$this->code.'("height",'.$this->position['height'].');';
echo '/* ]]> */';
foreach($this->label as $name => $data) { echo '</script>'."\n";
$style_lbl = 'position:absolute;top:'.$data['top'].'px;left:'.$data['left'].'px;text-align:'.$data['align'].';'; flush();
if ($data['width']>0) {$style_lbl .= 'width:'.$data['width'].'px;';} }
if ($data['height']>0) {$style_lbl .= 'height:'.$data['height'].'px;';} }
if (array_key_exists('font-size', $data)) {$style_lbl .= 'font-size:'.$data['font-size'].'px;';} function getHtml()
if (array_key_exists('font-family', $data)) {$style_lbl .= 'font-family:'.$data['font-family'].';';} {
if (array_key_exists('font-weight', $data)) {$style_lbl .= 'font-weight:'.$data['font-weight'].';';} $html = '';
if (array_key_exists('bgr_color', $data) && ($data['bgr_color']!='')) {$style_lbl .= 'background:'.$data['bgr_color'].';';} $js = '';
if (array_key_exists('type', $data)) { $this->_setStep($this->step);
switch ($data['type']) { $this->position = $this->_calculatePosition($this->step);
case 'text':
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$data['value'].'</div>'."\n"; $style_brd = 'position:absolute;top:'.$this->top.'px;left:'.$this->left.'px;width:'.$this->width.'px;height:'.$this->height.'px;background:'.$this->bgr_color.';';
break; if ($this->border>0) {$style_brd .= 'border:'.$this->border.'px solid;border-color:'.$this->brd_color.';';}
case 'button':
$html .= '<div><input id="plbl'.$name.$this->code.'" type="button" value="'.$data['value'].'" style="'.$style_lbl.'" onclick="'.$data['target'].'.location.href=\''.$data['action'].'\'" /></div>'."\n"; $style_bar = 'position:absolute;top:'.$this->position['top'].'px;left:'.$this->position['left'].'px;'.'width:'.$this->position['width'].'px;height:'.$this->position['height'].'px;background:'.$this->color.';';
break;
case 'step': if ($this->frame['show']==true) {
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$this->step.'</div>'."\n"; if ($this->frame['border']>0) {$border = 'border:'.$this->frame['border'].'px solid;border-color:'.$this->frame['brd_color'].';';}
break; $html = '<div id="pfrm'.$this->code.'" style="position:absolute;top:'.$this->frame['top'].'px;left:'.$this->frame['left'].'px;width:'.$this->frame['width'].'px;height:'.$this->frame['height'].'px;'.$border.'background:'.$this->frame['color'].';">'."\n";
case 'percent': }
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$this->_calculatePercent($this->step).'%</div>'."\n";
break; $html .= '<div id="pbrd'.$this->code.'" style="'.$style_brd.'">'."\n";
case 'crossbar': $html .= '<div id="pbar'.$this->code.'" style="'.$style_bar.'"></div></div>'."\n";
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$data['value'].'</div>'."\n";
$js .= 'function PBposition'.$this->code.'(item,pixel) {'."\n";
$js .= 'function PBrotaryCross'.$name.$this->code.'() {'."\n"; $js .= ' pixel = parseInt(pixel);'."\n";
$js .= ' cross = document.getElementById("plbl'.$name.$this->code.'").firstChild.nodeValue;'."\n"; $js .= ' switch(item) {'."\n";
$js .= ' switch(cross) {'."\n"; $js .= ' case "left": document.getElementById("pbar'.$this->code.'").style.left=(pixel) + \'px\'; break;'."\n";
$js .= ' case "--": cross = "\\\\"; break;'."\n"; $js .= ' case "top": document.getElementById("pbar'.$this->code.'").style.top=(pixel) + \'px\'; break;'."\n";
$js .= ' case "\\\\": cross = "|"; break;'."\n"; $js .= ' case "width": document.getElementById("pbar'.$this->code.'").style.width=(pixel) + \'px\'; break;'."\n";
$js .= ' case "|": cross = "/"; break;'."\n"; $js .= ' case "height": document.getElementById("pbar'.$this->code.'").style.height=(pixel) + \'px\'; break;'."\n";
$js .= ' default: cross = "--"; break;'."\n"; $js .= ' }'."\n";
$js .= ' }'."\n"; $js .= '}'."\n";
$js .= ' document.getElementById("plbl'.$name.$this->code.'").firstChild.nodeValue = cross;'."\n";
$js .= '}'."\n"; foreach($this->label as $name => $data) {
break; $style_lbl = 'position:absolute;top:'.$data['top'].'px;left:'.$data['left'].'px;text-align:'.$data['align'].';';
} if ($data['width']>0) {$style_lbl .= 'width:'.$data['width'].'px;';}
} if ($data['height']>0) {$style_lbl .= 'height:'.$data['height'].'px;';}
}
if (array_key_exists('font-size', $data)) {$style_lbl .= 'font-size:'.$data['font-size'].'px;';}
if(count($this->label)>0) { if (array_key_exists('font-family', $data)) {$style_lbl .= 'font-family:'.$data['font-family'].';';}
if (array_key_exists('font-weight', $data)) {$style_lbl .= 'font-weight:'.$data['font-weight'].';';}
$js .= 'function PBlabelText'.$this->code.'(name,text) {'."\n"; if (array_key_exists('bgr_color', $data) && ($data['bgr_color']!='')) {$style_lbl .= 'background:'.$data['bgr_color'].';';}
$js .= ' name = "plbl" + name + "'.$this->code.'";'."\n";
$js .= ' document.getElementById(name).firstChild.nodeValue=text;'."\n"; if (array_key_exists('type', $data)) {
$js .= '}'."\n"; switch ($data['type']) {
} case 'text':
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$data['value'].'</div>'."\n";
if ($this->frame['show']==true) { break;
$html .= '</div>'."\n"; case 'button':
} $html .= '<div><input id="plbl'.$name.$this->code.'" type="button" value="'.$data['value'].'" style="'.$style_lbl.'" onclick="'.$data['target'].'.location.href=\''.$data['action'].'\'" /></div>'."\n";
break;
$html .= '<script type="text/JavaScript">'."\n"; case 'step':
$html .= $js; $html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$this->step.'</div>'."\n";
$html .= '</script>'."\n"; break;
case 'percent':
return $html; $html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$this->_calculatePercent($this->step).'%</div>'."\n";
} break;
case 'crossbar':
function show() $html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$data['value'].'</div>'."\n";
{
$this->status = 'show'; $js .= 'function PBrotaryCross'.$name.$this->code.'() {'."\n";
echo $this->getHtml(); $js .= ' cross = document.getElementById("plbl'.$name.$this->code.'").firstChild.nodeValue;'."\n";
flush(); $js .= ' switch(cross) {'."\n";
} $js .= ' case "--": cross = "\\\\"; break;'."\n";
$js .= ' case "\\\\": cross = "|"; break;'."\n";
function moveStep($step) $js .= ' case "|": cross = "/"; break;'."\n";
{ $js .= ' default: cross = "--"; break;'."\n";
$last_step = $this->step; $js .= ' }'."\n";
$this->_setStep($step); $js .= ' document.getElementById("plbl'.$name.$this->code.'").firstChild.nodeValue = cross;'."\n";
$js .= '}'."\n";
$js = ''; break;
}
$new_position = $this->_calculatePosition($this->step); }
if ($new_position['width']!=$this->position['width'] && ($this->direction=='right' || $this->direction=='left')) { }
if ($this->direction=='left') {
$js .= 'PBposition'.$this->code.'("left",'.$new_position['left'].');'; if(count($this->label)>0) {
}
$js .= 'PBposition'.$this->code.'("width",'.$new_position['width'].');'; $js .= 'function PBlabelText'.$this->code.'(name,text) {'."\n";
} $js .= ' name = "plbl" + name + "'.$this->code.'";'."\n";
if ($new_position['height']!=$this->position['height'] && ($this->direction=='up' || $this->direction=='down')) { $js .= ' document.getElementById(name).firstChild.nodeValue=text;'."\n";
if ($this->direction=='up') { $js .= '}'."\n";
$js .= 'PBposition'.$this->code.'("top",'.$new_position['top'].');'; }
}
$js .= 'PBposition'.$this->code.'("height",'.$new_position['height'].');'; if ($this->frame['show']==true) {
} $html .= '</div>'."\n";
$this->position = $new_position; }
foreach($this->label as $name => $data) { $html .= '<script type="text/JavaScript">'."\n";
if (array_key_exists('type', $data)) { $html .= '/* <![CDATA[ */';
switch($data['type']) { $html .= $js;
case 'step': $html .= '/* ]]> */';
if ($this->step!=$last_step) { $html .= '</script>'."\n";
$js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$this->step.'/'.$this->max.'");';
} return $html;
break; }
case 'percent':
$percent = $this->_calculatePercent($this->step); function show()
if ($percent!=$this->_calculatePercent($last_step)) { {
$js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$percent.'%");'; $this->status = 'show';
} echo $this->getHtml();
break; flush();
case 'crossbar': }
$js .= 'PBrotaryCross'.$name.$this->code.'();';
break; function moveStep($step)
} {
} $last_step = $this->step;
} $this->_setStep($step);
if ($js!='') {
echo '<script type="text/JavaScript">'.$js.'</script>'."\n"; $js = '';
flush ();
} $new_position = $this->_calculatePosition($this->step);
} if ($new_position['width']!=$this->position['width'] && ($this->direction=='right' || $this->direction=='left')) {
if ($this->direction=='left') {
function moveNext() $js .= 'PBposition'.$this->code.'("left",'.$new_position['left'].');';
{ }
$this->moveStep($this->step + 1); $js .= 'PBposition'.$this->code.'("width",'.$new_position['width'].');';
} }
if ($new_position['height']!=$this->position['height'] && ($this->direction=='up' || $this->direction=='down')) {
function moveMin() if ($this->direction=='up') {
{ $js .= 'PBposition'.$this->code.'("top",'.$new_position['top'].');';
$this->moveStep($this->min); }
} $js .= 'PBposition'.$this->code.'("height",'.$new_position['height'].');';
}
function hide() $this->position = $new_position;
{
if ($this->status=='show') { foreach($this->label as $name => $data) {
$this->status = 'hide'; if (array_key_exists('type', $data)) {
switch($data['type']) {
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.visibility="hidden";document.getElementById("pbar'.$this->code.'").style.visibility="hidden";'; case 'step':
if ($this->frame['show']==true) { if ($this->step!=$last_step) {
echo 'document.getElementById("pfrm'.$this->code.'").style.visibility="hidden";'; $js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$this->step.'/'.$this->max.'");';
} }
foreach($this->label as $name => $data) { break;
echo 'document.getElementById("plbl'.$name.$this->code.'").style.visibility="hidden";'; case 'percent':
} $percent = $this->_calculatePercent($this->step);
echo '</script>'."\n"; if ($percent!=$this->_calculatePercent($last_step)) {
flush(); $js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$percent.'%");';
} }
} break;
case 'crossbar':
function unhide() $js .= 'PBrotaryCross'.$name.$this->code.'();';
{ break;
if ($this->status=='hide') { }
$this->status = 'show'; }
}
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.visibility="visible";document.getElementById("pbar'.$this->code.'").style.visibility="visible";'; if ($js!='') {
if ($this->frame['show']==true) { echo '<script type="text/JavaScript">'."\n"
echo 'document.getElementById("pfrm'.$this->code.'").style.visibility="visible";'; .'/* <![CDATA[ */'."\n"
} . $js."\n"
foreach($this->label as $name => $data) { . '/* ]]> */'."\n"
echo 'document.getElementById("plbl'.$name.$this->code.'").style.visibility="visible";'; .'</script>'."\n";
} flush ();
echo '</script>'."\n"; }
flush(); }
}
} function moveNext()
{
$this->moveStep($this->step + 1);
}
function moveMin()
{
$this->moveStep($this->min);
}
function hide()
{
if ($this->status=='show') {
$this->status = 'hide';
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.visibility="hidden";document.getElementById("pbar'.$this->code.'").style.visibility="hidden";';
if ($this->frame['show']==true) {
echo 'document.getElementById("pfrm'.$this->code.'").style.visibility="hidden";';
}
foreach($this->label as $name => $data) {
echo 'document.getElementById("plbl'.$name.$this->code.'").style.visibility="hidden";';
}
echo '</script>'."\n";
flush();
}
}
function unhide()
{
if ($this->status=='hide') {
$this->status = 'show';
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.visibility="visible";document.getElementById("pbar'.$this->code.'").style.visibility="visible";';
if ($this->frame['show']==true) {
echo 'document.getElementById("pfrm'.$this->code.'").style.visibility="visible";';
}
foreach($this->label as $name => $data) {
echo 'document.getElementById("plbl'.$name.$this->code.'").style.visibility="visible";';
}
echo '</script>'."\n";
flush();
}
}
} }
?> ?>

View File

@@ -6,8 +6,8 @@
Typical use: Typical use:
{ {
if (version_compare(PHP_VERSION,'5','>=')) if (version_compare(PHP_VERSION,'5','>='))
require_once('domxml-php4-to-php5.php'); require_once('domxml-php4-to-php5.php');
} }
Version 1.19, 2007-09-30, http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/ Version 1.19, 2007-09-30, http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
@@ -20,17 +20,17 @@
http://alexandre.alapetite.net/divers/apropos/#by-sa http://alexandre.alapetite.net/divers/apropos/#by-sa
- Attribution. You must give the original author credit - Attribution. You must give the original author credit
- Share Alike. If you alter, transform, or build upon this work, - Share Alike. If you alter, transform, or build upon this work,
you may distribute the resulting work only under a license identical to this one you may distribute the resulting work only under a license identical to this one
(Can be included in GPL/LGPL projects) (Can be included in GPL/LGPL projects)
- The French law is authoritative - The French law is authoritative
- Any of these conditions can be waived if you get permission from Alexandre Alapetite - Any of these conditions can be waived if you get permission from Alexandre Alapetite
- Please send to Alexandre Alapetite the modifications you make, - Please send to Alexandre Alapetite the modifications you make,
in order to improve this file for the benefit of everybody in order to improve this file for the benefit of everybody
If you want to distribute this code, please do it as a link to: If you want to distribute this code, please do it as a link to:
http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/ http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
*/ */
@ini_set('zend.ze1_compatibility_mode', '0'); @ini_set('zend.ze1_compatibility_mode', '0');
define('DOMXML_LOAD_PARSING',0); define('DOMXML_LOAD_PARSING',0);
define('DOMXML_LOAD_VALIDATING',1); define('DOMXML_LOAD_VALIDATING',1);
define('DOMXML_LOAD_RECOVERING',2); define('DOMXML_LOAD_RECOVERING',2);
@@ -42,36 +42,36 @@ function domxml_new_doc($version) {return new php4DOMDocument();}
function domxml_new_xmldoc($version) {return new php4DOMDocument();} function domxml_new_xmldoc($version) {return new php4DOMDocument();}
function domxml_open_file($filename,$mode=DOMXML_LOAD_PARSING,&$error=null) function domxml_open_file($filename,$mode=DOMXML_LOAD_PARSING,&$error=null)
{ {
$dom=new php4DOMDocument($mode); $dom=new php4DOMDocument($mode);
$errorMode=(func_num_args()>2)&&defined('LIBXML_VERSION'); $errorMode=(func_num_args()>2)&&defined('LIBXML_VERSION');
if ($errorMode) libxml_use_internal_errors(true); if ($errorMode) libxml_use_internal_errors(true);
if (!$dom->myDOMNode->load($filename)) $dom=null; if (!$dom->myDOMNode->load($filename)) $dom=null;
if ($errorMode) if ($errorMode)
{ {
$error=array_map('_error_report',libxml_get_errors()); $error=array_map('_error_report',libxml_get_errors());
libxml_clear_errors(); libxml_clear_errors();
} }
return $dom; return $dom;
} }
function domxml_open_mem($str,$mode=DOMXML_LOAD_PARSING,&$error=null) function domxml_open_mem($str,$mode=DOMXML_LOAD_PARSING,&$error=null)
{ {
$dom=new php4DOMDocument($mode); $dom=new php4DOMDocument($mode);
$errorMode=(func_num_args()>2)&&defined('LIBXML_VERSION'); $errorMode=(func_num_args()>2)&&defined('LIBXML_VERSION');
if ($errorMode) libxml_use_internal_errors(true); if ($errorMode) libxml_use_internal_errors(true);
if (!$dom->myDOMNode->loadXML($str)) $dom=null; if (!$dom->myDOMNode->loadXML($str)) $dom=null;
if ($errorMode) if ($errorMode)
{ {
$error=array_map('_error_report',libxml_get_errors()); $error=array_map('_error_report',libxml_get_errors());
libxml_clear_errors(); libxml_clear_errors();
} }
return $dom; return $dom;
} }
function html_doc($html_doc,$from_file=false) function html_doc($html_doc,$from_file=false)
{ {
$dom=new php4DOMDocument(); $dom=new php4DOMDocument();
if ($from_file) $result=$dom->myDOMNode->loadHTMLFile($html_doc); if ($from_file) $result=$dom->myDOMNode->loadHTMLFile($html_doc);
else $result=$dom->myDOMNode->loadHTML($html_doc); else $result=$dom->myDOMNode->loadHTML($html_doc);
return $result ? $dom : null; return $result ? $dom : null;
} }
function html_doc_file($filename) {return html_doc($filename,true);} function html_doc_file($filename) {return html_doc($filename,true);}
function xmldoc($str) {return domxml_open_mem($str);} function xmldoc($str) {return domxml_open_mem($str);}
@@ -84,400 +84,400 @@ function _error_report($error) {return array('errormessage'=>$error->message,'no
class php4DOMAttr extends php4DOMNode class php4DOMAttr extends php4DOMNode
{ {
function name() {return $this->myDOMNode->name;} function name() {return $this->myDOMNode->name;}
function set_content($text) {} function set_content($text) {}
//function set_value($content) {return $this->myDOMNode->value=htmlspecialchars($content,ENT_QUOTES);} //function set_value($content) {return $this->myDOMNode->value=htmlspecialchars($content,ENT_QUOTES);}
function specified() {return $this->myDOMNode->specified;} function specified() {return $this->myDOMNode->specified;}
function value() {return $this->myDOMNode->value;} function value() {return $this->myDOMNode->value;}
} }
class php4DOMDocument extends php4DOMNode class php4DOMDocument extends php4DOMNode
{ {
function php4DOMDocument($mode=DOMXML_LOAD_PARSING) function php4DOMDocument($mode=DOMXML_LOAD_PARSING)
{ {
$this->myDOMNode=new DOMDocument(); $this->myDOMNode=new DOMDocument();
$this->myOwnerDocument=$this; $this->myOwnerDocument=$this;
if ($mode & DOMXML_LOAD_VALIDATING) $this->myDOMNode->validateOnParse=true; if ($mode & DOMXML_LOAD_VALIDATING) $this->myDOMNode->validateOnParse=true;
if ($mode & DOMXML_LOAD_RECOVERING) $this->myDOMNode->recover=true; if ($mode & DOMXML_LOAD_RECOVERING) $this->myDOMNode->recover=true;
if ($mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) $this->myDOMNode->substituteEntities=true; if ($mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) $this->myDOMNode->substituteEntities=true;
if ($mode & DOMXML_LOAD_DONT_KEEP_BLANKS) $this->myDOMNode->preserveWhiteSpace=false; if ($mode & DOMXML_LOAD_DONT_KEEP_BLANKS) $this->myDOMNode->preserveWhiteSpace=false;
} }
function add_root($name) function add_root($name)
{ {
if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild); if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
return new php4DOMElement($this->myDOMNode->appendChild($this->myDOMNode->createElement($name)),$this->myOwnerDocument); return new php4DOMElement($this->myDOMNode->appendChild($this->myDOMNode->createElement($name)),$this->myOwnerDocument);
} }
function create_attribute($name,$value) function create_attribute($name,$value)
{ {
$myAttr=$this->myDOMNode->createAttribute($name); $myAttr=$this->myDOMNode->createAttribute($name);
$myAttr->value=htmlspecialchars($value,ENT_QUOTES); $myAttr->value=htmlspecialchars($value,ENT_QUOTES);
return new php4DOMAttr($myAttr,$this); return new php4DOMAttr($myAttr,$this);
} }
function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);} function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);}
function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);} function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);}
function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);} function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);}
function create_element_ns($uri,$name,$prefix=null) function create_element_ns($uri,$name,$prefix=null)
{ {
if ($prefix==null) $prefix=$this->myDOMNode->lookupPrefix($uri); if ($prefix==null) $prefix=$this->myDOMNode->lookupPrefix($uri);
if (($prefix==null)&&(($this->myDOMNode->documentElement==null)||(!$this->myDOMNode->documentElement->isDefaultNamespace($uri)))) $prefix='a'.sprintf('%u',crc32($uri)); if (($prefix==null)&&(($this->myDOMNode->documentElement==null)||(!$this->myDOMNode->documentElement->isDefaultNamespace($uri)))) $prefix='a'.sprintf('%u',crc32($uri));
return new php4DOMElement($this->myDOMNode->createElementNS($uri,$prefix==null ? $name : $prefix.':'.$name),$this); return new php4DOMElement($this->myDOMNode->createElementNS($uri,$prefix==null ? $name : $prefix.':'.$name),$this);
} }
function create_entity_reference($content) {return new php4DOMNode($this->myDOMNode->createEntityReference($content),$this);} //By Walter Ebert 2007-01-22 function create_entity_reference($content) {return new php4DOMNode($this->myDOMNode->createEntityReference($content),$this);} //By Walter Ebert 2007-01-22
function create_processing_instruction($target,$data=''){return new php4DomProcessingInstruction($this->myDOMNode->createProcessingInstruction($target,$data),$this);} function create_processing_instruction($target,$data=''){return new php4DomProcessingInstruction($this->myDOMNode->createProcessingInstruction($target,$data),$this);}
function create_text_node($content) {return new php4DOMText($this->myDOMNode->createTextNode($content),$this);} function create_text_node($content) {return new php4DOMText($this->myDOMNode->createTextNode($content),$this);}
function document_element() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);} function document_element() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);}
function dump_file($filename,$compressionmode=false,$format=false) function dump_file($filename,$compressionmode=false,$format=false)
{ {
$format0=$this->myDOMNode->formatOutput; $format0=$this->myDOMNode->formatOutput;
$this->myDOMNode->formatOutput=$format; $this->myDOMNode->formatOutput=$format;
$res=$this->myDOMNode->save($filename); $res=$this->myDOMNode->save($filename);
$this->myDOMNode->formatOutput=$format0; $this->myDOMNode->formatOutput=$format0;
return $res; return $res;
} }
function dump_mem($format=false,$encoding=false) function dump_mem($format=false,$encoding=false)
{ {
$format0=$this->myDOMNode->formatOutput; $format0=$this->myDOMNode->formatOutput;
$this->myDOMNode->formatOutput=$format; $this->myDOMNode->formatOutput=$format;
$encoding0=$this->myDOMNode->encoding; $encoding0=$this->myDOMNode->encoding;
if ($encoding) $this->myDOMNode->encoding=$encoding; if ($encoding) $this->myDOMNode->encoding=$encoding;
$dump=$this->myDOMNode->saveXML(); $dump=$this->myDOMNode->saveXML();
$this->myDOMNode->formatOutput=$format0; $this->myDOMNode->formatOutput=$format0;
if ($encoding) $this->myDOMNode->encoding= $encoding0=='' ? 'UTF-8' : $encoding0; //UTF-8 is XML default encoding if ($encoding) $this->myDOMNode->encoding= $encoding0=='' ? 'UTF-8' : $encoding0; //UTF-8 is XML default encoding
return $dump; return $dump;
} }
function free() function free()
{ {
if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild); if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
$this->myDOMNode=null; $this->myDOMNode=null;
$this->myOwnerDocument=null; $this->myOwnerDocument=null;
} }
function get_element_by_id($id) {return parent::_newDOMElement($this->myDOMNode->getElementById($id),$this);} function get_element_by_id($id) {return parent::_newDOMElement($this->myDOMNode->getElementById($id),$this);}
function get_elements_by_tagname($name) function get_elements_by_tagname($name)
{ {
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name); $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this); while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this);
return $nodeSet; return $nodeSet;
} }
function html_dump_mem() {return $this->myDOMNode->saveHTML();} function html_dump_mem() {return $this->myDOMNode->saveHTML();}
function root() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);} function root() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);}
function xpath_new_context() {return new php4DOMXPath($this);} function xpath_new_context() {return new php4DOMXPath($this);}
} }
class php4DOMElement extends php4DOMNode class php4DOMElement extends php4DOMNode
{ {
function add_namespace($uri,$prefix) function add_namespace($uri,$prefix)
{ {
if ($this->myDOMNode->hasAttributeNS('http://www.w3.org/2000/xmlns/',$prefix)) return false; if ($this->myDOMNode->hasAttributeNS('http://www.w3.org/2000/xmlns/',$prefix)) return false;
else else
{ {
$this->myDOMNode->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:'.$prefix,$uri); //By Daniel Walker 2006-09-08 $this->myDOMNode->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:'.$prefix,$uri); //By Daniel Walker 2006-09-08
return true; return true;
} }
} }
function get_attribute($name) {return $this->myDOMNode->getAttribute($name);} function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
function get_attribute_node($name) {return parent::_newDOMElement($this->myDOMNode->getAttributeNode($name),$this->myOwnerDocument);} function get_attribute_node($name) {return parent::_newDOMElement($this->myDOMNode->getAttributeNode($name),$this->myOwnerDocument);}
function get_elements_by_tagname($name) function get_elements_by_tagname($name)
{ {
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name); $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument); while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
return $nodeSet; return $nodeSet;
} }
function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);} function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);} function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
function set_attribute($name,$value) function set_attribute($name,$value)
{ {
//return $this->myDOMNode->setAttribute($name,$value); //Does not return a DomAttr //return $this->myDOMNode->setAttribute($name,$value); //Does not return a DomAttr
$myAttr=$this->myDOMNode->ownerDocument->createAttribute($name); $myAttr=$this->myDOMNode->ownerDocument->createAttribute($name);
$myAttr->value=htmlspecialchars($value,ENT_QUOTES); //Entity problem reported by AL-DesignWorks 2007-09-07 $myAttr->value=htmlspecialchars($value,ENT_QUOTES); //Entity problem reported by AL-DesignWorks 2007-09-07
$this->myDOMNode->setAttributeNode($myAttr); $this->myDOMNode->setAttributeNode($myAttr);
return new php4DOMAttr($myAttr,$this->myOwnerDocument); return new php4DOMAttr($myAttr,$this->myOwnerDocument);
} }
/*function set_attribute_node($attr) /*function set_attribute_node($attr)
{ {
$this->myDOMNode->setAttributeNode($this->_importNode($attr)); $this->myDOMNode->setAttributeNode($this->_importNode($attr));
return $attr; return $attr;
}*/ }*/
function set_name($name) function set_name($name)
{ {
if ($this->myDOMNode->prefix=='') $newNode=$this->myDOMNode->ownerDocument->createElement($name); if ($this->myDOMNode->prefix=='') $newNode=$this->myDOMNode->ownerDocument->createElement($name);
else $newNode=$this->myDOMNode->ownerDocument->createElementNS($this->myDOMNode->namespaceURI,$this->myDOMNode->prefix.':'.$name); else $newNode=$this->myDOMNode->ownerDocument->createElementNS($this->myDOMNode->namespaceURI,$this->myDOMNode->prefix.':'.$name);
$myDOMNodeList=$this->myDOMNode->attributes; $myDOMNodeList=$this->myDOMNode->attributes;
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i++)) while ($node=$myDOMNodeList->item($i++))
if ($node->namespaceURI=='') $newNode->setAttribute($node->name,$node->value); if ($node->namespaceURI=='') $newNode->setAttribute($node->name,$node->value);
else $newNode->setAttributeNS($node->namespaceURI,$node->nodeName,$node->value); else $newNode->setAttributeNS($node->namespaceURI,$node->nodeName,$node->value);
$myDOMNodeList=$this->myDOMNode->childNodes; $myDOMNodeList=$this->myDOMNode->childNodes;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item(0)) $newNode->appendChild($node); while ($node=$myDOMNodeList->item(0)) $newNode->appendChild($node);
$this->myDOMNode->parentNode->replaceChild($newNode,$this->myDOMNode); $this->myDOMNode->parentNode->replaceChild($newNode,$this->myDOMNode);
$this->myDOMNode=$newNode; $this->myDOMNode=$newNode;
return true; return true;
} }
function tagname() {return $this->myDOMNode->tagName;} function tagname() {return $this->myDOMNode->tagName;}
} }
class php4DOMNode class php4DOMNode
{ {
public $myDOMNode; public $myDOMNode;
public $myOwnerDocument; public $myOwnerDocument;
function php4DOMNode($aDomNode,$aOwnerDocument) function php4DOMNode($aDomNode,$aOwnerDocument)
{ {
$this->myDOMNode=$aDomNode; $this->myDOMNode=$aDomNode;
$this->myOwnerDocument=$aOwnerDocument; $this->myOwnerDocument=$aOwnerDocument;
} }
function __get($name) function __get($name)
{ {
switch ($name) switch ($name)
{ {
case 'type': return $this->myDOMNode->nodeType; case 'type': return $this->myDOMNode->nodeType;
case 'tagname': return $this->myDOMNode->tagName; //DomElement case 'tagname': return $this->myDOMNode->tagName; //DomElement
case 'content': return $this->myDOMNode->textContent; case 'content': return $this->myDOMNode->textContent;
case 'name': return $this->myDOMNode->name; //DomAttribute case 'name': return $this->myDOMNode->name; //DomAttribute
case 'value': return $this->myDOMNode->value; case 'value': return $this->myDOMNode->value;
default: default:
$myErrors=debug_backtrace(); $myErrors=debug_backtrace();
trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE); trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
return false; return false;
} }
} }
function add_child($newnode) {return append_child($newnode);} function add_child($newnode) {return append_child($newnode);}
function add_namespace($uri,$prefix) {return false;} function add_namespace($uri,$prefix) {return false;}
function append_child($newnode) {return self::_newDOMElement($this->myDOMNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);} function append_child($newnode) {return self::_newDOMElement($this->myDOMNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);}
function append_sibling($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);} function append_sibling($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);}
function attributes() function attributes()
{ {
$myDOMNodeList=$this->myDOMNode->attributes; $myDOMNodeList=$this->myDOMNode->attributes;
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument); while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
return $nodeSet; return $nodeSet;
} }
function child_nodes() function child_nodes()
{ {
$myDOMNodeList=$this->myDOMNode->childNodes; $myDOMNodeList=$this->myDOMNode->childNodes;
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=self::_newDOMElement($node,$this->myOwnerDocument); while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=self::_newDOMElement($node,$this->myOwnerDocument);
return $nodeSet; return $nodeSet;
} }
function children() {return $this->child_nodes();} function children() {return $this->child_nodes();}
function clone_node($deep=false) {return self::_newDOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);} function clone_node($deep=false) {return self::_newDOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);}
//dump_node($node) should only be called on php4DOMDocument //dump_node($node) should only be called on php4DOMDocument
function dump_node($node=null) {return $node==null ? $this->myOwnerDocument->myDOMNode->saveXML($this->myDOMNode) : $this->myOwnerDocument->myDOMNode->saveXML($node->myDOMNode);} function dump_node($node=null) {return $node==null ? $this->myOwnerDocument->myDOMNode->saveXML($this->myDOMNode) : $this->myOwnerDocument->myDOMNode->saveXML($node->myDOMNode);}
function first_child() {return self::_newDOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);} function first_child() {return self::_newDOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);}
function get_content() {return $this->myDOMNode->textContent;} function get_content() {return $this->myDOMNode->textContent;}
function has_attributes() {return $this->myDOMNode->hasAttributes();} function has_attributes() {return $this->myDOMNode->hasAttributes();}
function has_child_nodes() {return $this->myDOMNode->hasChildNodes();} function has_child_nodes() {return $this->myDOMNode->hasChildNodes();}
function insert_before($newnode,$refnode) {return self::_newDOMElement($this->myDOMNode->insertBefore($this->_importNode($newnode),$refnode==null?null:$refnode->myDOMNode),$this->myOwnerDocument);} function insert_before($newnode,$refnode) {return self::_newDOMElement($this->myDOMNode->insertBefore($this->_importNode($newnode),$refnode==null?null:$refnode->myDOMNode),$this->myOwnerDocument);}
function is_blank_node() {return ($this->myDOMNode->nodeType===XML_TEXT_NODE)&&preg_match('%^\s*$%',$this->myDOMNode->nodeValue);} function is_blank_node() {return ($this->myDOMNode->nodeType===XML_TEXT_NODE)&&preg_match('%^\s*$%',$this->myDOMNode->nodeValue);}
function last_child() {return self::_newDOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);} function last_child() {return self::_newDOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
function new_child($name,$content) function new_child($name,$content)
{ {
$mySubNode=$this->myDOMNode->ownerDocument->createElement($name); $mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($content))); $mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($content)));
$this->myDOMNode->appendChild($mySubNode); $this->myDOMNode->appendChild($mySubNode);
return new php4DOMElement($mySubNode,$this->myOwnerDocument); return new php4DOMElement($mySubNode,$this->myOwnerDocument);
} }
function next_sibling() {return self::_newDOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);} function next_sibling() {return self::_newDOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
function node_name() {return ($this->myDOMNode->nodeType===XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->nodeName;} //Avoid namespace prefix for DOMElement function node_name() {return ($this->myDOMNode->nodeType===XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->nodeName;} //Avoid namespace prefix for DOMElement
function node_type() {return $this->myDOMNode->nodeType;} function node_type() {return $this->myDOMNode->nodeType;}
function node_value() {return $this->myDOMNode->nodeValue;} function node_value() {return $this->myDOMNode->nodeValue;}
function owner_document() {return $this->myOwnerDocument;} function owner_document() {return $this->myOwnerDocument;}
function parent_node() {return self::_newDOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);} function parent_node() {return self::_newDOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
function prefix() {return $this->myDOMNode->prefix;} function prefix() {return $this->myDOMNode->prefix;}
function previous_sibling() {return self::_newDOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);} function previous_sibling() {return self::_newDOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);}
function remove_child($oldchild) {return self::_newDOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);} function remove_child($oldchild) {return self::_newDOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);}
function replace_child($newnode,$oldnode) {return self::_newDOMElement($this->myDOMNode->replaceChild($this->_importNode($newnode),$oldnode->myDOMNode),$this->myOwnerDocument);} function replace_child($newnode,$oldnode) {return self::_newDOMElement($this->myDOMNode->replaceChild($this->_importNode($newnode),$oldnode->myDOMNode),$this->myOwnerDocument);}
function replace_node($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->replaceChild($this->_importNode($newnode),$this->myDOMNode),$this->myOwnerDocument);} function replace_node($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->replaceChild($this->_importNode($newnode),$this->myDOMNode),$this->myOwnerDocument);}
function set_content($text) {return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($text)));} //Entity problem reported by AL-DesignWorks 2007-09-07 function set_content($text) {return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($text)));} //Entity problem reported by AL-DesignWorks 2007-09-07
//function set_name($name) {return $this->myOwnerDocument->renameNode($this->myDOMNode,$this->myDOMNode->namespaceURI,$name);} //function set_name($name) {return $this->myOwnerDocument->renameNode($this->myDOMNode,$this->myDOMNode->namespaceURI,$name);}
function set_namespace($uri,$prefix=null) function set_namespace($uri,$prefix=null)
{//Contributions by Daniel Walker 2006-09-08 {//Contributions by Daniel Walker 2006-09-08
$nsprefix=$this->myDOMNode->lookupPrefix($uri); $nsprefix=$this->myDOMNode->lookupPrefix($uri);
if ($nsprefix==null) if ($nsprefix==null)
{ {
$nsprefix= $prefix==null ? $nsprefix='a'.sprintf('%u',crc32($uri)) : $prefix; $nsprefix= $prefix==null ? $nsprefix='a'.sprintf('%u',crc32($uri)) : $prefix;
if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE) if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE)
{ {
if (($prefix!=null)&&$this->myDOMNode->ownerElement->hasAttributeNS('http://www.w3.org/2000/xmlns/',$nsprefix)&& if (($prefix!=null)&&$this->myDOMNode->ownerElement->hasAttributeNS('http://www.w3.org/2000/xmlns/',$nsprefix)&&
($this->myDOMNode->ownerElement->getAttributeNS('http://www.w3.org/2000/xmlns/',$nsprefix)!=$uri)) ($this->myDOMNode->ownerElement->getAttributeNS('http://www.w3.org/2000/xmlns/',$nsprefix)!=$uri))
{//Remove namespace {//Remove namespace
$parent=$this->myDOMNode->ownerElement; $parent=$this->myDOMNode->ownerElement;
$parent->removeAttributeNode($this->myDOMNode); $parent->removeAttributeNode($this->myDOMNode);
$parent->setAttribute($this->myDOMNode->localName,$this->myDOMNode->nodeValue); $parent->setAttribute($this->myDOMNode->localName,$this->myDOMNode->nodeValue);
$this->myDOMNode=$parent->getAttributeNode($this->myDOMNode->localName); $this->myDOMNode=$parent->getAttributeNode($this->myDOMNode->localName);
return; return;
}
$this->myDOMNode->ownerElement->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:'.$nsprefix,$uri);
}
}
if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE)
{
$parent=$this->myDOMNode->ownerElement;
$parent->removeAttributeNode($this->myDOMNode);
$parent->setAttributeNS($uri,$nsprefix.':'.$this->myDOMNode->localName,$this->myDOMNode->nodeValue);
$this->myDOMNode=$parent->getAttributeNodeNS($uri,$this->myDOMNode->localName);
}
elseif ($this->myDOMNode->nodeType===XML_ELEMENT_NODE)
{
$NewNode=$this->myDOMNode->ownerDocument->createElementNS($uri,$nsprefix.':'.$this->myDOMNode->localName);
foreach ($this->myDOMNode->attributes as $n) $NewNode->appendChild($n->cloneNode(true));
foreach ($this->myDOMNode->childNodes as $n) $NewNode->appendChild($n->cloneNode(true));
$xpath=new DOMXPath($this->myDOMNode->ownerDocument);
$myDOMNodeList=$xpath->query('namespace::*[name()!="xml"]',$this->myDOMNode); //Add old namespaces
foreach ($myDOMNodeList as $n) $NewNode->setAttributeNS('http://www.w3.org/2000/xmlns/',$n->nodeName,$n->nodeValue);
$this->myDOMNode->parentNode->replaceChild($NewNode,$this->myDOMNode);
$this->myDOMNode=$NewNode;
}
}
function unlink_node()
{
if ($this->myDOMNode->parentNode!=null)
{
if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE) $this->myDOMNode->parentNode->removeAttributeNode($this->myDOMNode);
else $this->myDOMNode->parentNode->removeChild($this->myDOMNode);
}
}
protected function _importNode($newnode) {return $this->myOwnerDocument===$newnode->myOwnerDocument ? $newnode->myDOMNode : $this->myOwnerDocument->myDOMNode->importNode($newnode->myDOMNode,true);} //To import DOMNode from another DOMDocument
static function _newDOMElement($aDOMNode,$aOwnerDocument)
{//Check the PHP5 DOMNode before creating a new associated PHP4 DOMNode wrapper
if ($aDOMNode==null) return null;
switch ($aDOMNode->nodeType)
{
case XML_ELEMENT_NODE: return new php4DOMElement($aDOMNode,$aOwnerDocument);
case XML_TEXT_NODE: return new php4DOMText($aDOMNode,$aOwnerDocument);
case XML_ATTRIBUTE_NODE: return new php4DOMAttr($aDOMNode,$aOwnerDocument);
case XML_PI_NODE: return new php4DomProcessingInstruction($aDOMNode,$aOwnerDocument);
default: return new php4DOMNode($aDOMNode,$aOwnerDocument);
}
} }
$this->myDOMNode->ownerElement->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:'.$nsprefix,$uri);
}
}
if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE)
{
$parent=$this->myDOMNode->ownerElement;
$parent->removeAttributeNode($this->myDOMNode);
$parent->setAttributeNS($uri,$nsprefix.':'.$this->myDOMNode->localName,$this->myDOMNode->nodeValue);
$this->myDOMNode=$parent->getAttributeNodeNS($uri,$this->myDOMNode->localName);
}
elseif ($this->myDOMNode->nodeType===XML_ELEMENT_NODE)
{
$NewNode=$this->myDOMNode->ownerDocument->createElementNS($uri,$nsprefix.':'.$this->myDOMNode->localName);
foreach ($this->myDOMNode->attributes as $n) $NewNode->appendChild($n->cloneNode(true));
foreach ($this->myDOMNode->childNodes as $n) $NewNode->appendChild($n->cloneNode(true));
$xpath=new DOMXPath($this->myDOMNode->ownerDocument);
$myDOMNodeList=$xpath->query('namespace::*[name()!="xml"]',$this->myDOMNode); //Add old namespaces
foreach ($myDOMNodeList as $n) $NewNode->setAttributeNS('http://www.w3.org/2000/xmlns/',$n->nodeName,$n->nodeValue);
$this->myDOMNode->parentNode->replaceChild($NewNode,$this->myDOMNode);
$this->myDOMNode=$NewNode;
}
}
function unlink_node()
{
if ($this->myDOMNode->parentNode!=null)
{
if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE) $this->myDOMNode->parentNode->removeAttributeNode($this->myDOMNode);
else $this->myDOMNode->parentNode->removeChild($this->myDOMNode);
}
}
protected function _importNode($newnode) {return $this->myOwnerDocument===$newnode->myOwnerDocument ? $newnode->myDOMNode : $this->myOwnerDocument->myDOMNode->importNode($newnode->myDOMNode,true);} //To import DOMNode from another DOMDocument
static function _newDOMElement($aDOMNode,$aOwnerDocument)
{//Check the PHP5 DOMNode before creating a new associated PHP4 DOMNode wrapper
if ($aDOMNode==null) return null;
switch ($aDOMNode->nodeType)
{
case XML_ELEMENT_NODE: return new php4DOMElement($aDOMNode,$aOwnerDocument);
case XML_TEXT_NODE: return new php4DOMText($aDOMNode,$aOwnerDocument);
case XML_ATTRIBUTE_NODE: return new php4DOMAttr($aDOMNode,$aOwnerDocument);
case XML_PI_NODE: return new php4DomProcessingInstruction($aDOMNode,$aOwnerDocument);
default: return new php4DOMNode($aDOMNode,$aOwnerDocument);
}
}
} }
class php4DomProcessingInstruction extends php4DOMNode class php4DomProcessingInstruction extends php4DOMNode
{ {
function data() {return $this->myDOMNode->data;} function data() {return $this->myDOMNode->data;}
function target() {return $this->myDOMNode->target;} function target() {return $this->myDOMNode->target;}
} }
class php4DOMText extends php4DOMNode class php4DOMText extends php4DOMNode
{ {
function __get($name) function __get($name)
{ {
if ($name==='tagname') return '#text'; if ($name==='tagname') return '#text';
else return parent::__get($name); else return parent::__get($name);
} }
function tagname() {return '#text';} function tagname() {return '#text';}
function set_content($text) {$this->myDOMNode->nodeValue=$text; return true;} function set_content($text) {$this->myDOMNode->nodeValue=$text; return true;}
} }
if (!defined('XPATH_NODESET')) if (!defined('XPATH_NODESET'))
{ {
define('XPATH_UNDEFINED',0); define('XPATH_UNDEFINED',0);
define('XPATH_NODESET',1); define('XPATH_NODESET',1);
define('XPATH_BOOLEAN',2); define('XPATH_BOOLEAN',2);
define('XPATH_NUMBER',3); define('XPATH_NUMBER',3);
define('XPATH_STRING',4); define('XPATH_STRING',4);
/*define('XPATH_POINT',5); /*define('XPATH_POINT',5);
define('XPATH_RANGE',6); define('XPATH_RANGE',6);
define('XPATH_LOCATIONSET',7); define('XPATH_LOCATIONSET',7);
define('XPATH_USERS',8); define('XPATH_USERS',8);
define('XPATH_XSLT_TREE',9);*/ define('XPATH_XSLT_TREE',9);*/
} }
class php4DOMNodelist class php4DOMNodelist
{ {
private $myDOMNodelist; private $myDOMNodelist;
public $nodeset; public $nodeset;
public $type; public $type;
public $value; public $value;
function php4DOMNodelist($aDOMNodelist,$aOwnerDocument) function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
{
if (is_object($aDOMNodelist)||is_array($aDOMNodelist))
{
$this->myDOMNodelist=$aDOMNodelist;
$this->nodeset=array();
if (isset($this->myDOMNodelist))
{ {
$this->type=XPATH_NODESET; if (is_object($aDOMNodelist)||is_array($aDOMNodelist))
$i=0; {
while ($node=$this->myDOMNodelist->item($i++)) $this->nodeset[]=php4DOMNode::_newDOMElement($node,$aOwnerDocument); $this->myDOMNodelist=$aDOMNodelist;
$this->nodeset=array();
if (isset($this->myDOMNodelist))
{
$this->type=XPATH_NODESET;
$i=0;
while ($node=$this->myDOMNodelist->item($i++)) $this->nodeset[]=php4DOMNode::_newDOMElement($node,$aOwnerDocument);
}
else $this->type=XPATH_UNDEFINED;
}
elseif (is_int($aDOMNodelist)||is_float($aDOMNodelist))
{
$this->type=XPATH_NUMBER;
$this->value=$aDOMNodelist;
}
elseif (is_bool($aDOMNodelist))
{
$this->type=XPATH_BOOLEAN;
$this->value=$aDOMNodelist;
}
elseif (is_string($aDOMNodelist))
{
$this->type=XPATH_STRING;
$this->value=$aDOMNodelist;
}
else $this->type=XPATH_UNDEFINED;
} }
else $this->type=XPATH_UNDEFINED;
}
elseif (is_int($aDOMNodelist)||is_float($aDOMNodelist))
{
$this->type=XPATH_NUMBER;
$this->value=$aDOMNodelist;
}
elseif (is_bool($aDOMNodelist))
{
$this->type=XPATH_BOOLEAN;
$this->value=$aDOMNodelist;
}
elseif (is_string($aDOMNodelist))
{
$this->type=XPATH_STRING;
$this->value=$aDOMNodelist;
}
else $this->type=XPATH_UNDEFINED;
}
} }
class php4DOMXPath class php4DOMXPath
{ {
public $myDOMXPath; public $myDOMXPath;
private $myOwnerDocument; private $myOwnerDocument;
function php4DOMXPath($dom_document) function php4DOMXPath($dom_document)
{ {
//TODO: If $dom_document is a DomElement, make that default $contextnode and modify XPath. Ex: '/test' //TODO: If $dom_document is a DomElement, make that default $contextnode and modify XPath. Ex: '/test'
$this->myOwnerDocument=$dom_document->myOwnerDocument; $this->myOwnerDocument=$dom_document->myOwnerDocument;
$this->myDOMXPath=new DOMXPath($this->myOwnerDocument->myDOMNode); $this->myDOMXPath=new DOMXPath($this->myOwnerDocument->myDOMNode);
} }
function xpath_eval($eval_str,$contextnode=null) function xpath_eval($eval_str,$contextnode=null)
{ {
if (method_exists($this->myDOMXPath,'evaluate')) if (method_exists($this->myDOMXPath,'evaluate'))
return isset($contextnode) ? new php4DOMNodelist($this->myDOMXPath->evaluate($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument) : new php4DOMNodelist($this->myDOMXPath->evaluate($eval_str),$this->myOwnerDocument); return isset($contextnode) ? new php4DOMNodelist($this->myDOMXPath->evaluate($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument) : new php4DOMNodelist($this->myDOMXPath->evaluate($eval_str),$this->myOwnerDocument);
else return isset($contextnode) ? new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument) : new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument); else return isset($contextnode) ? new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument) : new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument);
} }
function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);} function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
} }
if (extension_loaded('xsl')) if (extension_loaded('xsl'))
{//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/ {//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));} function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));}
function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);} function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));} function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
class php4DomXsltStylesheet class php4DomXsltStylesheet
{ {
private $myxsltProcessor; private $myxsltProcessor;
function php4DomXsltStylesheet($dom_document) function php4DomXsltStylesheet($dom_document)
{ {
$this->myxsltProcessor=new xsltProcessor(); $this->myxsltProcessor=new xsltProcessor();
$this->myxsltProcessor->importStyleSheet($dom_document); $this->myxsltProcessor->importStyleSheet($dom_document);
} }
function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false) function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
{ {
foreach ($xslt_parameters as $param=>$value) $this->myxsltProcessor->setParameter('',$param,$value); foreach ($xslt_parameters as $param=>$value) $this->myxsltProcessor->setParameter('',$param,$value);
$myphp4DOMDocument=new php4DOMDocument(); $myphp4DOMDocument=new php4DOMDocument();
$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode); $myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
return $myphp4DOMDocument; return $myphp4DOMDocument;
} }
function result_dump_file($dom_document,$filename) function result_dump_file($dom_document,$filename)
{ {
$html=$dom_document->myDOMNode->saveHTML(); $html=$dom_document->myDOMNode->saveHTML();
file_put_contents($filename,$html); file_put_contents($filename,$html);
return $html; return $html;
} }
function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();} function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
} }
} }
?> ?>

View File

@@ -0,0 +1,54 @@
<?php
final class SettingsStorage extends ArrayObject
{
protected static $_instance = null;
public function __construct($array = array(), $flags = parent::ARRAY_AS_PROPS)
{
parent::__construct($array, $flags);
}
public static function getInstance()
{
if( self::$_instance === NULL ) {
self::$_instance = new self();
}
return self::$_instance;
}
public static function get($index)
{
$instance = self::getInstance();
if (!$instance->offsetExists($index)) {
throw new Exception("No entry is registered for key '$index'");
}
return $instance->offsetGet($index);
}
public static function set($index, $value)
{
$instance = self::getInstance();
$instance->offsetSet($index, $value);
}
public static function isRegistered($index)
{
if (self::$_instance === null) {
return false;
}
return self::$_instance->offsetExists($index);
}
/**
* Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).
*/
public function offsetExists($index)
{
return array_key_exists($index, $this);
}
}
?>

View File

@@ -9,7 +9,7 @@
* *
* ? Copyright 2005 Developer's Network. All rights reserved. * ? Copyright 2005 Developer's Network. All rights reserved.
* This is licensed under the Lesser General Public License (LGPL) * This is licensed under the Lesser General Public License (LGPL)
* *
* Thanks to CertainKey Inc. for providing some example outputs in Javascript * Thanks to CertainKey Inc. for providing some example outputs in Javascript
* *
*----- Version 1.0.1 ---------------------------------------------------------- *----- Version 1.0.1 ----------------------------------------------------------
@@ -34,47 +34,47 @@
// hashing class state and storage object. Abstract base class only. // hashing class state and storage object. Abstract base class only.
class hashData class hashData
{ {
// final hash // final hash
var $hash = null; var $hash = null;
} }
// hashing class. Abstract base class only. // hashing class. Abstract base class only.
class hash class hash
{ {
// The base modes are: // The base modes are:
// 'bin' - binary output (most compact) // 'bin' - binary output (most compact)
// 'bit' - bit output (largest) // 'bit' - bit output (largest)
// 'oct' - octal output (medium-large) // 'oct' - octal output (medium-large)
// 'hex' - hexidecimal (default, medium) // 'hex' - hexidecimal (default, medium)
// perform a hash on a string // perform a hash on a string
function hash($str, $mode = 'hex') function hash($str, $mode = 'hex')
{ {
trigger_error('hash::hash() NOT IMPLEMENTED', E_USER_WARNING); trigger_error('hash::hash() NOT IMPLEMENTED', E_USER_WARNING);
return false; return false;
} }
// chop the resultant hash into $length byte chunks // chop the resultant hash into $length byte chunks
function hashChunk($str, $length, $mode = 'hex') function hashChunk($str, $length, $mode = 'hex')
{ {
trigger_error('hash::hashChunk() NOT IMPLEMENTED', E_USER_WARNING); trigger_error('hash::hashChunk() NOT IMPLEMENTED', E_USER_WARNING);
return false; return false;
} }
// perform a hash on a file
function hashFile($filename, $mode = 'hex')
{
trigger_error('hash::hashFile() NOT IMPLEMENTED', E_USER_WARNING);
return false;
}
// chop the resultant hash into $length byte chunks // perform a hash on a file
function hashChunkFile($filename, $length, $mode = 'hex') function hashFile($filename, $mode = 'hex')
{ {
trigger_error('hash::hashChunkFile() NOT IMPLEMENTED', E_USER_WARNING); trigger_error('hash::hashFile() NOT IMPLEMENTED', E_USER_WARNING);
return false; return false;
} }
// chop the resultant hash into $length byte chunks
function hashChunkFile($filename, $length, $mode = 'hex')
{
trigger_error('hash::hashChunkFile() NOT IMPLEMENTED', E_USER_WARNING);
return false;
}
} }
@@ -83,244 +83,244 @@ class hash
class SHA256Data extends hashData class SHA256Data extends hashData
{ {
// buffer // buffer
var $buf = array(); var $buf = array();
// padded data // padded data
var $chunks = null; var $chunks = null;
function SHA256Data($str) function SHA256Data($str)
{ {
$M = strlen($str); // number of bytes $M = strlen($str); // number of bytes
$L1 = ($M >> 28) & 0x0000000F; // top order bits $L1 = ($M >> 28) & 0x0000000F; // top order bits
$L2 = $M << 3; // number of bits $L2 = $M << 3; // number of bits
$l = pack('N*', $L1, $L2); $l = pack('N*', $L1, $L2);
// 64 = 64 bits needed for the size mark. 1 = the 1 bit added to the // 64 = 64 bits needed for the size mark. 1 = the 1 bit added to the
// end. 511 = 511 bits to get the number to be at least large enough // end. 511 = 511 bits to get the number to be at least large enough
// to require one block. 512 is the block size. // to require one block. 512 is the block size.
$k = $L2 + 64 + 1 + 511; $k = $L2 + 64 + 1 + 511;
$k -= $k % 512 + $L2 + 64 + 1; $k -= $k % 512 + $L2 + 64 + 1;
$k >>= 3; // convert to byte count $k >>= 3; // convert to byte count
$str .= chr(0x80) . str_repeat(chr(0), $k) . $l; $str .= chr(0x80) . str_repeat(chr(0), $k) . $l;
assert('strlen($str) % 64 == 0'); assert('strlen($str) % 64 == 0');
// break the binary string into 512-bit blocks // break the binary string into 512-bit blocks
preg_match_all( '#.{64}#', $str, $this->chunks ); preg_match_all( '#.{64}#', $str, $this->chunks );
$this->chunks = $this->chunks[0]; $this->chunks = $this->chunks[0];
// H(0) // H(0)
/* /*
$this->hash = array $this->hash = array
( (
(int)0x6A09E667, (int)0xBB67AE85, (int)0x6A09E667, (int)0xBB67AE85,
(int)0x3C6EF372, (int)0xA54FF53A, (int)0x3C6EF372, (int)0xA54FF53A,
(int)0x510E527F, (int)0x9B05688C, (int)0x510E527F, (int)0x9B05688C,
(int)0x1F83D9AB, (int)0x5BE0CD19, (int)0x1F83D9AB, (int)0x5BE0CD19,
); );
*/ */
$this->hash = array $this->hash = array
( (
1779033703, -1150833019, 1779033703, -1150833019,
1013904242, -1521486534, 1013904242, -1521486534,
1359893119, -1694144372, 1359893119, -1694144372,
528734635, 1541459225, 528734635, 1541459225,
); );
} }
} }
// static class. Access via SHA256::hash() // static class. Access via SHA256::hash()
class SHA256 extends hash class SHA256 extends hash
{ {
static function hashing($str, $mode = 'hex') static function hashing($str, $mode = 'hex')
{
static $modes = array( 'hex', 'bin', 'bit' );
$ret = false;
if(!in_array(strtolower($mode), $modes))
{ {
static $modes = array( 'hex', 'bin', 'bit' ); trigger_error('mode specified is unrecognized: ' . $mode, E_USER_WARNING);
$ret = false; }
else
if(!in_array(strtolower($mode), $modes)) {
$data = new SHA256Data($str);
SHA256::compute($data);
$func = array('SHA256', 'hash' . $mode);
if(is_callable($func))
{
$func = 'hash' . $mode;
$ret = SHA256::$func($data);
//$ret = call_user_func($func, $data);
}
else
{
trigger_error('SHA256::hash' . $mode . '() NOT IMPLEMENTED.', E_USER_WARNING);
}
}
return $ret;
}
// ------------
// begin internal functions
// 32-bit summation
static function sum()
{
$T = 0;
for($x = 0, $y = func_num_args(); $x < $y; $x++)
{
// argument
$a = func_get_arg($x);
// carry storage
$c = 0;
for($i = 0; $i < 32; $i++)
{
// sum of the bits at $i
$j = (($T >> $i) & 1) + (($a >> $i) & 1) + $c;
// carry of the bits at $i
$c = ($j >> 1) & 1;
// strip the carry
$j &= 1;
// clear the bit
$T &= ~(1 << $i);
// set the bit
$T |= $j << $i;
}
}
return $T;
}
// compute the hash
static function compute(&$hashData)
{
static $vars = 'abcdefgh';
static $K = null;
if($K === null)
{
/*
$K = array(
(int)0x428A2F98, (int)0x71374491, (int)0xB5C0FBCF, (int)0xE9B5DBA5,
(int)0x3956C25B, (int)0x59F111F1, (int)0x923F82A4, (int)0xAB1C5ED5,
(int)0xD807AA98, (int)0x12835B01, (int)0x243185BE, (int)0x550C7DC3,
(int)0x72BE5D74, (int)0x80DEB1FE, (int)0x9BDC06A7, (int)0xC19BF174,
(int)0xE49B69C1, (int)0xEFBE4786, (int)0x0FC19DC6, (int)0x240CA1CC,
(int)0x2DE92C6F, (int)0x4A7484AA, (int)0x5CB0A9DC, (int)0x76F988DA,
(int)0x983E5152, (int)0xA831C66D, (int)0xB00327C8, (int)0xBF597FC7,
(int)0xC6E00BF3, (int)0xD5A79147, (int)0x06CA6351, (int)0x14292967,
(int)0x27B70A85, (int)0x2E1B2138, (int)0x4D2C6DFC, (int)0x53380D13,
(int)0x650A7354, (int)0x766A0ABB, (int)0x81C2C92E, (int)0x92722C85,
(int)0xA2BFE8A1, (int)0xA81A664B, (int)0xC24B8B70, (int)0xC76C51A3,
(int)0xD192E819, (int)0xD6990624, (int)0xF40E3585, (int)0x106AA070,
(int)0x19A4C116, (int)0x1E376C08, (int)0x2748774C, (int)0x34B0BCB5,
(int)0x391C0CB3, (int)0x4ED8AA4A, (int)0x5B9CCA4F, (int)0x682E6FF3,
(int)0x748F82EE, (int)0x78A5636F, (int)0x84C87814, (int)0x8CC70208,
(int)0x90BEFFFA, (int)0xA4506CEB, (int)0xBEF9A3F7, (int)0xC67178F2
);
*/
$K = array (
1116352408, 1899447441, -1245643825, -373957723,
961987163, 1508970993, -1841331548, -1424204075,
-670586216, 310598401, 607225278, 1426881987,
1925078388, -2132889090, -1680079193, -1046744716,
-459576895, -272742522, 264347078, 604807628,
770255983, 1249150122, 1555081692, 1996064986,
-1740746414, -1473132947, -1341970488, -1084653625,
-958395405, -710438585, 113926993, 338241895,
666307205, 773529912, 1294757372, 1396182291,
1695183700, 1986661051, -2117940946, -1838011259,
-1564481375, -1474664885, -1035236496, -949202525,
-778901479, -694614492, -200395387, 275423344,
430227734, 506948616, 659060556, 883997877,
958139571, 1322822218, 1537002063, 1747873779,
1955562222, 2024104815, -2067236844, -1933114872,
-1866530822, -1538233109, -1090935817, -965641998,
);
}
$W = array();
for($i = 0, $numChunks = sizeof($hashData->chunks); $i < $numChunks; $i++)
{
// initialize the registers
for($j = 0; $j < 8; $j++)
${$vars{$j}} = $hashData->hash[$j];
// the SHA-256 compression function
for($j = 0; $j < 64; $j++)
{
if($j < 16)
{ {
trigger_error('mode specified is unrecognized: ' . $mode, E_USER_WARNING); $T1 = ord($hashData->chunks[$i]{$j*4 }) & 0xFF; $T1 <<= 8;
$T1 |= ord($hashData->chunks[$i]{$j*4+1}) & 0xFF; $T1 <<= 8;
$T1 |= ord($hashData->chunks[$i]{$j*4+2}) & 0xFF; $T1 <<= 8;
$T1 |= ord($hashData->chunks[$i]{$j*4+3}) & 0xFF;
$W[$j] = $T1;
} }
else else
{ {
$data = new SHA256Data($str); $W[$j] = SHA256::sum(((($W[$j-2] >> 17) & 0x00007FFF) | ($W[$j-2] << 15)) ^ ((($W[$j-2] >> 19) & 0x00001FFF) | ($W[$j-2] << 13)) ^ (($W[$j-2] >> 10) & 0x003FFFFF), $W[$j-7], ((($W[$j-15] >> 7) & 0x01FFFFFF) | ($W[$j-15] << 25)) ^ ((($W[$j-15] >> 18) & 0x00003FFF) | ($W[$j-15] << 14)) ^ (($W[$j-15] >> 3) & 0x1FFFFFFF), $W[$j-16]);
}
SHA256::compute($data); $T1 = SHA256::sum($h, ((($e >> 6) & 0x03FFFFFF) | ($e << 26)) ^ ((($e >> 11) & 0x001FFFFF) | ($e << 21)) ^ ((($e >> 25) & 0x0000007F) | ($e << 7)), ($e & $f) ^ (~$e & $g), $K[$j], $W[$j]);
$T2 = SHA256::sum(((($a >> 2) & 0x3FFFFFFF) | ($a << 30)) ^ ((($a >> 13) & 0x0007FFFF) | ($a << 19)) ^ ((($a >> 22) & 0x000003FF) | ($a << 10)), ($a & $b) ^ ($a & $c) ^ ($b & $c));
$h = $g;
$g = $f;
$f = $e;
$e = SHA256::sum($d, $T1);
$d = $c;
$c = $b;
$b = $a;
$a = SHA256::sum($T1, $T2);
}
$func = array('SHA256', 'hash' . $mode); // compute the next hash set
if(is_callable($func)) for($j = 0; $j < 8; $j++)
{ $hashData->hash[$j] = SHA256::sum(${$vars{$j}}, $hashData->hash[$j]);
$func = 'hash' . $mode;
$ret = SHA256::$func($data);
//$ret = call_user_func($func, $data);
}
else
{
trigger_error('SHA256::hash' . $mode . '() NOT IMPLEMENTED.', E_USER_WARNING);
}
}
return $ret;
} }
}
// ------------
// begin internal functions
// 32-bit summation
static function sum()
{
$T = 0;
for($x = 0, $y = func_num_args(); $x < $y; $x++)
{
// argument
$a = func_get_arg($x);
// carry storage
$c = 0;
for($i = 0; $i < 32; $i++)
{
// sum of the bits at $i
$j = (($T >> $i) & 1) + (($a >> $i) & 1) + $c;
// carry of the bits at $i
$c = ($j >> 1) & 1;
// strip the carry
$j &= 1;
// clear the bit
$T &= ~(1 << $i);
// set the bit
$T |= $j << $i;
}
}
return $T;
}
// compute the hash
static function compute(&$hashData)
{
static $vars = 'abcdefgh';
static $K = null;
if($K === null)
{
/*
$K = array(
(int)0x428A2F98, (int)0x71374491, (int)0xB5C0FBCF, (int)0xE9B5DBA5,
(int)0x3956C25B, (int)0x59F111F1, (int)0x923F82A4, (int)0xAB1C5ED5,
(int)0xD807AA98, (int)0x12835B01, (int)0x243185BE, (int)0x550C7DC3,
(int)0x72BE5D74, (int)0x80DEB1FE, (int)0x9BDC06A7, (int)0xC19BF174,
(int)0xE49B69C1, (int)0xEFBE4786, (int)0x0FC19DC6, (int)0x240CA1CC,
(int)0x2DE92C6F, (int)0x4A7484AA, (int)0x5CB0A9DC, (int)0x76F988DA,
(int)0x983E5152, (int)0xA831C66D, (int)0xB00327C8, (int)0xBF597FC7,
(int)0xC6E00BF3, (int)0xD5A79147, (int)0x06CA6351, (int)0x14292967,
(int)0x27B70A85, (int)0x2E1B2138, (int)0x4D2C6DFC, (int)0x53380D13,
(int)0x650A7354, (int)0x766A0ABB, (int)0x81C2C92E, (int)0x92722C85,
(int)0xA2BFE8A1, (int)0xA81A664B, (int)0xC24B8B70, (int)0xC76C51A3,
(int)0xD192E819, (int)0xD6990624, (int)0xF40E3585, (int)0x106AA070,
(int)0x19A4C116, (int)0x1E376C08, (int)0x2748774C, (int)0x34B0BCB5,
(int)0x391C0CB3, (int)0x4ED8AA4A, (int)0x5B9CCA4F, (int)0x682E6FF3,
(int)0x748F82EE, (int)0x78A5636F, (int)0x84C87814, (int)0x8CC70208,
(int)0x90BEFFFA, (int)0xA4506CEB, (int)0xBEF9A3F7, (int)0xC67178F2
);
*/
$K = array (
1116352408, 1899447441, -1245643825, -373957723,
961987163, 1508970993, -1841331548, -1424204075,
-670586216, 310598401, 607225278, 1426881987,
1925078388, -2132889090, -1680079193, -1046744716,
-459576895, -272742522, 264347078, 604807628,
770255983, 1249150122, 1555081692, 1996064986,
-1740746414, -1473132947, -1341970488, -1084653625,
-958395405, -710438585, 113926993, 338241895,
666307205, 773529912, 1294757372, 1396182291,
1695183700, 1986661051, -2117940946, -1838011259,
-1564481375, -1474664885, -1035236496, -949202525,
-778901479, -694614492, -200395387, 275423344,
430227734, 506948616, 659060556, 883997877,
958139571, 1322822218, 1537002063, 1747873779,
1955562222, 2024104815, -2067236844, -1933114872,
-1866530822, -1538233109, -1090935817, -965641998,
);
}
$W = array();
for($i = 0, $numChunks = sizeof($hashData->chunks); $i < $numChunks; $i++)
{
// initialize the registers
for($j = 0; $j < 8; $j++)
${$vars{$j}} = $hashData->hash[$j];
// the SHA-256 compression function
for($j = 0; $j < 64; $j++)
{
if($j < 16)
{
$T1 = ord($hashData->chunks[$i]{$j*4 }) & 0xFF; $T1 <<= 8;
$T1 |= ord($hashData->chunks[$i]{$j*4+1}) & 0xFF; $T1 <<= 8;
$T1 |= ord($hashData->chunks[$i]{$j*4+2}) & 0xFF; $T1 <<= 8;
$T1 |= ord($hashData->chunks[$i]{$j*4+3}) & 0xFF;
$W[$j] = $T1;
}
else
{
$W[$j] = SHA256::sum(((($W[$j-2] >> 17) & 0x00007FFF) | ($W[$j-2] << 15)) ^ ((($W[$j-2] >> 19) & 0x00001FFF) | ($W[$j-2] << 13)) ^ (($W[$j-2] >> 10) & 0x003FFFFF), $W[$j-7], ((($W[$j-15] >> 7) & 0x01FFFFFF) | ($W[$j-15] << 25)) ^ ((($W[$j-15] >> 18) & 0x00003FFF) | ($W[$j-15] << 14)) ^ (($W[$j-15] >> 3) & 0x1FFFFFFF), $W[$j-16]);
}
$T1 = SHA256::sum($h, ((($e >> 6) & 0x03FFFFFF) | ($e << 26)) ^ ((($e >> 11) & 0x001FFFFF) | ($e << 21)) ^ ((($e >> 25) & 0x0000007F) | ($e << 7)), ($e & $f) ^ (~$e & $g), $K[$j], $W[$j]);
$T2 = SHA256::sum(((($a >> 2) & 0x3FFFFFFF) | ($a << 30)) ^ ((($a >> 13) & 0x0007FFFF) | ($a << 19)) ^ ((($a >> 22) & 0x000003FF) | ($a << 10)), ($a & $b) ^ ($a & $c) ^ ($b & $c)); // set up the display of the hash in hex.
$h = $g; static function hashHex(&$hashData)
$g = $f; {
$f = $e; $str = '';
$e = SHA256::sum($d, $T1);
$d = $c; reset($hashData->hash);
$c = $b; do
$b = $a;
$a = SHA256::sum($T1, $T2);
}
// compute the next hash set
for($j = 0; $j < 8; $j++)
$hashData->hash[$j] = SHA256::sum(${$vars{$j}}, $hashData->hash[$j]);
}
}
// set up the display of the hash in hex.
static function hashHex(&$hashData)
{ {
$str = ''; $str .= sprintf('%08x', current($hashData->hash));
reset($hashData->hash);
do
{
$str .= sprintf('%08x', current($hashData->hash));
}
while(next($hashData->hash));
return $str;
} }
while(next($hashData->hash));
// set up the output of the hash in binary return $str;
function hashBin(&$hashData) }
// set up the output of the hash in binary
function hashBin(&$hashData)
{
$str = '';
reset($hashData->hash);
do
{ {
$str = ''; $str .= pack('N', current($hashData->hash));
reset($hashData->hash);
do
{
$str .= pack('N', current($hashData->hash));
}
while(next($hashData->hash));
return $str;
} }
while(next($hashData->hash));
return $str;
}
} }
@@ -331,42 +331,42 @@ class SHA256 extends hash
// format a string into 4 byte hex chunks // format a string into 4 byte hex chunks
function hexerize($str) function hexerize($str)
{ {
$n = 0; $n = 0;
$b = 0; $b = 0;
if(is_array($str)) if(is_array($str))
{
reset($str);
$o = 'array(' . sizeof($str) . ')::' . "\n\n";
while($s = current($str))
{ {
reset($str); $o .= hexerize($s);
$o = 'array(' . sizeof($str) . ')::' . "\n\n"; next($str);
while($s = current($str))
{
$o .= hexerize($s);
next($str);
}
$o .= 'end array;'."\n";
} }
else $o .= 'end array;'."\n";
}
else
{
if(is_integer($str) || is_float($str))
$str = pack('N',$str);
$o = 'string(' . strlen($str) . ')' . "::\n";
for($i = 0, $j = strlen($str); $i < $j; $i++, $b = $i % 4)
{ {
if(is_integer($str) || is_float($str)) $o .= sprintf('%02X', ord($str{$i}));
$str = pack('N',$str); // only process when 32-bits have passed through
$o = 'string(' . strlen($str) . ')' . "::\n"; if($i != 0 && $b == 3)
for($i = 0, $j = strlen($str); $i < $j; $i++, $b = $i % 4) {
{ // process new line points
$o .= sprintf('%02X', ord($str{$i})); if($n == 3)
// only process when 32-bits have passed through $o .= "\n";
if($i != 0 && $b == 3) else
{ $o .= ' ';
// process new line points ++$n;
if($n == 3) $n %= 4;
$o .= "\n"; }
else
$o .= ' ';
++$n;
$n %= 4;
}
}
} }
}
return $o . "\n";
return $o . "\n";
} }
@@ -374,69 +374,69 @@ function hexerize($str)
function test1() function test1()
{ {
$it = 1; $it = 1;
echo '<pre>';
$test = array('abc','abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'); echo '<pre>';
foreach($test as $str)
{
echo 'Testing ' . var_export($str,true) . "\n";
list($s1,$s2) = explode(' ', microtime());
for($x = 0; $x < $it; $x++)
$data = new SHA256Data($str);
list($e1,$e2) = explode(' ', microtime());
echo hexerize($data->chunks);
echo hexerize($data->hash);
echo 'processing took ' . (($e2 - $s2 + $e1 - $s1) / $it) . ' seconds.' . "\n\n\n";
}
echo '</pre>'; $test = array('abc','abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq');
foreach($test as $str)
{
echo 'Testing ' . var_export($str,true) . "\n";
list($s1,$s2) = explode(' ', microtime());
for($x = 0; $x < $it; $x++)
$data = new SHA256Data($str);
list($e1,$e2) = explode(' ', microtime());
echo hexerize($data->chunks);
echo hexerize($data->hash);
echo 'processing took ' . (($e2 - $s2 + $e1 - $s1) / $it) . ' seconds.' . "\n\n\n";
}
echo '</pre>';
} }
function test2() function test2()
{ {
$it = 1; $it = 1;
echo '<pre>'; echo '<pre>';
$test = array('abc','abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'); $test = array('abc','abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq');
foreach($test as $str) foreach($test as $str)
{ {
echo 'Testing ' . var_export($str,true) . "\n"; echo 'Testing ' . var_export($str,true) . "\n";
list($s1,$s2) = explode(' ', microtime()); list($s1,$s2) = explode(' ', microtime());
for($x = 0; $x < $it; $x++) for($x = 0; $x < $it; $x++)
$o = SHA256::hash($str); $o = SHA256::hash($str);
list($e1,$e2) = explode(' ', microtime()); list($e1,$e2) = explode(' ', microtime());
echo $o; echo $o;
echo 'processing took ' . (($e2 - $s2 + $e1 - $s1) / $it) . ' seconds.' . "\n\n\n"; echo 'processing took ' . (($e2 - $s2 + $e1 - $s1) / $it) . ' seconds.' . "\n\n\n";
} }
echo '</pre>'; echo '</pre>';
} }
function testSum() function testSum()
{ {
echo '<pre>'; echo '<pre>';
echo SHA256::sum(1,2,3,4,5,6,7,8,9,10); echo SHA256::sum(1,2,3,4,5,6,7,8,9,10);
echo '</pre>'; echo '</pre>';
} }
function testSpeedHash($it = 10) function testSpeedHash($it = 10)
{ {
$it = intval($it); $it = intval($it);
if($it === 0) if($it === 0)
$it = 10; $it = 10;
set_time_limit(-1); set_time_limit(-1);
echo '<pre>' . "\n"; echo '<pre>' . "\n";
$test = array( $test = array(
''=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', ''=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
'abc'=>'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', 'abc'=>'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad',
'message digest'=>'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650', 'message digest'=>'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650',
@@ -445,33 +445,33 @@ function testSpeedHash($it = 10)
'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'=>'248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1', 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'=>'248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1',
'For this sample, this 63-byte string will be used as input data'=>'f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342', 'For this sample, this 63-byte string will be used as input data'=>'f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342',
'This is exactly 64 bytes long, not counting the terminating byte'=>'ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8', 'This is exactly 64 bytes long, not counting the terminating byte'=>'ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8',
); );
foreach($test as $str => $hash) foreach($test as $str => $hash)
{
echo 'Testing ' . var_export($str,true) . "\n";
echo 'Start time: ' . date('Y-m-d H:i:s') . "\n";
if($it > 1)
{ {
echo 'Testing ' . var_export($str,true) . "\n"; list($s1,$s2) = explode(' ', microtime());
echo 'Start time: ' . date('Y-m-d H:i:s') . "\n"; $o = SHA256::hash($str);
if($it > 1) list($e1,$e2) = explode(' ', microtime());
{ echo 'estimated time to perform test: ' . (($e2 - $s2 + $e1 - $s1) * $it) . ' seconds for ' . $it . ' iterations.' . "\n";
list($s1,$s2) = explode(' ', microtime());
$o = SHA256::hash($str);
list($e1,$e2) = explode(' ', microtime());
echo 'estimated time to perform test: ' . (($e2 - $s2 + $e1 - $s1) * $it) . ' seconds for ' . $it . ' iterations.' . "\n";
}
$t = 0;
for($x = 0; $x < $it; $x++)
{
list($s1,$s2) = explode(' ', microtime());
$o = SHA256::hash($str);
list($e1,$e2) = explode(' ', microtime());
$t += $e2 - $s2 + $e1 - $s1;
}
echo var_export($o,true) . ' == ' . var_export($hash,true) . ' ' . (strcasecmp($o,$hash)==0 ? 'PASSED' : 'FAILED') . "\n";
echo 'processing took ' . ($t / $it) . ' seconds.' . "\n\n\n";
} }
echo '</pre>'; $t = 0;
for($x = 0; $x < $it; $x++)
{
list($s1,$s2) = explode(' ', microtime());
$o = SHA256::hash($str);
list($e1,$e2) = explode(' ', microtime());
$t += $e2 - $s2 + $e1 - $s1;
}
echo var_export($o,true) . ' == ' . var_export($hash,true) . ' ' . (strcasecmp($o,$hash)==0 ? 'PASSED' : 'FAILED') . "\n";
echo 'processing took ' . ($t / $it) . ' seconds.' . "\n\n\n";
}
echo '</pre>';
} }
//testSpeedHash(1); //testSpeedHash(1);

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,325 @@
<?php
/**
* GTranslate - A class to comunicate with Google Translate(TM) Service
* Google Translate(TM) API Wrapper
* More info about Google(TM) service can be found on http://code.google.com/apis/ajaxlanguage/documentation/reference.html
* This code has o affiliation with Google (TM) , its a PHP Library that allows to comunicate with public a API
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Jose da Silva <jose@josedasilva.net>
* @since 2009/11/18
* @version 0.7.4
* @licence LGPL v3
*
* <code>
* <?
* require_once("GTranslate.php");
* try{
* $gt = new Gtranslate;
* echo $gt->english_to_german("hello world");
* } catch (GTranslateException $ge)
* {
* echo $ge->getMessage();
* }
* ?>
* </code>
*/
/**
* Exception class for GTranslated Exceptions
*/
class GTranslateException extends Exception
{
public function __construct($string) {
parent::__construct($string, 0);
}
public function __toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}
class GTranslate
{
/**
* Google Translate(TM) Api endpoint
* @access private
* @var String
*/
private $url = "http://ajax.googleapis.com/ajax/services/language/translate";
/**
* Google Translate (TM) Api Version
* @access private
* @var String
*/
private $api_version = "1.0";
/**
* Comunication Transport Method
* Available: http / curl
* @access private
* @var String
*/
private $request_type = "http";
/**
* Path to available languages file
* @access private
* @var String
*/
private $available_languages_file = "languages.ini";
/**
* Holder to the parse of the ini file
* @access private
* @var Array
*/
private $available_languages = array();
/**
* Google Translate api key
* @access private
* @var string
*/
private $api_key = null;
/**
* Google request User IP
* @access private
* @var string
*/
private $user_ip = null;
/**
* Constructor sets up {@link $available_languages}
*/
public function __construct()
{
$this->available_languages = parse_ini_file("languages.ini");
}
/**
* URL Formater to use on request
* @access private
* @param array $lang_pair
* @param array $string
* "returns String $url
*/
private function urlFormat($lang_pair,$string)
{
$parameters = array(
"v" => $this->api_version,
"q" => $string,
"langpair"=> implode("|",$lang_pair)
);
if(!empty($this->api_key))
{
$parameters["key"] = $this->api_key;
}
if( empty($this->user_ip) )
{
if( !empty($_SERVER["REMOTE_ADDR"]) )
{
$parameters["userip"] = $_SERVER["REMOTE_ADDR"];
}
} else
{
$parameters["userip"] = $this->user_ip;
}
$url = "";
foreach($parameters as $k=>$p)
{
$url .= $k."=".urlencode($p)."&";
}
return $url;
}
/**
* Define the request type
* @access public
* @param string $request_type
* return boolean
*/
public function setRequestType($request_type = 'http') {
if (!empty($request_type)) {
$this->request_type = $request_type;
return true;
}
return false;
}
/**
* Define the Google Translate Api Key
* @access public
* @param string $api_key
* return boolean
*/
public function setApiKey($api_key) {
if (!empty($api_key)) {
$this->api_key = $api_key;
return true;
}
return false;
}
/**
* Define the User Ip for the query
* @access public
* @param string $ip
* return boolean
*/
public function setUserIp($ip) {
if (!empty($ip)) {
$this->user_ip = $ip;
return true;
}
return false;
}
/**
* Query the Google(TM) endpoint
* @access private
* @param array $lang_pair
* @param array $string
* returns String $response
*/
public function query($lang_pair,$string)
{
$query_url = $this->urlFormat($lang_pair,$string);
$response = $this->{"request".ucwords($this->request_type)}($query_url);
return $response;
}
/**
* Query Wrapper for Http Transport
* @access private
* @param String $url
* returns String $response
*/
private function requestHttp($url)
{
return GTranslate::evalResponse(json_decode(file_get_contents($this->url."?".$url)));
}
/**
* Query Wrapper for Curl Transport
* @access private
* @param String $url
* returns String $response
*/
private function requestCurl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, !empty($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $url);
$body = curl_exec($ch);
curl_close($ch);
return GTranslate::evalResponse(json_decode($body));
}
/**
* Response Evaluator, validates the response
* Throws an exception on error
* @access private
* @param String $json_response
* returns String $response
*/
private function evalResponse($json_response)
{
switch($json_response->responseStatus)
{
case 200:
return $json_response->responseData->translatedText;
break;
default:
throw new GTranslateException("Unable to perform Translation:".$json_response->responseDetails);
break;
}
}
/**
* Validates if the language pair is valid
* Throws an exception on error
* @access private
* @param Array $languages
* returns Array $response Array with formated languages pair
*/
private function isValidLanguage($languages)
{
$language_list = $this->available_languages;
$languages = array_map( "strtolower", $languages );
$language_list_v = array_map( "strtolower", array_values($language_list) );
$language_list_k = array_map( "strtolower", array_keys($language_list) );
$valid_languages = false;
if( TRUE == in_array($languages[0],$language_list_v) AND TRUE == in_array($languages[1],$language_list_v) )
{
$valid_languages = true;
}
if( FALSE === $valid_languages AND TRUE == in_array($languages[0],$language_list_k) AND TRUE == in_array($languages[1],$language_list_k) )
{
$languages = array($language_list[strtoupper($languages[0])],$language_list[strtoupper($languages[1])]);
$valid_languages = true;
}
if( FALSE === $valid_languages )
{
throw new GTranslateException("Unsupported languages");
}
return $languages;
}
/**
* Magic method to understande translation comman
* Evaluates methods like language_to_language
* @access public
* @param String $name
* @param Array $args
* returns String $response Translated Text
*/
public function __call($name,$args)
{
$languages_list = explode("_to_",strtolower($name));
$languages = $this->isValidLanguage($languages_list);
$string = $args[0];
return $this->query($languages,$string);
}
}
?>

View File

@@ -0,0 +1,110 @@
AFRIKAANS = af
ALBANIAN = sq
AMHARIC = am
ARABIC = ar
ARMENIAN = hy
AZERBAIJANI = az
BASQUE = eu
BELARUSIAN = be
BENGALI = bn
BIHARI = bh
BRETON = br
BULGARIAN = bg
BURMESE = my
CATALAN = ca
CHEROKEE = chr
CHINESE = zh
CHINESE_SIMPLIFIED = zh-Hans
CHINESE_TRADITIONAL = zh-Hant
CORSICAN = co
CROATIAN = hr
CZECH = cs
DANISH = da
DHIVEHI = dv
DUTCH = nl
ENGLISH = en
ESPERANTO = eo
ESTONIAN = et
FAROESE = fo
FILIPINO = tl
FINNISH = fi
FRENCH = fr
FRISIAN = fy
GALICIAN = gl
GEORGIAN = ka
GERMAN = de
GERMAN INFORMAL= de-informal
GREEK = el
GUJARATI = gu
HAITIAN_CREOLE = ht
HEBREW = iw
HINDI = hi
HUNGARIAN = hu
ICELANDIC = is
INDONESIAN = id
INUKTITUT = iu
IRISH = ga
ITALIAN = it
JAPANESE = ja
JAVANESE = jw
KANNADA = kn
KAZAKH = kk
KHMER = km
KOREAN = ko
KURDISH = ku
KYRGYZ = ky
LAO = lo
LATIN = la
LATVIAN = lv
LITHUANIAN = lt
LUXEMBOURGISH = lb
MACEDONIAN = mk
MALAY = ms
MALAYALAM = ml
MALTESE = mt
MAORI = mi
MARATHI = mr
MONGOLIAN = mn
NEPALI = ne
NORWEGIAN = no
NORWEGIAN NYNORSK = nn
NORWEGIAN BOKMAL = nb
OCCITAN = oc
ORIYA = or
PASHTO = ps
PERSIAN = fa
POLISH = pl
PORTUGUESE = pt
PORTUGUESE_PORTUGAL = pt-PT
PUNJABI = pa
QUECHUA = qu
ROMANIAN = ro
RUSSIAN = ru
SANSKRIT = sa
SCOTS_GAELIC = gd
SERBIAN = sr
SINDHI = sd
SINHALESE = si
SLOVAK = sk
SLOVENIAN = sl
SPANISH = es
SUNDANESE = su
SWAHILI = sw
SWEDISH = sv
SYRIAC = syr
TAJIK = tg
TAMIL = ta
TATAR = tt
TELUGU = te
THAI = th
TIBETAN = bo
TONGA = to
TURKISH = tr
UKRAINIAN = uk
URDU = ur
UZBEK = uz
UIGHUR = ug
VIETNAMESE = vi
WELSH = cy
YIDDISH = yi
YORUBA = yo

View File

@@ -0,0 +1,36 @@
HTTP client PHP class
This LICENSE is in the BSD license style.
License Version Control:
@(#) $Id: LICENSE.txt,v 1.1 2006/04/17 19:44:04 mlemos Exp $
Copyright (c) 1999 - 2006, Manuel Lemos
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of Manuel Lemos nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,806 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
?>

View File

@@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -0,0 +1,132 @@
<?
// --------------------------------------------------------------------------------
// PhpConcept Library (PCL) Error 1.0
// --------------------------------------------------------------------------------
// License GNU/GPL - Vincent Blavet - Mars 2001
// http://www.phpconcept.net & http://phpconcept.free.fr
// --------------------------------------------------------------------------------
// Fran<61>ais :
// La description de l'usage de la librairie PCL Error 1.0 n'est pas encore
// disponible. Celle-ci n'est pour le moment distribu<62>e qu'avec les
// d<>veloppements applicatifs de PhpConcept.
// Une version ind<6E>pendante sera bientot disponible sur http://www.phpconcept.net
//
// English :
// The PCL Error 1.0 library description is not available yet. This library is
// released only with PhpConcept application and libraries.
// An independant release will be soon available on http://www.phpconcept.net
//
// --------------------------------------------------------------------------------
//
// * Avertissement :
//
// Cette librairie a <20>t<EFBFBD> cr<63><72>e de fa<66>on non professionnelle.
// Son usage est au risque et p<>ril de celui qui l'utilise, en aucun cas l'auteur
// de ce code ne pourra <20>tre tenu pour responsable des <20>ventuels d<>gats qu'il pourrait
// engendrer.
// Il est entendu cependant que l'auteur a r<>alis<69> ce code par plaisir et n'y a
// cach<63> aucun virus, ni malveillance.
// Cette libairie est distribu<62>e sous la license GNU/GPL (http://www.gnu.org)
//
// * Auteur :
//
// Ce code a <20>t<EFBFBD> <20>crit par Vincent Blavet (vincent@blavet.net) sur son temps
// de loisir.
//
// --------------------------------------------------------------------------------
// ----- Look for double include
if (!defined("PCLERROR_LIB"))
{
define( "PCLERROR_LIB", 1 );
// ----- Version
$g_pcl_error_version = "1.0";
// ----- Internal variables
// These values must only be change by PclError library functions
$g_pcl_error_string = "";
$g_pcl_error_code = 1;
// --------------------------------------------------------------------------------
// Function : PclErrorLog()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclErrorLog($p_error_code=0, $p_error_string="")
{
global $g_pcl_error_string;
global $g_pcl_error_code;
$g_pcl_error_code = $p_error_code;
$g_pcl_error_string = $p_error_string;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclErrorFatal()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclErrorFatal($p_file, $p_line, $p_error_string="")
{
global $g_pcl_error_string;
global $g_pcl_error_code;
$v_message = "<html><body>";
$v_message .= "<p align=center><font color=red bgcolor=white><b>PclError Library has detected a fatal error on file '$p_file', line $p_line</b></font></p>";
$v_message .= "<p align=center><font color=red bgcolor=white><b>$p_error_string</b></font></p>";
$v_message .= "</body></html>";
die($v_message);
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclErrorReset()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclErrorReset()
{
global $g_pcl_error_string;
global $g_pcl_error_code;
$g_pcl_error_code = 1;
$g_pcl_error_string = "";
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclErrorCode()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclErrorCode()
{
global $g_pcl_error_string;
global $g_pcl_error_code;
return($g_pcl_error_code);
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclErrorString()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclErrorString()
{
global $g_pcl_error_string;
global $g_pcl_error_code;
return($g_pcl_error_string." [code $g_pcl_error_code]");
}
// --------------------------------------------------------------------------------
// ----- End of double include look
}
?>

View File

@@ -0,0 +1,737 @@
<?php
// --------------------------------------------------------------------------------
// PhpConcept Library (PCL) Trace 2.0-beta1
// --------------------------------------------------------------------------------
// License GNU/GPL - Vincent Blavet - August 2003
// http://www.phpconcept.net
// --------------------------------------------------------------------------------
//
// The PCL Trace library description is not available yet.
// This library was first released only with PclZip library.
// An independant release will be soon available on http://www.phpconcept.net
//
// --------------------------------------------------------------------------------
//
// Warning :
// This library and the associated files are non commercial, non professional
// work.
// It should not have unexpected results. However if any damage is caused by
// this software the author can not be responsible.
// The use of this software is at the risk of the user.
//
// --------------------------------------------------------------------------------
// ----- Version
$g_pcltrace_version = "2.0-beta1";
// ----- Internal variables
// These values must be change by PclTrace library functions
$g_pcl_trace_mode = "memory";
$g_pcl_trace_filename = "trace.txt";
$g_pcl_trace_name = array();
$g_pcl_trace_index = 0;
$g_pcl_trace_level = 0;
$g_pcl_trace_suspend = false;
//$g_pcl_trace_entries = array();
// ----- For compatibility reason
define ('PCLTRACE_LIB', 1);
// --------------------------------------------------------------------------------
// Function : TrOn($p_level, $p_mode, $p_filename)
// Description :
// Parameters :
// $p_level : Trace level
// $p_mode : Mode of trace displaying :
// 'normal' : messages are displayed at function call
// 'memory' : messages are memorized in a table and can be display by
// TrDisplay() function. (default)
// 'log' : messages are writed in the file $p_filename
// --------------------------------------------------------------------------------
function PclTraceOn($p_level=1, $p_mode="memory", $p_filename="trace.txt")
{
TrOn($p_level, $p_mode, $p_filename);
}
function TrOn($p_level=1, $p_mode="memory", $p_filename="trace.txt")
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Enable trace mode
$g_pcl_trace_level = $p_level;
// ----- Memorize mode and filename
switch ($p_mode) {
case "normal" :
case "memory" :
case "log" :
$g_pcl_trace_mode = $p_mode;
break;
default :
$g_pcl_trace_mode = "logged";
}
// ----- Memorize filename
$g_pcl_trace_filename = $p_filename;
$g_pcl_trace_suspend = false;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : IsTrOn()
// Description :
// Return value :
// The trace level (0 for disable).
// --------------------------------------------------------------------------------
function PclTraceIsOn()
{
return IsTrOn();
}
function IsTrOn()
{
global $g_pcl_trace_level;
return($g_pcl_trace_level);
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrOff()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceOff()
{
TrOff();
}
function TrOff()
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
// ----- Clean
$g_pcl_trace_mode = "memory";
unset($g_pcl_trace_entries);
unset($g_pcl_trace_name);
unset($g_pcl_trace_index);
// ----- Switch off trace
$g_pcl_trace_level = 0;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclTraceSuspend()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceSuspend()
{
global $g_pcl_trace_suspend;
$g_pcl_trace_suspend = true;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclTraceResume()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceResume()
{
global $g_pcl_trace_suspend;
$g_pcl_trace_suspend = false;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrFctStart()
// Description :
// Just a trace function for debbugging purpose before I use a better tool !!!!
// Start and stop of this function is by $g_pcl_trace_level global variable.
// Parameters :
// $p_level : Level of trace required.
// --------------------------------------------------------------------------------
function PclTraceFctStart($p_file, $p_line, $p_name, $p_param="", $p_message="")
{
TrFctStart($p_file, $p_line, $p_name, $p_param, $p_message);
}
function TrFctStart($p_file, $p_line, $p_name, $p_param="", $p_message="")
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Look for disabled trace
if (($g_pcl_trace_level < 1) || ($g_pcl_trace_suspend))
return;
// ----- Add the function name in the list
if (!isset($g_pcl_trace_name))
$g_pcl_trace_name = $p_name;
else
$g_pcl_trace_name .= ",".$p_name;
// ----- Update the function entry
$i = sizeof($g_pcl_trace_entries);
$g_pcl_trace_entries[$i]['name'] = $p_name;
$g_pcl_trace_entries[$i]['param'] = $p_param;
$g_pcl_trace_entries[$i]['message'] = "";
$g_pcl_trace_entries[$i]['file'] = $p_file;
$g_pcl_trace_entries[$i]['line'] = $p_line;
$g_pcl_trace_entries[$i]['index'] = $g_pcl_trace_index;
$g_pcl_trace_entries[$i]['type'] = "1"; // means start of function
// ----- Update the message entry
if ($p_message != "")
{
$i = sizeof($g_pcl_trace_entries);
$g_pcl_trace_entries[$i]['name'] = "";
$g_pcl_trace_entries[$i]['param'] = "";
$g_pcl_trace_entries[$i]['message'] = $p_message;
$g_pcl_trace_entries[$i]['file'] = $p_file;
$g_pcl_trace_entries[$i]['line'] = $p_line;
$g_pcl_trace_entries[$i]['index'] = $g_pcl_trace_index;
$g_pcl_trace_entries[$i]['type'] = "3"; // means message
}
// ----- Action depending on mode
PclTraceAction($g_pcl_trace_entries[$i]);
// ----- Increment the index
$g_pcl_trace_index++;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrFctEnd()
// Description :
// Just a trace function for debbugging purpose before I use a better tool !!!!
// Start and stop of this function is by $g_pcl_trace_level global variable.
// Parameters :
// $p_level : Level of trace required.
// --------------------------------------------------------------------------------
function PclTraceFctEnd($p_file, $p_line, $p_return=1, $p_message="")
{
TrFctEnd($p_file, $p_line, $p_return, $p_message);
}
function TrFctEnd($p_file, $p_line, $p_return=1, $p_message="")
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Look for disabled trace
if (($g_pcl_trace_level < 1) || ($g_pcl_trace_suspend))
return;
// ----- Extract the function name in the list
// ----- Remove the function name in the list
if (!($v_name = strrchr($g_pcl_trace_name, ",")))
{
$v_name = $g_pcl_trace_name;
$g_pcl_trace_name = "";
}
else
{
$g_pcl_trace_name = substr($g_pcl_trace_name, 0, strlen($g_pcl_trace_name)-strlen($v_name));
$v_name = substr($v_name, -strlen($v_name)+1);
}
// ----- Decrement the index
$g_pcl_trace_index--;
// ----- Update the message entry
if ($p_message != "")
{
$i = sizeof($g_pcl_trace_entries);
$g_pcl_trace_entries[$i]['name'] = "";
$g_pcl_trace_entries[$i]['param'] = "";
$g_pcl_trace_entries[$i]['message'] = $p_message;
$g_pcl_trace_entries[$i]['file'] = $p_file;
$g_pcl_trace_entries[$i]['line'] = $p_line;
$g_pcl_trace_entries[$i]['index'] = $g_pcl_trace_index;
$g_pcl_trace_entries[$i]['type'] = "3"; // means message
}
// ----- Update the function entry
$i = sizeof($g_pcl_trace_entries);
$g_pcl_trace_entries[$i]['name'] = $v_name;
$g_pcl_trace_entries[$i]['param'] = $p_return;
$g_pcl_trace_entries[$i]['message'] = "";
$g_pcl_trace_entries[$i]['file'] = $p_file;
$g_pcl_trace_entries[$i]['line'] = $p_line;
$g_pcl_trace_entries[$i]['index'] = $g_pcl_trace_index;
$g_pcl_trace_entries[$i]['type'] = "2"; // means end of function
// ----- Action depending on mode
PclTraceAction($g_pcl_trace_entries[$i]);
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrFctMessage()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceFctMessage($p_file, $p_line, $p_level, $p_message="")
{
TrFctMessage($p_file, $p_line, $p_level, $p_message);
}
function TrFctMessage($p_file, $p_line, $p_level, $p_message="")
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Look for disabled trace
if (($g_pcl_trace_level < $p_level) || ($g_pcl_trace_suspend))
return;
// ----- Update the entry
$i = sizeof($g_pcl_trace_entries);
$g_pcl_trace_entries[$i]['name'] = "";
$g_pcl_trace_entries[$i]['param'] = "";
$g_pcl_trace_entries[$i]['message'] = $p_message;
$g_pcl_trace_entries[$i]['file'] = $p_file;
$g_pcl_trace_entries[$i]['line'] = $p_line;
$g_pcl_trace_entries[$i]['index'] = $g_pcl_trace_index;
$g_pcl_trace_entries[$i]['type'] = "3"; // means message of function
// ----- Action depending on mode
PclTraceAction($g_pcl_trace_entries[$i]);
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrMessage()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceMessage($p_file, $p_line, $p_level, $p_message="")
{
TrMessage($p_file, $p_line, $p_level, $p_message);
}
function TrMessage($p_file, $p_line, $p_level, $p_message="")
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Look for disabled trace
if (($g_pcl_trace_level < $p_level) || ($g_pcl_trace_suspend))
return;
// ----- Update the entry
$i = sizeof($g_pcl_trace_entries);
$g_pcl_trace_entries[$i]['name'] = "";
$g_pcl_trace_entries[$i]['param'] = "";
$g_pcl_trace_entries[$i]['message'] = $p_message;
$g_pcl_trace_entries[$i]['file'] = $p_file;
$g_pcl_trace_entries[$i]['line'] = $p_line;
$g_pcl_trace_entries[$i]['index'] = $g_pcl_trace_index;
$g_pcl_trace_entries[$i]['type'] = "4"; // means simple message
// ----- Action depending on mode
PclTraceAction($g_pcl_trace_entries[$i]);
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrDisplay()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceDisplay()
{
TrDisplay();
}
function TrDisplay()
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Look for disabled trace
if (($g_pcl_trace_level <= 0) || ($g_pcl_trace_mode != "memory") || ($g_pcl_trace_suspend))
return;
$v_font = "\"Verdana, Arial, Helvetica, sans-serif\"";
// ----- Trace Header
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>";
echo "<tr bgcolor=#0000CC>";
echo "<td bgcolor=#0000CC width=1>";
echo "</td>";
echo "<td><div align=center><font size=3 color=#FFFFFF face=$v_font>Trace</font></div></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=#0000CC width=1>";
echo "</td>";
echo "<td>";
// ----- Content header
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>";
// ----- Display
$v_again=0;
for ($i=0; $i<sizeof($g_pcl_trace_entries); $i++)
{
// ---- Row header
echo "<tr>";
echo "<td><table width=100% border=0 cellspacing=0 cellpadding=0><tr>";
$n = ($g_pcl_trace_entries[$i]['index']+1)*10;
echo "<td width=".$n."><table width=100% border=0 cellspacing=0 cellpadding=0><tr>";
for ($j=0; $j<=$g_pcl_trace_entries[$i]['index']; $j++)
{
if ($j==$g_pcl_trace_entries[$i]['index'])
{
if (($g_pcl_trace_entries[$i]['type'] == 1) || ($g_pcl_trace_entries[$i]['type'] == 2))
echo "<td width=10><div align=center><font size=2 face=$v_font>+</font></div></td>";
}
else
echo "<td width=10><div align=center><font size=2 face=$v_font>|</font></div></td>";
}
//echo "<td>&nbsp</td>";
echo "</tr></table></td>";
echo "<td width=2></td>";
switch ($g_pcl_trace_entries[$i]['type']) {
case 1:
echo "<td><font size=2 face=$v_font>".$g_pcl_trace_entries[$i]['name']."(".$g_pcl_trace_entries[$i]['param'].")</font></td>";
break;
case 2:
echo "<td><font size=2 face=$v_font>".$g_pcl_trace_entries[$i]['name']."()=".$g_pcl_trace_entries[$i]['param']."</font></td>";
break;
case 3:
case 4:
echo "<td><table width=100% border=0 cellspacing=0 cellpadding=0><td width=20></td><td>";
echo "<font size=2 face=$v_font>".$g_pcl_trace_entries[$i]['message']."</font>";
echo "</td></table></td>";
break;
default:
echo "<td><font size=2 face=$v_font>".$g_pcl_trace_entries[$i]['name']."(".$g_pcl_trace_entries[$i]['param'].")</font></td>";
}
echo "</tr></table></td>";
echo "<td width=5></td>";
echo "<td><font size=1 face=$v_font>".basename($g_pcl_trace_entries[$i]['file'])."</font></td>";
echo "<td width=5></td>";
echo "<td><font size=1 face=$v_font>".$g_pcl_trace_entries[$i]['line']."</font></td>";
echo "</tr>";
}
// ----- Content footer
echo "</table>";
// ----- Trace footer
echo "</td>";
echo "<td bgcolor=#0000CC width=1>";
echo "</td>";
echo "</tr>";
echo "<tr bgcolor=#0000CC>";
echo "<td bgcolor=#0000CC width=1>";
echo "</td>";
echo "<td><div align=center><font color=#FFFFFF face=$v_font>&nbsp</font></div></td>";
echo "</tr>";
echo "</table>";
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrDisplayNew()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceDisplayNew()
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
// ----- Look for disabled trace
if (($g_pcl_trace_level <= 0) || ($g_pcl_trace_mode != "memory") || ($g_pcl_trace_suspend))
return;
?>
<script language="javascript">
function PclTraceToggleView(element) {
if (element.style.visibility == 'visible') {
PclTraceHide(element);
} else {
PclTraceShow(element);
}
}
function PclTraceShow(element) {
element.style.visibility = 'visible';
element.style.position='relative';
}
function PclTraceHide(element) {
element.style.visibility = 'hidden';
element.style.position='absolute';
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
bordercolor="#0000CC">
<tr>
<td bgcolor="#0000CC">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Trace</b></font></div>
</td>
</tr>
<tr>
<td><?php
$v_font = "\"Verdana, Arial, Helvetica, sans-serif\"";
// ----- Trace Header
// ----- Display the items
$v_again=0;
for ($i=0; $i<sizeof($g_pcl_trace_entries); $i++)
{
switch ($g_pcl_trace_entries[$i]['type']) {
case 1: // fct start
PclTraceDisplayItemStart($i);
break;
case 2: // fct stop
PclTraceDisplayItemStop($i);
break;
case 3: // fct msg
case 4: // msg
PclTraceDisplayItemMsg($i);
break;
default:
}
/*
echo "</tr></table></td>";
echo "<td width=5></td>";
echo "<td><font size=1 face=$v_font>".basename($g_pcl_trace_entries[$i]['file'])."</font></td>";
echo "<td width=5></td>";
echo "<td><font size=1 face=$v_font>".$g_pcl_trace_entries[$i]['line']."</font></td>";
echo "</tr>";
*/
}
// ----- Trace footer
?></td>
</tr>
<tr>
<td bgcolor="#0000CC">&nbsp;</td>
</tr>
</table>
<script language="javascript">
function PclTraceShowAll() {
<?php
for ($i=0; $i<sizeof($g_pcl_trace_entries); $i++) {
if ($g_pcl_trace_entries[$i]['type'] == 1) {
echo "PclTraceShow(document.getElementById('fct-".$i."'));";
}
}
?>
}
function PclTraceHideAll() {
<?php
for ($i=0; $i<sizeof($g_pcl_trace_entries); $i++) {
if ($g_pcl_trace_entries[$i]['type'] == 1) {
echo "PclTraceHide(document.getElementById('fct-".$i."'));";
}
}
?>
}
</script>
<form id="formulaire" action="POST">
<p><input type='button' value='Show All' onclick="PclTraceShowAll();"></input>
<input type='button' value='Hide All' onclick="PclTraceHideAll();"></input>
</p>
</form>
<?php
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrDisplayNew()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceDisplayItemStart($p_id)
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><font face="Verdana, Arial, Helvetica, sans-serif"
color="#FFFFFF"><b><font color="#000000" size="2">+</font></b></font></td>
<td style="width: 2px;"></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font
color="#000000" size="2"> <a href="javascript:null();"
title="<?php echo 'File:'.basename($g_pcl_trace_entries[$p_id]['file'])." Line: ".$g_pcl_trace_entries[$p_id]['line'];?>"
onClick="PclTraceToggleView(document.getElementById('<?php echo 'fct-'.$p_id; ?>'));">
<?php echo $g_pcl_trace_entries[$p_id]['name']."(".$g_pcl_trace_entries[$p_id]['param'].")" ?>
</a></font></b></font></td>
</tr>
<tr id="<?php echo 'fct-'.$p_id; ?>"
style="visibility: hidden; position: absolute;">
<td width="10">&nbsp;</td>
<td style="width: 2px;" bgcolor="#0000CC"></td>
<td><?php
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrDisplayNew()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceDisplayItemStop($p_id)
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
color="#FFFFFF"><b><font color="#000000" size="2"> <?php echo $g_pcl_trace_entries[$p_id]['name']."()=".$g_pcl_trace_entries[$p_id]['param']; ?>
</font></b></font></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : TrDisplayNew()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceDisplayItemMsg($p_id)
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
global $g_pcl_trace_suspend;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><font face="Verdana, Arial, Helvetica, sans-serif"
color="#FFFFFF"><b><font color="#000000" size="2">
<center>.</center>
</font></b></font></td>
<td style="width: 2px;"></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font
color="#000000" size="2"> <?php echo $g_pcl_trace_entries[$p_id]['message'] ?>
</font></b></font></td>
<td width=5></td>
<td><font size=1 face="Verdana, Arial, Helvetica, sans-serif"><?php echo basename($g_pcl_trace_entries[$p_id]['file']); ?></font></td>
<td width=5></td>
<td><font size=1 face="Verdana, Arial, Helvetica, sans-serif"><?php echo $g_pcl_trace_entries[$p_id]['line']; ?></font></td>
</tr>
</table>
<?php
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclTraceAction()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function PclTraceAction($p_entry)
{
global $g_pcl_trace_level;
global $g_pcl_trace_mode;
global $g_pcl_trace_filename;
global $g_pcl_trace_name;
global $g_pcl_trace_index;
global $g_pcl_trace_entries;
if ($g_pcl_trace_mode == "normal")
{
for ($i=0; $i<$p_entry['index']; $i++)
echo "---";
if ($p_entry['type'] == 1)
echo "<b>".$p_entry['name']."</b>(".$p_entry['param'].") : ".$p_entry['message']." [".$p_entry[file].", ".$p_entry[line]."]<br>";
else if ($p_entry['type'] == 2)
echo "<b>".$p_entry['name']."</b>()=".$p_entry['param']." : ".$p_entry['message']." [".$p_entry[file].", ".$p_entry[line]."]<br>";
else
echo $p_entry['message']." [".$p_entry['file'].", ".$p_entry['line']."]<br>";
}
}
// --------------------------------------------------------------------------------
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,412 @@
// --------------------------------------------------------------------------------
// PclZip 2.8.1 - readme.txt
// --------------------------------------------------------------------------------
// License GNU/LGPL - August 2009
// Vincent Blavet - vincent@phpconcept.net
// http://www.phpconcept.net
// --------------------------------------------------------------------------------
// $Id: readme.txt,v 1.58 2009/08/11 14:58:12 vblavet Exp $
// --------------------------------------------------------------------------------
0 - Sommaire
============
1 - Introduction
2 - What's new
3 - Corrected bugs
4 - Known bugs or limitations
5 - License
6 - Warning
7 - Documentation
8 - Author
9 - Contribute
1 - Introduction
================
PclZip is a library that allow you to manage a Zip archive.
Full documentation about PclZip can be found here : http://www.phpconcept.net/pclzip
2 - What's new
==============
Version 2.8.1 :
- Move option PCLZIP_OPT_BY_EREG to PCLZIP_OPT_BY_PREG because ereg() is
deprecated in PHP 5.3. When using option PCLZIP_OPT_BY_EREG, PclZip will
automatically replace it by PCLZIP_OPT_BY_PREG.
Version 2.8 :
- Improve extraction of zip archive for large files by using temporary files
This feature is working like the one defined in r2.7.
Options are renamed : PCLZIP_OPT_TEMP_FILE_ON, PCLZIP_OPT_TEMP_FILE_OFF,
PCLZIP_OPT_TEMP_FILE_THRESHOLD
- Add a ratio constant PCLZIP_TEMPORARY_FILE_RATIO to configure the auto
sense of temporary file use.
- Bug correction : Reduce filepath in returned file list to remove ennoying
'.//' preambule in file path.
Version 2.7 :
- Improve creation of zip archive for large files :
PclZip will now autosense the configured memory and use temporary files
when large file is suspected.
This feature can also ne triggered by manual options in create() and add()
methods. 'PCLZIP_OPT_ADD_TEMP_FILE_ON' force the use of temporary files,
'PCLZIP_OPT_ADD_TEMP_FILE_OFF' disable the autosense technic,
'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD' allow for configuration of a size
threshold to use temporary files.
Using "temporary files" rather than "memory" might take more time, but
might give the ability to zip very large files :
Tested on my win laptop with a 88Mo file :
Zip "in-memory" : 18sec (max_execution_time=30, memory_limit=180Mo)
Zip "tmporary-files" : 23sec (max_execution_time=30, memory_limit=30Mo)
- Replace use of mktime() by time() to limit the E_STRICT error messages.
- Bug correction : When adding files with full windows path (drive letter)
PclZip is now working. Before, if the drive letter is not the default
path, PclZip was not able to add the file.
Version 2.6 :
- Code optimisation
- New attributes PCLZIP_ATT_FILE_COMMENT gives the ability to
add a comment for a specific file. (Don't really know if this is usefull)
- New attribute PCLZIP_ATT_FILE_CONTENT gives the ability to add a string
as a file.
- New attribute PCLZIP_ATT_FILE_MTIME modify the timestamp associated with
a file.
- Correct a bug. Files archived with a timestamp with 0h0m0s were extracted
with current time
- Add CRC value in the informations returned back for each file after an
action.
- Add missing closedir() statement.
- When adding a folder, and removing the path of this folder, files were
incorrectly added with a '/' at the beginning. Which means files are
related to root in unix systems. Corrected.
- Add conditional if before constant definition. This will allow users
to redefine constants without changing the file, and then improve
upgrade of pclzip code for new versions.
Version 2.5 :
- Introduce the ability to add file/folder with individual properties (file descriptor).
This gives for example the ability to change the filename of a zipped file.
. Able to add files individually
. Able to change full name
. Able to change short name
. Compatible with global options
- New attributes : PCLZIP_ATT_FILE_NAME, PCLZIP_ATT_FILE_NEW_SHORT_NAME, PCLZIP_ATT_FILE_NEW_FULL_NAME
- New error code : PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE
- Add a security control feature. PclZip can extract any file in any folder
of a system. People may use this to upload a zip file and try to override
a system file. The PCLZIP_OPT_EXTRACT_DIR_RESTRICTION will give the
ability to forgive any directory transversal behavior.
- New PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : check extraction path
- New error code : PCLZIP_ERR_DIRECTORY_RESTRICTION
- Modification in PclZipUtilPathInclusion() : dir and path beginning with ./ will be prepend
by current path (getcwd())
Version 2.4 :
- Code improvment : try to speed up the code by removing unusefull call to pack()
- Correct bug in delete() : delete() should be called with no argument. This was not
the case in 2.3. This is corrected in 2.4.
- Correct a bug in path_inclusion function. When the path has several '../../', the
result was bad.
- Add a check for magic_quotes_runtime configuration. If enabled, PclZip will
disable it while working and det it back to its original value.
This resolve a lots of bad formated archive errors.
- Bug correction : PclZip now correctly unzip file in some specific situation,
when compressed content has same size as uncompressed content.
- Bug correction : When selecting option 'PCLZIP_OPT_REMOVE_ALL_PATH',
directories are not any more created.
- Code improvment : correct unclosed opendir(), better handling of . and .. in
loops.
Version 2.3 :
- Correct a bug with PHP5 : affecting the value 0xFE49FFE0 to a variable does not
give the same result in PHP4 and PHP5 ....
Version 2.2 :
- Try development of PCLZIP_OPT_CRYPT .....
However this becomes to a stop. To crypt/decrypt I need to multiply 2 long integers,
the result (greater than a long) is not supported by PHP. Even the use of bcmath
functions does not help. I did not find yet a solution ...;
- Add missing '/' at end of directory entries
- Check is a file is encrypted or not. Returns status 'unsupported_encryption' and/or
error code PCLZIP_ERR_UNSUPPORTED_ENCRYPTION.
- Corrected : Bad "version need to extract" field in local file header
- Add private method privCheckFileHeaders() in order to check local and central
file headers. PclZip is now supporting purpose bit flag bit 3. Purpose bit flag bit 3 gives
the ability to have a local file header without size, compressed size and crc filled.
- Add a generic status 'error' for file status
- Add control of compression type. PclZip only support deflate compression method.
Before v2.2, PclZip does not check the compression method used in an archive while
extracting. With v2.2 PclZip returns a new error status for a file using an unsupported
compression method. New status is "unsupported_compression". New error code is
PCLZIP_ERR_UNSUPPORTED_COMPRESSION.
- Add optional attribute PCLZIP_OPT_STOP_ON_ERROR. This will stop the extract of files
when errors like 'a folder with same name exists' or 'a newer file exists' or
'a write protected file' exists, rather than set a status for the concerning file
and resume the extract of the zip.
- Add optional attribute PCLZIP_OPT_REPLACE_NEWER. This will force, during an extract' the
replacement of the file, even if a newer version of the file exists.
Note that today if a file with the same name already exists but is older it will be
replaced by the extracted one.
- Improve PclZipUtilOption()
- Support of zip archive with trailing bytes. Before 2.2, PclZip checks that the central
directory structure is the last data in the archive. Crypt encryption/decryption of
zip archive put trailing 0 bytes after decryption. PclZip is now supporting this.
Version 2.1 :
- Add the ability to abort the extraction by using a user callback function.
The user can now return the value '2' in its callback which indicates to stop the
extraction. For a pre call-back extract is stopped before the extration of the current
file. For a post call back, the extraction is stopped after.
- Add the ability to extract a file (or several files) directly in the standard output.
This is done by the new parameter PCLZIP_OPT_EXTRACT_IN_OUTPUT with method extract().
- Add support for parameters PCLZIP_OPT_COMMENT, PCLZIP_OPT_ADD_COMMENT,
PCLZIP_OPT_PREPEND_COMMENT. This will create, replace, add, or prepend comments
in the zip archive.
- When merging two archives, the comments are not any more lost, but merged, with a
blank space separator.
- Corrected bug : Files are not deleted when all files are asked to be deleted.
- Corrected bug : Folders with name '0' made PclZip to abort the create or add feature.
Version 2.0 :
***** Warning : Some new features may break the backward compatibility for your scripts.
Please carefully read the readme file.
- Add the ability to delete by Index, name and regular expression. This feature is
performed by the method delete(), which uses the optional parameters
PCLZIP_OPT_BY_INDEX, PCLZIP_OPT_BY_NAME, PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG.
- Add the ability to extract by regular expression. To extract by regexp you must use the method
extract(), with the option PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG
(depending if you want to use ereg() or preg_match() syntax) followed by the
regular expression pattern.
- Add the ability to extract by index, directly with the extract() method. This is a
code improvment of the extractByIndex() method.
- Add the ability to extract by name. To extract by name you must use the method
extract(), with the option PCLZIP_OPT_BY_NAME followed by the filename to
extract or an array of filenames to extract. To extract all a folder, use the folder
name rather than the filename with a '/' at the end.
- Add the ability to add files without compression. This is done with a new attribute
which is PCLZIP_OPT_NO_COMPRESSION.
- Add the attribute PCLZIP_OPT_EXTRACT_AS_STRING, which allow to extract a file directly
in a string without using any file (or temporary file).
- Add constant PCLZIP_SEPARATOR for static configuration of filename separators in a single string.
The default separator is now a comma (,) and not any more a blank space.
THIS BREAK THE BACKWARD COMPATIBILITY : Please check if this may have an impact with
your script.
- Improve algorythm performance by removing the use of temporary files when adding or
extracting files in an archive.
- Add (correct) detection of empty filename zipping. This can occurs when the removed
path is the same
as a zipped dir. The dir is not zipped (['status'] = filtered), only its content.
- Add better support for windows paths (thanks for help from manus@manusfreedom.com).
- Corrected bug : When the archive file already exists with size=0, the add() method
fails. Corrected in 2.0.
- Remove the use of OS_WINDOWS constant. Use php_uname() function rather.
- Control the order of index ranges in extract by index feature.
- Change the internal management of folders (better handling of internal flag).
Version 1.3 :
- Removing the double include check. This is now done by include_once() and require_once()
PHP directives.
- Changing the error handling mecanism : Remove the use of an external error library.
The former PclError...() functions are replaced by internal equivalent methods.
By changing the environment variable PCLZIP_ERROR_EXTERNAL you can still use the former library.
Introducing the use of constants for error codes rather than integer values. This will help
in futur improvment.
Introduction of error handling functions like errorCode(), errorName() and errorInfo().
- Remove the deprecated use of calling function with arguments passed by reference.
- Add the calling of extract(), extractByIndex(), create() and add() functions
with variable options rather than fixed arguments.
- Add the ability to remove all the file path while extracting or adding,
without any need to specify the path to remove.
This is available for extract(), extractByIndex(), create() and add() functionS by using
the new variable options parameters :
- PCLZIP_OPT_REMOVE_ALL_PATH : by indicating this option while calling the fct.
- Ability to change the mode of a file after the extraction (chmod()).
This is available for extract() and extractByIndex() functionS by using
the new variable options parameters.
- PCLZIP_OPT_SET_CHMOD : by setting the value of this option.
- Ability to definition call-back options. These call-back will be called during the adding,
or the extracting of file (extract(), extractByIndex(), create() and add() functions) :
- PCLZIP_CB_PRE_EXTRACT : will be called before each extraction of a file. The user
can trigerred the change the filename of the extracted file. The user can triggered the
skip of the extraction. This is adding a 'skipped' status in the file list result value.
- PCLZIP_CB_POST_EXTRACT : will be called after each extraction of a file.
Nothing can be triggered from that point.
- PCLZIP_CB_PRE_ADD : will be called before each add of a file. The user
can trigerred the change the stored filename of the added file. The user can triggered the
skip of the add. This is adding a 'skipped' status in the file list result value.
- PCLZIP_CB_POST_ADD : will be called after each add of a file.
Nothing can be triggered from that point.
- Two status are added in the file list returned as function result : skipped & filename_too_long
'skipped' is used when a call-back function ask for skipping the file.
'filename_too_long' is used while adding a file with a too long filename to archive (the file is
not added)
- Adding the function PclZipUtilPathInclusion(), that check the inclusion of a path into
a directory.
- Add a check of the presence of the archive file before some actions (like list, ...)
- Add the initialisation of field "index" in header array. This means that by
default index will be -1 when not explicitly set by the methods.
Version 1.2 :
- Adding a duplicate function.
- Adding a merge function. The merge function is a "quick merge" function,
it just append the content of an archive at the end of the first one. There
is no check for duplicate files or more recent files.
- Improve the search of the central directory end.
Version 1.1.2 :
- Changing the license of PclZip. PclZip is now released under the GNU / LGPL license
(see License section).
- Adding the optional support of a static temporary directory. You will need to configure
the constant PCLZIP_TEMPORARY_DIR if you want to use this feature.
- Improving the rename() function. In some cases rename() does not work (different
Filesystems), so it will be replaced by a copy() + unlink() functions.
Version 1.1.1 :
- Maintenance release, no new feature.
Version 1.1 :
- New method Add() : adding files in the archive
- New method ExtractByIndex() : partial extract of the archive, files are identified by
their index in the archive
- New method DeleteByIndex() : delete some files/folder entries from the archive,
files are identified by their index in the archive.
- Adding a test of the zlib extension presence. If not present abort the script.
Version 1.0.1 :
- No new feature
3 - Corrected bugs
==================
Corrected in Version 2.0 :
- Corrected : During an extraction, if a call-back fucntion is used and try to skip
a file, all the extraction process is stopped.
Corrected in Version 1.3 :
- Corrected : Support of static synopsis for method extract() is broken.
- Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).
- Corrected : When an extract is done with a remove_path parameter, the entry for
the directory with exactly the same path is not skipped/filtered.
- Corrected : extractByIndex() and deleteByIndex() were not managing index in the
right way. For example indexes '1,3-5,11' will only extract files 1 and 11. This
is due to a sort of the index resulting table that puts 11 before 3-5 (sort on
string and not interger). The sort is temporarilly removed, this means that
you must provide a sorted list of index ranges.
Corrected in Version 1.2 :
- Nothing.
Corrected in Version 1.1.2 :
- Corrected : Winzip is unable to delete or add new files in a PclZip created archives.
Corrected in Version 1.1.1 :
- Corrected : When archived file is not compressed (0% compression), the
extract method fails.
Corrected in Version 1.1 :
- Corrected : Adding a complete tree of folder may result in a bad archive
creation.
Corrected in Version 1.0.1 :
- Corrected : Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
4 - Known bugs or limitations
=============================
Please publish bugs reports in SourceForge :
http://sourceforge.net/tracker/?group_id=40254&atid=427564
In Version 2.x :
- PclZip does only support file uncompressed or compressed with deflate (compression method 8)
- PclZip does not support password protected zip archive
- Some concern were seen when changing mtime of a file while archiving.
Seems to be linked to Daylight Saving Time (PclTest_changing_mtime).
In Version 1.2 :
- merge() methods does not check for duplicate files or last date of modifications.
In Version 1.1 :
- Limitation : Using 'extract' fields in the file header in the zip archive is not supported.
- WinZip is unable to delete a single file in a PclZip created archive. It is also unable to
add a file in a PclZip created archive. (Corrected in v.1.2)
In Version 1.0.1 :
- Adding a complete tree of folder may result in a bad archive
creation. (Corrected in V.1.1).
- Path given to methods must be in the unix format (/) and not the Windows format (\).
Workaround : Use only / directory separators.
- PclZip is using temporary files that are sometime the name of the file with a .tmp or .gz
added suffix. Files with these names may already exist and may be overwritten.
Workaround : none.
- PclZip does not check if the zlib extension is present. If it is absent, the zip
file is not created and the lib abort without warning.
Workaround : enable the zlib extension on the php install
In Version 1.0 :
- Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
(Corrected in v.1.0.1)
- Limitation : Multi-disk zip archive are not supported.
5 - License
===========
Since version 1.1.2, PclZip Library is released under GNU/LGPL license.
This library is free, so you can use it at no cost.
HOWEVER, if you release a script, an application, a library or any kind of
code using PclZip library (or a part of it), YOU MUST :
- Indicate in the documentation (or a readme file), that your work
uses PclZip Library, and make a reference to the author and the web site
http://www.phpconcept.net
- Gives the ability to the final user to update the PclZip libary.
I will also appreciate that you send me a mail (vincent@phpconcept.net), just to
be aware that someone is using PclZip.
For more information about GNU/LGPL license : http://www.gnu.org
6 - Warning
=================
This library and the associated files are non commercial, non professional work.
It should not have unexpected results. However if any damage is caused by this software
the author can not be responsible.
The use of this software is at the risk of the user.
7 - Documentation
=================
PclZip User Manuel is available in English on PhpConcept : http://www.phpconcept.net/pclzip/man/en/index.php
A Russian translation was done by Feskov Kuzma : http://php.russofile.ru/ru/authors/unsort/zip/
8 - Author
==========
This software was written by Vincent Blavet (vincent@phpconcept.net) on its leasure time.
9 - Contribute
==============
If you want to contribute to the development of PclZip, please contact vincent@phpconcept.net.
If you can help in financing PhpConcept hosting service, please go to
http://www.phpconcept.net/soutien.php

View File

@@ -21,8 +21,8 @@
/** /**
* Constants for OLE package * Constants for OLE package
*/ */
define('OLE_PPS_TYPE_ROOT', 5); define('OLE_PPS_TYPE_ROOT', 5);
define('OLE_PPS_TYPE_DIR', 1); define('OLE_PPS_TYPE_DIR', 1);
define('OLE_PPS_TYPE_FILE', 2); define('OLE_PPS_TYPE_FILE', 2);
@@ -35,43 +35,43 @@ require_once($homedir.'/classes/pear/PEAR.php');
require_once $homedir.'/classes/pear/OLE/PPS.php'; require_once $homedir.'/classes/pear/OLE/PPS.php';
/** /**
* OLE package base class. * OLE package base class.
* *
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @category Structures * @category Structures
* @package OLE * @package OLE
*/ */
class OLE extends PEAR class OLE extends PEAR
{ {
/** /**
* The file handle for reading an OLE container * The file handle for reading an OLE container
* @var resource * @var resource
*/ */
var $_file_handle; var $_file_handle;
/** /**
* Array of PPS's found on the OLE container * Array of PPS's found on the OLE container
* @var array * @var array
*/ */
var $_list; var $_list;
/** /**
* Creates a new OLE object * Creates a new OLE object
* Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();) * Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();)
* @access public * @access public
*/ */
function OLE() function OLE()
{ {
$this->_list = array(); $this->_list = array();
} }
/** /**
* Reads an OLE container from the contents of the file given. * Reads an OLE container from the contents of the file given.
* *
* @acces public * @acces public
* @param string $file * @param string $file
* @return mixed true on success, PEAR_Error on failure * @return mixed true on success, PEAR_Error on failure
*/ */
function read($file) function read($file)
{ {
/* consider storing offsets as constants */ /* consider storing offsets as constants */
@@ -122,25 +122,25 @@ class OLE extends PEAR
} }
/** /**
* Destructor (using PEAR) * Destructor (using PEAR)
* Just closes the file handle on the OLE file. * Just closes the file handle on the OLE file.
* *
* @access private * @access private
*/ */
function _OLE() function _OLE()
{ {
fclose($this->_file_handle); fclose($this->_file_handle);
} }
/** /**
* Gets information about all PPS's on the OLE container from the PPS WK's * Gets information about all PPS's on the OLE container from the PPS WK's
* creates an OLE_PPS object for each one. * creates an OLE_PPS object for each one.
* *
* @access private * @access private
* @param integer $pps_wk_start Position inside the OLE file where PPS WK's start * @param integer $pps_wk_start Position inside the OLE file where PPS WK's start
* @param integer $big_block_size Size of big blobks in the OLE file * @param integer $big_block_size Size of big blobks in the OLE file
* @return mixed true on success, PEAR_Error on failure * @return mixed true on success, PEAR_Error on failure
*/ */
function _readPpsWks($pps_wk_start, $big_block_size) function _readPpsWks($pps_wk_start, $big_block_size)
{ {
$pointer = ($pps_wk_start + 1) * $big_block_size; $pointer = ($pps_wk_start + 1) * $big_block_size;
@@ -149,7 +149,7 @@ class OLE extends PEAR
fseek($this->_file_handle, $pointer); fseek($this->_file_handle, $pointer);
$pps_wk = fread($this->_file_handle, OLE_PPS_SIZE); $pps_wk = fread($this->_file_handle, OLE_PPS_SIZE);
if (strlen($pps_wk) != OLE_PPS_SIZE) { if (strlen($pps_wk) != OLE_PPS_SIZE) {
break; // Excel likes to add a trailing byte sometimes break; // Excel likes to add a trailing byte sometimes
//return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk)); //return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk));
} }
$name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??) $name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??)
@@ -157,8 +157,8 @@ class OLE extends PEAR
$name = substr($pps_wk, 0, $name_length); $name = substr($pps_wk, 0, $name_length);
$type = unpack("c", substr($pps_wk, 66, 1)); $type = unpack("c", substr($pps_wk, 66, 1));
if (($type[''] != OLE_PPS_TYPE_ROOT) and if (($type[''] != OLE_PPS_TYPE_ROOT) and
($type[''] != OLE_PPS_TYPE_DIR) and ($type[''] != OLE_PPS_TYPE_DIR) and
($type[''] != OLE_PPS_TYPE_FILE)) ($type[''] != OLE_PPS_TYPE_FILE))
{ {
return $this->raiseError("PPS at $pointer has unknown type: {$type['']}"); return $this->raiseError("PPS at $pointer has unknown type: {$type['']}");
} }
@@ -174,9 +174,9 @@ class OLE extends PEAR
// _data member will point to position in file!! // _data member will point to position in file!!
// OLE_PPS object is created with an empty children array!! // OLE_PPS object is created with an empty children array!!
$this->_list[] = new OLE_PPS(null, '', $type[''], $prev[''], $next[''], $this->_list[] = new OLE_PPS(null, '', $type[''], $prev[''], $next[''],
$dir[''], OLE::OLE2LocalDate($time_1st), $dir[''], OLE::OLE2LocalDate($time_1st),
OLE::OLE2LocalDate($time_2nd), OLE::OLE2LocalDate($time_2nd),
($start_block[''] + 1) * $big_block_size, array()); ($start_block[''] + 1) * $big_block_size, array());
// give it a size // give it a size
$this->_list[count($this->_list) - 1]->Size = $size['']; $this->_list[count($this->_list) - 1]->Size = $size[''];
// check if the PPS tree (starting from root) is complete // check if the PPS tree (starting from root) is complete
@@ -186,15 +186,15 @@ class OLE extends PEAR
$pointer += OLE_PPS_SIZE; $pointer += OLE_PPS_SIZE;
} }
} }
/** /**
* It checks whether the PPS tree is complete (all PPS's read) * It checks whether the PPS tree is complete (all PPS's read)
* starting with the given PPS (not necessarily root) * starting with the given PPS (not necessarily root)
* *
* @access private * @access private
* @param integer $index The index of the PPS from which we are checking * @param integer $index The index of the PPS from which we are checking
* @return boolean Whether the PPS tree for the given PPS is complete * @return boolean Whether the PPS tree for the given PPS is complete
*/ */
function _ppsTreeComplete($index) function _ppsTreeComplete($index)
{ {
if ($this->_list[$index]->NextPps != -1) { if ($this->_list[$index]->NextPps != -1) {
@@ -216,14 +216,14 @@ class OLE extends PEAR
return true; return true;
} }
/** /**
* Checks whether a PPS is a File PPS or not. * Checks whether a PPS is a File PPS or not.
* If there is no PPS for the index given, it will return false. * If there is no PPS for the index given, it will return false.
* *
* @access public * @access public
* @param integer $index The index for the PPS * @param integer $index The index for the PPS
* @return bool true if it's a File PPS, false otherwise * @return bool true if it's a File PPS, false otherwise
*/ */
function isFile($index) function isFile($index)
{ {
if (isset($this->_list[$index])) { if (isset($this->_list[$index])) {
@@ -232,14 +232,14 @@ class OLE extends PEAR
return false; return false;
} }
/** /**
* Checks whether a PPS is a Root PPS or not. * Checks whether a PPS is a Root PPS or not.
* If there is no PPS for the index given, it will return false. * If there is no PPS for the index given, it will return false.
* *
* @access public * @access public
* @param integer $index The index for the PPS. * @param integer $index The index for the PPS.
* @return bool true if it's a Root PPS, false otherwise * @return bool true if it's a Root PPS, false otherwise
*/ */
function isRoot($index) function isRoot($index)
{ {
if (isset($this->_list[$index])) { if (isset($this->_list[$index])) {
@@ -248,28 +248,28 @@ class OLE extends PEAR
return false; return false;
} }
/** /**
* Gives the total number of PPS's found in the OLE container. * Gives the total number of PPS's found in the OLE container.
* *
* @access public * @access public
* @return integer The total number of PPS's found in the OLE container * @return integer The total number of PPS's found in the OLE container
*/ */
function ppsTotal() function ppsTotal()
{ {
return count($this->_list); return count($this->_list);
} }
/** /**
* Gets data from a PPS * Gets data from a PPS
* If there is no PPS for the index given, it will return an empty string. * If there is no PPS for the index given, it will return an empty string.
* *
* @access public * @access public
* @param integer $index The index for the PPS * @param integer $index The index for the PPS
* @param integer $position The position from which to start reading * @param integer $position The position from which to start reading
* (relative to the PPS) * (relative to the PPS)
* @param integer $length The amount of bytes to read (at most) * @param integer $length The amount of bytes to read (at most)
* @return string The binary string containing the data requested * @return string The binary string containing the data requested
*/ */
function getData($index, $position, $length) function getData($index, $position, $length)
{ {
// if position is not valid return empty string // if position is not valid return empty string
@@ -280,15 +280,15 @@ class OLE extends PEAR
fseek($this->_file_handle, $this->_list[$index]->_data + $position); fseek($this->_file_handle, $this->_list[$index]->_data + $position);
return fread($this->_file_handle, $length); return fread($this->_file_handle, $length);
} }
/** /**
* Gets the data length from a PPS * Gets the data length from a PPS
* If there is no PPS for the index given, it will return 0. * If there is no PPS for the index given, it will return 0.
* *
* @access public * @access public
* @param integer $index The index for the PPS * @param integer $index The index for the PPS
* @return integer The amount of bytes in data the PPS has * @return integer The amount of bytes in data the PPS has
*/ */
function getDataLength($index) function getDataLength($index)
{ {
if (isset($this->_list[$index])) { if (isset($this->_list[$index])) {
@@ -298,13 +298,13 @@ class OLE extends PEAR
} }
/** /**
* Utility function to transform ASCII text to Unicode * Utility function to transform ASCII text to Unicode
* *
* @access public * @access public
* @static * @static
* @param string $ascii The ASCII string to transform * @param string $ascii The ASCII string to transform
* @return string The string in Unicode * @return string The string in Unicode
*/ */
static function Asc2Ucs($ascii) static function Asc2Ucs($ascii)
{ {
$rawname = ''; $rawname = '';
@@ -315,14 +315,14 @@ class OLE extends PEAR
} }
/** /**
* Utility function * Utility function
* Returns a string for the OLE container with the date given * Returns a string for the OLE container with the date given
* *
* @access public * @access public
* @static * @static
* @param integer $date A timestamp * @param integer $date A timestamp
* @return string The string for the OLE container * @return string The string for the OLE container
*/ */
static function LocalDate2OLE($date = null) static function LocalDate2OLE($date = null)
{ {
if (!isset($date)) { if (!isset($date)) {
@@ -336,7 +336,7 @@ class OLE extends PEAR
$days = 134774; $days = 134774;
// calculate seconds // calculate seconds
$big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date), $big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date),
date("m",$date),date("d",$date),date("Y",$date)); date("m",$date),date("d",$date),date("Y",$date));
// multiply just to make MS happy // multiply just to make MS happy
$big_date *= 10000000; $big_date *= 10000000;
@@ -363,13 +363,13 @@ class OLE extends PEAR
} }
/** /**
* Returns a timestamp from an OLE container's date * Returns a timestamp from an OLE container's date
* *
* @access public * @access public
* @static * @static
* @param integer $string A binary string with the encoded date * @param integer $string A binary string with the encoded date
* @return string The timestamp corresponding to the string * @return string The timestamp corresponding to the string
*/ */
static function OLE2LocalDate($string) static function OLE2LocalDate($string)
{ {
if (strlen($string) != 8) { if (strlen($string) != 8) {
@@ -399,10 +399,10 @@ class OLE extends PEAR
$big_date = ($high_part*$factor) + $low_part; $big_date = ($high_part*$factor) + $low_part;
// translate to seconds // translate to seconds
$big_date /= 10000000; $big_date /= 10000000;
// days from 1-1-1601 until the beggining of UNIX era // days from 1-1-1601 until the beggining of UNIX era
$days = 134774; $days = 134774;
// translate to seconds from beggining of UNIX era // translate to seconds from beggining of UNIX era
$big_date -= $days*24*3600; $big_date -= $days*24*3600;
return floor($big_date); return floor($big_date);

View File

@@ -24,100 +24,100 @@ require_once($homedir.'/classes/pear/PEAR.php');
require_once($homedir.'/classes/pear/OLE/OLE.php'); require_once($homedir.'/classes/pear/OLE/OLE.php');
/** /**
* Class for creating PPS's for OLE containers * Class for creating PPS's for OLE containers
* *
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @category Structures * @category Structures
* @package OLE * @package OLE
*/ */
class OLE_PPS extends PEAR class OLE_PPS extends PEAR
{ {
/** /**
* The PPS index * The PPS index
* @var integer * @var integer
*/ */
var $No; var $No;
/** /**
* The PPS name (in Unicode) * The PPS name (in Unicode)
* @var string * @var string
*/ */
var $Name; var $Name;
/** /**
* The PPS type. Dir, Root or File * The PPS type. Dir, Root or File
* @var integer * @var integer
*/ */
var $Type; var $Type;
/** /**
* The index of the previous PPS * The index of the previous PPS
* @var integer * @var integer
*/ */
var $PrevPps; var $PrevPps;
/** /**
* The index of the next PPS * The index of the next PPS
* @var integer * @var integer
*/ */
var $NextPps; var $NextPps;
/** /**
* The index of it's first child if this is a Dir or Root PPS * The index of it's first child if this is a Dir or Root PPS
* @var integer * @var integer
*/ */
var $DirPps; var $DirPps;
/** /**
* A timestamp * A timestamp
* @var integer * @var integer
*/ */
var $Time1st; var $Time1st;
/** /**
* A timestamp * A timestamp
* @var integer * @var integer
*/ */
var $Time2nd; var $Time2nd;
/** /**
* Starting block (small or big) for this PPS's data inside the container * Starting block (small or big) for this PPS's data inside the container
* @var integer * @var integer
*/ */
var $_StartBlock; var $_StartBlock;
/** /**
* The size of the PPS's data (in bytes) * The size of the PPS's data (in bytes)
* @var integer * @var integer
*/ */
var $Size; var $Size;
/** /**
* The PPS's data (only used if it's not using a temporary file) * The PPS's data (only used if it's not using a temporary file)
* @var string * @var string
*/ */
var $_data; var $_data;
/** /**
* Array of child PPS's (only used by Root and Dir PPS's) * Array of child PPS's (only used by Root and Dir PPS's)
* @var array * @var array
*/ */
var $children = array(); var $children = array();
/** /**
* The constructor * The constructor
* *
* @access public * @access public
* @param integer $No The PPS index * @param integer $No The PPS index
* @param string $name The PPS name (in Unicode) * @param string $name The PPS name (in Unicode)
* @param integer $type The PPS type. Dir, Root or File * @param integer $type The PPS type. Dir, Root or File
* @param integer $prev The index of the previous PPS * @param integer $prev The index of the previous PPS
* @param integer $next The index of the next PPS * @param integer $next The index of the next PPS
* @param integer $dir The index of it's first child if this is a Dir or Root PPS * @param integer $dir The index of it's first child if this is a Dir or Root PPS
* @param integer $time_1st A timestamp * @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp * @param integer $time_2nd A timestamp
* @param array $children Array containing children PPS for this PPS * @param array $children Array containing children PPS for this PPS
*/ */
function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children) function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
{ {
$this->No = $No; $this->No = $No;
@@ -139,11 +139,11 @@ class OLE_PPS extends PEAR
} }
/** /**
* Returns the amount of data saved for this PPS * Returns the amount of data saved for this PPS
* *
* @access private * @access private
* @return integer The amount of data (in bytes) * @return integer The amount of data (in bytes)
*/ */
function _DataLen() function _DataLen()
{ {
if (!isset($this->_data)) { if (!isset($this->_data)) {
@@ -161,11 +161,11 @@ class OLE_PPS extends PEAR
} }
/** /**
* Returns a string with the PPS's WK (What is a WK?) * Returns a string with the PPS's WK (What is a WK?)
* *
* @access private * @access private
* @return string The binary string * @return string The binary string
*/ */
function _getPpsWk() function _getPpsWk()
{ {
$ret = $this->Name; $ret = $this->Name;
@@ -173,35 +173,35 @@ class OLE_PPS extends PEAR
$ret .= "\x00"; $ret .= "\x00";
} }
$ret .= pack("v", strlen($this->Name) + 2) // 66 $ret .= pack("v", strlen($this->Name) + 2) // 66
. pack("c", $this->Type) // 67 . pack("c", $this->Type) // 67
. pack("c", 0x00) //UK // 68 . pack("c", 0x00) //UK // 68
. pack("V", $this->PrevPps) //Prev // 72 . pack("V", $this->PrevPps) //Prev // 72
. pack("V", $this->NextPps) //Next // 76 . pack("V", $this->NextPps) //Next // 76
. pack("V", $this->DirPps) //Dir // 80 . pack("V", $this->DirPps) //Dir // 80
. "\x00\x09\x02\x00" // 84 . "\x00\x09\x02\x00" // 84
. "\x00\x00\x00\x00" // 88 . "\x00\x00\x00\x00" // 88
. "\xc0\x00\x00\x00" // 92 . "\xc0\x00\x00\x00" // 92
. "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
. "\x00\x00\x00\x00" // 100 . "\x00\x00\x00\x00" // 100
. OLE::LocalDate2OLE($this->Time1st) // 108 . OLE::LocalDate2OLE($this->Time1st) // 108
. OLE::LocalDate2OLE($this->Time2nd) // 116 . OLE::LocalDate2OLE($this->Time2nd) // 116
. pack("V", isset($this->_StartBlock)? . pack("V", isset($this->_StartBlock)?
$this->_StartBlock:0) // 120 $this->_StartBlock:0) // 120
. pack("V", $this->Size) // 124 . pack("V", $this->Size) // 124
. pack("V", 0); // 128 . pack("V", 0); // 128
return $ret; return $ret;
} }
/** /**
* Updates index and pointers to previous, next and children PPS's for this * Updates index and pointers to previous, next and children PPS's for this
* PPS. I don't think it'll work with Dir PPS's. * PPS. I don't think it'll work with Dir PPS's.
* *
* @access private * @access private
* @param array &$pps_array Reference to the array of PPS's for the whole OLE * @param array &$pps_array Reference to the array of PPS's for the whole OLE
* container * container
* @return integer The index for this PPS * @return integer The index for this PPS
*/ */
function _savePpsSetPnt(&$pps_array) function _savePpsSetPnt(&$pps_array)
{ {
$pps_array[count($pps_array)] = &$this; $pps_array[count($pps_array)] = &$this;
$this->No = count($pps_array) - 1; $this->No = count($pps_array) - 1;

View File

@@ -23,50 +23,50 @@ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
require_once ($homedir.'/classes/pear/OLE/PPS.php'); require_once ($homedir.'/classes/pear/OLE/PPS.php');
/** /**
* Class for creating File PPS's for OLE containers * Class for creating File PPS's for OLE containers
* *
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @category Structures * @category Structures
* @package OLE * @package OLE
*/ */
class OLE_PPS_File extends OLE_PPS class OLE_PPS_File extends OLE_PPS
{ {
/** /**
* The temporary dir for storing the OLE file * The temporary dir for storing the OLE file
* @var string * @var string
*/ */
var $_tmp_dir; var $_tmp_dir;
/** /**
* The constructor * The constructor
* *
* @access public * @access public
* @param string $name The name of the file (in Unicode) * @param string $name The name of the file (in Unicode)
* @see OLE::Asc2Ucs() * @see OLE::Asc2Ucs()
*/ */
function OLE_PPS_File($name) function OLE_PPS_File($name)
{ {
$this->_tmp_dir = ''; $this->_tmp_dir = '';
$this->OLE_PPS( $this->OLE_PPS(
null, null,
$name, $name,
OLE_PPS_TYPE_FILE, OLE_PPS_TYPE_FILE,
null, null,
null, null,
null, null,
null, null,
null, null,
'', '',
array()); array());
} }
/** /**
* Sets the temp dir used for storing the OLE file * Sets the temp dir used for storing the OLE file
* *
* @access public * @access public
* @param string $dir The dir to be used as temp dir * @param string $dir The dir to be used as temp dir
* @return true if given dir is valid, false otherwise * @return true if given dir is valid, false otherwise
*/ */
function setTempDir($dir) function setTempDir($dir)
{ {
if (is_dir($dir)) { if (is_dir($dir)) {
@@ -77,11 +77,11 @@ class OLE_PPS_File extends OLE_PPS
} }
/** /**
* Initialization method. Has to be called right after OLE_PPS_File(). * Initialization method. Has to be called right after OLE_PPS_File().
* *
* @access public * @access public
* @return mixed true on success. PEAR_Error on failure * @return mixed true on success. PEAR_Error on failure
*/ */
function init() function init()
{ {
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File"); $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File");
@@ -94,13 +94,13 @@ class OLE_PPS_File extends OLE_PPS
fseek($this->_PPS_FILE, 0); fseek($this->_PPS_FILE, 0);
} }
} }
/** /**
* Append data to PPS * Append data to PPS
* *
* @access public * @access public
* @param string $data The data to append * @param string $data The data to append
*/ */
function append($data) function append($data)
{ {
if ($this->_PPS_FILE) { if ($this->_PPS_FILE) {

View File

@@ -23,50 +23,50 @@ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
require_once ($homedir.'/classes/pear/OLE/PPS.php'); require_once ($homedir.'/classes/pear/OLE/PPS.php');
/** /**
* Class for creating Root PPS's for OLE containers * Class for creating Root PPS's for OLE containers
* *
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @category Structures * @category Structures
* @package OLE * @package OLE
*/ */
class OLE_PPS_Root extends OLE_PPS class OLE_PPS_Root extends OLE_PPS
{ {
/** /**
* The temporary dir for storing the OLE file * The temporary dir for storing the OLE file
* @var string * @var string
*/ */
var $_tmp_dir; var $_tmp_dir;
/** /**
* Constructor * Constructor
* *
* @access public * @access public
* @param integer $time_1st A timestamp * @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp * @param integer $time_2nd A timestamp
*/ */
function OLE_PPS_Root($time_1st, $time_2nd, $raChild) function OLE_PPS_Root($time_1st, $time_2nd, $raChild)
{ {
$this->_tmp_dir = ''; $this->_tmp_dir = '';
$this->OLE_PPS( $this->OLE_PPS(
null, null,
OLE::Asc2Ucs('Root Entry'), OLE::Asc2Ucs('Root Entry'),
OLE_PPS_TYPE_ROOT, OLE_PPS_TYPE_ROOT,
null, null,
null, null,
null, null,
$time_1st, $time_1st,
$time_2nd, $time_2nd,
null, null,
$raChild); $raChild);
} }
/** /**
* Sets the temp dir used for storing the OLE file * Sets the temp dir used for storing the OLE file
* *
* @access public * @access public
* @param string $dir The dir to be used as temp dir * @param string $dir The dir to be used as temp dir
* @return true if given dir is valid, false otherwise * @return true if given dir is valid, false otherwise
*/ */
function setTempDir($dir) function setTempDir($dir)
{ {
if (is_dir($dir)) { if (is_dir($dir)) {
@@ -77,22 +77,22 @@ class OLE_PPS_Root extends OLE_PPS
} }
/** /**
* Method for saving the whole OLE container (including files). * Method for saving the whole OLE container (including files).
* In fact, if called with an empty argument (or '-'), it saves to a * In fact, if called with an empty argument (or '-'), it saves to a
* temporary file and then outputs it's contents to stdout. * temporary file and then outputs it's contents to stdout.
* *
* @param string $filename The name of the file where to save the OLE container * @param string $filename The name of the file where to save the OLE container
* @access public * @access public
* @return mixed true on success, PEAR_Error on failure * @return mixed true on success, PEAR_Error on failure
*/ */
function save($filename) function save($filename)
{ {
// Initial Setting for saving // Initial Setting for saving
$this->_BIG_BLOCK_SIZE = pow(2, $this->_BIG_BLOCK_SIZE = pow(2,
((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9)); ((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9));
$this->_SMALL_BLOCK_SIZE= pow(2, $this->_SMALL_BLOCK_SIZE= pow(2,
((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6)); ((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
// Open temp file if we are sending output to stdout // Open temp file if we are sending output to stdout
if (($filename == '-') or ($filename == '')) if (($filename == '-') or ($filename == ''))
{ {
@@ -116,10 +116,10 @@ class OLE_PPS_Root extends OLE_PPS
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo); list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
// Save Header // Save Header
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); $this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
// Make Small Data string (write SBD) // Make Small Data string (write SBD)
$this->_data = $this->_makeSmallData($aList); $this->_data = $this->_makeSmallData($aList);
// Write BB // Write BB
$this->_saveBigData($iSBDcnt, $aList); $this->_saveBigData($iSBDcnt, $aList);
// Write PPS // Write PPS
@@ -142,13 +142,13 @@ class OLE_PPS_Root extends OLE_PPS
} }
/** /**
* Calculate some numbers * Calculate some numbers
* *
* @access private * @access private
* @param array $raList Reference to an array of PPS's * @param array $raList Reference to an array of PPS's
* @return array The array of numbers * @return array The array of numbers
*/ */
function _calcSize(&$raList) function _calcSize(&$raList)
{ {
// Calculate Basic Setting // Calculate Basic Setting
list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0); list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0);
@@ -159,11 +159,11 @@ class OLE_PPS_Root extends OLE_PPS
$raList[$i]->Size = $raList[$i]->_DataLen(); $raList[$i]->Size = $raList[$i]->_DataLen();
if($raList[$i]->Size < OLE_DATA_SIZE_SMALL) { if($raList[$i]->Size < OLE_DATA_SIZE_SMALL) {
$iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) $iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0); + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
} }
else { else {
$iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) + $iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0)); (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
} }
} }
} }
@@ -171,22 +171,22 @@ class OLE_PPS_Root extends OLE_PPS
$iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE); $iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
$iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0); $iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0);
$iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) + $iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) +
(( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0)); (( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0));
$iCnt = count($raList); $iCnt = count($raList);
$iBdCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE; $iBdCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE;
$iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0)); $iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0));
return array($iSBDcnt, $iBBcnt, $iPPScnt); return array($iSBDcnt, $iBBcnt, $iPPScnt);
} }
/** /**
* Helper function for caculating a magic value for block sizes * Helper function for caculating a magic value for block sizes
* *
* @access private * @access private
* @param integer $i2 The argument * @param integer $i2 The argument
* @see save() * @see save()
* @return integer * @return integer
*/ */
function _adjust2($i2) function _adjust2($i2)
{ {
$iWk = log($i2)/log(2); $iWk = log($i2)/log(2);
@@ -194,27 +194,27 @@ class OLE_PPS_Root extends OLE_PPS
} }
/** /**
* Save OLE header * Save OLE header
* *
* @access private * @access private
* @param integer $iSBDcnt * @param integer $iSBDcnt
* @param integer $iBBcnt * @param integer $iBBcnt
* @param integer $iPPScnt * @param integer $iPPScnt
*/ */
function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt) function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt)
{ {
$FILE = $this->_FILEH_; $FILE = $this->_FILEH_;
// Calculate Basic Setting // Calculate Basic Setting
$iBlCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE; $iBlCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE; $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
$iBdExL = 0; $iBdExL = 0;
$iAll = $iBBcnt + $iPPScnt + $iSBDcnt; $iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
$iAllW = $iAll; $iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0); $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0); $iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
// Calculate BD count // Calculate BD count
if ($iBdCnt >$i1stBdL) if ($iBdCnt >$i1stBdL)
{ {
@@ -229,7 +229,7 @@ class OLE_PPS_Root extends OLE_PPS
} }
} }
} }
// Save Header // Save Header
fwrite($FILE, fwrite($FILE,
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
@@ -245,49 +245,49 @@ class OLE_PPS_Root extends OLE_PPS
. pack("v", 0) . pack("v", 0)
. "\x00\x00\x00\x00" . "\x00\x00\x00\x00"
. "\x00\x00\x00\x00" . "\x00\x00\x00\x00"
. pack("V", $iBdCnt) . pack("V", $iBdCnt)
. pack("V", $iBBcnt+$iSBDcnt) //ROOT START . pack("V", $iBBcnt+$iSBDcnt) //ROOT START
. pack("V", 0) . pack("V", 0)
. pack("V", 0x1000) . pack("V", 0x1000)
. pack("V", 0) //Small Block Depot . pack("V", 0) //Small Block Depot
. pack("V", 1) . pack("V", 1)
); );
// Extra BDList Start, Count // Extra BDList Start, Count
if ($iBdCnt < $i1stBdL) if ($iBdCnt < $i1stBdL)
{ {
fwrite($FILE, fwrite($FILE,
pack("V", -2). // Extra BDList Start pack("V", -2). // Extra BDList Start
pack("V", 0) // Extra BDList Count pack("V", 0) // Extra BDList Count
); );
} }
else else
{ {
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL)); fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
} }
// BDList // BDList
for ($i=0; $i<$i1stBdL and $i < $iBdCnt; $i++) { for ($i=0; $i<$i1stBdL and $i < $iBdCnt; $i++) {
fwrite($FILE, pack("V", $iAll+$i)); fwrite($FILE, pack("V", $iAll+$i));
} }
if ($i < $i1stBdL) if ($i < $i1stBdL)
{ {
for ($j = 0; $j < ($i1stBdL-$i); $j++) { for ($j = 0; $j < ($i1stBdL-$i); $j++) {
fwrite($FILE, (pack("V", -1))); fwrite($FILE, (pack("V", -1)));
} }
} }
} }
/** /**
* Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL) * Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL)
* *
* @access private * @access private
* @param integer $iStBlk * @param integer $iStBlk
* @param array &$raList Reference to array of PPS's * @param array &$raList Reference to array of PPS's
*/ */
function _saveBigData($iStBlk, &$raList) function _saveBigData($iStBlk, &$raList)
{ {
$FILE = $this->_FILEH_; $FILE = $this->_FILEH_;
// cycle through PPS's // cycle through PPS's
for ($i = 0; $i < count($raList); $i++) for ($i = 0; $i < count($raList); $i++)
{ {
@@ -295,7 +295,7 @@ class OLE_PPS_Root extends OLE_PPS
{ {
$raList[$i]->Size = $raList[$i]->_DataLen(); $raList[$i]->Size = $raList[$i]->_DataLen();
if(($raList[$i]->Size >= OLE_DATA_SIZE_SMALL) or if(($raList[$i]->Size >= OLE_DATA_SIZE_SMALL) or
(($raList[$i]->Type == OLE_PPS_TYPE_ROOT) and isset($raList[$i]->_data))) (($raList[$i]->Type == OLE_PPS_TYPE_ROOT) and isset($raList[$i]->_data)))
{ {
// Write Data // Write Data
if(isset($raList[$i]->_PPS_FILE)) if(isset($raList[$i]->_PPS_FILE))
@@ -311,7 +311,7 @@ class OLE_PPS_Root extends OLE_PPS
else { else {
fwrite($FILE, $raList[$i]->_data); fwrite($FILE, $raList[$i]->_data);
} }
if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)
{ {
for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); $j++) { for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); $j++) {
@@ -320,9 +320,9 @@ class OLE_PPS_Root extends OLE_PPS
} }
// Set For PPS // Set For PPS
$raList[$i]->_StartBlock = $iStBlk; $raList[$i]->_StartBlock = $iStBlk;
$iStBlk += $iStBlk +=
(floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) + (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0)); (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
} }
// Close file for each PPS, and unlink it // Close file for each PPS, and unlink it
if (isset($raList[$i]->_PPS_FILE)) if (isset($raList[$i]->_PPS_FILE))
@@ -336,17 +336,17 @@ class OLE_PPS_Root extends OLE_PPS
} }
/** /**
* get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL) * get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL)
* *
* @access private * @access private
* @param array &$raList Reference to array of PPS's * @param array &$raList Reference to array of PPS's
*/ */
function _makeSmallData(&$raList) function _makeSmallData(&$raList)
{ {
$sRes = ''; $sRes = '';
$FILE = $this->_FILEH_; $FILE = $this->_FILEH_;
$iSmBlk = 0; $iSmBlk = 0;
for ($i = 0; $i < count($raList); $i++) for ($i = 0; $i < count($raList); $i++)
{ {
// Make SBD, small data string // Make SBD, small data string
@@ -358,13 +358,13 @@ class OLE_PPS_Root extends OLE_PPS
if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL) if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL)
{ {
$iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) $iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0); + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
// Add to SBD // Add to SBD
for ($j = 0; $j < ($iSmbCnt-1); $j++) { for ($j = 0; $j < ($iSmbCnt-1); $j++) {
fwrite($FILE, pack("V", $j+$iSmBlk+1)); fwrite($FILE, pack("V", $j+$iSmBlk+1));
} }
fwrite($FILE, pack("V", -2)); fwrite($FILE, pack("V", -2));
// Add to Data String(this will be written for RootEntry) // Add to Data String(this will be written for RootEntry)
if ($raList[$i]->_PPS_FILE) if ($raList[$i]->_PPS_FILE)
{ {
@@ -399,12 +399,12 @@ class OLE_PPS_Root extends OLE_PPS
} }
/** /**
* Saves all the PPS's WKs * Saves all the PPS's WKs
* *
* @access private * @access private
* @param array $raList Reference to an array with all PPS's * @param array $raList Reference to an array with all PPS's
*/ */
function _savePps(&$raList) function _savePps(&$raList)
{ {
// Save each PPS WK // Save each PPS WK
for ($i = 0; $i < count($raList); $i++) { for ($i = 0; $i < count($raList); $i++) {
@@ -422,20 +422,20 @@ class OLE_PPS_Root extends OLE_PPS
} }
/** /**
* Saving Big Block Depot * Saving Big Block Depot
* *
* @access private * @access private
* @param integer $iSbdSize * @param integer $iSbdSize
* @param integer $iBsize * @param integer $iBsize
* @param integer $iPpsCnt * @param integer $iPpsCnt
*/ */
function _saveBbd($iSbdSize, $iBsize, $iPpsCnt) function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
{ {
$FILE = $this->_FILEH_; $FILE = $this->_FILEH_;
// Calculate Basic Setting // Calculate Basic Setting
$iBbCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE; $iBbCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE; $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
$iBdExL = 0; $iBdExL = 0;
$iAll = $iBsize + $iPpsCnt + $iSbdSize; $iAll = $iBsize + $iPpsCnt + $iSbdSize;
$iAllW = $iAll; $iAllW = $iAll;
@@ -455,7 +455,7 @@ class OLE_PPS_Root extends OLE_PPS
} }
} }
} }
// Making BD // Making BD
// Set for SBD // Set for SBD
if ($iSbdSize > 0) if ($iSbdSize > 0)
@@ -470,7 +470,7 @@ class OLE_PPS_Root extends OLE_PPS
fwrite($FILE, pack("V", $i+$iSbdSize+1)); fwrite($FILE, pack("V", $i+$iSbdSize+1));
} }
fwrite($FILE, pack("V", -2)); fwrite($FILE, pack("V", -2));
// Set for PPS // Set for PPS
for ($i = 0; $i<($iPpsCnt-1); $i++) { for ($i = 0; $i<($iPpsCnt-1); $i++) {
fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1)); fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1));
@@ -509,7 +509,7 @@ class OLE_PPS_Root extends OLE_PPS
if (($iBdCnt-$i1stBdL) % ($iBbCnt-1)) if (($iBdCnt-$i1stBdL) % ($iBbCnt-1))
{ {
for ($i = 0; $i < (($iBbCnt-1) - (($iBdCnt-$i1stBdL) % ($iBbCnt-1))); $i++) { for ($i = 0; $i < (($iBbCnt-1) - (($iBdCnt-$i1stBdL) % ($iBbCnt-1))); $i++) {
fwrite($FILE, pack("V", -1)); fwrite($FILE, pack("V", -1));
} }
} }
fwrite($FILE, pack("V", -2)); fwrite($FILE, pack("V", -2));

View File

@@ -40,7 +40,7 @@ define('PEAR_ERROR_CALLBACK', 16);
define('PEAR_ERROR_EXCEPTION', 32); define('PEAR_ERROR_EXCEPTION', 32);
/**#@-*/ /**#@-*/
define('PEAR_ZE2', (function_exists('version_compare') && define('PEAR_ZE2', (function_exists('version_compare') &&
version_compare(zend_version(), "2-dev", "ge"))); version_compare(zend_version(), "2-dev", "ge")));
if (substr(PHP_OS, 0, 3) == 'WIN') { if (substr(PHP_OS, 0, 3) == 'WIN') {
define('OS_WINDOWS', true); define('OS_WINDOWS', true);
@@ -216,17 +216,17 @@ class PEAR
// {{{ getStaticProperty() // {{{ getStaticProperty()
/** /**
* If you have a class that's mostly/entirely static, and you need static * If you have a class that's mostly/entirely static, and you need static
* properties, you can use this method to simulate them. Eg. in your method(s) * properties, you can use this method to simulate them. Eg. in your method(s)
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
* You MUST use a reference, or they will not persist! * You MUST use a reference, or they will not persist!
* *
* @access public * @access public
* @param string $class The calling classname, to prevent clashes * @param string $class The calling classname, to prevent clashes
* @param string $var The variable to retrieve. * @param string $var The variable to retrieve.
* @return mixed A reference to the variable. If not set it will be * @return mixed A reference to the variable. If not set it will be
* auto initialised to NULL. * auto initialised to NULL.
*/ */
function &getStaticProperty($class, $var) function &getStaticProperty($class, $var)
{ {
static $properties; static $properties;
@@ -237,14 +237,14 @@ class PEAR
// {{{ registerShutdownFunc() // {{{ registerShutdownFunc()
/** /**
* Use this function to register a shutdown method for static * Use this function to register a shutdown method for static
* classes. * classes.
* *
* @access public * @access public
* @param mixed $func The function name (or array of class/method) to call * @param mixed $func The function name (or array of class/method) to call
* @param mixed $args The arguments to pass to the function * @param mixed $args The arguments to pass to the function
* @return void * @return void
*/ */
function registerShutdownFunc($func, $args = array()) function registerShutdownFunc($func, $args = array())
{ {
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
@@ -263,7 +263,7 @@ class PEAR
* $code is an integer and $obj->getCode() == $code * $code is an integer and $obj->getCode() == $code
* @access public * @access public
* @return bool true if parameter is an error * @return bool true if parameter is an error
*/ */
function isError($data, $code = null) function isError($data, $code = null)
{ {
if ($data instanceof PEAR_Error) { if ($data instanceof PEAR_Error) {
@@ -510,12 +510,12 @@ class PEAR
* @since PHP 4.0.5 * @since PHP 4.0.5
*/ */
function &raiseError($message = null, function &raiseError($message = null,
$code = null, $code = null,
$mode = null, $mode = null,
$options = null, $options = null,
$userinfo = null, $userinfo = null,
$error_class = null, $error_class = null,
$skipmsg = false) $skipmsg = false)
{ {
// The error is yet a PEAR error object // The error is yet a PEAR error object
if (is_object($message)) { if (is_object($message)) {
@@ -528,8 +528,8 @@ class PEAR
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
if ($exp[0] == "*" || if ($exp[0] == "*" ||
(is_int(reset($exp)) && in_array($code, $exp)) || (is_int(reset($exp)) && in_array($code, $exp)) ||
(is_string(reset($exp)) && in_array($message, $exp))) { (is_string(reset($exp)) && in_array($message, $exp))) {
$mode = PEAR_ERROR_RETURN; $mode = PEAR_ERROR_RETURN;
} }
} }
@@ -539,7 +539,7 @@ class PEAR
if (isset($this) && isset($this->_default_error_mode)) { if (isset($this) && isset($this->_default_error_mode)) {
$mode = $this->_default_error_mode; $mode = $this->_default_error_mode;
$options = $this->_default_error_options; $options = $this->_default_error_options;
// Global error handler // Global error handler
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
$mode = $GLOBALS['_PEAR_default_error_mode']; $mode = $GLOBALS['_PEAR_default_error_mode'];
$options = $GLOBALS['_PEAR_default_error_options']; $options = $GLOBALS['_PEAR_default_error_options'];
@@ -573,8 +573,8 @@ class PEAR
* *
*/ */
function &throwError($message = null, function &throwError($message = null,
$code = null, $code = null,
$userinfo = null) $userinfo = null)
{ {
if (isset($this) && is_a($this, 'PEAR')) { if (isset($this) && is_a($this, 'PEAR')) {
$a = &$this->raiseError($message, $code, null, null, $userinfo); $a = &$this->raiseError($message, $code, null, null, $userinfo);
@@ -696,12 +696,12 @@ class PEAR
// {{{ popErrorHandling() // {{{ popErrorHandling()
/** /**
* Pop the last error handler used * Pop the last error handler used
* *
* @return bool Always true * @return bool Always true
* *
* @see PEAR::pushErrorHandling * @see PEAR::pushErrorHandling
*/ */
function popErrorHandling() function popErrorHandling()
{ {
$stack = &$GLOBALS['_PEAR_error_handler_stack']; $stack = &$GLOBALS['_PEAR_error_handler_stack'];
@@ -720,12 +720,12 @@ class PEAR
// {{{ loadExtension() // {{{ loadExtension()
/** /**
* OS independant PHP extension load. Remember to take care * OS independant PHP extension load. Remember to take care
* on the correct extension name for case sensitive OSes. * on the correct extension name for case sensitive OSes.
* *
* @param string $ext The extension name * @param string $ext The extension name
* @return bool Success or not on the dl() call * @return bool Success or not on the dl() call
*/ */
function loadExtension($ext) function loadExtension($ext)
{ {
if (!extension_loaded($ext)) { if (!extension_loaded($ext)) {
@@ -758,7 +758,7 @@ function _PEAR_call_destructors()
{ {
global $_PEAR_destructor_object_list; global $_PEAR_destructor_object_list;
if (is_array($_PEAR_destructor_object_list) && if (is_array($_PEAR_destructor_object_list) &&
sizeof($_PEAR_destructor_object_list)) sizeof($_PEAR_destructor_object_list))
{ {
reset($_PEAR_destructor_object_list); reset($_PEAR_destructor_object_list);
if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) { if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {
@@ -843,7 +843,7 @@ class PEAR_Error
* *
*/ */
function PEAR_Error($message = 'unknown error', $code = null, function PEAR_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null) $mode = null, $options = null, $userinfo = null)
{ {
if ($mode === null) { if ($mode === null) {
$mode = PEAR_ERROR_RETURN; $mode = PEAR_ERROR_RETURN;
@@ -952,10 +952,10 @@ class PEAR_Error
* @return int error code * @return int error code
* @access public * @access public
*/ */
function getCode() function getCode()
{ {
return $this->code; return $this->code;
} }
// }}} // }}}
// {{{ getType() // {{{ getType()
@@ -1045,22 +1045,22 @@ class PEAR_Error
function toString() { function toString() {
$modes = array(); $modes = array();
$levels = array(E_USER_NOTICE => 'notice', $levels = array(E_USER_NOTICE => 'notice',
E_USER_WARNING => 'warning', E_USER_WARNING => 'warning',
E_USER_ERROR => 'error'); E_USER_ERROR => 'error');
if ($this->mode & PEAR_ERROR_CALLBACK) { if ($this->mode & PEAR_ERROR_CALLBACK) {
if (is_array($this->callback)) { if (is_array($this->callback)) {
$callback = (is_object($this->callback[0]) ? $callback = (is_object($this->callback[0]) ?
strtolower(get_class($this->callback[0])) : strtolower(get_class($this->callback[0])) :
$this->callback[0]) . '::' . $this->callback[0]) . '::' .
$this->callback[1]; $this->callback[1];
} else { } else {
$callback = $this->callback; $callback = $this->callback;
} }
return sprintf('[%s: message="%s" code=%d mode=callback '. return sprintf('[%s: message="%s" code=%d mode=callback '.
'callback=%s prefix="%s" info="%s"]', 'callback=%s prefix="%s" info="%s"]',
strtolower(get_class($this)), $this->message, $this->code, strtolower(get_class($this)), $this->message, $this->code,
$callback, $this->error_message_prefix, $callback, $this->error_message_prefix,
$this->userinfo); $this->userinfo);
} }
if ($this->mode & PEAR_ERROR_PRINT) { if ($this->mode & PEAR_ERROR_PRINT) {
$modes[] = 'print'; $modes[] = 'print';
@@ -1076,10 +1076,10 @@ class PEAR_Error
} }
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
'prefix="%s" info="%s"]', 'prefix="%s" info="%s"]',
strtolower(get_class($this)), $this->message, $this->code, strtolower(get_class($this)), $this->message, $this->code,
implode("|", $modes), $levels[$this->level], implode("|", $modes), $levels[$this->level],
$this->error_message_prefix, $this->error_message_prefix,
$this->userinfo); $this->userinfo);
} }
// }}} // }}}

View File

@@ -1,56 +1,56 @@
<?php <?php
/* /*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com> * Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
* *
* PERL Spreadsheet::WriteExcel module. * PERL Spreadsheet::WriteExcel module.
* *
* The author of the Spreadsheet::WriteExcel module is John McNamara * The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org> * <jmcnamara@cpan.org>
* *
* I _DO_ maintain this code, and John McNamara has nothing to do with the * I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this * porting of this code to PHP. Any questions directly related to this
* class library should be directed to me. * class library should be directed to me.
* *
* License Information: * License Information:
* *
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
require_once $homedir.'/classes/pear/PEAR.php'; require_once $homedir.'/classes/pear/PEAR.php';
require_once $homedir.'/classes/pear/Spreadsheet/Excel/Writer/Workbook.php'; require_once $homedir.'/classes/pear/Spreadsheet/Excel/Writer/Workbook.php';
/** /**
* Class for writing Excel Spreadsheets. This class should change COMPLETELY. * Class for writing Excel Spreadsheets. This class should change COMPLETELY.
* *
* @author Xavier Noguer <xnoguer@rezebra.com> * @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats * @category FileFormats
* @package Spreadsheet_Excel_Writer * @package Spreadsheet_Excel_Writer
*/ */
class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
{ {
/** /**
* The constructor. It just creates a Workbook * The constructor. It just creates a Workbook
* *
* @param string $filename The optional filename for the Workbook. * @param string $filename The optional filename for the Workbook.
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created * @return Spreadsheet_Excel_Writer_Workbook The Workbook created
*/ */
function Spreadsheet_Excel_Writer($filename = '') function Spreadsheet_Excel_Writer($filename = '')
{ {
$this->_filename = $filename; $this->_filename = $filename;
@@ -58,11 +58,11 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
} }
/** /**
* Send HTTP headers for the Excel file. * Send HTTP headers for the Excel file.
* *
* @param string $filename The filename to use for HTTP headers * @param string $filename The filename to use for HTTP headers
* @access public * @access public
*/ */
function send($filename) function send($filename)
{ {
header("Content-type: application/vnd.ms-excel"); header("Content-type: application/vnd.ms-excel");
@@ -73,15 +73,15 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
} }
/** /**
* Utility function for writing formulas * Utility function for writing formulas
* Converts a cell's coordinates to the A1 format. * Converts a cell's coordinates to the A1 format.
* *
* @access public * @access public
* @static * @static
* @param integer $row Row for the cell to convert (0-indexed). * @param integer $row Row for the cell to convert (0-indexed).
* @param integer $col Column for the cell to convert (0-indexed). * @param integer $col Column for the cell to convert (0-indexed).
* @return string The cell identifier in A1 format * @return string The cell identifier in A1 format
*/ */
function rowcolToCell($row, $col) function rowcolToCell($row, $col)
{ {
if ($col > 255) { //maximum column value exceeded if ($col > 255) { //maximum column value exceeded

View File

@@ -1,95 +1,95 @@
<?php <?php
/* /*
* Module written/ported by Xavier Noguer <xnoguer@php.net> * Module written/ported by Xavier Noguer <xnoguer@php.net>
* *
* The majority of this is _NOT_ my code. I simply ported it from the * The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module. * PERL Spreadsheet::WriteExcel module.
* *
* The author of the Spreadsheet::WriteExcel module is John McNamara * The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org> * <jmcnamara@cpan.org>
* *
* I _DO_ maintain this code, and John McNamara has nothing to do with the * I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this * porting of this code to PHP. Any questions directly related to this
* class library should be directed to me. * class library should be directed to me.
* *
* License Information: * License Information:
* *
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net * Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
require_once $homedir.'/classes/pear/PEAR.php'; require_once $homedir.'/classes/pear/PEAR.php';
/** /**
* Class for writing Excel BIFF records. * Class for writing Excel BIFF records.
* *
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation): * From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
* *
* BIFF (BInary File Format) is the file format in which Excel documents are * BIFF (BInary File Format) is the file format in which Excel documents are
* saved on disk. A BIFF file is a complete description of an Excel document. * saved on disk. A BIFF file is a complete description of an Excel document.
* BIFF files consist of sequences of variable-length records. There are many * BIFF files consist of sequences of variable-length records. There are many
* different types of BIFF records. For example, one record type describes a * different types of BIFF records. For example, one record type describes a
* formula entered into a cell; one describes the size and location of a * formula entered into a cell; one describes the size and location of a
* window into a document; another describes a picture format. * window into a document; another describes a picture format.
* *
* @author Xavier Noguer <xnoguer@php.net> * @author Xavier Noguer <xnoguer@php.net>
* @category FileFormats * @category FileFormats
* @package Spreadsheet_Excel_Writer * @package Spreadsheet_Excel_Writer
*/ */
class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
{ {
/** /**
* The BIFF/Excel version (5). * The BIFF/Excel version (5).
* @var integer * @var integer
*/ */
var $_BIFF_version = 0x0500; var $_BIFF_version = 0x0500;
/** /**
* The byte order of this architecture. 0 => little endian, 1 => big endian * The byte order of this architecture. 0 => little endian, 1 => big endian
* @var integer * @var integer
*/ */
var $_byte_order; var $_byte_order;
/** /**
* The string containing the data of the BIFF stream * The string containing the data of the BIFF stream
* @var string * @var string
*/ */
var $_data; var $_data;
/** /**
* The size of the data in bytes. Should be the same as strlen($this->_data) * The size of the data in bytes. Should be the same as strlen($this->_data)
* @var integer * @var integer
*/ */
var $_datasize; var $_datasize;
/** /**
* The maximun length for a BIFF record. See _addContinue() * The maximun length for a BIFF record. See _addContinue()
* @var integer * @var integer
* @see _addContinue() * @see _addContinue()
*/ */
var $_limit; var $_limit;
/** /**
* Constructor * Constructor
* *
* @access public * @access public
*/ */
function Spreadsheet_Excel_Writer_BIFFwriter() function Spreadsheet_Excel_Writer_BIFFwriter()
{ {
$this->_byte_order = ''; $this->_byte_order = '';
@@ -101,11 +101,11 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
/** /**
* Determine the byte order and store it as class data to avoid * Determine the byte order and store it as class data to avoid
* recalculating it for each call to new(). * recalculating it for each call to new().
* *
* @access private * @access private
*/ */
function _setByteOrder() function _setByteOrder()
{ {
// Check if "pack" gives the required IEEE 64bit float // Check if "pack" gives the required IEEE 64bit float
@@ -124,11 +124,11 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
/** /**
* General storage function * General storage function
* *
* @param string $data binary data to prepend * @param string $data binary data to prepend
* @access private * @access private
*/ */
function _prepend($data) function _prepend($data)
{ {
if (strlen($data) > $this->_limit) { if (strlen($data) > $this->_limit) {
@@ -139,11 +139,11 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
/** /**
* General storage function * General storage function
* *
* @param string $data binary data to append * @param string $data binary data to append
* @access private * @access private
*/ */
function _append($data) function _append($data)
{ {
if (strlen($data) > $this->_limit) { if (strlen($data) > $this->_limit) {
@@ -154,13 +154,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
/** /**
* Writes Excel BOF record to indicate the beginning of a stream or * Writes Excel BOF record to indicate the beginning of a stream or
* sub-stream in the BIFF file. * sub-stream in the BIFF file.
* *
* @param integer $type Type of BIFF file to write: 0x0005 Workbook, * @param integer $type Type of BIFF file to write: 0x0005 Workbook,
* 0x0010 Worksheet. * 0x0010 Worksheet.
* @access private * @access private
*/ */
function _storeBof($type) function _storeBof($type)
{ {
$record = 0x0809; // Record identifier $record = 0x0809; // Record identifier
@@ -186,10 +186,10 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
/** /**
* Writes Excel EOF record to indicate the end of a BIFF stream. * Writes Excel EOF record to indicate the end of a BIFF stream.
* *
* @access private * @access private
*/ */
function _storeEof() function _storeEof()
{ {
$record = 0x000A; // Record identifier $record = 0x000A; // Record identifier
@@ -199,17 +199,17 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
/** /**
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In * Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits * Excel 97 the limit is 8228 bytes. Records that are longer than these limits
* must be split up into CONTINUE blocks. * must be split up into CONTINUE blocks.
* *
* This function takes a long BIFF record and inserts CONTINUE records as * This function takes a long BIFF record and inserts CONTINUE records as
* necessary. * necessary.
* *
* @param string $data The original binary data to be written * @param string $data The original binary data to be written
* @return string A very convenient string of continue blocks * @return string A very convenient string of continue blocks
* @access private * @access private
*/ */
function _addContinue($data) function _addContinue($data)
{ {
$limit = $this->_limit; $limit = $this->_limit;

View File

@@ -1,26 +1,26 @@
<?php <?php
/* /*
* Module written by Herman Kuiper <herman@ozuzo.net> * Module written by Herman Kuiper <herman@ozuzo.net>
* *
* License Information: * License Information:
* *
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
//require_once('PEAR.php'); //require_once('PEAR.php');
@@ -39,32 +39,32 @@ define("OP_GTE", 0x06);
define("OP_LTE", 0x07); define("OP_LTE", 0x07);
/** /**
* Baseclass for generating Excel DV records (validations) * Baseclass for generating Excel DV records (validations)
* *
* @author Herman Kuiper * @author Herman Kuiper
* @category FileFormats * @category FileFormats
* @package Spreadsheet_Excel_Writer * @package Spreadsheet_Excel_Writer
*/ */
class Spreadsheet_Excel_Writer_Validator class Spreadsheet_Excel_Writer_Validator
{ {
var $_type; var $_type;
var $_style; var $_style;
var $_fixedList; var $_fixedList;
var $_blank; var $_blank;
var $_incell; var $_incell;
var $_showprompt; var $_showprompt;
var $_showerror; var $_showerror;
var $_title_prompt; var $_title_prompt;
var $_descr_prompt; var $_descr_prompt;
var $_title_error; var $_title_error;
var $_descr_error; var $_descr_error;
var $_operator; var $_operator;
var $_formula1; var $_formula1;
var $_formula2; var $_formula2;
/** /**
* The parser from the workbook. Used to parse validation formulas also * The parser from the workbook. Used to parse validation formulas also
* @var Spreadsheet_Excel_Writer_Parser * @var Spreadsheet_Excel_Writer_Parser
*/ */
var $_parser; var $_parser;
function Spreadsheet_Excel_Writer_Validator(&$parser) function Spreadsheet_Excel_Writer_Validator(&$parser)
@@ -86,29 +86,29 @@ class Spreadsheet_Excel_Writer_Validator
$this->_formula2 = ''; $this->_formula2 = '';
} }
function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
{ {
$this->_showprompt = $showPrompt; $this->_showprompt = $showPrompt;
$this->_title_prompt = $promptTitle; $this->_title_prompt = $promptTitle;
$this->_descr_prompt = $promptDescription; $this->_descr_prompt = $promptDescription;
} }
function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
{ {
$this->_showerror = $showError; $this->_showerror = $showError;
$this->_title_error = $errorTitle; $this->_title_error = $errorTitle;
$this->_descr_error = $errorDescription; $this->_descr_error = $errorDescription;
} }
function allowBlank() function allowBlank()
{ {
$this->_blank = true; $this->_blank = true;
} }
function onInvalidStop() function onInvalidStop()
{ {
$this->_style = 0x00; $this->_style = 0x00;
} }
function onInvalidWarn() function onInvalidWarn()
{ {
@@ -169,62 +169,62 @@ class Spreadsheet_Excel_Writer_Validator
if ($this->_showerror) { if ($this->_showerror) {
$options |= 0x80000; $options |= 0x80000;
} }
$options |= $this->_operator << 20; $options |= $this->_operator << 20;
return $options; return $options;
} }
function _getData() function _getData()
{ {
$title_prompt_len = strlen($this->_title_prompt); $title_prompt_len = strlen($this->_title_prompt);
$descr_prompt_len = strlen($this->_descr_prompt); $descr_prompt_len = strlen($this->_descr_prompt);
$title_error_len = strlen($this->_title_error); $title_error_len = strlen($this->_title_error);
$descr_error_len = strlen($this->_descr_error); $descr_error_len = strlen($this->_descr_error);
$formula1_size = strlen($this->_formula1); $formula1_size = strlen($this->_formula1);
$formula2_size = strlen($this->_formula2); $formula2_size = strlen($this->_formula2);
$data = pack("V", $this->_getOptions()); $data = pack("V", $this->_getOptions());
$data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt; $data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
$data .= pack("vC", $title_error_len, 0x00) . $this->_title_error; $data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
$data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt; $data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
$data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error; $data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
$data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1; $data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
$data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2; $data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
return $data; return $data;
} }
} }
/*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation /*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation
{ {
function Spreadsheet_Excel_Writer_Validation_list() function Spreadsheet_Excel_Writer_Validation_list()
{ {
parent::Spreadsheet_Excel_Writer_Validation(); parent::Spreadsheet_Excel_Writer_Validation();
$this->_type = 0x03; $this->_type = 0x03;
} }
function setList($source, $incell = true) function setList($source, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
$this->_fixedList = true; $this->_fixedList = true;
$source = implode("\x00", $source); $source = implode("\x00", $source);
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
} }
function setRow($row, $col1, $col2, $incell = true) function setRow($row, $col1, $col2, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
//$this->_formula1 = ...; //$this->_formula1 = ...;
} }
function setCol($col, $row1, $row2, $incell = true) function setCol($col, $row1, $row2, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
//$this->_formula1 = ...; //$this->_formula1 = ...;
} }
}*/ }*/
?> ?>

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@
/** /**
* @class PGTStorageDB * @class PGTStorageDB
* The PGTStorageDB class is a class for PGT database storage. An instance of * The PGTStorageDB class is a class for PGT database storage. An instance of
* this class is returned by CASClient::SetPGTStorageDB(). * this class is returned by CASClient::SetPGTStorageDB().
* *
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr> * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
@@ -17,174 +17,174 @@
class PGTStorageDB extends PGTStorage class PGTStorageDB extends PGTStorage
{ {
/** /**
* @addtogroup internalPGTStorageDB * @addtogroup internalPGTStorageDB
* @{ * @{
*/ */
/** /**
* a string representing a PEAR DB URL to connect to the database. Written by * a string representing a PEAR DB URL to connect to the database. Written by
* PGTStorageDB::PGTStorageDB(), read by getURL(). * PGTStorageDB::PGTStorageDB(), read by getURL().
* *
* @hideinitializer * @hideinitializer
* @private * @private
*/ */
var $_url=''; var $_url='';
/** /**
* This method returns the PEAR DB URL to use to connect to the database. * This method returns the PEAR DB URL to use to connect to the database.
* *
* @return a PEAR DB URL * @return a PEAR DB URL
* *
* @private * @private
*/ */
function getURL() function getURL()
{ {
return $this->_url; return $this->_url;
} }
/** /**
* The handle of the connection to the database where PGT's are stored. Written by * The handle of the connection to the database where PGT's are stored. Written by
* PGTStorageDB::init(), read by getLink(). * PGTStorageDB::init(), read by getLink().
* *
* @hideinitializer * @hideinitializer
* @private * @private
*/ */
var $_link = null; var $_link = null;
/** /**
* This method returns the handle of the connection to the database where PGT's are * This method returns the handle of the connection to the database where PGT's are
* stored. * stored.
* *
* @return a handle of connection. * @return a handle of connection.
* *
* @private * @private
*/ */
function getLink() function getLink()
{ {
return $this->_link; return $this->_link;
} }
/** /**
* The name of the table where PGT's are stored. Written by * The name of the table where PGT's are stored. Written by
* PGTStorageDB::PGTStorageDB(), read by getTable(). * PGTStorageDB::PGTStorageDB(), read by getTable().
* *
* @hideinitializer * @hideinitializer
* @private * @private
*/ */
var $_table = ''; var $_table = '';
/** /**
* This method returns the name of the table where PGT's are stored. * This method returns the name of the table where PGT's are stored.
* *
* @return the name of a table. * @return the name of a table.
* *
* @private * @private
*/ */
function getTable() function getTable()
{ {
return $this->_table; return $this->_table;
} }
// ######################################################################## // ########################################################################
// DEBUGGING // DEBUGGING
// ######################################################################## // ########################################################################
/** /**
* This method returns an informational string giving the type of storage * This method returns an informational string giving the type of storage
* used by the object (used for debugging purposes). * used by the object (used for debugging purposes).
* *
* @return an informational string. * @return an informational string.
* @public * @public
*/ */
function getStorageType() function getStorageType()
{ {
return "database"; return "database";
} }
/** /**
* This method returns an informational string giving informations on the * This method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes). * parameters of the storage.(used for debugging purposes).
* *
* @public * @public
*/ */
function getStorageInfo() function getStorageInfo()
{ {
return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\''; return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
} }
// ######################################################################## // ########################################################################
// CONSTRUCTOR // CONSTRUCTOR
// ######################################################################## // ########################################################################
/** /**
* The class constructor, called by CASClient::SetPGTStorageDB(). * The class constructor, called by CASClient::SetPGTStorageDB().
* *
* @param $cas_parent the CASClient instance that creates the object. * @param $cas_parent the CASClient instance that creates the object.
* @param $user the user to access the data with * @param $user the user to access the data with
* @param $password the user's password * @param $password the user's password
* @param $database_type the type of the database hosting the data * @param $database_type the type of the database hosting the data
* @param $hostname the server hosting the database * @param $hostname the server hosting the database
* @param $port the port the server is listening on * @param $port the port the server is listening on
* @param $database the name of the database * @param $database the name of the database
* @param $table the name of the table storing the data * @param $table the name of the table storing the data
* *
* @public * @public
*/ */
function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table) function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
{ {
phpCAS::traceBegin(); phpCAS::traceBegin();
// call the ancestor's constructor // call the ancestor's constructor
$this->PGTStorage($cas_parent); $this->PGTStorage($cas_parent);
if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE; if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME; if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT; if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE; if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE; if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
// build and store the PEAR DB URL // build and store the PEAR DB URL
$this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database; $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
// XXX should use setURL and setTable // XXX should use setURL and setTable
phpCAS::traceEnd(); phpCAS::traceEnd();
}
// ########################################################################
// INITIALIZATION
// ########################################################################
/**
* This method is used to initialize the storage. Halts on error.
*
* @public
*/
function init()
{
phpCAS::traceBegin();
// if the storage has already been initialized, return immediatly
if ( $this->isInitialized() )
return;
// call the ancestor's method (mark as initialized)
parent::init();
//include phpDB library (the test was introduced in release 0.4.8 for
//the integration into Tikiwiki).
if (!class_exists('DB')) {
include_once('DB.php');
}
// try to connect to the database
$this->_link = DB::connect($this->getURL());
if ( DB::isError($this->_link) ) {
phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
}
var_dump($this->_link);
phpCAS::traceBEnd();
} }
/** @} */ // ########################################################################
// INITIALIZATION
// ########################################################################
/**
* This method is used to initialize the storage. Halts on error.
*
* @public
*/
function init()
{
phpCAS::traceBegin();
// if the storage has already been initialized, return immediatly
if ( $this->isInitialized() )
return;
// call the ancestor's method (mark as initialized)
parent::init();
//include phpDB library (the test was introduced in release 0.4.8 for
//the integration into Tikiwiki).
if (!class_exists('DB')) {
include_once('DB.php');
}
// try to connect to the database
$this->_link = DB::connect($this->getURL());
if ( DB::isError($this->_link) ) {
phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
}
var_dump($this->_link);
phpCAS::traceBEnd();
}
/** @} */
} }
?> ?>

View File

@@ -7,7 +7,7 @@
/** /**
* @class PGTStorageFile * @class PGTStorageFile
* The PGTStorageFile class is a class for PGT file storage. An instance of * The PGTStorageFile class is a class for PGT file storage. An instance of
* this class is returned by CASClient::SetPGTStorageFile(). * this class is returned by CASClient::SetPGTStorageFile().
* *
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr> * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
@@ -17,233 +17,233 @@
class PGTStorageFile extends PGTStorage class PGTStorageFile extends PGTStorage
{ {
/** /**
* @addtogroup internalPGTStorageFile * @addtogroup internalPGTStorageFile
* @{ * @{
*/ */
/** /**
* a string telling where PGT's should be stored on the filesystem. Written by * a string telling where PGT's should be stored on the filesystem. Written by
* PGTStorageFile::PGTStorageFile(), read by getPath(). * PGTStorageFile::PGTStorageFile(), read by getPath().
* *
* @private * @private
*/ */
var $_path; var $_path;
/** /**
* This method returns the name of the directory where PGT's should be stored * This method returns the name of the directory where PGT's should be stored
* on the filesystem. * on the filesystem.
* *
* @return the name of a directory (with leading and trailing '/') * @return the name of a directory (with leading and trailing '/')
* *
* @private * @private
*/ */
function getPath() function getPath()
{ {
return $this->_path; return $this->_path;
} }
/** /**
* a string telling the format to use to store PGT's (plain or xml). Written by * a string telling the format to use to store PGT's (plain or xml). Written by
* PGTStorageFile::PGTStorageFile(), read by getFormat(). * PGTStorageFile::PGTStorageFile(), read by getFormat().
* *
* @private * @private
*/ */
var $_format; var $_format;
/** /**
* This method returns the format to use when storing PGT's on the filesystem. * This method returns the format to use when storing PGT's on the filesystem.
* *
* @return a string corresponding to the format used (plain or xml). * @return a string corresponding to the format used (plain or xml).
* *
* @private * @private
*/ */
function getFormat() function getFormat()
{ {
return $this->_format; return $this->_format;
} }
// ######################################################################## // ########################################################################
// DEBUGGING // DEBUGGING
// ######################################################################## // ########################################################################
/** /**
* This method returns an informational string giving the type of storage * This method returns an informational string giving the type of storage
* used by the object (used for debugging purposes). * used by the object (used for debugging purposes).
* *
* @return an informational string. * @return an informational string.
* @public * @public
*/ */
function getStorageType() function getStorageType()
{ {
return "file"; return "file";
} }
/** /**
* This method returns an informational string giving informations on the * This method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes). * parameters of the storage.(used for debugging purposes).
* *
* @return an informational string. * @return an informational string.
* @public * @public
*/ */
function getStorageInfo() function getStorageInfo()
{ {
return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\''; return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
} }
// ######################################################################## // ########################################################################
// CONSTRUCTOR // CONSTRUCTOR
// ######################################################################## // ########################################################################
/** /**
* The class constructor, called by CASClient::SetPGTStorageFile(). * The class constructor, called by CASClient::SetPGTStorageFile().
* *
* @param $cas_parent the CASClient instance that creates the object. * @param $cas_parent the CASClient instance that creates the object.
* @param $format the format used to store the PGT's (`plain' and `xml' allowed). * @param $format the format used to store the PGT's (`plain' and `xml' allowed).
* @param $path the path where the PGT's should be stored * @param $path the path where the PGT's should be stored
* *
* @public * @public
*/ */
function PGTStorageFile($cas_parent,$format,$path) function PGTStorageFile($cas_parent,$format,$path)
{ {
phpCAS::traceBegin(); phpCAS::traceBegin();
// call the ancestor's constructor // call the ancestor's constructor
$this->PGTStorage($cas_parent); $this->PGTStorage($cas_parent);
if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT; if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH; if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
// check that the path is an absolute path // check that the path is an absolute path
if (getenv("OS")=="Windows_NT"){ if (getenv("OS")=="Windows_NT"){
if (!preg_match('`^[a-zA-Z]:`', $path)) {
phpCAS::error('an absolute path is needed for PGT storage to file');
}
}
else
{
if ( $path[0] != '/' ) {
phpCAS::error('an absolute path is needed for PGT storage to file');
}
// store the path (with a leading and trailing '/') if (!preg_match('`^[a-zA-Z]:`', $path)) {
$path = preg_replace('|[/]*$|','/',$path); phpCAS::error('an absolute path is needed for PGT storage to file');
$path = preg_replace('|^[/]*|','/',$path); }
}
}
$this->_path = $path; else
// check the format and store it {
switch ($format) {
case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN: if ( $path[0] != '/' ) {
case CAS_PGT_STORAGE_FILE_FORMAT_XML: phpCAS::error('an absolute path is needed for PGT storage to file');
$this->_format = $format; }
break;
default: // store the path (with a leading and trailing '/')
phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)'); $path = preg_replace('|[/]*$|','/',$path);
} $path = preg_replace('|^[/]*|','/',$path);
phpCAS::traceEnd(); }
$this->_path = $path;
// check the format and store it
switch ($format) {
case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
case CAS_PGT_STORAGE_FILE_FORMAT_XML:
$this->_format = $format;
break;
default:
phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
}
phpCAS::traceEnd();
} }
// ######################################################################## // ########################################################################
// INITIALIZATION // INITIALIZATION
// ######################################################################## // ########################################################################
/** /**
* This method is used to initialize the storage. Halts on error. * This method is used to initialize the storage. Halts on error.
* *
* @public * @public
*/ */
function init() function init()
{ {
phpCAS::traceBegin(); phpCAS::traceBegin();
// if the storage has already been initialized, return immediatly // if the storage has already been initialized, return immediatly
if ( $this->isInitialized() ) if ( $this->isInitialized() )
return; return;
// call the ancestor's method (mark as initialized) // call the ancestor's method (mark as initialized)
parent::init(); parent::init();
phpCAS::traceEnd(); phpCAS::traceEnd();
} }
// ######################################################################## // ########################################################################
// PGT I/O // PGT I/O
// ######################################################################## // ########################################################################
/** /**
* This method returns the filename corresponding to a PGT Iou. * This method returns the filename corresponding to a PGT Iou.
* *
* @param $pgt_iou the PGT iou. * @param $pgt_iou the PGT iou.
* *
* @return a filename * @return a filename
* @private * @private
*/ */
function getPGTIouFilename($pgt_iou) function getPGTIouFilename($pgt_iou)
{ {
phpCAS::traceBegin(); phpCAS::traceBegin();
$filename = $this->getPath().$pgt_iou.'.'.$this->getFormat(); $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
phpCAS::traceEnd($filename); phpCAS::traceEnd($filename);
return $filename; return $filename;
}
/**
* This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
* warning on error.
*
* @param $pgt the PGT
* @param $pgt_iou the PGT iou
*
* @public
*/
function write($pgt,$pgt_iou)
{
phpCAS::traceBegin();
$fname = $this->getPGTIouFilename($pgt_iou);
if ( $f=fopen($fname,"w") ) {
if ( fputs($f,$pgt) === FALSE ) {
phpCAS::error('could not write PGT to `'.$fname.'\'');
}
fclose($f);
} else {
phpCAS::error('could not open `'.$fname.'\'');
}
phpCAS::traceEnd();
} }
/** /**
* This method reads a PGT corresponding to a PGT Iou and deletes the * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
* corresponding file. * warning on error.
* *
* @param $pgt_iou the PGT iou * @param $pgt the PGT
* * @param $pgt_iou the PGT iou
* @return the corresponding PGT, or FALSE on error *
* * @public
* @public */
*/ function write($pgt,$pgt_iou)
function read($pgt_iou)
{ {
phpCAS::traceBegin(); phpCAS::traceBegin();
$pgt = FALSE; $fname = $this->getPGTIouFilename($pgt_iou);
$fname = $this->getPGTIouFilename($pgt_iou); if ( $f=fopen($fname,"w") ) {
if ( !($f=fopen($fname,"r")) ) { if ( fputs($f,$pgt) === FALSE ) {
phpCAS::trace('could not open `'.$fname.'\''); phpCAS::error('could not write PGT to `'.$fname.'\'');
} else { }
if ( ($pgt=fgets($f)) === FALSE ) { fclose($f);
phpCAS::trace('could not read PGT from `'.$fname.'\''); } else {
} phpCAS::error('could not open `'.$fname.'\'');
fclose($f); }
} phpCAS::traceEnd();
// delete the PGT file
@unlink($fname);
phpCAS::traceEnd($pgt);
return $pgt;
} }
/** @} */ /**
* This method reads a PGT corresponding to a PGT Iou and deletes the
* corresponding file.
*
* @param $pgt_iou the PGT iou
*
* @return the corresponding PGT, or FALSE on error
*
* @public
*/
function read($pgt_iou)
{
phpCAS::traceBegin();
$pgt = FALSE;
$fname = $this->getPGTIouFilename($pgt_iou);
if ( !($f=fopen($fname,"r")) ) {
phpCAS::trace('could not open `'.$fname.'\'');
} else {
if ( ($pgt=fgets($f)) === FALSE ) {
phpCAS::trace('could not read PGT from `'.$fname.'\'');
}
fclose($f);
}
// delete the PGT file
@unlink($fname);
phpCAS::traceEnd($pgt);
return $pgt;
}
/** @} */
} }
?> ?>

View File

@@ -17,172 +17,172 @@
class PGTStorage class PGTStorage
{ {
/** /**
* @addtogroup internalPGTStorage * @addtogroup internalPGTStorage
* @{ * @{
*/ */
// ######################################################################## // ########################################################################
// CONSTRUCTOR // CONSTRUCTOR
// ######################################################################## // ########################################################################
/** /**
* The constructor of the class, should be called only by inherited classes. * The constructor of the class, should be called only by inherited classes.
* *
* @param $cas_parent the CASclient instance that creates the current object. * @param $cas_parent the CASclient instance that creates the current object.
* *
* @protected * @protected
*/ */
function PGTStorage($cas_parent) function PGTStorage($cas_parent)
{ {
phpCAS::traceBegin(); phpCAS::traceBegin();
if ( !$cas_parent->isProxy() ) { if ( !$cas_parent->isProxy() ) {
phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy');
} }
phpCAS::traceEnd(); phpCAS::traceEnd();
} }
// ######################################################################## // ########################################################################
// DEBUGGING // DEBUGGING
// ######################################################################## // ########################################################################
/** /**
* This virtual method returns an informational string giving the type of storage * This virtual method returns an informational string giving the type of storage
* used by the object (used for debugging purposes). * used by the object (used for debugging purposes).
* *
* @public * @public
*/ */
function getStorageType() function getStorageType()
{ {
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
} }
/** /**
* This virtual method returns an informational string giving informations on the * This virtual method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes). * parameters of the storage.(used for debugging purposes).
* *
* @public * @public
*/ */
function getStorageInfo() function getStorageInfo()
{ {
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
} }
// ######################################################################## // ########################################################################
// ERROR HANDLING // ERROR HANDLING
// ######################################################################## // ########################################################################
/**
* string used to store an error message. Written by PGTStorage::setErrorMessage(),
* read by PGTStorage::getErrorMessage().
*
* @hideinitializer
* @private
* @deprecated not used.
*/
var $_error_message=FALSE;
/** /**
* This method sets en error message, which can be read later by * string used to store an error message. Written by PGTStorage::setErrorMessage(),
* PGTStorage::getErrorMessage(). * read by PGTStorage::getErrorMessage().
* *
* @param $error_message an error message * @hideinitializer
* * @private
* @protected * @deprecated not used.
* @deprecated not used. */
*/ var $_error_message=FALSE;
function setErrorMessage($error_message)
/**
* This method sets en error message, which can be read later by
* PGTStorage::getErrorMessage().
*
* @param $error_message an error message
*
* @protected
* @deprecated not used.
*/
function setErrorMessage($error_message)
{ {
$this->_error_message = $error_message; $this->_error_message = $error_message;
} }
/** /**
* This method returns an error message set by PGTStorage::setErrorMessage(). * This method returns an error message set by PGTStorage::setErrorMessage().
* *
* @return an error message when set by PGTStorage::setErrorMessage(), FALSE * @return an error message when set by PGTStorage::setErrorMessage(), FALSE
* otherwise. * otherwise.
* *
* @public * @public
* @deprecated not used. * @deprecated not used.
*/ */
function getErrorMessage() function getErrorMessage()
{ {
return $this->_error_message; return $this->_error_message;
} }
// ######################################################################## // ########################################################################
// INITIALIZATION // INITIALIZATION
// ######################################################################## // ########################################################################
/** /**
* a boolean telling if the storage has already been initialized. Written by * a boolean telling if the storage has already been initialized. Written by
* PGTStorage::init(), read by PGTStorage::isInitialized(). * PGTStorage::init(), read by PGTStorage::isInitialized().
* *
* @hideinitializer * @hideinitializer
* @private * @private
*/ */
var $_initialized = FALSE; var $_initialized = FALSE;
/** /**
* This method tells if the storage has already been intialized. * This method tells if the storage has already been intialized.
* *
* @return a boolean * @return a boolean
* *
* @protected * @protected
*/ */
function isInitialized() function isInitialized()
{ {
return $this->_initialized; return $this->_initialized;
} }
/** /**
* This virtual method initializes the object. * This virtual method initializes the object.
* *
* @protected * @protected
*/ */
function init() function init()
{ {
$this->_initialized = TRUE; $this->_initialized = TRUE;
} }
// ######################################################################## // ########################################################################
// PGT I/O // PGT I/O
// ######################################################################## // ########################################################################
/** /**
* This virtual method stores a PGT and its corresponding PGT Iuo. * This virtual method stores a PGT and its corresponding PGT Iuo.
* @note Should never be called. * @note Should never be called.
* *
* @param $pgt the PGT * @param $pgt the PGT
* @param $pgt_iou the PGT iou * @param $pgt_iou the PGT iou
* *
* @protected * @protected
*/ */
function write($pgt,$pgt_iou) function write($pgt,$pgt_iou)
{ {
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
} }
/** /**
* This virtual method reads a PGT corresponding to a PGT Iou and deletes * This virtual method reads a PGT corresponding to a PGT Iou and deletes
* the corresponding storage entry. * the corresponding storage entry.
* @note Should never be called. * @note Should never be called.
* *
* @param $pgt_iou the PGT iou * @param $pgt_iou the PGT iou
* *
* @protected * @protected
*/ */
function read($pgt_iou) function read($pgt_iou)
{ {
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
} }
/** @} */ /** @} */
} }
// include specific PGT storage classes // include specific PGT storage classes
include_once(dirname(__FILE__).'/pgt-file.php'); include_once(dirname(__FILE__).'/pgt-file.php');
include_once(dirname(__FILE__).'/pgt-db.php'); include_once(dirname(__FILE__).'/pgt-db.php');
?> ?>

File diff suppressed because it is too large Load Diff

View File

@@ -38,240 +38,240 @@ function domxml_new_doc($version) {return new php4DOMDocument('');}
function domxml_open_file($filename) {return new php4DOMDocument($filename);} function domxml_open_file($filename) {return new php4DOMDocument($filename);}
function domxml_open_mem($str) function domxml_open_mem($str)
{ {
$dom=new php4DOMDocument(''); $dom=new php4DOMDocument('');
$dom->myDOMNode->loadXML($str); $dom->myDOMNode->loadXML($str);
return $dom; return $dom;
} }
function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->query($eval_str,$contextnode);} function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->query($eval_str,$contextnode);}
function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);} function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);}
class php4DOMAttr extends php4DOMNode class php4DOMAttr extends php4DOMNode
{ {
function php4DOMAttr($aDOMAttr) {$this->myDOMNode=$aDOMAttr;} function php4DOMAttr($aDOMAttr) {$this->myDOMNode=$aDOMAttr;}
function Name() {return $this->myDOMNode->name;} function Name() {return $this->myDOMNode->name;}
function Specified() {return $this->myDOMNode->specified;} function Specified() {return $this->myDOMNode->specified;}
function Value() {return $this->myDOMNode->value;} function Value() {return $this->myDOMNode->value;}
} }
class php4DOMDocument extends php4DOMNode class php4DOMDocument extends php4DOMNode
{ {
function php4DOMDocument($filename='') function php4DOMDocument($filename='')
{ {
$this->myDOMNode=new DOMDocument(); $this->myDOMNode=new DOMDocument();
if ($filename!='') $this->myDOMNode->load($filename); if ($filename!='') $this->myDOMNode->load($filename);
} }
function create_attribute($name,$value) function create_attribute($name,$value)
{ {
$myAttr=$this->myDOMNode->createAttribute($name); $myAttr=$this->myDOMNode->createAttribute($name);
$myAttr->value=$value; $myAttr->value=$value;
return new php4DOMAttr($myAttr,$this); return new php4DOMAttr($myAttr,$this);
} }
function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);} function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);}
function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);} function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);}
function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);} function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);}
function create_text_node($content) {return new php4DOMNode($this->myDOMNode->createTextNode($content),$this);} function create_text_node($content) {return new php4DOMNode($this->myDOMNode->createTextNode($content),$this);}
function document_element() {return new php4DOMElement($this->myDOMNode->documentElement,$this);} function document_element() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
function dump_file($filename,$compressionmode=false,$format=false) {return $this->myDOMNode->save($filename);} function dump_file($filename,$compressionmode=false,$format=false) {return $this->myDOMNode->save($filename);}
function dump_mem($format=false,$encoding=false) {return $this->myDOMNode->saveXML();} function dump_mem($format=false,$encoding=false) {return $this->myDOMNode->saveXML();}
function get_element_by_id($id) {return new php4DOMElement($this->myDOMNode->getElementById($id),$this);} function get_element_by_id($id) {return new php4DOMElement($this->myDOMNode->getElementById($id),$this);}
function get_elements_by_tagname($name) function get_elements_by_tagname($name)
{ {
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name); $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i)) while ($node=$myDOMNodeList->item($i))
{ {
$nodeSet[]=new php4DOMElement($node,$this); $nodeSet[]=new php4DOMElement($node,$this);
$i++; $i++;
} }
return $nodeSet; return $nodeSet;
} }
function html_dump_mem() {return $this->myDOMNode->saveHTML();} function html_dump_mem() {return $this->myDOMNode->saveHTML();}
function root() {return new php4DOMElement($this->myDOMNode->documentElement,$this);} function root() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
} }
class php4DOMElement extends php4DOMNode class php4DOMElement extends php4DOMNode
{ {
function get_attribute($name) {return $this->myDOMNode->getAttribute($name);} function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
function get_elements_by_tagname($name) function get_elements_by_tagname($name)
{ {
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name); $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i)) while ($node=$myDOMNodeList->item($i))
{ {
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument); $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
$i++; $i++;
} }
return $nodeSet; return $nodeSet;
} }
function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);} function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);} function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
function set_attribute($name,$value) {return $this->myDOMNode->setAttribute($name,$value);} function set_attribute($name,$value) {return $this->myDOMNode->setAttribute($name,$value);}
function tagname() {return $this->myDOMNode->tagName;} function tagname() {return $this->myDOMNode->tagName;}
} }
class php4DOMNode class php4DOMNode
{ {
var $myDOMNode; var $myDOMNode;
var $myOwnerDocument; var $myOwnerDocument;
function php4DOMNode($aDomNode,$aOwnerDocument) function php4DOMNode($aDomNode,$aOwnerDocument)
{ {
$this->myDOMNode=$aDomNode; $this->myDOMNode=$aDomNode;
$this->myOwnerDocument=$aOwnerDocument; $this->myOwnerDocument=$aOwnerDocument;
} }
function __get($name) function __get($name)
{ {
if ($name=='type') return $this->myDOMNode->nodeType; if ($name=='type') return $this->myDOMNode->nodeType;
elseif ($name=='tagname') return $this->myDOMNode->tagName; elseif ($name=='tagname') return $this->myDOMNode->tagName;
elseif ($name=='content') return $this->myDOMNode->textContent; elseif ($name=='content') return $this->myDOMNode->textContent;
else else
{ {
$myErrors=debug_backtrace(); $myErrors=debug_backtrace();
trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE); trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
return false; return false;
} }
} }
function append_child($newnode) {return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);} function append_child($newnode) {return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);}
function append_sibling($newnode) {return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);} function append_sibling($newnode) {return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);}
function attributes() function attributes()
{ {
$myDOMNodeList=$this->myDOMNode->attributes; $myDOMNodeList=$this->myDOMNode->attributes;
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i)) while ($node=$myDOMNodeList->item($i))
{ {
$nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument); $nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
$i++; $i++;
} }
return $nodeSet; return $nodeSet;
} }
function child_nodes() function child_nodes()
{ {
$myDOMNodeList=$this->myDOMNode->childNodes; $myDOMNodeList=$this->myDOMNode->childNodes;
$nodeSet=array(); $nodeSet=array();
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i)) while ($node=$myDOMNodeList->item($i))
{ {
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument); $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
$i++; $i++;
} }
return $nodeSet; return $nodeSet;
} }
function children() {return $this->child_nodes();} function children() {return $this->child_nodes();}
function clone_node($deep=false) {return new php4DOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);} function clone_node($deep=false) {return new php4DOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);}
function first_child() {return new php4DOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);} function first_child() {return new php4DOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);}
function get_content() {return $this->myDOMNode->textContent;} function get_content() {return $this->myDOMNode->textContent;}
function has_attributes() {return $this->myDOMNode->hasAttributes();} function has_attributes() {return $this->myDOMNode->hasAttributes();}
function has_child_nodes() {return $this->myDOMNode->hasChildNodes();} function has_child_nodes() {return $this->myDOMNode->hasChildNodes();}
function insert_before($newnode,$refnode) {return new php4DOMElement($this->myDOMNode->insertBefore($newnode->myDOMNode,$refnode->myDOMNode),$this->myOwnerDocument);} function insert_before($newnode,$refnode) {return new php4DOMElement($this->myDOMNode->insertBefore($newnode->myDOMNode,$refnode->myDOMNode),$this->myOwnerDocument);}
function is_blank_node() function is_blank_node()
{ {
$myDOMNodeList=$this->myDOMNode->childNodes; $myDOMNodeList=$this->myDOMNode->childNodes;
$i=0; $i=0;
if (isset($myDOMNodeList)) if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i)) while ($node=$myDOMNodeList->item($i))
{ {
if (($node->nodeType==XML_ELEMENT_NODE)|| if (($node->nodeType==XML_ELEMENT_NODE)||
(($node->nodeType==XML_TEXT_NODE)&&!preg_match('/^([[:cntrl:]]|[[:space:]])*$/',$node->nodeValue))) (($node->nodeType==XML_TEXT_NODE)&&!preg_match('/^([[:cntrl:]]|[[:space:]])*$/',$node->nodeValue)))
return false; return false;
$i++; $i++;
} }
return true; return true;
} }
function last_child() {return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);} function last_child() {return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
function new_child($name,$content) function new_child($name,$content)
{ {
$mySubNode=$this->myDOMNode->ownerDocument->createElement($name); $mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content)); $mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content));
$this->myDOMNode->appendChild($mySubNode); $this->myDOMNode->appendChild($mySubNode);
return new php4DOMElement($mySubNode,$this->myOwnerDocument); return new php4DOMElement($mySubNode,$this->myOwnerDocument);
} }
function next_sibling() {return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);} function next_sibling() {return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
function node_name() {return $this->myDOMNode->localName;} function node_name() {return $this->myDOMNode->localName;}
function node_type() {return $this->myDOMNode->nodeType;} function node_type() {return $this->myDOMNode->nodeType;}
function node_value() {return $this->myDOMNode->nodeValue;} function node_value() {return $this->myDOMNode->nodeValue;}
function owner_document() {return $this->myOwnerDocument;} function owner_document() {return $this->myOwnerDocument;}
function parent_node() {return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);} function parent_node() {return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
function prefix() {return $this->myDOMNode->prefix;} function prefix() {return $this->myDOMNode->prefix;}
function previous_sibling() {return new php4DOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);} function previous_sibling() {return new php4DOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);}
function remove_child($oldchild) {return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);} function remove_child($oldchild) {return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);}
function replace_child($oldnode,$newnode) {return new php4DOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$newnode->myDOMNode),$this->myOwnerDocument);} function replace_child($oldnode,$newnode) {return new php4DOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$newnode->myDOMNode),$this->myOwnerDocument);}
function set_content($text) function set_content($text)
{ {
if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE)) if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE))
$this->myDOMNode->removeChild($this->myDOMNode->firstChild); $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text)); return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));
} }
} }
class php4DOMNodelist class php4DOMNodelist
{ {
var $myDOMNodelist; var $myDOMNodelist;
var $nodeset; var $nodeset;
function php4DOMNodelist($aDOMNodelist,$aOwnerDocument) function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
{ {
$this->myDOMNodelist=$aDOMNodelist; $this->myDOMNodelist=$aDOMNodelist;
$this->nodeset=array(); $this->nodeset=array();
$i=0; $i=0;
if (isset($this->myDOMNodelist)) if (isset($this->myDOMNodelist))
while ($node=$this->myDOMNodelist->item($i)) while ($node=$this->myDOMNodelist->item($i))
{ {
$this->nodeset[]=new php4DOMElement($node,$aOwnerDocument); $this->nodeset[]=new php4DOMElement($node,$aOwnerDocument);
$i++; $i++;
} }
} }
} }
class php4DOMXPath class php4DOMXPath
{ {
var $myDOMXPath; var $myDOMXPath;
var $myOwnerDocument; var $myOwnerDocument;
function php4DOMXPath($dom_document) function php4DOMXPath($dom_document)
{ {
$this->myOwnerDocument=$dom_document; $this->myOwnerDocument=$dom_document;
$this->myDOMXPath=new DOMXPath($dom_document->myDOMNode); $this->myDOMXPath=new DOMXPath($dom_document->myDOMNode);
} }
function query($eval_str,$contextnode) function query($eval_str,$contextnode)
{ {
if (isset($contextnode)) return new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument); if (isset($contextnode)) return new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument);
else return new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument); else return new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument);
} }
function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);} function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
} }
if (extension_loaded('xsl')) if (extension_loaded('xsl'))
{//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/ {//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));} function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));}
function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);} function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));} function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
class php4DomXsltStylesheet class php4DomXsltStylesheet
{ {
var $myxsltProcessor; var $myxsltProcessor;
function php4DomXsltStylesheet($dom_document) function php4DomXsltStylesheet($dom_document)
{ {
$this->myxsltProcessor=new xsltProcessor(); $this->myxsltProcessor=new xsltProcessor();
$this->myxsltProcessor->importStyleSheet($dom_document); $this->myxsltProcessor->importStyleSheet($dom_document);
} }
function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false) function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
{ {
foreach ($xslt_parameters as $param=>$value) foreach ($xslt_parameters as $param=>$value)
$this->myxsltProcessor->setParameter('',$param,$value); $this->myxsltProcessor->setParameter('',$param,$value);
$myphp4DOMDocument=new php4DOMDocument(); $myphp4DOMDocument=new php4DOMDocument();
$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode); $myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
return $myphp4DOMDocument; return $myphp4DOMDocument;
} }
function result_dump_file($dom_document,$filename) function result_dump_file($dom_document,$filename)
{ {
$html=$dom_document->myDOMNode->saveHTML(); $html=$dom_document->myDOMNode->saveHTML();
file_put_contents($filename,$html); file_put_contents($filename,$html);
return $html; return $html;
} }
function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();} function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
} }
} }
?> ?>

View File

@@ -2,26 +2,26 @@
/** /**
* @file languages/spanish.php * @file languages/spanish.php
* @author Iván-Benjamín García Torà <ivaniclixx AT gmail DOT com> * @author Iván-Benjamín García Torà <ivaniclixx AT gmail DOT com
* @sa @link internalLang Internationalization @endlink * @sa @link internalLang Internationalization @endlink
* @ingroup internalLang * @ingroup internalLang
*/ */
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> 'usant servidor', => 'usant servidor',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> 'Autentificació CAS necessària!', => 'Autentificació CAS necessària!',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> 'Sortida de CAS necessària!', => 'Sortida de CAS necessària!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Ja hauria d\ haver estat redireccionat al servidor CAS. Feu click <a href="%s">aquí</a> per a continuar.', => 'Ja hauria d\ haver estat redireccionat al servidor CAS. Feu click <a href="%s">aquí</a> per a continuar.',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> 'Autentificació CAS fallida!', => 'Autentificació CAS fallida!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>No estàs autentificat.</p><p>Pots tornar a intentar-ho fent click <a href="%s">aquí</a>.</p><p>Si el problema persisteix hauría de contactar amb l\'<a href="mailto:%s">administrador d\'aquest llocc</a>.</p>', => '<p>No estàs autentificat.</p><p>Pots tornar a intentar-ho fent click <a href="%s">aquí</a>.</p><p>Si el problema persisteix hauría de contactar amb l\'<a href="mailto:%s">administrador d\'aquest llocc</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'El servei `<b>%s</b>\' no està disponible (<b>%s</b>).' => 'El servei `<b>%s</b>\' no està disponible (<b>%s</b>).'
); );
?> ?>

View File

@@ -8,20 +8,20 @@
*/ */
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> 'using server', => 'using server',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> 'CAS Authentication wanted!', => 'CAS Authentication wanted!',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> 'CAS logout wanted!', => 'CAS logout wanted!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'You should already have been redirected to the CAS server. Click <a href="%s">here</a> to continue.', => 'You should already have been redirected to the CAS server. Click <a href="%s">here</a> to continue.',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> 'CAS Authentication failed!', => 'CAS Authentication failed!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>You were not authenticated.</p><p>You may submit your request again by clicking <a href="%s">here</a>.</p><p>If the problem persists, you may contact <a href="mailto:%s">the administrator of this site</a>.</p>', => '<p>You were not authenticated.</p><p>You may submit your request again by clicking <a href="%s">here</a>.</p><p>If the problem persists, you may contact <a href="mailto:%s">the administrator of this site</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'The service `<b>%s</b>\' is not available (<b>%s</b>).' => 'The service `<b>%s</b>\' is not available (<b>%s</b>).'
); );
?> ?>

View File

@@ -8,20 +8,20 @@
*/ */
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> 'utilisant le serveur', => 'utilisant le serveur',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> 'Authentication CAS nécessaire&nbsp;!', => 'Authentication CAS n<EFBFBD>cessaire&nbsp;!',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> 'Déconnexion demandée&nbsp;!', => 'D<EFBFBD>connexion demand<EFBFBD>e&nbsp;!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Vous auriez du etre redirigé(e) vers le serveur CAS. Cliquez <a href="%s">ici</a> pour continuer.', => 'Vous auriez du etre redirig<EFBFBD>(e) vers le serveur CAS. Cliquez <a href="%s">ici</a> pour continuer.',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> 'Authentification CAS infructueuse&nbsp;!', => 'Authentification CAS infructueuse&nbsp;!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>Vous n\'avez pas été authentifié(e).</p><p>Vous pouvez soumettre votre requete à nouveau en cliquant <a href="%s">ici</a>.</p><p>Si le problème persiste, vous pouvez contacter <a href="mailto:%s">l\'administrateur de ce site</a>.</p>', => '<p>Vous n\'avez pas <EFBFBD>t<EFBFBD> authentifi<EFBFBD>(e).</p><p>Vous pouvez soumettre votre requete <EFBFBD> nouveau en cliquant <a href="%s">ici</a>.</p><p>Si le probl<EFBFBD>me persiste, vous pouvez contacter <a href="mailto:%s">l\'administrateur de ce site</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'Le service `<b>%s</b>\' est indisponible (<b>%s</b>)' => 'Le service `<b>%s</b>\' est indisponible (<b>%s</b>)'
); );

View File

@@ -8,20 +8,20 @@
*/ */
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> 'via Server', => 'via Server',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> 'CAS Authentifizierung erforderlich!', => 'CAS Authentifizierung erforderlich!',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> 'CAS Abmeldung!', => 'CAS Abmeldung!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'eigentlich h&auml;ten Sie zum CAS Server weitergeleitet werden sollen. Dr&uuml;cken Sie <a href="%s">hier</a> um fortzufahren.', => 'eigentlich h&auml;ten Sie zum CAS Server weitergeleitet werden sollen. Dr&uuml;cken Sie <a href="%s">hier</a> um fortzufahren.',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> 'CAS Anmeldung fehlgeschlagen!', => 'CAS Anmeldung fehlgeschlagen!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>Sie wurden nicht angemeldet.</p><p>Um es erneut zu versuchen klicken Sie <a href="%s">hier</a>.</p><p>Wenn das Problem bestehen bleibt, kontkatieren Sie den <a href="mailto:%s">Administrator</a> dieser Seite.</p>', => '<p>Sie wurden nicht angemeldet.</p><p>Um es erneut zu versuchen klicken Sie <a href="%s">hier</a>.</p><p>Wenn das Problem bestehen bleibt, kontkatieren Sie den <a href="mailto:%s">Administrator</a> dieser Seite.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'Der Dienst `<b>%s</b>\' ist nicht verf&uuml;gbar (<b>%s</b>).' => 'Der Dienst `<b>%s</b>\' ist nicht verf&uuml;gbar (<b>%s</b>).'
); );
?> ?>

View File

@@ -8,20 +8,20 @@
*/ */
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> '÷ñçóéìïðïéåßôáé ï åîõðçñåôçôÞò', => '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> 'Áðáéôåßôáé ç ôáõôïðïßçóç CAS!', => '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CAS!',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> 'Áðáéôåßôáé ç áðïóýíäåóç áðü CAS!', => '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> CAS!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Èá Ýðñåðå íá åß÷áôå áíáêáôåõèõíèåß óôïí åîõðçñåôçôÞ CAS. ÊÜíôå êëßê <a href="%s">åäþ</a> ãéá íá óõíå÷ßóåôå.', => '<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CAS. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <a href="%s"><EFBFBD><EFBFBD><EFBFBD></a> <EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> 'Ç ôáõôïðïßçóç CAS áðÝôõ÷å!', => '<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CAS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>Äåí ôáõôïðïéçèÞêáôå.</p><p>Ìðïñåßôå íá îáíáðñïóðáèÞóåôå, êÜíïíôáò êëßê <a href="%s">åäþ</a>.</p><p>Åáí ôï ðñüâëçìá åðéìåßíåé, åëÜôå óå åðáöÞ ìå ôïí <a href="mailto:%s">äéá÷åéñéóôÞ</a>.</p>', => '<p><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.</p><p><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <a href="%s"><EFBFBD><EFBFBD><EFBFBD></a>.</p><p><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> <a href="mailto:%s"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'Ç õðçñåóßá `<b>%s</b>\' äåí åßíáé äéáèÝóéìç (<b>%s</b>).' => '<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> `<b>%s</b>\' <EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<b>%s</b>).'
); );
?> ?>

View File

@@ -3,25 +3,25 @@
/** /**
* @file languages/japanese.php * @file languages/japanese.php
* @author fnorif (fnorif@yahoo.co.jp) * @author fnorif (fnorif@yahoo.co.jp)
* *
* Now Encoding is EUC-JP and LF * Now Encoding is EUC-JP and LF
**/ **/
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> 'using server', => 'using server',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> 'CASによる認証を行います', => 'CAS<EFBFBD>ˤ<EFBFBD><EFBFBD>ǧ<EFBFBD>ڤ<EFBFBD>Ԥ<EFBFBD><EFBFBD>ޤ<EFBFBD>',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> 'CASからログアウトします!', => 'CAS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<3F><><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>ޤ<EFBFBD>!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'CASサーバに行く必要があります。自動的に転送されない場合は <a href="%s">こちら</a> をクリックして続行します。', => 'CAS<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ф˹Ԥ<EFBFBD>ɬ<EFBFBD>פ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ưŪ<EFBFBD><EFBFBD>ž<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <a href="%s"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></a> <20>򥯥<EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD>Ԥ<EFBFBD><D4A4>ޤ<EFBFBD><DEA4><EFBFBD>',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> 'CASによる認証に失敗しました', => 'CAS<EFBFBD>ˤ<EFBFBD><EFBFBD>ǧ<EFBFBD>ڤ˼<EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>認証できませんでした.</p><p>もう一度リクエストを送信する場合は<a href="%s">こちら</a>をクリック.</p><p>問題が解決しない場合は <a href="mailto:%s">このサイトの管理者</a>に問い合わせてください.</p>', => '<p>ǧ<EFBFBD>ڤǤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>.</p><p><3E><EFBFBD><E2A4A6><EFBFBD>٥<D9A5><EAA5AF><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><a href="%s"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></a><3E>򥯥<EFBFBD>å<EFBFBD>.</p><p><3E><><EFBFBD><EFBFBD><EAA4AC><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD> <a href="mailto:%s"><3E><><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>Ȥδ<C8A4><CEB4><EFBFBD><EFBFBD></a><3E><><EFBFBD><EFBFBD><E4A4A4><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'サービス `<b>%s</b>\' は利用できません (<b>%s</b>).' => '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӥ<EFBFBD> `<b>%s</b>\' <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѤǤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD> (<b>%s</b>).'
); );
?> ?>

View File

@@ -2,26 +2,26 @@
/** /**
* @file languages/spanish.php * @file languages/spanish.php
* @author Iván-Benjamín García Torà <ivaniclixx AT gmail DOT com> * @author Iván-Benjamín García Torà <ivaniclixx AT gmail DOT com
* @sa @link internalLang Internationalization @endlink * @sa @link internalLang Internationalization @endlink
* @ingroup internalLang * @ingroup internalLang
*/ */
$this->_strings = array( $this->_strings = array(
CAS_STR_USING_SERVER CAS_STR_USING_SERVER
=> 'usando servidor', => 'usando servidor',
CAS_STR_AUTHENTICATION_WANTED CAS_STR_AUTHENTICATION_WANTED
=> '¡Autentificación CAS necesaria!', => '¡Autentificación CAS necesaria!',
CAS_STR_LOGOUT CAS_STR_LOGOUT
=> '¡Salida CAS necesaria!', => '¡Salida CAS necesaria!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Ya debería haber sido redireccionado al servidor CAS. Haga click <a href="%s">aquí</a> para continuar.', => 'Ya debería haber sido redireccionado al servidor CAS. Haga click <a href="%s">aquí</a> para continuar.',
CAS_STR_AUTHENTICATION_FAILED CAS_STR_AUTHENTICATION_FAILED
=> '¡Autentificación CAS fallida!', => '¡Autentificación CAS fallida!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>No estás autentificado.</p><p>Puedes volver a intentarlo haciendo click <a href="%s">aquí</a>.</p><p>Si el problema persiste debería contactar con el <a href="mailto:%s">administrador de este sitio</a>.</p>', => '<p>No estás autentificado.</p><p>Puedes volver a intentarlo haciendo click <a href="%s">aquí</a>.</p><p>Si el problema persiste debería contactar con el <a href="mailto:%s">administrador de este sitio</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE CAS_STR_SERVICE_UNAVAILABLE
=> 'El servicio `<b>%s</b>\' no está disponible (<b>%s</b>).' => 'El servicio `<b>%s</b>\' no está disponible (<b>%s</b>).'
); );
?> ?>

View File

@@ -1,8 +1,8 @@
<?php <?php
# #
# PHPZip v1.2 by Sext (sext@neud.net) 2002-11-18 # PHPZip v1.2 by Sext (sext@neud.net) 2002-11-18
# (Changed: 2003-03-01) # (Changed: 2003-03-01)
# #
# Makes zip archive # Makes zip archive
# #
# Based on "Zip file creation class", uses zLib # Based on "Zip file creation class", uses zLib
@@ -12,72 +12,72 @@
class PHPZip class PHPZip
{ {
function Zip($dir, $zipfilename) function Zip($dir, $zipfilename)
{ {
if (@function_exists('gzcompress')) if (@function_exists('gzcompress'))
{ {
$curdir = getcwd(); $curdir = getcwd();
if (is_array($dir)) if (is_array($dir))
{ {
$filelist = $dir; $filelist = $dir;
} }
else else
{ {
$filelist = $this -> GetFileList($dir); $filelist = $this -> GetFileList($dir);
} }
if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
else chdir($curdir);
if (count($filelist)>0) if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
{ else chdir($curdir);
foreach($filelist as $filename)
{
if (is_file($filename))
{
$fd = fopen ($filename, "r");
$content = @fread ($fd, filesize ($filename));
fclose ($fd);
if (is_array($dir)) $filename = basename($filename); if (count($filelist)>0)
$this -> addFile($content, $filename); {
} foreach($filelist as $filename)
} {
$out = $this -> file(); if (is_file($filename) && basename($filename)!='.htaccess')
{
$fd = fopen ($filename, "r");
$content = @fread ($fd, filesize ($filename));
fclose ($fd);
chdir($curdir); if (is_array($dir)) $filename = basename($filename);
$fp = fopen($zipfilename, "w"); $this -> addFile($content, $filename);
fwrite($fp, $out, strlen($out)); }
fclose($fp); }
} $out = $this -> file();
return 1;
}
else return 0;
}
function GetFileList($dir) chdir($curdir);
{ $fp = fopen($zipfilename, "w");
$file=Array(); fwrite($fp, $out, strlen($out));
if (file_exists($dir)) fclose($fp);
{ }
$args = func_get_args(); return 1;
if(isset($args[1])) {$pref = $args[1];} else {$pref="";} }
else return 0;
$dh = opendir($dir); }
while($files = readdir($dh))
{ function GetFileList($dir)
if (($files!=".")&&($files!="..")) {
{ $file=Array();
if (!is_dir($dir.$files)) if (file_exists($dir))
{ {
$file[]=$pref.$files; $args = func_get_args();
} if(isset($args[1])) {$pref = $args[1];} else {$pref="";}
}
} $dh = opendir($dir);
closedir($dh); while($files = readdir($dh))
} {
return $file; if (($files!=".")&&($files!=".."))
} {
if (!is_dir($dir.$files))
{
$file[]=$pref.$files;
}
}
}
closedir($dh);
}
return $file;
}
var $datasec = array(); var $datasec = array();
var $ctrl_dir = array(); var $ctrl_dir = array();
@@ -98,16 +98,16 @@ class PHPZip
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) { if ($timearray['year'] < 1980) {
$timearray['year'] = 1980; $timearray['year'] = 1980;
$timearray['mon'] = 1; $timearray['mon'] = 1;
$timearray['mday'] = 1; $timearray['mday'] = 1;
$timearray['hours'] = 0; $timearray['hours'] = 0;
$timearray['minutes'] = 0; $timearray['minutes'] = 0;
$timearray['seconds'] = 0; $timearray['seconds'] = 0;
} // end if } // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method } // end of the 'unix2DosTime()' method
@@ -126,9 +126,9 @@ class PHPZip
$dtime = dechex($this->unix2DosTime($time)); $dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7] $hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1]; . '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";'); eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04"; $fr = "\x50\x4b\x03\x04";
@@ -204,68 +204,68 @@ class PHPZip
$ctrldir = implode('', $this -> ctrl_dir); $ctrldir = implode('', $this -> ctrl_dir);
return return
$data . $data .
$ctrldir . $ctrldir .
$this -> eof_ctrl_dir . $this -> eof_ctrl_dir .
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length "\x00\x00"; // .zip file comment length
} // end of the 'file()' method } // end of the 'file()' method
// This comes from http://de.tikiwiki.org/xref-BRANCH-1-9/nav.html?lib/sheet/include/org/apicnet/io/archive/CZip.php.source.html // This comes from http://de.tikiwiki.org/xref-BRANCH-1-9/nav.html?lib/sheet/include/org/apicnet/io/archive/CZip.php.source.html
function extract($dir, $zipfilename){ function extract($dir, $zipfilename){
if (function_exists("zip_open")) { if (function_exists("zip_open")) {
$this->createDir($dir); $this->createDir($dir);
$zip = zip_open($zipfilename); $zip = zip_open($zipfilename);
if ($zip) { if ($zip) {
while ($zip_entry = zip_read($zip)) { while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry, "r")) { if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
// LimeSurvey Only extract first dir for the moment // LimeSurvey Only extract first dir for the moment
if ( ! preg_match("/(\/)/i", zip_entry_name($zip_entry))) if ( ! preg_match("/(\/)/i", zip_entry_name($zip_entry)))
{ {
$this->createFile($dir."/".zip_entry_name($zip_entry), $buf,zip_entry_filesize($zip_entry)); $this->createFile($dir."/".zip_entry_name($zip_entry), $buf,zip_entry_filesize($zip_entry));
} }
zip_entry_close($zip_entry); zip_entry_close($zip_entry);
} }
} }
zip_close($zip); zip_close($zip);
} }
else else
{ {
return "Error:OpenZip"; return "Error:OpenZip";
} }
} }
return 'OK'; return 'OK';
} }
function createDir($dir){ function createDir($dir){
if (preg_match("/(\/$)/", $dir)) @mkdir (substr($dir, 0, strlen($dir) - 1)); if (preg_match("/(\/$)/", $dir)) @mkdir (substr($dir, 0, strlen($dir) - 1));
else @mkdir ($dir); else @mkdir ($dir);
} }
// This comes from http://fr.php.net/zip
function createFile($file, $data, $size){
//$file = new File($file, TRUE);
//if ($file->exists()) {
// $file->delFile();
// $file->createFile();
//}
//$file->writeData($data);
if (is_file($file))
{ // This comes from http://fr.php.net/zip
unlink($file); function createFile($file, $data, $size){
} //$file = new File($file, TRUE);
$fopen = fopen($file, "w"); //if ($file->exists()) {
fwrite($fopen,$data,$size); // $file->delFile();
} // $file->createFile();
//}
//$file->writeData($data);
if (is_file($file))
{
unlink($file);
}
$fopen = fopen($file, "w");
fwrite($fopen,$data,$size);
}
} // end of the 'PHPZip' class } // end of the 'PHPZip' class
?> ?>

View File

@@ -173,6 +173,7 @@ class queXMLPDF extends TCPDF {
protected $style = "<style> protected $style = "<style>
td.questionTitle {font-weight:bold; font-size:12pt;} td.questionTitle {font-weight:bold; font-size:12pt;}
td.questionText {font-weight:bold; font-size:12pt;} td.questionText {font-weight:bold; font-size:12pt;}
td.vasLabel {font-weright:bold; font-size:10pt; text-align:center;}
td.questionHelp {font-weight:normal; text-align:right; font-style:italic; font-size:8pt;} td.questionHelp {font-weight:normal; text-align:right; font-style:italic; font-size:8pt;}
td.questionHelpAfter {text-align:center; font-weight:bold; font-size:10pt;} td.questionHelpAfter {text-align:center; font-weight:bold; font-size:10pt;}
td.responseAboveText {font-weight:normal; font-style:normal; text-align:left; font-size:12pt;} td.responseAboveText {font-weight:normal; font-style:normal; text-align:left; font-size:12pt;}
@@ -1021,21 +1022,17 @@ class queXMLPDF extends TCPDF {
$stmp = array(); $stmp = array();
$sl = $this->numberToLetter($scount); $sl = $this->numberToLetter($scount);
$stmp['title'] = "Section " . $sl; $stmp['title'] = "Section " . $sl;
$stmp['info'] = "";
$stmp['text'] = "";
foreach ($s->sectionInfo as $sitmp) foreach ($s->sectionInfo as $sitmp)
{ {
if ($sitmp->position == 'title') if ($sitmp->position == 'title')
{ {
if (!isset($stmp['text']))
$stmp['text'] = "";
$stmp['text'] .= $sitmp->text; $stmp['text'] .= $sitmp->text;
} }
if ($sitmp->position == 'before' || $sitmp->position == 'during') if ($sitmp->position == 'before' || $sitmp->position == 'during')
{ {
if (!isset($stmp['info']))
$stmp['info'] = "";
$stmp['info'] .= $sitmp->text . "<br/>"; $stmp['info'] .= $sitmp->text . "<br/>";
} }
} }
@@ -1047,12 +1044,10 @@ class queXMLPDF extends TCPDF {
$rstmp = array(); $rstmp = array();
$qtmp['title'] = $sl . $qcount . "."; $qtmp['title'] = $sl . $qcount . ".";
$qtmp['text'] = "";
foreach ($qu->text as $ttmp) foreach ($qu->text as $ttmp)
{ {
if (!isset($qtmp['text']))
$qtmp['text'] = "";
//Add a new line if we aren't at the end //Add a new line if we aren't at the end
if ($ttmp != end($qu->text)){ $qtmp['text'] .= "<br/>"; } if ($ttmp != end($qu->text)){ $qtmp['text'] .= "<br/>"; }
@@ -1080,11 +1075,9 @@ class queXMLPDF extends TCPDF {
foreach ($qu->subQuestion as $sq) foreach ($qu->subQuestion as $sq)
{ {
$sqtmp = array(); $sqtmp = array();
$sqtmp['text'] = "";
foreach ($sq->text as $ttmp) foreach ($sq->text as $ttmp)
{ {
if (!isset($sqtmp['text']))
$sqtmp['text'] = "";
$sqtmp['text'] .= $ttmp; $sqtmp['text'] .= $ttmp;
} }
$sqtmp['varname'] = $sq['varName']; $sqtmp['varname'] = $sq['varName'];
@@ -1136,8 +1129,9 @@ class queXMLPDF extends TCPDF {
else if (isset($r->vas)) else if (isset($r->vas))
{ {
$rtmp['type'] = 'vas'; $rtmp['type'] = 'vas';
$rtmp['width'] = current($r->vas->length); $rtmp['width'] = 100;
$rtmp['text'] = current($r->vas->label); $rtmp['labelleft'] = current($r->vas->labelleft);
$rtmp['labelright'] = current($r->vas->labelright);
} }
$rstmp['response'] = $rtmp; $rstmp['response'] = $rtmp;
$qtmp['responses'][] = $rstmp; $qtmp['responses'][] = $rstmp;
@@ -1299,7 +1293,7 @@ class queXMLPDF extends TCPDF {
$this->drawMatrixTextVertical($subquestions,$response['width'],$text,$bgtype); $this->drawMatrixTextVertical($subquestions,$response['width'],$text,$bgtype);
break; break;
case 'vas': case 'vas':
$this->drawMatrixVas($subquestions,$text); $this->drawMatrixVas($subquestions,$text,$response['labelleft'],$response['labelright']);
break; break;
} }
@@ -1340,7 +1334,7 @@ class queXMLPDF extends TCPDF {
break; break;
case 'vas': case 'vas':
$this->addBoxGroup(1,$varname,$rtext,strlen($this->vasIncrements)); $this->addBoxGroup(1,$varname,$rtext,strlen($this->vasIncrements));
$this->drawVas($response['text']); $this->drawVas("",$response['labelleft'],$response['labelright']);
break; break;
} }
@@ -1403,16 +1397,19 @@ class queXMLPDF extends TCPDF {
* *
* @param array $subquestions The subquestions containing text and varname * @param array $subquestions The subquestions containing text and varname
* @param string|bool $parenttext The question text of the parent or false if not specified * @param string|bool $parenttext The question text of the parent or false if not specified
* @param string $labelleft The left hand side label
* @param string $labelright The right hand side label
* *
* @author Adam Zammit <adam.zammit@acspri.org.au> * @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2010-09-20 * @since 2010-09-20
*/ */
protected function drawMatrixVas($subquestions,$parenttext = false) protected function drawMatrixVas($subquestions,$parenttext = false,$labelleft,$labelright)
{ {
$c = count($subquestions); $c = count($subquestions);
$width = strlen($this->vasIncrements); $width = strlen($this->vasIncrements);
$heading = true;
for ($i = 0; $i < $c; $i++) for ($i = 0; $i < $c; $i++)
{ {
$s = $subquestions[$i]; $s = $subquestions[$i];
@@ -1425,13 +1422,15 @@ class queXMLPDF extends TCPDF {
$this->drawVas($s['text']); $this->drawVas($s['text'],$labelleft,$labelright,$heading);
$currentY = $this->GetY(); $currentY = $this->GetY();
//Insert a gap here //Insert a gap here
$this->Rect($this->getMainPageX(),$this->GetY(),$this->getMainPageWidth(),$this->subQuestionLineSpacing,'F',array(),$this->backgroundColourQuestion); $this->Rect($this->getMainPageX(),$this->GetY(),$this->getMainPageWidth(),$this->subQuestionLineSpacing,'F',array(),$this->backgroundColourQuestion);
$this->SetY($currentY + $this->subQuestionLineSpacing,false); $this->SetY($currentY + $this->subQuestionLineSpacing,false);
$heading = false;
} }
@@ -1459,7 +1458,7 @@ class queXMLPDF extends TCPDF {
//Align to skip column on right //Align to skip column on right
$this->SetX(($this->getPageWidth() - $this->getMainPageX() - $this->skipColumnWidth - $this->longTextResponseWidth),false); $this->SetX(($this->getPageWidth() - $this->getMainPageX() - $this->skipColumnWidth - $this->longTextResponseWidth),false);
//Add to pay layout //Add to pay layout
$this->addBox($this->GetX(),$this->GetY(),$this->GetX() + $this->longTextResponseWidth, $this->GetX() + $height); $this->addBox($this->GetX(),$this->GetY(),$this->GetX() + $this->longTextResponseWidth, $this->GetY() + $height);
$this->SetDrawColor($this->lineColour[0],$this->lineColour[1],$this->lineColour[2]); $this->SetDrawColor($this->lineColour[0],$this->lineColour[1],$this->lineColour[2]);
$this->Cell($this->longTextResponseWidth,$height,'',$border,0,'',true,'',0,false,'T','C'); $this->Cell($this->longTextResponseWidth,$height,'',$border,0,'',true,'',0,false,'T','C');
$currentY = $currentY + $height; $currentY = $currentY + $height;
@@ -1470,22 +1469,40 @@ class queXMLPDF extends TCPDF {
/** /**
* Draw a VAS * Draw a VAS
* *
* @param mixed $text The label for the VAS if any * @param string $text The text of this item
* @param string $labelleft The left hand side label
* @param string $labelright The right hand side label
* @param bool $heading Whether to draw a heading or not
* *
* @author Adam Zammit <adam.zammit@acspri.org.au> * @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2010-09-20 * @since 2010-09-20
*/ */
protected function drawVas($text) protected function drawVas($text, $labelleft,$labelright,$heading = true)
{ {
$textwidth = $this->getMainPageWidth() - $this->skipColumnWidth - ($this->vasLength + ($this->vasLineWidth * 2.0)) - 2;
$this->setBackground('question');
if ($heading)
{
//draw heading
$lwidth = 20;
$slwidth = $textwidth - ($lwidth / 2);
$gapwidth = ($this->vasLength + ($this->vasLineWidth * 2.0)) - $lwidth;
$html = "<table><tr><td width=\"{$slwidth}mm\"></td><td width=\"{$lwidth}mm\" class=\"vasLabel\">$labelleft</td><td width=\"{$gapwidth}mm\"></td><td width=\"{$lwidth}mm\" class=\"vasLabel\">$labelright</td></tr></table>";
$this->writeHTMLCell($this->getMainPageWidth(), 0, $this->getMainPageX(), $this->GetY(), $this->style . $html,0,1,true,false);
}
$currentY = $this->GetY(); $currentY = $this->GetY();
$textwidth = $this->getMainPageWidth() - $this->skipColumnWidth - ($this->vasLength + ($this->vasLineWidth * 2.0)) - 2;
$html = "<table><tr><td width=\"{$textwidth}mm\" class=\"responseText\">$text</td><td></td></tr></table>"; $html = "<table><tr><td width=\"{$textwidth}mm\" class=\"responseText\">$text</td><td></td></tr></table>";
$textwidth += 2; $textwidth += 2;
$this->setBackground('question');
$this->writeHTMLCell($this->getMainPageWidth(), $this->vasAreaHeight, $this->getMainPageX(), $this->GetY(), $this->style . $html,0,1,true,false); $this->writeHTMLCell($this->getMainPageWidth(), $this->vasAreaHeight, $this->getMainPageX(), $this->GetY(), $this->style . $html,0,1,true,false);
@@ -1979,7 +1996,7 @@ class queXMLPDF extends TCPDF {
$html = "<span class=\"sectionTitle\">$title:</span>&nbsp;<span class=\"sectionDescription\">$desc</span>"; $html = "<span class=\"sectionTitle\">$title:</span>&nbsp;<span class=\"sectionDescription\">$desc</span>";
if ($info) if ($info && !empty($info))
$html .= "<div class=\"sectionInfo\">$info</div>"; $html .= "<div class=\"sectionInfo\">$info</div>";
$this->setBackground('section'); $this->setBackground('section');

View File

@@ -1,3 +1,57 @@
5.9.011 (2010-11-02)
- Bug item #3101486 "Bug Fix for image loading" was fixed.
5.9.010 (2010-10-27)
- Support for CSS properties 'border-spacing' and 'padding' for tables were added.
- Several language files were added.
5.9.009 (2010-10-21)
- HTML text alignment was improved to include the case of RTL text on LTR direction and LTR text on RTL direction.
5.9.008 (2010-10-21)
- Bug item #3091502 "Bookmark oddity" was fixed.
- HTML internal links now accepts page number and Y position.
- The method write1DBarcode() was improved to accept separate horizontal and vertical padding (see example n. 27).
5.9.007 (2010-10-20)
- Method adjustCellPadding() was fixed to handle bad input.
5.9.006 (2010-10-19)
- Support for AES 256 bit encryption was added (see example n. 16).
- Method getNumLines() was fixed for the empty string case.
5.9.005 (2010-10-18)
- Method addPageRegion() was changed to accept regions starting exactly from the top of the page.
5.9.004 (2010-10-18)
- A bug related to annotations was fixed.
- The file unicode_data.php was canged to encapsulate all data in a class.
- The file htmlcolors.php was changed to remove the global variable.
5.9.003 (2010-10-15)
- Support for no-write page regions was added. Check the example n. 64 and new methods setPageRegions(), addPageRegion(), getPageRegions(), removePageRegion().
- A bug on Right-To-Left alignment was fixed.
5.9.002 (2010-10-08)
- Cell method was improved to preserve the font stretching and spacing values when using the $stretch parameter (see example n. 4).
5.9.001 (2010-10-07)
- The problem of blank page for nobr table higher than a single page was fixed.
5.9.000 (2010-10-06)
- Support for text stretching and spacing (kerning) was added, see example n. 63 and methods setFontStretching(), getFontStretching(), setFontSpacing(), getFontSpacing().
- Support for CSS properties 'font-stretch' and 'letter-spacing' was added (see example n. 63).
- The cMargin state was replaced by cell_padding array that can be set/get using setCellPadding() and getCellPadding() methods.
- Methods getCellPaddings() and setCellPaddings() were added to fine tune cell paddings (see example n. 5).
- Methods getCellMargins() and setCellMargins() were added to fine tune cell margins (see example n. 5).
- Method write1DBarcode() was improved to permit custom labels (see example n. 27).
- Method ImagePngAlpha() now includes support for ImageMagick to improve performances.
- XObject Template support was extended to support Multicell(), writeHTML() and writeHTMLCell() methods.
- The signature of getNumLines() and getStringHeight() methods is changed.
- Example n. 57 was updated.
// -------------------------------------------------------------------
5.8.034 (2010-09-27) 5.8.034 (2010-09-27)
- A bug related to SetFont on XObject templates was fixed. - A bug related to SetFont on XObject templates was fixed.

View File

@@ -1,85 +1,86 @@
TCPDF - README TCPDF - README
============================================================ ============================================================
I WISH TO IMPROVE AND EXPAND TCPDF BUT I NEED YOUR SUPPORT. I WISH TO IMPROVE AND EXPAND TCPDF BUT I NEED YOUR SUPPORT.
PLEASE MAKE A DONATION: PLEASE MAKE A DONATION:
http://sourceforge.net/donate/index.php?group_id=128076 http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 5.8.034 Version: 5.9.011
Release date: 2010-09-27 Release date: 2010-11-02
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2010: Copyright (c) 2002-2010:
Nicola Asuni Nicola Asuni
Tecnick.com s.r.l. Tecnick.com s.r.l.
Via Della Pace, 11 Via Della Pace, 11
09044 Quartucciu (CA) 09044 Quartucciu (CA)
ITALY ITALY
www.tecnick.com www.tecnick.com
URLs: URLs:
http: www.tcpdf.org http: www.tcpdf.org
http: www.sourceforge.net/projects/tcpdf http: www.sourceforge.net/projects/tcpdf
Description: Description:
TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions. TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions.
Main Features: Main Features:
* no external libraries are required for the basic functions; * no external libraries are required for the basic functions;
* all standard page formats, custom page formats, custom margins and units of measure; * all standard page formats, custom page formats, custom margins and units of measure;
* UTF-8 Unicode and Right-To-Left languages; * UTF-8 Unicode and Right-To-Left languages;
* TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts; * TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
* font subsetting; * font subsetting;
* methods to publish some XHTML + CSS code, Javascript and Forms; * methods to publish some XHTML + CSS code, Javascript and Forms;
* images, graphic (geometric figures) and transformation methods; * images, graphic (geometric figures) and transformation methods;
* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http: www.imagemagick.org/www/formats.html) * supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http: www.imagemagick.org/www/formats.html)
* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417; * 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;
* Grayscale, RGB, CMYK, Spot Colors and Transparencies; * Grayscale, RGB, CMYK, Spot Colors and Transparencies;
* automatic page header and footer management; * automatic page header and footer management;
* document encryption and digital signature certifications; * document encryption up to 256 bit and digital signature certifications;
* transactions to UNDO commands; * transactions to UNDO commands;
* PDF annotations, including links, text and file attachments; * PDF annotations, including links, text and file attachments;
* text rendering modes (fill, stroke and clipping); * text rendering modes (fill, stroke and clipping);
* multiple columns mode; * multiple columns mode;
* bookmarks and table of content; * no-write page regions;
* text hyphenation; * bookmarks and table of content;
* automatic page break, line break and text alignments including justification; * text hyphenation;
* automatic page numbering and page groups; * text stretching and spacing (tracking/kerning);
* move and delete pages; * automatic page break, line break and text alignments including justification;
* page compression (requires php-zlib extension); * automatic page numbering and page groups;
* XOBject Templates; * move and delete pages;
* page compression (requires php-zlib extension);
* XOBject Templates;
Installation (full instructions on http: www.tcpdf.org):
1. copy the folder on your Web server Installation (full instructions on http: www.tcpdf.org):
2. set your installation path and other parameters on the config/tcpdf_config.php 1. copy the folder on your Web server
3. call the examples/example_001.php page with your browser to see an example 2. set your installation path and other parameters on the config/tcpdf_config.php
3. call the examples/example_001.php page with your browser to see an example
Source Code Documentation:
doc/index.html Source Code Documentation:
doc/index.html
For Additional Documentation:
http: www.tcpdf.org For Additional Documentation:
http: www.tcpdf.org
License
Copyright (C) 2002-2010 Nicola Asuni - Tecnick.com S.r.l. License
Copyright (C) 2002-2010 Nicola Asuni - Tecnick.com S.r.l.
TCPDF is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as TCPDF is free software: you can redistribute it and/or modify it
published by the Free Software Foundation, either version 3 of the under the terms of the GNU Lesser General Public License as
License, or (at your option) any later version. published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
TCPDF is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of TCPDF is distributed in the hope that it will be useful, but
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. WITHOUT ANY WARRANTY; without even the implied warranty of
See the GNU Lesser General Public License for more details. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TCPDF. If not, see <http://www.gnu.org/licenses/>. You should have received a copy of the GNU Lesser General Public License
along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
See LICENSE.TXT file for more information.
See LICENSE.TXT file for more information.
============================================================
============================================================

View File

@@ -94,8 +94,10 @@ Hebrew (iw)
Polish (pl) Polish (pl)
----------- -----------
Pchnąć w tę łódź jeża lub ośm skrzyń fig Pchnąć w tę łódź jeża lub osiem skrzyń fig
(= To push a hedgehog or eight bins of figs in this boat) (= To push a hedgehog or eight bins of figs in this boat)
Zażółć gęślą jaźń
Russian (ru) Russian (ru)
------------ ------------

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : afr.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Afrikaans
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Afrikaans
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Afrikaans
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'af';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'bladsy';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : ara.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Arabic
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Arabic
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Arabic
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = 'ar';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'صفحة';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : aze.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Azerbaijani
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Azerbaijani
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Azerbaijani
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'az';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'səhifə';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : bel.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Basque
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Basque
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Basque
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'be';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'старонкі';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -2,13 +2,14 @@
//============================================================+ //============================================================+
// File name : eng.php // File name : eng.php
// Begin : 2004-03-03 // Begin : 2004-03-03
// Last Update : 2010-08-08 // Last Update : 2010-10-26
// //
// Description : Language module for TCPDF // Description : Language module for TCPDF
// (contains translated texts) // (contains translated texts)
// // Brazilian
//
// Author: Nicola Asuni // Author: Nicola Asuni
// //
// (c) Copyright: // (c) Copyright:
// Nicola Asuni // Nicola Asuni
// Tecnick.com s.r.l. // Tecnick.com s.r.l.
@@ -22,15 +23,15 @@
/** /**
* TCPDF language file (contains translated texts). * TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @abstract TCPDF language file. * @abstract TCPDF language file: Brazilian
* @author Nicola Asuni * @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net * @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL * @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03 * @since 2004-03-03
*/ */
// ENGLISH // Brazilian
global $l; global $l;
$l = Array(); $l = Array();
@@ -45,5 +46,5 @@ $l['a_meta_language'] = 'pt';
$l['w_page'] = 'página'; $l['w_page'] = 'página';
//============================================================+ //============================================================+
// END OF FILE // END OF FILE
//============================================================+ //============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : cat.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Catalan
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Catalan
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Catalan
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ca';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'pàgina';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : ces.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Czech
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Czech
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Czech
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'cs';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'stránky';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : chi.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Chinese (Simplified)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Chinese (Simplified)
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Chinese (Simplified)
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'cn';
// TRANSLATIONS --------------------------------------
$l['w_page'] = '页面';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : urd.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Welsh
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Welsh
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Welsh
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'cy';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'tudalen';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : dan.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Danish
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Danish
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Danish
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'da';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'side';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -2,13 +2,14 @@
//============================================================+ //============================================================+
// File name : eng.php // File name : eng.php
// Begin : 2004-03-03 // Begin : 2004-03-03
// Last Update : 2010-08-08 // Last Update : 2010-10-26
// //
// Description : Language module for TCPDF // Description : Language module for TCPDF
// (contains translated texts) // (contains translated texts)
// // English
//
// Author: Nicola Asuni // Author: Nicola Asuni
// //
// (c) Copyright: // (c) Copyright:
// Nicola Asuni // Nicola Asuni
// Tecnick.com s.r.l. // Tecnick.com s.r.l.
@@ -22,15 +23,15 @@
/** /**
* TCPDF language file (contains translated texts). * TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @abstract TCPDF language file. * @abstract TCPDF language file: English
* @author Nicola Asuni * @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net * @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL * @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03 * @since 2004-03-03
*/ */
// ENGLISH // English
global $l; global $l;
$l = Array(); $l = Array();
@@ -45,5 +46,5 @@ $l['a_meta_language'] = 'en';
$l['w_page'] = 'page'; $l['w_page'] = 'page';
//============================================================+ //============================================================+
// END OF FILE // END OF FILE
//============================================================+ //============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : est.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Estonian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Estonian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Estonian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'et';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'lehekülg';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : eus.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Basque
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Basque
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Basque
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'eu';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'Orrialdearen';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : fra.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// French
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: French
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// French
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'fr';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'page';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -2,13 +2,14 @@
//============================================================+ //============================================================+
// File name : eng.php // File name : eng.php
// Begin : 2004-03-03 // Begin : 2004-03-03
// Last Update : 2010-08-08 // Last Update : 2010-10-26
// //
// Description : Language module for TCPDF // Description : Language module for TCPDF
// (contains translated texts) // (contains translated texts)
// // German
//
// Author: Nicola Asuni // Author: Nicola Asuni
// //
// (c) Copyright: // (c) Copyright:
// Nicola Asuni // Nicola Asuni
// Tecnick.com s.r.l. // Tecnick.com s.r.l.
@@ -22,15 +23,15 @@
/** /**
* TCPDF language file (contains translated texts). * TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @abstract TCPDF language file. * @abstract TCPDF language file: German
* @author Nicola Asuni * @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net * @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL * @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03 * @since 2004-03-03
*/ */
// ENGLISH // German
global $l; global $l;
$l = Array(); $l = Array();
@@ -45,5 +46,5 @@ $l['a_meta_language'] = 'de';
$l['w_page'] = 'seite'; $l['w_page'] = 'seite';
//============================================================+ //============================================================+
// END OF FILE // END OF FILE
//============================================================+ //============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : ind.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Irish
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Irish
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Irish
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ga';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'leathanach';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : glg.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Galician
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Galician
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Galician
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'gl';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'Páxina';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : hat.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Haitian Creole
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Haitian Creole
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Haitian Creole
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ht';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'paj';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : heb.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Hebrew
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Hebrew
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Hebrew
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = 'he';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'מקור:';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : hrv.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Croatian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Croatian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Croatian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'hr';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'stranica';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : hun.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Hungarian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Hungarian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Hungarian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'hu';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'oldal';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : hye.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Armenian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Armenian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Armenian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'hy';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'էջ';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : ind.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Indonesian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Indonesian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Indonesian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'id';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'halaman';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -2,13 +2,14 @@
//============================================================+ //============================================================+
// File name : ita.php // File name : ita.php
// Begin : 2004-03-03 // Begin : 2004-03-03
// Last Update : 2010-08-08 // Last Update : 2010-10-26
// //
// Description : Language module for TCPDF // Description : Language module for TCPDF
// (contains translated texts) // (contains translated texts)
// // Italian
//
// Author: Nicola Asuni // Author: Nicola Asuni
// //
// (c) Copyright: // (c) Copyright:
// Nicola Asuni // Nicola Asuni
// Tecnick.com s.r.l. // Tecnick.com s.r.l.
@@ -22,15 +23,15 @@
/** /**
* TCPDF language file (contains translated texts). * TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @abstract TCPDF language file. * @abstract TCPDF language file: Italian
* @author Nicola Asuni * @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net * @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL * @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03 * @since 2004-03-03
*/ */
// ENGLISH // Italian
global $l; global $l;
$l = Array(); $l = Array();
@@ -45,5 +46,5 @@ $l['a_meta_language'] = 'it';
$l['w_page'] = 'pagina'; $l['w_page'] = 'pagina';
//============================================================+ //============================================================+
// END OF FILE // END OF FILE
//============================================================+ //============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : kat.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Georgian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Georgian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Georgian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ka';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'გვერდი';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : kor.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Korean
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Korean
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Korean
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ko';
// TRANSLATIONS --------------------------------------
$l['w_page'] = '페이지';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : mkd.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Macedonian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Macedonian
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Macedonian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'mk';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'страница';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : mlt.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Maltese
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Maltese
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Maltese
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'mt';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'paġna';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : msa.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Malay
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Malay
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// Malay
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ms';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'laman';
//============================================================+
// END OF FILE
//============================================================+

View File

@@ -0,0 +1,50 @@
<?php
//============================================================+
// File name : dan.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Dutch
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file: Dutch
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2010-10-26
*/
// Dutch
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'nl';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'pagina';
//============================================================+
// END OF FILE
//============================================================+

Some files were not shown because too many files have changed in this diff Show More